Files
TeyvatGuide/src/store/modules/achievements.ts
2023-06-25 16:15:15 +08:00

58 lines
1.3 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 v0.1.3
*/
// vue
import { ref } from "vue";
// pinia
import { defineStore } from "pinia";
export const useAchievementsStore = defineStore(
"achievements",
() => {
// 成就数据
const totalAchievements = ref(950);
const finAchievements = ref(0);
const lastVersion = ref("v3.6");
const UIAFVersion = ref("v1.1");
const title = ref("成就完成数0/950 完成率0%");
function init(): void {
totalAchievements.value = 950;
finAchievements.value = 0;
lastVersion.value = "v3.6";
title.value = getTitle();
}
function getTitle(): string {
return `成就完成数:${finAchievements.value}/${totalAchievements.value} 完成率:${(
(finAchievements.value / totalAchievements.value) *
100
).toFixed(2)}%`;
}
function flushData(total: number, fin: number): void {
totalAchievements.value = total;
finAchievements.value = fin;
title.value = getTitle();
}
return {
totalAchievements,
finAchievements,
lastVersion,
UIAFVersion,
title,
init,
getTitle,
flushData,
};
},
{
persist: true,
},
);