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