- 教程 / 挑战编辑器“新建”时序号没有加 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,
|
||||
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<Props>()
|
||||
@@ -129,7 +128,7 @@ const previewContent = ref("")
|
||||
|
||||
const frame = useTemplateRef<HTMLIFrameElement>("frame")
|
||||
const storageScope = () =>
|
||||
props.persistStorage && taskId.value ? `${user.username}:${taskId.value}` : ""
|
||||
props.storageTaskId ? `${user.username}:${props.storageTaskId}` : ""
|
||||
|
||||
function getContent(forDownload = false) {
|
||||
const scope = storageScope()
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
:html="html"
|
||||
:css="css"
|
||||
:js="js"
|
||||
persist-storage
|
||||
:storage-task-id="taskId"
|
||||
show-code-button
|
||||
clearable
|
||||
@showCode="showCode = true"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
:css="css"
|
||||
:js="js"
|
||||
:asset-base-url="assetBaseUrl"
|
||||
persist-storage
|
||||
:storage-task-id="taskId"
|
||||
/>
|
||||
</template>
|
||||
</n-split>
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user