2025-07-19 03:30:44 +08:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (C) 2025 QuantumNous
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-06-23 16:34:00 +08:00
|
|
|
|
import React, { useState, useCallback, useMemo, useEffect } from 'react';
|
2025-06-19 08:57:34 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Table,
|
|
|
|
|
|
Tag,
|
|
|
|
|
|
Empty,
|
|
|
|
|
|
Checkbox,
|
|
|
|
|
|
Form,
|
2025-06-19 18:54:46 +08:00
|
|
|
|
Input,
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
Tooltip,
|
|
|
|
|
|
Select,
|
2025-06-23 17:35:39 +08:00
|
|
|
|
Modal,
|
2026-04-26 20:17:35 +08:00
|
|
|
|
Spin,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
} from '@douyinfe/semi-ui';
|
2025-06-19 18:54:46 +08:00
|
|
|
|
import { IconSearch } from '@douyinfe/semi-icons';
|
2026-04-26 20:17:35 +08:00
|
|
|
|
import { RefreshCcw, CheckSquare, AlertTriangle } from 'lucide-react';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
import {
|
|
|
|
|
|
API,
|
|
|
|
|
|
showError,
|
2026-04-26 20:17:35 +08:00
|
|
|
|
showInfo,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
showSuccess,
|
|
|
|
|
|
showWarning,
|
|
|
|
|
|
stringToColor,
|
|
|
|
|
|
} from '../../../helpers';
|
2025-08-18 04:14:35 +08:00
|
|
|
|
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
2025-06-19 15:17:05 +08:00
|
|
|
|
import { DEFAULT_ENDPOINT } from '../../../constants';
|
2025-06-19 08:57:34 +08:00
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import {
|
|
|
|
|
|
IllustrationNoResult,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
IllustrationNoResultDark,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
} from '@douyinfe/semi-illustrations';
|
|
|
|
|
|
import ChannelSelectorModal from '../../../components/settings/ChannelSelectorModal';
|
|
|
|
|
|
|
2026-02-20 12:28:26 +08:00
|
|
|
|
const OFFICIAL_RATIO_PRESET_ID = -100;
|
|
|
|
|
|
const OFFICIAL_RATIO_PRESET_NAME = '官方倍率预设';
|
|
|
|
|
|
const OFFICIAL_RATIO_PRESET_BASE_URL = 'https://basellm.github.io';
|
|
|
|
|
|
const OFFICIAL_RATIO_PRESET_ENDPOINT =
|
|
|
|
|
|
'/llm-metadata/api/newapi/ratio_config-v1-base.json';
|
|
|
|
|
|
const MODELS_DEV_PRESET_ID = -101;
|
|
|
|
|
|
const MODELS_DEV_PRESET_NAME = 'models.dev 价格预设';
|
|
|
|
|
|
const MODELS_DEV_PRESET_BASE_URL = 'https://models.dev';
|
|
|
|
|
|
const MODELS_DEV_PRESET_ENDPOINT = 'https://models.dev/api.json';
|
|
|
|
|
|
|
2026-04-26 20:17:35 +08:00
|
|
|
|
function ConflictConfirmModal({ t, visible, items, loading, onOk, onCancel }) {
|
📱 refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
• Removed isMobile import.
• Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
• Layout: HeaderBar, PageLayout, SiderBar
• Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
• Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
• Unifies mobile detection with a React-friendly hook.
• Eliminates duplicated logic and improves maintainability.
• Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
const isMobile = useIsMobile();
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const columns = [
|
|
|
|
|
|
{ title: t('渠道'), dataIndex: 'channel' },
|
|
|
|
|
|
{ title: t('模型'), dataIndex: 'model' },
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('当前计费'),
|
|
|
|
|
|
dataIndex: 'current',
|
|
|
|
|
|
render: (text) => <div style={{ whiteSpace: 'pre-wrap' }}>{text}</div>,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('修改为'),
|
|
|
|
|
|
dataIndex: 'newVal',
|
|
|
|
|
|
render: (text) => <div style={{ whiteSpace: 'pre-wrap' }}>{text}</div>,
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
title={t('确认冲突项修改')}
|
|
|
|
|
|
visible={visible}
|
2026-04-26 20:17:35 +08:00
|
|
|
|
confirmLoading={loading}
|
|
|
|
|
|
cancelButtonProps={{ disabled: loading }}
|
|
|
|
|
|
maskClosable={!loading}
|
|
|
|
|
|
onCancel={loading ? undefined : onCancel}
|
2025-06-23 17:35:39 +08:00
|
|
|
|
onOk={onOk}
|
📱 refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
• Removed isMobile import.
• Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
• Layout: HeaderBar, PageLayout, SiderBar
• Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
• Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
• Unifies mobile detection with a React-friendly hook.
• Eliminates duplicated logic and improves maintainability.
• Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
size={isMobile ? 'full-width' : 'large'}
|
2025-06-23 17:35:39 +08:00
|
|
|
|
>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Table
|
|
|
|
|
|
columns={columns}
|
|
|
|
|
|
dataSource={items}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
/>
|
2025-06-23 17:35:39 +08:00
|
|
|
|
</Modal>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
export default function UpstreamRatioSync(props) {
|
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
const [modalVisible, setModalVisible] = useState(false);
|
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
|
const [syncLoading, setSyncLoading] = useState(false);
|
2026-04-26 20:17:35 +08:00
|
|
|
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
📱 refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
• Removed isMobile import.
• Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
• Layout: HeaderBar, PageLayout, SiderBar
• Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
• Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
• Unifies mobile detection with a React-friendly hook.
• Eliminates duplicated logic and improves maintainability.
• Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
const isMobile = useIsMobile();
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 渠道选择相关
|
|
|
|
|
|
const [allChannels, setAllChannels] = useState([]);
|
|
|
|
|
|
const [selectedChannelIds, setSelectedChannelIds] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
// 渠道端点配置
|
|
|
|
|
|
const [channelEndpoints, setChannelEndpoints] = useState({}); // { channelId: endpoint }
|
|
|
|
|
|
|
|
|
|
|
|
// 差异数据和测试结果
|
|
|
|
|
|
const [differences, setDifferences] = useState({});
|
|
|
|
|
|
const [resolutions, setResolutions] = useState({});
|
|
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
// 是否已经执行过同步
|
|
|
|
|
|
const [hasSynced, setHasSynced] = useState(false);
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
// 分页相关状态
|
|
|
|
|
|
const [currentPage, setCurrentPage] = useState(1);
|
|
|
|
|
|
const [pageSize, setPageSize] = useState(10);
|
|
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
// 搜索相关状态
|
|
|
|
|
|
const [searchKeyword, setSearchKeyword] = useState('');
|
|
|
|
|
|
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
// 倍率类型过滤
|
|
|
|
|
|
const [ratioTypeFilter, setRatioTypeFilter] = useState('');
|
|
|
|
|
|
|
2025-06-23 17:35:39 +08:00
|
|
|
|
// 冲突确认弹窗相关
|
|
|
|
|
|
const [confirmVisible, setConfirmVisible] = useState(false);
|
|
|
|
|
|
const [conflictItems, setConflictItems] = useState([]); // {channel, model, current, newVal, ratioType}
|
|
|
|
|
|
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
const channelSelectorRef = React.useRef(null);
|
|
|
|
|
|
|
2025-06-23 16:34:00 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
|
}, [ratioTypeFilter, searchKeyword]);
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const fetchAllChannels = async () => {
|
|
|
|
|
|
setLoading(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await API.get('/api/ratio_sync/channels');
|
|
|
|
|
|
|
|
|
|
|
|
if (res.data.success) {
|
|
|
|
|
|
const channels = res.data.data || [];
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const transferData = channels.map((channel) => ({
|
2025-06-19 08:57:34 +08:00
|
|
|
|
key: channel.id,
|
|
|
|
|
|
label: channel.name,
|
|
|
|
|
|
value: channel.id,
|
2025-06-19 18:38:43 +08:00
|
|
|
|
disabled: false,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
_originalData: channel,
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
setAllChannels(transferData);
|
|
|
|
|
|
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
// 合并已有 endpoints,避免每次打开弹窗都重置
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setChannelEndpoints((prev) => {
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
const merged = { ...prev };
|
2025-08-30 21:15:10 +08:00
|
|
|
|
transferData.forEach((channel) => {
|
2025-09-01 23:43:39 +08:00
|
|
|
|
const id = channel.key;
|
|
|
|
|
|
const base = channel._originalData?.base_url || '';
|
|
|
|
|
|
const name = channel.label || '';
|
2026-02-12 12:57:27 +08:00
|
|
|
|
const channelType = channel._originalData?.type;
|
2026-02-20 12:28:26 +08:00
|
|
|
|
const isOfficialRatioPreset =
|
|
|
|
|
|
id === OFFICIAL_RATIO_PRESET_ID ||
|
|
|
|
|
|
base === OFFICIAL_RATIO_PRESET_BASE_URL ||
|
|
|
|
|
|
name === OFFICIAL_RATIO_PRESET_NAME;
|
|
|
|
|
|
const isModelsDevPreset =
|
|
|
|
|
|
id === MODELS_DEV_PRESET_ID ||
|
|
|
|
|
|
base === MODELS_DEV_PRESET_BASE_URL ||
|
|
|
|
|
|
name === MODELS_DEV_PRESET_NAME;
|
2026-02-12 12:57:27 +08:00
|
|
|
|
const isOpenRouter = channelType === 20;
|
2025-09-01 23:43:39 +08:00
|
|
|
|
if (!merged[id]) {
|
2026-02-20 12:28:26 +08:00
|
|
|
|
if (isModelsDevPreset) {
|
|
|
|
|
|
merged[id] = MODELS_DEV_PRESET_ENDPOINT;
|
|
|
|
|
|
} else if (isOfficialRatioPreset) {
|
|
|
|
|
|
merged[id] = OFFICIAL_RATIO_PRESET_ENDPOINT;
|
2026-02-12 12:57:27 +08:00
|
|
|
|
} else if (isOpenRouter) {
|
|
|
|
|
|
merged[id] = 'openrouter';
|
|
|
|
|
|
} else {
|
|
|
|
|
|
merged[id] = DEFAULT_ENDPOINT;
|
|
|
|
|
|
}
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return merged;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showError(res.data.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(t('获取渠道失败:') + error.message);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const confirmChannelSelection = () => {
|
|
|
|
|
|
const selected = allChannels
|
2025-08-30 21:15:10 +08:00
|
|
|
|
.filter((ch) => selectedChannelIds.includes(ch.value))
|
|
|
|
|
|
.map((ch) => ch._originalData);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
if (selected.length === 0) {
|
|
|
|
|
|
showWarning(t('请至少选择一个渠道'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setModalVisible(false);
|
|
|
|
|
|
fetchRatiosFromChannels(selected);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fetchRatiosFromChannels = async (channelList) => {
|
|
|
|
|
|
setSyncLoading(true);
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const upstreams = channelList.map((ch) => ({
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
id: ch.id,
|
|
|
|
|
|
name: ch.name,
|
|
|
|
|
|
base_url: ch.base_url,
|
|
|
|
|
|
endpoint: channelEndpoints[ch.id] || DEFAULT_ENDPOINT,
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const payload = {
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
upstreams: upstreams,
|
2025-06-19 15:17:05 +08:00
|
|
|
|
timeout: 10,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await API.post('/api/ratio_sync/fetch', payload);
|
|
|
|
|
|
|
|
|
|
|
|
if (!res.data.success) {
|
|
|
|
|
|
showError(res.data.message || t('后端请求失败'));
|
|
|
|
|
|
setSyncLoading(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { differences = {}, test_results = [] } = res.data.data;
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const errorResults = test_results.filter((r) => r.status === 'error');
|
2025-06-19 08:57:34 +08:00
|
|
|
|
if (errorResults.length > 0) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
showWarning(
|
|
|
|
|
|
t('部分渠道测试失败:') +
|
|
|
|
|
|
errorResults.map((r) => `${r.name}: ${r.error}`).join(', '),
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setDifferences(differences);
|
|
|
|
|
|
setResolutions({});
|
2025-06-19 18:54:46 +08:00
|
|
|
|
setHasSynced(true);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
if (Object.keys(differences).length === 0) {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
showSuccess(t('未找到差异化价格,无需同步'));
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
showError(t('请求后端接口失败:') + e.message);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setSyncLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-04-26 20:17:35 +08:00
|
|
|
|
const ratioSyncFields = [
|
|
|
|
|
|
'model_ratio',
|
|
|
|
|
|
'completion_ratio',
|
|
|
|
|
|
'cache_ratio',
|
|
|
|
|
|
'create_cache_ratio',
|
|
|
|
|
|
'image_ratio',
|
|
|
|
|
|
'audio_ratio',
|
|
|
|
|
|
'audio_completion_ratio',
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const numericSyncFields = new Set([...ratioSyncFields, 'model_price']);
|
|
|
|
|
|
const syncFieldOrder = [
|
|
|
|
|
|
...ratioSyncFields,
|
|
|
|
|
|
'model_price',
|
|
|
|
|
|
'billing_mode',
|
|
|
|
|
|
'billing_expr',
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
function getSyncFieldLabel(ratioType) {
|
|
|
|
|
|
const typeMap = {
|
|
|
|
|
|
model_ratio: t('模型倍率'),
|
|
|
|
|
|
completion_ratio: t('补全倍率'),
|
|
|
|
|
|
cache_ratio: t('缓存倍率'),
|
|
|
|
|
|
create_cache_ratio: t('缓存创建倍率'),
|
|
|
|
|
|
image_ratio: t('图片倍率'),
|
|
|
|
|
|
audio_ratio: t('音频倍率'),
|
|
|
|
|
|
audio_completion_ratio: t('音频补全倍率'),
|
|
|
|
|
|
model_price: t('固定价格'),
|
|
|
|
|
|
billing_mode: t('计费模式'),
|
|
|
|
|
|
billing_expr: t('表达式计费'),
|
|
|
|
|
|
};
|
|
|
|
|
|
return typeMap[ratioType] || ratioType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getOrderedRatioTypes(ratioTypes) {
|
|
|
|
|
|
const keys = Object.keys(ratioTypes || {});
|
|
|
|
|
|
const ordered = [
|
|
|
|
|
|
...syncFieldOrder.filter((field) => keys.includes(field)),
|
|
|
|
|
|
...keys.filter((field) => !syncFieldOrder.includes(field)),
|
|
|
|
|
|
];
|
|
|
|
|
|
return ratioTypeFilter
|
|
|
|
|
|
? ordered.filter((field) => field === ratioTypeFilter)
|
|
|
|
|
|
: ordered;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function deleteResolutionField(newRes, model, ratioType) {
|
|
|
|
|
|
if (!newRes[model]) return;
|
|
|
|
|
|
delete newRes[model][ratioType];
|
|
|
|
|
|
if (ratioType === 'billing_expr') {
|
|
|
|
|
|
delete newRes[model].billing_mode;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ratioType === 'billing_mode') {
|
|
|
|
|
|
delete newRes[model].billing_expr;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Object.keys(newRes[model]).length === 0) {
|
|
|
|
|
|
delete newRes[model];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-23 17:35:39 +08:00
|
|
|
|
function getBillingCategory(ratioType) {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
if (ratioType === 'model_price') return 'price';
|
|
|
|
|
|
if (ratioType === 'billing_mode' || ratioType === 'billing_expr') {
|
|
|
|
|
|
return 'tiered';
|
|
|
|
|
|
}
|
|
|
|
|
|
return 'ratio';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function optionKeyBySyncField(ratioType) {
|
|
|
|
|
|
const explicit = {
|
|
|
|
|
|
billing_mode: 'billing_setting.billing_mode',
|
|
|
|
|
|
billing_expr: 'billing_setting.billing_expr',
|
|
|
|
|
|
};
|
|
|
|
|
|
if (explicit[ratioType]) return explicit[ratioType];
|
|
|
|
|
|
return ratioType
|
|
|
|
|
|
.split('_')
|
|
|
|
|
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
|
|
|
|
.join('');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getUpstreamValue(model, ratioType, sourceName) {
|
|
|
|
|
|
return differences[model]?.[ratioType]?.upstreams?.[sourceName];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isSelectableUpstreamValue(value) {
|
|
|
|
|
|
return value !== null && value !== undefined && value !== 'same';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getPreferredSyncField(model, ratioType, sourceName) {
|
|
|
|
|
|
const exprValue = getUpstreamValue(model, 'billing_expr', sourceName);
|
|
|
|
|
|
if (ratioType !== 'billing_expr' && isSelectableUpstreamValue(exprValue)) {
|
|
|
|
|
|
return 'billing_expr';
|
|
|
|
|
|
}
|
|
|
|
|
|
return ratioType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function shouldShowSyncField(model, ratioType, sourceName) {
|
|
|
|
|
|
if (!sourceName) return true;
|
|
|
|
|
|
return getPreferredSyncField(model, ratioType, sourceName) === ratioType;
|
2025-06-23 17:35:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const selectValue = useCallback(
|
2026-04-26 20:17:35 +08:00
|
|
|
|
(model, ratioType, value, sourceName) => {
|
|
|
|
|
|
const preferredRatioType = sourceName
|
|
|
|
|
|
? getPreferredSyncField(model, ratioType, sourceName)
|
|
|
|
|
|
: ratioType;
|
|
|
|
|
|
const preferredValue =
|
|
|
|
|
|
preferredRatioType === ratioType
|
|
|
|
|
|
? value
|
|
|
|
|
|
: getUpstreamValue(model, preferredRatioType, sourceName);
|
|
|
|
|
|
ratioType = preferredRatioType;
|
|
|
|
|
|
value = preferredValue;
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const category = getBillingCategory(ratioType);
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setResolutions((prev) => {
|
|
|
|
|
|
const newModelRes = { ...(prev[model] || {}) };
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
Object.keys(newModelRes).forEach((rt) => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
if (
|
|
|
|
|
|
category !== 'tiered' &&
|
|
|
|
|
|
getBillingCategory(rt) !== 'tiered' &&
|
|
|
|
|
|
getBillingCategory(rt) !== category
|
|
|
|
|
|
) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
delete newModelRes[rt];
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
newModelRes[ratioType] = value;
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2026-04-26 20:17:35 +08:00
|
|
|
|
if (category === 'tiered' && sourceName) {
|
|
|
|
|
|
const modeValue =
|
|
|
|
|
|
differences[model]?.billing_mode?.upstreams?.[sourceName];
|
|
|
|
|
|
const exprValue =
|
|
|
|
|
|
differences[model]?.billing_expr?.upstreams?.[sourceName];
|
|
|
|
|
|
if (
|
|
|
|
|
|
modeValue !== undefined &&
|
|
|
|
|
|
modeValue !== null &&
|
|
|
|
|
|
modeValue !== 'same'
|
|
|
|
|
|
) {
|
|
|
|
|
|
newModelRes.billing_mode = modeValue;
|
|
|
|
|
|
} else if (ratioType === 'billing_expr') {
|
|
|
|
|
|
newModelRes.billing_mode = 'tiered_expr';
|
|
|
|
|
|
}
|
|
|
|
|
|
if (
|
|
|
|
|
|
exprValue !== undefined &&
|
|
|
|
|
|
exprValue !== null &&
|
|
|
|
|
|
exprValue !== 'same'
|
|
|
|
|
|
) {
|
|
|
|
|
|
newModelRes.billing_expr = exprValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...prev,
|
|
|
|
|
|
[model]: newModelRes,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2026-04-26 20:17:35 +08:00
|
|
|
|
[setResolutions, differences],
|
2025-08-30 21:15:10 +08:00
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
const applySync = async () => {
|
|
|
|
|
|
const currentRatios = {
|
|
|
|
|
|
ModelRatio: JSON.parse(props.options.ModelRatio || '{}'),
|
|
|
|
|
|
CompletionRatio: JSON.parse(props.options.CompletionRatio || '{}'),
|
|
|
|
|
|
CacheRatio: JSON.parse(props.options.CacheRatio || '{}'),
|
2026-04-26 20:17:35 +08:00
|
|
|
|
CreateCacheRatio: JSON.parse(props.options.CreateCacheRatio || '{}'),
|
|
|
|
|
|
ImageRatio: JSON.parse(props.options.ImageRatio || '{}'),
|
|
|
|
|
|
AudioRatio: JSON.parse(props.options.AudioRatio || '{}'),
|
|
|
|
|
|
AudioCompletionRatio: JSON.parse(
|
|
|
|
|
|
props.options.AudioCompletionRatio || '{}',
|
|
|
|
|
|
),
|
2025-06-19 08:57:34 +08:00
|
|
|
|
ModelPrice: JSON.parse(props.options.ModelPrice || '{}'),
|
2026-04-26 20:17:35 +08:00
|
|
|
|
'billing_setting.billing_mode': JSON.parse(
|
|
|
|
|
|
props.options['billing_setting.billing_mode'] || '{}',
|
|
|
|
|
|
),
|
|
|
|
|
|
'billing_setting.billing_expr': JSON.parse(
|
|
|
|
|
|
props.options['billing_setting.billing_expr'] || '{}',
|
|
|
|
|
|
),
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const conflicts = [];
|
|
|
|
|
|
|
|
|
|
|
|
const getLocalBillingCategory = (model) => {
|
|
|
|
|
|
if (currentRatios.ModelPrice[model] !== undefined) return 'price';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (
|
|
|
|
|
|
currentRatios.ModelRatio[model] !== undefined ||
|
2025-06-23 17:35:39 +08:00
|
|
|
|
currentRatios.CompletionRatio[model] !== undefined ||
|
2026-04-26 20:17:35 +08:00
|
|
|
|
currentRatios.CacheRatio[model] !== undefined ||
|
|
|
|
|
|
currentRatios.CreateCacheRatio[model] !== undefined ||
|
|
|
|
|
|
currentRatios.ImageRatio[model] !== undefined ||
|
|
|
|
|
|
currentRatios.AudioRatio[model] !== undefined ||
|
|
|
|
|
|
currentRatios.AudioCompletionRatio[model] !== undefined
|
2025-08-30 21:15:10 +08:00
|
|
|
|
)
|
|
|
|
|
|
return 'ratio';
|
2025-06-23 17:35:39 +08:00
|
|
|
|
return null;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const findSourceChannel = (model, ratioType, value) => {
|
|
|
|
|
|
if (differences[model] && differences[model][ratioType]) {
|
|
|
|
|
|
const upMap = differences[model][ratioType].upstreams || {};
|
|
|
|
|
|
const entry = Object.entries(upMap).find(([_, v]) => v === value);
|
|
|
|
|
|
if (entry) return entry[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
return t('未知');
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Object.entries(resolutions).forEach(([model, ratios]) => {
|
|
|
|
|
|
const localCat = getLocalBillingCategory(model);
|
2026-04-26 20:17:35 +08:00
|
|
|
|
const newCat =
|
|
|
|
|
|
'model_price' in ratios
|
|
|
|
|
|
? 'price'
|
|
|
|
|
|
: ratioSyncFields.some((rt) => rt in ratios)
|
|
|
|
|
|
? 'ratio'
|
|
|
|
|
|
: 'tiered';
|
|
|
|
|
|
|
|
|
|
|
|
if (localCat && newCat !== 'tiered' && localCat !== newCat) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const currentDesc =
|
|
|
|
|
|
localCat === 'price'
|
|
|
|
|
|
? `${t('固定价格')} : ${currentRatios.ModelPrice[model]}`
|
|
|
|
|
|
: `${t('模型倍率')} : ${currentRatios.ModelRatio[model] ?? '-'}\n${t('补全倍率')} : ${currentRatios.CompletionRatio[model] ?? '-'}`;
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
|
|
|
|
|
let newDesc = '';
|
|
|
|
|
|
if (newCat === 'price') {
|
|
|
|
|
|
newDesc = `${t('固定价格')} : ${ratios['model_price']}`;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const newModelRatio = ratios['model_ratio'] ?? '-';
|
|
|
|
|
|
const newCompRatio = ratios['completion_ratio'] ?? '-';
|
|
|
|
|
|
newDesc = `${t('模型倍率')} : ${newModelRatio}\n${t('补全倍率')} : ${newCompRatio}`;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const channels = Object.entries(ratios)
|
|
|
|
|
|
.map(([rt, val]) => findSourceChannel(model, rt, val))
|
|
|
|
|
|
.filter((v, idx, arr) => arr.indexOf(v) === idx)
|
|
|
|
|
|
.join(', ');
|
|
|
|
|
|
|
|
|
|
|
|
conflicts.push({
|
|
|
|
|
|
channel: channels,
|
|
|
|
|
|
model,
|
|
|
|
|
|
current: currentDesc,
|
|
|
|
|
|
newVal: newDesc,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (conflicts.length > 0) {
|
|
|
|
|
|
setConflictItems(conflicts);
|
|
|
|
|
|
setConfirmVisible(true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await performSync(currentRatios);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const performSync = useCallback(
|
|
|
|
|
|
async (currentRatios) => {
|
|
|
|
|
|
const finalRatios = {
|
|
|
|
|
|
ModelRatio: { ...currentRatios.ModelRatio },
|
|
|
|
|
|
CompletionRatio: { ...currentRatios.CompletionRatio },
|
|
|
|
|
|
CacheRatio: { ...currentRatios.CacheRatio },
|
2026-04-26 20:17:35 +08:00
|
|
|
|
CreateCacheRatio: { ...currentRatios.CreateCacheRatio },
|
|
|
|
|
|
ImageRatio: { ...currentRatios.ImageRatio },
|
|
|
|
|
|
AudioRatio: { ...currentRatios.AudioRatio },
|
|
|
|
|
|
AudioCompletionRatio: { ...currentRatios.AudioCompletionRatio },
|
2025-08-30 21:15:10 +08:00
|
|
|
|
ModelPrice: { ...currentRatios.ModelPrice },
|
2026-04-26 20:17:35 +08:00
|
|
|
|
'billing_setting.billing_mode': {
|
|
|
|
|
|
...currentRatios['billing_setting.billing_mode'],
|
|
|
|
|
|
},
|
|
|
|
|
|
'billing_setting.billing_expr': {
|
|
|
|
|
|
...currentRatios['billing_setting.billing_expr'],
|
|
|
|
|
|
},
|
2025-08-30 21:15:10 +08:00
|
|
|
|
};
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
Object.entries(resolutions).forEach(([model, ratios]) => {
|
|
|
|
|
|
const selectedTypes = Object.keys(ratios);
|
|
|
|
|
|
const hasPrice = selectedTypes.includes('model_price');
|
2026-04-26 20:17:35 +08:00
|
|
|
|
const hasRatio = selectedTypes.some((rt) =>
|
|
|
|
|
|
ratioSyncFields.includes(rt),
|
|
|
|
|
|
);
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (hasPrice) {
|
|
|
|
|
|
delete finalRatios.ModelRatio[model];
|
|
|
|
|
|
delete finalRatios.CompletionRatio[model];
|
|
|
|
|
|
delete finalRatios.CacheRatio[model];
|
2026-04-26 20:17:35 +08:00
|
|
|
|
delete finalRatios.CreateCacheRatio[model];
|
|
|
|
|
|
delete finalRatios.ImageRatio[model];
|
|
|
|
|
|
delete finalRatios.AudioRatio[model];
|
|
|
|
|
|
delete finalRatios.AudioCompletionRatio[model];
|
2025-08-30 21:15:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (hasRatio) {
|
|
|
|
|
|
delete finalRatios.ModelPrice[model];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Object.entries(ratios).forEach(([ratioType, value]) => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
const optionKey = optionKeyBySyncField(ratioType);
|
|
|
|
|
|
finalRatios[optionKey][model] = numericSyncFields.has(ratioType)
|
|
|
|
|
|
? parseFloat(value)
|
|
|
|
|
|
: value;
|
2025-08-30 21:15:10 +08:00
|
|
|
|
});
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setLoading(true);
|
2026-04-26 20:17:35 +08:00
|
|
|
|
showInfo(t('正在同步价格,请稍候'));
|
|
|
|
|
|
let success = false;
|
2025-08-30 21:15:10 +08:00
|
|
|
|
try {
|
|
|
|
|
|
const updates = Object.entries(finalRatios).map(([key, value]) =>
|
|
|
|
|
|
API.put('/api/option/', {
|
|
|
|
|
|
key,
|
|
|
|
|
|
value: JSON.stringify(value, null, 2),
|
|
|
|
|
|
}),
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const results = await Promise.all(updates);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (results.every((res) => res.data.success)) {
|
|
|
|
|
|
showSuccess(t('同步成功'));
|
|
|
|
|
|
props.refresh();
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setDifferences((prevDifferences) => {
|
|
|
|
|
|
const newDifferences = { ...prevDifferences };
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
Object.entries(resolutions).forEach(([model, ratios]) => {
|
|
|
|
|
|
Object.keys(ratios).forEach((ratioType) => {
|
|
|
|
|
|
if (newDifferences[model] && newDifferences[model][ratioType]) {
|
|
|
|
|
|
delete newDifferences[model][ratioType];
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (Object.keys(newDifferences[model]).length === 0) {
|
|
|
|
|
|
delete newDifferences[model];
|
|
|
|
|
|
}
|
2025-06-19 18:38:43 +08:00
|
|
|
|
}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
});
|
2025-06-19 18:38:43 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return newDifferences;
|
|
|
|
|
|
});
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setResolutions({});
|
2026-04-26 20:17:35 +08:00
|
|
|
|
success = true;
|
2025-08-30 21:15:10 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
showError(t('部分保存失败'));
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(t('保存失败'));
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
2026-04-26 20:17:35 +08:00
|
|
|
|
return success;
|
2025-08-30 21:15:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
[resolutions, props.options, props.refresh],
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
const getCurrentPageData = (dataSource) => {
|
|
|
|
|
|
const startIndex = (currentPage - 1) * pageSize;
|
|
|
|
|
|
const endIndex = startIndex + pageSize;
|
|
|
|
|
|
return dataSource.slice(startIndex, endIndex);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const renderHeader = () => (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex flex-col w-full'>
|
|
|
|
|
|
<div className='flex flex-col md:flex-row justify-between items-center gap-4 w-full'>
|
|
|
|
|
|
<div className='flex flex-col md:flex-row gap-2 w-full md:w-auto order-2 md:order-1'>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
icon={<RefreshCcw size={14} />}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full md:w-auto mt-2'
|
2026-04-26 20:17:35 +08:00
|
|
|
|
disabled={loading || syncLoading || confirmLoading}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
onClick={() => {
|
|
|
|
|
|
setModalVisible(true);
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
if (allChannels.length === 0) {
|
|
|
|
|
|
fetchAllChannels();
|
|
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('选择同步渠道')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
|
|
{(() => {
|
|
|
|
|
|
const hasSelections = Object.keys(resolutions).length > 0;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
icon={<CheckSquare size={14} />}
|
|
|
|
|
|
type='secondary'
|
|
|
|
|
|
onClick={applySync}
|
2026-04-26 20:17:35 +08:00
|
|
|
|
loading={loading || confirmLoading}
|
|
|
|
|
|
disabled={
|
|
|
|
|
|
!hasSelections || loading || syncLoading || confirmLoading
|
|
|
|
|
|
}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full md:w-auto mt-2'
|
2025-06-19 08:57:34 +08:00
|
|
|
|
>
|
|
|
|
|
|
{t('应用同步')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
);
|
|
|
|
|
|
})()}
|
2025-06-19 18:54:46 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex flex-col sm:flex-row gap-2 w-full md:w-auto mt-2'>
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
<Input
|
|
|
|
|
|
prefix={<IconSearch size={14} />}
|
|
|
|
|
|
placeholder={t('搜索模型名称')}
|
|
|
|
|
|
value={searchKeyword}
|
|
|
|
|
|
onChange={setSearchKeyword}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full sm:w-64'
|
2026-04-26 20:17:35 +08:00
|
|
|
|
disabled={loading || syncLoading || confirmLoading}
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Select
|
2026-04-26 20:17:35 +08:00
|
|
|
|
placeholder={t('按价格字段筛选')}
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
value={ratioTypeFilter}
|
|
|
|
|
|
onChange={setRatioTypeFilter}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full sm:w-48'
|
2026-04-26 20:17:35 +08:00
|
|
|
|
disabled={loading || syncLoading || confirmLoading}
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
onClear={() => setRatioTypeFilter('')}
|
|
|
|
|
|
>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Select.Option value='model_ratio'>{t('模型倍率')}</Select.Option>
|
|
|
|
|
|
<Select.Option value='completion_ratio'>
|
|
|
|
|
|
{t('补全倍率')}
|
|
|
|
|
|
</Select.Option>
|
|
|
|
|
|
<Select.Option value='cache_ratio'>{t('缓存倍率')}</Select.Option>
|
2026-04-26 20:17:35 +08:00
|
|
|
|
<Select.Option value='create_cache_ratio'>
|
|
|
|
|
|
{t('缓存创建倍率')}
|
|
|
|
|
|
</Select.Option>
|
|
|
|
|
|
<Select.Option value='image_ratio'>{t('图片倍率')}</Select.Option>
|
|
|
|
|
|
<Select.Option value='audio_ratio'>{t('音频倍率')}</Select.Option>
|
|
|
|
|
|
<Select.Option value='audio_completion_ratio'>
|
|
|
|
|
|
{t('音频补全倍率')}
|
|
|
|
|
|
</Select.Option>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Select.Option value='model_price'>{t('固定价格')}</Select.Option>
|
2026-04-26 20:17:35 +08:00
|
|
|
|
<Select.Option value='billing_expr'>
|
|
|
|
|
|
{t('表达式计费')}
|
|
|
|
|
|
</Select.Option>
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
</Select>
|
|
|
|
|
|
</div>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const renderDifferenceTable = () => {
|
|
|
|
|
|
const dataSource = useMemo(() => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
return Object.entries(differences).map(([model, ratioTypes]) => {
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const hasPrice = 'model_price' in ratioTypes;
|
2026-04-26 20:17:35 +08:00
|
|
|
|
const hasOtherRatio = ratioSyncFields.some((rt) => rt in ratioTypes);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2026-04-26 20:17:35 +08:00
|
|
|
|
return {
|
|
|
|
|
|
key: model,
|
|
|
|
|
|
model,
|
|
|
|
|
|
ratioTypes,
|
|
|
|
|
|
billingConflict: hasPrice && hasOtherRatio,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}, [differences]);
|
|
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
const filteredDataSource = useMemo(() => {
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
if (!searchKeyword.trim() && !ratioTypeFilter) {
|
2025-06-19 18:54:46 +08:00
|
|
|
|
return dataSource;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return dataSource.filter((item) => {
|
|
|
|
|
|
const matchesKeyword =
|
|
|
|
|
|
!searchKeyword.trim() ||
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
item.model.toLowerCase().includes(searchKeyword.toLowerCase().trim());
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const matchesRatioType =
|
2026-04-26 20:17:35 +08:00
|
|
|
|
!ratioTypeFilter || ratioTypeFilter in item.ratioTypes;
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
|
|
|
|
|
|
return matchesKeyword && matchesRatioType;
|
|
|
|
|
|
});
|
|
|
|
|
|
}, [dataSource, searchKeyword, ratioTypeFilter]);
|
2025-06-19 18:54:46 +08:00
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const upstreamNames = useMemo(() => {
|
|
|
|
|
|
const set = new Set();
|
2025-06-19 18:54:46 +08:00
|
|
|
|
filteredDataSource.forEach((row) => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
getOrderedRatioTypes(row.ratioTypes).forEach((ratioType) => {
|
|
|
|
|
|
Object.keys(row.ratioTypes[ratioType]?.upstreams || {}).forEach(
|
|
|
|
|
|
(name) => set.add(name),
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
return Array.from(set);
|
2026-04-26 20:17:35 +08:00
|
|
|
|
}, [filteredDataSource, ratioTypeFilter]);
|
|
|
|
|
|
|
|
|
|
|
|
const renderValueTag = (value, color = 'default') => {
|
|
|
|
|
|
if (value === null || value === undefined) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Tag color='default' shape='circle'>
|
|
|
|
|
|
{t('未设置')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const text = String(value);
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Tooltip content={text}>
|
|
|
|
|
|
<Tag color={color} shape='circle'>
|
|
|
|
|
|
<span className='inline-block max-w-[360px] truncate align-bottom'>
|
|
|
|
|
|
{text}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const renderCurrentFields = (record) => {
|
|
|
|
|
|
const fields = getOrderedRatioTypes(record.ratioTypes);
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className='flex min-w-[260px] flex-col gap-2'>
|
|
|
|
|
|
{fields.map((ratioType) => (
|
|
|
|
|
|
<div
|
|
|
|
|
|
key={ratioType}
|
|
|
|
|
|
className='flex min-w-0 flex-wrap items-center gap-2'
|
|
|
|
|
|
>
|
|
|
|
|
|
<Tag color={stringToColor(ratioType)} shape='circle'>
|
|
|
|
|
|
{getSyncFieldLabel(ratioType)}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
{renderValueTag(record.ratioTypes[ratioType]?.current, 'blue')}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const renderUpstreamField = (record, ratioType, upName) => {
|
|
|
|
|
|
const diff = record.ratioTypes[ratioType] || {};
|
|
|
|
|
|
const upstreamVal = diff.upstreams?.[upName];
|
|
|
|
|
|
const isConfident = diff.confidence?.[upName] !== false;
|
|
|
|
|
|
const isPreferredField =
|
|
|
|
|
|
getPreferredSyncField(record.model, ratioType, upName) === ratioType;
|
|
|
|
|
|
|
|
|
|
|
|
if (upstreamVal === null || upstreamVal === undefined) {
|
|
|
|
|
|
return renderValueTag(undefined);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (upstreamVal === 'same') {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Tag color='blue' shape='circle'>
|
|
|
|
|
|
{t('与本地相同')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const text = String(upstreamVal);
|
|
|
|
|
|
const isSelected =
|
|
|
|
|
|
isPreferredField &&
|
|
|
|
|
|
resolutions[record.model]?.[ratioType] === upstreamVal;
|
|
|
|
|
|
const valueNode = isPreferredField ? (
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
|
checked={isSelected}
|
|
|
|
|
|
disabled={loading || syncLoading || confirmLoading}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
const isChecked = e.target.checked;
|
|
|
|
|
|
if (isChecked) {
|
|
|
|
|
|
selectValue(record.model, ratioType, upstreamVal, upName);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setResolutions((prev) => {
|
|
|
|
|
|
const newRes = { ...prev };
|
|
|
|
|
|
deleteResolutionField(newRes, record.model, ratioType);
|
|
|
|
|
|
return newRes;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Tooltip content={text}>
|
|
|
|
|
|
<span className='inline-block max-w-[360px] truncate align-bottom'>
|
|
|
|
|
|
{text}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
</Checkbox>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Tooltip content={text}>
|
|
|
|
|
|
<Tag color='default' shape='circle' type='light'>
|
|
|
|
|
|
<span className='inline-block max-w-[360px] truncate align-bottom'>
|
|
|
|
|
|
{text}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className='flex min-w-0 items-center gap-2'>
|
|
|
|
|
|
{valueNode}
|
|
|
|
|
|
{!isConfident && (
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
|
position='left'
|
|
|
|
|
|
content={t('该数据可能不可信,请谨慎使用')}
|
|
|
|
|
|
>
|
|
|
|
|
|
<AlertTriangle size={16} className='shrink-0 text-yellow-500' />
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const renderUpstreamFields = (record, upName) => {
|
|
|
|
|
|
const fields = getOrderedRatioTypes(record.ratioTypes).filter(
|
|
|
|
|
|
(ratioType) => shouldShowSyncField(record.model, ratioType, upName),
|
|
|
|
|
|
);
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className='flex min-w-[280px] flex-col gap-2'>
|
|
|
|
|
|
{fields.map((ratioType) => (
|
|
|
|
|
|
<div key={ratioType} className='flex min-w-0 items-start gap-2'>
|
|
|
|
|
|
<Tag
|
|
|
|
|
|
color={stringToColor(ratioType)}
|
|
|
|
|
|
shape='circle'
|
|
|
|
|
|
className='shrink-0'
|
|
|
|
|
|
>
|
|
|
|
|
|
{getSyncFieldLabel(ratioType)}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
<div className='min-w-0 flex-1'>
|
|
|
|
|
|
{renderUpstreamField(record, ratioType, upName)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
if (filteredDataSource.length === 0) {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
if (syncLoading) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className='flex min-h-[260px] flex-col items-center justify-center gap-3'>
|
|
|
|
|
|
<Spin size='large' />
|
|
|
|
|
|
<div className='text-sm text-gray-500'>
|
|
|
|
|
|
{t('正在同步上游价格,请稍候')}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Empty
|
|
|
|
|
|
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
darkModeImage={
|
|
|
|
|
|
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
|
|
|
|
|
}
|
2025-06-19 18:54:46 +08:00
|
|
|
|
description={
|
|
|
|
|
|
searchKeyword.trim()
|
|
|
|
|
|
? t('未找到匹配的模型')
|
2025-08-30 21:15:10 +08:00
|
|
|
|
: Object.keys(differences).length === 0
|
|
|
|
|
|
? hasSynced
|
2026-04-26 20:17:35 +08:00
|
|
|
|
? t('暂无差异化价格显示')
|
2025-08-30 21:15:10 +08:00
|
|
|
|
: t('请先选择同步渠道')
|
|
|
|
|
|
: t('请先选择同步渠道')
|
2025-06-19 18:54:46 +08:00
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
style={{ padding: 30 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('模型'),
|
|
|
|
|
|
dataIndex: 'model',
|
|
|
|
|
|
fixed: 'left',
|
2026-04-26 20:17:35 +08:00
|
|
|
|
render: (text, record) => (
|
|
|
|
|
|
<div className='flex min-w-[180px] items-center gap-2'>
|
|
|
|
|
|
<span className='font-medium'>{text}</span>
|
|
|
|
|
|
{record.billingConflict && (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Tooltip
|
2026-04-26 20:17:35 +08:00
|
|
|
|
position='top'
|
|
|
|
|
|
content={t('该模型存在固定价格与倍率计费方式冲突,请确认选择')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
>
|
2026-04-26 20:17:35 +08:00
|
|
|
|
<AlertTriangle size={14} className='shrink-0 text-yellow-500' />
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
</Tooltip>
|
2026-04-26 20:17:35 +08:00
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
),
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
},
|
2025-06-19 08:57:34 +08:00
|
|
|
|
{
|
2026-04-26 20:17:35 +08:00
|
|
|
|
title: t('当前价格'),
|
2025-06-19 08:57:34 +08:00
|
|
|
|
dataIndex: 'current',
|
2026-04-26 20:17:35 +08:00
|
|
|
|
render: (_, record) => renderCurrentFields(record),
|
2025-06-19 08:57:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
...upstreamNames.map((upName) => {
|
|
|
|
|
|
const channelStats = (() => {
|
2025-06-19 18:38:43 +08:00
|
|
|
|
let selectableCount = 0;
|
|
|
|
|
|
let selectedCount = 0;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
filteredDataSource.forEach((row) => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
getOrderedRatioTypes(row.ratioTypes).forEach((ratioType) => {
|
|
|
|
|
|
const upstreamVal =
|
|
|
|
|
|
row.ratioTypes[ratioType]?.upstreams?.[upName];
|
|
|
|
|
|
if (
|
|
|
|
|
|
getPreferredSyncField(row.model, ratioType, upName) ===
|
|
|
|
|
|
ratioType &&
|
|
|
|
|
|
isSelectableUpstreamValue(upstreamVal)
|
|
|
|
|
|
) {
|
|
|
|
|
|
selectableCount++;
|
|
|
|
|
|
if (resolutions[row.model]?.[ratioType] === upstreamVal) {
|
|
|
|
|
|
selectedCount++;
|
|
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
2026-04-26 20:17:35 +08:00
|
|
|
|
});
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
selectableCount,
|
|
|
|
|
|
selectedCount,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
allSelected:
|
|
|
|
|
|
selectableCount > 0 && selectedCount === selectableCount,
|
|
|
|
|
|
partiallySelected:
|
|
|
|
|
|
selectedCount > 0 && selectedCount < selectableCount,
|
|
|
|
|
|
hasSelectableItems: selectableCount > 0,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
const handleBulkSelect = (checked) => {
|
2025-06-23 17:35:39 +08:00
|
|
|
|
if (checked) {
|
2025-06-19 18:54:46 +08:00
|
|
|
|
filteredDataSource.forEach((row) => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
getOrderedRatioTypes(row.ratioTypes).forEach((ratioType) => {
|
|
|
|
|
|
const upstreamVal =
|
|
|
|
|
|
row.ratioTypes[ratioType]?.upstreams?.[upName];
|
|
|
|
|
|
if (
|
|
|
|
|
|
getPreferredSyncField(row.model, ratioType, upName) ===
|
|
|
|
|
|
ratioType &&
|
|
|
|
|
|
isSelectableUpstreamValue(upstreamVal)
|
|
|
|
|
|
) {
|
|
|
|
|
|
selectValue(row.model, ratioType, upstreamVal, upName);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-06-23 17:35:39 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setResolutions((prev) => {
|
|
|
|
|
|
const newRes = { ...prev };
|
|
|
|
|
|
filteredDataSource.forEach((row) => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
getOrderedRatioTypes(row.ratioTypes).forEach((ratioType) => {
|
|
|
|
|
|
if (
|
|
|
|
|
|
row.ratioTypes[ratioType]?.upstreams?.[upName] !== undefined
|
|
|
|
|
|
) {
|
|
|
|
|
|
deleteResolutionField(newRes, row.model, ratioType);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
2026-04-26 20:17:35 +08:00
|
|
|
|
});
|
2025-06-23 17:35:39 +08:00
|
|
|
|
});
|
|
|
|
|
|
return newRes;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
2025-06-23 17:35:39 +08:00
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
title: channelStats.hasSelectableItems ? (
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
|
checked={channelStats.allSelected}
|
|
|
|
|
|
indeterminate={channelStats.partiallySelected}
|
2026-04-26 20:17:35 +08:00
|
|
|
|
disabled={loading || syncLoading || confirmLoading}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
onChange={(e) => handleBulkSelect(e.target.checked)}
|
|
|
|
|
|
>
|
|
|
|
|
|
{upName}
|
|
|
|
|
|
</Checkbox>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<span>{upName}</span>
|
|
|
|
|
|
),
|
|
|
|
|
|
dataIndex: upName,
|
2026-04-26 20:17:35 +08:00
|
|
|
|
render: (_, record) => renderUpstreamFields(record, upName),
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
}),
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Table
|
|
|
|
|
|
columns={columns}
|
2025-06-19 18:54:46 +08:00
|
|
|
|
dataSource={getCurrentPageData(filteredDataSource)}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
pagination={{
|
|
|
|
|
|
currentPage: currentPage,
|
|
|
|
|
|
pageSize: pageSize,
|
2025-06-19 18:54:46 +08:00
|
|
|
|
total: filteredDataSource.length,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
showSizeChanger: true,
|
|
|
|
|
|
showQuickJumper: true,
|
|
|
|
|
|
pageSizeOptions: ['5', '10', '20', '50'],
|
|
|
|
|
|
onChange: (page, size) => {
|
|
|
|
|
|
setCurrentPage(page);
|
|
|
|
|
|
setPageSize(size);
|
|
|
|
|
|
},
|
|
|
|
|
|
onShowSizeChange: (current, size) => {
|
|
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
|
setPageSize(size);
|
2025-08-30 21:15:10 +08:00
|
|
|
|
},
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}}
|
|
|
|
|
|
scroll={{ x: 'max-content' }}
|
|
|
|
|
|
size='middle'
|
|
|
|
|
|
loading={loading || syncLoading}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const updateChannelEndpoint = useCallback((channelId, endpoint) => {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setChannelEndpoints((prev) => ({ ...prev, [channelId]: endpoint }));
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}, []);
|
|
|
|
|
|
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
const handleModalClose = () => {
|
|
|
|
|
|
setModalVisible(false);
|
|
|
|
|
|
if (channelSelectorRef.current) {
|
|
|
|
|
|
channelSelectorRef.current.resetPagination();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Form.Section text={renderHeader()}>
|
|
|
|
|
|
{renderDifferenceTable()}
|
|
|
|
|
|
</Form.Section>
|
|
|
|
|
|
|
|
|
|
|
|
<ChannelSelectorModal
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
ref={channelSelectorRef}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
t={t}
|
|
|
|
|
|
visible={modalVisible}
|
✨ feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
• Parse /api/pricing response and convert to ratio / price maps.
• Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
• Include confidence map when building differences and filter “same”/empty entries.
- dto/ratio_sync.go
• Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
• Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
• Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
• Leverage ChannelSelectorModal’s pagination reset.
- ChannelsTable.js – fix tag color for disabled status.
- en.json – add translations for new UI labels.
Motivation
These changes let users sync model ratios / prices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
onCancel={handleModalClose}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
onOk={confirmChannelSelection}
|
|
|
|
|
|
allChannels={allChannels}
|
|
|
|
|
|
selectedChannelIds={selectedChannelIds}
|
|
|
|
|
|
setSelectedChannelIds={setSelectedChannelIds}
|
|
|
|
|
|
channelEndpoints={channelEndpoints}
|
|
|
|
|
|
updateChannelEndpoint={updateChannelEndpoint}
|
|
|
|
|
|
/>
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
|
|
|
|
|
<ConflictConfirmModal
|
|
|
|
|
|
t={t}
|
|
|
|
|
|
visible={confirmVisible}
|
|
|
|
|
|
items={conflictItems}
|
2026-04-26 20:17:35 +08:00
|
|
|
|
loading={confirmLoading}
|
2025-06-23 17:35:39 +08:00
|
|
|
|
onOk={async () => {
|
2026-04-26 20:17:35 +08:00
|
|
|
|
setConfirmLoading(true);
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const curRatios = {
|
|
|
|
|
|
ModelRatio: JSON.parse(props.options.ModelRatio || '{}'),
|
|
|
|
|
|
CompletionRatio: JSON.parse(props.options.CompletionRatio || '{}'),
|
|
|
|
|
|
CacheRatio: JSON.parse(props.options.CacheRatio || '{}'),
|
2026-04-26 20:17:35 +08:00
|
|
|
|
CreateCacheRatio: JSON.parse(
|
|
|
|
|
|
props.options.CreateCacheRatio || '{}',
|
|
|
|
|
|
),
|
|
|
|
|
|
ImageRatio: JSON.parse(props.options.ImageRatio || '{}'),
|
|
|
|
|
|
AudioRatio: JSON.parse(props.options.AudioRatio || '{}'),
|
|
|
|
|
|
AudioCompletionRatio: JSON.parse(
|
|
|
|
|
|
props.options.AudioCompletionRatio || '{}',
|
|
|
|
|
|
),
|
2025-06-23 17:35:39 +08:00
|
|
|
|
ModelPrice: JSON.parse(props.options.ModelPrice || '{}'),
|
2026-04-26 20:17:35 +08:00
|
|
|
|
'billing_setting.billing_mode': JSON.parse(
|
|
|
|
|
|
props.options['billing_setting.billing_mode'] || '{}',
|
|
|
|
|
|
),
|
|
|
|
|
|
'billing_setting.billing_expr': JSON.parse(
|
|
|
|
|
|
props.options['billing_setting.billing_expr'] || '{}',
|
|
|
|
|
|
),
|
2025-06-23 17:35:39 +08:00
|
|
|
|
};
|
2026-04-26 20:17:35 +08:00
|
|
|
|
try {
|
|
|
|
|
|
const success = await performSync(curRatios);
|
|
|
|
|
|
if (success) {
|
|
|
|
|
|
setConfirmVisible(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setConfirmLoading(false);
|
|
|
|
|
|
}
|
2025-06-23 17:35:39 +08:00
|
|
|
|
}}
|
|
|
|
|
|
onCancel={() => setConfirmVisible(false)}
|
|
|
|
|
|
/>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
</>
|
|
|
|
|
|
);
|
2025-08-30 21:15:10 +08:00
|
|
|
|
}
|