Просмотр исходного кода

feat: 渠道-模型级联选择 + 隐藏首页统计卡片

- UserRatioSection 模型输入改为级联下拉,选渠道后自动加载模型列表
- models 信息嵌入 channelOptions 消除冗余 channelMap 状态
- 注释掉首页 HeroSection 统计数据卡片

Co-Authored-By: Claude <noreply@anthropic.com>
master
fengsilin 13 часов назад
Родитель
Сommit
d26ad9e635
2 измененных файлов: 24 добавлений и 8 удалений
  1. +22
    -6
      web/src/components/table/users/modals/UserRatioSection.jsx
  2. +2
    -2
      web/src/pages/Home/components/HeroSection.jsx

+ 22
- 6
web/src/components/table/users/modals/UserRatioSection.jsx Просмотреть файл

@@ -21,6 +21,7 @@ const UserRatioSection = ({ userId }) => {
const [loading, setLoading] = useState(false);
const [addModalVisible, setAddModalVisible] = useState(false);
const [channelOptions, setChannelOptions] = useState([]);
const [modelOptions, setModelOptions] = useState([]);
const formApiRef = useRef(null);

const loadRatios = async () => {
@@ -50,6 +51,7 @@ const UserRatioSection = ({ userId }) => {
? `${ch.name} (${ch.remark})`
: `${ch.name} (ID: ${ch.id})`,
value: ch.id,
models: (ch.models || '').split(',').map((m) => m.trim()).filter(Boolean),
}));
setChannelOptions(options);
} else {
@@ -190,12 +192,6 @@ const UserRatioSection = ({ userId }) => {
getFormApi={(api) => (formApiRef.current = api)}
onSubmit={handleAdd}
>
<Form.Input
field='model_name'
label={t('模型名称')}
placeholder='gpt-4o'
rules={[{ required: true, message: t('请输入模型名称') }]}
/>
<Form.Select
field='channel_id'
label={t('渠道')}
@@ -205,6 +201,26 @@ const UserRatioSection = ({ userId }) => {
showClear
rules={[{ required: true, message: t('请选择渠道') }]}
style={{ width: '100%' }}
onChange={(val) => {
formApiRef.current?.setValue('model_name', undefined);
const selected = channelOptions.find((c) => c.value === val);
if (selected?.models) {
setModelOptions(selected.models.map((m) => ({ label: m, value: m })));
} else {
setModelOptions([]);
}
}}
/>
<Form.Select
field='model_name'
label={t('模型')}
placeholder={t('请选择模型')}
optionList={modelOptions}
filter
showClear
disabled={modelOptions.length === 0}
rules={[{ required: true, message: t('请选择模型') }]}
style={{ width: '100%' }}
/>
<Form.InputNumber
field='ratio'


+ 2
- 2
web/src/pages/Home/components/HeroSection.jsx Просмотреть файл

@@ -172,14 +172,14 @@ const HeroSection = () => {
</div>

{/* 统计数据 */}
<div className="flex flex-wrap gap-8 pt-2">
{/* <div className="flex flex-wrap gap-8 pt-2">
{stats.map((stat, index) => (
<div key={index} className="stat-card">
<span className="stat-card-value">{stat.value}</span>
<span className="stat-card-label">{stat.label}</span>
</div>
))}
</div>
</div> */}
</div>

{/* 右侧功能卡片 */}


Загрузка…
Отмена
Сохранить