cloud-web-corejs 1.0.54-dev.756 → 1.0.54-dev.757
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/index.js +15 -0
- package/src/layout/components/AppMain.vue +7 -0
- package/src/microRouter/index.js +15 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -323,12 +323,27 @@ function syncSubRouter() {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
/**
|
|
327
|
+
* 主应用页签"刷新"转发过来时在子应用内部重建当前页组件。
|
|
328
|
+
* 与主应用自身刷新同一套路:先删 keep-alive 缓存,再绕 /redirect 让组件重新创建。
|
|
329
|
+
*/
|
|
330
|
+
function refreshCurrentView() {
|
|
331
|
+
const view = router.currentRoute;
|
|
332
|
+
const fullPath = view.fullPath;
|
|
333
|
+
store.dispatch("tagsView/delCachedView", view).then(() => {
|
|
334
|
+
router.replace({ path: "/redirect" + fullPath }).catch(() => {});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
326
338
|
export async function update(props = {}) {
|
|
327
339
|
if (props.microActive === false) {
|
|
328
340
|
pauseSubRouter();
|
|
329
341
|
} else if (props.microActive === true) {
|
|
330
342
|
resumeSubRouter();
|
|
331
343
|
}
|
|
344
|
+
if (props.microRefresh) {
|
|
345
|
+
refreshCurrentView();
|
|
346
|
+
}
|
|
332
347
|
}
|
|
333
348
|
|
|
334
349
|
export async function unmount() {
|
|
@@ -32,6 +32,7 @@ import outLink from '@base/views/user/outLink/index.vue';
|
|
|
32
32
|
import unreadDialog from "../../layout/components/notify_message/unreadDialog.vue";
|
|
33
33
|
import watermark from "./watermark";
|
|
34
34
|
import { isRepeatable } from "@base/utils/repeatOpen";
|
|
35
|
+
import { refreshMicroApp } from "@base/microRouter";
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
export default {
|
|
@@ -66,6 +67,12 @@ export default {
|
|
|
66
67
|
// handler 存实例属性并在销毁时 $off:事件总线是应用级单例,
|
|
67
68
|
// 不解绑会在登出重建布局后累积 handler 并钉住旧实例(内存泄露)
|
|
68
69
|
this.reflushRouteViewHandler = (view) => {
|
|
70
|
+
let meta = this.$route.meta || {};
|
|
71
|
+
// 子应用页面不在本 router-view 内(由 qiankun 挂独立容器),
|
|
72
|
+
// 走本地 /redirect 重建只会隐藏再显示容器、实例不变,须转发给子应用自己重建
|
|
73
|
+
if (meta.isMicroApp && refreshMicroApp(meta.appCode)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
69
76
|
if(this.$route.name=="outLink"){
|
|
70
77
|
let t = this.$refs["ref_"+this.$route.path][0];
|
|
71
78
|
t.$baseReload();
|
package/src/microRouter/index.js
CHANGED
|
@@ -363,6 +363,21 @@ function notifyMicroApp(instance, props) {
|
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
+
/**
|
|
367
|
+
* 转发"刷新当前页"给子应用。
|
|
368
|
+
* 保活模式下主应用那套 delCachedView + /redirect 重建只作用于自己的 router-view,
|
|
369
|
+
* 子应用内容由 qiankun 挂在独立容器里,走一圈只是容器隐藏再显示、实例毫发无损,
|
|
370
|
+
* 表现为点刷新没反应——必须由子应用在自身路由内重建组件。
|
|
371
|
+
* 返回是否已转发(false 表示该应用未装载,调用方回落自身刷新逻辑)。
|
|
372
|
+
*/
|
|
373
|
+
export function refreshMicroApp(appCode) {
|
|
374
|
+
const alive = aliveApps[appCode];
|
|
375
|
+
if (!alive) return false;
|
|
376
|
+
// 带时间戳:qiankun 对相同 props 也会调用 update,但时间戳能让子应用区分每次点击
|
|
377
|
+
notifyMicroApp(alive.instance, { microRefresh: Date.now() });
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
|
|
366
381
|
/** 真正卸载全部子应用(登出等场景按需调用;常规页签切换不卸载) */
|
|
367
382
|
export function unmountAllMicroApps() {
|
|
368
383
|
Object.keys(aliveApps).forEach((code) => {
|