2026-07-17 11:54:43 +08:00

32 lines
1.3 KiB
JavaScript
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.

(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”的正常入口。
}
})();