Auto-update flow rework: - updater.ts: disable autoDownload, add manual `updater:download` IPC handler so user explicitly triggers download via "Download & Install" button - updater.ts: resolve system proxy via session.defaultSession.resolveProxy() and inject into HTTPS_PROXY env var, fixing zero download speed behind VPN/proxy - preload.ts + electron.d.ts: expose `downloadUpdate` method to renderer UI improvements: - UpdateDialog: add "Download & Install" button when update available but not yet downloading; show progress bar during download; "Restart to Update" when ready - GeneralSection UpdateCard: show "Download & Install" / "Restart to Update" button next to "Check for Updates"; show download progress bar inline; add "View Details" link to reopen update dialog - AppShell: dismissUpdate no longer permanently hides update for that version (removed localStorage persistence), just closes the dialog - useUpdate: add downloadUpdate to context i18n: - Added `update.installUpdate` key (en: "Download & Install", zh: "下载并安装") Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.6 KiB
TypeScript
39 lines
1.6 KiB
TypeScript
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
|
versions: {
|
|
electron: process.versions.electron,
|
|
node: process.versions.node,
|
|
chrome: process.versions.chrome,
|
|
},
|
|
shell: {
|
|
openPath: (folderPath: string) => ipcRenderer.invoke('shell:open-path', folderPath),
|
|
},
|
|
dialog: {
|
|
openFolder: (options?: { defaultPath?: string; title?: string }) =>
|
|
ipcRenderer.invoke('dialog:open-folder', options),
|
|
},
|
|
install: {
|
|
checkPrerequisites: () => ipcRenderer.invoke('install:check-prerequisites'),
|
|
start: (options?: { includeNode?: boolean }) => ipcRenderer.invoke('install:start', options),
|
|
cancel: () => ipcRenderer.invoke('install:cancel'),
|
|
getLogs: () => ipcRenderer.invoke('install:get-logs'),
|
|
onProgress: (callback: (data: unknown) => void) => {
|
|
const listener = (_event: unknown, data: unknown) => callback(data);
|
|
ipcRenderer.on('install:progress', listener);
|
|
return () => { ipcRenderer.removeListener('install:progress', listener); };
|
|
},
|
|
},
|
|
updater: {
|
|
checkForUpdates: () => ipcRenderer.invoke('updater:check'),
|
|
downloadUpdate: () => ipcRenderer.invoke('updater:download'),
|
|
quitAndInstall: () => ipcRenderer.invoke('updater:quit-and-install'),
|
|
onStatus: (callback: (data: unknown) => void) => {
|
|
const listener = (_event: unknown, data: unknown) => callback(data);
|
|
ipcRenderer.on('updater:status', listener);
|
|
return () => { ipcRenderer.removeListener('updater:status', listener); };
|
|
},
|
|
},
|
|
});
|