build / build (push) Successful in 8m17s
- index.html 插 A 类 loader:唯一接入点,FOUC 门/manifest 预取/link 排序全由 yh-theme-init.js 承担,主题升级走 /static 通道不重新构建 - vite 加 /static dev 代理(YH_THEME_PROXY_TARGET 可覆盖) - host.config 回写 __APP_CONFIG__.serviceHost(仅同源):init 的 appearance 请求跨源会被直接跳过 - 顶栏头像接平台键 yh-avatar,监听 yh-appearance-updated,userInfo 兜底 - view-ui-plus 声明锁 1.3.24(对齐通道皮肤生成版本)
65 lines
3.6 KiB
HTML
65 lines
3.6 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<!-- 运行时配置引导:在任何应用模块执行前同步拉取 /<contextPath>/api/env-config
|
||
(后端免登录端点,projman 配置管理在线维护),替代生产构建环境变量。
|
||
必须同步:host.config.ts 在模块求值期就读 window.__APP_CONFIG__;失败/本地开发
|
||
(根路径,段数不足 2)则不设置:本地走 .env.dev(VITE_*),线上走同域推导兜底。
|
||
target = URL 第 2 段目录名:本应用产物部署于 /{contextPath}/front/,故为 front,
|
||
对应后端配置键 yh.env-config.source.front(环境变量 YH_ENV_CONFIG_SOURCE_FRONT)。
|
||
注意:同步 XHR 不支持 timeout 属性(赋值会抛 InvalidAccessError),依赖内网快速失败 -->
|
||
<script>
|
||
(function () {
|
||
try {
|
||
var seg = location.pathname.split("/").filter(Boolean);
|
||
if (seg.length < 2) return; // 本地开发(根路径):走 .env.dev
|
||
var xhr = new XMLHttpRequest();
|
||
xhr.open("GET", "/" + seg[0] + "/api/env-config?target=" + encodeURIComponent(seg[1]), false);
|
||
xhr.send(null);
|
||
if (xhr.status === 200) {
|
||
var conf = JSON.parse(xhr.responseText);
|
||
if (conf && typeof conf === "object") window.__APP_CONFIG__ = conf;
|
||
}
|
||
} catch (e) {
|
||
/* 拉取失败保持未设置,走同域推导兜底 */
|
||
}
|
||
})();
|
||
</script>
|
||
<!-- 主题通道引导(A 类免插件接入,见 YschTheme《管理端主题远程化与公共静态通道方案》§11):
|
||
唯一接入点。不装 npm 依赖、不改构建配置;FOUC 门、manifest 预取、主题 <link> 追加与
|
||
排序(晚于 viewuiplus.css)全由通道 yh-theme-init.js 承担,主题升级走 /static 通道,
|
||
本应用无需重新构建。
|
||
origin 零写死,优先级四档:__APP_CONFIG__.staticHost(专用通道覆盖)
|
||
> __APP_CONFIG__.baseHost(env-config 在线维护,换域名改配置即生效)
|
||
> %VITE_THEME_HOST%(仅 dev 注入的跨源直连,需通道已开 CORS)
|
||
> 同源相对 "/static/…"(生产常态:本应用部署在 base 域 /<app>/front/,与通道同源;
|
||
本地 dev 由 vite.config 的 /static 代理兜到通道)。
|
||
document.write 是有意为之:保证 parser-blocking,让档位类与 FOUC 门先于首帧;
|
||
build 不读 .env,占位符留字面量 → 判首字符 % 置空 → 产物零环境值烧入。 -->
|
||
<script>
|
||
(function () {
|
||
var c = window.__APP_CONFIG__ || {};
|
||
var themeHost = "%VITE_THEME_HOST%";
|
||
if (themeHost.charAt(0) === "%") themeHost = "";
|
||
var host = String(c.staticHost || c.baseHost || themeHost).replace(/\/+$/, "");
|
||
document.write('<script src="' + host + '/static/js/yh-theme-init.js"><\/script>');
|
||
})();
|
||
</script>
|
||
<title><%- title %></title>
|
||
<link rel="stylesheet" href="./libs/ztree/zTreeStyle.css" />
|
||
<script src="./libs/jquery.min.js"></script>
|
||
<script src="./libs/lodash.min.js"></script>
|
||
<script src="./libs/ztree/jquery.ztree.all.min.js"></script>
|
||
<%- injectScript %>
|
||
</head>
|
||
|
||
<body>
|
||
<div id="app"></div>
|
||
<script type="module" src="/src/main.ts"></script>
|
||
</body>
|
||
|
||
</html> |