|
|
@@ -171,15 +171,27 @@ export function useRafThrottle<T extends FunctionArgs>(fn: T): T {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-export function resetMicroContentWH(domId, callBack?: Function) {
|
|
|
- const contentDom = document.getElementById(domId);
|
|
|
- if (contentDom && contentDom.firstChild) {
|
|
|
- (contentDom.firstChild as HTMLElement).style.height = '100%';
|
|
|
- (contentDom.firstChild as HTMLElement).style.width = '100%';
|
|
|
- if (callBack) callBack();
|
|
|
- } else {
|
|
|
- setTimeout(() => {
|
|
|
- resetMicroContentWH(domId, callBack);
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
+export function resetMicroContentWH(domId, callBack?: Function, maxWaitMs = 60000) {
|
|
|
+ // [fix-subapp-loading] 增加超时兜底:原实现每秒无限轮询等待微应用容器出现内容,
|
|
|
+ // 微应用挂载失败/被卸载时容器永远为空 → 加载遮罩永久转圈(整页"正在加载"卡死,见 docs/17 §8)。
|
|
|
+ // 超时后强制放行(隐藏遮罩),把"整页永久卡死"降级为"页面可见但内容可能缺失"。
|
|
|
+ const start = Date.now();
|
|
|
+ let done = false;
|
|
|
+ const poll = () => {
|
|
|
+ if (done) return;
|
|
|
+ const contentDom = document.getElementById(domId);
|
|
|
+ if (contentDom && contentDom.firstChild) {
|
|
|
+ done = true;
|
|
|
+ (contentDom.firstChild as HTMLElement).style.height = '100%';
|
|
|
+ (contentDom.firstChild as HTMLElement).style.width = '100%';
|
|
|
+ if (callBack) callBack();
|
|
|
+ } else if (Date.now() - start >= maxWaitMs) {
|
|
|
+ done = true;
|
|
|
+ console.error('[fix-subapp-loading] 微应用容器等待超时,强制放行:', domId);
|
|
|
+ if (callBack) callBack();
|
|
|
+ } else {
|
|
|
+ setTimeout(poll, 1000);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ poll();
|
|
|
}
|