- 教程 / 挑战编辑器“新建”时序号没有加 1(?? 的优先级),而保存按序号更新, 新建后保存会覆盖列表里最后一个任务 - 预览的 localStorage 作用域改由页面传入任务 id;自由创作页用的是局部 taskId, 之前读全局 taskId 会把数据存到上一个打开过的任务名下 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ffdfbc2513
commit
e47fac1732
6 files changed
+9
-10
No files matched your search
@@ -67,7 +67,6 @@ import {
|
|||||||
listenPreviewStorage,
|
listenPreviewStorage,
|
||||||
loadPreviewStorage,
|
loadPreviewStorage,
|
||||||
} from "../../utils/previewStorage"
|
} from "../../utils/previewStorage"
|
||||||
import { taskId } from "../../store/task"
|
|
||||||
import { user } from "../../store/user"
|
import { user } from "../../store/user"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -78,8 +77,8 @@ interface Props {
|
|||||||
submissionId?: string
|
submissionId?: string
|
||||||
showCodeButton?: boolean
|
showCodeButton?: boolean
|
||||||
clearable?: boolean
|
clearable?: boolean
|
||||||
// 自己的编辑器:代码里的 localStorage 按“用户 + 任务”存下来,刷新后还在
|
// 自己的编辑器传当前任务 id:代码里的 localStorage 按“用户 + 任务”存下来,刷新后还在
|
||||||
persistStorage?: boolean
|
storageTaskId?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
@@ -129,7 +128,7 @@ const previewContent = ref("")
|
|||||||
|
|
||||||
const frame = useTemplateRef<HTMLIFrameElement>("frame")
|
const frame = useTemplateRef<HTMLIFrameElement>("frame")
|
||||||
const storageScope = () =>
|
const storageScope = () =>
|
||||||
props.persistStorage && taskId.value ? `${user.username}:${taskId.value}` : ""
|
props.storageTaskId ? `${user.username}:${props.storageTaskId}` : ""
|
||||||
|
|
||||||
function getContent(forDownload = false) {
|
function getContent(forDownload = false) {
|
||||||
const scope = storageScope()
|
const scope = storageScope()
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
:css="css"
|
:css="css"
|
||||||
:js="js"
|
:js="js"
|
||||||
:asset-base-url="assetBaseUrl"
|
:asset-base-url="assetBaseUrl"
|
||||||
persist-storage
|
:storage-task-id="taskId"
|
||||||
show-code-button
|
show-code-button
|
||||||
clearable
|
clearable
|
||||||
@showCode="showCode = true"
|
@showCode="showCode = true"
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ async function getContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createNew() {
|
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.title = ""
|
||||||
challenge.content = ""
|
challenge.content = ""
|
||||||
challenge.score = 0
|
challenge.score = 0
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
:html="html"
|
:html="html"
|
||||||
:css="css"
|
:css="css"
|
||||||
:js="js"
|
:js="js"
|
||||||
persist-storage
|
:storage-task-id="taskId"
|
||||||
show-code-button
|
show-code-button
|
||||||
clearable
|
clearable
|
||||||
@showCode="showCode = true"
|
@showCode="showCode = true"
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ async function getContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createNew() {
|
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.title = ""
|
||||||
tutorial.content = ""
|
tutorial.content = ""
|
||||||
tutorial.is_public = false
|
tutorial.is_public = false
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
:css="css"
|
:css="css"
|
||||||
:js="js"
|
:js="js"
|
||||||
:asset-base-url="assetBaseUrl"
|
:asset-base-url="assetBaseUrl"
|
||||||
persist-storage
|
:storage-task-id="taskId"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</n-split>
|
</n-split>
|
||||||
@@ -28,7 +28,7 @@ import Preview from "../components/editor/Preview.vue"
|
|||||||
import TaskPanel from "../components/task/TaskPanel.vue"
|
import TaskPanel from "../components/task/TaskPanel.vue"
|
||||||
import { show, panelSize } from "../store/panel"
|
import { show, panelSize } from "../store/panel"
|
||||||
import { html, css, js } from "../store/editors"
|
import { html, css, js } from "../store/editors"
|
||||||
import { assetBaseUrl } from "../store/task"
|
import { assetBaseUrl, taskId } from "../store/task"
|
||||||
|
|
||||||
const { ctrl_s } = useMagicKeys({
|
const { ctrl_s } = useMagicKeys({
|
||||||
passive: false,
|
passive: false,
|
||||||
|
|||||||
Reference in new issue
Block a user