safety-eval-service-frontend/public/index.html

102 lines
3.9 KiB
HTML
Raw Normal View History

2026-06-22 13:48:12 +08:00
<!--BEGIN-->
<!--<% var { env: $env, process: $process, mode: $mode, builtInfo: $builtInfo, links: $links, redirectLogin: $redirectLogin, framework: $framework, scripts: $scripts, element: $element } = htmlWebpackPlugin.options %>-->
<!--<% var { appKey: $appKey, antd: $antd, basename: $basename, API_HOST: $API_HOST } = $process %>-->
<!--<% var { ['ant-prefix']: $antPrefix, fontFamily: $fontFamily, colorPrimary: $colorPrimary, borderRadius: $borderRadius } = $antd %>-->
<!--NED-->
<!DOCTYPE html>
<html lang="zh">
<head data-built-info="<%= $builtInfo %>">
<meta charset="UTF-8"/>
<meta name="renderer" content="webkit"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover">
<% for (const item of $links) { %>
<link type="text/css" rel="stylesheet" href="<%= item %>"></link>
<% } %>
<title>--</title>
<script>
(function () {
const APP_ENV = {
antd: {
'ant-prefix': '<%= $antPrefix %>',
fontFamily: '<%= $fontFamily %>',
colorPrimary: '<%= $colorPrimary %>',
borderRadius: parseInt('<%= $borderRadius %>')
},
appKey: '<%= $appKey %>',
basename: '<%= $basename %>',
API_HOST: '<%= $API_HOST %>'
};
2026-06-26 17:28:06 +08:00
const injectedApiHost = APP_ENV.API_HOST;
const isDev = '<%= $mode %>' === 'development';
// 开发环境优先 jjb.config 注入的 API_HOST避免 sessionStorage 残留网关地址导致 Network Error
if (isDev && injectedApiHost && injectedApiHost.indexOf('http') === 0) {
APP_ENV.API_HOST = injectedApiHost;
} else {
APP_ENV.API_HOST = sessionStorage.API_HOST || injectedApiHost || window.location.origin;
}
2026-06-22 13:48:12 +08:00
window.process = {
env: { app: APP_ENV },
NODE_ENV: '<%= $mode %>'
};
window.__JJB_ENVIRONMENT__ = {
API_HOST: APP_ENV.API_HOST,
redirect: '<%= $redirectLogin %>',
FRAMEWORK: APP_ENV.antd
};
})();
2026-06-26 17:28:06 +08:00
// 抑制 ResizeObserver 在页面/标签切换时的无害告警,避免 dev overlay 误报
(function () {
if (typeof window.ResizeObserver !== 'undefined') {
var NativeResizeObserver = window.ResizeObserver;
window.ResizeObserver = class extends NativeResizeObserver {
constructor(callback) {
super(function (entries, observer) {
window.requestAnimationFrame(function () {
callback(entries, observer);
});
});
}
};
}
function isResizeObserverLoopError(message) {
return typeof message === 'string' && message.indexOf('ResizeObserver loop') !== -1;
}
function isAxiosNetworkError(reason) {
if (!reason) return false;
var msg = typeof reason === 'string' ? reason : (reason.message || '');
return msg === 'Network Error' || (reason.isAxiosError && msg === 'Network Error');
}
window.addEventListener('error', function (event) {
if (isResizeObserverLoopError(event.message)) {
event.stopImmediatePropagation();
event.preventDefault();
}
});
window.addEventListener('unhandledrejection', function (event) {
if (isAxiosNetworkError(event.reason)) {
console.warn('[dev] API unreachable:', event.reason?.config?.url || event.reason?.message);
event.preventDefault();
}
});
})();
2026-06-22 13:48:12 +08:00
</script>
<!-- SCRIPTS -->
<% for (const item of $scripts) { %>
<script src="<%= item %>" type="text/javascript"></script>
<% } %>
</head>
<body >
<!-- NOSCRIPT -->
<noscript>此网页需要开启JavaScript功能。</noscript>
<!-- MAIN -->
<% const { root } = $element; %>
<div id="<%= root.id %>" style="width: 100%; height: 100%; position: relative;overflow-y: auto"></div>
</body>
</html>