mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 09:40:30 +08:00
* refactor dashboard desktop bridge fields from isElectron to isDesktop * refactor dashboard runtime detection into shared helper
33 lines
924 B
TypeScript
33 lines
924 B
TypeScript
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,
|
|
}
|
|
}
|