refactor(types): 重构类型系统,统一共享类型定义
feat(types): 新增共享类型中心,包含用户、产品、订单等核心领域类型 fix(types): 修复类型定义错误,统一各模块类型引用 style(types): 优化类型文件格式和注释 docs(types): 更新类型文档和变更日志 test(types): 添加类型测试用例 build(types): 配置类型共享路径 chore(types): 清理重复类型定义文件
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Card, Typography, Row, Col, Form, Input, Select, Button, Table, Statistic, Spin, message, Alert } from 'antd';
|
||||
import { CalculatorOutlined, SaveOutlined, HistoryOutlined, LineChartOutlined } from '@ant-design/icons';
|
||||
import { Link } from 'umi';
|
||||
import { productDataSource, AIPricingSuggestion } from '@/services/productDataSource';
|
||||
|
||||
import { productDataSource } from '@/services/productDataSource';
|
||||
|
||||
const { Title, Text, Paragraph } = Typography;
|
||||
const { Option } = Select;
|
||||
|
||||
@@ -450,7 +450,7 @@ const CrossPlatformManage: React.FC = () => {
|
||||
render: (_: any, record: CrossPlatformProduct) => {
|
||||
const platformInfo = record.platforms[shop.shopId];
|
||||
if (!platformInfo || platformInfo.status === 'NOT_LISTED') {
|
||||
return <Tag size="small" style={{ opacity: 0.5 }}>未上架</Tag>;
|
||||
return <Tag style={{ opacity: 0.5 }}>未上架</Tag>;
|
||||
}
|
||||
|
||||
const statusConfig = STATUS_CONFIG[platformInfo.status];
|
||||
@@ -575,7 +575,7 @@ const CrossPlatformManage: React.FC = () => {
|
||||
<Option key={shop.shopId} value={shop.shopId}>
|
||||
<Space>
|
||||
{shop.shopName}
|
||||
{!shop.apiSupported && <Tag size="small" color="warning">No API</Tag>}
|
||||
{!shop.apiSupported && <Tag color="warning">No API</Tag>}
|
||||
<span style={{ color: '#999' }}>({shopStats[shop.shopId] || 0})</span>
|
||||
</Space>
|
||||
</Option>
|
||||
@@ -668,8 +668,8 @@ const CrossPlatformManage: React.FC = () => {
|
||||
<Space>
|
||||
{PLATFORM_CONFIG[info.shopInfo.platform]?.icon}
|
||||
<span>{info.shopInfo.shopName}</span>
|
||||
<Tag size="small">{info.shopInfo.region}</Tag>
|
||||
{!info.shopInfo.apiSupported && <Tag size="small" color="warning">No API</Tag>}
|
||||
<Tag>{info.shopInfo.region}</Tag>
|
||||
{!info.shopInfo.apiSupported && <Tag color="warning">No API</Tag>}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -765,7 +765,7 @@ const CrossPlatformManage: React.FC = () => {
|
||||
<Space>
|
||||
{PLATFORM_CONFIG[info.shopInfo.platform]?.icon}
|
||||
{info.shopInfo.shopName}
|
||||
<Tag size="small">{info.shopInfo.region}</Tag>
|
||||
<Tag>{info.shopInfo.region}</Tag>
|
||||
</Space>
|
||||
</Option>
|
||||
))}
|
||||
|
||||
@@ -33,7 +33,8 @@ import {
|
||||
FilterOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import type { UploadFile } from 'antd/es/upload/interface';
|
||||
import { productDataSource, Product } from '@/services/productDataSource';
|
||||
import { productDataSource } from '@/services/productDataSource';
|
||||
import { Product } from '@/types/product';
|
||||
|
||||
const { Option } = Select;
|
||||
const { TabPane } = Tabs;
|
||||
@@ -158,8 +159,8 @@ export const MaterialUpload: React.FC = () => {
|
||||
type: file.type?.startsWith('image') ? 'image' :
|
||||
file.type?.startsWith('video') ? 'video' : 'document',
|
||||
size: file.size || 0,
|
||||
url: URL.createObjectURL(file.originFileObj || file as Blob),
|
||||
thumbnail: file.type?.startsWith('image') ? URL.createObjectURL(file.originFileObj || file as Blob) : undefined,
|
||||
url: URL.createObjectURL(file.originFileObj || (file as unknown as Blob)),
|
||||
thumbnail: file.type?.startsWith('image') ? URL.createObjectURL(file.originFileObj || (file as unknown as Blob)) : undefined,
|
||||
uploadedAt: new Date().toISOString(),
|
||||
uploadedBy: 'Current User',
|
||||
status: 'READY',
|
||||
|
||||
@@ -34,7 +34,8 @@ import {
|
||||
SyncOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { productDataSource, Product } from '@/services/productDataSource';
|
||||
import { productDataSource } from '@/services/productDataSource';
|
||||
import { Product } from '@/types/product';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
const { TabPane } = Tabs;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useEffect, useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Card,
|
||||
Table,
|
||||
@@ -6,6 +7,7 @@ import {
|
||||
Space,
|
||||
Tag,
|
||||
Input,
|
||||
InputNumber,
|
||||
Select,
|
||||
Row,
|
||||
Col,
|
||||
@@ -43,7 +45,7 @@ import {
|
||||
CloseCircleOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { Link, history } from 'umi';
|
||||
|
||||
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
|
||||
import type { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
|
||||
import moment from 'moment';
|
||||
@@ -76,7 +78,7 @@ interface FilterState {
|
||||
platform: string[];
|
||||
category: string[];
|
||||
roiRange: [number, number] | null;
|
||||
dateRange: [moment.Moment, moment.Moment] | null;
|
||||
dateRange: any;
|
||||
}
|
||||
|
||||
interface SortState {
|
||||
@@ -213,6 +215,7 @@ const MOCK_PRODUCTS: Product[] = [
|
||||
];
|
||||
|
||||
export const ProductList: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [selectedRows, setSelectedRows] = useState<Product[]>([]);
|
||||
@@ -288,15 +291,15 @@ export const ProductList: React.FC = () => {
|
||||
};
|
||||
|
||||
const handleAddProduct = () => {
|
||||
history.push('/Product/ProductPublishForm');
|
||||
navigate('/Product/ProductPublishForm');
|
||||
};
|
||||
|
||||
const handleEditProduct = (record: Product) => {
|
||||
history.push(`/Product/ProductDetail?id=${record.id}`);
|
||||
navigate(`/Product/ProductDetail?id=${record.id}`);
|
||||
};
|
||||
|
||||
const handleViewProduct = (record: Product) => {
|
||||
history.push(`/Product/ProductDetail?id=${record.id}`);
|
||||
navigate(`/Product/ProductDetail?id=${record.id}`);
|
||||
};
|
||||
|
||||
const handleDeleteProduct = (record: Product) => {
|
||||
@@ -557,7 +560,7 @@ export const ProductList: React.FC = () => {
|
||||
{Object.entries(record.platformStatus).map(([platform, status]) => (
|
||||
<Tooltip key={platform} title={`${platform}: ${status}`}>
|
||||
<Tag
|
||||
size="small"
|
||||
|
||||
color={status === 'LIVE' ? 'success' : status === 'FAILED' ? 'error' : 'processing'}
|
||||
>
|
||||
{platform.charAt(0)}
|
||||
@@ -824,7 +827,7 @@ export const ProductList: React.FC = () => {
|
||||
<span>{item.label}</span>
|
||||
<Space>
|
||||
<Button
|
||||
size="small"
|
||||
|
||||
icon={<ArrowUpOutlined />}
|
||||
type={sort.field === item.key && sort.order === 'ascend' ? 'primary' : 'default'}
|
||||
onClick={() => handleSortChange(item.key, 'ascend')}
|
||||
@@ -832,7 +835,7 @@ export const ProductList: React.FC = () => {
|
||||
升序
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
|
||||
icon={<ArrowDownOutlined />}
|
||||
type={sort.field === item.key && sort.order === 'descend' ? 'primary' : 'default'}
|
||||
onClick={() => handleSortChange(item.key, 'descend')}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Card, Typography, Row, Col, Select, Button, Table, Statistic, Spin, message, Alert, Badge } from 'antd';
|
||||
import { LineChart, Line, AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
||||
import { AlertOutlined, TrendingUpOutlined, TrendingDownOutlined, ReloadOutlined, EyeOutlined } from '@ant-design/icons';
|
||||
import { Link } from 'umi';
|
||||
import { AlertOutlined, UpOutlined, DownOutlined, ReloadOutlined, EyeOutlined } from '@ant-design/icons';
|
||||
//
|
||||
import { productDataSource, ProfitMonitor as ProfitMonitorData } from '@/services/productDataSource';
|
||||
|
||||
const { Title, Text, Paragraph } = Typography;
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import { Card, Typography, Row, Col, DatePicker, Select, Button, Table, Statistic, Spin, message } from 'antd';
|
||||
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, LineChart, Line } from 'recharts';
|
||||
import { ArrowUpOutlined, ArrowDownOutlined, ReloadOutlined } from '@ant-design/icons';
|
||||
import { Link } from 'umi';
|
||||
//
|
||||
import { productDataSource, ROIAnalysis as ROIAnalysisData } from '@/services/productDataSource';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
Reference in New Issue
Block a user