Skip to content

Commit ef7acc6

Browse files
Azir-11honghuangdc
authored andcommitted
feat(projects): optimize tabs cache cleaning strategy. close #820.
1 parent 2a0c9f1 commit ef7acc6

File tree

14 files changed

+6
-55
lines changed

14 files changed

+6
-55
lines changed

src/constants/app.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ export const themePageAnimationModeRecord: Record<UnionKey.ThemePageAnimateMode,
5757

5858
export const themePageAnimationModeOptions = transformRecordToOption(themePageAnimationModeRecord);
5959

60-
export const resetCacheStrategyRecord: Record<UnionKey.ResetCacheStrategy, App.I18n.I18nKey> = {
61-
refresh: 'theme.layout.resetCacheStrategy.refresh',
62-
close: 'theme.layout.resetCacheStrategy.close'
63-
};
64-
65-
export const resetCacheStrategyOptions = transformRecordToOption(resetCacheStrategyRecord);
66-
6760
export const DARK_CLASS = 'dark';
6861

6962
export const watermarkTimeFormatOptions = [

src/layouts/modules/theme-drawer/modules/layout/modules/tab-settings.vue

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { resetCacheStrategyOptions, themeTabModeOptions } from '@/constants/app';
2+
import { themeTabModeOptions } from '@/constants/app';
33
import { useThemeStore } from '@/store/modules/theme';
44
import { translateOptions } from '@/utils/common';
55
import { $t } from '@/locales';
@@ -15,14 +15,6 @@ const themeStore = useThemeStore();
1515
<template>
1616
<NDivider>{{ $t('theme.layout.tab.title') }}</NDivider>
1717
<TransitionGroup tag="div" name="setting-list" class="flex-col-stretch gap-12px">
18-
<SettingItem key="0" :label="$t('theme.layout.resetCacheStrategy.title')">
19-
<NSelect
20-
v-model:value="themeStore.resetCacheStrategy"
21-
:options="translateOptions(resetCacheStrategyOptions)"
22-
size="small"
23-
class="w-120px"
24-
/>
25-
</SettingItem>
2618
<SettingItem key="1" :label="$t('theme.layout.tab.visible')">
2719
<NSwitch v-model:value="themeStore.tab.visible" />
2820
</SettingItem>

src/layouts/modules/theme-drawer/modules/preset/modules/theme-preset.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ type ThemePreset = Pick<
1616
| 'themeColor'
1717
| 'otherColor'
1818
| 'isInfoFollowPrimary'
19-
| 'resetCacheStrategy'
2019
| 'layout'
2120
| 'page'
2221
| 'header'

src/locales/langs/en-us.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ const local: App.I18n.Schema = {
185185
}
186186
},
187187
fixedHeaderAndTab: 'Fixed Header And Tab'
188-
},
189-
resetCacheStrategy: {
190-
title: 'Reset Cache Strategy',
191-
close: 'Close Page',
192-
refresh: 'Refresh Page'
193188
}
194189
},
195190
general: {

src/locales/langs/zh-cn.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ const local: App.I18n.Schema = {
182182
}
183183
},
184184
fixedHeaderAndTab: '固定头部和标签栏'
185-
},
186-
resetCacheStrategy: {
187-
title: '重置缓存策略',
188-
close: '关闭页面',
189-
refresh: '刷新页面'
190185
}
191186
},
192187
general: {

src/store/modules/app/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ export const useAppStore = defineStore(SetupStoreId.App, () => {
4646
});
4747

4848
setReloadFlag(true);
49-
50-
if (themeStore.resetCacheStrategy === 'refresh') {
51-
routeStore.resetRouteCache();
52-
}
49+
routeStore.resetRouteCache();
5350
}
5451

5552
const locale = ref<App.I18n.LangType>(localStg.get('lang') || 'zh-CN');

src/store/modules/tab/index.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
112112
await switchRouteByTab(nextTab);
113113
}
114114

115-
// reset route cache if cache strategy is close
116-
if (themeStore.resetCacheStrategy === 'close') {
117-
routeStore.resetRouteCache(removedTabRouteKey);
118-
}
115+
// reset route cache
116+
routeStore.resetRouteCache(removedTabRouteKey);
119117
}
120118

121119
/** remove active tab */
@@ -147,10 +145,8 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
147145
const tabsToRemove = tabs.value.filter(tab => !remainTabIds.includes(tab.id));
148146
const routeKeysToReset: RouteKey[] = [];
149147

150-
if (themeStore.resetCacheStrategy === 'close') {
151-
for (const tab of tabsToRemove) {
152-
routeKeysToReset.push(tab.routeKey);
153-
}
148+
for (const tab of tabsToRemove) {
149+
routeKeysToReset.push(tab.routeKey);
154150
}
155151

156152
const removedTabsIds = tabsToRemove.map(tab => tab.id);

src/theme/preset/azir.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"error": "#c49a9a"
1616
},
1717
"isInfoFollowPrimary": true,
18-
"resetCacheStrategy": "refresh",
1918
"layout": {
2019
"mode": "vertical-mix",
2120
"scrollMode": "wrapper"

src/theme/preset/compact.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"error": "#f5222d"
1616
},
1717
"isInfoFollowPrimary": true,
18-
"resetCacheStrategy": "close",
1918
"layout": {
2019
"mode": "vertical",
2120
"scrollMode": "content"

src/theme/preset/dark.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"error": "#f5222d"
1616
},
1717
"isInfoFollowPrimary": true,
18-
"resetCacheStrategy": "close",
1918
"layout": {
2019
"mode": "vertical",
2120
"scrollMode": "content"

0 commit comments

Comments
 (0)