fix(update): 更新检查改查本仓 Gitea,修复查不到新版 (v0.5.3-local.6)

本仓从上游 fork 后,更新检查仍查上游 GitHub,导致:
- 上游只发官方版(无本地补丁),本仓 -local.* 版本它不知道
- 国内网络访问 api.github.com 常失败,显示「上次检查未成功」
- 安装命令也指向上游 github.com

三处改动:
- updateCheck.ts(控制室):改为 Gitea API /api/v1/repos/xiaoqu/dsh-worktable/releases/latest
- index.tsx(设置面板,独立实现):同样改 Gitea API
- hostTransport.ts:安装命令改为带具体 tag 的本仓 tgz

注意 Gitea 不支持 /releases/latest/download 简写(实测 404),
安装命令必须带具体 tag,UPDATE_TGZ 每次发版需同步更新。

版本比较无需改动:cmpVer('v0.5.2-local.6','0.5.3-local.5') = -1,
core 段 0.5.2 < 0.5.3 已能正确判定有新版。

测试同步:sidebar-popup.test.mjs 的 releaseUrl 断言改为新 API 地址。

验证:npm run pack 全绿,双资产同源 sha256 95b2b6b1…。
This commit is contained in:
wangheng
2026-12-02 17:00:56 +08:00
parent 61711299ec
commit f65694516f
10 changed files with 76 additions and 29 deletions
+5 -1
View File
@@ -36,9 +36,13 @@ 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.6/dsh-worktable.tgz'
export function worktableUpgrade(protocol = typeof location === 'undefined' ? 'http:' : location.protocol) {
const desktop = protocol === 'dsh-app:'
const command = 'dsh plugin --profile ' + (desktop ? 'desktop' : 'web') + ' add "https://github.com/Aisland-SJL/dsh-worktable/releases/latest/download/dsh-worktable.tgz"'
const command = 'dsh plugin --profile ' + (desktop ? 'desktop' : 'web') + ' add "' + UPDATE_TGZ + '"'
const prompt = desktop
? '帮我升级 dsh-worktable。我当前使用官方桌面端:先定位该桌面端自带的 dsh CLI 并准备更新,再提醒我完整退出桌面端。确认退出后使用该 CLI 执行 ' + command + '。不要使用网页端 CLI,不要修改 web profile,不要自动杀进程或重启;完成后提醒我手动重新打开桌面端。'
: '帮我升级 dsh-worktable:执行 ' + command + ',完成后提醒我重启 dsh web 并刷新页面'
+6 -3
View File
@@ -30,8 +30,11 @@ import { loadHostState, queueHostSave, markHydrated, staysReadOnly, flushHostSav
type OrderBy = 'manual' | 'recent'
type DockMode = 'footer' | 'float'
// ── 更新检查(客户端直连 GitHub Releases API,只读 GET;失败静默)──
const UPDATE_REPO = 'Aisland-SJL/dsh-worktable'
// ── 更新检查(客户端直连本仓 Gitea Releases API,只读 GET;失败静默)──
// 本仓是内部补丁分发仓:上游只发官方版(无本地补丁),
// 查上游既看不到本仓版本,国内网络也常失败。
const UPDATE_HOST = 'https://gitea.ququclean.com'
const UPDATE_REPO = 'xiaoqu/dsh-worktable'
const { command: UPGRADE_CMD, prompt: UPGRADE_AI, desktop: DESKTOP_HOST } = worktableUpgrade()
// 更新提示图标(手绘 SVG,避免 emoji 跨平台渲染差异)
const ICON_SYNC = (
@@ -1094,7 +1097,7 @@ function WorktableSection(props: any) {
const ctrl = new AbortController()
const timer = setTimeout(() => ctrl.abort(), 8000) // 单次 8s 超时,计入下一轮重试
try {
const r = await fetch('https://api.github.com/repos/' + UPDATE_REPO + '/releases/latest', { headers: { Accept: 'application/vnd.github+json' }, cache: 'no-store', signal: ctrl.signal })
const r = await fetch(UPDATE_HOST + '/api/v1/repos/' + UPDATE_REPO + '/releases/latest', { headers: { Accept: 'application/json' }, cache: 'no-store', signal: ctrl.signal })
if (r.ok) d = await r.json() as { tag_name?: string; body?: string; html_url?: string }
else if (r.status === 403 || r.status === 404) break // 限流/不存在:不再重试
} catch { /* 网络抖动/超时:下一轮重试 */ }
+5 -2
View File
@@ -1,7 +1,10 @@
/** 更新检查核心(控制室公告页使用;设置面板保留自身实现,后续版本统一去重)。键与设置面板共用。 */
declare const __WT_VERSION__: string
export const LOCAL_VERSION = typeof __WT_VERSION__ === 'undefined' ? 'dev' : __WT_VERSION__
const UPDATE_REPO = 'Aisland-SJL/dsh-worktable'
// 本仓是内部补丁分发仓,更新源必须是自己的 Gitea,而不是上游 GitHub:
// 上游只发布官方版(无本地补丁),查它既看不到本仓版本,国内网络也常失败。
const UPDATE_HOST = 'https://gitea.ququclean.com'
const UPDATE_REPO = 'xiaoqu/dsh-worktable'
export type UpdateStatus = 'idle' | 'checking' | 'uptodate' | 'failed'
export type UpdateInfo = { latest: string; notes: string; url: string }
@@ -92,7 +95,7 @@ export async function checkUpdate(force = false): Promise<{ status: UpdateStatus
const ctrl = new AbortController()
const timer = setTimeout(() => ctrl.abort(), 8000)
try {
const r = await fetch('https://api.github.com/repos/' + UPDATE_REPO + '/releases/latest', { headers: { Accept: 'application/vnd.github+json' }, cache: 'no-store', signal: ctrl.signal })
const r = await fetch(UPDATE_HOST + '/api/v1/repos/' + UPDATE_REPO + '/releases/latest', { headers: { Accept: 'application/json' }, cache: 'no-store', signal: ctrl.signal })
if (r.ok) d = (await r.json()) as { tag_name?: string; body?: string; html_url?: string }
else if (r.status === 403 || r.status === 404) break
} catch { /* 网络抖动/超时:下一轮重试 */ }