yak_handcuffs/src/store/common.ts

25 lines
465 B
TypeScript
Raw Normal View History

2025-04-01 18:07:18 +08:00
import { defineStore } from 'pinia';
2025-04-03 18:21:17 +08:00
import { TLogin } from "@/api/index.d";
2025-04-01 18:07:18 +08:00
export const useCommonStore = defineStore('common', {
state: () => {
return {
2025-04-03 18:21:17 +08:00
time: new Date(),
user: <TLogin.IRes>{}
2025-04-01 18:07:18 +08:00
};
},
getters: {},
actions: {
setTime() {
this.time = new Date();
2025-04-03 18:21:17 +08:00
},
setUser(data: TLogin.IRes) {
this.user = data
},
clearStore() {
this.$reset();
2025-04-01 18:07:18 +08:00
}
2025-04-03 18:21:17 +08:00
},
persist: true
2025-04-01 18:07:18 +08:00
});