mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-12-01 01:05:10 +08:00
fix(desktop): update Windows executable in place
This commit is contained in:
1 parent
919c1d8032
commit
ddaa61c827
20 files changed
+850
-37
No files matched your search
@@ -95,7 +95,8 @@ export function AppLifecycleSettingsCard() {
|
||||
const nextVersion = await updateStore.check();
|
||||
message(nextVersion ? t("发现新版本 {version}", { version: nextVersion }) : t("当前已是最新版本"));
|
||||
} catch (cause) {
|
||||
message(cause instanceof Error ? cause.message : String(cause));
|
||||
const error = cause instanceof Error ? cause.message : String(cause);
|
||||
message(t("检查更新失败:{error}", { error }));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -103,7 +104,8 @@ export function AppLifecycleSettingsCard() {
|
||||
try {
|
||||
await updateStore.install();
|
||||
} catch (cause) {
|
||||
message(cause instanceof Error ? cause.message : String(cause));
|
||||
const error = cause instanceof Error ? cause.message : String(cause);
|
||||
message(t("安装更新失败:{error}", { error }));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -606,7 +606,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 156,
|
||||
"line": 158,
|
||||
"column": 27
|
||||
}
|
||||
]
|
||||
@@ -916,7 +916,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 152,
|
||||
"line": 154,
|
||||
"column": 13
|
||||
}
|
||||
]
|
||||
@@ -1673,7 +1673,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 126,
|
||||
"line": 128,
|
||||
"column": 17
|
||||
}
|
||||
]
|
||||
@@ -1725,7 +1725,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 151,
|
||||
"line": 153,
|
||||
"column": 13
|
||||
}
|
||||
]
|
||||
@@ -2353,7 +2353,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "shared/api.ts",
|
||||
"line": 488,
|
||||
"line": 486,
|
||||
"column": 43
|
||||
}
|
||||
]
|
||||
@@ -2365,7 +2365,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 149,
|
||||
"line": 151,
|
||||
"column": 18
|
||||
}
|
||||
]
|
||||
@@ -2451,12 +2451,12 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 137,
|
||||
"line": 139,
|
||||
"column": 18
|
||||
},
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 143,
|
||||
"line": 145,
|
||||
"column": 16
|
||||
}
|
||||
]
|
||||
@@ -2680,7 +2680,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "shared/api.ts",
|
||||
"line": 483,
|
||||
"line": 481,
|
||||
"column": 43
|
||||
}
|
||||
]
|
||||
@@ -2795,7 +2795,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 160,
|
||||
"line": 162,
|
||||
"column": 37
|
||||
}
|
||||
]
|
||||
@@ -2834,7 +2834,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "shared/api.ts",
|
||||
"line": 420,
|
||||
"line": 418,
|
||||
"column": 21
|
||||
}
|
||||
]
|
||||
@@ -2900,12 +2900,12 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 113,
|
||||
"line": 115,
|
||||
"column": 18
|
||||
},
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 119,
|
||||
"line": 121,
|
||||
"column": 16
|
||||
}
|
||||
]
|
||||
@@ -3194,6 +3194,20 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"92e26b27d5ea8f0e": {
|
||||
"source": "检查更新失败:{error}",
|
||||
"kind": "template",
|
||||
"placeholders": [
|
||||
"error"
|
||||
],
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 99,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
},
|
||||
"940a168911ade998": {
|
||||
"source": "每页条数",
|
||||
"kind": "text",
|
||||
@@ -3520,7 +3534,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 110,
|
||||
"line": 112,
|
||||
"column": 29
|
||||
}
|
||||
]
|
||||
@@ -3532,12 +3546,12 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 125,
|
||||
"line": 127,
|
||||
"column": 18
|
||||
},
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 131,
|
||||
"line": 133,
|
||||
"column": 16
|
||||
}
|
||||
]
|
||||
@@ -3749,6 +3763,20 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"a80b53f8848e6d27": {
|
||||
"source": "安装更新失败:{error}",
|
||||
"kind": "template",
|
||||
"placeholders": [
|
||||
"error"
|
||||
],
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 108,
|
||||
"column": 15
|
||||
}
|
||||
]
|
||||
},
|
||||
"a98585871c5313ff": {
|
||||
"source": "显示名称",
|
||||
"kind": "text",
|
||||
@@ -3814,7 +3842,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 156,
|
||||
"line": 158,
|
||||
"column": 39
|
||||
}
|
||||
]
|
||||
@@ -3854,7 +3882,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 138,
|
||||
"line": 140,
|
||||
"column": 17
|
||||
}
|
||||
]
|
||||
@@ -4577,7 +4605,7 @@
|
||||
"refs": [
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 114,
|
||||
"line": 116,
|
||||
"column": 17
|
||||
}
|
||||
]
|
||||
@@ -5522,7 +5550,7 @@
|
||||
},
|
||||
{
|
||||
"file": "features/settings/AppLifecycleSettingsCard.tsx",
|
||||
"line": 160,
|
||||
"line": 162,
|
||||
"column": 25
|
||||
}
|
||||
]
|
||||
|
||||
@@ -221,6 +221,7 @@
|
||||
"91aaf184cfc17ffd": "Overview",
|
||||
"91af6e57e7453fbe": "Add account",
|
||||
"92156a483d4ba248": "Only request, response, and trace attachments are deleted; call summaries, metrics, and configuration are kept.",
|
||||
"92e26b27d5ea8f0e": "Failed to check for updates: {error}",
|
||||
"940a168911ade998": "Items per page",
|
||||
"945fb1c67eca8493": "Installing the plugin runtime",
|
||||
"946b3ffc02f026c0": "Delete this model?",
|
||||
@@ -259,6 +260,7 @@
|
||||
"a748cc074f78de00": "View details",
|
||||
"a7617f42f898b2bf": "Use complete request URL",
|
||||
"a8036485f9227f2c": "Drag to reorder",
|
||||
"a80b53f8848e6d27": "Failed to install update: {error}",
|
||||
"a98585871c5313ff": "Display name",
|
||||
"ab9084a640fbb864": "Deselect all",
|
||||
"abecab6701177721": "Launch at login enabled",
|
||||
|
||||
@@ -221,6 +221,7 @@
|
||||
"91aaf184cfc17ffd": "数据概览",
|
||||
"91af6e57e7453fbe": "添加账号",
|
||||
"92156a483d4ba248": "仅删除请求、响应和追踪附件等详细内容,保留调用汇总、统计指标和配置。",
|
||||
"92e26b27d5ea8f0e": "检查更新失败:{error}",
|
||||
"940a168911ade998": "每页条数",
|
||||
"945fb1c67eca8493": "正在安装插件运行时",
|
||||
"946b3ffc02f026c0": "确定删除这个模型吗?",
|
||||
@@ -259,6 +260,7 @@
|
||||
"a748cc074f78de00": "查看详情",
|
||||
"a7617f42f898b2bf": "使用完整请求地址",
|
||||
"a8036485f9227f2c": "拖动排序",
|
||||
"a80b53f8848e6d27": "安装更新失败:{error}",
|
||||
"a98585871c5313ff": "显示名称",
|
||||
"ab9084a640fbb864": "全不选",
|
||||
"abecab6701177721": "已开启开机启动",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getVersion, setDockVisibility } from "@tauri-apps/api/app";
|
||||
import { isTauri } from "@tauri-apps/api/core";
|
||||
import { invoke, isTauri } from "@tauri-apps/api/core";
|
||||
import { disable, enable, isEnabled } from "@tauri-apps/plugin-autostart";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { check, type Update } from "@tauri-apps/plugin-updater";
|
||||
@@ -46,11 +46,39 @@ export async function writeDockIconVisibility(visible: boolean): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkForUpdate(): Promise<Update | null> {
|
||||
return check();
|
||||
export type AppUpdate = {
|
||||
version: string;
|
||||
install(): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
};
|
||||
|
||||
type PortableUpdateInfo = {
|
||||
version: string;
|
||||
};
|
||||
|
||||
export async function checkForUpdate(): Promise<AppUpdate | null> {
|
||||
if (desktopPlatform() === "windows") {
|
||||
const update = await invoke<PortableUpdateInfo | null>("check_portable_update");
|
||||
if (!update) return null;
|
||||
return {
|
||||
version: update.version,
|
||||
install: () => invoke("install_portable_update", { expectedVersion: update.version }),
|
||||
close: async () => {},
|
||||
};
|
||||
}
|
||||
|
||||
const update: Update | null = await check();
|
||||
if (!update) return null;
|
||||
return {
|
||||
version: update.version,
|
||||
install: async () => {
|
||||
await update.downloadAndInstall();
|
||||
await relaunch();
|
||||
},
|
||||
close: () => update.close(),
|
||||
};
|
||||
}
|
||||
|
||||
export async function installUpdate(update: Update): Promise<void> {
|
||||
await update.downloadAndInstall();
|
||||
await relaunch();
|
||||
export async function installUpdate(update: AppUpdate): Promise<void> {
|
||||
await update.install();
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { Update } from "@tauri-apps/plugin-updater";
|
||||
import {
|
||||
checkForUpdate,
|
||||
hasNativeAppLifecycle,
|
||||
installUpdate,
|
||||
type AppUpdate,
|
||||
} from "../native/appLifecycle";
|
||||
|
||||
export type UpdateSnapshot = {
|
||||
@@ -17,7 +17,7 @@ let snapshot: UpdateSnapshot = {
|
||||
checking: false,
|
||||
installing: false,
|
||||
};
|
||||
let availableUpdate: Update | null = null;
|
||||
let availableUpdate: AppUpdate | null = null;
|
||||
let pendingCheck: Promise<string | null> | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
@@ -26,7 +26,7 @@ function update(patch: Partial<UpdateSnapshot>) {
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
async function replaceAvailableUpdate(next: Update | null) {
|
||||
async function replaceAvailableUpdate(next: AppUpdate | null) {
|
||||
const previous = availableUpdate;
|
||||
availableUpdate = next;
|
||||
update({ availableVersion: next?.version ?? null });
|
||||
|
||||
Reference in new issue
Block a user