186 lines
6.8 KiB
TypeScript
186 lines
6.8 KiB
TypeScript
import { lazy, Suspense } from 'react'
|
|
import { Route, Routes } from 'react-router-dom'
|
|
|
|
import { PageLoading } from '@/components/PageLoading'
|
|
import { NotFoundPage } from '@/features/NotFoundPage'
|
|
import { StorefrontLayout } from '@/layouts/StorefrontLayout'
|
|
|
|
const ListingListPage = lazy(() =>
|
|
import('@/features/listings/ListingListPage').then(module => ({ default: module.ListingListPage }))
|
|
)
|
|
const LoginPage = lazy(() =>
|
|
import('@/features/auth/LoginPage').then(module => ({ default: module.LoginPage }))
|
|
)
|
|
const MobileLayout = lazy(() =>
|
|
import('@/layouts/MobileLayout').then(module => ({ default: module.MobileLayout }))
|
|
)
|
|
const MobileHomePage = lazy(() =>
|
|
import('@/features/mobile/MobileHomePage').then(module => ({ default: module.MobileHomePage }))
|
|
)
|
|
const MobileListingDetailPage = lazy(() =>
|
|
import('@/features/mobile/MobileListingDetailPage').then(module => ({
|
|
default: module.MobileListingDetailPage,
|
|
}))
|
|
)
|
|
const MobileProfilePage = lazy(() =>
|
|
import('@/features/mobile/MobileProfilePage').then(module => ({
|
|
default: module.MobileProfilePage,
|
|
}))
|
|
)
|
|
const MobileOrdersPage = lazy(() =>
|
|
import('@/features/mobile/MobileOrdersPage').then(module => ({
|
|
default: module.MobileOrdersPage,
|
|
}))
|
|
)
|
|
const MobileOrderDetailPage = lazy(() =>
|
|
import('@/features/mobile/MobileOrderDetailPage').then(module => ({
|
|
default: module.MobileOrderDetailPage,
|
|
}))
|
|
)
|
|
const MobileMessagesPage = lazy(() =>
|
|
import('@/features/mobile/MobileMessagesPage').then(module => ({
|
|
default: module.MobileMessagesPage,
|
|
}))
|
|
)
|
|
const MobileChatPage = lazy(() =>
|
|
import('@/features/mobile/MobileChatPage').then(module => ({
|
|
default: module.MobileChatPage,
|
|
}))
|
|
)
|
|
const AdminLoginPage = lazy(() =>
|
|
import('@/features/admin/AdminLoginPage').then(module => ({ default: module.AdminLoginPage }))
|
|
)
|
|
const AdminGuard = lazy(() =>
|
|
import('@/features/admin/AdminGuard').then(module => ({ default: module.AdminGuard }))
|
|
)
|
|
const AdminChangePasswordPage = lazy(() =>
|
|
import('@/features/admin/AdminChangePasswordPage').then(module => ({
|
|
default: module.AdminChangePasswordPage,
|
|
}))
|
|
)
|
|
const AdminDashboardPage = lazy(() =>
|
|
import('@/features/admin/AdminDashboardPage').then(module => ({
|
|
default: module.AdminDashboardPage,
|
|
}))
|
|
)
|
|
const AdminOrdersPage = lazy(() =>
|
|
import('@/features/admin/AdminOrdersPage').then(module => ({
|
|
default: module.AdminOrdersPage,
|
|
}))
|
|
)
|
|
const AdminListingsPage = lazy(() =>
|
|
import('@/features/admin/AdminListingsPage').then(module => ({
|
|
default: module.AdminListingsPage,
|
|
}))
|
|
)
|
|
const AdminUsersPage = lazy(() =>
|
|
import('@/features/admin/AdminUsersPage').then(module => ({
|
|
default: module.AdminUsersPage,
|
|
}))
|
|
)
|
|
const AdminRefundReviewPage = lazy(() =>
|
|
import('@/features/admin/AdminRefundReviewPage').then(module => ({
|
|
default: module.AdminRefundReviewPage,
|
|
}))
|
|
)
|
|
const AdminWithdrawalsPage = lazy(() =>
|
|
import('@/features/admin/AdminWithdrawalsPage').then(module => ({
|
|
default: module.AdminWithdrawalsPage,
|
|
}))
|
|
)
|
|
const AdminDisputesPage = lazy(() =>
|
|
import('@/features/admin/AdminDisputesPage').then(module => ({
|
|
default: module.AdminDisputesPage,
|
|
}))
|
|
)
|
|
const AdminFinancePage = lazy(() =>
|
|
import('@/features/admin/AdminFinancePage').then(module => ({
|
|
default: module.AdminFinancePage,
|
|
}))
|
|
)
|
|
const AdminAnnouncementsPage = lazy(() =>
|
|
import('@/features/admin/AdminAnnouncementsPage').then(module => ({
|
|
default: module.AdminAnnouncementsPage,
|
|
}))
|
|
)
|
|
const AdminLayout = lazy(() =>
|
|
import('@/layouts/AdminLayout').then(module => ({ default: module.AdminLayout }))
|
|
)
|
|
const AdminSectionPlaceholder = lazy(() =>
|
|
import('@/layouts/AdminLayout').then(module => ({ default: module.AdminSectionPlaceholder }))
|
|
)
|
|
|
|
const adminSections: Array<{ path: string; title: string; description: string }> = [
|
|
{ path: 'distribution/sites', title: '分销站点', description: '管理分站、规则、结算与站点钱包。' },
|
|
{ path: 'system-configs', title: '系统配置', description: '维护首页、发布、订单与支付配置。' },
|
|
{ path: 'audit-logs', title: '审计日志', description: '查看高风险操作与变更记录。' },
|
|
]
|
|
|
|
export function AppRouter() {
|
|
const adminBase = import.meta.env.VITE_ADMIN_BASE_PATH || '/console-jy8k3m'
|
|
|
|
return (
|
|
<Suspense fallback={<PageLoading />}>
|
|
<Routes>
|
|
<Route element={<StorefrontLayout />}>
|
|
<Route index element={<ListingListPage />} />
|
|
</Route>
|
|
|
|
<Route path="/login" element={<LoginPage />} />
|
|
<Route path="/m/login" element={<LoginPage />} />
|
|
|
|
<Route path="/m" element={<MobileLayout />}>
|
|
<Route index element={<MobileHomePage />} />
|
|
<Route path="listings" element={<MobileHomePage />} />
|
|
<Route path="listings/:id" element={<MobileListingDetailPage />} />
|
|
<Route path="orders" element={<MobileOrdersPage />} />
|
|
<Route path="orders/:id" element={<MobileOrderDetailPage />} />
|
|
<Route path="messages" element={<MobileMessagesPage />} />
|
|
<Route path="messages/:id" element={<MobileChatPage />} />
|
|
<Route path="profile" element={<MobileProfilePage />} />
|
|
</Route>
|
|
|
|
<Route path={`${adminBase}/login`} element={<AdminLoginPage />} />
|
|
<Route path={adminBase} element={<AdminGuard />}>
|
|
<Route path="change-password" element={<AdminChangePasswordPage />} />
|
|
<Route element={<AdminLayout />}>
|
|
<Route index element={<AdminDashboardPage />} />
|
|
<Route path="orders" element={<AdminOrdersPage />} />
|
|
<Route path="orders/refund-review" element={<AdminRefundReviewPage />} />
|
|
<Route path="listings" element={<AdminListingsPage />} />
|
|
<Route path="listings/review" element={<AdminListingsPage mode="review" />} />
|
|
<Route path="users" element={<AdminUsersPage />} />
|
|
<Route path="withdrawals" element={<AdminWithdrawalsPage />} />
|
|
<Route path="disputes" element={<AdminDisputesPage />} />
|
|
<Route path="finance" element={<AdminFinancePage />} />
|
|
<Route path="announcements" element={<AdminAnnouncementsPage />} />
|
|
{adminSections.map(section => (
|
|
<Route
|
|
key={section.path}
|
|
path={section.path}
|
|
element={
|
|
<AdminSectionPlaceholder
|
|
title={section.title}
|
|
description={section.description}
|
|
/>
|
|
}
|
|
/>
|
|
))}
|
|
<Route
|
|
path="*"
|
|
element={
|
|
<AdminSectionPlaceholder
|
|
title="功能建设中"
|
|
description="这个后台页面还没有进入迁移批次。"
|
|
/>
|
|
}
|
|
/>
|
|
</Route>
|
|
</Route>
|
|
|
|
<Route path="*" element={<NotFoundPage />} />
|
|
</Routes>
|
|
</Suspense>
|
|
)
|
|
}
|