fix(profile): 修复个人中心接口报错
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
import type { FileCallBack, UpdatePasswordParam, UserProfile } from './model';
|
||||
import type { FileCallBack, UpdatePasswordParam } from './model';
|
||||
import type { UserInfoResp } from '#/api/core/user';
|
||||
|
||||
import { buildUUID } from '@vben/utils';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
import { getUserInfoApi } from '#/api/core/user';
|
||||
|
||||
enum Api {
|
||||
root = '/user/profile',
|
||||
updateAvatar = '/user/profile/avatar',
|
||||
updatePassword = '/user/profile/updatePwd',
|
||||
updatePassword = '/account/password',
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户个人主页信息
|
||||
* @returns userInformation
|
||||
*/
|
||||
export function userProfile() {
|
||||
return requestClient.get<UserProfile>(Api.root);
|
||||
export async function userProfile() {
|
||||
const resp = await getUserInfoApi() as UserInfoResp;
|
||||
if (!resp) {
|
||||
throw new Error('获取用户信息失败');
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import type { UserProfile } from '#/api/system/profile/model';
|
||||
|
||||
import type { UserInfoResp } from '#/api/core/user';
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
import { DictEnum } from '@vben/constants';
|
||||
@@ -17,7 +15,7 @@ import { getDictOptions } from '#/utils/dict';
|
||||
|
||||
import { emitter } from '../mitt';
|
||||
|
||||
const props = defineProps<{ profile: UserProfile }>();
|
||||
const props = defineProps<{ profile: UserInfoResp }>();
|
||||
|
||||
const userStore = useUserStore();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type { UserProfile } from '#/api/system/profile/model';
|
||||
import type { UserInfoResp } from '#/api/core/user';
|
||||
|
||||
import { onMounted, onUnmounted, ref } from 'vue';
|
||||
|
||||
@@ -13,10 +13,14 @@ import { emitter } from './mitt';
|
||||
import ProfilePanel from './profile-panel.vue';
|
||||
import SettingPanel from './setting-panel.vue';
|
||||
|
||||
const profile = ref<UserProfile>();
|
||||
const profile = ref<UserInfoResp>();
|
||||
async function loadProfile() {
|
||||
try {
|
||||
const resp = await userProfile();
|
||||
profile.value = resp;
|
||||
} catch (error) {
|
||||
console.error('加载用户信息失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadProfile);
|
||||
|
||||
Reference in New Issue
Block a user