2026-07-30 09:21:55 +08:00
|
|
|
import { AlertTriangle, LoaderCircle } from "lucide-solid";
|
2026-07-30 15:16:02 +08:00
|
|
|
import { lazy, Show, Suspense } from "solid-js";
|
2026-07-30 09:21:55 +08:00
|
|
|
import { render } from "solid-js/web";
|
|
|
|
|
import { createFrameBridge } from "../primitives/create-frame-bridge";
|
|
|
|
|
import "../styles/app.css";
|
2026-07-30 15:16:02 +08:00
|
|
|
import { isView, pageDefinition } from "./registry";
|
2026-07-30 09:21:55 +08:00
|
|
|
|
|
|
|
|
function FramePage() {
|
|
|
|
|
const requested = new URLSearchParams(window.location.search).get("view");
|
|
|
|
|
const view = isView(requested) ? requested : null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Show
|
|
|
|
|
when={view}
|
|
|
|
|
fallback={
|
|
|
|
|
<main class="flex min-h-dvh items-center justify-center p-6 text-center text-coral-strong">
|
|
|
|
|
<div>
|
|
|
|
|
<AlertTriangle class="mx-auto mb-3" size={28} />
|
|
|
|
|
<strong class="block">未知页面</strong>
|
|
|
|
|
<span class="mt-1 block text-sm text-muted">{requested ?? "(empty)"}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{(activeView) => {
|
|
|
|
|
const bridge = createFrameBridge(activeView());
|
2026-07-30 15:16:02 +08:00
|
|
|
const definition = pageDefinition(activeView());
|
|
|
|
|
const Page = lazy(definition.load);
|
|
|
|
|
document.title = `${definition.label} · Wasmeld`;
|
2026-07-30 09:21:55 +08:00
|
|
|
return (
|
|
|
|
|
<Suspense
|
|
|
|
|
fallback={
|
|
|
|
|
<main class="flex min-h-dvh items-center justify-center text-muted">
|
2026-07-30 15:16:02 +08:00
|
|
|
<LoaderCircle class="animate-spin" size={24} />
|
2026-07-30 09:21:55 +08:00
|
|
|
</main>
|
|
|
|
|
}
|
|
|
|
|
>
|
2026-07-30 15:16:02 +08:00
|
|
|
<Page
|
|
|
|
|
state={bridge.state}
|
|
|
|
|
active={bridge.active}
|
|
|
|
|
lifecycle={bridge.lifecycle}
|
|
|
|
|
command={bridge.command}
|
|
|
|
|
/>
|
2026-07-30 09:21:55 +08:00
|
|
|
</Suspense>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
</Show>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const root = document.getElementById("app");
|
|
|
|
|
if (!root) throw new Error("missing #app root");
|
|
|
|
|
render(() => <FramePage />, root);
|