first commit

This commit is contained in:
chenzhen
2025-07-22 11:21:01 +08:00
commit 09d0e316e1
164 changed files with 7907 additions and 0 deletions

40
src/stores/user.js Normal file
View File

@@ -0,0 +1,40 @@
import { defineStore } from 'pinia'
import { getToken, setToken,clearToken } from '../utils/auth'
import { getUserInfo } from '../api/auth'
export const useUserStore = new defineStore({
id: 'userStore',
state: () => {
return {
userInfo: {},
token: getToken() || null,
temToken: null
}
},
getters: {
isLogin: (state) => state.token && state.userInfo
},
actions: {
// 获取用户信息
async getUser() {
console.log("store=>getUser")
const data = await getUserInfo()
console.log(data,'xxx ')
this.userInfo = data
},
// 登录
login(userinfo) {
this.token = userinfo.token
setToken(userinfo.token)
this.userInfo = userinfo
},
// 退出
logout() {
this.token = ''
this.userInfo = {}
clearToken();
}
}
})