32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
(function () {
|
||
'use strict';
|
||
|
||
var APP_CODE = 'fami';
|
||
|
||
window.HyAppDefaultAppCode = APP_CODE;
|
||
window.HyAppI18nSupported = ['en', 'ar', 'tr', 'es'];
|
||
document.documentElement.setAttribute('data-hy-app-code', APP_CODE);
|
||
|
||
// 该入口只属于 Fami。common/api.js 的请求租户以 app_code query 为最高优先级,若宿主误带其他
|
||
// App 参数,仅设置页面默认值仍会串到错误活动周期;在公共脚本初始化前统一 URL,保留 token/env 等参数。
|
||
try {
|
||
var url = new URL(window.location.href);
|
||
var changed = url.searchParams.get('app_code') !== APP_CODE;
|
||
url.searchParams.set('app_code', APP_CODE);
|
||
['app', 'appCode'].forEach(function (key) {
|
||
if (
|
||
url.searchParams.has(key) &&
|
||
url.searchParams.get(key) !== APP_CODE
|
||
) {
|
||
url.searchParams.set(key, APP_CODE);
|
||
changed = true;
|
||
}
|
||
});
|
||
if (changed && window.history && window.history.replaceState) {
|
||
window.history.replaceState(null, '', url.toString());
|
||
}
|
||
} catch (error) {
|
||
// 极少数受限 WebView 不允许构造或替换 URL;页面默认 App 仍能覆盖“未传 app_code”的正常入口。
|
||
}
|
||
})();
|