fix(table): 统一筛选交互并补齐移动视口覆盖
This commit is contained in:
@@ -63,7 +63,6 @@ export const useChannelsData = () => {
|
||||
// Model test states
|
||||
const [showModelTestModal, setShowModelTestModal] = useState(false);
|
||||
const [currentTestChannel, setCurrentTestChannel] = useState(null);
|
||||
const [modelSearchKeyword, setModelSearchKeyword] = useState('');
|
||||
const [modelTestResults, setModelTestResults] = useState({});
|
||||
const [testingModels, setTestingModels] = useState(new Set());
|
||||
const [selectedModelKeys, setSelectedModelKeys] = useState([]);
|
||||
@@ -290,6 +289,7 @@ export const useChannelsData = () => {
|
||||
enableTagMode,
|
||||
typeKey = activeTypeKey,
|
||||
statusF,
|
||||
signal,
|
||||
) => {
|
||||
if (statusF === undefined) statusF = statusFilter;
|
||||
|
||||
@@ -303,41 +303,51 @@ export const useChannelsData = () => {
|
||||
page,
|
||||
pageSize,
|
||||
idSort,
|
||||
signal,
|
||||
);
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const reqId = ++requestCounter.current;
|
||||
setSearching(false);
|
||||
setLoading(true);
|
||||
const typeParam = typeKey !== 'all' ? `&type=${typeKey}` : '';
|
||||
const statusParam = statusF !== 'all' ? `&status=${statusF}` : '';
|
||||
const res = await API.get(
|
||||
`/api/channel/?p=${page}&page_size=${pageSize}&id_sort=${idSort}&tag_mode=${enableTagMode}${typeParam}${statusParam}`,
|
||||
);
|
||||
try {
|
||||
const res = await API.get(
|
||||
`/api/channel/?p=${page}&page_size=${pageSize}&id_sort=${idSort}&tag_mode=${enableTagMode}${typeParam}${statusParam}`,
|
||||
{ signal },
|
||||
);
|
||||
|
||||
if (res === undefined || reqId !== requestCounter.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
const { items, total, type_counts } = data;
|
||||
if (type_counts) {
|
||||
const sumAll = Object.values(type_counts).reduce(
|
||||
(acc, v) => acc + v,
|
||||
0,
|
||||
);
|
||||
setTypeCounts({ ...type_counts, all: sumAll });
|
||||
if (
|
||||
res === undefined ||
|
||||
signal?.aborted ||
|
||||
reqId !== requestCounter.current
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setChannelFormat(items, enableTagMode);
|
||||
setChannelCount(total);
|
||||
// 获取日消耗数据
|
||||
fetchDailyQuotaInfo(items);
|
||||
} else {
|
||||
showError(message);
|
||||
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
const { items, total, type_counts } = data;
|
||||
if (type_counts) {
|
||||
const sumAll = Object.values(type_counts).reduce(
|
||||
(acc, v) => acc + v,
|
||||
0,
|
||||
);
|
||||
setTypeCounts({ ...type_counts, all: sumAll });
|
||||
}
|
||||
setChannelFormat(items, enableTagMode);
|
||||
setChannelCount(total);
|
||||
// 获取日消耗数据
|
||||
fetchDailyQuotaInfo(items);
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
} finally {
|
||||
if (reqId === requestCounter.current) setLoading(false);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
// Search channels
|
||||
@@ -348,23 +358,28 @@ export const useChannelsData = () => {
|
||||
page = 1,
|
||||
pageSz = pageSize,
|
||||
sortFlag = idSort,
|
||||
signal,
|
||||
) => {
|
||||
const { searchKeyword, searchGroup, searchModel } = getFormValues();
|
||||
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
||||
await loadChannels(
|
||||
page,
|
||||
pageSz,
|
||||
sortFlag,
|
||||
enableTagMode,
|
||||
typeKey,
|
||||
statusF,
|
||||
signal,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const reqId = ++requestCounter.current;
|
||||
setLoading(false);
|
||||
setSearching(true);
|
||||
try {
|
||||
if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
|
||||
await loadChannels(
|
||||
page,
|
||||
pageSz,
|
||||
sortFlag,
|
||||
enableTagMode,
|
||||
typeKey,
|
||||
statusF,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await API.get('/api/channel/search', {
|
||||
signal,
|
||||
params: {
|
||||
keyword: searchKeyword,
|
||||
group: searchGroup,
|
||||
@@ -377,6 +392,7 @@ export const useChannelsData = () => {
|
||||
status: statusF === 'all' ? undefined : statusF,
|
||||
},
|
||||
});
|
||||
if (signal?.aborted || reqId !== requestCounter.current) return;
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
const { items = [], total = 0, type_counts = {} } = data;
|
||||
@@ -394,7 +410,7 @@ export const useChannelsData = () => {
|
||||
showError(message);
|
||||
}
|
||||
} finally {
|
||||
setSearching(false);
|
||||
if (reqId === requestCounter.current) setSearching(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1060,7 +1076,6 @@ export const useChannelsData = () => {
|
||||
}
|
||||
|
||||
setShowModelTestModal(false);
|
||||
setModelSearchKeyword('');
|
||||
setIsBatchTesting(false);
|
||||
setTestingModels(new Set());
|
||||
setSelectedModelKeys([]);
|
||||
@@ -1153,8 +1168,6 @@ export const useChannelsData = () => {
|
||||
setShowModelTestModal,
|
||||
currentTestChannel,
|
||||
setCurrentTestChannel,
|
||||
modelSearchKeyword,
|
||||
setModelSearchKeyword,
|
||||
modelTestResults,
|
||||
testingModels,
|
||||
selectedModelKeys,
|
||||
|
||||
Reference in New Issue
Block a user