Add auto-update support (tauri-plugin-updater) and Gitea release pipeline
Ed25519-signed updates, checked via a fixed-tag latest.json manifest on Gitea Releases; scripts/release.sh automates build+sign+publish. Adds a manual "Nach Updates suchen" trigger plus a silent startup check.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { check, type Update } from '@tauri-apps/plugin-updater'
|
||||
import { relaunch } from '@tauri-apps/plugin-process'
|
||||
|
||||
export async function checkForUpdate(): Promise<Update | null> {
|
||||
try {
|
||||
return await check()
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export async function installUpdate(update: Update, onProgress: (pct: number | null) => void): Promise<void> {
|
||||
let total = 0
|
||||
let downloaded = 0
|
||||
await update.downloadAndInstall((event) => {
|
||||
if (event.event === 'Started') {
|
||||
total = event.data.contentLength ?? 0
|
||||
onProgress(total > 0 ? 0 : null)
|
||||
} else if (event.event === 'Progress') {
|
||||
downloaded += event.data.chunkLength
|
||||
onProgress(total > 0 ? Math.min(100, Math.round((downloaded / total) * 100)) : null)
|
||||
} else if (event.event === 'Finished') {
|
||||
onProgress(100)
|
||||
}
|
||||
})
|
||||
await relaunch()
|
||||
}
|
||||
Reference in New Issue
Block a user