2023-06-11 19:18:58 +05:00
|
|
|
|
<script lang="ts">
|
2026-01-04 22:50:34 +05:00
|
|
|
|
import { onMount, onDestroy } from "svelte"
|
2026-01-06 23:32:58 +05:00
|
|
|
|
import { invoke } from "@tauri-apps/api/core"
|
|
|
|
|
|
import { Notification, Space, Button } from "@svelteuidev/core"
|
2026-01-04 22:50:34 +05:00
|
|
|
|
import { InfoCircled } from "radix-icons-svelte"
|
|
|
|
|
|
|
2023-06-11 19:18:58 +05:00
|
|
|
|
import ArcReactor from "@/components/elements/ArcReactor.svelte"
|
|
|
|
|
|
import HDivider from "@/components/elements/HDivider.svelte"
|
|
|
|
|
|
import Stats from "@/components/elements/Stats.svelte"
|
|
|
|
|
|
import Footer from "@/components/Footer.svelte"
|
|
|
|
|
|
|
2026-01-07 00:15:36 +05:00
|
|
|
|
import {
|
|
|
|
|
|
isJarvisRunning,
|
|
|
|
|
|
updateJarvisStats,
|
|
|
|
|
|
jarvisState,
|
|
|
|
|
|
ipcConnected,
|
|
|
|
|
|
enableIpc,
|
|
|
|
|
|
disableIpc
|
|
|
|
|
|
} from "@/stores"
|
2023-06-11 19:18:58 +05:00
|
|
|
|
|
2026-01-07 00:15:36 +05:00
|
|
|
|
let processRunning = false
|
2026-01-06 23:32:58 +05:00
|
|
|
|
let launching = false
|
|
|
|
|
|
|
2026-01-07 00:15:36 +05:00
|
|
|
|
// when process state changes, enable/disable IPC
|
|
|
|
|
|
isJarvisRunning.subscribe((value) => {
|
|
|
|
|
|
processRunning = value
|
|
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
|
// process is running, enable IPC connection
|
|
|
|
|
|
enableIpc()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// process stopped, disable IPC (stops reconnect attempts)
|
|
|
|
|
|
disableIpc()
|
|
|
|
|
|
}
|
2026-01-04 22:50:34 +05:00
|
|
|
|
})
|
2023-06-11 19:18:58 +05:00
|
|
|
|
|
2026-01-04 22:50:34 +05:00
|
|
|
|
onMount(() => {
|
|
|
|
|
|
document.body.classList.add("assist-page")
|
2026-01-07 00:15:36 +05:00
|
|
|
|
updateJarvisStats()
|
2026-01-04 22:50:34 +05:00
|
|
|
|
})
|
2023-06-11 19:18:58 +05:00
|
|
|
|
|
2026-01-04 22:50:34 +05:00
|
|
|
|
onDestroy(() => {
|
|
|
|
|
|
document.body.classList.remove("assist-page")
|
2026-01-07 00:15:36 +05:00
|
|
|
|
disableIpc()
|
2026-01-04 22:50:34 +05:00
|
|
|
|
})
|
2026-01-06 23:32:58 +05:00
|
|
|
|
|
|
|
|
|
|
async function runAssistant() {
|
|
|
|
|
|
launching = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
await invoke("run_jarvis_app")
|
2026-01-07 00:15:36 +05:00
|
|
|
|
|
|
|
|
|
|
// wait for startup
|
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
|
|
await updateJarvisStats()
|
2026-01-06 23:32:58 +05:00
|
|
|
|
launching = false
|
2026-01-07 00:15:36 +05:00
|
|
|
|
}, 2500)
|
2026-01-06 23:32:58 +05:00
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error("Failed to run jarvis-app:", err)
|
|
|
|
|
|
launching = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-11 19:18:58 +05:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<HDivider />
|
2026-01-04 22:50:34 +05:00
|
|
|
|
|
2026-01-07 00:15:36 +05:00
|
|
|
|
{#if !processRunning}
|
2026-01-04 22:50:34 +05:00
|
|
|
|
<Notification
|
|
|
|
|
|
title="Внимание!"
|
|
|
|
|
|
icon={InfoCircled}
|
|
|
|
|
|
color="cyan"
|
|
|
|
|
|
withCloseButton={false}
|
|
|
|
|
|
>
|
2026-01-06 23:32:58 +05:00
|
|
|
|
В данный момент ассистент не запущен.<br />
|
|
|
|
|
|
Но вы всё еще можете изменять его настройки.<br />
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
color="lime"
|
|
|
|
|
|
radius="md"
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
uppercase
|
|
|
|
|
|
ripple
|
|
|
|
|
|
fullSize
|
|
|
|
|
|
on:click={runAssistant}
|
|
|
|
|
|
disabled={launching}
|
|
|
|
|
|
>
|
|
|
|
|
|
{launching ? "Запуск..." : "Запустить"}
|
|
|
|
|
|
</Button>
|
2026-01-04 22:50:34 +05:00
|
|
|
|
</Notification>
|
2023-06-11 19:18:58 +05:00
|
|
|
|
{:else}
|
2026-01-04 22:50:34 +05:00
|
|
|
|
<ArcReactor />
|
2026-01-07 00:15:36 +05:00
|
|
|
|
|
|
|
|
|
|
{#if !$ipcConnected}
|
|
|
|
|
|
<Notification
|
|
|
|
|
|
title="Подключение..."
|
|
|
|
|
|
color="yellow"
|
|
|
|
|
|
withCloseButton={false}
|
|
|
|
|
|
>
|
|
|
|
|
|
Устанавливается связь с ассистентом...
|
|
|
|
|
|
</Notification>
|
|
|
|
|
|
{/if}
|
2023-06-11 19:18:58 +05:00
|
|
|
|
{/if}
|
2026-01-04 22:50:34 +05:00
|
|
|
|
|
|
|
|
|
|
<HDivider noMargin />
|
2023-06-11 19:18:58 +05:00
|
|
|
|
<Stats />
|
2026-01-06 23:32:58 +05:00
|
|
|
|
<Footer />
|