Skip to content

Commit

Permalink
feat: 设置缓存机制
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 12586
  • Loading branch information
hyunfa committed Jul 19, 2024
1 parent a6706b6 commit e262cd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export default class App extends Vue {
}
private async created() {
const localConfig = JSON.parse(localStorage.getItem('config') as string);
if (localConfig) {
PlatformConfigStore.updatePlatformConfig(localConfig)
}
// 获取平台配置信息
await PlatformConfigStore.getConfig();
// 设置网页标题
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/store/modules/platform-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import logoSrc from '@/images/logoIcon.png';
export default class PlatformConfigStore extends VuexModule {
public defaults: IPlatformConfig = {
bkAppCode: '', // appcode
name: '', // 站点的名称,通常显示在页面左上角,也会出现在网页title中
nameEn: '', // 站点的名称-英文
name: '蓝鲸节点管理', // 站点的名称,通常显示在页面左上角,也会出现在网页title中
nameEn: 'BlueKing NodeMan', // 站点的名称-英文
appLogo: '', // 站点logo
favicon: '/static/images/favicon.png', // 站点favicon
helperText: '',
Expand Down Expand Up @@ -62,8 +62,10 @@ export default class PlatformConfigStore extends VuexModule {
helperText: window.i18n.t('联系BK助手'),
version: window.PROJECT_CONFIG.VERSION,
});
console.log("🚀 ~ PlatformConfigStore ~ getConfig ~ config:", config)

this.context.commit('updatePlatformConfig', config);
// 判断version
if (JSON.parse(localStorage.getItem('config') as string)?.version !== config.version ) {
this.context.commit('updatePlatformConfig', config);
localStorage.setItem('config',JSON.stringify(config));
}
}
}

0 comments on commit e262cd0

Please sign in to comment.