File size: 924 Bytes
8ede856 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | export type DesktopRuntimeInfo = {
bridge: Window['astrbotDesktop'] | undefined
hasDesktopRuntimeProbe: boolean
hasDesktopRestartCapability: boolean
isDesktopRuntime: boolean
}
export async function getDesktopRuntimeInfo(): Promise<DesktopRuntimeInfo> {
const bridge = window.astrbotDesktop
const hasDesktopRuntimeProbe =
!!bridge && typeof bridge.isDesktopRuntime === 'function'
const hasDesktopRestartCapability =
!!bridge &&
typeof bridge.restartBackend === 'function' &&
hasDesktopRuntimeProbe
let isDesktopRuntime = !!bridge?.isDesktop
if (hasDesktopRuntimeProbe) {
try {
isDesktopRuntime = isDesktopRuntime || !!(await bridge.isDesktopRuntime())
} catch (error) {
console.warn('[desktop-runtime] Failed to detect desktop runtime.', error)
}
}
return {
bridge,
hasDesktopRuntimeProbe,
hasDesktopRestartCapability,
isDesktopRuntime,
}
}
|