iloom-flatten/index.html

57 lines
1.6 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>昱森 - 以AI为梭织天地经纬</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* 内联样式确保主题色立即生效,避免闪烁 */
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
html.light, html.light body {
background-color: #ffffff !important;
color: #000000;
}
html.dark, html.dark body {
background-color: #1a1a1a !important;
color: #ffffff;
}
</style>
<script>
// 在 React 加载前立即设置主题,避免闪烁
(function() {
const isInIframe = window.self !== window.top;
function applyThemeToDOM(theme) {
document.documentElement.classList.remove('light', 'dark');
document.documentElement.classList.add(theme);
document.documentElement.setAttribute('data-theme', theme);
}
if (isInIframe) {
// 监听父窗口主动推送的主题消息
window.addEventListener('message', function(event) {
if (event.data && typeof event.data.theme === 'string') {
const theme = event.data.theme;
if (theme === 'light' || theme === 'dark') {
applyThemeToDOM(theme);
}
}
});
} else {
// 非 iframe 环境,使用默认 light 主题
applyThemeToDOM('light');
}
})();
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>