diff --git a/src/app/(app)/problems/[id]/@Code/page.tsx b/src/app/(app)/problems/[id]/@Code/page.tsx index 9885a41..f150484 100644 --- a/src/app/(app)/problems/[id]/@Code/page.tsx +++ b/src/app/(app)/problems/[id]/@Code/page.tsx @@ -1,11 +1,30 @@ -import { ProblemEditor } from "@/components/problem-editor"; +import { AIProblemEditor } from "@/components/ai-optimized-editor"; +import { useParams } from "next/navigation"; export default function CodePage() { + const params = useParams(); + const problemId = params.id as string; + + const handleOptimize = async () => { + // 这里实现调用AI优化逻辑 + console.log("Optimizing code for problem", problemId); + }; + return (
-
- +
+
+ +
+
); -} +} \ No newline at end of file diff --git a/src/app/(app)/problems/[id]/page.tsx b/src/app/(app)/problems/[id]/page.tsx index 81343f9..3524e9f 100644 --- a/src/app/(app)/problems/[id]/page.tsx +++ b/src/app/(app)/problems/[id]/page.tsx @@ -11,10 +11,8 @@ import { import { Locale } from "@/config/i18n"; import { useEffect, useState } from "react"; import { useTranslations } from "next-intl"; -import { usePathname } from "next/navigation"; import Dockview from "@/components/dockview"; import { useDockviewStore } from "@/stores/dockview"; -import { AIProblemEditor } from "@/components/ai-optimized-editor"; interface ProblemPageProps { locale: Locale; @@ -28,169 +26,123 @@ interface ProblemPageProps { } export default function ProblemPage({ - locale, - Description, - Solutions, - Submissions, - Details, - Code, - Testcase, - Bot, -}: ProblemPageProps) { + locale, + Description, + Solutions, + Submissions, + Details, + Code, + Testcase, + Bot, + }: ProblemPageProps) { const [key, setKey] = useState(0); const { setApi } = useDockviewStore(); const t = useTranslations("ProblemPage"); - const pathname = usePathname(); - const problemId = pathname.split("/").pop(); // 从URL提取problemId - - // AI优化相关状态 - const [showAIEditor, setShowAIEditor] = useState(false); - const [userCode, setUserCode] = useState(`function example() { - // 初始代码 - return "Hello World"; -}`); - - // 修改Code面板内容以包含切换功能 - const CodeWithToggle = ( -
-
- - - {showAIEditor && ( - - )} -
- - {showAIEditor ? ( - - ) : ( - // 原始Code组件保持不变 -
- {Code} -
- )} -
- ); useEffect(() => { setKey((prevKey) => prevKey + 1); }, [locale]); - // 修改Dockview配置:更新Code面板引用 return ( - + ); -} +} \ No newline at end of file