feat(web): add lightweight workspace matching existing UI
This commit is contained in:
+26
-2
@@ -1,8 +1,32 @@
|
||||
import { render } from "preact";
|
||||
import { RootRouter } from "@/root-router";
|
||||
import { registerServiceWorker } from "@/pwa";
|
||||
import "./index.css";
|
||||
import { persistUiModePreference, readUiModePreference, resolveUiRoute } from "@/lib/ui-mode";
|
||||
import "./typography.css";
|
||||
|
||||
registerServiceWorker();
|
||||
// Both presentations use the same fonts. A blocked CDN does not block the UI.
|
||||
const fonts = document.createElement("link");
|
||||
fonts.rel = "stylesheet";
|
||||
fonts.href = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Orbitron:wght@700;800;900&display=swap";
|
||||
document.head.appendChild(fonts);
|
||||
|
||||
let storage: Storage | null = null;
|
||||
try { storage = window.localStorage; } catch { /* Storage may be unavailable in private browsing. */ }
|
||||
const connection = (navigator as Navigator & { connection?: { saveData?: boolean } }).connection;
|
||||
const route = resolveUiRoute(window.location, {
|
||||
userAgent: navigator.userAgent,
|
||||
saveData: connection?.saveData,
|
||||
}, readUiModePreference(storage));
|
||||
if (route.preference) persistUiModePreference(storage, route.preference);
|
||||
if (route.url !== `${window.location.pathname}${window.location.search}${window.location.hash}`) {
|
||||
window.history.replaceState(window.history.state, "", route.url);
|
||||
}
|
||||
|
||||
if (route.mode === "lite") {
|
||||
document.querySelector('meta[name="viewport"]')?.setAttribute("content", "width=device-width, initial-scale=1, viewport-fit=cover");
|
||||
document.querySelector('meta[name="theme-color"]')?.setAttribute("content", "#ffffff");
|
||||
} else {
|
||||
registerServiceWorker();
|
||||
}
|
||||
|
||||
render(<RootRouter />, document.getElementById("app")!);
|
||||
|
||||
Reference in New Issue
Block a user