mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
chore: format code
This commit is contained in:
parent
331278a5be
commit
ff6f1abf61
4 changed files with 550 additions and 2411 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,8 +1,8 @@
|
|||
// @refresh reload
|
||||
import { render } from "solid-js/web"
|
||||
import { DesktopInterface, PlatformProvider, Platform } from "@opencode-ai/desktop"
|
||||
import { runUpdater } from "./updater";
|
||||
import { onMount } from "solid-js";
|
||||
import { runUpdater } from "./updater"
|
||||
import { onMount } from "solid-js"
|
||||
|
||||
const root = document.getElementById("root")
|
||||
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
||||
|
|
@ -13,15 +13,14 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
|||
|
||||
const platform: Platform = {}
|
||||
|
||||
render(
|
||||
() => {
|
||||
onMount(() => {
|
||||
if(window.__OPENCODE__.updaterEnabled) runUpdater();
|
||||
});
|
||||
render(() => {
|
||||
onMount(() => {
|
||||
if (window.__OPENCODE__.updaterEnabled) runUpdater()
|
||||
})
|
||||
|
||||
return <PlatformProvider value={platform}>
|
||||
return (
|
||||
<PlatformProvider value={platform}>
|
||||
<DesktopInterface />
|
||||
</PlatformProvider>
|
||||
},
|
||||
root!,
|
||||
)
|
||||
)
|
||||
}, root!)
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
import { check, DownloadEvent } from '@tauri-apps/plugin-updater';
|
||||
import { relaunch } from '@tauri-apps/plugin-process';
|
||||
import { ask, message } from '@tauri-apps/plugin-dialog';
|
||||
import { check, DownloadEvent } from "@tauri-apps/plugin-updater"
|
||||
import { relaunch } from "@tauri-apps/plugin-process"
|
||||
import { ask, message } from "@tauri-apps/plugin-dialog"
|
||||
|
||||
export async function runUpdater(onDownloadEvent?:(progress: DownloadEvent) => void) {
|
||||
let update;
|
||||
export async function runUpdater(onDownloadEvent?: (progress: DownloadEvent) => void) {
|
||||
let update
|
||||
try {
|
||||
update = await check();
|
||||
update = await check()
|
||||
} catch {
|
||||
await message("Failed to check for updates")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!update) return;
|
||||
if (update.version <= update.currentVersion) return;
|
||||
if (!update) return
|
||||
if (update.version <= update.currentVersion) return
|
||||
|
||||
try {
|
||||
await update.download(onDownloadEvent);
|
||||
await update.download(onDownloadEvent)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
|
||||
const shouldUpdate = await ask(`Version ${update.version} of OpenCode is available, would you like to install it?`)
|
||||
if (!shouldUpdate) return;
|
||||
if (!shouldUpdate) return
|
||||
|
||||
try {
|
||||
await update.install();
|
||||
await update.install()
|
||||
} catch {
|
||||
await message("Failed to install update")
|
||||
return false
|
||||
}
|
||||
|
||||
const shouldRestart = await ask("Update installed successfully, would you like to restart OpenCode?");
|
||||
if(shouldRestart) await relaunch()
|
||||
const shouldRestart = await ask("Update installed successfully, would you like to restart OpenCode?")
|
||||
if (shouldRestart) await relaunch()
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue