fix(update): 复制 AI 提示词可用性与升级命令版本 (v0.5.3-local.10)

三个问题一起修:

1. 复制不生效:copyText 只试 navigator.clipboard.writeText,在 webview
   (非安全上下文/权限未授予)会抛错直接返回 false,且按钮仍显示原样 →
   表现为「点了没反应」。改为三级降级:Clipboard API → execCommand('copy')
   → 再次 Clipboard API;并新增 update.copyFailed 失败态提示(3s)。

2. 按钮颜色太浅:.dsh-wt_updateBtnCopy 原为 rgba(79,142,247,.18) 半透明底
   + #cfe0ff 浅蓝字,在浅色主题上几乎看不见。改为实心强调色 + 白字 + 加粗,
   并补 hover/active 反馈。

3. 升级命令用的是当前版本:UPDATE_TGZ 写死 v0.5.3-local.9,不随检测结果变化,
   「有新版本」提示里给的却是自己这一版的地址。改为
   worktableUpgrade(tag) 按目标版本生成;index.tsx / split.tsx 两个调用点
   均传 updateInfo.latest。

测试:
- host-transport.test.mjs 调用签名补 tag 参数
- 新增断言:命令必须指向目标版本(local.10 与 local.9 各验一次)

验证:npm run pack 全绿,双资产同源 sha256 2ff7d45a…。
This commit is contained in:
wangheng
2026-12-02 17:51:52 +08:00
parent f2ef7655dd
commit 468b0cebec
12 changed files with 142 additions and 39 deletions
+13 -4
View File
@@ -37,12 +37,21 @@ export function hostPreviewUrl(
/** Keep update instructions on the active profile; Desktop must use its bundled CLI. */
// 本仓发布在自建 Gitea:它不支持 GitHub 的 /releases/latest/download 简写,
// 安装命令必须带具体 tag。这里给固定 tag(随发布更新),避免给出 404 的命令。
const UPDATE_TGZ = 'https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download/v0.5.3-local.9/dsh-worktable.tgz'
// 安装命令必须带具体 tag。tag 由调用方传入(等于检查到的新版本),
// 不再写死当前版本——否则「有新版本」提示里给的却是自己这一版的地址。
const UPDATE_BASE = 'https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download'
export function worktableUpgrade(protocol = typeof location === 'undefined' ? 'http:' : location.protocol) {
export function upgradeCommandFor(tag: string, protocol = typeof location === 'undefined' ? 'http:' : location.protocol): string {
const desktop = protocol === 'dsh-app:'
const command = 'dsh plugin --profile ' + (desktop ? 'desktop' : 'web') + ' add "' + UPDATE_TGZ + '"'
const clean = String(tag || '').trim().replace(/^v/, '')
const t = clean ? 'v' + clean : ''
const url = t ? UPDATE_BASE + '/' + t + '/dsh-worktable.tgz' : UPDATE_BASE + '/'
return 'dsh plugin --profile ' + (desktop ? 'desktop' : 'web') + ' add "' + url + '"'
}
export function worktableUpgrade(tag: string, protocol = typeof location === 'undefined' ? 'http:' : location.protocol) {
const desktop = protocol === 'dsh-app:'
const command = upgradeCommandFor(tag, protocol)
const prompt = desktop
? '帮我升级 dsh-worktable。我当前使用官方桌面端:先定位该桌面端自带的 dsh CLI 并准备更新,再提醒我完整退出桌面端。确认退出后使用该 CLI 执行 ' + command + '。不要使用网页端 CLI,不要修改 web profile,不要自动杀进程或重启;完成后提醒我手动重新打开桌面端。'
: '帮我升级 dsh-worktable:执行 ' + command + ',完成后提醒我重启 dsh web 并刷新页面'