896aa75a39
Beim App-Start wird automatisch geprüft, ob bei git.kgva.ch/karim/RAPPORT eine neue Version verfügbar ist. Update-Modal mit Release-Notes und drei Aktionen: Jetzt installieren (Download → Signaturprüfung → Neustart), Später, oder Diese Version überspringen (in localStorage gemerkt). Signing via minisign-Keypair unter ~/.tauri/rapport_updater.key, Public Key im Tauri-Config. Release-Script scripts/release.sh baut, signiert und erzeugt latest.json für Gitea. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
// Shared helpers for the Tauri app updater. Used by the auto-check modal
|
|
// (UpdateNotifier) and the manual check in Settings → Updates & Support.
|
|
|
|
export const SKIP_KEY = "rapport_update_skipped_version";
|
|
export const LAST_CHECK_KEY = "rapport_update_last_check";
|
|
|
|
export function isTauri() {
|
|
return typeof window !== "undefined" && !!window.__TAURI_INTERNALS__;
|
|
}
|
|
|
|
export async function checkForAppUpdate({ respectSkip = true } = {}) {
|
|
if (!isTauri()) return { available: false, isTauri: false };
|
|
const { check } = await import("@tauri-apps/plugin-updater");
|
|
const result = await check();
|
|
localStorage.setItem(LAST_CHECK_KEY, new Date().toISOString());
|
|
if (!result?.available) return { available: false, update: null, isTauri: true };
|
|
if (respectSkip && localStorage.getItem(SKIP_KEY) === result.version) {
|
|
return { available: false, update: result, isTauri: true, skipped: true };
|
|
}
|
|
return { available: true, update: result, isTauri: true };
|
|
}
|
|
|
|
export async function installAppUpdate(update, onProgress) {
|
|
await update.downloadAndInstall(onProgress);
|
|
const { relaunch } = await import("@tauri-apps/plugin-process");
|
|
await relaunch();
|
|
}
|
|
|
|
export function skipUpdateVersion(version) {
|
|
if (version) localStorage.setItem(SKIP_KEY, version);
|
|
}
|
|
|
|
export function getLastUpdateCheck() {
|
|
return localStorage.getItem(LAST_CHECK_KEY);
|
|
}
|
|
|
|
export function formatLastCheck(iso) {
|
|
if (!iso) return "noch nie";
|
|
try {
|
|
const d = new Date(iso);
|
|
return d.toLocaleString("de-CH", {
|
|
day: "2-digit", month: "long", year: "numeric",
|
|
hour: "2-digit", minute: "2-digit",
|
|
});
|
|
} catch {
|
|
return "—";
|
|
}
|
|
}
|