Skip to content

Commit

Permalink
feat: 加上version配置以便在版本改变时清空缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Sep 7, 2022
1 parent 091f9ad commit 4f0a169
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { createApp } from 'vue';
import App from './App.vue';
import { event, mitter } from './event';
import layoutMenuItem from '@/layout/components/menu/components/menuItem.vue';
import KeepAlive from '@/components/meKeepAlive';
export const app = createApp(App);
export async function bootscrapt() {
app.component('LayoutMenuItem', layoutMenuItem);
app.component('KeepAlive', KeepAlive);
await Promise.allSettled(mitter.emit(event.START, app));
mitter.emit(event.READY, app);
app.mount('#app');
Expand Down
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import loginConfig from './login';
import themeConfig from './theme';
const settingKey = 'me-config';
const settingConfig = {
version: '1.0.3', //版本当版本改变时会清空localStorage和sessionStorage
openKeepAlive: true, // 是否开启KeepAlive缓存
};
export { loginConfig, localeConfig, themeConfig, settingKey, settingConfig };
6 changes: 6 additions & 0 deletions src/event/modules/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { installI18n } from '@/locales/i18n';
import nProgress from 'nprogress';
import 'nprogress/nprogress.css';
import { permission } from '@/utils/permission';
import { settingKey, settingConfig } from '@/config';
mitter.once(event.START, async (app) => {
if (localStorage.getItem(`${settingKey}-version`) !== settingConfig.version) {
localStorage.clear();
sessionStorage.clear();
localStorage.setItem(`${settingKey}-version`, settingConfig.version);
}
installIcon(app);
await installStore(app);
await installI18n(app);
Expand Down

0 comments on commit 4f0a169

Please sign in to comment.