diff --git a/frontend/src/components/game/GameComments.vue b/frontend/src/components/game/GameComments.vue index 4a40cc0..eda406b 100644 --- a/frontend/src/components/game/GameComments.vue +++ b/frontend/src/components/game/GameComments.vue @@ -71,7 +71,7 @@ function formatDate(dateStr: string) {
- {{ c.expand?.author?.username || '用户' }} + {{ c.expand?.author?.name || c.expand?.author?.username || '用户' }} diff --git a/frontend/src/components/group/GroupMembersPanel.vue b/frontend/src/components/group/GroupMembersPanel.vue index a67c46d..99cfd2c 100644 --- a/frontend/src/components/group/GroupMembersPanel.vue +++ b/frontend/src/components/group/GroupMembersPanel.vue @@ -130,13 +130,13 @@ async function onJoinRequestResponded(requestId: string) {
- {{ member.username }} + {{ member.name || member.username }} 群主
diff --git a/frontend/src/components/group/JoinRequestCard.vue b/frontend/src/components/group/JoinRequestCard.vue index bcc6fd6..bd083e2 100644 --- a/frontend/src/components/group/JoinRequestCard.vue +++ b/frontend/src/components/group/JoinRequestCard.vue @@ -46,11 +46,11 @@ async function handleReject() {
- {{ (props as any).expand?.user?.username || '用户' }} + {{ (props as any).expand?.user?.name || (props as any).expand?.user?.username || '用户' }} 申请加入「{{ (props as any).expand?.group?.name || '群组' }}」
diff --git a/frontend/src/components/team/IdleMembersList.vue b/frontend/src/components/team/IdleMembersList.vue index 7b7980f..3eda464 100644 --- a/frontend/src/components/team/IdleMembersList.vue +++ b/frontend/src/components/team/IdleMembersList.vue @@ -62,17 +62,17 @@ async function inviteMember(userId: string, username: string) { >
- {{ member.username }} + {{ member.name || member.username }} {{ member.statusNote }}
diff --git a/frontend/src/components/team/InvitationCard.vue b/frontend/src/components/team/InvitationCard.vue index e3346ca..cc52f2e 100644 --- a/frontend/src/components/team/InvitationCard.vue +++ b/frontend/src/components/team/InvitationCard.vue @@ -50,11 +50,11 @@ async function rejectInvitation() {
- {{ invitation.expand?.from?.username }} + {{ invitation.expand?.from?.name || invitation.expand?.from?.username }} 邀请你加入
diff --git a/frontend/src/components/team/InviteButton.vue b/frontend/src/components/team/InviteButton.vue index 981fd6e..4afe258 100644 --- a/frontend/src/components/team/InviteButton.vue +++ b/frontend/src/components/team/InviteButton.vue @@ -32,7 +32,7 @@ async function handleGameSelect(gameName: string) { try { const session = await createTeamSession({ sourceGroup: groupStore.currentGroupId, - name: `${userStore.user?.username || ''}的车队`, + name: `${userStore.user?.name || userStore.user?.username || ''}的车队`, gameName, members: [userStore.userId] }) diff --git a/frontend/src/components/team/TeamSessionPanel.vue b/frontend/src/components/team/TeamSessionPanel.vue index fd04cb1..d338f0c 100644 --- a/frontend/src/components/team/TeamSessionPanel.vue +++ b/frontend/src/components/team/TeamSessionPanel.vue @@ -100,10 +100,10 @@ async function handleGameSelected(gameName: string) { > - {{ member.username }} + {{ member.name || member.username }}
diff --git a/frontend/src/stores/user.ts b/frontend/src/stores/user.ts index 18518ee..c027a5e 100644 --- a/frontend/src/stores/user.ts +++ b/frontend/src/stores/user.ts @@ -53,7 +53,7 @@ export const useUserStore = defineStore('user', () => { } // 注册 - async function register(data: { email: string; password: string; passwordConfirm: string; username: string }) { + async function register(data: { email: string; password: string; passwordConfirm: string; username: string; name?: string }) { try { loading.value = true await pb.collection('users').create(data) diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 97bc0ab..757f9e4 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -45,6 +45,7 @@ export type GamePlatform = 'PC' | 'PS5' | 'Xbox' | 'Switch' | 'Mobile' export interface User { id: string username: string + name?: string email: string avatar?: string status: UserStatus @@ -171,6 +172,11 @@ export interface JoinRequest { } } +// 获取用户显示名称(优先 name,回退 username) +export function displayName(user?: { name?: string; username: string } | null): string { + return user?.name || user?.username || '未知' +} + // 多媒体记忆类型 (二期规划) export type MemoryFileType = 'image' | 'video' | 'audio' | 'other' diff --git a/frontend/src/views/GroupView.vue b/frontend/src/views/GroupView.vue index 9f3907f..4524738 100644 --- a/frontend/src/views/GroupView.vue +++ b/frontend/src/views/GroupView.vue @@ -23,7 +23,7 @@ const members = computed(() => groupStore.currentMembers) const ownerName = computed(() => { const owner = members.value.find(m => m.id === group.value?.owner) - return owner?.username || '未知' + return owner?.name || owner?.username || '未知' }) const membersByStatus = computed(() => { @@ -155,8 +155,8 @@ async function refreshMembers() {
暂无
- - {{ m.username }} + + {{ m.name || m.username }} {{ m.statusNote }}
diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index d836b52..2c19c83 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -70,7 +70,7 @@ function openGameDetail(game: Game) {

- 欢迎回来, {{ userStore.user?.username || '玩家' }} + 欢迎回来, {{ userStore.user?.name || userStore.user?.username || '玩家' }}

diff --git a/frontend/src/views/Layout.vue b/frontend/src/views/Layout.vue index ab244ce..9980448 100644 --- a/frontend/src/views/Layout.vue +++ b/frontend/src/views/Layout.vue @@ -11,6 +11,7 @@ import NotificationPanel from '@/components/common/NotificationPanel.vue' import CreateGroupDialog from '@/components/group/CreateGroupDialog.vue' import JoinGroupDialog from '@/components/group/JoinGroupDialog.vue' import { Monitor, HomeFilled, Grid, Plus, Search, Bell, AlarmClock, SwitchButton, Document } from '@element-plus/icons-vue' +import { displayName } from '@/types' const router = useRouter() const route = useRoute() @@ -151,7 +152,7 @@ const pageTitle = computed(() => { class="user-avatar" alt="" /> - {{ userStore.user?.username }} + {{ displayName(userStore.user) }} diff --git a/frontend/src/views/Register.vue b/frontend/src/views/Register.vue index 79c3e0b..2980f8a 100644 --- a/frontend/src/views/Register.vue +++ b/frontend/src/views/Register.vue @@ -1,49 +1,74 @@