Files
TeyvatGuide/src/store/modules/achievements.ts
2023-03-22 15:59:06 +08:00

45 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file store modules achievements.ts
* @description Achievements store module
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha
*/
import { defineStore } from "pinia";
const useAchievementsStore = defineStore({
id: "achievements",
state() {
return {
total_achievements: 899,
fin_achievements: 0,
// 这个数据用于说明当前的数据版本,不会被渲染
last_version: "v3.5",
UIAF_Version: "v1.1",
// 显示用,避免重复计算
title: "成就完成数0/899 完成率0%",
};
},
actions: {
init() {
this.total_achievements = 899;
this.fin_achievements = 0;
this.title = this.getTitle();
},
flushData(total: number, fin: number) {
this.total_achievements = total;
this.fin_achievements = fin;
this.title = this.getTitle();
},
getTitle() {
return `成就完成数:${this.fin_achievements}/${this.total_achievements} 完成率:${(
(this.fin_achievements / this.total_achievements) *
100
).toFixed(2)}%`;
},
},
persist: true,
});
export default useAchievementsStore;