From e47fac1732326657b89cadfc8d1f8a44e4e153d7 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 26 Oct 2026 22:40:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=87=BA=E9=A2=98=E9=A1=B5=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E4=BC=9A=E8=A6=86=E7=9B=96=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E9=81=93=E9=A2=98=EF=BC=9B=E8=87=AA=E7=94=B1=E5=88=9B=E4=BD=9C?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E6=95=B0=E6=8D=AE=E5=AD=98=E5=88=B0=E4=BA=86?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E4=BB=BB=E5=8A=A1=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 教程 / 挑战编辑器“新建”时序号没有加 1(?? 的优先级),而保存按序号更新, 新建后保存会覆盖列表里最后一个任务 - 预览的 localStorage 作用域改由页面传入任务 id;自由创作页用的是局部 taskId, 之前读全局 taskId 会把数据存到上一个打开过的任务名下 Co-Authored-By: Claude Opus 5.5 --- client/src/components/editor/Preview.vue | 7 +++---- client/src/pages/ChallengeDetail.vue | 2 +- client/src/pages/ChallengeEditor.vue | 2 +- client/src/pages/CreationDetail.vue | 2 +- client/src/pages/TutorialEditor.vue | 2 +- client/src/pages/Workspace.vue | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/client/src/components/editor/Preview.vue b/client/src/components/editor/Preview.vue index 4df9f91..a7247a6 100644 --- a/client/src/components/editor/Preview.vue +++ b/client/src/components/editor/Preview.vue @@ -67,7 +67,6 @@ import { listenPreviewStorage, loadPreviewStorage, } from "../../utils/previewStorage" -import { taskId } from "../../store/task" import { user } from "../../store/user" interface Props { @@ -78,8 +77,8 @@ interface Props { submissionId?: string showCodeButton?: boolean clearable?: boolean - // 自己的编辑器:代码里的 localStorage 按“用户 + 任务”存下来,刷新后还在 - persistStorage?: boolean + // 自己的编辑器传当前任务 id:代码里的 localStorage 按“用户 + 任务”存下来,刷新后还在 + storageTaskId?: number } const props = defineProps() @@ -129,7 +128,7 @@ const previewContent = ref("") const frame = useTemplateRef("frame") const storageScope = () => - props.persistStorage && taskId.value ? `${user.username}:${taskId.value}` : "" + props.storageTaskId ? `${user.username}:${props.storageTaskId}` : "" function getContent(forDownload = false) { const scope = storageScope() diff --git a/client/src/pages/ChallengeDetail.vue b/client/src/pages/ChallengeDetail.vue index 29a5a18..cda4fbe 100644 --- a/client/src/pages/ChallengeDetail.vue +++ b/client/src/pages/ChallengeDetail.vue @@ -90,7 +90,7 @@ :css="css" :js="js" :asset-base-url="assetBaseUrl" - persist-storage + :storage-task-id="taskId" show-code-button clearable @showCode="showCode = true" diff --git a/client/src/pages/ChallengeEditor.vue b/client/src/pages/ChallengeEditor.vue index a9f226d..6d5d3eb 100644 --- a/client/src/pages/ChallengeEditor.vue +++ b/client/src/pages/ChallengeEditor.vue @@ -224,7 +224,7 @@ async function getContent() { } function createNew() { - challenge.display = list.value[list.value.length - 1]?.display ?? 0 + 1 + challenge.display = (list.value[list.value.length - 1]?.display ?? 0) + 1 challenge.title = "" challenge.content = "" challenge.score = 0 diff --git a/client/src/pages/CreationDetail.vue b/client/src/pages/CreationDetail.vue index bad1ef0..decdc69 100644 --- a/client/src/pages/CreationDetail.vue +++ b/client/src/pages/CreationDetail.vue @@ -80,7 +80,7 @@ :html="html" :css="css" :js="js" - persist-storage + :storage-task-id="taskId" show-code-button clearable @showCode="showCode = true" diff --git a/client/src/pages/TutorialEditor.vue b/client/src/pages/TutorialEditor.vue index d191e81..ab2306f 100644 --- a/client/src/pages/TutorialEditor.vue +++ b/client/src/pages/TutorialEditor.vue @@ -192,7 +192,7 @@ async function getContent() { } function createNew() { - tutorial.display = list.value[list.value.length - 1]?.display ?? 0 + 1 + tutorial.display = (list.value[list.value.length - 1]?.display ?? 0) + 1 tutorial.title = "" tutorial.content = "" tutorial.is_public = false diff --git a/client/src/pages/Workspace.vue b/client/src/pages/Workspace.vue index 1cb2414..ae21a00 100644 --- a/client/src/pages/Workspace.vue +++ b/client/src/pages/Workspace.vue @@ -14,7 +14,7 @@ :css="css" :js="js" :asset-base-url="assetBaseUrl" - persist-storage + :storage-task-id="taskId" /> @@ -28,7 +28,7 @@ import Preview from "../components/editor/Preview.vue" import TaskPanel from "../components/task/TaskPanel.vue" import { show, panelSize } from "../store/panel" import { html, css, js } from "../store/editors" -import { assetBaseUrl } from "../store/task" +import { assetBaseUrl, taskId } from "../store/task" const { ctrl_s } = useMagicKeys({ passive: false,