feat: 合并代码后 系统设置 ui样式优化、bug修复、全局统一图标对齐等

This commit is contained in:
zhanjunhao
2026-11-10 17:27:36 +08:00
parent 5463a0c772
commit ed9820e6a6
195 changed files with 3546 additions and 1984 deletions
+111 -116
View File
@@ -16,6 +16,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { Eraser as ActionEraser } from '@/components/common/icons/ActionIcons';
import {
Plus as ActionPlus,
RefreshCw as ActionRefreshCw,
ChevronDown as ActionChevronDown,
ChevronRight as ActionChevronRight,
} from '@/components/common/icons/ActionIcons';
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import {
Card,
@@ -37,17 +44,7 @@ import {
Empty,
Switch,
} from '@/components/ui';
import {
Plus,
Pencil,
Trash2,
RefreshCw,
Copy,
Search,
Eraser,
ChevronDown,
ChevronRight,
} from 'lucide-react';
import { Search } from 'lucide-react';
import { API, showError, showSuccess } from '../../helpers';
import { useTranslation } from 'react-i18next';
import './LevelPolicySetting.css';
@@ -131,7 +128,7 @@ const GroupModelDiscountEditor = ({
/>
<Button
size='small'
icon={<Plus size={14} />}
icon={<ActionPlus size={14} />}
disabled={!allowAdd || pendingModels.length === 0 || pendingInvalid}
onClick={() => {
onAdd(pendingModels, pendingTrim);
@@ -149,102 +146,96 @@ const GroupModelDiscountEditor = ({
</Text>
)}
</Space>
{rows.length === 0 ? (
{rows.length === 0 &&
// 已废弃分组不显示「按分组折扣计费」——该分组已无流量,顶部已有废弃提示
allowAdd ? (
(allowAdd ? (
<div className='mt-2'>
<Text type='tertiary' size='small'>
{t('未配置模型折扣:该分组所有模型按分组折扣系数计费')}
</Text>
</div>
) : null
) : (
<Table
// 嵌在 358px 的弹窗体里,列宽合计 460~480px,必须给横向滚动
scroll={{ x: 'max-content' }}
size='small'
className='level-policy-table mt-2'
pagination={false}
dataSource={rows}
columns={[
{
title: t('模型'),
dataIndex: 'model',
render: (v, r) => (
<Space>
<span>{v}</span>
{r.maybeDisabled && (
<Tooltip
content={t(
'该模型不在启用模型列表中(可能已下线),折扣条目保留但不会有流量命中',
)}
>
<Tag color='orange' type='ghost'>
{t('未启用')}
</Tag>
</Tooltip>
)}
</Space>
),
},
{
title: t('折扣系数'),
dataIndex: 'raw',
width: 170,
render: (v, r) => {
const s = String(v ?? '').trim();
const num = Number(s);
const invalid = s !== '' && (!Number.isFinite(num) || num <= 0);
return (
<Input
size='small'
style={{ width: 130 }}
validateStatus={s === '' || invalid ? 'error' : 'default'}
value={String(v ?? '')}
onChange={(val) => onChange(r.model, val)}
/>
);
},
},
{
title: t('效果'),
width: 210,
render: (_, r) => (
<div>
{discountHint(r.raw) || (
<Text type='danger' size='small'>
{t('须填写,删除条目请点「移除」')}
</Text>
)}
<div>
<Text type='tertiary' size='small'>
{replaceHint}
</Text>
</div>
</div>
),
},
{
title: t('操作'),
width: 100,
render: (_, r) => (
<Popconfirm
title={t('确认移除该模型折扣?')}
onConfirm={() => onRemove(r.model)}
>
<Button
size='small'
type='danger'
icon={<Trash2 size={14} />}
) : null)}
<Table
// 嵌在 358px 的弹窗体里,列宽合计 460~480px,必须给横向滚动
scroll={{ x: 'max-content' }}
size='small'
className='level-policy-table mt-2'
pagination={false}
dataSource={rows}
columns={[
{
title: t('模型'),
dataIndex: 'model',
render: (v, r) => (
<Space>
<span>{v}</span>
{r.maybeDisabled && (
<Tooltip
content={t(
'该模型不在启用模型列表中(可能已下线),折扣条目保留但不会有流量命中',
)}
>
{t('移除')}
</Button>
</Popconfirm>
),
<Tag color='orange' type='ghost'>
{t('未启用')}
</Tag>
</Tooltip>
)}
</Space>
),
},
{
title: t('折扣系数'),
dataIndex: 'raw',
width: 170,
render: (v, r) => {
const s = String(v ?? '').trim();
const num = Number(s);
const invalid = s !== '' && (!Number.isFinite(num) || num <= 0);
return (
<Input
size='small'
style={{ width: 130 }}
validateStatus={s === '' || invalid ? 'error' : 'default'}
value={String(v ?? '')}
onChange={(val) => onChange(r.model, val)}
/>
);
},
]}
/>
)}
},
{
title: t('效果'),
width: 210,
render: (_, r) => (
<div>
{discountHint(r.raw) || (
<Text type='danger' size='small'>
{t('须填写,删除条目请点「移除」')}
</Text>
)}
<div>
<Text type='tertiary' size='small'>
{replaceHint}
</Text>
</div>
</div>
),
},
{
title: t('操作'),
width: 100,
render: (_, r) => (
<Popconfirm
title={t('确认移除该模型折扣?')}
onConfirm={() => onRemove(r.model)}
>
<Button type='link' size='small' danger>
{t('移除')}
</Button>
</Popconfirm>
),
},
]}
/>
</div>
);
};
@@ -988,17 +979,17 @@ const LevelPolicySetting = () => {
render: (_, r) => (
<Space>
<Button
size='small'
icon={<Pencil size={14} />}
onClick={() => openEditor(type, r.code)}
type='link'
size='small'
>
{t('编辑')}
</Button>
<Tooltip content={t('以该等级为模板新建')}>
<Button
size='small'
icon={<Copy size={14} />}
onClick={() => duplicateLevel(type, r.code)}
type='link'
size='small'
>
{t('复制')}
</Button>
@@ -1009,10 +1000,10 @@ const LevelPolicySetting = () => {
onConfirm={() => deleteLevel(type, r.code)}
>
<Button
size='small'
type='danger'
icon={<Trash2 size={14} />}
loading={deletingCode === `${type}/${r.code}`}
type='link'
size='small'
danger
>
{t('删除')}
</Button>
@@ -1106,7 +1097,7 @@ const LevelPolicySetting = () => {
headerExtraContent={
<Button
theme='solid'
icon={<Plus size={14} />}
icon={<ActionPlus size={14} />}
onClick={() => openEditor(type, null)}
>
{t('新增等级')}
@@ -1147,7 +1138,7 @@ const LevelPolicySetting = () => {
headerExtraContent={
<Space>
<Button
icon={<RefreshCw size={14} />}
icon={<ActionRefreshCw size={14} />}
onClick={fetchAll}
disabled={loading}
>
@@ -1355,7 +1346,11 @@ const LevelPolicySetting = () => {
title={t('清空全部逐模型覆盖?')}
onConfirm={clearOverrides}
>
<Button size='small' type='tertiary' icon={<Eraser size={14} />}>
<Button
size='small'
type='tertiary'
icon={<ActionEraser size={14} />}
>
{t('清空全部')}
</Button>
</Popconfirm>
@@ -1391,7 +1386,7 @@ const LevelPolicySetting = () => {
/>
<Button
theme='solid'
icon={<Plus size={14} />}
icon={<ActionPlus size={14} />}
disabled={overrideModels.length === 0}
onClick={addOverrides}
>
@@ -1465,10 +1460,10 @@ const LevelPolicySetting = () => {
width: 110,
render: (_, r) => (
<Button
size='small'
type='danger'
icon={<Trash2 size={14} />}
onClick={() => removeOverride(r.model)}
type='link'
size='small'
danger
>
{t('移除')}
</Button>
@@ -1632,9 +1627,9 @@ const LevelPolicySetting = () => {
type={r.modelDiscountCount > 0 ? 'primary' : 'tertiary'}
icon={
expanded ? (
<ChevronDown size={14} />
<ActionChevronDown size={14} />
) : (
<ChevronRight size={14} />
<ActionChevronRight size={14} />
)
}
onClick={() => toggleGroupExpanded(r.key)}