fix: use system proxy for app updates

This commit is contained in:
t8y2
2026-05-26 20:12:41 +08:00
parent 32273b4d6e
commit 2038501b53
8 changed files with 222 additions and 6 deletions
+12 -1
View File
@@ -8,6 +8,16 @@ export function shouldOpenUpdateDialog(options: { silent?: boolean }) {
return options.silent !== true;
}
export async function resolveUpdaterProxy(): Promise<string | undefined> {
if (!isTauriRuntime()) return undefined;
try {
const proxy = await api.getSystemProxyUrl();
return proxy || undefined;
} catch {
return undefined;
}
}
export function useAppUpdater() {
const { t } = useI18n();
const { toast } = useToast();
@@ -74,7 +84,8 @@ export function useAppUpdater() {
downloadProgress.value = 0;
try {
const { check } = await import("@tauri-apps/plugin-updater");
const update = await check();
const proxy = await resolveUpdaterProxy();
const update = await check(proxy ? { proxy } : undefined);
if (!update) return;
let totalBytes = 0;
let downloadedBytes = 0;
+1
View File
@@ -213,6 +213,7 @@ export const deleteHistoryEntry = forward("deleteHistoryEntry");
// Updates
export const checkForUpdates = forward("checkForUpdates");
export const getSystemProxyUrl = forward("getSystemProxyUrl");
export const getAppVersion = forward("getAppVersion");
// Layout
+4
View File
@@ -1258,6 +1258,10 @@ export async function checkForUpdates(): Promise<UpdateInfo> {
return get("/api/update/check");
}
export async function getSystemProxyUrl(): Promise<string | null> {
return null;
}
export async function getAppVersion(): Promise<string> {
const res: { version: string } = await get("/api/version");
return res.version;
+4
View File
@@ -830,6 +830,10 @@ export async function checkForUpdates(): Promise<UpdateInfo> {
return invoke("check_for_updates");
}
export async function getSystemProxyUrl(): Promise<string | null> {
return invoke("get_system_proxy_url");
}
export async function getAppVersion(): Promise<string> {
const { getVersion } = await import("@tauri-apps/api/app");
return getVersion();