diff --git a/src/main.ts b/src/main.ts index 6314d1e..133ee14 100644 --- a/src/main.ts +++ b/src/main.ts @@ -192,6 +192,47 @@ window.onload = function () { } } + // 全局快捷键:Ctrl+S / ⌘+S 触发保存 + window.addEventListener('keydown', function (e) { + const isSaveKey = (e.ctrlKey || e.metaKey) && (e.key === 's' || e.key === 'S') + if (!isSaveKey) return + e.preventDefault() + + const params = new URLSearchParams(window.location.search) + const isEditMode = params.get('mode') === 'edit' || params.get('model') === 'edit' + if (!isEditMode) { + console.warn('当前为只读模式,Ctrl+S 不可用') + alert('当前为只读模式,不能保存') + return + } + + // 触发保存按钮的同一逻辑 + saveCallbackDom.click() + }) + + // 向父窗口暴露:显示保存状态(文本、颜色、延时可选) + ;(window as any).showSaveStatus = (text: string, color?: string, delay?: number) => { + try { + const indicator = document.getElementById('save-status-indicator') as HTMLDivElement | null + if (!indicator) return + const duration = typeof delay === 'number' ? delay : 2000 + indicator.textContent = text || '已保存' + indicator.style.background = color || '#4caf50' + indicator.style.display = 'block' + // 清理之前的隐藏计时器 + const key = '__save_status_timer__' + const prev = (window as any)[key] + if (prev) { + window.clearTimeout(prev) + } + ;(window as any)[key] = window.setTimeout(() => { + indicator.style.display = 'none' + }, duration) + } catch (err) { + console.warn('显示保存状态失败:', err) + } + } + const undoDom = document.querySelector('.menu-item__undo')! undoDom.title = `撤销(${isApple ? '⌘' : 'Ctrl'}+Z)` undoDom.onclick = function () { diff --git a/src/style.css b/src/style.css index 7d5a87d..c7e5aad 100644 --- a/src/style.css +++ b/src/style.css @@ -218,7 +218,8 @@ ul { user-select: none; border-radius: 3px; color: #0969da; /* link blue */ - font-size: 12px; + font-size: 16px; + /* font-weight: bold; */ line-height: 24px; } diff --git a/vocd.html b/vocd.html index 05c82bf..71781b4 100644 --- a/vocd.html +++ b/vocd.html @@ -346,6 +346,7 @@ @@ -427,6 +428,21 @@ + +
已保存