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,