mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-03 01:50:23 +08:00
fix: address PR review feedback for auto-update
- Register manual check listeners before checkForUpdates() to avoid race
- Strip prerelease/build metadata in version comparison
- Add res.setEncoding("utf8") for GitHub API response
- Stream file hashing in CI script instead of reading into memory
- Add directory existence checks in fix-latest-yml.mjs
- Define UpdateStatus type locally in preload to avoid tsconfig scope issues
- Show error dialog for manual check failures (parse/network errors)
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import { contextBridge, type IpcRendererEvent, ipcRenderer } from "electron"
|
||||
|
||||
// Locally defined to avoid dependency on electron.d.ts compilation scope
|
||||
type UpdateStatus =
|
||||
| { status: "available"; version: string }
|
||||
| { status: "available-manual"; version: string; url: string }
|
||||
| { status: "downloading"; percent: number }
|
||||
| { status: "downloaded" }
|
||||
| { status: "error"; message: string }
|
||||
|
||||
/**
|
||||
* Expose safe APIs to the renderer process
|
||||
*/
|
||||
@@ -33,8 +41,8 @@ contextBridge.exposeInMainWorld("electronAPI", {
|
||||
ipcRenderer.invoke("set-user-locale", locale),
|
||||
|
||||
// Auto-update
|
||||
onUpdateStatus: (callback: (data: UpdateStatusData) => void) => {
|
||||
const handler = (_event: IpcRendererEvent, data: UpdateStatusData) =>
|
||||
onUpdateStatus: (callback: (data: UpdateStatus) => void) => {
|
||||
const handler = (_event: IpcRendererEvent, data: UpdateStatus) =>
|
||||
callback(data)
|
||||
ipcRenderer.on("update-status", handler)
|
||||
return () => ipcRenderer.removeListener("update-status", handler)
|
||||
|
||||
Reference in New Issue
Block a user