feat: 用户数据保存userId信息做判断
This commit is contained in:
@@ -9,6 +9,8 @@ import { parseUrlPath } from '@/plugins/file-static-url';
|
|||||||
|
|
||||||
/**用户信息类型 */
|
/**用户信息类型 */
|
||||||
type UserInfo = {
|
type UserInfo = {
|
||||||
|
/**用户ID */
|
||||||
|
userId: string;
|
||||||
/**登录账号 */
|
/**登录账号 */
|
||||||
userName: string;
|
userName: string;
|
||||||
/**用户角色 字符串数组 */
|
/**用户角色 字符串数组 */
|
||||||
@@ -31,6 +33,7 @@ type UserInfo = {
|
|||||||
|
|
||||||
const useUserStore = defineStore('user', {
|
const useUserStore = defineStore('user', {
|
||||||
state: (): UserInfo => ({
|
state: (): UserInfo => ({
|
||||||
|
userId: '',
|
||||||
userName: '',
|
userName: '',
|
||||||
roles: [],
|
roles: [],
|
||||||
permissions: [],
|
permissions: [],
|
||||||
@@ -109,6 +112,7 @@ const useUserStore = defineStore('user', {
|
|||||||
const res = await getInfo();
|
const res = await getInfo();
|
||||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||||
const { user, roles, permissions } = res.data;
|
const { user, roles, permissions } = res.data;
|
||||||
|
this.userId = user.userId;
|
||||||
// 登录账号
|
// 登录账号
|
||||||
this.userName = user.userName;
|
this.userName = user.userName;
|
||||||
// 用户头像
|
// 用户头像
|
||||||
|
|||||||
Reference in New Issue
Block a user