mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 00:29:30 +00:00
fix: use system proxy for app updates
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user