diff options
Diffstat (limited to 'packages/tauri')
| -rw-r--r-- | packages/tauri/src/index.tsx | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/packages/tauri/src/index.tsx b/packages/tauri/src/index.tsx index c77058eb9..025dfd540 100644 --- a/packages/tauri/src/index.tsx +++ b/packages/tauri/src/index.tsx @@ -1,14 +1,16 @@ // @refresh reload import { render } from "solid-js/web" import { App, PlatformProvider, Platform } from "@opencode-ai/desktop" -import { onMount } from "solid-js" import { open, save } from "@tauri-apps/plugin-dialog" import { open as shellOpen } from "@tauri-apps/plugin-shell" import { type as ostype } from "@tauri-apps/plugin-os" import { AsyncStorage } from "@solid-primitives/storage" -import { runUpdater, UPDATER_ENABLED } from "./updater" +import { UPDATER_ENABLED } from "./updater" import { createMenu } from "./menu" +import { check, Update } from "@tauri-apps/plugin-updater" +import { invoke } from "@tauri-apps/api/core" +import { relaunch } from "@tauri-apps/plugin-process" const root = document.getElementById("root") if (import.meta.env.DEV && !(root instanceof HTMLElement)) { @@ -17,6 +19,8 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) { ) } +let update: Update | null = null + const platform: Platform = { platform: "tauri", @@ -66,15 +70,26 @@ const platform: Platform = { } return api }, + + checkUpdate: async () => { + if (!UPDATER_ENABLED) return { updateAvailable: false } + update = await check() + if (!update) return { updateAvailable: false } + await update.download() + return { updateAvailable: true, version: update.version } + }, + + update: async () => { + if (!UPDATER_ENABLED || !update) return + await update.install() + await invoke("kill_sidecar") + await relaunch() + }, } createMenu() render(() => { - onMount(() => { - if (UPDATER_ENABLED) runUpdater({ alertOnFail: false }) - }) - return ( <PlatformProvider value={platform}> {ostype() === "macos" && ( |
