feat(user): 添加用户 ID 属性并进行相关处理
- 在 UserInfosState 接口中添加 id属性 - 在 userInfo store 中添加用户 ID 相关逻辑 - 更新 getUserInfos 和 updateUserInfos 方法以处理用户 ID - 注释掉水平菜单滚动定位代码
This commit is contained in:
@@ -93,7 +93,7 @@ const initElMenuOffsetLeft = () => {
|
||||
nextTick(() => {
|
||||
let els = <HTMLElement>document.querySelector('.el-menu.el-menu--horizontal li.is-active');
|
||||
if (!els) return false;
|
||||
elMenuHorizontalScrollRef.value.$refs.wrapRef.scrollLeft = els.offsetLeft;
|
||||
// elMenuHorizontalScrollRef.value.$refs.wrapRef.scrollLeft = els.offsetLeft;
|
||||
});
|
||||
};
|
||||
// 路由过滤递归函数
|
||||
|
||||
@@ -6,6 +6,7 @@ import {useFrontendMenuStore} from "/@/stores/frontendMenu";
|
||||
|
||||
// 用户信息
|
||||
export interface UserInfosState {
|
||||
id:'',
|
||||
avatar: string;
|
||||
username: string;
|
||||
name: string;
|
||||
|
||||
@@ -12,6 +12,7 @@ import headerImage from '/@/assets/img/headerImage.png';
|
||||
export const useUserInfo = defineStore('userInfo', {
|
||||
state: (): UserInfosStates => ({
|
||||
userInfos: {
|
||||
id:'',
|
||||
avatar: '',
|
||||
username: '',
|
||||
name: '',
|
||||
@@ -37,6 +38,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
this.userInfos.pwd_change_count = count;
|
||||
},
|
||||
async updateUserInfos(userInfos:any) {
|
||||
this.userInfos.id = userInfos.id;
|
||||
this.userInfos.username = userInfos.name;
|
||||
this.userInfos.avatar = userInfos.avatar;
|
||||
this.userInfos.name = userInfos.name;
|
||||
@@ -54,6 +56,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
this.userInfos = Session.get('userInfo');
|
||||
} else {
|
||||
let userInfos: any = await this.getApiUserInfo();
|
||||
this.userInfos.id = userInfos.id;
|
||||
this.userInfos.username = userInfos.data.name;
|
||||
this.userInfos.avatar = userInfos.data.avatar;
|
||||
this.userInfos.name = userInfos.data.name;
|
||||
@@ -74,6 +77,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
url: '/api/system/user/user_info/',
|
||||
method: 'get',
|
||||
}).then((res:any)=>{
|
||||
this.userInfos.id = res.data.id;
|
||||
this.userInfos.username = res.data.name;
|
||||
this.userInfos.avatar = (res.data.avatar && getBaseURL(res.data.avatar)) || headerImage;
|
||||
this.userInfos.name = res.data.name;
|
||||
|
||||
Reference in New Issue
Block a user