feat: HEL-68 手机端 P0 同网址分流闸门与手机壳
在电脑端 index.html head 加极早分流闸门(?ui 覆盖优先,720px/移动 UA 判定,首屏前跳转 /m/);新建 frontend/m/ 手机壳(index.html、tokens/shell CSS、api/session/router/boot JS、nav.config),首页五入口、占位图标页/功能页、登录页、日/夜主题与栈式返回。未改电脑 DOM/样式,未碰问天。 Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
(function (global) {
|
||||
"use strict";
|
||||
|
||||
const THEME_KEY = "xiaobaiTheme";
|
||||
|
||||
function readTheme() {
|
||||
try {
|
||||
return global.localStorage.getItem(THEME_KEY) === "dark" ? "dark" : "light";
|
||||
} catch (_error) {
|
||||
return "light";
|
||||
}
|
||||
}
|
||||
|
||||
function applyTheme(theme) {
|
||||
const normalized = theme === "dark" ? "dark" : "light";
|
||||
const app = document.getElementById("m-app");
|
||||
app.dataset.theme = normalized;
|
||||
app.style.colorScheme = normalized;
|
||||
document.body.style.backgroundColor = normalized === "dark" ? "#141519" : "#f4f5f7";
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
const next = readTheme() === "dark" ? "light" : "dark";
|
||||
try {
|
||||
global.localStorage.setItem(THEME_KEY, next);
|
||||
} catch (_error) {
|
||||
// Theme still applies for the current page when storage is unavailable.
|
||||
}
|
||||
applyTheme(next);
|
||||
}
|
||||
|
||||
global.MobileTheme = { readTheme: readTheme, applyTheme: applyTheme, toggle: toggle };
|
||||
|
||||
async function boot() {
|
||||
applyTheme(readTheme());
|
||||
let session = { authenticated: false };
|
||||
try {
|
||||
session = await global.MobileSession.me();
|
||||
} catch (_error) {
|
||||
session = { authenticated: false };
|
||||
}
|
||||
const hash = global.location.hash || "";
|
||||
if (!session.authenticated) {
|
||||
if (!/^#\/?auth/.test(hash)) global.location.replace("#/auth");
|
||||
} else if (/^#\/?auth/.test(hash)) {
|
||||
global.location.replace("#/home");
|
||||
}
|
||||
global.MobileRouter.init();
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", boot, { once: true });
|
||||
} else {
|
||||
boot();
|
||||
}
|
||||
})(window);
|
||||
Reference in New Issue
Block a user