12345678910111213141516171819202122232425262728 |
- import { defineStore } from 'pinia'
- export const useUserStore = defineStore('user',() => {
- const token = ref('')
- const userInfo = reactive({
- userId: 0,
- userName: '',
- roleId: 0,
- roleName: ''
- })
- const expiresAt = ref(0)
- const updateInfo = (data) => {
- token.value = data.token
- expiresAt.value = data.expiresAt
- Object.assign(userInfo, {
- userId: data.user.ID,
- userName: data.user.nickName,
- roleId: data.user.authority.authorityId,
- roleName: data.user.authority.authorityName
- })
- }
- return {
- token,
- userInfo,
- expiresAt,
- updateInfo
- }
- })
|