From c9917683e5ad3474ebe8af93893cf83f7d982972 Mon Sep 17 00:00:00 2001 From: beierweiwei <364704059@qq.com> Date: Thu, 26 Nov 2026 23:29:22 +0800 Subject: [PATCH] =?UTF-8?q?Update=20plugin=20=E5=A4=A7=E5=8F=A4=E6=88=AA?= =?UTF-8?q?=E5=9B=BE=20v1.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - feat: restore OCR translation support - feat: add translation provider language profiles - feat: improve OCR window layout and editor sizing - feat: improve OCR plugin flows and window handling - fix: repair editor window close flow and add preview collapse - feat: add provider setup guide to settings panel - feat: add first-use setup command and auto-open config panel - fix: improve OCR editor workflows - feat: rename plugin and update logo - chore: prepare plugin for ZTools submission - docs: add plugin submission screenshots - feat: add editor download & zoom/pan, English commands, user README - test: add SettingsStore cross-machine sync coverage - chore: bump plugin version to 1.1.0 and update changelog - chore: publish plugin from source root and ship user README - feat: 重写截图为沉浸式标注器,主题色收敛(v1.2.0) - chore: 移除无引用的旧界面截图,README 改引用当前标注界面 - fix: 截图导出按视口坐标裁剪,修复高分屏选区内容错位 - chore: bump plugin version to 1.2.1 and update changelog - chore: 沉淀 ztools publish 本机网络故障排查与代理注入脚本 - fix: HDR 截图全白时回退系统截图 - chore: 排除插件包内发布辅助文件 - docs: keep official release guide in plugin package - chore: preserve official release guide bytes - docs: record full fork cache recovery flow - feat: 增强固定截图右键操作 - chore: bump plugin version to 1.2.3 - docs: 展示固定截图右键菜单 - fix: 保留固定图子窗口直到识别完成 - fix: 固定期间保留插件主视图 - feat: 新增大古快传插件,与大古截图并列的文件传输插件 - fix: 宿主收起插件时冻结画面覆盖层跟随关闭 - feat: 快传配置页用户名输入框与表单交互优化 - chore: 准备发布——截图 1.3.0 补 Esc 修复说明,快传版本定版 1.0.0 - docs: 快传 1.0.0 变更说明补配置页用户名与表单优化 - docs: 快传 README 补界面截图与远程 agent 使用场景,截图插件补工具条截图 - docs: 两个插件 README 双向推荐 - fix: 分享未安装快传时引导安装并说明分享能力 --- plugins/dagu-ocr/CHANGELOG.md | 13 + plugins/dagu-ocr/README.md | 21 +- plugins/dagu-ocr/dagu-transfer-shared.cjs | 223 ++++++++++++++++++ .../docs/screenshots/overlay-toolbar.png | Bin 0 -> 15198 bytes .../dagu-ocr/docs/screenshots/share-list.png | Bin 0 -> 5995 bytes plugins/dagu-ocr/plugin.json | 4 +- plugins/dagu-ocr/{preload.js => preload.cjs} | 14 ++ .../dagu-ocr/scripts/copy-plugin-files.mjs | 8 +- .../dagu-ocr/scripts/install-to-ztools.mjs | 68 ------ .../dagu-ocr/src/capture/desktop-capture.js | 18 ++ plugins/dagu-ocr/src/capture/overlay.css | 13 +- plugins/dagu-ocr/src/capture/overlay.js | 50 ++++ plugins/dagu-ocr/src/capture/toolbar.js | 2 + plugins/dagu-ocr/src/controls.css | 182 ++++++++++++++ plugins/dagu-ocr/src/core/kv.js | 120 ++++++++++ plugins/dagu-ocr/src/core/storage.js | 131 +++------- plugins/dagu-ocr/src/core/synced-secrets.js | 20 ++ plugins/dagu-ocr/src/main.js | 35 ++- plugins/dagu-ocr/src/share/handoff.js | 109 +++++++++ plugins/dagu-ocr/src/styles.css | 159 +------------ plugins/dagu-ocr/src/theme.js | 61 +++-- plugins/dagu-ocr/vite.config.js | 6 + 22 files changed, 901 insertions(+), 356 deletions(-) create mode 100644 plugins/dagu-ocr/dagu-transfer-shared.cjs create mode 100644 plugins/dagu-ocr/docs/screenshots/overlay-toolbar.png create mode 100644 plugins/dagu-ocr/docs/screenshots/share-list.png rename plugins/dagu-ocr/{preload.js => preload.cjs} (58%) delete mode 100644 plugins/dagu-ocr/scripts/install-to-ztools.mjs create mode 100644 plugins/dagu-ocr/src/controls.css create mode 100644 plugins/dagu-ocr/src/core/kv.js create mode 100644 plugins/dagu-ocr/src/core/synced-secrets.js create mode 100644 plugins/dagu-ocr/src/share/handoff.js diff --git a/plugins/dagu-ocr/CHANGELOG.md b/plugins/dagu-ocr/CHANGELOG.md index 21330837f..3201cbda2 100644 --- a/plugins/dagu-ocr/CHANGELOG.md +++ b/plugins/dagu-ocr/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 1.3.0 - 2026-11-24 + +### 新增 + +- 截图与图片编辑工具条新增「分享」:把当前图片交给独立插件「大古快传」上传,本插件不再需要自己实现上传。点击后直接跳到大古快传的目标列表;没有安装大古快传时留在当前界面并提示。 +- 跟随 ZTools 的深浅色与主题色:ZTools 是深色时,主页面、配置面板、截图与图片编辑窗口的工具条用深色配色;浅色下保持原有配色。固定图窗口保持原有的深色悬浮样式。 + +### 修复 + +- 修复 Windows 开启 HDR 的显示器上截图发白、过曝甚至全白的问题:HDR 下不再用桌面捕获源抓冻结画面,直接改用 ZTools 自带截图框选(这一步会把截图写进剪贴板),选好区域后回到同一套标注界面,标注、OCR、翻译、固定、分享照常可用。是否 HDR 按宿主返回的显示器信息判断,只对 Windows 生效;普通显示器不受影响。 +- 修复开发模式下插件的 preload 不被加载的问题:插件根目录的 `package.json` 是 ES 模块类型,名为 `preload.js` 的文件会被 Electron 当成 ES 模块,页面拿不到任何 preload 接口。preload 改名为 `preload.cjs`。正式安装包里没有 `package.json`,不受影响。 +- 修复截图期间按 Esc 后全屏冻结画面悬在屏幕上的问题:宿主主进程会截获 Esc 直接收起插件,覆盖层是独立子窗口收不到按键,现在宿主收起插件时冻结画面跟随关闭;「分享」场景不受影响,仍等大古快传确认后再收尾。 + ## 1.2.3 - 2026-11-12 ### 新增 diff --git a/plugins/dagu-ocr/README.md b/plugins/dagu-ocr/README.md index 5dcb8d67e..d17e9b4be 100644 --- a/plugins/dagu-ocr/README.md +++ b/plugins/dagu-ocr/README.md @@ -9,12 +9,15 @@ - 随手截了张图想裁剪、打马赛克 → 用「编辑图片」就地处理。 - 截图里的字看不清,想变成可复制文本 → 截图后点「图片 OCR」。 - 遇到一段英文/日文,想看懂 → 选中图片点「翻译」,或直接在输入框里粘贴文字翻译。 +- 截完图想直接放到服务器或固定文件夹 → 点「分享」,交给配套插件「大古快传」上传(需另外安装),目标路径自动复制好。 ## 界面一览 沉浸式截图:按下截图后整个屏幕冻结,直接拖拽框选区域,选区下方浮出工具条;在画面上画形状、线条、画笔、荧光笔、马赛克、文字,完成后复制、保存或固定到屏幕。 -截图工具:**选择 / 形状 / 线条 / 画笔 / 荧光笔 / 马赛克 / 文字 / 橡皮擦**,右侧是撤销重做、OCR、翻译、取消、固定、保存与复制;滚轮以光标为锚点缩放,空格或中键拖动画面。 +截图工具:**选择 / 形状 / 线条 / 画笔 / 荧光笔 / 马赛克 / 文字 / 橡皮擦**,右侧是撤销重做、OCR、翻译、分享、取消、固定、保存与复制;滚轮以光标为锚点缩放,空格或中键拖动画面。 + +![截图工具条:标注工具与 OCR、翻译、分享等操作](./docs/screenshots/overlay-toolbar.png) 「编辑图片」用的是同一个标注界面,只是直接打开图片、不再需要框选。 @@ -46,6 +49,14 @@ 每个入口都支持输入同名英文指令:`Screenshot` / `Image OCR` / `Translate Text` / `Edit Image` / `Settings`。 +## 分享到「大古快传」 + +截图与标注完成后,不用另存再传:工具条上点「分享」,当前图片直接交给配套插件**大古快传**的目标列表,回车选个目标就上传,目标路径自动复制到剪贴板。上次使用的目标排在第一行,传到服务器、传到本地文件夹都一样顺手。 + +![分享:当前截图进入大古快传的目标列表](./docs/screenshots/share-list.png) + +**大古快传**是一个独立插件:把图片或文件上传到本地目录或 SSH 服务器,也能从 SSH 服务器把文件取回本机;远程开发时想把本地图发给 AI agent,也可以先传到服务器再把路径发给它。还没有安装?在 ZTools 插件中心搜索「大古快传」即可。没装也不影响截图:点「分享」会留在当前界面并提示,截图不会丢。 + 图片来源很自由:截图、拖入文件、点击上传、甚至直接 `Ctrl+V` 粘贴剪贴板里的图片都行。 ## 配置 @@ -57,6 +68,14 @@ OCR 和翻译各选一个「提供商」(Provider)即可,二选一: 设置页没有预置密钥,打开后一目了然,照着下拉框和「如何设置提供商?」的提示操作即可。 +## 主题 + +界面跟随 ZTools 的深浅色与主题色(ZTools 的主题设置默认跟随系统):深色下主页面、配置面板和截图工具条都是深色,按钮用 ZTools 的主题色。固定在屏幕上的图片窗口保持深色悬浮样式,不随主题变。 + +## 开着 HDR 的显示器(Windows) + +显示器在 Windows 里开着 HDR 时,「截图」的框选这一步改用 ZTools 自带的截图(它在 HDR 下颜色正常),选好区域后回到本插件的标注界面,标注、OCR、翻译、固定、分享照常可用。普通显示器不受影响。这一步用的是自带截图,所以会把截图写进剪贴板。 + ## 关于密钥与历史记录 - 偏好设置保存在 ZTools 的 `dbStorage`,密钥默认**只保存在本机**。 diff --git a/plugins/dagu-ocr/dagu-transfer-shared.cjs b/plugins/dagu-ocr/dagu-transfer-shared.cjs new file mode 100644 index 000000000..32f192fe8 --- /dev/null +++ b/plugins/dagu-ocr/dagu-transfer-shared.cjs @@ -0,0 +1,223 @@ +'use strict'; + +// 大古截图与大古快传共用的约定:唯一文件名的格式、交接文件的存放位置、跳转用的 token 与标签。 +// 两个插件的 preload 各自加载本插件目录内的同步副本(由 scripts/sync-shared.mjs 从 shared/ 复制)。 + +const path = require('node:path'); + +const SHARE_DIR_NAME = 'dagu-transfer'; +// 不含斜杠,写进大古快传的正则指令时无需转义。 +const TOKEN_PREFIX = 'dagu-transfer-share:'; +// 大古截图跳转时按「插件标题 + 指令名」定位大古快传,改任一侧都要同步另一侧的 plugin.json。 +const TRANSFER_TITLE = '大古快传'; +const TRANSFER_SHARE_CMD = '接收分享'; +// 已是唯一命名的文件:<名称>-YYYYMMDD-HHmmss-<6 位小写字母数字><.扩展名> +const UNIQUE_NAME_PATTERN = /^(.+)-\d{8}-\d{6}-[a-z0-9]{6}(\.[a-z0-9]{1,5})$/; +// 交接文件只接受这一种形态,token 因此无法把读取范围扩大到约定目录之外。 +const SHARE_FILE_PATTERN = /^(?:截图|图片)-\d{8}-\d{6}-[a-z0-9]{6}\.png$/; +// 目录分隔符、Windows 文件名非法字符与控制字符统一替换掉。 +const UNSAFE_CHARS = /[<>:"/\\|?*\u0000-\u001f\u007f]/g; +const STALE_MS = 24 * 60 * 60 * 1000; +// 确认文件:交接文件名后加 .ack。 +const ACK_SUFFIX = '.ack'; +const ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789'; + +const pad = (value) => String(value).padStart(2, '0'); + +function timestamp(now = new Date()) { + const date = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}`; + return `${date}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`; +} + +// 36^6 ≈ 21.7 亿种组合,把 [0, 1) 的随机数均匀映射成 6 位小写字母数字。 +function randomSuffix(random = Math.random) { + let value = Math.floor(random() * 2176782336); + let text = ''; + for (let index = 0; index < 6; index += 1) { + text = ALPHABET[value % 36] + text; + value = Math.floor(value / 36); + } + return text; +} + +function isUniqueFileName(fileName) { + return UNIQUE_NAME_PATTERN.test(String(fileName || '')); +} + +// 只保留文件名部分(丢弃目录),并替换各平台都不允许的字符。 +function baseFileName(fileName) { + const normalized = String(fileName || '').replace(/\\/g, '/'); + return normalized.slice(normalized.lastIndexOf('/') + 1).replace(UNSAFE_CHARS, '_').trim(); +} + +function splitFileName(fileName) { + const base = baseFileName(fileName); + const dot = base.lastIndexOf('.'); + const hasExtension = dot > 0 && base.length - dot <= 6; + return { + base: hasExtension ? base.slice(0, dot) : base, + ext: hasExtension ? base.slice(dot).toLowerCase() : '' + }; +} + +// 已经符合唯一命名的文件名原样保留;force 为 true 时换一个新的时间与随机后缀。 +function uniqueFileName(fileName, { now = new Date(), random = Math.random, force = false } = {}) { + const source = baseFileName(fileName); + const match = UNIQUE_NAME_PATTERN.exec(source); + if (match && !force) return source; + const { base, ext } = match ? { base: match[1], ext: match[2] } : splitFileName(source); + return `${base || '文件'}-${timestamp(now)}-${randomSuffix(random)}${ext}`; +} + +function buildShareFileName(prefix = '截图', { now = new Date(), random = Math.random, ext = 'png' } = {}) { + return `${prefix}-${timestamp(now)}-${randomSuffix(random)}.${ext}`; +} + +function encodeShareToken(fileName) { + return TOKEN_PREFIX + encodeURIComponent(fileName); +} + +// 解析跳转 token;不是合法的交接文件名时返回空字符串。 +function decodeShareToken(token) { + if (typeof token !== 'string' || !token.startsWith(TOKEN_PREFIX)) return ''; + try { + const fileName = decodeURIComponent(token.slice(TOKEN_PREFIX.length)); + return SHARE_FILE_PATTERN.test(fileName) ? fileName : ''; + } catch { + return ''; + } +} + +function isShareFileName(fileName) { + return SHARE_FILE_PATTERN.test(String(fileName || '')); +} + +function redirectLabel() { + return [TRANSFER_TITLE, TRANSFER_SHARE_CMD]; +} + +// 「复制为路径」得到的路径文本带着成对的双引号或单引号,这里去掉首尾空白与成对引号。 +function unquotePath(text) { + const value = String(text ?? '').trim(); + const first = value[0]; + if ((first === '"' || first === "'") && value.length > 1 && value.endsWith(first)) { + return value.slice(1, -1).trim(); + } + return value; +} + +function shareDir(tmpdir) { + return path.join(tmpdir, SHARE_DIR_NAME); +} + +// 只为合法的交接文件名拼路径,其它输入一律返回空字符串。 +function shareFilePath(tmpdir, fileName) { + return isShareFileName(fileName) ? path.join(shareDir(tmpdir), fileName) : ''; +} + +// 截图侧使用:把图片写进交接目录,并在每次写入后清理过期的交接文件。 +// 宿主的 redirect 找不到目标插件时照样返回成功,所以「对方是否接手」要靠确认文件来判断: +// 快传读到交接文件后调用 ack 留下 <文件名>.ack,截图侧用 isAcked 轮询。 +function createShareWriter({ fs, tmpdir, now = () => new Date(), random = Math.random, staleMs = STALE_MS } = {}) { + const dir = shareDir(tmpdir); + + const filePathOf = (fileName) => (isShareFileName(fileName) ? path.join(dir, fileName) : ''); + const ackPathOf = (fileName) => { + const filePath = filePathOf(fileName); + return filePath ? `${filePath}${ACK_SUFFIX}` : ''; + }; + + const remove = (target) => { + if (!target) return false; + try { + fs.rmSync(target, { force: true }); + return true; + } catch { + return false; + } + }; + + const pruneStale = () => { + let entries = []; + try { + entries = fs.readdirSync(dir); + } catch { + return; + } + const cutoff = now().getTime() - staleMs; + for (const entry of entries) { + if (!isShareFileName(entry.replace(/\.ack$/, ''))) continue; + const target = path.join(dir, entry); + try { + if (fs.statSync(target).mtimeMs < cutoff) fs.rmSync(target, { force: true }); + } catch { + // 清理失败不影响分享主流程。 + } + } + }; + + const write = (base64, { prefix = '截图', ext = 'png' } = {}) => { + const fileName = buildShareFileName(prefix, { now: now(), random, ext }); + fs.mkdirSync(dir, { recursive: true }); + fs.writeFileSync(path.join(dir, fileName), Buffer.from(String(base64 || ''), 'base64')); + pruneStale(); + return { fileName, token: encodeShareToken(fileName), label: redirectLabel() }; + }; + + return Object.freeze({ + dir, + write, + pruneStale, + // 快传侧调用:确认已经拿到这个交接文件。 + ack: (fileName) => { + const ackPath = ackPathOf(fileName); + if (!ackPath) return false; + try { + fs.writeFileSync(ackPath, ''); + return true; + } catch { + return false; + } + }, + // 截图侧调用:对方是否已经确认接手。 + isAcked: (fileName) => { + const ackPath = ackPathOf(fileName); + if (!ackPath) return false; + try { + return fs.existsSync(ackPath); + } catch { + return false; + } + }, + // 连同确认文件一起删除。 + discard: (fileName) => { + const removed = remove(filePathOf(fileName)); + remove(ackPathOf(fileName)); + return removed; + }, + // 跳转前清掉上一次可能残留的确认文件,避免把旧确认当成本次的结果。 + clearAck: (fileName) => remove(ackPathOf(fileName)) + }); +} + +module.exports = { + SHARE_DIR_NAME, + TOKEN_PREFIX, + TRANSFER_TITLE, + TRANSFER_SHARE_CMD, + timestamp, + randomSuffix, + baseFileName, + splitFileName, + isUniqueFileName, + uniqueFileName, + buildShareFileName, + encodeShareToken, + decodeShareToken, + isShareFileName, + redirectLabel, + unquotePath, + shareDir, + shareFilePath, + createShareWriter +}; diff --git a/plugins/dagu-ocr/docs/screenshots/overlay-toolbar.png b/plugins/dagu-ocr/docs/screenshots/overlay-toolbar.png new file mode 100644 index 0000000000000000000000000000000000000000..c9b2d9b2d28a9bc107fd61763c6769957ee69c9c GIT binary patch literal 15198 zcmbVzby!qe+czNX&_gLT^Z+6u1JXm+NDLjq5Q2mXNO!}~r3i?WLrN=xbSNN#bV&^$ z(j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_p+ZJ?jfI)gYz#u8}EIhprd3fv{&YEV%F}4iccK%Y-XzG$invlkH zd{y?(p-qrsEcd5+dof3}F{q5W1RJFM*ODYjY|<8usTjL3L6ME20Aws1)pvd0 z|6bPnc8421xT6csZy;RV-DP+0`hXXna{$Yd%7YOkIi?&%qTAS8iUT813n_mRb+usTK*%^G8E|GN^Rp|c#rkxcT literal 0 HcmV?d00001 diff --git a/plugins/dagu-ocr/docs/screenshots/share-list.png b/plugins/dagu-ocr/docs/screenshots/share-list.png new file mode 100644 index 0000000000000000000000000000000000000000..767fc03bf0852825176787fff2decb66042dfddc GIT binary patch literal 5995 zcmdT|c~q0vwm&f~v9}PhSV0Jb(u%DLQjoy}QpJkaA`Z2n0fMNYGJ_BZnJN`UlvoEq znN%Dq2mzD?5=f#9QNo~ANFanD5D)?hgCT@4yac>=y>&tNTEBk$;^4z!>b=x&7CKfKjoe=su3f9q<15f?O|xLXs+c z&b>Uhe`Wdp54~Qd?}|$9BFTd`A3w_ID<0TWYAC{9Srz(B1-2#KZ@2Y`Z;V7ZQ3 z2mc$5?}hY;vGdPRL{0s~dt=Ui_m35=HzW&<`Ma-uvq$@M9<)zRJL1>WALN8PXk!W* z_RQGsSep7tCp_>nxx{8CVlxnM+HbiGt#tPecI|tV0(rN+*x@VQmh^dFa6? zL|Dcrl%;_^xUn?0jq=b3-!3BWf7xXS{c&m0&@$%}d?+_t+9t_}Q3PmaCl#{~Z>R!f zVGfcA2hIk`2hkuy#UE761(V(XTO$$*Wj)q0e-yu>^cU~BMxnAmxHd;ifi5f5y+kTogzH5WbX#`q+x zI3+9^2)oxho8@>RU*+QXxj{gRQlxZPyrZ7m{hy++x2YVL|{Jf~L z(=daM7O*AdMDAM24*N|qb2vQi5)$~d$HF9+AU!c{adoaX8H)9vbV!$6-K-BX(Yr({ zspY6=w6l5TNi%(rRKKMhIVLmPPZziw392WuHs+iu{ccGqxg~2u+`(lk-*(=h27ihn zd=VJcd?%cQ6YD{_D!F%tpth!M5X&j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MsRkwvm?kk;sA0I(DN-4BcDd&Y?e_h%Q8cj32$sOwz$#P*LQkFVM&vPuLezQ%7(_+Y3CebAOTeAE>`IX9G|V_j-V$H4*%YTnwx&d%Xx zy)MMG#V6NWMK_yMMvd`J3T_g_QnEpz|? literal 0 HcmV?d00001 diff --git a/plugins/dagu-ocr/plugin.json b/plugins/dagu-ocr/plugin.json index 4ae7cead0..38dd5285a 100644 --- a/plugins/dagu-ocr/plugin.json +++ b/plugins/dagu-ocr/plugin.json @@ -1,12 +1,12 @@ { "name": "dagu-ocr", "title": "大古截图", - "version": "1.2.3", + "version": "1.3.0", "description": "截图、OCR 文字识别与图片翻译,从图片中提取并翻译文字", "author": "beierweiwei", "logo": "icon.png", "main": "index.html", - "preload": "preload.js", + "preload": "preload.cjs", "development": { "main": "http://127.0.0.1:5173/index.html" }, diff --git a/plugins/dagu-ocr/preload.js b/plugins/dagu-ocr/preload.cjs similarity index 58% rename from plugins/dagu-ocr/preload.js rename to plugins/dagu-ocr/preload.cjs index fb182f538..38fbaf761 100644 --- a/plugins/dagu-ocr/preload.js +++ b/plugins/dagu-ocr/preload.cjs @@ -23,6 +23,20 @@ try { // 普通浏览器开发环境没有 Node 能力。 } +// 供「分享到大古快传」使用:把当前图片写进两个插件约定的交接目录,并给出跳转用的 token 与标签。 +try { + const fs = require('fs'); + const os = require('os'); + const handoff = require('./dagu-transfer-shared.cjs'); + const writer = handoff.createShareWriter({ fs, tmpdir: os.tmpdir() }); + window.__daguOcrPrepareShare = (base64) => writer.write(base64); + window.__daguOcrDiscardShare = (fileName) => writer.discard(fileName); + // 大古快传读到交接文件后会留下确认文件;跳转接口找不到对方时也返回成功,只能靠它判断。 + window.__daguOcrShareAcked = (fileName) => writer.isAcked(fileName); +} catch { + // 普通浏览器开发环境没有 Node 能力:分享按钮会提示需要大古快传。 +} + try { const { ipcRenderer } = require('electron'); ipcRenderer.on(EDITOR_CHANNEL, (_event, payload) => { diff --git a/plugins/dagu-ocr/scripts/copy-plugin-files.mjs b/plugins/dagu-ocr/scripts/copy-plugin-files.mjs index 136fc726e..1cdbc496d 100644 --- a/plugins/dagu-ocr/scripts/copy-plugin-files.mjs +++ b/plugins/dagu-ocr/scripts/copy-plugin-files.mjs @@ -6,12 +6,12 @@ const distDir = fileURLToPath(new URL('../dist/', import.meta.url)) mkdirSync(distDir, { recursive: true }) -for (const file of ['plugin.json', 'preload.js', 'icon.png', 'LICENSE', 'CHANGELOG.md', 'README.md']) { +for (const file of ['plugin.json', 'preload.cjs', 'dagu-transfer-shared.cjs', 'icon.png', 'LICENSE', 'CHANGELOG.md', 'README.md']) { copyFileSync(`${pluginRoot}${file}`, `${distDir}${file}`) } -// 随 README 一起发布的界面截图(README 仅引用这三个) +// 随 README 一起发布的界面截图 mkdirSync(`${distDir}docs/screenshots/`, { recursive: true }) -for (const file of ['editor.png', 'main-ocr.png', 'translation.png']) { +for (const file of ['editor.png', 'main-ocr.png', 'translation.png', 'pin-context-menu.png', 'overlay-toolbar.png']) { copyFileSync(`${pluginRoot}docs/screenshots/${file}`, `${distDir}docs/screenshots/${file}`) -} \ No newline at end of file +} diff --git a/plugins/dagu-ocr/scripts/install-to-ztools.mjs b/plugins/dagu-ocr/scripts/install-to-ztools.mjs deleted file mode 100644 index 578fdaa4d..000000000 --- a/plugins/dagu-ocr/scripts/install-to-ztools.mjs +++ /dev/null @@ -1,68 +0,0 @@ -import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from 'node:fs' -import os from 'node:os' -import path from 'node:path' -import { fileURLToPath } from 'node:url' -import { createPackage, extractFile } from '@electron/asar' - -const pluginRoot = fileURLToPath(new URL('..', import.meta.url)) -const distDir = path.join(pluginRoot, 'dist') - -const pluginJson = JSON.parse( - await import('node:fs').then(fs => fs.readFileSync(path.join(pluginRoot, 'plugin.json'), 'utf-8')) -) - -if (!existsSync(path.join(distDir, 'plugin.json'))) { - console.error('未找到构建产物 plugin/dist/plugin.json,请先执行 npm run build') - process.exit(1) -} - -const targetDir = process.env.ZTOOLS_PLUGINS_DIR - ? path.join(process.env.ZTOOLS_PLUGINS_DIR, pluginJson.name) - : path.join(os.homedir(), '.ztools', 'plugins', pluginJson.name) - -function installedAsarPath() { - const pluginsDir = path.dirname(targetDir) - if (!existsSync(pluginsDir)) return null - - const candidates = readdirSync(pluginsDir) - .filter((name) => name.endsWith('.asar')) - .map((name) => { - const filePath = path.join(pluginsDir, name) - try { - const metadata = JSON.parse(extractFile(filePath, 'plugin.json').toString('utf8')) - return { filePath, name, metadata, mtime: statSync(filePath).mtimeMs } - } catch { - return null - } - }) - .filter((candidate) => candidate?.metadata?.name === pluginJson.name) - .sort((a, b) => b.mtime - a.mtime) - - return candidates[0]?.filePath || null -} - -console.log(`安装 ${pluginJson.title} v${pluginJson.version}`) -console.log(` 源: ${distDir}`) -console.log(` 目标: ${targetDir}`) - -rmSync(targetDir, { recursive: true, force: true }) -mkdirSync(targetDir, { recursive: true }) -cpSync(distDir, targetDir, { recursive: true }) - -console.log(`✓ 已安装到 ${targetDir}`) - -const activeAsar = installedAsarPath() -if (activeAsar) { - const temporaryAsar = path.join(os.tmpdir(), `dagu-ocr-install-${Date.now()}.asar`) - await createPackage(distDir, temporaryAsar) - try { - copyFileSync(temporaryAsar, activeAsar) - console.log(`✓ 已更新 ZTools 实际加载的插件包: ${activeAsar}`) - } finally { - rmSync(temporaryAsar, { force: true }) - } -} else { - console.log('未发现已安装的同名 ASAR,仅保留目录安装') -} - -console.log('提示:重启 ZTools 客户端后生效。') diff --git a/plugins/dagu-ocr/src/capture/desktop-capture.js b/plugins/dagu-ocr/src/capture/desktop-capture.js index 9b7b335c5..34023c803 100644 --- a/plugins/dagu-ocr/src/capture/desktop-capture.js +++ b/plugins/dagu-ocr/src/capture/desktop-capture.js @@ -73,6 +73,21 @@ export function displayPixelSize(display) { }; } +export function isWindowsHost(nav) { + const platform = String(nav?.userAgentData?.platform || nav?.platform || ''); + return /win/i.test(platform); +} + +// HDR 显示器(只在 Windows 判断):ZTools 给插件的桌面捕获源走 DXGI 桌面复制,HDR 下交出来的是 +// 没做色调映射的画面;宿主自带的截图走 GDI,由系统映射成 SDR。插件接口里拿不到映射后的整帧, +// 所以这类显示器不抓桌面帧,直接用宿主截图。宿主返回的显示器对象里,Chromium 在 HDR 开启时 +// 报 10 位色深、scRGB 色彩空间。macOS / Linux 的采集链路没有这个问题,且 macOS 的广色域屏也报 10 位。 +export function isHdrDisplay(display, nav) { + if (!display || typeof display !== 'object' || !isWindowsHost(nav)) return false; + if (Number(display.depthPerComponent) > 8) return true; + return /scrgb|\bpq\b|hdr/i.test(String(display.colorSpace || '')); +} + export function pickSourceForDisplay(sources, display) { const list = Array.isArray(sources) ? sources.filter(Boolean) : []; if (!list.length) return null; @@ -113,6 +128,9 @@ export async function captureDisplay(win, display) { if (typeof host?.desktopCaptureSources !== 'function') { throw new Error('当前环境不支持屏幕捕获'); } + if (isHdrDisplay(display, win?.navigator)) { + throw new Error('HDR 显示器的桌面捕获画面异常,已改用系统截图'); + } const requested = displayPixelSize(display); const sources = await host.desktopCaptureSources({ types: ['screen'], thumbnailSize: requested }); const source = pickSourceForDisplay(sources, display); diff --git a/plugins/dagu-ocr/src/capture/overlay.css b/plugins/dagu-ocr/src/capture/overlay.css index 91554e1b3..987b9bc64 100644 --- a/plugins/dagu-ocr/src/capture/overlay.css +++ b/plugins/dagu-ocr/src/capture/overlay.css @@ -141,15 +141,16 @@ html, body { .capture-btn:disabled:hover { background: transparent; } .capture-btn svg { width: 20px; height: 20px; } +/* 工具条跟随深浅色:界面颜色一律取主题变量,只有压在截图上的元素(尺寸标签、就地文字框)固定配色。 */ .capture-tool.active, .capture-toggle.active { background: var(--capture-accent); - color: #ffffff; + color: var(--primary-contrast, #ffffff); } .capture-btn.capture-primary { background: var(--capture-accent); - color: #ffffff; + color: var(--primary-contrast, #ffffff); } .capture-btn.capture-primary:hover { background: var(--capture-accent-hover); } @@ -174,7 +175,7 @@ html, body { gap: 2px; padding: 2px; border-radius: var(--radius-sm, 8px); - background: rgba(15, 23, 42, .06); + background: var(--hover-bg, rgba(15, 23, 42, .06)); } .capture-toggle { @@ -220,7 +221,7 @@ html, body { padding: 0 6px; border: 1px solid var(--capture-toolbar-border); border-radius: 6px; - background: #ffffff; + background: var(--surface, #ffffff); color: var(--capture-icon); font: inherit; font-size: 12px; @@ -235,7 +236,7 @@ html, body { .capture-color { width: 18px; height: 18px; - border: 1px solid rgba(15, 23, 42, .18); + border: 1px solid var(--border-color, rgba(15, 23, 42, .18)); border-radius: 4px; cursor: pointer; padding: 0; @@ -255,7 +256,7 @@ html, body { border-radius: 6px; overflow: hidden; cursor: pointer; - background: rgba(15, 23, 42, .06); + background: var(--hover-bg, rgba(15, 23, 42, .06)); } .capture-custom-color input { diff --git a/plugins/dagu-ocr/src/capture/overlay.js b/plugins/dagu-ocr/src/capture/overlay.js index 9353dd7f8..98cc1fe89 100644 --- a/plugins/dagu-ocr/src/capture/overlay.js +++ b/plugins/dagu-ocr/src/capture/overlay.js @@ -14,6 +14,7 @@ import { createTextEditor } from './text-editor.js'; import { createToolController } from './tool-controller.js'; import { createToolbar } from './toolbar.js'; import { selectionSizeLabel } from './geometry.js'; +import { handoffToTransfer } from '../share/handoff.js'; const win = globalThis.window; const CHANNEL = 'dagu-ocr-editor'; @@ -338,6 +339,53 @@ function pinImage() { finish(); } +// 交给大古快传后由它接手:覆盖层直接关闭且不发 closed,主窗口只做本地清理, +// 不再恢复窗口或退出插件,免得把刚打开的大古快传关掉。 +let sharing = false; + +async function shareImage() { + const dataUrl = composeImage(); + if (!dataUrl) { + showHint('没有可分享的内容'); + return; + } + if (sharing || state.finished) return; + sharing = true; + showHint('正在打开「大古快传」…', { sticky: true }); + let storage = null; + try { + storage = win.localStorage; + } catch { + // 本地存储不可用时只能依赖跳转接口的返回值。 + } + let result; + try { + result = await handoffToTransfer({ + host: host(), + prepare: win.__daguOcrPrepareShare, + discard: win.__daguOcrDiscardShare, + acked: win.__daguOcrShareAcked, + storage, + dataUrl + }); + } finally { + sharing = false; + } + if (!result.ok) { + showHint(result.message, { sticky: true }); + return; + } + state.finished = true; + send('shared'); + setTimeout(() => { + try { + win.close(); + } catch { + // 窗口已关闭时忽略。 + } + }, 150); +} + function sendResult(action) { const dataUrl = composeImage(); if (!dataUrl) { @@ -384,6 +432,8 @@ async function handleAction(action) { saveImage(); } else if (action === 'pin') { pinImage(); + } else if (action === 'share') { + await shareImage(); } else if (action === 'ocr' || action === 'translate') { sendResult(action); } diff --git a/plugins/dagu-ocr/src/capture/toolbar.js b/plugins/dagu-ocr/src/capture/toolbar.js index e77efc18e..bfe18fef7 100644 --- a/plugins/dagu-ocr/src/capture/toolbar.js +++ b/plugins/dagu-ocr/src/capture/toolbar.js @@ -80,6 +80,7 @@ export function createToolbar({ root, getSettings, onToolChange, onAction, onSet ${button({ id: 'capture-ocr', className: 'capture-btn capture-flow', title: '识别当前图片文字', html: 'OCR' })} ${button({ id: 'capture-translate', className: 'capture-btn capture-flow', title: '识别并翻译当前图片', html: '翻译' })} + ${button({ id: 'capture-share', className: 'capture-btn capture-flow', title: '分享到大古快传', html: '分享' })} ${button({ id: 'capture-close', title: '取消 (Esc)', html: icon('close') })} ${button({ id: 'capture-pin', title: '固定到屏幕', html: icon('pin') })} @@ -212,6 +213,7 @@ export function createToolbar({ root, getSettings, onToolChange, onAction, onSet 'capture-redo': 'redo', 'capture-ocr': 'ocr', 'capture-translate': 'translate', + 'capture-share': 'share', 'capture-close': 'close', 'capture-pin': 'pin', 'capture-save': 'save', diff --git a/plugins/dagu-ocr/src/controls.css b/plugins/dagu-ocr/src/controls.css new file mode 100644 index 000000000..b68702df7 --- /dev/null +++ b/plugins/dagu-ocr/src/controls.css @@ -0,0 +1,182 @@ +/* 两个插件共用的表单控件与配置面板样式:按钮、字段、开关、说明块、卡片面板。源文件在 plugin/src,快传目录里是同步副本。 */ + +.icon-button, .text-button, .swap-button, .ghost-button, .secondary-button, .primary-button { + border: 1px solid transparent; + border-radius: var(--radius-sm); + transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast); +} +.icon-button { + min-height: 32px; + padding: 5px 11px; + border-color: var(--border-color); + background: var(--surface); + color: var(--text-color); + font-size: 12px; + font-weight: 550; +} +.icon-button:hover, .secondary-button:hover { border-color: var(--primary-color); background: var(--hover-bg); } +.primary-button, .secondary-button, .ghost-button { min-height: 34px; padding: 6px 13px; font-size: 13px; font-weight: 600; } +.primary-button { + min-width: 74px; + background: var(--primary-color); + color: var(--primary-contrast); + box-shadow: 0 3px 10px var(--accent-soft); +} +.primary-button:hover { background: var(--primary-hover); } +.secondary-button { border-color: var(--border-color); background: var(--surface); color: var(--text-color); } +.ghost-button { background: transparent; color: var(--text-secondary); } +.ghost-button:hover { color: var(--danger-color); background: rgba(239, 68, 68, .08); } +/* 次级文字入口(复制/编辑/历史等)用次级字体色,主题色只留给主操作按钮。 */ +.text-button { padding: 4px 0; background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 550; } +.text-button:hover { color: var(--text-color); } +.danger-text { color: var(--danger-color); } + +.primary-button, .secondary-button, .ghost-button, .icon-button, .text-button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; +} +.button-icon { display: inline-flex; align-items: center; } +.button-icon svg { width: 16px; height: 16px; } +.icon-button .button-icon svg { width: 17px; height: 17px; } +[data-icon] { display: inline-flex; align-items: center; justify-content: center; } +[data-icon] svg { width: 16px; height: 16px; } +.icon-button [data-icon] svg { width: 17px; height: 17px; } +.swap-button [data-icon] svg { width: 18px; height: 18px; } + +/* 表单里的输入框与下拉框 */ +.field select, .config-fields select { + width: 100%; + min-height: var(--control-height); + padding: 7px 10px; + border: 1px solid var(--border-color); + border-radius: var(--radius-sm); + background: var(--surface-muted); + color: var(--text-color); + outline: none; +} +.form-grid input:focus, .form-grid select:focus, .field select:focus, .config-fields select:focus { + border-color: var(--primary-color); + background: var(--surface); + box-shadow: 0 0 0 3px var(--accent-soft); +} + +/* 配置面板:标题栏、可滚动的卡片内容区、底部操作栏 */ +.config-panel { + width: min(100%, 760px); + max-height: min(88vh, 720px); + max-height: min(88dvh, 720px); + min-height: 0; + display: flex; + flex-direction: column; + overflow: hidden; + border: 1px solid var(--border-color); + border-radius: var(--radius-lg); + background: var(--surface); + box-shadow: var(--shadow-pop); +} +.config-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 16px 18px 12px; + border-bottom: 1px solid var(--divider-color); +} +.config-header h2 { margin: 0; font-size: 16px; } +.config-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 18px 18px; } +.config-card { + margin-top: 10px; + padding: 14px; + border: 1px solid var(--divider-color); + border-radius: var(--radius-md); + background: var(--surface-muted); +} +.config-fields { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 12px; +} +.field, .form-grid label { + display: flex; + flex-direction: column; + gap: 6px; + color: var(--text-secondary); + font-size: 12px; +} +.field > span { font-weight: 600; } +.field select { min-height: var(--control-height); } +.provider-guide { margin-top: 10px; color: var(--text-secondary); font-size: 12px; } +.provider-guide summary { cursor: pointer; color: var(--primary-color); font-weight: 600; user-select: none; } +.provider-guide summary::marker { content: ''; } +.provider-guide[open] summary { margin-bottom: 8px; } +.provider-guide-body { + padding: 10px 12px; + border-left: 3px solid var(--primary-color); + border-radius: 0 var(--radius-sm) var(--radius-sm) 0; + background: var(--accent-soft); + color: var(--text-color); +} +.provider-guide-body p { margin: 0 0 7px; } +.provider-guide-body p:last-child { margin-bottom: 0; } +.provider-guide-body strong { color: var(--primary-color); } +.card-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; } +.card-label span { color: var(--text-color); font-size: 13px; font-weight: 650; } +.card-label small { color: var(--text-secondary); font-size: 11px; } +.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } +.form-grid input, .form-grid select { + min-height: var(--control-height); + padding: 7px 10px; + border: 1px solid var(--border-color); + border-radius: var(--radius-sm); + background: var(--surface); + color: var(--text-color); + outline: none; +} +.full-field { grid-column: 1 / -1; } +.form-grid small { color: var(--text-secondary); font-size: 10px; } +.sync-warning { + margin-top: 14px; + padding: 12px; + border: 1px solid var(--warning-border); + border-radius: var(--radius-md); + background: var(--warning-bg); +} +.switch-line { display: inline-flex; align-items: center; gap: 8px; color: var(--text-color); font-size: 12px; font-weight: 650; } +.switch-line input { position: absolute; opacity: 0; } +.switch-ui { + position: relative; + width: 32px; + height: 18px; + border-radius: var(--radius-full); + background: var(--border-color); + transition: background var(--transition-fast); +} +.switch-ui::after { + content: ''; + position: absolute; + top: 3px; + left: 3px; + width: 12px; + height: 12px; + border-radius: 50%; + background: #fff; + transition: transform var(--transition-fast); +} +.switch-line input:checked + .switch-ui { background: var(--primary-color); } +.switch-line input:checked + .switch-ui::after { transform: translateX(14px); } +.sync-warning p { margin: 8px 0 0 40px; color: var(--text-secondary); font-size: 11px; line-height: 1.55; } +.config-footer { + display: flex; + flex: 0 0 auto; + justify-content: space-between; + gap: 8px; + padding: 13px 18px 15px; + border-top: 1px solid var(--divider-color); +} + +@media (max-width: 700px) { + .config-fields, .form-grid { grid-template-columns: 1fr; } + .full-field { grid-column: auto; } +} diff --git a/plugins/dagu-ocr/src/core/kv.js b/plugins/dagu-ocr/src/core/kv.js new file mode 100644 index 000000000..cc3217c5a --- /dev/null +++ b/plugins/dagu-ocr/src/core/kv.js @@ -0,0 +1,120 @@ +// 宿主 dbStorage 与本地存储的通用键值读写:有 dbStorage 时优先使用它,否则退回本地存储。 +// 大古截图与大古快传共用(大古快传目录内是同步副本)。 + +function parseStoredValue(value) { + if (value === null || value === undefined || value === '') return null; + if (typeof value === 'string') { + try { + return JSON.parse(value); + } catch { + return null; + } + } + return value; +} + +function getLocalStorage(win) { + try { + return win?.localStorage || globalThis.localStorage || null; + } catch { + return null; + } +} + +// window 与 localStorage 通过参数注入,测试里可以替换;不传时取当前全局环境。 +export function createKvStore({ win, localStorage } = {}) { + const host = win || globalThis.window || globalThis; + const local = localStorage || getLocalStorage(host); + + const dbStorage = () => host?.ztools?.dbStorage || host?.utools?.dbStorage || null; + + return { + get dbStorage() { + return dbStorage(); + }, + + hasDbStorage() { + const storage = dbStorage(); + return Boolean( + storage && ( + typeof storage.getItem === 'function' || + typeof storage.get === 'function' || + typeof storage.setItem === 'function' || + typeof storage.set === 'function' + ) + ); + }, + + async readDb(key) { + const storage = dbStorage(); + if (!storage) return null; + if (typeof storage.getItem === 'function') return parseStoredValue(await storage.getItem(key)); + if (typeof storage.get === 'function') return parseStoredValue(await storage.get(key)); + return null; + }, + + async writeDb(key, value) { + const storage = dbStorage(); + if (!storage) return false; + if (typeof storage.setItem === 'function') { + await storage.setItem(key, value); + return true; + } + if (typeof storage.set === 'function') { + await storage.set(key, value); + return true; + } + return false; + }, + + async removeDb(key) { + const storage = dbStorage(); + if (!storage) return false; + if (typeof storage.removeItem === 'function') { + await storage.removeItem(key); + return true; + } + if (typeof storage.delete === 'function') { + await storage.delete(key); + return true; + } + return false; + }, + + readLocal(key) { + try { + return parseStoredValue(local?.getItem(key)); + } catch { + return null; + } + }, + + writeLocal(key, value) { + try { + local?.setItem(key, JSON.stringify(value)); + return true; + } catch { + return false; + } + }, + + removeLocal(key) { + try { + local?.removeItem?.(key); + } catch { + // Storage can be unavailable in private browser contexts. + } + }, + + // 同一个键:先读 dbStorage,读不到再读本地存储。 + async load(key) { + const stored = this.hasDbStorage() ? await this.readDb(key) : null; + return stored ?? this.readLocal(key); + }, + + // 写入当前可用的存储,返回是否写入成功。 + async save(key, value) { + return this.hasDbStorage() ? this.writeDb(key, value) : this.writeLocal(key, value); + } + }; +} diff --git a/plugins/dagu-ocr/src/core/storage.js b/plugins/dagu-ocr/src/core/storage.js index 5a373cb65..87b5b930d 100644 --- a/plugins/dagu-ocr/src/core/storage.js +++ b/plugins/dagu-ocr/src/core/storage.js @@ -1,3 +1,5 @@ +import { createKvStore } from './kv.js'; +import { loadSecrets, saveSecrets } from './synced-secrets.js'; import { normalizeTranslationLanguage } from './translation-languages.js'; export const STORAGE_KEYS = { @@ -9,6 +11,8 @@ export const STORAGE_KEYS = { history: 'ocr_history' }; +const SECRET_KEYS = Object.freeze({ local: STORAGE_KEYS.localSecrets, synced: STORAGE_KEYS.syncedSecrets }); + export const DEFAULT_CONFIG = { ocrProviderId: '', translationProviderId: '', @@ -42,30 +46,6 @@ const SECRET_FIELDS = [ 'myMemoryKey' ]; -function parseStoredValue(value) { - if (value === null || value === undefined || value === '') return null; - if (typeof value === 'string') { - try { - return JSON.parse(value); - } catch { - return null; - } - } - return value; -} - -function getGlobalWindow() { - return globalThis.window || globalThis; -} - -function getLocalStorage() { - try { - return getGlobalWindow().localStorage || globalThis.localStorage || null; - } catch { - return null; - } -} - function pick(source, fields) { return fields.reduce((result, field) => { if (source && source[field] !== undefined) result[field] = source[field]; @@ -107,85 +87,39 @@ function legacyProviderChoices(legacy) { export class SettingsStore { constructor({ win, localStorage } = {}) { - this.win = win || getGlobalWindow(); - this.localStorage = localStorage || getLocalStorage(); + this.kv = createKvStore({ win, localStorage }); } get dbStorage() { - return this.win?.ztools?.dbStorage || this.win?.utools?.dbStorage || null; + return this.kv.dbStorage; } hasDbStorage() { - const storage = this.dbStorage; - return Boolean( - storage && ( - typeof storage.getItem === 'function' || - typeof storage.get === 'function' || - typeof storage.setItem === 'function' || - typeof storage.set === 'function' - ) - ); + return this.kv.hasDbStorage(); } - async readDb(key) { - const storage = this.dbStorage; - if (!storage) return null; - if (typeof storage.getItem === 'function') return parseStoredValue(await storage.getItem(key)); - if (typeof storage.get === 'function') return parseStoredValue(await storage.get(key)); - return null; + readDb(key) { + return this.kv.readDb(key); } - async writeDb(key, value) { - const storage = this.dbStorage; - if (!storage) return false; - if (typeof storage.setItem === 'function') { - await storage.setItem(key, value); - return true; - } - if (typeof storage.set === 'function') { - await storage.set(key, value); - return true; - } - return false; + writeDb(key, value) { + return this.kv.writeDb(key, value); } - async removeDb(key) { - const storage = this.dbStorage; - if (!storage) return false; - if (typeof storage.removeItem === 'function') { - await storage.removeItem(key); - return true; - } - if (typeof storage.delete === 'function') { - await storage.delete(key); - return true; - } - return false; + removeDb(key) { + return this.kv.removeDb(key); } readLocal(key) { - try { - return parseStoredValue(this.localStorage?.getItem(key)); - } catch { - return null; - } + return this.kv.readLocal(key); } writeLocal(key, value) { - try { - this.localStorage?.setItem(key, JSON.stringify(value)); - return true; - } catch { - return false; - } + return this.kv.writeLocal(key, value); } removeLocal(key) { - try { - this.localStorage?.removeItem?.(key); - } catch { - // Storage can be unavailable in private browser contexts. - } + this.kv.removeLocal(key); } async load() { @@ -194,7 +128,6 @@ export class SettingsStore { : null; if (!preferences) preferences = this.readLocal(STORAGE_KEYS.localPreferences); - let localSecrets = this.readLocal(STORAGE_KEYS.localSecrets) || {}; const legacy = this.readLocal(STORAGE_KEYS.legacyConfig); let migrated = false; @@ -206,16 +139,21 @@ export class SettingsStore { targetLang: legacy.targetLang || 'zh-CN', syncSecrets: false }; - localSecrets = { ...localSecrets, ...pick(legacy, SECRET_FIELDS) }; + // 旧配置里的密钥并入本机密钥副本。 + this.writeLocal(STORAGE_KEYS.localSecrets, { + ...this.readLocal(STORAGE_KEYS.localSecrets), + ...pick(legacy, SECRET_FIELDS) + }); migrated = true; } - const config = normalizeConfig({ ...preferences, ...localSecrets }); - - if (config.syncSecrets && this.hasDbStorage()) { - const syncedSecrets = await this.readDb(STORAGE_KEYS.syncedSecrets); - if (syncedSecrets) Object.assign(config, pick(syncedSecrets, SECRET_FIELDS)); - } + const secrets = await loadSecrets({ + kv: this.kv, + keys: SECRET_KEYS, + sync: normalizeConfig(preferences).syncSecrets, + fallback: {} + }); + const config = normalizeConfig({ ...preferences, ...pick(secrets, SECRET_FIELDS) }); if (migrated) { await this.save(config); @@ -228,7 +166,6 @@ export class SettingsStore { async save(config) { const normalized = normalizeConfig(config); const preferences = pick(normalized, PREFERENCE_FIELDS); - const secrets = pick(normalized, SECRET_FIELDS); if (this.hasDbStorage()) { await this.writeDb(STORAGE_KEYS.preferences, preferences); @@ -236,12 +173,12 @@ export class SettingsStore { this.writeLocal(STORAGE_KEYS.localPreferences, preferences); } - this.writeLocal(STORAGE_KEYS.localSecrets, secrets); - if (normalized.syncSecrets && this.hasDbStorage()) { - await this.writeDb(STORAGE_KEYS.syncedSecrets, secrets); - } else if (this.hasDbStorage()) { - await this.removeDb(STORAGE_KEYS.syncedSecrets); - } + await saveSecrets({ + kv: this.kv, + keys: SECRET_KEYS, + secrets: pick(normalized, SECRET_FIELDS), + sync: normalized.syncSecrets + }); return normalized; } diff --git a/plugins/dagu-ocr/src/core/synced-secrets.js b/plugins/dagu-ocr/src/core/synced-secrets.js new file mode 100644 index 000000000..7b7e4ff65 --- /dev/null +++ b/plugins/dagu-ocr/src/core/synced-secrets.js @@ -0,0 +1,20 @@ +// 「密钥」的存取规则,大古截图与大古快传共用(快传目录内是同步副本): +// - 本机副本始终写在插件自己的 localStorage 里,不随 ZTools 同步; +// - 打开「同步密钥」后,另外往 dbStorage 写一份同步副本(dbStorage 的内容随 ZTools 账号备份同步); +// - 关闭「同步密钥」时删除同步副本,保留本机副本;开关打开时读取以同步副本为准。 + +// keys 是 { local, synced } 两个存储键;fallback 在两处都没有数据时返回。 +export async function loadSecrets({ kv, keys, sync, fallback = null }) { + const local = kv.readLocal(keys.local); + if (!sync || !kv.hasDbStorage()) return local ?? fallback; + const synced = await kv.readDb(keys.synced); + return synced ?? local ?? fallback; +} + +// 返回本机副本是否写入成功。 +export async function saveSecrets({ kv, keys, secrets, sync }) { + const saved = kv.writeLocal(keys.local, secrets); + if (sync && kv.hasDbStorage()) await kv.writeDb(keys.synced, secrets); + else if (kv.hasDbStorage()) await kv.removeDb(keys.synced); + return saved; +} diff --git a/plugins/dagu-ocr/src/main.js b/plugins/dagu-ocr/src/main.js index 055cdd8c0..1ebef85d3 100644 --- a/plugins/dagu-ocr/src/main.js +++ b/plugins/dagu-ocr/src/main.js @@ -3,8 +3,9 @@ import App from './App.vue'; import './styles.css'; import { OCRApp } from './ocr.js'; import { pngSizeFromDataUrl } from './image-size.js'; -import { displayUnderCursor, isDesktopCaptureSupported } from './capture/desktop-capture.js'; +import { displayUnderCursor, isDesktopCaptureSupported, isHdrDisplay } from './capture/desktop-capture.js'; import { createPrimeKey, primeCaptureFrame } from './capture/prime-frame.js'; +import { acknowledgeHandoff } from './share/handoff.js'; const win = globalThis.window || globalThis; const EDITOR_PAGE = 'overlay.html'; @@ -100,7 +101,7 @@ function overlayWindowOptions(bounds, show = false) { focusable: true, title: '截图', webPreferences: { - preload: 'preload.js', + preload: 'preload.cjs', backgroundThrottling: false } }; @@ -218,7 +219,7 @@ function openPinWindow({ imageUrl, bounds }) { alwaysOnTop: false, title: '固定截图', webPreferences: { - preload: 'preload.js', + preload: 'preload.cjs', backgroundThrottling: false } }, () => {}); @@ -332,12 +333,20 @@ function startScreenshotFlow() { controller.showStatus('正在准备截图...'); closeOverlayWindow(); + const display = displayUnderCursor(win); + // HDR 显示器上桌面捕获源拿不到正常画面,插件接口里也没有映射后的整帧: + // 直接用 ZTools 自带的截图框选(它走 GDI,HDR 下颜色正常),选完回到同一套标注界面。 + if (isHdrDisplay(display, win.navigator)) { + console.info('[capture] HDR 显示器,改用系统截图框选:', display?.id, display?.depthPerComponent, display?.colorSpace); + startNativeScreenshotFlow(); + return; + } + if (!isDesktopCaptureSupported(win)) { startNativeScreenshotFlow(); return; } - const display = displayUnderCursor(win); const bounds = display?.bounds || { x: 0, y: 0, width: 1280, height: 800 }; // 抓帧与覆盖层窗口创建并行:窗口加载完成时画面通常已就绪,不再等第二轮采集。 const primeKey = createPrimeKey(); @@ -459,6 +468,11 @@ function handleEditorMessage(message) { void controller.handleEditedImage(message.imageUrl, message.action || 'ocr'); return true; } + if (message.event === 'shared') { + // 图片已交给大古快传:只清理本地记录,不恢复主窗口也不退出插件,避免打断对方。 + closeOverlayWindow(); + return true; + } if (message.event === 'closed') { closeOverlayWindow(); if (message.returnInput || message.returnToInput) showMainWindow(); @@ -485,6 +499,19 @@ if (win?.ztools && typeof win.ztools.onPluginEnter === 'function') { win.utools.onPluginEnter(handlePluginEnter); } +// 跳转到别的插件(例如分享到大古快传)时,宿主会让本插件视图退出。 +// 宿主的跳转接口找不到目标时也返回成功,覆盖层要靠这次退出才能确认对方确实接手了。 +const lifecycleHost = win?.ztools || win?.utools; +if (typeof lifecycleHost?.onPluginOut === 'function') { + lifecycleHost.onPluginOut(() => { + // 宿主收起插件时(例如截图期间按 Esc,宿主主进程截获「返回搜索页面」),主视图收到 PluginOut, + // 但全屏冻结画面是独立子窗口,不会自己退出——不关的话它悬在屏幕上,看起来像「按 Esc 没反应」。 + // 分享场景例外:acknowledgeHandoff 写下确认标记后,覆盖层按自己的节奏收尾关闭。 + const acknowledged = acknowledgeHandoff(window.localStorage); + if (!acknowledged) closeOverlayWindow(); + }); +} + window.addEventListener('message', (event) => { const data = event.data || {}; if (data.type === 'daguOcrEditorMessage') { diff --git a/plugins/dagu-ocr/src/share/handoff.js b/plugins/dagu-ocr/src/share/handoff.js new file mode 100644 index 000000000..98bde074a --- /dev/null +++ b/plugins/dagu-ocr/src/share/handoff.js @@ -0,0 +1,109 @@ +// 把当前图片交给「大古快传」插件:写交接文件 → 跳转 → 确认对方确实接手。上传本身由大古快传负责。 + +// 宿主的 redirect 找不到目标插件时只弹一条系统通知,照样返回成功,所以不能靠返回值判断。 +// 跳转成功时宿主会让本插件视图退出(onPluginOut):主窗口收到后把交接编号写进 ACK_KEY; +// 大古快传读到交接文件时也会留下确认文件。两个信号出现任何一个才算交接成功。 +export const PENDING_KEY = 'dagu-ocr-share-pending'; +export const ACK_KEY = 'dagu-ocr-share-ack'; +export const HANDOFF_TIMEOUT_MS = 3000; +const HANDOFF_POLL_MS = 30; + +// 跳转失败时保留在当前界面,用户还可以改用保存或复制。 +const MISSING_TRANSFER = '没有找到「大古快传」:在 ZTools 插件中心安装后,可把截图分享到本地目录或 SSH 服务器'; +const NO_NODE = '分享需要在 ZTools 中安装「大古快传」后使用'; +const PREPARE_FAILED = '准备分享文件失败'; + +function base64Of(dataUrl) { + return String(dataUrl).split(',')[1] || ''; +} + +function createNonce() { + return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`; +} + +// 主窗口在 onPluginOut 时调用:把待确认的交接编号写成确认标记,覆盖层读到后才知道跳转成功了。 +export function acknowledgeHandoff(storage) { + try { + const nonce = storage?.getItem(PENDING_KEY); + if (!nonce) return false; + storage.setItem(ACK_KEY, nonce); + return true; + } catch { + return false; + } +} + +function clearHandoffKeys(storage) { + try { + storage?.removeItem(PENDING_KEY); + storage?.removeItem(ACK_KEY); + } catch { + // 清理失败不影响结果。 + } +} + +// 轮询等待两个确认信号中的任何一个。storage 不可用时无法确认,按「已确认」处理。 +export function waitForHandoff({ storage, nonce, acked = () => false, timeoutMs = HANDOFF_TIMEOUT_MS, pollMs = HANDOFF_POLL_MS } = {}) { + if (!storage) return Promise.resolve(true); + return new Promise((resolve) => { + let settled = false; + const finish = (value) => { + if (settled) return; + settled = true; + clearInterval(timer); + clearTimeout(deadline); + resolve(value); + }; + const check = () => { + let marked = false; + try { + marked = storage.getItem(ACK_KEY) === nonce; + } catch { + // 读不到就继续等,直到超时。 + } + if (marked || acked()) finish(true); + }; + const timer = setInterval(check, pollMs); + const deadline = setTimeout(() => finish(false), timeoutMs); + check(); + }); +} + +// prepare / discard / acked 是 preload 暴露的窄接口:写交接文件、跳转失败时把它删掉、查询对方的确认文件。 +export async function handoffToTransfer({ host, prepare, discard, acked, dataUrl, storage, timeoutMs, pollMs }) { + if (typeof prepare !== 'function') return { ok: false, message: NO_NODE }; + let share; + try { + share = prepare(base64Of(dataUrl)); + } catch (error) { + console.warn('[capture] 写入分享文件失败:', error); + return { ok: false, message: PREPARE_FAILED }; + } + if (!share?.token) return { ok: false, message: PREPARE_FAILED }; + + const usable = storage?.getItem && storage?.setItem ? storage : null; + const nonce = createNonce(); + let redirectFailed = false; + try { + if (usable) { + clearHandoffKeys(usable); + usable.setItem(PENDING_KEY, nonce); + } + if (typeof host?.redirect !== 'function') redirectFailed = true; + else host.redirect(share.label, share.token); + } catch (error) { + console.warn('[capture] 跳转到大古快传失败:', error); + redirectFailed = true; + } + const accepted = !redirectFailed && await waitForHandoff({ + storage: usable, + nonce, + acked: () => Boolean(acked?.(share.fileName)), + ...(timeoutMs ? { timeoutMs } : {}), + ...(pollMs ? { pollMs } : {}) + }); + clearHandoffKeys(usable); + if (accepted) return { ok: true }; + if (typeof discard === 'function') discard(share.fileName); + return { ok: false, message: MISSING_TRANSFER }; +} diff --git a/plugins/dagu-ocr/src/styles.css b/plugins/dagu-ocr/src/styles.css index 4d160a552..2e1d882dc 100644 --- a/plugins/dagu-ocr/src/styles.css +++ b/plugins/dagu-ocr/src/styles.css @@ -1,4 +1,5 @@ @import './theme.css'; +@import './controls.css'; * { box-sizing: border-box; } @@ -31,57 +32,13 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus- gap: 10px; } -.config-header, .result-heading, .section-heading { +.result-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; } -.icon-button, .text-button, .swap-button, .ghost-button, .secondary-button, .primary-button { - border: 1px solid transparent; - border-radius: var(--radius-sm); - transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast); -} -.icon-button { - min-height: 32px; - padding: 5px 11px; - border-color: var(--border-color); - background: var(--surface); - color: var(--text-color); - font-size: 12px; - font-weight: 550; -} -.icon-button:hover, .secondary-button:hover { border-color: var(--primary-color); background: var(--hover-bg); } -.primary-button, .secondary-button, .ghost-button { min-height: 34px; padding: 6px 13px; font-size: 13px; font-weight: 600; } -.primary-button { - min-width: 74px; - background: var(--primary-color); - color: var(--primary-contrast); - box-shadow: 0 3px 10px var(--accent-soft); -} -.primary-button:hover { background: var(--primary-hover); } -.secondary-button { border-color: var(--border-color); background: var(--surface); color: var(--text-color); } -.ghost-button { background: transparent; color: var(--text-secondary); } -.ghost-button:hover { color: var(--danger-color); background: rgba(239, 68, 68, .08); } -/* 次级文字入口(复制/编辑/历史等)用次级字体色,主题色只留给主操作按钮。 */ -.text-button { padding: 4px 0; background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 550; } -.text-button:hover { color: var(--text-color); } -.danger-text { color: var(--danger-color); } - -.primary-button, .secondary-button, .ghost-button, .icon-button, .text-button { - display: inline-flex; - align-items: center; - justify-content: center; - gap: 6px; -} -.button-icon { display: inline-flex; align-items: center; } -.button-icon svg { width: 16px; height: 16px; } -.icon-button .button-icon svg { width: 17px; height: 17px; } -[data-icon] { display: inline-flex; align-items: center; justify-content: center; } -[data-icon] svg { width: 16px; height: 16px; } -.icon-button [data-icon] svg { width: 17px; height: 17px; } -.swap-button [data-icon] svg { width: 18px; height: 18px; } .upload-icon [data-icon] svg { width: 26px; height: 26px; } .drop-area, .input-panel, .workspace-grid, .history-section, .empty-state { border: 1px solid var(--border-color); @@ -143,8 +100,7 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus- outline: none; line-height: 1.65; } -.input-panel textarea:focus, .result-area textarea:focus, .translate-result-area textarea:focus, -.form-grid input:focus, .form-grid select:focus, .config-fields select:focus { +.input-panel textarea:focus, .result-area textarea:focus, .translate-result-area textarea:focus { border-color: var(--primary-color); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); @@ -163,7 +119,7 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus- } .translation-bar .translation-controls { flex: 1; } .result-area > .translation-controls { flex: 0 0 auto; align-self: stretch; } -.translation-controls select, .swap-button, .config-fields select, .form-grid select { +.translation-controls select, .swap-button { width: 100%; min-height: var(--control-height); padding: 7px 10px; @@ -370,111 +326,6 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus- } @keyframes spin { to { transform: rotate(360deg); } } -.config-panel { - width: min(100%, 760px); - max-height: min(88vh, 720px); - max-height: min(88dvh, 720px); - min-height: 0; - display: flex; - flex-direction: column; - overflow: hidden; - border: 1px solid var(--border-color); - border-radius: var(--radius-lg); - background: var(--surface); - box-shadow: var(--shadow-pop); -} -.config-header { padding: 16px 18px 12px; border-bottom: 1px solid var(--divider-color); } -.config-header h2 { margin: 0; font-size: 16px; } -.config-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 18px 18px; } -.config-card { - margin-top: 10px; - padding: 14px; - border: 1px solid var(--divider-color); - border-radius: var(--radius-md); - background: var(--surface-muted); -} -.config-fields { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 12px; -} -.field, .form-grid label { - display: flex; - flex-direction: column; - gap: 6px; - color: var(--text-secondary); - font-size: 12px; -} -.field > span { font-weight: 600; } -.field select { min-height: var(--control-height); } -.provider-guide { margin-top: 10px; color: var(--text-secondary); font-size: 12px; } -.provider-guide summary { cursor: pointer; color: var(--primary-color); font-weight: 600; user-select: none; } -.provider-guide summary::marker { content: ''; } -.provider-guide[open] summary { margin-bottom: 8px; } -.provider-guide-body { - padding: 10px 12px; - border-left: 3px solid var(--primary-color); - border-radius: 0 var(--radius-sm) var(--radius-sm) 0; - background: var(--accent-soft); - color: var(--text-color); -} -.provider-guide-body p { margin: 0 0 7px; } -.provider-guide-body p:last-child { margin-bottom: 0; } -.provider-guide-body strong { color: var(--primary-color); } -.card-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; } -.card-label span { color: var(--text-color); font-size: 13px; font-weight: 650; } -.card-label small { color: var(--text-secondary); font-size: 11px; } -.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } -.form-grid input, .form-grid select { - min-height: var(--control-height); - padding: 7px 10px; - border: 1px solid var(--border-color); - border-radius: var(--radius-sm); - background: var(--surface); - color: var(--text-color); - outline: none; -} -.full-field { grid-column: 1 / -1; } -.form-grid small { color: var(--text-secondary); font-size: 10px; } -.sync-warning { - margin-top: 14px; - padding: 12px; - border: 1px solid var(--warning-border); - border-radius: var(--radius-md); - background: var(--warning-bg); -} -.switch-line { display: inline-flex; align-items: center; gap: 8px; color: var(--text-color); font-size: 12px; font-weight: 650; } -.switch-line input { position: absolute; opacity: 0; } -.switch-ui { - position: relative; - width: 32px; - height: 18px; - border-radius: var(--radius-full); - background: var(--border-color); - transition: background var(--transition-fast); -} -.switch-ui::after { - content: ''; - position: absolute; - top: 3px; - left: 3px; - width: 12px; - height: 12px; - border-radius: 50%; - background: #fff; - transition: transform var(--transition-fast); -} -.switch-line input:checked + .switch-ui { background: var(--primary-color); } -.switch-line input:checked + .switch-ui::after { transform: translateX(14px); } -.sync-warning p { margin: 8px 0 0 40px; color: var(--text-secondary); font-size: 11px; line-height: 1.55; } -.config-footer { - display: flex; - flex: 0 0 auto; - justify-content: space-between; - gap: 8px; - padding: 13px 18px 15px; - border-top: 1px solid var(--divider-color); -} @media (max-width: 860px) { .actions-row { flex-wrap: wrap; } @@ -490,6 +341,4 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus- .translation-bar { align-items: stretch; flex-direction: column; } .text-comparison.with-translation { grid-template-columns: 1fr; } .text-pane textarea, .text-comparison.with-translation .text-pane textarea { height: 210px; min-height: 170px; } - .config-fields, .form-grid { grid-template-columns: 1fr; } - .full-field { grid-column: auto; } } diff --git a/plugins/dagu-ocr/src/theme.js b/plugins/dagu-ocr/src/theme.js index ff382dd19..103a5c460 100644 --- a/plugins/dagu-ocr/src/theme.js +++ b/plugins/dagu-ocr/src/theme.js @@ -1,22 +1,19 @@ -// 主色解析规则与 ZTools 主进程保持一致: -// 只有 primaryColor === 'custom' 时才使用 customColor,否则按命名主题取色阶。 -// 插件页面始终使用浅色画布,因此取浅色色阶,保证白色文字有足够对比。 -const PRIMARY_COLOR_MAP = { - blue: '#0284c7', - purple: '#7c3aed', - green: '#059669', - orange: '#ea580c', - red: '#dc2626', - pink: '#db2777' +// 主色与深浅色都跟随 ZTools,规则与其主进程保持一致: +// - 只有 primaryColor === 'custom' 时才使用 customColor,否则按命名主题取色阶,深色下取深色一组; +// - 深浅色取宿主的 isDark(宿主设置默认跟随系统)。宿主没有主题接口时(浏览器)深浅色取系统的 prefers-color-scheme。 +const PRIMARY_COLORS = { + light: { blue: '#0284c7', purple: '#7c3aed', green: '#059669', orange: '#ea580c', red: '#dc2626', pink: '#db2777' }, + dark: { blue: '#38bdf8', purple: '#a78bfa', green: '#34d399', orange: '#fb923c', red: '#f87171', pink: '#f472b6' } }; const DERIVED_TOKENS = ['--primary-color', '--primary-hover', '--primary-contrast', '--accent-soft', '--focus-ring']; export function resolveThemePrimaryColor(theme = {}) { + const palette = theme.isDark ? PRIMARY_COLORS.dark : PRIMARY_COLORS.light; const named = String(theme.primaryColor || ''); const custom = String(theme.customColor || ''); if (named === 'custom' && /^#[0-9a-f]{6}$/i.test(custom)) return custom.toLowerCase(); - return PRIMARY_COLOR_MAP[named] || PRIMARY_COLOR_MAP.green; + return palette[named] || palette.green; } function parseHexColor(color) { @@ -30,9 +27,11 @@ function toHex({ r, g, b }) { return `#${[r, g, b].map((channel) => Math.max(0, Math.min(255, Math.round(channel))).toString(16).padStart(2, '0')).join('')}`; } -// 主色按钮上的文字需要按亮度自动选黑/白,自定义亮色时不会出现白字发虚。 -function contrastColor({ r, g, b }) { - return (0.299 * r + 0.587 * g + 0.114 * b) / 255 > 0.62 ? '#1f2937' : '#ffffff'; +// 主色按钮上的文字按亮度自动选黑/白,自定义亮色时不会出现白字发虚。 +// 深色下宿主的主色都是偏亮的一组,深色文字的门槛相应放低,否则浅色按钮上会出现白字。 +function contrastColor({ r, g, b }, isDark) { + const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255; + return luminance > (isDark ? 0.5 : 0.62) ? '#1f2937' : '#ffffff'; } export function createZtoolsThemeSync({ win = window, doc = document } = {}) { @@ -41,8 +40,13 @@ export function createZtoolsThemeSync({ win = window, doc = document } = {}) { const clearDerivedTokens = () => { DERIVED_TOKENS.forEach((token) => root.style.removeProperty(token)); }; + // 样式表里 html.dark 这一组变量随之生效。 + const setDark = (isDark) => { + if (isDark) root.classList.add('dark'); + else root.classList.remove('dark'); + }; - const applyColor = (color) => { + const applyColor = (color, isDark) => { const rgb = parseHexColor(color); if (!rgb) { clearDerivedTokens(); @@ -51,7 +55,7 @@ export function createZtoolsThemeSync({ win = window, doc = document } = {}) { const hover = toHex({ r: rgb.r * 0.88, g: rgb.g * 0.88, b: rgb.b * 0.88 }); root.style.setProperty('--primary-color', toHex(rgb)); root.style.setProperty('--primary-hover', hover); - root.style.setProperty('--primary-contrast', contrastColor(rgb)); + root.style.setProperty('--primary-contrast', contrastColor(rgb, isDark)); root.style.setProperty('--accent-soft', `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, .10)`); root.style.setProperty('--focus-ring', `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, .28)`); }; @@ -67,15 +71,34 @@ export function createZtoolsThemeSync({ win = window, doc = document } = {}) { }; const applyTheme = (theme = {}) => { - applyColor(hostInjectedColor() || resolveThemePrimaryColor(theme)); + const isDark = Boolean(theme?.isDark); + setDark(isDark); + applyColor(hostInjectedColor() || resolveThemePrimaryColor(theme), isDark); }; const host = win.ztools; if (typeof host?.getThemeInfo === 'function' && typeof host?.onThemeChange === 'function') { applyTheme(host.getThemeInfo()); host.onThemeChange(applyTheme); - return clearDerivedTokens; + return () => { + clearDerivedTokens(); + setDark(false); + }; } - return () => {}; + // 没有宿主主题接口(普通浏览器):深浅色取系统设置,主色沿用样式表里的默认值。 + let media = null; + try { + media = typeof win.matchMedia === 'function' ? win.matchMedia('(prefers-color-scheme: dark)') : null; + } catch { + media = null; + } + if (!media) return () => {}; + const applySystem = (event) => setDark(Boolean(event?.matches)); + applySystem(media); + media.addEventListener?.('change', applySystem); + return () => { + media.removeEventListener?.('change', applySystem); + setDark(false); + }; } diff --git a/plugins/dagu-ocr/vite.config.js b/plugins/dagu-ocr/vite.config.js index 0a3fbf3d6..cc680bdd9 100644 --- a/plugins/dagu-ocr/vite.config.js +++ b/plugins/dagu-ocr/vite.config.js @@ -14,6 +14,12 @@ export default defineConfig({ }, }, base: './', + // 宿主的开发入口是 http://127.0.0.1:5173/index.html(见 plugin.json 的 development.main)。 + // 不指定 host 时 vite 监听 localhost,Node 17+ 在 Windows 上把它解析成 IPv6 的 ::1, + // 宿主连 127.0.0.1 会被拒绝,页面空白。 + server: { + host: '127.0.0.1', + }, build: { outDir: 'dist', rollupOptions: {