Skip to content

Commit

Permalink
fix: fail to fetch correct user avatar (#5369)
Browse files Browse the repository at this point in the history
#### What type of PR is this?

/area ui
/kind bug
/milestone 2.13.x

#### What this PR does / why we need it:

修复 Console 中用户头像无法正确获取的问题。

#### Which issue(s) this PR fixes:

Fixes #5368 

#### Special notes for your reviewer:

测试方式:

1. 创建若干用户,并为部分用户设置不同的头像。
2. 分别进入不同用户的个人资料页面,观察头像是否符合预期。

#### Does this PR introduce a user-facing change?

```release-note
修复 Console 中用户头像无法正确获取的问题。
```
  • Loading branch information
ruibaby committed Feb 19, 2024
1 parent 8156d9d commit 45d8391
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ui/src/components/user-avatar/UserAvatar.vue
Expand Up @@ -13,7 +13,7 @@ import {
Dialog,
VLoading,
} from "@halo-dev/components";
import { ref, defineAsyncComponent, type Ref } from "vue";
import { ref, defineAsyncComponent, type Ref, toRefs } from "vue";
import { usePermission } from "@/utils/permission";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
Expand All @@ -32,12 +32,14 @@ const props = withDefaults(
}
);
const { isCurrentUser, name } = toRefs(props);
const queryClient = useQueryClient();
const { currentUserHasPermission } = usePermission();
const { t } = useI18n();
const { data: avatar, isFetching } = useQuery({
queryKey: ["user-avatar", props.name, props.isCurrentUser],
queryKey: ["user-avatar", name, isCurrentUser],
queryFn: async () => {
const { data } = props.isCurrentUser
? await apiClient.user.getCurrentUserDetail()
Expand Down

0 comments on commit 45d8391

Please sign in to comment.