From c1eaae64aa6e799d746c8acd994fbf40091bfcc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=B1=BC=E5=BC=80=E5=8F=91?= Date: Sun, 10 May 2026 20:49:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor(profile):=20=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=8E=92=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 合并用户信息卡片和积分资产区,移除独立的账户信息区块 - 退出登录移至页面底部,避免与侧边栏重复 - 接入真实用户数据到侧边栏头像和昵称 - 新增系统默认头像 SVG,替代首字母占位 - 清理不再使用的 CSS 样式 --- tauri-app/public/default-avatar.svg | 11 + tauri-app/src/components/Layout/Sidebar.css | 41 ---- tauri-app/src/components/Layout/Sidebar.tsx | 28 +-- .../ContentManagement/ContentManagement.css | 66 ------ tauri-app/src/pages/Profile/Profile.tsx | 214 ++++++++++-------- 5 files changed, 135 insertions(+), 225 deletions(-) create mode 100644 tauri-app/public/default-avatar.svg diff --git a/tauri-app/public/default-avatar.svg b/tauri-app/public/default-avatar.svg new file mode 100644 index 0000000..aa9052e --- /dev/null +++ b/tauri-app/public/default-avatar.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tauri-app/src/components/Layout/Sidebar.css b/tauri-app/src/components/Layout/Sidebar.css index a62dc12..bc3aa32 100644 --- a/tauri-app/src/components/Layout/Sidebar.css +++ b/tauri-app/src/components/Layout/Sidebar.css @@ -181,12 +181,6 @@ background: var(--bg-hover); } -.sidebar-divider { - height: 1px; - background: var(--border-light); - margin: var(--spacing-xs) 0; -} - .user-avatar { width: 36px; height: 36px; @@ -216,39 +210,4 @@ text-overflow: ellipsis; } -.user-role { - font-size: var(--font-xs); - color: var(--text-tertiary); -} -.sidebar-logout { - display: flex; - align-items: center; - justify-content: center; - gap: var(--spacing-sm); - padding: var(--spacing-xs) var(--spacing-sm); - border-radius: var(--radius-md); - color: var(--text-tertiary); - background: transparent; - border: none; - cursor: pointer; - font-size: var(--font-xs); - font-family: var(--font-family); - width: 100%; - text-align: center; - transition: all var(--transition-fast); -} - -.sidebar-logout:hover { - background: var(--bg-hover); - color: var(--text-secondary); -} - -.sidebar-logout svg { - flex-shrink: 0; - opacity: 0.7; -} - -.sidebar-logout:hover svg { - opacity: 1; -} diff --git a/tauri-app/src/components/Layout/Sidebar.tsx b/tauri-app/src/components/Layout/Sidebar.tsx index fac025f..0ae1a82 100644 --- a/tauri-app/src/components/Layout/Sidebar.tsx +++ b/tauri-app/src/components/Layout/Sidebar.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { createNewProject } from '../../store'; +import { createNewProject, useAuthStore } from '../../store'; import { useNavigation } from '../../contexts/NavigationContext'; import './Sidebar.css'; @@ -45,6 +45,7 @@ interface SidebarProps { export default function Sidebar({ currentPath, onNavigate }: SidebarProps) { const { appEnvironment } = useNavigation(); + const authUser = useAuthStore((s) => s.user); const [expandedItems, setExpandedItems] = useState>( new Set(['content-management', 'settings']) ); @@ -198,26 +199,17 @@ export default function Sidebar({ currentPath, onNavigate }: SidebarProps) { )}
-
onNavigate('profile')}> -
U
+
onNavigate('profile')} title="个人中心"> + avatar
- 用户 - 免费版 + {authUser?.nickname || '用户'}
-
-
); diff --git a/tauri-app/src/pages/ContentManagement/ContentManagement.css b/tauri-app/src/pages/ContentManagement/ContentManagement.css index cfc27d0..8a4fab8 100644 --- a/tauri-app/src/pages/ContentManagement/ContentManagement.css +++ b/tauri-app/src/pages/ContentManagement/ContentManagement.css @@ -371,17 +371,6 @@ ============================================================ */ /* 顶部用户信息栏 */ -.profile-topbar { - display: flex; - align-items: center; - gap: var(--spacing-lg); - padding: var(--spacing-xl) var(--spacing-2xl); - background: var(--bg-card); - border-radius: var(--radius-xl); - border: 1px solid var(--border-light); - margin-bottom: var(--spacing-xl); -} - .profile-topbar-avatar { width: 64px; height: 64px; @@ -397,24 +386,6 @@ object-fit: cover; } -.profile-topbar-info { - display: flex; - flex-direction: column; - gap: 4px; - flex: 1; -} - -.profile-topbar-name { - font-size: var(--font-xl); - font-weight: 600; - color: var(--text-primary); -} - -.profile-topbar-meta { - font-size: var(--font-sm); - color: var(--text-secondary); -} - .profile-topbar-logout { padding: 8px 20px; border-radius: var(--radius-lg); @@ -432,43 +403,6 @@ border-color: var(--text-secondary); } -/* 积分统计行 */ -.profile-stats-row { - display: flex; - gap: var(--spacing-lg); - align-items: stretch; -} - -.profile-stat-box { - flex: 1; - background: var(--bg-card); - border: 1px solid var(--border-light); - border-radius: var(--radius-xl); - padding: var(--spacing-xl); - display: flex; - flex-direction: column; - justify-content: center; -} - -.profile-stat-value { - font-size: 32px; - font-weight: 700; - line-height: 1.2; - color: var(--text-primary); -} - -.profile-stat-label { - font-size: var(--font-sm); - color: var(--text-secondary); - margin-top: 4px; -} - -.profile-stat-action { - display: flex; - align-items: center; - padding: 0 var(--spacing-xl); -} - /* Avatar Clone Card - 这个就是我们要复用的样式 */ .avatar-card { position: relative; diff --git a/tauri-app/src/pages/Profile/Profile.tsx b/tauri-app/src/pages/Profile/Profile.tsx index 0650995..7f163d2 100644 --- a/tauri-app/src/pages/Profile/Profile.tsx +++ b/tauri-app/src/pages/Profile/Profile.tsx @@ -13,11 +13,6 @@ interface UserProfile { avatar: string; } -function getInitials(nickname: string | null): string { - if (!nickname) return 'U'; - return nickname.charAt(0).toUpperCase(); -} - function formatTxTime(iso: string): string { const d = new Date(iso); return d.toLocaleString('zh-CN', { @@ -123,36 +118,95 @@ export default function Profile() { return (
- {/* 顶部用户信息栏 */} -
- {displayAvatar ? ( - avatar - ) : ( -
{getInitials(displayName)}
- )} -
-
{displayName}
-
-
- - {/* 积分统计 */} -
-
-
- {balance?.balance ?? 0} + {/* 个人资料卡片 */} +
+ {/* 用户区 */} +
+ avatar +
+ {editing ? ( +
+ setNickname(e.target.value)} + maxLength={20} + autoFocus + style={{ + padding: '6px 12px', + borderRadius: '8px', + border: '1px solid var(--border-color)', + fontSize: '15px', + outline: 'none', + width: '160px', + }} + onKeyDown={(e) => { if (e.key === 'Enter') handleSaveNickname(); }} + /> + + +
+ ) : ( +
+ + {displayName} + + +
+ )} + {nickError && ( +
+ {nickError} +
+ )} + {displayMobile && ( +
+ {displayMobile} +
+ )}
-
当前积分
-
-
{balance?.totalRecharged ?? 0}
-
累计充值
-
-
-
{balance?.totalConsumed ?? 0}
-
累计消费
-
-
-
@@ -223,74 +277,34 @@ export default function Profile() {
- {/* 账户信息 */} + {/* 退出登录 — 页面底部 */}
-

- 账户信息 -

-
-
- 昵称 - - {editing ? ( - <> - setNickname(e.target.value)} - maxLength={20} - autoFocus - style={{ - padding: '4px 10px', - borderRadius: '6px', - border: '1px solid var(--border-color)', - fontSize: 'var(--font-sm)', - outline: 'none', - width: '160px', - }} - onKeyDown={(e) => { if (e.key === 'Enter') handleSaveNickname(); }} - /> - - - - ) : ( - <> - {displayName} - - - )} - -
- {nickError && ( -
- {nickError} -
- )} - - {displayMobile && ( -
- 绑定手机 - {displayMobile} -
- )} - -
- - -
-
+