add dark mode

This commit is contained in:
landaiqing
2024-08-08 16:39:27 +08:00
parent a4b502717c
commit 562071cdc5
26 changed files with 479 additions and 112 deletions

View File

@@ -0,0 +1,44 @@
import {defineStore} from 'pinia';
import {ref} from 'vue';
import {User} from "@/types/user";
import {parse, stringify} from "zipson/lib";
import {handleLocalforage} from "@/utils/localforage";
export const useAuthStore = defineStore(
'user',
() => {
const user = ref<User>();
function setUser(data: User) {
user.value = data;
}
function getUser() {
return user.value;
}
function clearUser() {
user.value = void 0;
}
return {
user,
setUser,
getUser,
clearUser
};
},
{
// 开启数据持久化
persist: {
key: 'user',
paths: ['user'],
storage: handleLocalforage,
serializer: {
deserialize: parse,
serialize: stringify,
},
}
}
);