fix: 批改页 J/K 按键位对调;预览换内容不再进浏览器历史,“后退”能回到作品墙
Deploy / deploy (build, debian, 22) (push) Canceled after 0s

- J 上一个、K 下一个,和面板上的左右箭头一致
- 打开的作品放进地址栏(?sub=):点开记一步历史,J/K 切换只替换,关闭 / Esc 退回那一步
- 所有会换内容的预览 iframe 加 key,换内容时换新的 iframe:在原 iframe 里改 srcdoc 是一次导航,
  会进浏览器历史,“后退”就成了在预览里倒退(批改页切换学生、挑战页改代码都会这样)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-27 09:31:29 +08:00
1 parent 75e20a3ae1
commit 0b3780e0cd
7 files changed
+50 -15

No files matched your search

+5
View File
@@ -46,6 +46,7 @@
ref="frame"
class="iframe"
:sandbox="PREVIEW_SANDBOX"
:key="frameKey"
:srcdoc="previewContent"
></iframe>
</div>
@@ -141,8 +142,12 @@ function getContent(forDownload = false) {
})
}
// 每次内容变了换一个新的 iframe:在同一个 iframe 里改 srcdoc 会进浏览器历史,
// 按“后退”就成了在预览里倒退,而不是离开页面
const frameKey = ref(0)
function preview() {
previewContent.value = getContent()
frameKey.value++
}
function download() {
+1 -1
View File
@@ -61,7 +61,7 @@
@update:show="(v: boolean) => !v && (large = null)"
>
<div v-if="large" class="large">
<iframe :sandbox="PREVIEW_SANDBOX" :srcdoc="docOf(large)"></iframe>
<iframe :key="large.id" :sandbox="PREVIEW_SANDBOX" :srcdoc="docOf(large)"></iframe>
</div>
</n-modal>
</template>
+4 -3
View File
@@ -13,7 +13,7 @@
<Icon icon="lucide:arrow-left" />
</n-button>
</template>
上一个学生(K)
上一个学生(J)
</n-tooltip>
<n-tooltip>
<template #trigger>
@@ -21,7 +21,7 @@
<Icon icon="lucide:arrow-right" />
</n-button>
</template>
下一个学生(J)
下一个学生(K)
</n-tooltip>
</template>
<n-button
@@ -61,7 +61,8 @@
</button>
</div>
<div class="frame">
<iframe :sandbox="PREVIEW_SANDBOX" :srcdoc="doc"></iframe>
<!-- key:换作品时换新的 iframe,不进浏览器历史 -->
<iframe :key="currentId" :sandbox="PREVIEW_SANDBOX" :srcdoc="doc"></iframe>
</div>
<n-flex justify="space-between" align="center" class="meta">
<span class="muted">
@@ -10,6 +10,7 @@
<div v-else-if="current" class="body">
<button class="thumb" title="点击放大看" @click="showLarge = true">
<iframe
:key="current.submission_id"
:sandbox="PREVIEW_SANDBOX"
:srcdoc="doc"
tabindex="-1"
@@ -39,7 +40,7 @@
style="width: 90vw; max-width: 1000px"
>
<div class="large">
<iframe :sandbox="PREVIEW_SANDBOX" :srcdoc="doc"></iframe>
<iframe :key="current?.submission_id" :sandbox="PREVIEW_SANDBOX" :srcdoc="doc"></iframe>
</div>
<div class="large-rates">
<button