mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
fix: 修复上传头像退出登录的bug
This commit is contained in:
@@ -66,7 +66,7 @@ export function useUserProfile() {
|
||||
width: "auto",
|
||||
},
|
||||
buildUrl(key: string) {
|
||||
return `api/basic/file/download?&key=` + key;
|
||||
return `api/basic/file/download?token=${userStore.getToken}&key=` + key;
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -82,7 +82,7 @@ export function useUserProfile() {
|
||||
onReady: null,
|
||||
uploader: {
|
||||
type: "form",
|
||||
action: "/basic/file/upload",
|
||||
action: "/basic/file/upload?token=" + userStore.getToken,
|
||||
name: "file",
|
||||
headers: {
|
||||
Authorization: "Bearer " + userStore.getToken,
|
||||
@@ -92,7 +92,7 @@ export function useUserProfile() {
|
||||
},
|
||||
},
|
||||
buildUrl(key: string) {
|
||||
return `api/basic/file/download?&key=` + key;
|
||||
return `api/basic/file/download?token=${userStore.getToken}&key=` + key;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -147,6 +147,7 @@ import { isEmpty } from "lodash-es";
|
||||
import { dict } from "@fast-crud/fast-crud";
|
||||
import dayjs from "dayjs";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -351,7 +352,7 @@ const checkPasskeySupport = () => {
|
||||
passkeySupported.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const userStore = useUserStore();
|
||||
const userAvatar = computed(() => {
|
||||
if (isEmpty(userInfo.value.avatar)) {
|
||||
return "";
|
||||
@@ -360,7 +361,7 @@ const userAvatar = computed(() => {
|
||||
return userInfo.value.avatar;
|
||||
}
|
||||
|
||||
return "api/basic/file/download?&key=" + userInfo.value.avatar;
|
||||
return `api/basic/file/download?token=${userStore.getToken}&key=${userInfo.value.avatar}`;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="header-profile flex-wrap bg-white dark:bg-black">
|
||||
<div class="flex flex-1">
|
||||
<div class="avatar">
|
||||
<a-avatar v-if="userInfo.avatar" size="large" :src="'api/basic/file/download?&key=' + userInfo.avatar" style="background-color: #eee"> </a-avatar>
|
||||
<a-avatar v-if="userInfo.avatar" size="large" :src="avatar" style="background-color: #eee"> </a-avatar>
|
||||
<a-avatar v-else size="large" style="background-color: #00b4f5">
|
||||
{{ userInfo.username }}
|
||||
</a-avatar>
|
||||
@@ -228,6 +228,16 @@ const userStore = useUserStore();
|
||||
const userInfo: ComputedRef<UserInfoRes> = computed(() => {
|
||||
return userStore.getUserInfo;
|
||||
});
|
||||
const avatar = computed(() => {
|
||||
const avt = userStore.getUserInfo?.avatar;
|
||||
if (!avt) {
|
||||
return "";
|
||||
}
|
||||
if (avt.startsWith("http")) {
|
||||
return avt;
|
||||
}
|
||||
return `/api/basic/file/download?key=${avt}`;
|
||||
});
|
||||
const now = computed(() => {
|
||||
const serverTime = Date.now() - settingStore.app.deltaTime;
|
||||
return dayjs(serverTime).format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
Reference in New Issue
Block a user