1+ <script lang="ts" setup>
2+ import { api , User } from ' @/api' ;
3+ import { ref , watch } from ' vue' ;
4+ import { useRoute , useRouter } from ' vue-router' ;
5+ import Icon from ' @/components/common/Icon.vue' ;
6+
7+ const user = ref <User >();
8+ const route = useRoute ();
9+ const router = useRouter ();
10+ const error = ref <string >(' 正在加载中...' );
11+
12+ watch (
13+ () => route .params .username ,
14+ () => {
15+ load ();
16+ },
17+ { immediate: true }
18+ );
19+
20+ function load() {
21+ user .value = undefined ;
22+ error .value = ' 正在加载中...' ;
23+ api .getUser (route .params .username as string ).then (u => {
24+ user .value = u ;
25+ }).catch (() => {
26+ error .value = ' 用户不存在' ;
27+ });
28+ }
29+
30+ load ();
31+ </script >
32+
33+ <template >
34+ <main
35+ v-if =" !user"
36+ class =" flex-1 overflow-auto bg-base-100 w-full flex items-center justify-center"
37+ >
38+ <span class =" text-lg text-base-content/70" >{{ error }}</span >
39+ </main >
40+ <section v-else class =" h-full flex flex-col w-full bg-base-200" >
41+ <header
42+ class =" flex justify-between items-center px-4 py-2 bg-base-100 shadow-sm z-10"
43+ >
44+ <button class =" btn btn-ghost btn-sm gap-2" @click =" router.push('/')" >
45+ <Icon icon =" mdi:arrow-left" />
46+ 返回
47+ </button >
48+ <h1 class =" text-lg font-bold" >用户资料</h1 >
49+ <div class =" w-16" ></div > <!-- Spacer for centering -->
50+ </header >
51+
52+ <main class =" flex-1 overflow-auto p-4 space-y-6 max-w-4xl mx-auto w-full" >
53+ <!-- User Info Card -->
54+ <div class =" card bg-base-100 shadow-xl" >
55+ <div class =" card-body flex-row items-center gap-6" >
56+ <div class =" avatar placeholder" >
57+ <div class =" bg-neutral text-neutral-content rounded-full w-24" >
58+ <img v-if =" user.avatar" :src =" user.avatar" :alt =" user.nickname" />
59+ <span v-else class =" text-3xl" >{{ user.nickname.charAt(0).toUpperCase() }}</span >
60+ </div >
61+ </div >
62+ <div class =" flex flex-col gap-1" >
63+ <h2 class =" card-title text-2xl flex items-center gap-2" >
64+ {{ user.nickname }}
65+ <div v-if =" user.isAdmin" class =" badge badge-primary badge-sm" >管理员</div >
66+ </h2 >
67+ <p class =" text-base-content/70" >@{{ user.username }}</p >
68+ <div class =" flex items-center gap-2 text-sm text-base-content/60 mt-1" >
69+ <img src =" /fishpi.svg" class =" w-[1.5em] group-hover:scale-110 transition-transform" />
70+ <a :href =" `https://fishpi.cn/member/${user.username}`" target =" _blank" rel =" noopener noreferrer" >
71+ 访问摸鱼派主页
72+ </a >
73+ </div >
74+ </div >
75+ </div >
76+ </div >
77+
78+ <!-- Stats Section (Placeholder) -->
79+ <div class =" grid grid-cols-1 md:grid-cols-2 gap-4" >
80+ <div class =" card bg-base-100 shadow-xl" >
81+ <div class =" card-body" >
82+ <h3 class =" card-title text-lg mb-2" >
83+ <Icon icon =" mdi:chart-box" class =" text-primary" />
84+ 胜负统计
85+ </h3 >
86+ <div class =" flex items-center justify-center h-32 bg-base-200 rounded-lg border-2 border-dashed border-base-300" >
87+ <span class =" text-base-content/50" >暂无数据 (开发中)</span >
88+ </div >
89+ </div >
90+ </div >
91+
92+ <div class =" card bg-base-100 shadow-xl" >
93+ <div class =" card-body" >
94+ <h3 class =" card-title text-lg mb-2" >
95+ <Icon icon =" mdi:trophy" class =" text-warning" />
96+ 成就
97+ </h3 >
98+ <div class =" flex items-center justify-center h-32 bg-base-200 rounded-lg border-2 border-dashed border-base-300" >
99+ <span class =" text-base-content/50" >暂无数据 (开发中)</span >
100+ </div >
101+ </div >
102+ </div >
103+ </div >
104+
105+ <!-- Game History Section (Placeholder) -->
106+ <div class =" card bg-base-100 shadow-xl" >
107+ <div class =" card-body" >
108+ <h3 class =" card-title text-lg mb-4" >
109+ <Icon icon =" mdi:history" class =" text-secondary" />
110+ 游玩记录
111+ </h3 >
112+
113+ <div class =" flex flex-col items-center justify-center py-12 bg-base-200 rounded-lg border-2 border-dashed border-base-300" >
114+ <Icon icon =" mdi:gamepad-variant-outline" class =" text-4xl text-base-content/30 mb-2" />
115+ <span class =" text-base-content/50" >暂无游玩记录</span >
116+ </div >
117+ </div >
118+ </div >
119+ </main >
120+ </section >
121+ </template >
0 commit comments