cloud-web-corejs 1.0.54-dev.761 → 1.0.54-dev.762
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/vab.js +1 -0
- package/src/views/user/login/indexMixin.js +74 -21
package/package.json
CHANGED
package/src/utils/vab.js
CHANGED
|
@@ -92,9 +92,8 @@ export default {
|
|
|
92
92
|
beforeDestroy() {
|
|
93
93
|
this.clearQrLoginTimer();
|
|
94
94
|
this.clearSmsTimer();
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
this.closeRedirectLoading();
|
|
95
|
+
// 注意:这里不能关跳转期 loading。组件销毁发生在导航确认时,而首页真正渲染上屏
|
|
96
|
+
// 还在其后,遮罩要撑过这段时间,由 closeRedirectLoading 收口
|
|
98
97
|
},
|
|
99
98
|
created() {
|
|
100
99
|
this.init();
|
|
@@ -250,10 +249,11 @@ export default {
|
|
|
250
249
|
localStorage.removeItem("currentMenuId");
|
|
251
250
|
this.rememberPassword();
|
|
252
251
|
window.removeEventListener("keydown", this.keyDown, false);
|
|
253
|
-
// 登录成功后的跳转链路(getWebPrefix → 路由守卫拉用户信息/生成动态路由 →
|
|
254
|
-
//
|
|
255
|
-
//
|
|
256
|
-
|
|
252
|
+
// 登录成功后的跳转链路(getWebPrefix → 路由守卫拉用户信息/生成动态路由 →
|
|
253
|
+
// 首页渲染上屏)耗时较长,换成挂在 body 上的全屏遮罩顶住这段时间,
|
|
254
|
+
// 防止登录页被再次操作;由 closeRedirectLoading 统一收口
|
|
255
|
+
loadingObj.close();
|
|
256
|
+
this.openRedirectLoading();
|
|
257
257
|
this.handleRedirectUrl();
|
|
258
258
|
} else {
|
|
259
259
|
setTimeout(function () {
|
|
@@ -470,19 +470,11 @@ export default {
|
|
|
470
470
|
prefix = prefix || window.WEB_PREFIX;
|
|
471
471
|
location.href = prefix + "/index.html" + path;
|
|
472
472
|
} else {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
// 跳转完成(守卫链+首页组件解析结束)
|
|
479
|
-
this.closeRedirectLoading();
|
|
480
|
-
},
|
|
481
|
-
() => {
|
|
482
|
-
// 跳转被中止(如守卫拉取用户信息失败后重定向回登录页),恢复登录页可操作
|
|
483
|
-
this.closeRedirectLoading(true);
|
|
484
|
-
}
|
|
485
|
-
);
|
|
473
|
+
// 遮罩不在 push 的回调里收口:守卫内的重定向会让原始导航走 onAbort,
|
|
474
|
+
// 而真正的导航仍在继续,统一交给 openRedirectLoading 里注册的 afterEach
|
|
475
|
+
this.$router.push({
|
|
476
|
+
path: path,
|
|
477
|
+
});
|
|
486
478
|
}
|
|
487
479
|
}, () => {
|
|
488
480
|
// getWebPrefix 请求失败:恢复登录页可操作,避免 loading 永久卡死
|
|
@@ -528,10 +520,71 @@ export default {
|
|
|
528
520
|
});
|
|
529
521
|
},
|
|
530
522
|
/**
|
|
531
|
-
*
|
|
523
|
+
* 打开登录跳转期的全屏遮罩。
|
|
524
|
+
* 不能用 fullscreen:true —— element 的全屏 loading 是全局单例(fullscreenLoading),
|
|
525
|
+
* request.js 里 isLoading 的请求(getWebPrefix 就是)用的正是这个单例,请求结束会把
|
|
526
|
+
* 它一起 close 掉。这里传 target:body + fullscreen:false 拿独立实例,遮罩挂在 body 上
|
|
527
|
+
* 不随登录组件销毁而消失,全屏样式手动补。
|
|
528
|
+
*/
|
|
529
|
+
openRedirectLoading() {
|
|
530
|
+
this.closeRedirectLoading();
|
|
531
|
+
let loading = this.$baseLoading({
|
|
532
|
+
target: document.body,
|
|
533
|
+
fullscreen: false,
|
|
534
|
+
lock: true,
|
|
535
|
+
});
|
|
536
|
+
let el = loading && loading.$el;
|
|
537
|
+
if (el) {
|
|
538
|
+
el.style.position = "fixed";
|
|
539
|
+
el.style.top = "0";
|
|
540
|
+
el.style.left = "0";
|
|
541
|
+
el.style.width = "100%";
|
|
542
|
+
el.style.height = "100%";
|
|
543
|
+
el.style.zIndex = 9999;
|
|
544
|
+
}
|
|
545
|
+
this.redirectLoadingObj = loading;
|
|
546
|
+
// 收口挂在 afterEach 上:路由守卫里的重定向会让原始 push 走 onAbort,但新导航
|
|
547
|
+
// 其实还在继续(实测 onAbort 在 +211ms 触发,首页 +577ms 才绘制完成),所以不能
|
|
548
|
+
// 用 push 的回调收口。afterEach 只在导航真正确认后触发一次,且带最终目标路由
|
|
549
|
+
this.redirectAfterEachOff = this.$router.afterEach((to) => {
|
|
550
|
+
if (String((to && to.path) || "").indexOf("/login") >= 0) {
|
|
551
|
+
// 兜了一圈又回到登录页(如守卫拉用户信息失败),恢复登录页可操作
|
|
552
|
+
this.closeRedirectLoading(true);
|
|
553
|
+
} else {
|
|
554
|
+
this.closeRedirectLoadingAfterPaint();
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
// 兜底:跳转链路既不 complete 也不 abort 时不至于永久锁死
|
|
558
|
+
this.redirectLoadingTimer = setTimeout(() => {
|
|
559
|
+
this.closeRedirectLoading(true);
|
|
560
|
+
}, 20000);
|
|
561
|
+
},
|
|
562
|
+
/**
|
|
563
|
+
* 等目标页真正绘制上屏后再撤遮罩:$nextTick 等 Vue 完成 patch,
|
|
564
|
+
* 双 rAF 等浏览器完成这一帧的绘制
|
|
565
|
+
*/
|
|
566
|
+
closeRedirectLoadingAfterPaint() {
|
|
567
|
+
this.$nextTick(() => {
|
|
568
|
+
requestAnimationFrame(() => {
|
|
569
|
+
requestAnimationFrame(() => {
|
|
570
|
+
this.closeRedirectLoading();
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
});
|
|
574
|
+
},
|
|
575
|
+
/**
|
|
576
|
+
* 登录跳转期 loading 统一收口:上屏完成、跳转中止、getWebPrefix 失败、超时兜底时调用。
|
|
532
577
|
* reenable=true 时恢复登录页可操作(跳转失败仍停留在登录页的场景)
|
|
533
578
|
*/
|
|
534
579
|
closeRedirectLoading(reenable) {
|
|
580
|
+
if (this.redirectAfterEachOff) {
|
|
581
|
+
this.redirectAfterEachOff();
|
|
582
|
+
this.redirectAfterEachOff = null;
|
|
583
|
+
}
|
|
584
|
+
if (this.redirectLoadingTimer) {
|
|
585
|
+
clearTimeout(this.redirectLoadingTimer);
|
|
586
|
+
this.redirectLoadingTimer = null;
|
|
587
|
+
}
|
|
535
588
|
if (this.redirectLoadingObj) {
|
|
536
589
|
this.redirectLoadingObj.close();
|
|
537
590
|
this.redirectLoadingObj = null;
|