diff --git a/src/store/modules/achievements.ts b/src/store/modules/achievements.ts index b696fd8d..4de67aef 100644 --- a/src/store/modules/achievements.ts +++ b/src/store/modules/achievements.ts @@ -24,12 +24,18 @@ const useAchievementsStore = defineStore({ init() { this.total_achievements = 899; this.fin_achievements = 0; - this.title = "成就完成数:0/899 完成率:0%"; + this.title = this.getTitle(); }, flushData(total: number, fin: number) { this.total_achievements = total; this.fin_achievements = fin; - this.title = `成就完成数:${fin}/${total} 完成率:${((fin / total) * 100).toFixed(2)}%`; + this.title = this.getTitle(); + }, + getTitle() { + return `成就完成数:${this.fin_achievements}/${this.total_achievements} 完成率:${( + (this.fin_achievements / this.total_achievements) * + 100 + ).toFixed(2)}%`; }, }, persist: true, diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 5d7b1909..e999f035 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -46,6 +46,10 @@ const useAppStore = defineStore({ actions: { // 初始化配置 async init() { + // 防止数据清空 + if (this.sidebar === undefined) { + this.sidebar = true; + } // 初始化加载状态 this.loading = false; // 初始化咨讯页渲染模式