2026-04-19 14:18:20 +08:00
|
|
|
<script setup lang="ts">
|
2026-04-22 00:24:21 +08:00
|
|
|
import { defineAsyncComponent, onMounted, watch } from "vue";
|
2026-04-19 14:18:20 +08:00
|
|
|
import { useDesktopSession } from "./composables/useDesktopSession";
|
2026-04-20 11:08:09 +08:00
|
|
|
|
|
|
|
|
const DesktopShell = defineAsyncComponent(() => import("./components/DesktopShell.vue"));
|
|
|
|
|
const LoginView = defineAsyncComponent(() => import("./views/LoginView.vue"));
|
2026-04-19 14:18:20 +08:00
|
|
|
|
|
|
|
|
const { isAuthenticated, syncRuntimeSession } = useDesktopSession();
|
|
|
|
|
|
2026-04-22 00:24:21 +08:00
|
|
|
interface WindowModeBridge {
|
|
|
|
|
setWindowMode?: (mode: "login" | "main") => Promise<unknown>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getModeBridge(): WindowModeBridge | undefined {
|
|
|
|
|
return (globalThis as unknown as {
|
|
|
|
|
desktopBridge?: { app?: WindowModeBridge };
|
|
|
|
|
}).desktopBridge?.app;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function syncWindowMode(authenticated: boolean): void {
|
|
|
|
|
void getModeBridge()?.setWindowMode?.(authenticated ? "main" : "login");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fire immediately during setup so the main process can size + reveal the
|
|
|
|
|
// window before the user sees any "wrong-sized" frame.
|
|
|
|
|
syncWindowMode(isAuthenticated.value);
|
|
|
|
|
watch(isAuthenticated, (next) => syncWindowMode(next));
|
|
|
|
|
|
2026-04-19 14:18:20 +08:00
|
|
|
onMounted(() => {
|
|
|
|
|
void syncRuntimeSession();
|
2026-04-22 00:24:21 +08:00
|
|
|
syncWindowMode(isAuthenticated.value);
|
2026-04-19 14:18:20 +08:00
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<DesktopShell v-if="isAuthenticated" />
|
|
|
|
|
<LoginView v-else />
|
|
|
|
|
</template>
|