Преглед изворни кода

fix: 修复切换选项卡时刷新的问题

Signed-off-by: 喵你个汪 <jason-dom@qq.com>
喵你个汪 пре 1 година
родитељ
комит
db53d1fa6a
1 измењених фајлова са 8 додато и 7 уклоњено
  1. 8 7
      Web/src/layout/routerView/parent.vue

+ 8 - 7
Web/src/layout/routerView/parent.vue

@@ -66,16 +66,17 @@ const getIframeListRoutes = async () => {
 onBeforeMount(() => {
 	state.keepAliveNameList = keepAliveNames.value;
 	mittBus.on('onTagsViewRefreshRouterView', (fullPath: string) => {
+		const cacheList = cachedViews.value;
+		if (route.meta.isKeepAlive) cachedViews.value = cachedViews.value?.filter((name: string) => route.name !== name);
 		state.keepAliveNameList = keepAliveNames.value.filter((name: string) => route.name !== name);
 		state.refreshRouterViewKey = '';
 		state.iframeRefreshKey = '';
-    cachedViews.value = [];
-		setTimeout(() => {
-      state.iframeRefreshKey = fullPath;
-      state.refreshRouterViewKey = fullPath;
-      cachedViews.value = [<string>route.name];
-      state.keepAliveNameList = keepAliveNames.value;
-    }, 10);
+		nextTick(() => {
+			if (route.meta.isKeepAlive) cachedViews.value = cacheList;
+			state.keepAliveNameList = keepAliveNames.value;
+			state.refreshRouterViewKey = fullPath;
+			state.iframeRefreshKey = fullPath;
+		});
 	});
 });
 // 页面加载时