From 2f2af1a3d25521fab9a5351d3083094e251b9408 Mon Sep 17 00:00:00 2001 From: KiriAky 107 Date: Mon, 7 Sep 2026 22:33:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(desktop):=20=E5=AE=8C=E6=88=90=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=BF=AB=E6=8D=B7=E9=94=AE=E4=B8=8E=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=E6=A1=86=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src-tauri/tauri.conf.json | 2 +- .../components/common/TitleBarMenu.spec.ts | 9 ++++ .../src/components/common/TitleBarMenu.vue | 46 ++++++++++++---- .../editor/VisualMarkdownEditor.spec.ts | 10 ++++ .../features/editor/VisualMarkdownEditor.vue | 25 ++++++++- .../src/services/platform/lifecycle.spec.ts | 20 +++++++ frontend/src/services/platform/lifecycle.ts | 54 +++++++++++++++++-- 7 files changed, 149 insertions(+), 17 deletions(-) create mode 100644 frontend/src/services/platform/lifecycle.spec.ts diff --git a/frontend/src-tauri/tauri.conf.json b/frontend/src-tauri/tauri.conf.json index bf4cdd1..f9c874e 100644 --- a/frontend/src-tauri/tauri.conf.json +++ b/frontend/src-tauri/tauri.conf.json @@ -10,7 +10,7 @@ "frontendDist": "../dist" }, "app": { - "windows": [{"label": "main", "title": "NotesAgent Preview", "width": 1200, "height": 800, "minWidth": 640, "minHeight": 480, "decorations": false}], + "windows": [{"label": "main", "title": "NotesAgent Preview", "width": 1280, "height": 960, "minWidth": 720, "minHeight": 700, "center": true, "decorations": false}], "security": { "csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: http://127.0.0.1:8000; font-src 'self' data:; connect-src ipc: http://ipc.localhost http://127.0.0.1:8000; frame-src 'self' blob:; object-src 'none'; base-uri 'self'", "capabilities": ["main"] diff --git a/frontend/src/components/common/TitleBarMenu.spec.ts b/frontend/src/components/common/TitleBarMenu.spec.ts index 1123703..33e5085 100644 --- a/frontend/src/components/common/TitleBarMenu.spec.ts +++ b/frontend/src/components/common/TitleBarMenu.spec.ts @@ -58,4 +58,13 @@ describe('桌面顶部段落菜单', () => { expect(wrapper.get('.import-properties').text()).toContain('Ctrl+Alt+P') wrapper.unmount() }) + + it('格式菜单列出十四种警告框和元数据快捷键', async () => { + const wrapper = mount(TitleBarMenu) + await wrapper.get('[data-menu="format"] .menu-trigger').trigger('click') + expect(wrapper.findAll('.callout-options button')).toHaveLength(14) + expect(wrapper.get('.submenu-heading').text()).toContain('Ctrl+Alt+C') + expect(wrapper.get('.metadata-command').text()).toContain('Ctrl+Alt+P') + wrapper.unmount() + }) }) diff --git a/frontend/src/components/common/TitleBarMenu.vue b/frontend/src/components/common/TitleBarMenu.vue index 7ec630f..23a649e 100644 --- a/frontend/src/components/common/TitleBarMenu.vue +++ b/frontend/src/components/common/TitleBarMenu.vue @@ -14,6 +14,11 @@ const open = ref(null) const bar = ref(null) const error = ref('') const shortcut = computed(() => /Mac|iPhone|iPad/.test(navigator.platform) ? '⌘⌥P' : 'Ctrl+Alt+P') +const callouts = [ + ['note', '笔记'], ['abstract', '摘要'], ['info', '信息'], ['todo', '待办'], ['tip', '技巧'], + ['important', '重要'], ['success', '成功'], ['question', '问题'], ['warning', '警告'], + ['failure', '失败'], ['danger', '危险'], ['bug', '缺陷'], ['example', '示例'], ['quote', '引用'], +] as const function enabled(id: EditorCommandId) { return getEditorCommandCapabilities().find(item => item.id === id)?.enabled ?? false @@ -31,6 +36,11 @@ async function command(id: EditorCommandId, params?: unknown) { if (result.ok) close() else error.value = t('当前编辑器无法执行此命令。', 'The active editor cannot run this command.') } +async function metadataCommand() { + const imported = await executeEditorCommand('editor.import-note-properties') + if (imported.ok) { close(); return } + await command('editor.metadata.edit') +} async function save() { await editor.save(); close() } function setMode(mode: 'source' | 'wysiwyg') { editor.setMode(mode); close() } function toggleTheme() { theme.toggleTheme(); close() } @@ -63,14 +73,14 @@ onBeforeUnmount(() => window.removeEventListener('pointerdown', dismiss))