164 lines
6.4 KiB
HTML
164 lines
6.4 KiB
HTML
<!--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">
|
|
<meta charset="UTF-8" name="referrer" content="strict-origin-when-cross-origin"/>
|
|
<% 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 %>'
|
|
};
|
|
APP_ENV.API_HOST = '<%= $API_HOST %>';
|
|
const injectedApiHost = APP_ENV.API_HOST;
|
|
const isDev = '<%= $mode %>' === 'development';
|
|
if (isDev && injectedApiHost && injectedApiHost.indexOf('http') === 0) {
|
|
APP_ENV.API_HOST = injectedApiHost;
|
|
} else {
|
|
APP_ENV.API_HOST = sessionStorage.API_HOST || injectedApiHost || window.location.origin;
|
|
}
|
|
window.process = {
|
|
env: { app: APP_ENV },
|
|
NODE_ENV: '<%= $mode %>'
|
|
};
|
|
window.__JJB_ENVIRONMENT__ = {
|
|
API_HOST: APP_ENV.API_HOST,
|
|
redirect: '<%= $redirectLogin %>',
|
|
FRAMEWORK: APP_ENV.antd
|
|
};
|
|
|
|
/** 返回 GBS 基座(与 Map 页左上角返回一致) */
|
|
window.backToBase = function () {
|
|
window.close();
|
|
setTimeout(function () {
|
|
if (!window.closed && !window.opener) {
|
|
var apiHost = (window.__JJB_ENVIRONMENT__ && window.__JJB_ENVIRONMENT__.API_HOST)
|
|
|| (window.process && window.process.env && window.process.env.app && window.process.env.app.API_HOST)
|
|
|| 'https://gbs-gateway.qhdsafety.com/';
|
|
window.location.href = apiHost.slice(-1) === '/' ? apiHost : apiHost + '/';
|
|
}
|
|
}, 500);
|
|
};
|
|
|
|
/** 全局 HTTP 拦截器 */
|
|
window.jjbCommonGlobalConfig = {
|
|
httpInterceptor: {
|
|
request: function (url, method, params, headers) {
|
|
if (sessionStorage.getItem('orgInfoId')) {
|
|
headers.orgInfoId = sessionStorage.getItem('orgInfoId');
|
|
}
|
|
return Promise.resolve([url, method, params, headers]);
|
|
},
|
|
response: function (res) {
|
|
var url = (res && res.config && res.config.url)
|
|
|| (res.response && res.response.config && res.response.config.url)
|
|
|| '';
|
|
// 注册/填报开放接口、终端类型检测、文件上传失败时不自动返回基座
|
|
if (
|
|
url.indexOf('checkTerminalType') !== -1
|
|
|| url.indexOf('/safetyEval/images/') !== -1
|
|
|| url.indexOf('/safetyEval/file/upload') !== -1
|
|
) {
|
|
return Promise.resolve(res);
|
|
}
|
|
var data = res && (res.data || (res.response && res.response.data));
|
|
if (data && data.success === false) {
|
|
window.backToBase();
|
|
}
|
|
return Promise.resolve(res);
|
|
}
|
|
}
|
|
};
|
|
|
|
/** Driver 鉴权参数提前解析,避免首屏请求时 sessionStorage 尚未写入 */
|
|
(function bootstrapDriverAuthParams() {
|
|
var AUTH_KEYS = ['token', 'accessTicket', 'clientId', 'orgId', 'code'];
|
|
function parseQuery(search) {
|
|
var params = {};
|
|
if (!search) return params;
|
|
try {
|
|
var normalized = search.charAt(0) === '?' ? search : '?' + search;
|
|
var urlParams = new URLSearchParams(normalized);
|
|
urlParams.forEach(function (value, key) {
|
|
if (value) params[key] = value;
|
|
});
|
|
} catch (e) { /* ignore */ }
|
|
return params;
|
|
}
|
|
function parseUrl(url) {
|
|
if (!url) return {};
|
|
try {
|
|
return parseQuery(new URL(url, window.location.origin).search);
|
|
} catch (e) {
|
|
var idx = url.indexOf('?');
|
|
return idx === -1 ? {} : parseQuery(url.slice(idx));
|
|
}
|
|
}
|
|
function parseHash() {
|
|
var hash = window.location.hash || '';
|
|
var idx = hash.indexOf('?');
|
|
return idx === -1 ? {} : parseQuery(hash.slice(idx));
|
|
}
|
|
function mergeParams() {
|
|
var sources = [
|
|
parseQuery(window.location.search),
|
|
parseHash(),
|
|
parseUrl(window.location.href),
|
|
parseUrl(document.referrer)
|
|
];
|
|
var result = {};
|
|
sources.forEach(function (source) {
|
|
AUTH_KEYS.forEach(function (key) {
|
|
if (!result[key] && source[key]) result[key] = source[key];
|
|
});
|
|
});
|
|
AUTH_KEYS.forEach(function (key) {
|
|
if (!result[key]) {
|
|
var stored = sessionStorage.getItem(key);
|
|
if (stored) result[key] = stored;
|
|
}
|
|
});
|
|
AUTH_KEYS.forEach(function (key) {
|
|
if (result[key]) sessionStorage.setItem(key, result[key]);
|
|
});
|
|
return result;
|
|
}
|
|
mergeParams();
|
|
})();
|
|
})();
|
|
</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>
|
|
<script src="https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js"></script>
|
|
<link href="https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
|
|
</html>
|