feat(mobile): 新增解忧商行移动端首页、详情与个人中心

This commit is contained in:
yml2213
2026-10-30 12:26:31 +08:00
parent 97167fa482
commit ef01486e53
14 changed files with 1499 additions and 10 deletions
+66
View File
@@ -0,0 +1,66 @@
import 'antd-mobile/es/global'
import { TabBar } from 'antd-mobile'
import { AppOutline, MessageOutline, UnorderedListOutline, UserOutline } from 'antd-mobile-icons'
import { Link, Outlet, useLocation, useNavigate } from 'react-router-dom'
import { BrandLogo } from '@/components/BrandLogo'
import { useSessionStore } from '@/stores/session'
const tabs = [
{ key: '/m', title: '首页', icon: <AppOutline /> },
{ key: '/m/orders', title: '订单', icon: <UnorderedListOutline /> },
{ key: '/m/messages', title: '消息', icon: <MessageOutline /> },
{ key: '/m/profile', title: '我的', icon: <UserOutline /> },
]
function activeTab(pathname: string) {
if (pathname.startsWith('/m/orders') || pathname.startsWith('/m/chats')) return '/m/orders'
if (pathname.startsWith('/m/messages')) return '/m/messages'
if (pathname.startsWith('/m/profile')) return '/m/profile'
return '/m'
}
export function MobileLayout() {
const location = useLocation()
const navigate = useNavigate()
const user = useSessionStore(state => state.user)
const hideTabbar = /^\/m\/listings\/[^/]+$/.test(location.pathname)
return (
<div className="mobile-shell">
<header className="mobile-header">
<Link to="/m" className="mobile-header__brand" aria-label="解忧商行移动端首页">
<BrandLogo height={30} />
</Link>
<div className="mobile-header__right">
{user ? (
<Link to="/m/profile" className="mobile-header__user">
{user.nickname || '我的'}
</Link>
) : (
<Link to="/m/login" className="mobile-header__login">
登录
</Link>
)}
</div>
</header>
<main className="mobile-content">
<Outlet />
</main>
<div className="mobile-tabbar" hidden={hideTabbar}>
<TabBar
activeKey={activeTab(location.pathname)}
onChange={key => navigate(key)}
safeArea
>
{tabs.map(tab => (
<TabBar.Item key={tab.key} icon={tab.icon} title={tab.title} />
))}
</TabBar>
</div>
</div>
)
}