|
@@ -16,7 +16,6 @@ import {
|
|
|
Card,
|
|
Card,
|
|
|
Tabs,
|
|
Tabs,
|
|
|
TabPane,
|
|
TabPane,
|
|
|
- Dropdown,
|
|
|
|
|
Empty
|
|
Empty
|
|
|
} from '@douyinfe/semi-ui';
|
|
} from '@douyinfe/semi-ui';
|
|
|
import {
|
|
import {
|
|
@@ -257,7 +256,7 @@ const ModelPricing = () => {
|
|
|
|
|
|
|
|
const [models, setModels] = useState([]);
|
|
const [models, setModels] = useState([]);
|
|
|
const [loading, setLoading] = useState(true);
|
|
const [loading, setLoading] = useState(true);
|
|
|
- const [userState, userDispatch] = useContext(UserContext);
|
|
|
|
|
|
|
+ const [userState] = useContext(UserContext);
|
|
|
const [groupRatio, setGroupRatio] = useState({});
|
|
const [groupRatio, setGroupRatio] = useState({});
|
|
|
const [usableGroup, setUsableGroup] = useState({});
|
|
const [usableGroup, setUsableGroup] = useState({});
|
|
|
|
|
|
|
@@ -334,57 +333,6 @@ const ModelPricing = () => {
|
|
|
return counts;
|
|
return counts;
|
|
|
}, [models, modelCategories]);
|
|
}, [models, modelCategories]);
|
|
|
|
|
|
|
|
- const renderArrow = (items, pos, handleArrowClick) => {
|
|
|
|
|
- const style = {
|
|
|
|
|
- width: 32,
|
|
|
|
|
- height: 32,
|
|
|
|
|
- margin: '0 12px',
|
|
|
|
|
- display: 'flex',
|
|
|
|
|
- justifyContent: 'center',
|
|
|
|
|
- alignItems: 'center',
|
|
|
|
|
- borderRadius: '100%',
|
|
|
|
|
- background: 'rgba(var(--semi-grey-1), 1)',
|
|
|
|
|
- color: 'var(--semi-color-text)',
|
|
|
|
|
- cursor: 'pointer',
|
|
|
|
|
- };
|
|
|
|
|
- return (
|
|
|
|
|
- <Dropdown
|
|
|
|
|
- render={
|
|
|
|
|
- <Dropdown.Menu>
|
|
|
|
|
- {items.map(item => {
|
|
|
|
|
- const key = item.itemKey;
|
|
|
|
|
- const modelCount = categoryCounts[key] || 0;
|
|
|
|
|
-
|
|
|
|
|
- return (
|
|
|
|
|
- <Dropdown.Item
|
|
|
|
|
- key={item.itemKey}
|
|
|
|
|
- onClick={() => setActiveKey(item.itemKey)}
|
|
|
|
|
- icon={modelCategories[item.itemKey]?.icon}
|
|
|
|
|
- >
|
|
|
|
|
- <div className="flex items-center gap-2">
|
|
|
|
|
- {modelCategories[item.itemKey]?.label || item.itemKey}
|
|
|
|
|
- <Tag
|
|
|
|
|
- color={activeKey === item.itemKey ? 'red' : 'grey'}
|
|
|
|
|
- size='small'
|
|
|
|
|
- shape='circle'
|
|
|
|
|
- >
|
|
|
|
|
- {modelCount}
|
|
|
|
|
- </Tag>
|
|
|
|
|
- </div>
|
|
|
|
|
- </Dropdown.Item>
|
|
|
|
|
- );
|
|
|
|
|
- })}
|
|
|
|
|
- </Dropdown.Menu>
|
|
|
|
|
- }
|
|
|
|
|
- >
|
|
|
|
|
- <div style={style} onClick={handleArrowClick}>
|
|
|
|
|
- {pos === 'start' ? '←' : '→'}
|
|
|
|
|
- </div>
|
|
|
|
|
- </Dropdown>
|
|
|
|
|
- );
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- // 检查分类是否有对应的模型
|
|
|
|
|
const availableCategories = useMemo(() => {
|
|
const availableCategories = useMemo(() => {
|
|
|
if (!models.length) return ['all'];
|
|
if (!models.length) return ['all'];
|
|
|
|
|
|
|
@@ -394,11 +342,9 @@ const ModelPricing = () => {
|
|
|
}).map(([key]) => key);
|
|
}).map(([key]) => key);
|
|
|
}, [models]);
|
|
}, [models]);
|
|
|
|
|
|
|
|
- // 渲染标签页
|
|
|
|
|
const renderTabs = () => {
|
|
const renderTabs = () => {
|
|
|
return (
|
|
return (
|
|
|
<Tabs
|
|
<Tabs
|
|
|
- renderArrow={renderArrow}
|
|
|
|
|
activeKey={activeKey}
|
|
activeKey={activeKey}
|
|
|
type="card"
|
|
type="card"
|
|
|
collapsible
|
|
collapsible
|
|
@@ -434,16 +380,13 @@ const ModelPricing = () => {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 优化过滤逻辑
|
|
|
|
|
const filteredModels = useMemo(() => {
|
|
const filteredModels = useMemo(() => {
|
|
|
let result = models;
|
|
let result = models;
|
|
|
|
|
|
|
|
- // 先按分类过滤
|
|
|
|
|
if (activeKey !== 'all') {
|
|
if (activeKey !== 'all') {
|
|
|
result = result.filter(model => modelCategories[activeKey].filter(model));
|
|
result = result.filter(model => modelCategories[activeKey].filter(model));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 再按搜索词过滤
|
|
|
|
|
if (filteredValue.length > 0) {
|
|
if (filteredValue.length > 0) {
|
|
|
const searchTerm = filteredValue[0].toLowerCase();
|
|
const searchTerm = filteredValue[0].toLowerCase();
|
|
|
result = result.filter(model =>
|
|
result = result.filter(model =>
|
|
@@ -454,7 +397,6 @@ const ModelPricing = () => {
|
|
|
return result;
|
|
return result;
|
|
|
}, [activeKey, models, filteredValue]);
|
|
}, [activeKey, models, filteredValue]);
|
|
|
|
|
|
|
|
- // 搜索和操作区组件
|
|
|
|
|
const SearchAndActions = useMemo(() => (
|
|
const SearchAndActions = useMemo(() => (
|
|
|
<Card className="!rounded-xl mb-6" bordered={false}>
|
|
<Card className="!rounded-xl mb-6" bordered={false}>
|
|
|
<div className="flex flex-wrap items-center gap-4">
|
|
<div className="flex flex-wrap items-center gap-4">
|
|
@@ -485,7 +427,6 @@ const ModelPricing = () => {
|
|
|
</Card>
|
|
</Card>
|
|
|
), [selectedRowKeys, t]);
|
|
), [selectedRowKeys, t]);
|
|
|
|
|
|
|
|
- // 表格组件
|
|
|
|
|
const ModelTable = useMemo(() => (
|
|
const ModelTable = useMemo(() => (
|
|
|
<Card className="!rounded-xl overflow-hidden" bordered={false}>
|
|
<Card className="!rounded-xl overflow-hidden" bordered={false}>
|
|
|
<Table
|
|
<Table
|