From 47d2fe63ed21cfabd94de865f2ce11168f02ac8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B9=B2=E5=86=B0DryIce?= Date: Sat, 26 Sep 2026 21:28:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E4=BD=9C=E4=B8=9A=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=B2=98=E8=B4=B4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/src/components/HomeworkEditDialog.vue | 66 ++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/HomeworkEditDialog.vue b/apps/web/src/components/HomeworkEditDialog.vue index ba5fc677..e035660f 100644 --- a/apps/web/src/components/HomeworkEditDialog.vue +++ b/apps/web/src/components/HomeworkEditDialog.vue @@ -30,6 +30,26 @@ @keyup="updateCurrentLine" /> +
+ + 粘贴 + + + 粘贴并完成 + +
+
@@ -328,8 +348,9 @@ export default { watch: { async modelValue(newValue) { if (newValue) { - // 当对话框打开时,重置内容为初始内容 - this.content = this.initialContent + // 当对话框打开时,重置内容为初始内容;最后一行不是空行时,在文末加一个空行 + const initial = this.initialContent || '' + this.content = initial === '' || initial.endsWith('\n') ? initial : initial + '\n' // 加载模板数据 try { this.templateData = await dataProvider.loadData('classworks-config-homework-template') @@ -526,6 +547,47 @@ export default { }) } }, + // 从剪贴板读取内容并按光标位置组装新正文:有选中则替换,否则在光标处插入 + // 剪贴板完全为空时返回 null,空格或换行视为有效内容原样粘贴 + async buildContentWithPaste() { + const text = await navigator.clipboard.readText() + if (text == null || text === '') return null + const textarea = this.$refs.inputRef.$el.querySelector('textarea') + const start = textarea.selectionStart + const end = textarea.selectionEnd + return { + content: this.content.slice(0, start) + text + this.content.slice(end), + cursorPosition: start + text.length, + } + }, + // 从剪贴板粘贴,保留在对话框继续编辑 + async pasteFromClipboard() { + try { + const result = await this.buildContentWithPaste() + if (!result) return + this.content = result.content + this.$nextTick(() => { + const textarea = this.$refs.inputRef.$el.querySelector('textarea') + textarea.focus() + textarea.setSelectionRange(result.cursorPosition, result.cursorPosition) + this.updateCurrentLine() + }) + } catch (error) { + console.error('Failed to read clipboard:', error) + } + }, + // 从剪贴板粘贴并直接保存关闭,插入逻辑与粘贴一致 + async pasteAndComplete() { + try { + const result = await this.buildContentWithPaste() + if (!result) return + this.content = result.content + this.$emit('save', this.content.trim()) + this.dialogVisible = false + } catch (error) { + console.error('Failed to read clipboard:', error) + } + }, }, } From 74be238c99898b7a09a389ff389f6b6803442efa Mon Sep 17 00:00:00 2001 From: Sunwuyuan Date: Fri, 2 Oct 2026 12:04:54 +0000 Subject: [PATCH 2/2] =?UTF-8?q?feat(web):=20=E5=A2=9E=E5=8A=A0=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E8=AE=BE=E7=BD=AE=E9=A1=B9=EF=BC=8C=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E4=BD=9C=E4=B8=9A=E7=BC=96=E8=BE=91=E7=B2=98?= =?UTF-8?q?=E8=B4=B4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 display.showPasteButtons 设置(默认开启),位于设置 > 显示: - 关闭后隐藏作业编辑对话框中的「粘贴」与「粘贴并完成」按钮 --- apps/web/src/components/HomeworkEditDialog.vue | 5 ++++- .../src/components/settings/cards/DisplaySettingsCard.vue | 3 +++ apps/web/src/utils/settings.js | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/HomeworkEditDialog.vue b/apps/web/src/components/HomeworkEditDialog.vue index e035660f..ad3040ae 100644 --- a/apps/web/src/components/HomeworkEditDialog.vue +++ b/apps/web/src/components/HomeworkEditDialog.vue @@ -30,7 +30,7 @@ @keyup="updateCurrentLine" /> -
+
+ + + diff --git a/apps/web/src/utils/settings.js b/apps/web/src/utils/settings.js index 53b539f4..ae136734 100644 --- a/apps/web/src/utils/settings.js +++ b/apps/web/src/utils/settings.js @@ -212,6 +212,13 @@ const settingsDefinitions = { description: '是否显示快捷键盘', icon: 'mdi-dialpad', }, + 'display.showPasteButtons': { + type: 'boolean', + default: true, + description: '是否显示作业编辑粘贴按钮', + icon: 'mdi-content-paste', + // 控制作业编辑对话框中的「粘贴」与「粘贴并完成」按钮,关闭后仅保留手动编辑 + }, 'display.forceDesktopMode': { type: 'boolean', default: false,