From 15e753d6fb44f4fe956456aeea84c653f4a1909d Mon Sep 17 00:00:00 2001 From: "weihao.li" <791783391@qq.com> Date: Sat, 4 Jul 2026 03:19:36 +0800 Subject: [PATCH] fix(web/classic): use POST /api/channel/:id/status for enable/disable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #5755 (4aee5f7d) rejected `status` in PUT /api/channel/ and migrated the default theme to POST /api/channel/:id/status, but classic's manageChannel was left on PUT + body{status}, breaking enable/disable under classic theme on rc.16+ (backend returns "无效的参数"). Switch enable/disable to the same POST endpoint; derive record.status from the target value because POST returns {data: changed bool}, not a channel object. priority/weight/enable_all keep PUT (their body has no `status` field, so they don't trip the interceptor). --- .../src/hooks/channels/useChannelsData.jsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/web/classic/src/hooks/channels/useChannelsData.jsx b/web/classic/src/hooks/channels/useChannelsData.jsx index e0208683f7c4..215a6e338a28 100644 --- a/web/classic/src/hooks/channels/useChannelsData.jsx +++ b/web/classic/src/hooks/channels/useChannelsData.jsx @@ -443,17 +443,20 @@ export const useChannelsData = () => { const manageChannel = async (id, action, record, value) => { let data = { id }; let res; + // POST /api/channel/:id/status 返回 {data: changed bool},不再是 channel 对象, + // enable/disable 后用本地推断的目标状态更新 record.status + let statusAfter; switch (action) { case 'delete': res = await API.delete(`/api/channel/${id}/`); break; case 'enable': - data.status = 1; - res = await API.put('/api/channel/', data); + statusAfter = 1; + res = await API.post(`/api/channel/${id}/status`, { status: 1 }); break; case 'disable': - data.status = 2; - res = await API.put('/api/channel/', data); + statusAfter = 2; + res = await API.post(`/api/channel/${id}/status`, { status: 2 }); break; case 'priority': if (value === '') return; @@ -475,10 +478,13 @@ export const useChannelsData = () => { const { success, message } = res.data; if (success) { showSuccess(t('操作成功完成!')); - let channel = res.data.data; let newChannels = [...channels]; - if (action !== 'delete') { - record.status = channel.status; + if (action === 'enable' || action === 'disable') { + // POST /api/channel/:id/status -> {success, data: changed bool} + record.status = statusAfter; + } else if (action !== 'delete') { + // PUT /api/channel/ -> {success, data: channel object} + record.status = res.data.data.status; } setChannels(newChannels); } else {