cloud-web-corejs 1.0.54-dev.759 → 1.0.54-dev.760

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.759",
4
+ "version": "1.0.54-dev.760",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
package/src/index.js CHANGED
@@ -327,14 +327,13 @@ function syncSubRouter() {
327
327
 
328
328
  /**
329
329
  * 主应用页签"刷新"转发过来时在子应用内部重建当前页组件。
330
- * 与主应用自身刷新同一套路:先删 keep-alive 缓存,再绕 /redirect 让组件重新创建。
330
+ * 不能套用主应用那招(delCachedView + /redirect):子应用与主应用共用同一个
331
+ * 浏览器 hash,跳 /redirect 会被主应用 afterEach 判成"离开子应用路由",
332
+ * 容器随即隐藏并暂停子应用路由,重建被掐断——表现就是点刷新没反应。
333
+ * 改为自增序号通知 AppMain 原地销毁重建,全程不碰 URL。
331
334
  */
332
335
  function refreshCurrentView() {
333
- const view = router.currentRoute;
334
- const fullPath = view.fullPath;
335
- store.dispatch("tagsView/delCachedView", view).then(() => {
336
- router.replace({ path: "/redirect" + fullPath }).catch(() => {});
337
- });
336
+ store.commit("micro/BUMP_RELOAD_SEQ");
338
337
  }
339
338
 
340
339
  export async function update(props = {}) {
@@ -4,7 +4,7 @@
4
4
  <!-- <keep-alive :include="cachedViews"><router-view :key="key" v-if="$route.name !== 'outLink'" /></keep-alive>-->
5
5
 
6
6
  <BaseKeepAlive :include="cachedViews">
7
- <router-view :key="key" v-if="$route.name !== 'outLink'" />
7
+ <router-view :key="key" v-if="microReloadFlag && $route.name !== 'outLink'" />
8
8
  </BaseKeepAlive>
9
9
 
10
10
  </transition>
@@ -59,10 +59,27 @@ export default {
59
59
  data() {
60
60
  return {
61
61
  rIndex: -1,
62
- reflushFlag: true
62
+ reflushFlag: true,
63
+ // 子应用模式下由 micro.reloadSeq 驱动的重建开关,见下方 watch
64
+ microReloadFlag: true
63
65
  };
64
66
  },
65
67
  methods: {},
68
+ watch: {
69
+ // 主应用页签刷新经 update({microRefresh}) 传到子应用后自增该序号。
70
+ // 这里不走 /redirect 重建:子应用与主应用共用同一个浏览器 hash,
71
+ // 跳 /redirect 会被主应用 afterEach 判成"离开子应用路由"从而隐藏容器并暂停子应用路由,
72
+ // 重建被掐断,表现为刷新无反应。改为原地销毁重建组件,完全不碰 URL。
73
+ "$store.state.micro.reloadSeq"() {
74
+ let view = this.$route;
75
+ this.$store.dispatch("tagsView/delCachedView", view).then(() => {
76
+ this.microReloadFlag = false;
77
+ this.$nextTick(() => {
78
+ this.microReloadFlag = true;
79
+ });
80
+ });
81
+ }
82
+ },
66
83
  created() {
67
84
  // handler 存实例属性并在销毁时 $off:事件总线是应用级单例,
68
85
  // 不解绑会在登出重建布局后累积 handler 并钉住旧实例(内存泄露)
@@ -17,6 +17,8 @@ const state = {
17
17
  // 主应用经本地调试覆盖装载本应用时为 true:启用"URL 直达未配菜单页面"的兜底路由。
18
18
  // 正式注册表装载时为 false——菜单即权限边界,不能让任意路径都能打开组件
19
19
  debug: false,
20
+ // 主应用页签"刷新"下发 update({microRefresh}) 时自增,AppMain 据此原地重建当前页组件
21
+ reloadSeq: 0,
20
22
  };
21
23
 
22
24
  const mutations = {
@@ -29,6 +31,9 @@ const mutations = {
29
31
  state.lang = payload.lang || "";
30
32
  state.debug = !!payload.debug;
31
33
  },
34
+ BUMP_RELOAD_SEQ: (state) => {
35
+ state.reloadSeq = state.reloadSeq + 1;
36
+ },
32
37
  SET_ROUTER_PAUSED: (state, paused) => {
33
38
  state.routerPaused = !!paused;
34
39
  },