소스 검색

✨ feat(admin): add stock data management feature

- add stock data menu item with LineChartOutlined icon and stock:manage permission
- add stock data route configuration
- optimize StockDataPage by:
  - remove unused react-json-view import
  - add type annotation for render parameters
  - replace ReactJson with pre tag for JSON display to reduce bundle size and improve performance
yourname 5 달 전
부모
커밋
302d7fa601
3개의 변경된 파일20개의 추가작업 그리고 10개의 파일을 삭제
  1. 8 0
      src/client/admin/menu.tsx
  2. 6 10
      src/client/admin/pages/StockDataPage.tsx
  3. 6 0
      src/client/admin/routes.tsx

+ 8 - 0
src/client/admin/menu.tsx

@@ -9,6 +9,7 @@ import {
   InfoCircleOutlined,
   DatabaseOutlined,
   FileTextOutlined,
+  LineChartOutlined,
 } from '@ant-design/icons';
 
 export interface MenuItem {
@@ -100,6 +101,13 @@ export const useMenu = () => {
       icon: <FileTextOutlined />,
       path: '/admin/submission-records',
       permission: 'submission:manage'
+    },
+    {
+      key: 'stock-data',
+      label: '股票数据管理',
+      icon: <LineChartOutlined />,
+      path: '/admin/stock-data',
+      permission: 'stock:manage'
     }
   ];
 

+ 6 - 10
src/client/admin/pages/StockDataPage.tsx

@@ -4,7 +4,7 @@ import { PlusOutlined, EditOutlined, DeleteOutlined, SearchOutlined, EyeOutlined
 import { stockDataClient } from '@/client/api';
 import type { InferResponseType, InferRequestType } from 'hono/client';
 import { App } from 'antd';
-import ReactJson from 'react-json-view';
+// import ReactJson from 'react-json-view';
 
 const { Title } = Typography;
 
@@ -174,7 +174,7 @@ export const StockDataPage: React.FC = () => {
     {
       title: '数据摘要',
       key: 'dataSummary',
-      render: (_, record: StockDataItem) => (
+      render: (_: any, record: StockDataItem) => (
         <div>
           {record.data.date && <div>日期: {record.data.date}</div>}
           {record.data.close && <div>收盘价: {record.data.close}</div>}
@@ -191,7 +191,7 @@ export const StockDataPage: React.FC = () => {
     {
       title: '状态',
       key: 'status',
-      render: (_, record: StockDataItem) => (
+      render: (_: any, record: StockDataItem) => (
         <Tag color={new Date(record.updatedAt) > new Date(record.createdAt) ? 'blue' : 'green'}>
           {new Date(record.updatedAt) > new Date(record.createdAt) ? '已更新' : '原始数据'}
         </Tag>
@@ -332,13 +332,9 @@ export const StockDataPage: React.FC = () => {
             </Card>
             
             <Card title="股票数据">
-              <ReactJson 
-                src={currentItem.data} 
-                name={false} 
-                collapsed={false} 
-                theme="rjv-default"
-                style={{ padding: '10px 0' }}
-              />
+              <pre style={{ whiteSpace: 'pre-wrap', wordWrap: 'break-word', maxHeight: '400px', overflow: 'auto', padding: '10px', backgroundColor: '#f5f5f5', borderRadius: '4px' }}>
+                {JSON.stringify(currentItem.data, null, 2)}
+              </pre>
             </Card>
           </div>
         )}

+ 6 - 0
src/client/admin/routes.tsx

@@ -8,6 +8,7 @@ import { DashboardPage } from './pages/Dashboard';
 import { UsersPage } from './pages/Users';
 import { ClassroomDataPage } from './pages/ClassroomDataPage';
 import { SubmissionRecordsPage } from './pages/SubmissionRecordsPage';
+import { StockDataPage } from './pages/StockDataPage';
 import { LoginPage } from './pages/Login';
 
 export const router = createBrowserRouter([
@@ -51,6 +52,11 @@ export const router = createBrowserRouter([
         element: <SubmissionRecordsPage />,
         errorElement: <ErrorPage />
       },
+      {
+        path: 'stock-data',
+        element: <StockDataPage />,
+        errorElement: <ErrorPage />
+      },
       {
         path: '*',
         element: <NotFoundPage />,