提交记录修改VERSION+1 −1看文件
修改desktop/Cage.swift+0 −9看文件
修改desktop/Updates.swift+7 −8看文件
修改desktop/UpdatesTests.swift+8 −2看文件
修改desktop/windows/AppUpdater.cs+2 −4看文件
修改desktop/windows/MainWindow.cs+1 −1看文件
修改docs/design/workbench.md+4 −2看文件
修改docs/getting-started.md+3 −1看文件
修改docs/releasing.md+1 −1看文件
修改docs/windows.md+1 −1看文件
修改ui/package-lock.json+2 −2看文件
修改ui/package.json+1 −1看文件
新增ui/scripts/app-update-ui-smoke.mjs+82 −0看文件
修改ui/scripts/recovery-ui-smoke.mjs+7 −10看文件
修改ui/src/app-updates.jsx+78 −69看文件
修改ui/src/style.css+25 −16看文件
修改www/package-lock.json+2 −2看文件
修改www/package.json+1 −1看文件
| @@ -1 +1 @@ | ||
| 1 | 删除:0.1.3-alpha.1 | |
| 1 | 新增:0.1.3-alpha.2 | |
| @@ -94,15 +94,6 @@ final class CageApp: NSObject, NSApplicationDelegate, NSWindowDelegate, WKNaviga | ||
| 94 | 94 | appUpdater = CageAppUpdater(bundleURL: Bundle.main.bundleURL, onChange: { [weak self] state in |
| 95 | 95 | guard let data = try? JSONSerialization.data(withJSONObject: state), let json = String(data: data, encoding: .utf8) else { return } |
| 96 | 96 | self?.webView.evaluateJavaScript("window.dispatchEvent(new CustomEvent('cage-app-update',{detail:\(json)}));", completionHandler: nil) |
| 97 | 删除: }, confirmStop: { [weak self] completion in | |
| 98 | 删除: guard let self else { completion(false); return } | |
| 99 | 删除: let alert = NSAlert() | |
| 100 | 删除: alert.messageText = "更新已下载,保存并停止环境后安装重启" | |
| 101 | 删除: alert.informativeText = "请先保存编辑器中的文件并结束正在运行的工作。继续后 Cage 会停止环境、安装已验证的更新并重新启动。" | |
| 102 | 删除: alert.addButton(withTitle: "已保存,停止并安装") | |
| 103 | 删除: alert.addButton(withTitle: "稍后安装") | |
| 104 | 删除: self.window.makeKeyAndOrderFront(nil) | |
| 105 | 删除: alert.beginSheetModal(for: self.window) { completion($0 == .alertFirstButtonReturn) } | |
| 106 | 97 | }, quit: { [weak self] in self?.allowQuit = true; NSApp.terminate(nil) }, reconnect: { [weak self] in self?.bootstrap() }) |
| 107 | 98 | window.makeKeyAndOrderFront(nil) |
| 108 | 99 | NSApp.activate(ignoringOtherApps: true) |
| @@ -155,6 +155,9 @@ enum CageUpdateFiles { | ||
| 155 | 155 | if let expectedTeam, actual != expectedTeam { throw CageUpdateError("更新应用的发布者不匹配") } |
| 156 | 156 | return actual |
| 157 | 157 | } |
| 158 | 新增: static func verifyArchitecture(_ executable: URL, validation: CageUpdateValidation? = nil) throws { | |
| 159 | 新增: _ = try run("/usr/bin/lipo", [executable.path, "-verify_arch", "arm64"], validation: validation) | |
| 160 | 新增: } | |
| 158 | 161 | static func verifyApp(_ url: URL, version: String, team: String, gatekeeper: Bool = true, validation: CageUpdateValidation? = nil) throws { |
| 159 | 162 | try validation?.checkCancellation() |
| 160 | 163 | let values = try url.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey]) |
| @@ -170,7 +173,7 @@ enum CageUpdateFiles { | ||
| 170 | 173 | (1...3).contains(parts.count), ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: parts[0], minorVersion: parts.count > 1 ? parts[1] : 0, patchVersion: parts.count > 2 ? parts[2] : 0)) else { throw CageUpdateError("此更新需要更高版本的 macOS") } |
| 171 | 174 | } |
| 172 | 175 | _ = try signingInfo(url, bundle: true, expectedTeam: team) |
| 173 | 删除: _ = try run("/usr/bin/lipo", ["-verify_arch", "arm64", url.appendingPathComponent("Contents/MacOS/Cage").path], validation: validation) | |
| 176 | 新增: try verifyArchitecture(url.appendingPathComponent("Contents/MacOS/Cage"), validation: validation) | |
| 174 | 177 | for name in ["cage", "mihomo", "CageUpdateInstaller"] { |
| 175 | 178 | let nested = url.appendingPathComponent("Contents/Resources/\(name)") |
| 176 | 179 | guard FileManager.default.fileExists(atPath: nested.path) else { throw CageUpdateError("更新包缺少必要的应用组件") } |
| @@ -225,7 +228,6 @@ final class CageAppUpdater { | ||
| 225 | 228 | private let bundleURL: URL |
| 226 | 229 | private let root: URL |
| 227 | 230 | private let onChange: ([String: Any]) -> Void |
| 228 | 删除: private let confirmStop: (@escaping (Bool) -> Void) -> Void | |
| 229 | 231 | private let quit: () -> Void |
| 230 | 232 | private let reconnect: () -> Void |
| 231 | 233 | private var state: [String: Any] |
| @@ -240,9 +242,9 @@ final class CageAppUpdater { | ||
| 240 | 242 | private var waitingForTermination = false |
| 241 | 243 | private var installationCommitted = false |
| 242 | 244 | |
| 243 | 删除: init(bundleURL: URL, onChange: @escaping ([String: Any]) -> Void, confirmStop: @escaping (@escaping (Bool) -> Void) -> Void, quit: @escaping () -> Void, reconnect: @escaping () -> Void) { | |
| 245 | 新增: init(bundleURL: URL, onChange: @escaping ([String: Any]) -> Void, quit: @escaping () -> Void, reconnect: @escaping () -> Void) { | |
| 244 | 246 | self.bundleURL = bundleURL.resolvingSymlinksInPath() |
| 245 | 删除: self.onChange = onChange; self.confirmStop = confirmStop; self.quit = quit; self.reconnect = reconnect | |
| 247 | 新增: self.onChange = onChange; self.quit = quit; self.reconnect = reconnect | |
| 246 | 248 | let path = ProcessInfo.processInfo.environment["CLAUDE_CAGE_CONFIG"] ?? FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".claude-cage/config.json").path |
| 247 | 249 | root = URL(fileURLWithPath: path).deletingLastPathComponent().appendingPathComponent("updates", isDirectory: true) |
| 248 | 250 | let version = Bundle(url: bundleURL)?.object(forInfoDictionaryKey: "CageVersion") as? String ?? "开发版本" |
| @@ -466,10 +468,7 @@ final class CageAppUpdater { | ||
| 466 | 468 | self.quit() |
| 467 | 469 | } catch { self.abortInstaller(); self.failure("无法开始安装,原应用已保留"); self.reconnect() } |
| 468 | 470 | case "stop_required" where !stop: |
| 469 | 删除: self.confirmStop { confirmed in | |
| 470 | 删除: if confirmed { self.prepareEnvironment(stop: true) } | |
| 471 | 删除: else { self.abortInstaller(); self.change(["phase": "ready", "message": "更新已下载,保存工作后可继续安装", "retryable": true]) } | |
| 472 | 删除: } | |
| 471 | 新增: self.prepareEnvironment(stop: true) | |
| 473 | 472 | default: |
| 474 | 473 | self.abortInstaller(); self.failure(result["message"] as? String ?? "环境未能安全停止,更新未安装") |
| 475 | 474 | } |
| @@ -22,8 +22,12 @@ enum UpdatesTests { | ||
| 22 | 22 | let root = FileManager.default.temporaryDirectory.appendingPathComponent("cage-updates-test-" + UUID().uuidString) |
| 23 | 23 | try CageUpdateFiles.privateDirectory(root) |
| 24 | 24 | defer { try? FileManager.default.removeItem(at: root) } |
| 25 | 新增: // Exercise the production lipo invocation against a real Mach-O binary. | |
| 26 | 新增: // lipo consumes every argument after -verify_arch as an architecture. | |
| 27 | 新增: try CageUpdateFiles.verifyArchitecture(URL(fileURLWithPath: CommandLine.arguments[0])) | |
| 25 | 28 | let hashFile = root.appendingPathComponent("content") |
| 26 | 29 | try CageUpdateFiles.write(Data("abc".utf8), to: hashFile) |
| 30 | 新增: try rejects("non-Mach-O executable refused") { try CageUpdateFiles.verifyArchitecture(hashFile) } | |
| 27 | 31 | let hash = try CageUpdateFiles.digest(hashFile) |
| 28 | 32 | try expect(hash == "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", "stream digest") |
| 29 | 33 | let permissions = try FileManager.default.attributesOfItem(atPath: hashFile.path) |
| @@ -114,7 +118,7 @@ enum UpdatesTests { | ||
| 114 | 118 | if let value = savedEnvironment[key] { setenv(key, value, 1) } else { unsetenv(key) } |
| 115 | 119 | } |
| 116 | 120 | } |
| 117 | 删除: let updater = CageAppUpdater(bundleURL: old, onChange: { _ in }, confirmStop: { $0(false) }, quit: {}, reconnect: {}) | |
| 121 | 新增: let updater = CageAppUpdater(bundleURL: old, onChange: { _ in }, quit: {}, reconnect: {}) | |
| 118 | 122 | try expect(updater.awaitingInitialWorkbench, "newly installed uninitialized window permits native rollback termination") |
| 119 | 123 | updater.markLaunchReady() |
| 120 | 124 | try expect(!updater.awaitingInitialWorkbench, "initialized workbench keeps ordinary quit confirmation") |
| @@ -123,13 +127,15 @@ enum UpdatesTests { | ||
| 123 | 127 | if CommandLine.arguments.count == 2 { |
| 124 | 128 | let signed = URL(fileURLWithPath: CommandLine.arguments[1]) |
| 125 | 129 | let team = try CageUpdateFiles.signingInfo(signed, bundle: true) |
| 130 | 新增: let version = Bundle(url: signed)?.object(forInfoDictionaryKey: "CageVersion") as? String ?? "" | |
| 131 | 新增: try CageUpdateFiles.verifyApp(signed, version: version, team: team, gatekeeper: false) | |
| 126 | 132 | try rejects("different publisher refused") { _ = try CageUpdateFiles.signingInfo(signed, bundle: true, expectedTeam: "AAAAAAAAAA") } |
| 127 | 133 | let tampered = root.appendingPathComponent("tampered.app") |
| 128 | 134 | try FileManager.default.copyItem(at: signed, to: tampered) |
| 129 | 135 | let plist = tampered.appendingPathComponent("Contents/Info.plist") |
| 130 | 136 | try Data("tampered".utf8).write(to: plist) |
| 131 | 137 | try rejects("real signature tampering refused") { _ = try CageUpdateFiles.signingInfo(tampered, bundle: true, expectedTeam: team) } |
| 132 | 删除: print("PASS: real Developer ID signature, wrong publisher, and tampered App checks") | |
| 138 | 新增: print("PASS: real App architecture and Developer ID signature, wrong publisher, and tampered App checks") | |
| 133 | 139 | } |
| 134 | 140 | print("PASS: versions, private files, containment, replacement/double-failure rollback, process cancellation, and temporary image cleanup") |
| 135 | 141 | } |
| @@ -10,16 +10,15 @@ internal sealed class AppUpdater : IDisposable | ||
| 10 | 10 | public static string Version => typeof(AppUpdater).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "development"; |
| 11 | 11 | public static string Root => Path.Combine(Backend.Root, "updates"); |
| 12 | 12 | private readonly Action<Dictionary<string, object?>> changed; |
| 13 | 删除: private readonly Func<bool> confirmStop; | |
| 14 | 13 | private readonly Action quit, reconnect; |
| 15 | 14 | private readonly Dictionary<string, object?> state = new() { ["phase"] = "idle", ["currentVersion"] = Version, ["message"] = "" }; |
| 16 | 15 | private CancellationTokenSource? cancellation; |
| 17 | 16 | private InstallPlan? prepared; |
| 18 | 17 | private bool committed; |
| 19 | 18 | |
| 20 | 删除: public AppUpdater(Action<Dictionary<string, object?>> changed, Func<bool> confirmStop, Action quit, Action reconnect) | |
| 19 | 新增: public AppUpdater(Action<Dictionary<string, object?>> changed, Action quit, Action reconnect) | |
| 21 | 20 | { |
| 22 | 删除: this.changed = changed; this.confirmStop = confirmStop; this.quit = quit; this.reconnect = reconnect; | |
| 21 | 新增: this.changed = changed; this.quit = quit; this.reconnect = reconnect; | |
| 23 | 22 | try |
| 24 | 23 | { |
| 25 | 24 | var result = Path.Combine(Root, "last-result.json"); |
| @@ -140,7 +139,6 @@ internal sealed class AppUpdater : IDisposable | ||
| 140 | 139 | var (exit, data) = await Backend.Json(["prepare-update", "--json"], token); |
| 141 | 140 | if (data.Text("status") == "stop_required") |
| 142 | 141 | { |
| 143 | 删除: if (!confirmStop()) { Change("ready", "更新已下载,保存工作后可继续安装", true); return; } | |
| 144 | 142 | (exit, data) = await Backend.Json(["prepare-update", "--json", "--stop"], token); |
| 145 | 143 | } |
| 146 | 144 | if (exit != 0 || data.Text("status") != "prepared") throw new IOException(data.Text("message") is { Length: > 0 } detail ? detail : "环境未能安全停止"); |
| @@ -52,7 +52,7 @@ internal sealed class MainWindow : Form | ||
| 52 | 52 | trayMenu.Items.Add("退出 Cage…", null, (_, _) => RequestQuit()); |
| 53 | 53 | tray = new NotifyIcon { Icon = Icon, Text = "Cage", Visible = true, ContextMenuStrip = trayMenu }; |
| 54 | 54 | tray.DoubleClick += (_, _) => RestoreWindow(); |
| 55 | 删除: updater = new AppUpdater(PublishUpdate, ConfirmStop, () => { allowQuit = true; Close(); }, () => _ = Bootstrap()); | |
| 55 | 新增: updater = new AppUpdater(PublishUpdate, () => { allowQuit = true; Close(); }, () => _ = Bootstrap()); | |
| 56 | 56 | Shown += async (_, _) => { |
| 57 | 57 | if (Program.SmokeOutput != null) _ = SmokeDeadline(); |
| 58 | 58 | await Initialize(); |
| @@ -178,7 +178,9 @@ Claude Desktop 的私有 D-Bus 会话运行 `org.freedesktop.portal.FileChooser` | ||
| 178 | 178 | |
| 179 | 179 | ## 更新与后台接管 |
| 180 | 180 | |
| 181 | 删除:左下角更新入口在发现新版时显示向下箭头,悬浮提示“下载更新”。点击后通过所选受管代理下载 Release 安装包并核验摘要、应用身份及平台签名:macOS 检查同一 Developer ID Team 与 Apple 验证结果;Windows 检查 Authenticode 信任链、相同发布者公钥和安装器版本,随后安装并重启;代理失败无直连回退。有运行环境时,原生确认框要求用户先保存并停止。安装或新工作台启动失败时尝试恢复旧 App,无法恢复时保留备份和失败信息。ad-hoc 或未签名开发构建不进入自动安装流程。 | |
| 181 | 新增:应用启动后自动检查更新,运行期间每六小时重查;失败后每五分钟重试,隐藏窗口时暂停检查,恢复显示后按到期间隔重查。正常状态不显示入口,发现新版时在左下角显示金色圆形下载按钮,悬浮说明目标版本及停止环境、重启的影响。用户保存工作后点击一次即可开始,不显示更新卡片;下载时按钮显示环形进度与百分比,校验及安装时显示忙碌状态。失败显示原因并保留重试入口。Linux 使用系统安装包更新,不显示自动安装按钮。 | |
| 182 | 新增: | |
| 183 | 新增:点击后通过所选受管代理下载 Release 安装包并核验摘要、应用身份及平台签名:macOS 检查同一 Developer ID Team 与 Apple 验证结果;Windows 检查 Authenticode 信任链、相同发布者公钥和安装器版本。通过后自动停止环境、安装并重启,不再二次确认;代理失败无直连回退。安装或新工作台启动失败时尝试恢复旧 App,无法恢复时保留备份和失败信息。ad-hoc 或未签名开发构建不进入自动安装流程。 | |
| 182 | 184 | |
| 183 | 185 | 更新源为公开 GitHub Releases 接口,不需要 GitHub 凭据,也不读取浏览器登录会话。访问失败时显示原因;草稿、附件缺失或非公开发行物不能作为可用更新。首次安装使用对应平台的 macOS DMG、Windows EXE 或 Linux DEB。macOS 与可信签名的 Windows 版本由应用内更新器检查和下载;Windows 未签名预览版和 Linux 系统包手动更新。 |
| 184 | 186 | |
| @@ -188,7 +190,7 @@ Claude Desktop 的私有 D-Bus 会话运行 `org.freedesktop.portal.FileChooser` | ||
| 188 | 190 | |
| 189 | 191 | 不支持版本握手的旧控制服务需要一次明确的停止与迁移操作。启动器使用认证会话提交停止,确认同一任务成功、环境停止和终端关闭,再核对进程所属用户、可执行文件、完整启动参数、工作目录、监听端口和启动时间后发送退出信号。身份变化、停止失败或退出超时都会中止更新,不发送强制杀死信号。此兼容操作仅支持 macOS,普通启动不会执行。 |
| 190 | 192 | |
| 191 | 删除:安装器共用 `cage prepare-update --json`:空闲后台退出后返回 `prepared`,仍需保存停止时返回 `stop_required`;用户确认后调用 `prepare-update --stop --json` 完成停止与退出。失败以非零退出码和 `error` 状态返回。该入口不启动新后台;安装器替换应用并重新打开后,由常规启动入口接管。 | |
| 193 | 新增:安装器共用 `cage prepare-update --json`:空闲后台退出后返回 `prepared`,存在运行环境时返回 `stop_required`;安装器继续调用 `prepare-update --stop --json` 完成停止与退出。单次更新点击已授权该停止操作,安装器不再弹出确认。失败以非零退出码和 `error` 状态返回。该入口不启动新后台;安装器替换应用并重新打开后,由常规启动入口接管。 | |
| 192 | 194 | |
| 193 | 195 | ## 持久环境的组件与工具版本 |
| 194 | 196 | |
| @@ -186,7 +186,9 @@ Cage 使用轻量 Linux 虚拟机,没有完整桌面。浏览器与编辑器 | ||
| 186 | 186 | |
| 187 | 187 | 首次安装请下载公开 Release 的 DMG。应用内更新用于后续版本升级。 |
| 188 | 188 | |
| 189 | 删除:应用内更新入口在左下角。有新版时,向下箭头悬浮显示“下载更新”;点击后自动下载、校验、安装并重启。有环境或任务运行时,下载校验完成后会弹出原生确认框,请保存文件再确认停止;暂不安装可保留下载结果,稍后继续。应用更新会结束工作台终端,保留项目、配置、虚拟磁盘和登录状态。安装或启动失败时会尝试恢复旧应用,并显示失败原因。 | |
| 189 | 新增:应用会在启动后自动检查更新,运行期间每六小时重查;检查失败后每五分钟重试,隐藏窗口期间暂停检查。没有新版时不显示更新入口。有新版时,左下角显示金色圆形下载按钮;请先保存文件并结束运行中的任务,再点击一次。按钮会显示环形下载进度和百分比,下载校验完成后自动停止环境、安装并重启,不再弹出确认框。应用更新会结束工作台终端,保留项目、配置、虚拟磁盘和登录状态。失败时显示原因,点击原按钮可重试。 | |
| 190 | 新增: | |
| 191 | 新增:macOS 的 `0.1.3-alpha.1` 及更早公开版本存在本机更新校验错误。遇到“本机更新验证未完成”时,请保存文件、停止环境并退出 Cage,从官方 Release 下载 `0.1.3-alpha.2` 或更新的 DMG,替换原来的应用一次;已有项目和数据会保留。修复版之后可使用应用内更新。 | |
| 190 | 192 | |
| 191 | 193 | 检查和下载使用已经应用并运行的所选代理,失败不会改用主机直连。自动安装要求当前 App 与新 App 使用相同发布者的 Developer ID 签名,且新包通过 Apple 验证;ad-hoc 开发构建不能自动安装。更新器使用公开的 GitHub Releases 接口,无需 GitHub 登录,也不读取浏览器会话。若提示更新源不可访问,先确认所选代理可用,再检查对应 Release 是否仍公开且附件完整;需要手动下载时使用同一公开 Release。实际安装、重启和恢复的验收范围以该版本说明为准。 |
| 192 | 194 | |
| @@ -59,7 +59,7 @@ DMG 提交已 Accepted 时,直接对原 DMG 执行 `xcrun stapler staple`、`x | ||
| 59 | 59 | |
| 60 | 60 | 应用内更新读取公开 Release 中与版本对应的 `Cage-<版本>-macos-arm64.dmg` 和 `SHA256SUMS`,通过所选受管代理获取,无直连回退。发布包及其中的控制程序、代理核心和更新安装器须由与当前 App 相同的 Developer ID Team 签名,并通过公证与 Gatekeeper 验证;ad-hoc 开发构建会被自动安装流程拒绝。公开下载源无需 GitHub 凭据;发布者仍须按每个版本分别验证下载、安装与重启,不能将附件公开可读等同于升级验收通过。 |
| 61 | 61 | |
| 62 | 删除:客户端下载校验后自动进入安装;存在运行环境时先取得用户保存停止的确认,再停止环境和控制服务、替换 App 并重启。版本接管与启动失败恢复见[工作台设计](design/workbench.md#更新与后台接管)。配置、代理和虚拟磁盘位于用户数据目录,替换或删除 App 不会自动删除这些数据;Linux 组件与工具另行升级。 | |
| 62 | 新增:客户端自动检查新版,仅在有可安装更新时显示圆形按钮。用户保存工作后点击一次,下载校验完成即停止环境和控制服务、替换 App 并重启,不再二次确认。版本接管与启动失败恢复见[工作台设计](design/workbench.md#更新与后台接管)。配置、代理和虚拟磁盘位于用户数据目录,替换或删除 App 不会自动删除这些数据;Linux 组件与工具另行升级。 | |
| 63 | 63 | |
| 64 | 64 | ## 客机工具版本与来源 |
| 65 | 65 | |
| @@ -43,7 +43,7 @@ Windows 快捷键以 `Ctrl` 为主:`Ctrl+O` 打开项目、`Ctrl+T` 新建网 | ||
| 43 | 43 | |
| 44 | 44 | 应用内更新从固定的公开 GitHub Releases 来源选择 Windows x64 安装器,并沿用预发行与正式版通道规则。检查与下载经过已经应用并运行的 Cage 代理,不回退主机直连。下载安装器后校验 SHA-256、版本、产品名称和 Authenticode 签名;当前应用与新安装器必须具有相同的发布者公钥,未签名开发包不能自动安装更新。 |
| 45 | 45 | |
| 46 | 删除:有运行任务时,安装前会要求保存并确认停止。更新器先备份应用,再通过工作台统一入口停止环境、代理和控制服务,等待当前窗口退出后执行静默安装。新应用完成工作台启动确认后才认定成功;安装或启动失败时尝试恢复旧程序,保留失败原因和必要备份。磁盘空间不足、文件被其他软件占用等情况可能阻止自动恢复,应按错误信息处理。 | |
| 46 | 新增:没有新版时隐藏更新按钮;有新版时显示金色圆形按钮。用户先保存文件并结束运行中的任务,再点击一次,按钮显示环形下载进度和百分比。校验通过后自动安装,不再二次确认。更新器先备份应用,再通过工作台统一入口停止环境、代理和控制服务,等待当前窗口退出后执行静默安装。新应用完成工作台启动确认后才认定成功;安装或启动失败时尝试恢复旧程序,保留失败原因和必要备份。磁盘空间不足、文件被其他软件占用等情况可能阻止自动恢复,应按错误信息处理。 | |
| 47 | 47 | |
| 48 | 48 | 手动更新前也应保存文件、停止环境并退出 Cage,再运行新版安装器。旧后台仍运行时安装器会拒绝覆盖。更新应用不等于更新 Linux 内所有工具;工具升级在“设置 → 环境与恢复”中单独执行。 |
| 49 | 49 | |
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "cage-workbench", |
| 3 | 删除: "version": "0.1.3-alpha.1", | |
| 3 | 新增: "version": "0.1.3-alpha.2", | |
| 4 | 4 | "lockfileVersion": 3, |
| 5 | 5 | "requires": true, |
| 6 | 6 | "packages": { |
| 7 | 7 | "": { |
| 8 | 8 | "name": "cage-workbench", |
| 9 | 删除: "version": "0.1.3-alpha.1", | |
| 9 | 新增: "version": "0.1.3-alpha.2", | |
| 10 | 10 | "dependencies": { |
| 11 | 11 | "@xterm/addon-fit": "0.11.0", |
| 12 | 12 | "@xterm/xterm": "6.0.0", |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "cage-workbench", |
| 3 | 3 | "private": true, |
| 4 | 删除: "version": "0.1.3-alpha.1", | |
| 4 | 新增: "version": "0.1.3-alpha.2", | |
| 5 | 5 | "type": "module", |
| 6 | 6 | "scripts": { |
| 7 | 7 | "prepare-vnc": "node scripts/prepare-vnc.mjs", |
| @@ -0,0 +1,82 @@ | ||
| 1 | 新增:import assert from "node:assert/strict"; | |
| 2 | 新增:import fs from "node:fs/promises"; | |
| 3 | 新增:import { createWorkbench } from "./workbench-fixture.mjs"; | |
| 4 | 新增: | |
| 5 | 新增:const output = process.env.CAGE_UPDATE_QA_OUTPUT || "/tmp/cage-update-diagnosis/ui"; | |
| 6 | 新增:await fs.mkdir(output, { recursive: true }); | |
| 7 | 新增:const calls = []; | |
| 8 | 新增:let update = { phase: "idle", currentVersion: "0.1.3-alpha.1" }; | |
| 9 | 新增:const fixture = await createWorkbench({ nativeRequest: async body => { | |
| 10 | 新增: if (body.action !== "appUpdate") return body.action === "workbenchReady" ? true : null; | |
| 11 | 新增: calls.push(body.operation); | |
| 12 | 新增: if (body.operation === "check") update = { ...update, phase: "current", message: "已是最新版本" }; | |
| 13 | 新增: if (body.operation === "install") update = { ...update, phase: "downloading", receivedBytes: 50, totalBytes: 100 }; | |
| 14 | 新增: return update; | |
| 15 | 新增:} }); | |
| 16 | 新增:const { page, browser, errors } = fixture; | |
| 17 | 新增:const publish = async value => { | |
| 18 | 新增: update = value; | |
| 19 | 新增: await page.evaluate(detail => window.dispatchEvent(new CustomEvent("cage-app-update", { detail })), value); | |
| 20 | 新增:}; | |
| 21 | 新增:const count = operation => calls.filter(value => value === operation).length; | |
| 22 | 新增:try { | |
| 23 | 新增: await page.clock.install(); | |
| 24 | 新增: calls.length = 0; | |
| 25 | 新增: update = { phase: "idle", currentVersion: "0.1.3-alpha.1" }; | |
| 26 | 新增: await page.reload(); | |
| 27 | 新增: await page.getByRole("heading", { name: "先启动 Cage 环境" }).waitFor(); | |
| 28 | 新增: await page.exposeFunction("updateCheckCount", () => count("check")); | |
| 29 | 新增: await page.waitForFunction(async () => await window.updateCheckCount() === 1); | |
| 30 | 新增: await page.waitForFunction(() => !document.querySelector(".app-update-button")); | |
| 31 | 新增: assert.deepEqual(calls, ["status", "check"], "startup must check without a user click"); | |
| 32 | 新增: await page.clock.fastForward(6 * 60 * 60 * 1000 + 60000); | |
| 33 | 新增: await page.waitForFunction(async () => await window.updateCheckCount() === 2); | |
| 34 | 新增: await page.waitForFunction(() => !document.querySelector(".app-update-button")); | |
| 35 | 新增: assert.equal(count("check"), 2, "periodic checks run while the window is visible"); | |
| 36 | 新增: await publish({ phase: "failed", currentVersion: update.currentVersion, message: "所选代理未运行" }); | |
| 37 | 新增: await page.locator(".app-update-button").waitFor({ state: "hidden" }); | |
| 38 | 新增: assert.equal(await page.locator(".app-update-button").count(), 0, "background check failure must not advertise an update"); | |
| 39 | 新增: await page.clock.fastForward(5 * 60 * 1000 + 60000); | |
| 40 | 新增: await page.waitForFunction(async () => await window.updateCheckCount() === 3); | |
| 41 | 新增: assert.equal(count("check"), 3, "a failed background check retries after the proxy can recover"); | |
| 42 | 新增: await publish({ phase: "available", currentVersion: "0.1.3-alpha.1", latestVersion: "0.1.3-alpha.2" }); | |
| 43 | 新增: const button = page.getByRole("button", { name: "下载更新", exact: true }); | |
| 44 | 新增: await button.waitFor(); | |
| 45 | 新增: assert.match(await button.getAttribute("title"), /0.1.3-alpha.2.*保存工作.*自动停止环境/); | |
| 46 | 新增: await page.screenshot({ path: `${output}/available.png` }); | |
| 47 | 新增: await button.click(); | |
| 48 | 新增: await page.getByRole("button", { name: "正在下载更新 50%", exact: true }).waitFor(); | |
| 49 | 新增: assert.equal(count("install"), 1); | |
| 50 | 新增: assert.equal(await page.getByRole("progressbar", { name: "更新下载进度" }).getAttribute("aria-valuenow"), "50"); | |
| 51 | 新增: assert.equal(await page.locator(".app-update-percent").innerText(), "50%"); | |
| 52 | 新增: assert.equal(await page.getByRole("dialog", { name: "Cage 更新" }).count(), 0); | |
| 53 | 新增: assert.ok(await page.getByRole("button", { name: "正在下载更新 50%", exact: true }).isDisabled()); | |
| 54 | 新增: await page.screenshot({ path: `${output}/downloading.png` }); | |
| 55 | 新增: await publish({ ...update, receivedBytes: 110 }); | |
| 56 | 新增: await page.getByRole("button", { name: "正在下载更新 100%", exact: true }).waitFor(); | |
| 57 | 新增: await publish({ ...update, totalBytes: 0 }); | |
| 58 | 新增: assert.equal(await page.getByRole("progressbar").getAttribute("aria-valuenow"), null, "unknown totals must stay indeterminate"); | |
| 59 | 新增: await publish({ ...update, phase: "verifying" }); | |
| 60 | 新增: await page.getByRole("button", { name: "正在验证更新", exact: true }).waitFor(); | |
| 61 | 新增: await publish({ ...update, phase: "installing" }); | |
| 62 | 新增: await page.getByRole("button", { name: "正在安装更新,完成后自动重启", exact: true }).waitFor(); | |
| 63 | 新增: await publish({ ...update, phase: "failed", message: "下载中断,请检查代理后重试", retryable: true }); | |
| 64 | 新增: await page.getByRole("alert").filter({ hasText: "下载中断" }).waitFor(); | |
| 65 | 新增: const retry = page.getByRole("button", { name: "重试更新", exact: true }); | |
| 66 | 新增: await retry.waitFor(); | |
| 67 | 新增: await retry.click(); | |
| 68 | 新增: await page.getByRole("button", { name: "正在下载更新 50%", exact: true }).waitFor(); | |
| 69 | 新增: assert.equal(count("install"), 2); | |
| 70 | 新增: await page.getByRole("button", { name: "收起侧栏", exact: true }).click(); | |
| 71 | 新增: assert.equal(await page.locator(".app-update-button").count(), 1, "collapsed sidebar keeps one progress indicator"); | |
| 72 | 新增: await publish({ phase: "current", currentVersion: "0.1.3-alpha.2" }); | |
| 73 | 新增: await page.locator(".app-update-button").waitFor({ state: "hidden" }); | |
| 74 | 新增: assert.equal(await page.locator(".app-update-button").count(), 0, "a current version leaves no update affordance"); | |
| 75 | 新增: await publish({ phase: "manual", currentVersion: "0.1.3-alpha.2" }); | |
| 76 | 新增: await page.locator(".app-update-button").waitFor({ state: "hidden" }); | |
| 77 | 新增: assert.equal(await page.locator(".app-update-button").count(), 0, "system package updates must not offer an automatic installation"); | |
| 78 | 新增: assert.deepEqual(errors, []); | |
| 79 | 新增: const result = { checks: ["automatic startup and periodic checks", "failed background check retry", "latest version hidden", "single click without update dialog", "ring and percentage", "indeterminate progress", "verification and installation", "visible failure and retry", "collapsed sidebar", "Linux manual update remains separate"], calls }; | |
| 80 | 新增: await fs.writeFile(`${output}/checks.json`, JSON.stringify(result, null, 2)); | |
| 81 | 新增: console.log(JSON.stringify(result)); | |
| 82 | 新增:} finally { await browser.close(); } | |
| @@ -20,22 +20,19 @@ const checks = []; | ||
| 20 | 20 | try { |
| 21 | 21 | await page.getByRole("button", { name: "下载更新", exact: true }).waitFor(); |
| 22 | 22 | const button = page.getByRole("button", { name: "下载更新", exact: true }); |
| 23 | 删除: assert.equal(await button.getAttribute("title"), "下载更新"); | |
| 23 | 新增: assert.match(await button.getAttribute("title"), /点击后将自动停止环境、安装并重启/); | |
| 24 | 24 | const bounds = await button.boundingBox(); |
| 25 | 25 | assert.ok(bounds.x < 248 && bounds.y > 700, "update action is not in the bottom-left sidebar"); |
| 26 | 26 | await page.screenshot({ path: fileURLToPath(new URL("update-available.png", output)) }); |
| 27 | 27 | await button.click(); |
| 28 | 28 | assert.equal(calls.filter((call) => call.operation === "install").length, 1); |
| 29 | 29 | await page.getByRole("progressbar", { name: "更新下载进度" }).waitFor(); |
| 30 | 删除: assert.equal(await page.getByRole("progressbar").getAttribute("value"), "50"); | |
| 31 | 删除: await page.getByRole("button", { name: "取消下载", exact: true }).click(); | |
| 32 | 删除: assert.equal(calls.filter((call) => call.operation === "cancel").length, 1); | |
| 33 | 删除: await page.getByRole("dialog", { name: "Cage 更新" }).getByRole("button", { name: "关闭", exact: true }).click(); | |
| 34 | 删除: await page.evaluate(() => window.dispatchEvent(new CustomEvent("cage-app-update", { detail: { phase: "failed", message: "更新源暂不可访问,仓库尚未公开", retryable: true } }))); | |
| 35 | 删除: await page.getByRole("button", { name: "查看更新状态", exact: true }).click(); | |
| 36 | 删除: await page.getByText("更新源暂不可访问,仓库尚未公开", { exact: true }).waitFor(); | |
| 37 | 删除: await page.getByRole("dialog", { name: "Cage 更新" }).getByRole("button", { name: "关闭", exact: true }).click(); | |
| 38 | 删除: checks.push("bottom-left update affordance", "single install request", "download progress and cancel", "private source failure visible"); | |
| 30 | 新增: assert.equal(await page.getByRole("progressbar").getAttribute("aria-valuenow"), "50"); | |
| 31 | 新增: assert.equal(await page.getByRole("dialog", { name: "Cage 更新" }).count(), 0); | |
| 32 | 新增: await page.evaluate(() => window.dispatchEvent(new CustomEvent("cage-app-update", { detail: { phase: "failed", latestVersion: "0.2.0-alpha.2", message: "更新源暂不可访问,仓库尚未公开", retryable: true } }))); | |
| 33 | 新增: await page.getByRole("button", { name: "重试更新", exact: true }).waitFor(); | |
| 34 | 新增: await page.getByRole("alert").filter({ hasText: "更新源暂不可访问,仓库尚未公开" }).waitFor(); | |
| 35 | 新增: checks.push("bottom-left update affordance", "single install request without a dialog", "inline ring progress", "private source failure visible"); | |
| 39 | 36 | |
| 40 | 37 | const downloads = [{ id: "qa-download", name: "report.txt", state: "failed", error: "目标目录暂时无法写入", retryable: true }]; |
| 41 | 38 | let retries = 0, editorRestarts = 0, componentUpdates = 0; |
| @@ -1,116 +1,125 @@ | ||
| 1 | 删除:import React, { useEffect, useRef, useState } from "react"; | |
| 2 | 删除:import { ArrowDownToLine, Check, LoaderCircle, RefreshCw } from "lucide-react"; | |
| 1 | 新增:import React, { useCallback, useEffect, useRef, useState } from "react"; | |
| 2 | 新增:import { ArrowDownToLine, RefreshCw } from "lucide-react"; | |
| 3 | 3 | import { native, nativeAvailable } from "./api"; |
| 4 | 删除:import { Modal } from "./views"; | |
| 5 | 4 | |
| 6 | 5 | const activePhases = new Set(["checking", "downloading", "downloaded", "verifying", "installing"]); |
| 6 | 新增:const checkInterval = 6 * 60 * 60 * 1000; | |
| 7 | 新增:const retryInterval = 5 * 60 * 1000; | |
| 8 | 新增: | |
| 7 | 9 | export function useAppUpdates() { |
| 8 | 10 | const [state, setState] = useState({ phase: "idle", message: "" }); |
| 9 | 11 | const current = useRef(state); |
| 10 | 12 | current.current = state; |
| 13 | 新增: const requestPending = useRef(false); | |
| 14 | 新增: const lastCheck = useRef(0); | |
| 11 | 15 | const available = nativeAvailable(); |
| 12 | 删除: const run = async (operation) => { | |
| 13 | 删除: if (!available) return; | |
| 16 | 新增: const run = useCallback(async (operation) => { | |
| 17 | 新增: if (!available || requestPending.current || activePhases.has(current.current.phase)) return; | |
| 18 | 新增: requestPending.current = true; | |
| 19 | 新增: if (operation === "check") lastCheck.current = Date.now(); | |
| 20 | 新增: if (operation === "install") setState(previous => ({ ...previous, phase: "checking" })); | |
| 14 | 21 | try { |
| 15 | 22 | const next = await native("appUpdate", { operation }); |
| 16 | 23 | if (next?.phase) setState(next); |
| 17 | 24 | } catch (error) { |
| 18 | 删除: setState((previous) => ({ ...previous, phase: "failed", message: error.message, retryable: true })); | |
| 19 | 删除: } | |
| 20 | 删除: }; | |
| 25 | 新增: setState(previous => ({ ...previous, phase: "failed", message: error.message, retryable: true })); | |
| 26 | 新增: } finally { requestPending.current = false; } | |
| 27 | 新增: }, [available]); | |
| 28 | 新增: | |
| 21 | 29 | useEffect(() => { |
| 22 | 30 | if (!available) return; |
| 23 | 31 | let live = true; |
| 24 | 删除: const receive = (event) => { | |
| 32 | 新增: const receive = event => { | |
| 25 | 33 | if (event.detail?.phase) setState(event.detail); |
| 26 | 34 | }; |
| 35 | 新增: const check = () => { | |
| 36 | 新增: if (document.visibilityState === "hidden" || window.cageWindowVisible === false) return; | |
| 37 | 新增: const phase = current.current.phase; | |
| 38 | 新增: const interval = phase === "failed" ? retryInterval : checkInterval; | |
| 39 | 新增: if (["idle", "current", "failed", "available"].includes(phase) && Date.now() - lastCheck.current >= interval) void run("check"); | |
| 40 | 新增: }; | |
| 27 | 41 | window.addEventListener("cage-app-update", receive); |
| 42 | 新增: window.addEventListener("focus", check); | |
| 43 | 新增: window.addEventListener("cage-window-visibility", check); | |
| 44 | 新增: document.addEventListener("visibilitychange", check); | |
| 28 | 45 | (async () => { |
| 29 | 46 | try { |
| 30 | 删除: let next = await native("appUpdate", { operation: "status" }); | |
| 47 | 新增: const next = await native("appUpdate", { operation: "status" }); | |
| 31 | 48 | if (!live) return; |
| 32 | 删除: if (!next || next.phase === "idle") next = await native("appUpdate", { operation: "check" }); | |
| 33 | 删除: if (live && next?.phase) setState(next); | |
| 49 | 新增: if (next?.phase) { current.current = next; setState(next); } | |
| 50 | 新增: if (!next || ["idle", "current", "failed"].includes(next.phase)) void run("check"); | |
| 34 | 51 | } catch (error) { |
| 35 | 52 | if (live) setState({ phase: "failed", message: error.message, retryable: true }); |
| 36 | 53 | } |
| 37 | 54 | })(); |
| 38 | 删除: const timer = setInterval(() => { | |
| 39 | 删除: if (["idle", "current", "failed"].includes(current.current.phase)) void run("check"); | |
| 40 | 删除: }, 6 * 60 * 60 * 1000); | |
| 55 | 新增: const timer = setInterval(check, 60 * 1000); | |
| 41 | 56 | return () => { |
| 42 | 57 | live = false; |
| 43 | 58 | clearInterval(timer); |
| 44 | 59 | window.removeEventListener("cage-app-update", receive); |
| 60 | 新增: window.removeEventListener("focus", check); | |
| 61 | 新增: window.removeEventListener("cage-window-visibility", check); | |
| 62 | 新增: document.removeEventListener("visibilitychange", check); | |
| 45 | 63 | }; |
| 46 | 删除: }, [available]); | |
| 64 | 新增: }, [available, run]); | |
| 47 | 65 | return { state, run, available }; |
| 48 | 66 | } |
| 49 | 67 | |
| 50 | 68 | export function AppUpdateButton({ updates }) { |
| 51 | 删除: const [details, setDetails] = useState(false); | |
| 52 | 69 | const { state, run, available } = updates; |
| 53 | 删除: if (!available) return null; | |
| 54 | 70 | const busy = activePhases.has(state.phase); |
| 55 | 删除: const downloadable = ["available", "ready"].includes(state.phase); | |
| 71 | 新增: const failed = state.phase === "failed"; | |
| 72 | 新增: const visible = state.latestVersion && ["available", "ready", "failed", ...activePhases].includes(state.phase); | |
| 73 | 新增: const announcedFailure = useRef(""); | |
| 74 | 新增: const [failure, setFailure] = useState(""); | |
| 75 | 新增: useEffect(() => { | |
| 76 | 新增: if (failed && visible && state.message && announcedFailure.current !== state.message) { | |
| 77 | 新增: announcedFailure.current = state.message; | |
| 78 | 新增: setFailure(state.message); | |
| 79 | 新增: } | |
| 80 | 新增: if (!failed) { announcedFailure.current = ""; setFailure(""); } | |
| 81 | 新增: }, [failed, visible, state.message]); | |
| 82 | 新增: useEffect(() => { | |
| 83 | 新增: if (!failure) return; | |
| 84 | 新增: const timer = setTimeout(() => setFailure(""), 8000); | |
| 85 | 新增: return () => clearTimeout(timer); | |
| 86 | 新增: }, [failure]); | |
| 87 | 新增: if (!available || !visible) return null; | |
| 88 | 新增: const downloading = state.phase === "downloading"; | |
| 56 | 89 | const percent = state.totalBytes > 0 |
| 57 | 删除: ? Math.min(100, Math.floor((state.receivedBytes || 0) / state.totalBytes * 100)) | |
| 90 | 新增: ? Math.max(0, Math.min(100, Math.floor((state.receivedBytes || 0) / state.totalBytes * 100))) | |
| 58 | 91 | : null; |
| 59 | 删除: const label = state.phase === "available" ? "下载更新" | |
| 60 | 删除: : state.phase === "manual" ? "查看更新方式" | |
| 61 | 删除: : state.phase === "ready" ? "安装更新并重启" | |
| 62 | 删除: : state.phase === "downloading" ? `正在下载更新${percent === null ? "" : ` ${percent}%`}` | |
| 63 | 删除: : state.phase === "verifying" || state.phase === "downloaded" ? "正在校验更新" | |
| 64 | 删除: : state.phase === "installing" ? "正在安装更新" | |
| 65 | 删除: : state.phase === "checking" ? "正在检查更新" | |
| 66 | 删除: : state.phase === "failed" ? "查看更新状态" | |
| 67 | 删除: : "检查更新"; | |
| 68 | 删除: const Icon = busy ? LoaderCircle : downloadable ? ArrowDownToLine : state.phase === "current" ? Check : RefreshCw; | |
| 92 | 新增: const label = downloading ? `正在下载更新${percent === null ? "" : ` ${percent}%`}` | |
| 93 | 新增: : state.phase === "verifying" || state.phase === "downloaded" ? "正在验证更新" | |
| 94 | 新增: : state.phase === "installing" ? "正在安装更新,完成后自动重启" | |
| 95 | 新增: : state.phase === "checking" ? "正在准备更新" | |
| 96 | 新增: : failed ? "重试更新" : "下载更新"; | |
| 97 | 新增: const hint = failed ? `${state.message || "更新未完成"},点击重试` | |
| 98 | 新增: : busy ? label : `更新至 ${state.latestVersion}。请先保存工作,点击后将自动停止环境、安装并重启。`; | |
| 99 | 新增: const circumference = 2 * Math.PI * 15; | |
| 69 | 100 | return ( |
| 70 | 101 | <> |
| 71 | 102 | <button |
| 72 | 删除: className={`icon-button app-update-button ${downloadable ? "available" : ""}`} | |
| 103 | 新增: className={`app-update-button${busy ? " busy" : ""}${failed ? " failed" : ""}`} | |
| 73 | 104 | aria-label={label} |
| 74 | 删除: title={state.phase === "failed" ? state.message || label : label} | |
| 75 | 删除: onClick={() => { | |
| 76 | 删除: setDetails(true); | |
| 77 | 删除: if (downloadable) void run("install"); | |
| 78 | 删除: else if (["idle", "current"].includes(state.phase)) void run("check"); | |
| 79 | 删除: }} | |
| 105 | 新增: title={hint} | |
| 106 | 新增: disabled={busy} | |
| 107 | 新增: onClick={() => { setFailure(""); void run("install"); }} | |
| 80 | 108 | > |
| 81 | 删除: <Icon size={17} className={busy ? "spin" : ""} /> | |
| 82 | 删除: {state.phase === "available" && <i className="update-available-dot" />} | |
| 109 | 新增: {busy ? ( | |
| 110 | 新增: <> | |
| 111 | 新增: <svg className={`app-update-ring${downloading && percent !== null ? "" : " indeterminate"}`} | |
| 112 | 新增: viewBox="0 0 36 36" role="progressbar" aria-label={downloading ? "更新下载进度" : label} | |
| 113 | 新增: aria-valuemin={0} aria-valuemax={100} aria-valuenow={downloading && percent !== null ? percent : undefined}> | |
| 114 | 新增: <circle className="app-update-ring-track" cx="18" cy="18" r="15" /> | |
| 115 | 新增: <circle className="app-update-ring-value" cx="18" cy="18" r="15" | |
| 116 | 新增: strokeDasharray={circumference} strokeDashoffset={circumference * (1 - (downloading && percent !== null ? percent / 100 : 0.25))} /> | |
| 117 | 新增: </svg> | |
| 118 | 新增: {downloading && percent !== null && <span className="app-update-percent">{percent}%</span>} | |
| 119 | 新增: </> | |
| 120 | 新增: ) : failed ? <RefreshCw size={20} /> : <ArrowDownToLine size={22} />} | |
| 83 | 121 | </button> |
| 84 | 删除: {details && ( | |
| 85 | 删除: <Modal title="Cage 更新" onClose={() => setDetails(false)}> | |
| 86 | 删除: <div className="app-update-details"> | |
| 87 | 删除: <p>{state.message || "检查是否有可安装的新版本。"}</p> | |
| 88 | 删除: <dl> | |
| 89 | 删除: {state.currentVersion && <><dt>当前版本</dt><dd>{state.currentVersion}</dd></>} | |
| 90 | 删除: {state.latestVersion && <><dt>可用版本</dt><dd>{state.latestVersion}</dd></>} | |
| 91 | 删除: </dl> | |
| 92 | 删除: {state.phase === "downloading" && ( | |
| 93 | 删除: <> | |
| 94 | 删除: <progress aria-label="更新下载进度" value={percent ?? undefined} max="100" /> | |
| 95 | 删除: <p>{percent === null ? "正在下载…" : `已下载 ${percent}%`}</p> | |
| 96 | 删除: </> | |
| 97 | 删除: )} | |
| 98 | 删除: {state.phase === "ready" && <p>更新已下载。保存工作后可继续安装,项目与登录状态会保留。</p>} | |
| 99 | 删除: <div className="modal-actions"> | |
| 100 | 删除: {state.phase === "downloading" && <button onClick={() => run("cancel")}>取消下载</button>} | |
| 101 | 删除: {!busy && state.phase !== "manual" && ( | |
| 102 | 删除: <button onClick={() => run("check")}>重新检查</button> | |
| 103 | 删除: )} | |
| 104 | 删除: {!busy && (downloadable || (state.phase === "failed" && state.latestVersion)) && ( | |
| 105 | 删除: <button className="primary" onClick={() => run("install")}> | |
| 106 | 删除: {state.phase === "ready" ? "安装并重启" : state.phase === "failed" ? "重试更新" : "下载更新"} | |
| 107 | 删除: </button> | |
| 108 | 删除: )} | |
| 109 | 删除: <button onClick={() => setDetails(false)}>关闭</button> | |
| 110 | 删除: </div> | |
| 111 | 删除: </div> | |
| 112 | 删除: </Modal> | |
| 113 | 删除: )} | |
| 122 | 新增: {failure && <div className="app-update-error" role="alert">{failure}。可点击更新按钮重试。</div>} | |
| 114 | 123 | </> |
| 115 | 124 | ); |
| 116 | 125 | } |
| @@ -517,22 +517,31 @@ button.large { | ||
| 517 | 517 | gap: 6px; |
| 518 | 518 | } |
| 519 | 519 | .sidebar-footer-actions > .sidebar-link { flex: 1; min-width: 0; } |
| 520 | 删除:.app-update-button { position: relative; flex: 0 0 auto; } | |
| 521 | 删除:.app-update-button.available { color: var(--accent, #267455); } | |
| 522 | 删除:.update-available-dot { | |
| 523 | 删除: position: absolute; | |
| 524 | 删除: width: 5px; | |
| 525 | 删除: height: 5px; | |
| 526 | 删除: border-radius: 50%; | |
| 527 | 删除: background: currentColor; | |
| 528 | 删除: right: 4px; | |
| 529 | 删除: top: 4px; | |
| 530 | 删除:} | |
| 531 | 删除:.app-update-details { min-width: min(340px, 65vw); padding: 18px 24px 24px; } | |
| 532 | 删除:.app-update-details dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; } | |
| 533 | 删除:.app-update-details dt { color: var(--muted); } | |
| 534 | 删除:.app-update-details dd { margin: 0; } | |
| 535 | 删除:.app-update-details progress { width: 100%; accent-color: var(--accent, #267455); } | |
| 520 | 新增:.app-update-button { | |
| 521 | 新增: position: relative; flex: 0 0 36px; width: 36px; height: 36px; padding: 0; | |
| 522 | 新增: display: grid; place-items: center; border: 0; border-radius: 50%; | |
| 523 | 新增: background: #b78a00; color: #fff; cursor: pointer; | |
| 524 | 新增:} | |
| 525 | 新增:.app-update-button:hover:not(:disabled) { background: #a17900; } | |
| 526 | 新增:.app-update-button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; } | |
| 527 | 新增:.app-update-button:disabled { opacity: 1; cursor: progress; } | |
| 528 | 新增:.app-update-ring { position: absolute; inset: 0; width: 36px; height: 36px; transform: rotate(-90deg); } | |
| 529 | 新增:.app-update-ring circle { fill: none; stroke-width: 2; } | |
| 530 | 新增:.app-update-ring-track { stroke: #ffffff40; } | |
| 531 | 新增:.app-update-ring-value { stroke: currentColor; stroke-linecap: round; transition: stroke-dashoffset 0.18s linear; } | |
| 532 | 新增:.app-update-ring.indeterminate { animation: app-update-turn 1s linear infinite; } | |
| 533 | 新增:.app-update-percent { font-size: 10px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1; } | |
| 534 | 新增:.app-update-error { | |
| 535 | 新增: position: fixed; left: 18px; bottom: 82px; z-index: 50; | |
| 536 | 新增: max-width: min(380px, calc(100vw - 36px)); padding: 12px 16px; | |
| 537 | 新增: border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); | |
| 538 | 新增: box-shadow: 0 8px 24px #00000018; font-size: 13px; line-height: 1.6; | |
| 539 | 新增:} | |
| 540 | 新增:@keyframes app-update-turn { to { transform: rotate(270deg); } } | |
| 541 | 新增:@media (prefers-reduced-motion: reduce) { | |
| 542 | 新增: .app-update-ring.indeterminate { animation: none; } | |
| 543 | 新增: .app-update-ring-value { transition: none; } | |
| 544 | 新增:} | |
| 536 | 545 | .browser-download-list { min-width: min(400px, 70vw); max-height: 55vh; overflow: auto; padding: 4px 24px 20px; } |
| 537 | 546 | .browser-download-item { padding: 12px 0; border-bottom: 1px solid var(--border, #dedede); overflow-wrap: anywhere; } |
| 538 | 547 | .browser-download-item p { margin: 5px 0; font-size: 12px; color: var(--muted); } |
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "claude-cage-website", |
| 3 | 删除: "version": "0.1.3-alpha.1", | |
| 3 | 新增: "version": "0.1.3-alpha.2", | |
| 4 | 4 | "lockfileVersion": 3, |
| 5 | 5 | "requires": true, |
| 6 | 6 | "packages": { |
| 7 | 7 | "": { |
| 8 | 8 | "name": "claude-cage-website", |
| 9 | 删除: "version": "0.1.3-alpha.1", | |
| 9 | 新增: "version": "0.1.3-alpha.2", | |
| 10 | 10 | "license": "MIT", |
| 11 | 11 | "dependencies": { |
| 12 | 12 | "@fontsource-variable/inter": "^5.3.0", |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "claude-cage-website", |
| 3 | 3 | "type": "module", |
| 4 | 删除: "version": "0.1.3-alpha.1", | |
| 4 | 新增: "version": "0.1.3-alpha.2", | |
| 5 | 5 | "private": true, |
| 6 | 6 | "description": "Claude Cage project website and macOS, Windows and Linux downloads", |
| 7 | 7 | "license": "MIT", |

