Revert "🐛 fix: preserve group filter when switching channel type/status"

This reverts commit a8ba2eba33.
This commit is contained in:
t0ng7u
2025-06-24 01:51:26 +08:00
parent 6c31151430
commit 5a5e8ce652

View File

@@ -880,22 +880,14 @@ const ChannelsTable = () => {
enableTagMode, enableTagMode,
typeKey = activeTypeKey, typeKey = activeTypeKey,
statusF, statusF,
searchParams = null,
) => { ) => {
if (statusF === undefined) statusF = statusFilter; if (statusF === undefined) statusF = statusFilter;
const reqId = ++requestCounter.current; // 记录当前请求序号 const reqId = ++requestCounter.current; // 记录当前请求序号
setLoading(true); setLoading(true);
const { searchKeyword, searchGroup, searchModel } = searchParams || getFormValues();
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 groupParam = searchGroup ? `&group=${searchGroup}` : '';
const modelParam = searchModel ? `&model=${searchModel}` : '';
const keywordParam = searchKeyword ? `&keyword=${searchKeyword}` : '';
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}${groupParam}${modelParam}${keywordParam}`, `/api/channel/?p=${page}&page_size=${pageSize}&id_sort=${idSort}&tag_mode=${enableTagMode}${typeParam}${statusParam}`,
); );
if (res === undefined || reqId !== requestCounter.current) { if (res === undefined || reqId !== requestCounter.current) {
return; return;
@@ -942,9 +934,9 @@ const ChannelsTable = () => {
}; };
const refresh = async () => { const refresh = async () => {
const formValues = getFormValues(); const { searchKeyword, searchGroup, searchModel } = getFormValues();
if (formValues.searchKeyword === '' && formValues.searchGroup === '' && formValues.searchModel === '') { if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
await loadChannels(activePage, pageSize, idSort, enableTagMode, activeTypeKey, statusFilter, formValues); await loadChannels(activePage, pageSize, idSort, enableTagMode);
} else { } else {
await searchChannels(enableTagMode); await searchChannels(enableTagMode);
} }
@@ -1068,7 +1060,7 @@ const ChannelsTable = () => {
setSearching(true); setSearching(true);
try { try {
if (searchKeyword === '' && searchGroup === '' && searchModel === '') { if (searchKeyword === '' && searchGroup === '' && searchModel === '') {
await loadChannels(activePage, pageSize, idSort, enableTagMode, activeTypeKey, statusFilter); await loadChannels(activePage - 1, pageSize, idSort, enableTagMode);
return; return;
} }
@@ -1249,7 +1241,7 @@ const ChannelsTable = () => {
onChange={(key) => { onChange={(key) => {
setActiveTypeKey(key); setActiveTypeKey(key);
setActivePage(1); setActivePage(1);
loadChannels(1, pageSize, idSort, enableTagMode, key, statusFilter, getFormValues()); loadChannels(1, pageSize, idSort, enableTagMode, key);
}} }}
className="mb-4" className="mb-4"
> >
@@ -1292,14 +1284,14 @@ const ChannelsTable = () => {
const handlePageChange = (page) => { const handlePageChange = (page) => {
setActivePage(page); setActivePage(page);
loadChannels(page, pageSize, idSort, enableTagMode, activeTypeKey, statusFilter, getFormValues()).then(() => { }); loadChannels(page, pageSize, idSort, enableTagMode).then(() => { });
}; };
const handlePageSizeChange = async (size) => { const handlePageSizeChange = async (size) => {
localStorage.setItem('page-size', size + ''); localStorage.setItem('page-size', size + '');
setPageSize(size); setPageSize(size);
setActivePage(1); setActivePage(1);
loadChannels(1, size, idSort, enableTagMode, activeTypeKey, statusFilter, getFormValues()) loadChannels(1, size, idSort, enableTagMode)
.then() .then()
.catch((reason) => { .catch((reason) => {
showError(reason); showError(reason);
@@ -1658,7 +1650,7 @@ const ChannelsTable = () => {
localStorage.setItem('channel-status-filter', v); localStorage.setItem('channel-status-filter', v);
setStatusFilter(v); setStatusFilter(v);
setActivePage(1); setActivePage(1);
loadChannels(1, pageSize, idSort, enableTagMode, activeTypeKey, v, getFormValues()); loadChannels(1, pageSize, idSort, enableTagMode, activeTypeKey, v);
}} }}
size="small" size="small"
> >
@@ -1756,12 +1748,7 @@ const ChannelsTable = () => {
onChange={() => { onChange={() => {
// 延迟执行搜索,让表单值先更新 // 延迟执行搜索,让表单值先更新
setTimeout(() => { setTimeout(() => {
const values = getFormValues(); searchChannels(enableTagMode);
if (values.searchKeyword === '' && values.searchModel === '') {
loadChannels(1, pageSize, idSort, enableTagMode, activeTypeKey, statusFilter, values);
} else {
searchChannels(enableTagMode);
}
}, 0); }, 0);
}} }}
/> />