|
@@ -25,9 +25,13 @@ import {
|
|
|
showInfo,
|
|
showInfo,
|
|
|
showSuccess,
|
|
showSuccess,
|
|
|
loadChannelModels,
|
|
loadChannelModels,
|
|
|
- copy
|
|
|
|
|
|
|
+ copy,
|
|
|
} from '../../helpers';
|
|
} from '../../helpers';
|
|
|
-import { CHANNEL_OPTIONS, ITEMS_PER_PAGE, MODEL_TABLE_PAGE_SIZE } from '../../constants';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ CHANNEL_OPTIONS,
|
|
|
|
|
+ ITEMS_PER_PAGE,
|
|
|
|
|
+ MODEL_TABLE_PAGE_SIZE,
|
|
|
|
|
+} from '../../constants';
|
|
|
import { useIsMobile } from '../common/useIsMobile';
|
|
import { useIsMobile } from '../common/useIsMobile';
|
|
|
import { useTableCompactMode } from '../common/useTableCompactMode';
|
|
import { useTableCompactMode } from '../common/useTableCompactMode';
|
|
|
import { Modal } from '@douyinfe/semi-ui';
|
|
import { Modal } from '@douyinfe/semi-ui';
|
|
@@ -64,7 +68,7 @@ export const useChannelsData = () => {
|
|
|
|
|
|
|
|
// Status filter
|
|
// Status filter
|
|
|
const [statusFilter, setStatusFilter] = useState(
|
|
const [statusFilter, setStatusFilter] = useState(
|
|
|
- localStorage.getItem('channel-status-filter') || 'all'
|
|
|
|
|
|
|
+ localStorage.getItem('channel-status-filter') || 'all',
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// Type tabs states
|
|
// Type tabs states
|
|
@@ -80,8 +84,8 @@ export const useChannelsData = () => {
|
|
|
const [selectedModelKeys, setSelectedModelKeys] = useState([]);
|
|
const [selectedModelKeys, setSelectedModelKeys] = useState([]);
|
|
|
const [isBatchTesting, setIsBatchTesting] = useState(false);
|
|
const [isBatchTesting, setIsBatchTesting] = useState(false);
|
|
|
const [modelTablePage, setModelTablePage] = useState(1);
|
|
const [modelTablePage, setModelTablePage] = useState(1);
|
|
|
- const [selectedEndpointType, setSelectedEndpointType] = useState('');
|
|
|
|
|
-
|
|
|
|
|
|
|
+const [selectedEndpointType, setSelectedEndpointType] = useState('');
|
|
|
|
|
+
|
|
|
// 使用 ref 来避免闭包问题,类似旧版实现
|
|
// 使用 ref 来避免闭包问题,类似旧版实现
|
|
|
const shouldStopBatchTestingRef = useRef(false);
|
|
const shouldStopBatchTestingRef = useRef(false);
|
|
|
|
|
|
|
@@ -117,9 +121,12 @@ export const useChannelsData = () => {
|
|
|
// Initialize from localStorage
|
|
// Initialize from localStorage
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const localIdSort = localStorage.getItem('id-sort') === 'true';
|
|
const localIdSort = localStorage.getItem('id-sort') === 'true';
|
|
|
- const localPageSize = parseInt(localStorage.getItem('page-size')) || ITEMS_PER_PAGE;
|
|
|
|
|
- const localEnableTagMode = localStorage.getItem('enable-tag-mode') === 'true';
|
|
|
|
|
- const localEnableBatchDelete = localStorage.getItem('enable-batch-delete') === 'true';
|
|
|
|
|
|
|
+ const localPageSize =
|
|
|
|
|
+ parseInt(localStorage.getItem('page-size')) || ITEMS_PER_PAGE;
|
|
|
|
|
+ const localEnableTagMode =
|
|
|
|
|
+ localStorage.getItem('enable-tag-mode') === 'true';
|
|
|
|
|
+ const localEnableBatchDelete =
|
|
|
|
|
+ localStorage.getItem('enable-batch-delete') === 'true';
|
|
|
|
|
|
|
|
setIdSort(localIdSort);
|
|
setIdSort(localIdSort);
|
|
|
setPageSize(localPageSize);
|
|
setPageSize(localPageSize);
|
|
@@ -177,7 +184,10 @@ export const useChannelsData = () => {
|
|
|
// Save column preferences
|
|
// Save column preferences
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (Object.keys(visibleColumns).length > 0) {
|
|
if (Object.keys(visibleColumns).length > 0) {
|
|
|
- localStorage.setItem('channels-table-columns', JSON.stringify(visibleColumns));
|
|
|
|
|
|
|
+ localStorage.setItem(
|
|
|
|
|
+ 'channels-table-columns',
|
|
|
|
|
+ JSON.stringify(visibleColumns),
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
}, [visibleColumns]);
|
|
}, [visibleColumns]);
|
|
|
|
|
|
|
@@ -291,14 +301,21 @@ export const useChannelsData = () => {
|
|
|
const { searchKeyword, searchGroup, searchModel } = getFormValues();
|
|
const { searchKeyword, searchGroup, searchModel } = getFormValues();
|
|
|
if (searchKeyword !== '' || searchGroup !== '' || searchModel !== '') {
|
|
if (searchKeyword !== '' || searchGroup !== '' || searchModel !== '') {
|
|
|
setLoading(true);
|
|
setLoading(true);
|
|
|
- await searchChannels(enableTagMode, typeKey, statusF, page, pageSize, idSort);
|
|
|
|
|
|
|
+ await searchChannels(
|
|
|
|
|
+ enableTagMode,
|
|
|
|
|
+ typeKey,
|
|
|
|
|
+ statusF,
|
|
|
|
|
+ page,
|
|
|
|
|
+ pageSize,
|
|
|
|
|
+ idSort,
|
|
|
|
|
+ );
|
|
|
setLoading(false);
|
|
setLoading(false);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const reqId = ++requestCounter.current;
|
|
const reqId = ++requestCounter.current;
|
|
|
setLoading(true);
|
|
setLoading(true);
|
|
|
- const typeParam = (typeKey !== 'all') ? `&type=${typeKey}` : '';
|
|
|
|
|
|
|
+ const typeParam = typeKey !== 'all' ? `&type=${typeKey}` : '';
|
|
|
const statusParam = statusF !== 'all' ? `&status=${statusF}` : '';
|
|
const statusParam = statusF !== 'all' ? `&status=${statusF}` : '';
|
|
|
const res = await API.get(
|
|
const res = await API.get(
|
|
|
`/api/channel/?p=${page}&page_size=${pageSize}&id_sort=${idSort}&tag_mode=${enableTagMode}${typeParam}${statusParam}`,
|
|
`/api/channel/?p=${page}&page_size=${pageSize}&id_sort=${idSort}&tag_mode=${enableTagMode}${typeParam}${statusParam}`,
|
|
@@ -312,7 +329,10 @@ export const useChannelsData = () => {
|
|
|
if (success) {
|
|
if (success) {
|
|
|
const { items, total, type_counts } = data;
|
|
const { items, total, type_counts } = data;
|
|
|
if (type_counts) {
|
|
if (type_counts) {
|
|
|
- const sumAll = Object.values(type_counts).reduce((acc, v) => acc + v, 0);
|
|
|
|
|
|
|
+ const sumAll = Object.values(type_counts).reduce(
|
|
|
|
|
+ (acc, v) => acc + v,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ );
|
|
|
setTypeCounts({ ...type_counts, all: sumAll });
|
|
setTypeCounts({ ...type_counts, all: sumAll });
|
|
|
}
|
|
}
|
|
|
setChannelFormat(items, enableTagMode);
|
|
setChannelFormat(items, enableTagMode);
|
|
@@ -336,11 +356,18 @@ export const useChannelsData = () => {
|
|
|
setSearching(true);
|
|
setSearching(true);
|
|
|
try {
|
|
try {
|
|
|
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
|
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
|
|
- await loadChannels(page, pageSz, sortFlag, enableTagMode, typeKey, statusF);
|
|
|
|
|
|
|
+ await loadChannels(
|
|
|
|
|
+ page,
|
|
|
|
|
+ pageSz,
|
|
|
|
|
+ sortFlag,
|
|
|
|
|
+ enableTagMode,
|
|
|
|
|
+ typeKey,
|
|
|
|
|
+ statusF,
|
|
|
|
|
+ );
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const typeParam = (typeKey !== 'all') ? `&type=${typeKey}` : '';
|
|
|
|
|
|
|
+ const typeParam = typeKey !== 'all' ? `&type=${typeKey}` : '';
|
|
|
const statusParam = statusF !== 'all' ? `&status=${statusF}` : '';
|
|
const statusParam = statusF !== 'all' ? `&status=${statusF}` : '';
|
|
|
const res = await API.get(
|
|
const res = await API.get(
|
|
|
`/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}&id_sort=${sortFlag}&tag_mode=${enableTagMode}&p=${page}&page_size=${pageSz}${typeParam}${statusParam}`,
|
|
`/api/channel/search?keyword=${searchKeyword}&group=${searchGroup}&model=${searchModel}&id_sort=${sortFlag}&tag_mode=${enableTagMode}&p=${page}&page_size=${pageSz}${typeParam}${statusParam}`,
|
|
@@ -348,7 +375,10 @@ export const useChannelsData = () => {
|
|
|
const { success, message, data } = res.data;
|
|
const { success, message, data } = res.data;
|
|
|
if (success) {
|
|
if (success) {
|
|
|
const { items = [], total = 0, type_counts = {} } = data;
|
|
const { items = [], total = 0, type_counts = {} } = data;
|
|
|
- const sumAll = Object.values(type_counts).reduce((acc, v) => acc + v, 0);
|
|
|
|
|
|
|
+ const sumAll = Object.values(type_counts).reduce(
|
|
|
|
|
+ (acc, v) => acc + v,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ );
|
|
|
setTypeCounts({ ...type_counts, all: sumAll });
|
|
setTypeCounts({ ...type_counts, all: sumAll });
|
|
|
setChannelFormat(items, enableTagMode);
|
|
setChannelFormat(items, enableTagMode);
|
|
|
setChannelCount(total);
|
|
setChannelCount(total);
|
|
@@ -367,7 +397,14 @@ export const useChannelsData = () => {
|
|
|
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
|
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
|
|
await loadChannels(page, pageSize, idSort, enableTagMode);
|
|
await loadChannels(page, pageSize, idSort, enableTagMode);
|
|
|
} else {
|
|
} else {
|
|
|
- await searchChannels(enableTagMode, activeTypeKey, statusFilter, page, pageSize, idSort);
|
|
|
|
|
|
|
+ await searchChannels(
|
|
|
|
|
+ enableTagMode,
|
|
|
|
|
+ activeTypeKey,
|
|
|
|
|
+ statusFilter,
|
|
|
|
|
+ page,
|
|
|
|
|
+ pageSize,
|
|
|
|
|
+ idSort,
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -453,9 +490,16 @@ export const useChannelsData = () => {
|
|
|
const { searchKeyword, searchGroup, searchModel } = getFormValues();
|
|
const { searchKeyword, searchGroup, searchModel } = getFormValues();
|
|
|
setActivePage(page);
|
|
setActivePage(page);
|
|
|
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
|
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
|
|
- loadChannels(page, pageSize, idSort, enableTagMode).then(() => { });
|
|
|
|
|
|
|
+ loadChannels(page, pageSize, idSort, enableTagMode).then(() => {});
|
|
|
} else {
|
|
} else {
|
|
|
- searchChannels(enableTagMode, activeTypeKey, statusFilter, page, pageSize, idSort);
|
|
|
|
|
|
|
+ searchChannels(
|
|
|
|
|
+ enableTagMode,
|
|
|
|
|
+ activeTypeKey,
|
|
|
|
|
+ statusFilter,
|
|
|
|
|
+ page,
|
|
|
|
|
+ pageSize,
|
|
|
|
|
+ idSort,
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -471,7 +515,14 @@ export const useChannelsData = () => {
|
|
|
showError(reason);
|
|
showError(reason);
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
- searchChannels(enableTagMode, activeTypeKey, statusFilter, 1, size, idSort);
|
|
|
|
|
|
|
+ searchChannels(
|
|
|
|
|
+ enableTagMode,
|
|
|
|
|
+ activeTypeKey,
|
|
|
|
|
+ statusFilter,
|
|
|
|
|
+ 1,
|
|
|
|
|
+ size,
|
|
|
|
|
+ idSort,
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -502,7 +553,10 @@ export const useChannelsData = () => {
|
|
|
showError(res?.data?.message || t('渠道复制失败'));
|
|
showError(res?.data?.message || t('渠道复制失败'));
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- showError(t('渠道复制失败: ') + (error?.response?.data?.message || error?.message || error));
|
|
|
|
|
|
|
+ showError(
|
|
|
|
|
+ t('渠道复制失败: ') +
|
|
|
|
|
+ (error?.response?.data?.message || error?.message || error),
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -541,7 +595,11 @@ export const useChannelsData = () => {
|
|
|
data.priority = parseInt(data.priority);
|
|
data.priority = parseInt(data.priority);
|
|
|
break;
|
|
break;
|
|
|
case 'weight':
|
|
case 'weight':
|
|
|
- if (data.weight === undefined || data.weight < 0 || data.weight === '') {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ data.weight === undefined ||
|
|
|
|
|
+ data.weight < 0 ||
|
|
|
|
|
+ data.weight === ''
|
|
|
|
|
+ ) {
|
|
|
showInfo('权重必须是非负整数!');
|
|
showInfo('权重必须是非负整数!');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -684,7 +742,11 @@ export const useChannelsData = () => {
|
|
|
const res = await API.post(`/api/channel/fix`);
|
|
const res = await API.post(`/api/channel/fix`);
|
|
|
const { success, message, data } = res.data;
|
|
const { success, message, data } = res.data;
|
|
|
if (success) {
|
|
if (success) {
|
|
|
- showSuccess(t('已修复 ${success} 个通道,失败 ${fails} 个通道。').replace('${success}', data.success).replace('${fails}', data.fails));
|
|
|
|
|
|
|
+ showSuccess(
|
|
|
|
|
+ t('已修复 ${success} 个通道,失败 ${fails} 个通道。')
|
|
|
|
|
+ .replace('${success}', data.success)
|
|
|
|
|
+ .replace('${fails}', data.fails),
|
|
|
|
|
+ );
|
|
|
await refresh();
|
|
await refresh();
|
|
|
} else {
|
|
} else {
|
|
|
showError(message);
|
|
showError(message);
|
|
@@ -701,7 +763,7 @@ export const useChannelsData = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 添加到正在测试的模型集合
|
|
// 添加到正在测试的模型集合
|
|
|
- setTestingModels(prev => new Set([...prev, model]));
|
|
|
|
|
|
|
+ setTestingModels((prev) => new Set([...prev, model]));
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
let url = `/api/channel/test/${record.id}?model=${model}`;
|
|
let url = `/api/channel/test/${record.id}?model=${model}`;
|
|
@@ -718,14 +780,14 @@ export const useChannelsData = () => {
|
|
|
const { success, message, time } = res.data;
|
|
const { success, message, time } = res.data;
|
|
|
|
|
|
|
|
// 更新测试结果
|
|
// 更新测试结果
|
|
|
- setModelTestResults(prev => ({
|
|
|
|
|
|
|
+ setModelTestResults((prev) => ({
|
|
|
...prev,
|
|
...prev,
|
|
|
[testKey]: {
|
|
[testKey]: {
|
|
|
success,
|
|
success,
|
|
|
message,
|
|
message,
|
|
|
time: time || 0,
|
|
time: time || 0,
|
|
|
- timestamp: Date.now()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ timestamp: Date.now(),
|
|
|
|
|
+ },
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
if (success) {
|
|
if (success) {
|
|
@@ -743,7 +805,9 @@ export const useChannelsData = () => {
|
|
|
);
|
|
);
|
|
|
} else {
|
|
} else {
|
|
|
showInfo(
|
|
showInfo(
|
|
|
- t('通道 ${name} 测试成功,模型 ${model} 耗时 ${time.toFixed(2)} 秒。')
|
|
|
|
|
|
|
+ t(
|
|
|
|
|
+ '通道 ${name} 测试成功,模型 ${model} 耗时 ${time.toFixed(2)} 秒。',
|
|
|
|
|
+ )
|
|
|
.replace('${name}', record.name)
|
|
.replace('${name}', record.name)
|
|
|
.replace('${model}', model)
|
|
.replace('${model}', model)
|
|
|
.replace('${time.toFixed(2)}', time.toFixed(2)),
|
|
.replace('${time.toFixed(2)}', time.toFixed(2)),
|
|
@@ -755,19 +819,19 @@ export const useChannelsData = () => {
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
// 处理网络错误
|
|
// 处理网络错误
|
|
|
const testKey = `${record.id}-${model}`;
|
|
const testKey = `${record.id}-${model}`;
|
|
|
- setModelTestResults(prev => ({
|
|
|
|
|
|
|
+ setModelTestResults((prev) => ({
|
|
|
...prev,
|
|
...prev,
|
|
|
[testKey]: {
|
|
[testKey]: {
|
|
|
success: false,
|
|
success: false,
|
|
|
message: error.message || t('网络错误'),
|
|
message: error.message || t('网络错误'),
|
|
|
time: 0,
|
|
time: 0,
|
|
|
- timestamp: Date.now()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ timestamp: Date.now(),
|
|
|
|
|
+ },
|
|
|
}));
|
|
}));
|
|
|
showError(`${t('模型')} ${model}: ${error.message || t('测试失败')}`);
|
|
showError(`${t('模型')} ${model}: ${error.message || t('测试失败')}`);
|
|
|
} finally {
|
|
} finally {
|
|
|
// 从正在测试的模型集合中移除
|
|
// 从正在测试的模型集合中移除
|
|
|
- setTestingModels(prev => {
|
|
|
|
|
|
|
+ setTestingModels((prev) => {
|
|
|
const newSet = new Set(prev);
|
|
const newSet = new Set(prev);
|
|
|
newSet.delete(model);
|
|
newSet.delete(model);
|
|
|
return newSet;
|
|
return newSet;
|
|
@@ -782,9 +846,11 @@ export const useChannelsData = () => {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const models = currentTestChannel.models.split(',').filter(model =>
|
|
|
|
|
- model.toLowerCase().includes(modelSearchKeyword.toLowerCase())
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ const models = currentTestChannel.models
|
|
|
|
|
+ .split(',')
|
|
|
|
|
+ .filter((model) =>
|
|
|
|
|
+ model.toLowerCase().includes(modelSearchKeyword.toLowerCase()),
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
if (models.length === 0) {
|
|
if (models.length === 0) {
|
|
|
showError(t('没有找到匹配的模型'));
|
|
showError(t('没有找到匹配的模型'));
|
|
@@ -795,9 +861,9 @@ export const useChannelsData = () => {
|
|
|
shouldStopBatchTestingRef.current = false; // 重置停止标志
|
|
shouldStopBatchTestingRef.current = false; // 重置停止标志
|
|
|
|
|
|
|
|
// 清空该渠道之前的测试结果
|
|
// 清空该渠道之前的测试结果
|
|
|
- setModelTestResults(prev => {
|
|
|
|
|
|
|
+ setModelTestResults((prev) => {
|
|
|
const newResults = { ...prev };
|
|
const newResults = { ...prev };
|
|
|
- models.forEach(model => {
|
|
|
|
|
|
|
+ models.forEach((model) => {
|
|
|
const testKey = `${currentTestChannel.id}-${model}`;
|
|
const testKey = `${currentTestChannel.id}-${model}`;
|
|
|
delete newResults[testKey];
|
|
delete newResults[testKey];
|
|
|
});
|
|
});
|
|
@@ -805,7 +871,12 @@ export const useChannelsData = () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- showInfo(t('开始批量测试 ${count} 个模型,已清空上次结果...').replace('${count}', models.length));
|
|
|
|
|
|
|
+ showInfo(
|
|
|
|
|
+ t('开始批量测试 ${count} 个模型,已清空上次结果...').replace(
|
|
|
|
|
+ '${count}',
|
|
|
|
|
+ models.length,
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
// 提高并发数量以加快测试速度,参考旧版的并发限制
|
|
// 提高并发数量以加快测试速度,参考旧版的并发限制
|
|
|
const concurrencyLimit = 5;
|
|
const concurrencyLimit = 5;
|
|
@@ -819,13 +890,16 @@ export const useChannelsData = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const batch = models.slice(i, i + concurrencyLimit);
|
|
const batch = models.slice(i, i + concurrencyLimit);
|
|
|
- showInfo(t('正在测试第 ${current} - ${end} 个模型 (共 ${total} 个)')
|
|
|
|
|
- .replace('${current}', i + 1)
|
|
|
|
|
- .replace('${end}', Math.min(i + concurrencyLimit, models.length))
|
|
|
|
|
- .replace('${total}', models.length)
|
|
|
|
|
|
|
+ showInfo(
|
|
|
|
|
+ t('正在测试第 ${current} - ${end} 个模型 (共 ${total} 个)')
|
|
|
|
|
+ .replace('${current}', i + 1)
|
|
|
|
|
+ .replace('${end}', Math.min(i + concurrencyLimit, models.length))
|
|
|
|
|
+ .replace('${total}', models.length),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- const batchPromises = batch.map(model => testChannel(currentTestChannel, model, selectedEndpointType));
|
|
|
|
|
|
|
+ const batchPromises = batch.map((model) =>
|
|
|
|
|
+ testChannel(currentTestChannel, model, selectedEndpointType),
|
|
|
|
|
+ );
|
|
|
const batchResults = await Promise.allSettled(batchPromises);
|
|
const batchResults = await Promise.allSettled(batchPromises);
|
|
|
results.push(...batchResults);
|
|
results.push(...batchResults);
|
|
|
|
|
|
|
@@ -837,20 +911,20 @@ export const useChannelsData = () => {
|
|
|
|
|
|
|
|
// 短暂延迟避免过于频繁的请求
|
|
// 短暂延迟避免过于频繁的请求
|
|
|
if (i + concurrencyLimit < models.length) {
|
|
if (i + concurrencyLimit < models.length) {
|
|
|
- await new Promise(resolve => setTimeout(resolve, 100));
|
|
|
|
|
|
|
+ await new Promise((resolve) => setTimeout(resolve, 100));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!shouldStopBatchTestingRef.current) {
|
|
if (!shouldStopBatchTestingRef.current) {
|
|
|
// 等待一小段时间确保所有结果都已更新
|
|
// 等待一小段时间确保所有结果都已更新
|
|
|
- await new Promise(resolve => setTimeout(resolve, 300));
|
|
|
|
|
|
|
+ await new Promise((resolve) => setTimeout(resolve, 300));
|
|
|
|
|
|
|
|
// 使用当前状态重新计算结果统计
|
|
// 使用当前状态重新计算结果统计
|
|
|
- setModelTestResults(currentResults => {
|
|
|
|
|
|
|
+ setModelTestResults((currentResults) => {
|
|
|
let successCount = 0;
|
|
let successCount = 0;
|
|
|
let failCount = 0;
|
|
let failCount = 0;
|
|
|
|
|
|
|
|
- models.forEach(model => {
|
|
|
|
|
|
|
+ models.forEach((model) => {
|
|
|
const testKey = `${currentTestChannel.id}-${model}`;
|
|
const testKey = `${currentTestChannel.id}-${model}`;
|
|
|
const result = currentResults[testKey];
|
|
const result = currentResults[testKey];
|
|
|
if (result && result.success) {
|
|
if (result && result.success) {
|
|
@@ -862,10 +936,11 @@ export const useChannelsData = () => {
|
|
|
|
|
|
|
|
// 显示完成消息
|
|
// 显示完成消息
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
- showSuccess(t('批量测试完成!成功: ${success}, 失败: ${fail}, 总计: ${total}')
|
|
|
|
|
- .replace('${success}', successCount)
|
|
|
|
|
- .replace('${fail}', failCount)
|
|
|
|
|
- .replace('${total}', models.length)
|
|
|
|
|
|
|
+ showSuccess(
|
|
|
|
|
+ t('批量测试完成!成功: ${success}, 失败: ${fail}, 总计: ${total}')
|
|
|
|
|
+ .replace('${success}', successCount)
|
|
|
|
|
+ .replace('${fail}', failCount)
|
|
|
|
|
+ .replace('${total}', models.length),
|
|
|
);
|
|
);
|
|
|
}, 100);
|
|
}, 100);
|
|
|
|
|
|
|
@@ -1053,4 +1128,4 @@ export const useChannelsData = () => {
|
|
|
setCompactMode,
|
|
setCompactMode,
|
|
|
setActivePage,
|
|
setActivePage,
|
|
|
};
|
|
};
|
|
|
-};
|
|
|
|
|
|
|
+};
|