feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面
This commit is contained in:
@@ -27,15 +27,17 @@ import {
|
||||
} from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
KeyRound,
|
||||
LayoutGrid,
|
||||
ScrollText,
|
||||
Wallet,
|
||||
UserRound,
|
||||
Activity,
|
||||
BarChart2,
|
||||
CreditCard,
|
||||
FileText,
|
||||
Gift,
|
||||
Receipt,
|
||||
Settings,
|
||||
} from 'lucide-react';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { useMarquee } from '../../hooks/common/useMarquee';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
import UserCenterSidebar from './UserCenterSidebar';
|
||||
import UserDashboard from './UserDashboard';
|
||||
@@ -47,6 +49,7 @@ import TopUp from '../TopUp';
|
||||
import PersonalSetting from '../../components/settings/PersonalSetting';
|
||||
import ServiceDashboard from '../ServiceDashboard';
|
||||
import WeyAiDownload from '../WeyAiDownload';
|
||||
import KeyManagement from '../KeyManagement';
|
||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||
|
||||
// 移动端底部导航组件
|
||||
@@ -58,16 +61,22 @@ const MobileBottomNav = ({ sidebarConfig }) => {
|
||||
const navItems = [
|
||||
{
|
||||
key: 'dashboard',
|
||||
icon: BarChart2,
|
||||
icon: LayoutGrid,
|
||||
label: t('概览'),
|
||||
path: '/user-center/dashboard',
|
||||
},
|
||||
{
|
||||
key: 'usageRecord',
|
||||
icon: FileText,
|
||||
icon: ScrollText,
|
||||
label: t('记录'),
|
||||
path: '/user-center/usage-record',
|
||||
},
|
||||
{
|
||||
key: 'keyManagement',
|
||||
icon: KeyRound,
|
||||
label: t('密钥管理'),
|
||||
path: '/user-center/key-management',
|
||||
},
|
||||
{
|
||||
key: 'serviceDashboard',
|
||||
icon: Activity,
|
||||
@@ -82,7 +91,7 @@ const MobileBottomNav = ({ sidebarConfig }) => {
|
||||
},
|
||||
{
|
||||
key: 'topup',
|
||||
icon: CreditCard,
|
||||
icon: Wallet,
|
||||
label: t('充值'),
|
||||
path: '/user-center/topup',
|
||||
},
|
||||
@@ -94,7 +103,7 @@ const MobileBottomNav = ({ sidebarConfig }) => {
|
||||
},
|
||||
{
|
||||
key: 'settings',
|
||||
icon: Settings,
|
||||
icon: UserRound,
|
||||
label: t('设置'),
|
||||
path: '/user-center/settings',
|
||||
},
|
||||
@@ -110,7 +119,7 @@ const MobileBottomNav = ({ sidebarConfig }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl border-t border-gray-200/80 dark:border-neutral-800/80 safe-area-inset-bottom'>
|
||||
<nav className='uc-mobile-nav md:hidden fixed bottom-0 left-0 right-0 z-50 safe-area-inset-bottom'>
|
||||
<div className='flex items-center justify-around h-14'>
|
||||
{visibleNavItems.map((item) => {
|
||||
const isActive =
|
||||
@@ -121,43 +130,29 @@ const MobileBottomNav = ({ sidebarConfig }) => {
|
||||
return (
|
||||
<button
|
||||
key={item.key}
|
||||
type='button'
|
||||
data-active={isActive}
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
onClick={() => navigate(item.path)}
|
||||
className={`flex flex-col items-center justify-center flex-1 h-full transition-all ${
|
||||
isActive ? 'scale-105' : 'opacity-60'
|
||||
}`}
|
||||
className='uc-mobile-nav-item flex flex-col items-center justify-center flex-1 h-full'
|
||||
>
|
||||
<div
|
||||
className={`p-1.5 rounded-lg ${isActive ? 'bg-gradient-to-br from-blue-500 to-brand-to' : ''}`}
|
||||
>
|
||||
<IconComponent
|
||||
size={20}
|
||||
className={
|
||||
isActive ? 'text-white' : 'text-gray-500 dark:text-gray-400'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<span
|
||||
className={`text-[10px] mt-0.5 font-medium ${
|
||||
isActive
|
||||
? 'text-gray-900 dark:text-white'
|
||||
: 'text-gray-500 dark:text-gray-400'
|
||||
}`}
|
||||
>
|
||||
{item.label}
|
||||
</span>
|
||||
<IconComponent size={20} />
|
||||
<span>{item.label}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
|
||||
const UserCenter = () => {
|
||||
const UserCenter = ({ keyManagementMode = false }) => {
|
||||
const [statusState] = useContext(StatusContext);
|
||||
// 仅用于页面外壳的样式标识(看板与子页面底色不同),不参与路由判断
|
||||
const ucRoute = useLocation().pathname.split('/')[2] || 'dashboard';
|
||||
|
||||
// 跑马灯公告是否存在(用于动态计算顶部间距)
|
||||
const hasMarquee = !!statusState?.status?.marquee_content?.trim();
|
||||
const { visible: hasMarquee } = useMarquee();
|
||||
const userCenterConfig = useMemo(
|
||||
() =>
|
||||
normalizeSidebarModulesAdmin(statusState?.status?.SidebarModulesAdmin)
|
||||
@@ -198,13 +193,14 @@ const UserCenter = () => {
|
||||
return element;
|
||||
};
|
||||
|
||||
if (!firstVisiblePath) {
|
||||
if (!firstVisiblePath && !keyManagementMode) {
|
||||
return <Navigate to='/' replace />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex flex-col md:flex-row h-screen overflow-hidden bg-[var(--surface-bg-base)] transition-colors duration-300 ${hasMarquee ? 'pt-[96px] sm:pt-[104px]' : 'pt-14 sm:pt-16'}`}
|
||||
data-uc-route={ucRoute}
|
||||
className={`user-center flex flex-col md:flex-row h-screen overflow-hidden bg-[var(--surface-bg-base)] ${hasMarquee ? 'pt-[91px] md:pt-[107px]' : 'pt-14 md:pt-[72px]'}`}
|
||||
>
|
||||
{/* Sidebar - 仅桌面端 */}
|
||||
<div className='hidden md:block flex-shrink-0 h-full'>
|
||||
@@ -218,68 +214,75 @@ const UserCenter = () => {
|
||||
|
||||
{/* 内容区域 */}
|
||||
<div className='relative z-10 h-full overflow-y-auto uc-page-scrollbar'>
|
||||
<Routes>
|
||||
<Route
|
||||
path='/'
|
||||
element={<Navigate to={firstVisibleRoute} replace />}
|
||||
/>
|
||||
<Route
|
||||
path='dashboard'
|
||||
element={guardUserCenterRoute('dashboard', <UserDashboard />)}
|
||||
/>
|
||||
<Route
|
||||
path='usage-record'
|
||||
element={guardUserCenterRoute('usageRecord', <UsageRecord />)}
|
||||
/>
|
||||
{/* ServiceDashboard 组件内部有 min-h-screen pt-[88px],嵌入 UserCenter 后用 -mt-[64px] 部分抵消 pt,保留 24px 顶部间距(与其他页面 p-6 一致),[&>div]:min-h-0 避免撑高 */}
|
||||
<Route
|
||||
path='service-dashboard'
|
||||
element={guardUserCenterRoute(
|
||||
'serviceDashboard',
|
||||
<div className='-mt-[64px] [&>div]:min-h-0'>
|
||||
<ServiceDashboard />
|
||||
</div>,
|
||||
)}
|
||||
/>
|
||||
{/* TopUp 组件内部有 pt-[64px] 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消。
|
||||
* embedded:UserCenter shell 已提供 PageBackground,子页面不再渲染自身背景,避免双层叠加 */}
|
||||
<Route
|
||||
path='topup'
|
||||
element={guardUserCenterRoute(
|
||||
'topup',
|
||||
<div className='-mt-[64px]'>
|
||||
<TopUp embedded />
|
||||
</div>,
|
||||
)}
|
||||
/>
|
||||
{/* PersonalSetting 内部有 pt-16 sm:pt-20 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消 */}
|
||||
{/* 邀请返利 / 发票抬头:侧栏项、routePathMap、权限守卫此前都已配好,
|
||||
{keyManagementMode ? (
|
||||
<KeyManagement embedded />
|
||||
) : (
|
||||
<Routes>
|
||||
<Route
|
||||
path='/'
|
||||
element={<Navigate to={firstVisibleRoute} replace />}
|
||||
/>
|
||||
<Route
|
||||
path='dashboard'
|
||||
element={guardUserCenterRoute('dashboard', <UserDashboard />)}
|
||||
/>
|
||||
<Route
|
||||
path='usage-record'
|
||||
element={guardUserCenterRoute('usageRecord', <UsageRecord />)}
|
||||
/>
|
||||
{/* ServiceDashboard 组件内部有 min-h-screen pt-[88px],嵌入 UserCenter 后用 -mt-[64px] 部分抵消 pt,保留 24px 顶部间距(与其他页面 p-6 一致),[&>div]:min-h-0 避免撑高 */}
|
||||
<Route
|
||||
path='service-dashboard'
|
||||
element={guardUserCenterRoute(
|
||||
'serviceDashboard',
|
||||
<div className='-mt-[64px] [&>div]:min-h-0'>
|
||||
<ServiceDashboard />
|
||||
</div>,
|
||||
)}
|
||||
/>
|
||||
{/* TopUp 组件内部有 pt-[64px] 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消。
|
||||
* embedded:UserCenter shell 已提供 PageBackground,子页面不再渲染自身背景,避免双层叠加 */}
|
||||
<Route
|
||||
path='topup'
|
||||
element={guardUserCenterRoute(
|
||||
'topup',
|
||||
<div className='-mt-[64px]'>
|
||||
<TopUp embedded />
|
||||
</div>,
|
||||
)}
|
||||
/>
|
||||
{/* PersonalSetting 内部有 pt-16 sm:pt-20 用于独立路由清除固定头部,UserCenter 已处理顶部偏移,需用 -mt 抵消 */}
|
||||
{/* 邀请返利 / 发票抬头:侧栏项、routePathMap、权限守卫此前都已配好,
|
||||
唯独漏了这两个 <Route>,导致点进来是空白内容区。
|
||||
手机端侧栏是 hidden md:block,底部导航是唯一入口,等于两个死路口。
|
||||
两个组件根节点都是 p-4 sm:p-6、无自带顶部偏移,可直接嵌入。 */}
|
||||
<Route
|
||||
path='invite'
|
||||
element={guardUserCenterRoute('invite', <Invite />)}
|
||||
/>
|
||||
<Route
|
||||
path='invoice'
|
||||
element={guardUserCenterRoute('invoice', <Invoice />)}
|
||||
/>
|
||||
<Route
|
||||
path='settings'
|
||||
element={guardUserCenterRoute(
|
||||
'settings',
|
||||
<div className='-mt-16 sm:-mt-20 [&_.sticky]:!top-4'>
|
||||
<PersonalSetting />
|
||||
</div>,
|
||||
)}
|
||||
/>
|
||||
{/* WeyAi 桌面端下载:侧栏入口指到这里而不是独立的 /weyai/download,
|
||||
<Route
|
||||
path='invite'
|
||||
element={guardUserCenterRoute('invite', <Invite />)}
|
||||
/>
|
||||
<Route
|
||||
path='invoice'
|
||||
element={guardUserCenterRoute('invoice', <Invoice />)}
|
||||
/>
|
||||
<Route
|
||||
path='settings'
|
||||
element={guardUserCenterRoute(
|
||||
'settings',
|
||||
<div className='-mt-16 sm:-mt-20 [&_.sticky]:!top-4'>
|
||||
<PersonalSetting />
|
||||
</div>,
|
||||
)}
|
||||
/>
|
||||
{/* WeyAi 桌面端下载:侧栏入口指到这里而不是独立的 /weyai/download,
|
||||
否则点一下侧栏就整页跳走、导航栏消失。embedded:不加顶部让位、
|
||||
不自绘背景(shell 已有 PageBackground)。未开放时页面自身显示空态,
|
||||
侧栏项也随开关隐藏,无需再加守卫 */}
|
||||
<Route path='weyai-download' element={<WeyAiDownload embedded />} />
|
||||
</Routes>
|
||||
<Route
|
||||
path='weyai-download'
|
||||
element={<WeyAiDownload embedded />}
|
||||
/>
|
||||
</Routes>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user