Files
monkey-ai-web/index.html
T
zhanjunhao 821577f4b1 refactor: 移除运行时后端配置并统一使用构建变量
删除 public/config.js 及 HTML 加载引用,后端地址改为构建变量优先、否则同源。补充环境变量示例、配置回归测试与部署迁移说明。

验证:npm run check 通过,183 项测试通过,生产构建成功。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-22 12:50:16 +08:00

362 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<!-- favicon: 后端启动时把 __WL_BRAND_FAVICON__ 替换为 common.Logo(未配置时为 /logo.svg);
dev 模式占位符未替换时,下面的内联脚本会重写 href 为 /logo.svg。 -->
<link id="wl-favicon" rel="icon" href="__WL_BRAND_FAVICON__" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- 浅/暗双色 theme-color,跟随系统偏好 —— 移动端浏览器顶栏不再"亮色背景上一条白条" -->
<meta
name="theme-color"
content="#fafbfc"
media="(prefers-color-scheme: light)"
/>
<meta
name="theme-color"
content="#0f1115"
media="(prefers-color-scheme: dark)"
/>
<meta
name="description"
content="OpenAI 接口聚合管理,支持多种渠道包括 Azure,可用于二次分发管理 key,仅单可执行文件,已打包好 Docker 镜像,一键部署,开箱即用"
/>
<!-- 中性标题;内联脚本若解析到品牌名会覆盖。换品牌时 tab 不会闪老品牌字样。 -->
<title>Loading</title>
<!--
首屏白屏过渡 - 极简加载动画。
品牌(logo / 名称 / favicon)不写死:
1. 后端启动时把 __WL_BRAND_NAME__ / __WL_BRAND_LOGO__ / __WL_BRAND_FAVICON__ 替换为系统配置
2. 内联脚本再用 localStorage 缓存兜底(返回访客拿到最新值)
3. 都没有时回退到品牌名首字母字母章,绝不出现固定品牌标识
品牌色用 CSS 变量:下面的 theme-presplash 脚本会把上一次保存的主题 CSS 同步插入,
首帧就已经是品牌色;首次访问时回落到 var() 兜底。
-->
<script>
// 暗色预判:在 splash 首帧 paint 之前同步给 <html> 打上 .dark 类。
// 镜像 Theme/index.jsx 的逻辑:'dark'(默认)→ 强制暗;'auto' → 跟随系统偏好;'light' → 浅。
// 不在 <head> 里设 body[theme-mode],因为 body 还没解析;
// theme.js 的选择器是 `html.dark, body[theme-mode="dark"]` 的 OR,只设 html.dark 已足够触发暗色变量。
// ThemeProvider mount 后会把 body 属性补齐,本脚本只是把"决策时机"从 React mount 提到了 paint 之前。
(function () {
try {
var pref = localStorage.getItem('theme-mode') || 'dark';
var isDark =
pref === 'dark' ||
(pref === 'auto' &&
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches);
if (isDark) document.documentElement.classList.add('dark');
} catch (e) {
/* 隐私模式(localStorage 不可用):与默认主题保持一致,直接落深色 */
document.documentElement.classList.add('dark');
}
})();
// 预注入上次保存的主题 CSS,消除"兜底色 → 品牌色"首帧跳变。
// 必须放在 splash <style> 之前/同步执行,才能在第一次 paint 时已就位。
(function () {
try {
var css = localStorage.getItem('theme-css-cache');
if (!css) return;
var s = document.createElement('style');
s.id = 'theme-presplash';
s.textContent = css;
document.head.appendChild(s);
} catch (e) {
/* 隐私模式 / 配额满:静默回退到兜底色 */
}
})();
</script>
<style>
.wl-loading {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
width: 100%;
background: #fafbfc;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
user-select: none;
overflow: hidden;
position: relative;
}
/* 居中柔光 —— 跟随主题色 */
.wl-loading::before {
content: '';
position: absolute;
width: 420px;
height: 420px;
border-radius: 50%;
background: radial-gradient(
circle,
var(--brand-primary-soft, rgba(22, 104, 220, 0.10)),
transparent 70%
);
filter: blur(24px);
pointer-events: none;
}
.wl-box {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
align-items: center;
animation: wl-fade 0.5s ease-out both;
}
@keyframes wl-fade {
from {
opacity: 0;
transform: translateY(12px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* logo + 旋转环 */
.wl-logo-ring {
position: relative;
width: 84px;
height: 84px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 22px;
}
.wl-logo-ring::before {
content: '';
position: absolute;
inset: 0;
border-radius: 50%;
border: 3px solid var(--brand-primary-soft, rgba(22, 104, 220, 0.16));
border-top-color: var(--brand-primary, #1668dc);
animation: wl-spin 0.9s linear infinite;
}
@keyframes wl-spin {
to {
transform: rotate(360deg);
}
}
.wl-logo-slot {
display: flex;
align-items: center;
justify-content: center;
width: 56px;
height: 56px;
}
.wl-logo {
width: 56px;
height: 56px;
border-radius: 14px;
object-fit: cover;
display: block;
}
/* 首字母字母章兜底 */
.wl-mono {
width: 56px;
height: 56px;
border-radius: 14px;
display: flex;
align-items: center;
justify-content: center;
font-size: 26px;
font-weight: 700;
color: #fff;
background: linear-gradient(
135deg,
var(--brand-gradient-from, #4096ff),
var(--brand-gradient-to, #0958d9)
);
}
.wl-brand {
font-size: 20px;
font-weight: 700;
letter-spacing: 1px;
color: var(--brand-primary, #0958d9);
margin-bottom: 14px;
min-height: 24px;
}
.wl-text {
font-size: 13px;
color: #94a3b8;
letter-spacing: 0.5px;
animation: wl-blink 1.6s ease-in-out infinite;
}
@keyframes wl-blink {
0%,
100% {
opacity: 0.45;
}
50% {
opacity: 1;
}
}
/* 暗色:系统偏好(首屏 ThemeContext 还没运行)+ 项目手动暗色 */
@media (prefers-color-scheme: dark) {
.wl-loading {
background: #0f1115;
}
.wl-text {
color: #64748b;
}
}
html.dark .wl-loading,
body[theme-mode='dark'] .wl-loading {
background: #0f1115;
}
html.dark .wl-text,
body[theme-mode='dark'] .wl-text {
color: #64748b;
}
/* 无障碍:尊重系统"减少动效"偏好 —— 关闭旋转、淡入、闪烁 */
@media (prefers-reduced-motion: reduce) {
.wl-logo-ring::before,
.wl-box,
.wl-text {
animation: none !important;
}
/* 静态指示:环改为完整一圈淡色,仍保留"正在加载"暗示 */
.wl-logo-ring::before {
border-color: var(--brand-primary, #1668dc);
opacity: 0.6;
}
.wl-text {
opacity: 0.75;
}
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root">
<!-- 首屏加载动画 - React 挂载后自动替换。data-* 由后端启动时注入。 -->
<div
id="wl-splash"
class="wl-loading"
data-brand="__WL_BRAND_NAME__"
data-logo="__WL_BRAND_LOGO__"
>
<div class="wl-box">
<div class="wl-logo-ring"><span class="wl-logo-slot"></span></div>
<div class="wl-brand"></div>
<div class="wl-text"></div>
</div>
</div>
</div>
<script>
// 解析品牌 + 渲染 splash 文案 / logo / favicon / title。
// 优先级:后端注入的 data-* > localStorage > 终极空串。
//
// 三阶段分离 —— window.__WL_BRAND__ 是硬不变量:
// 阶段 1:解析品牌(用 localStorage 兜底)并挂到 window;
// 这一步在 splash 元素检查之前,即使 splash markup 缺失(理论不该发生),
// React 端的 getSystemName/getLogo 也已经能从 window 拿到品牌。
// 阶段 2:若 splash 元素不存在则跳过后续渲染。
// 阶段 3:渲染 splash 文案 / logo / favicon / title。失败不影响 window 已设。
(function () {
var PLACEHOLDER_PREFIX = '__WL_';
var clean = function (v) {
if (!v) return '';
if (v.indexOf(PLACEHOLDER_PREFIX) === 0) return ''; // dev 模式占位符未被后端替换
if (v === 'undefined' || v === 'null') return '';
return v;
};
// ===== 阶段 1:解析 + 挂 window =====
// 区分三种"data-* 看起来是空"的语义,避免管理员 unset Logo 后
// splash 还从 localStorage 里捞出上一版的旧 logo 闪一下:
// (a) raw === null → attribute 缺失(splash markup 被改)→ 回退 LS
// (b) raw 以 '__WL_' 开头 → dev 模式占位符未被后端替换 → 回退 LS
// (c) raw === '' 或真实值 → 后端真实注入(含管理员主动 unset)→ trust,不回退 LS
var el = document.getElementById('wl-splash');
var rawBrand = el ? el.getAttribute('data-brand') : null;
var rawLogo = el ? el.getAttribute('data-logo') : null;
var brandIsDevPH = !!(rawBrand && rawBrand.indexOf(PLACEHOLDER_PREFIX) === 0);
var logoIsDevPH = !!(rawLogo && rawLogo.indexOf(PLACEHOLDER_PREFIX) === 0);
var name = brandIsDevPH ? '' : clean(rawBrand);
var logo = logoIsDevPH ? '' : clean(rawLogo);
try {
if ((!el || brandIsDevPH) && !name) name = clean(localStorage.getItem('system_name'));
if ((!el || logoIsDevPH) && !logo) logo = clean(localStorage.getItem('logo'));
} catch (e) {
/* 隐私模式 localStorage 不可用:name/logo 保持空,React 端走终极兜底 */
}
// 极端环境(CSP 严格 / 扩展冻结 window)下赋值可能抛错。
// 包一层 try 防止把阶段 3 的 splash 渲染也带挂。
try {
window.__WL_BRAND__ = { name: name, logo: logo };
} catch (e) {
/* window 不可写:React 端 utils 会走终极兜底 'Weelinking'/'/logo.svg' */
}
// ===== 阶段 2:splash 缺失则跳过渲染 =====
if (!el) return;
// ===== 阶段 3:渲染 splash =====
try {
// ---- 文案:navigator.language 判定 zh / en ----
var lang = (navigator.language || 'zh').toLowerCase();
var loadingText = lang.indexOf('zh') === 0 ? '加载中...' : 'Loading...';
var textEl = el.querySelector('.wl-text');
if (textEl) textEl.textContent = loadingText;
// ---- 品牌名 + 标题 ----
var brandEl = el.querySelector('.wl-brand');
if (brandEl && name) brandEl.textContent = name;
// 标题始终设值:有品牌名用品牌名,否则保持静态 "Loading"
if (name) document.title = name;
// ---- favicon:占位符未替换时回落 /logo.svg;有 logo URL 时覆盖 ----
var favEl = document.getElementById('wl-favicon');
if (favEl) {
var fav = favEl.getAttribute('href');
if (!fav || fav.indexOf(PLACEHOLDER_PREFIX) === 0) {
favEl.setAttribute('href', logo || '/logo.svg');
} else if (logo && fav !== logo) {
// localStorage 比后端启动注入新(管理员热改了 Logo),动态覆盖
favEl.setAttribute('href', logo);
}
}
// ---- logo / 字母章 ----
var slot = el.querySelector('.wl-logo-slot');
var monoChar = (name || '').trim();
monoChar = monoChar ? Array.from(monoChar)[0].toUpperCase() : '';
var renderMono = function () {
if (!slot) return;
slot.innerHTML = '';
// 没名字也没 logo:旋转环里留空,避免出现"空着的渐变色方块" UX 漏洞
if (!monoChar) return;
var d = document.createElement('div');
d.className = 'wl-mono';
d.textContent = monoChar;
slot.appendChild(d);
};
if (slot && logo) {
var img = document.createElement('img');
img.className = 'wl-logo';
img.alt = name || 'logo';
img.onerror = renderMono;
img.src = logo;
slot.appendChild(img);
} else {
renderMono();
}
} catch (e) {
/* splash 渲染挂了不影响 window var 已设 —— React 端仍能正确读到品牌 */
}
})();
</script>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>