返回 AiToEarn
index.tsx
1 /*
2 * @Author: nevin
3 * @Date: 2025-02-10 22:20:15
4 * @LastEditTime: 2025-04-01 15:58:37
5 * @LastEditors: nevin
6 * @Description:
7 */
8 import {
9 createHashRouter,
10 IndexRouteObject,
11 Navigate,
12 NonIndexRouteObject,
13 } from 'react-router-dom';
14 import { AntdIconProps } from '@ant-design/icons/lib/components/AntdIcon';
15 import {
16 CopyOutlined,
17 FireOutlined,
18 UsergroupAddOutlined,
19 ShopOutlined,
20 MessageOutlined,
21 AuditOutlined,
22 OpenAIOutlined,
23 } from '@ant-design/icons';
24
25 // 组件
26 import { LayoutBody } from '@/layout/LayoutBody';
27
28 // 页面组件
29 import Login from '@/views/login';
30 import Trending from '@/views/trending';
31 import Account from '@/views/account';
32 import Publish from '@/views/publish/page';
33 import VideoPage from '@/views/publish/children/videoPage/page';
34 import ImagePage from '@/views/publish/children/imagePage/page';
35 import PubRecord from '@/views/publish/children/pubRecord/page';
36 import Statistics from '@/views/statistics/statistics';
37 import Task from '@/views/task/task';
38 import UserWalletAccount from '@/views/finance/userWalletAccount';
39 import Finance from '@/views/finance/finance';
40 import UserWalletRecord from '@/views/finance/userWalletRecord';
41 import Reply from '@/views/reply';
42 import Replyother from '@/views/replyother/replyother';
43 import ErrorBoundary from '../components/ErrorBoundary/ErrorBoundary';
44 import AiTool from '@/views/aiTool/index';
45 import AiRanking from '../views/aiTool/children/aiRanking/index';
46 import AiToolWebview from '../views/aiTool/children/aiToolWebview';
47 import ExpectedIncome from '@/views/finance/expectedIncome';
48 import Test from '@/views/test';
49 import UserProfile from '@/views/user/mine/UserProfile';
50 // import Test from '@/views/test';
51
52 interface IRouterMeta {
53 // 路由名称
54 name?: string;
55 // 路由icon
56 icon?: React.ForwardRefExoticComponent<
57 Omit<AntdIconProps, 'ref'> & React.RefAttributes<HTMLSpanElement>
58 >;
59 }
60
61 interface ICustomRoute {
62 meta?: IRouterMeta;
63 }
64
65 // 扩展原ts类型
66 interface ICustomIndexRouteObject extends IndexRouteObject {}
67 interface ICustomNonIndexRouteObject extends NonIndexRouteObject {
68 children?: CustomRouteObject[];
69 }
70 type CustomRouteObject =
71 | (ICustomIndexRouteObject & ICustomRoute)
72 | (ICustomNonIndexRouteObject & ICustomRoute);
73
74 /**
75 * 路由表
76 * 只有 router[0] 才会被渲染到导航,所以请不要改动一级数据的顺序。
77 * router[0].children 下的路由如果存在 meta 会渲染到 nav
78 */
79 export const router: CustomRouteObject[] = [
80 {
81 element: (
82 <ErrorBoundary>
83 <LayoutBody />
84 </ErrorBoundary>
85 ),
86 children: [
87 // 重定向 ---------
88 { path: '/publish', element: <Navigate to="/publish/video" /> },
89 { path: '/aiTool', element: <Navigate to="/aiTool/aiRanking" /> },
90
91 // 路由 ----------
92 {
93 path: '/',
94 element: <Account />,
95 meta: { name: '账户', icon: UsergroupAddOutlined },
96 },
97 {
98 path: '/trending',
99 element: <Trending />,
100 meta: { name: '热门内容', icon: FireOutlined },
101 },
102 {
103 path: '/publish',
104 element: <Publish />,
105 meta: { name: '一键发布', icon: CopyOutlined },
106 children: [
107 {
108 path: 'video',
109 element: <VideoPage />,
110 },
111 {
112 path: 'image',
113 element: <ImagePage />,
114 },
115 { path: 'pubRecord', element: <PubRecord /> },
116 ],
117 },
118 {
119 path: '/aiTool',
120 element: <AiTool />,
121 meta: { name: 'AI工具', icon: OpenAIOutlined },
122 children: [
123 {
124 path: '/aiTool/aiRanking',
125 element: <AiRanking />,
126 },
127 {
128 path: '/aiTool/aiToolWebview',
129 element: <AiToolWebview />,
130 },
131 ],
132 },
133 {
134 path: '/reply',
135 element: <Reply />,
136 meta: { name: '评论管理', icon: MessageOutlined },
137 },
138 {
139 path: '/Replyother',
140 element: <Replyother />,
141 meta: { name: 'AI评论截流', icon: MessageOutlined },
142 },
143 {
144 path: '/statistics',
145 element: <Statistics />,
146 meta: { name: '数据中心', icon: AuditOutlined },
147 },
148 {
149 path: '/task',
150 element: <Task />,
151 meta: { name: '任务市场', icon: ShopOutlined },
152 },
153 {
154 path: '/finance',
155 element: <Finance />,
156 // meta: { name: '钱包', icon: MoneyCollectOutlined },
157 children: [
158 { path: 'userWalletRecord', element: <UserWalletRecord /> },
159 { path: 'userWalletAccount', element: <UserWalletAccount /> },
160 { path: 'expectedIncome', element: <ExpectedIncome /> },
161 ],
162 },
163 // {
164 // path: '/test',
165 // element: <Test />,
166 // meta: { name: '测试', icon: ShopOutlined },
167 // },
168 {
169 path: '/user',
170 children: [
171 { path: 'mine', element: <UserProfile /> },
172 ],
173 },
174 // {
175 // path: '/test',
176 // element: <Test />,
177 // meta: { name: '测试', icon: ShopOutlined },
178 // },
179 ],
180 },
181 { path: '/login', element: <Login /> },
182 ];
183
184 export default createHashRouter(router);
185
185 lines Plain Text