feat(gui, tauri, ci): Auto updater (#105)

This commit is contained in:
binarybaron 2024-10-17 18:56:04 +06:00 committed by GitHub
parent 90584a211d
commit 6c433041b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 925 additions and 75 deletions

View file

@ -18,6 +18,7 @@ import App from "./components/App";
import { initEventListeners } from "./rpc";
import { persistor, store } from "./store/storeRenderer";
import { Box } from "@material-ui/core";
import { checkForAppUpdates } from "./updater";
const container = document.getElementById("root");
const root = createRoot(container!);
@ -67,3 +68,4 @@ async function fetchInitialData() {
fetchInitialData();
initEventListeners();
checkForAppUpdates();

View file

@ -0,0 +1,27 @@
import { check } from "@tauri-apps/plugin-updater";
import { ask, message } from "@tauri-apps/plugin-dialog";
import { relaunch } from "@tauri-apps/plugin-process";
export async function checkForAppUpdates() {
const update = await check();
if (update?.available) {
const yes = await ask(
`
Update to ${update.version} is available!
Release notes: ${update.body}
`,
{
title: "Update Now!",
kind: "info",
okLabel: "Update",
cancelLabel: "Cancel",
}
);
if (yes) {
await update.downloadAndInstall();
await relaunch();
}
}
}