/** * Application-wide state: product information from `app.about` and the * last error the shell reported. */ import { defineStore } from "pinia"; import { ref } from "vue"; import { run, type EngineError } from "../ipc"; /** Result of the `app.about` command. */ export interface AboutInfo { /** Product name. */ name: string; /** Version of the running build. */ version: string; /** Slogan shown in the About window. */ slogan: string; } /** Store holding product information and the last engine error. */ export const useAppStore = defineStore("app", () => { /** Product information, null until loaded. */ const about = ref(null); /** Last error from the engine, null if none. */ const lastError = ref(null); /** Loads product information from the engine; on failure records the error. */ async function loadAbout(): Promise { const result = await run("app.about"); if (result.ok) { about.value = result.value; lastError.value = null; } else { lastError.value = result.error; } } return { about, lastError, loadAbout }; });