diff --git a/src/apis/auth/type.ts b/src/apis/auth/type.ts index ced4dca..ae4d098 100644 --- a/src/apis/auth/type.ts +++ b/src/apis/auth/type.ts @@ -1,64 +1,64 @@ /** 用户信息响应类型 */ export interface UserInfoResponse { - code: number; - status: number; - success: boolean; - msg: string; + code: number + status: number + success: boolean + msg: string data: { - user: UserDetail; - dept: DeptDetail; - roles: RoleDetail[]; - posts: any[]; - }; + user: UserDetail + dept: DeptDetail + roles: RoleDetail[] + posts: any[] + } } /** 用户详细信息 */ export interface UserDetail { - userId: string; - account: string; - name: string; - status: number; - userCode: string; - userStatus: string; - userType: string; - mobile: string; - createTime: string; - avatar?: string; + userId: string + account: string + name: string + status: number + userCode: string + userStatus: string + userType: string + mobile: string + createTime: string + avatar?: string } /** 部门详细信息 */ export interface DeptDetail { - deptId: string; - deptName: string; - parentId: string; - orderNum: number; - leaderId: string; - status: string; + deptId: string + deptName: string + parentId: string + orderNum: number + leaderId: string + status: string } /** 角色详细信息 */ export interface RoleDetail { - roleId: string; - roleName: string; - roleCode: string | null; - roleKey: string; + roleId: string + roleName: string + roleCode: string | null + roleKey: string } /** 用户类型 - 兼容旧版本 */ export interface UserInfo { - id: string; - username: string; - nickname: string; - gender: 0 | 1 | 2; - email: string; - phone: string; - avatar: string; - pwdResetTime: string; - pwdExpired: boolean; - registrationDate: string; - deptName: string; - roles: string[]; - permissions: string[]; + id: string + username: string + nickname: string + gender: 0 | 1 | 2 + email: string + phone: string + avatar: string + pwdResetTime: string + pwdExpired: boolean + registrationDate: string + deptName: string + roles: string[] + permissions: string[] } /** 路由类型 */ diff --git a/src/views/user/profile/BasicInfo.vue b/src/views/user/profile/BasicInfo.vue index e3d1a90..c88aed1 100644 --- a/src/views/user/profile/BasicInfo.vue +++ b/src/views/user/profile/BasicInfo.vue @@ -17,25 +17,25 @@
- {{ userInfo.nickname }} + {{ userInfo.name }}
- {{ userInfo.id }} + {{ userInfo.userId }}
- + @@ -102,19 +102,22 @@ import { uploadAvatar } from '@/apis/system' import 'vue-cropper/dist/index.css' import { useUserStore } from '@/stores' import getAvatar from '@/utils/avatar' +import XG_DEBUG from 'xgplayer/es/utils/debug' +import config = XG_DEBUG.config const { width } = useWindowSize() const userStore = useUserStore() const userInfo = computed(() => userStore.userInfo) -const avatar = { +const avatar = computed(() => ({ uid: '-2', name: 'avatar.png', - url: userInfo.value.avatar, -} -const avatarList = ref([avatar]) -const fileRef = ref(reactive({ name: 'avatar.png' })) -const options: cropperOptions = reactive({ + url: userInfo.value.avatar || getAvatar(userInfo.value.avatar, undefined), +})) + +const avatarList = computed(() => [avatar.value]) +const fileRef = ref(null) +const options = reactive({ img: '', autoCrop: true, autoCropWidth: 160, @@ -128,13 +131,14 @@ const options: cropperOptions = reactive({ outputType: 'png', }) const visible = ref(false) + // 打开裁剪框 const onBeforeUpload = (file: File): boolean => { fileRef.value = file const reader = new FileReader() reader.readAsDataURL(file) reader.onload = () => { - options.img = reader.result + options.img = reader.result as string } visible.value = true return false