From 08e10df88783f3ad23eec921a29e7191b8055e9f Mon Sep 17 00:00:00 2001 From: iszcz <74706321+iszcz@users.noreply.github.com> Date: Wed, 10 Apr 2024 02:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B8=A0=E9=81=93=E5=A4=8D?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/ChannelsTable.js | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js index 0d2ed57..ebfcf4d 100644 --- a/web/src/components/ChannelsTable.js +++ b/web/src/components/ChannelsTable.js @@ -254,6 +254,19 @@ const ChannelsTable = () => { > 编辑 + { + copySelectedChannel(record.id); + }} + > + + ), }, @@ -340,6 +353,31 @@ const ChannelsTable = () => { setLoading(false); }; + const copySelectedChannel = async (id) => { + const channelToCopy = channels.find(channel => String(channel.id) === String(id)); + console.log(channelToCopy) + channelToCopy.name += '_复制'; + channelToCopy.created_time = null; + channelToCopy.balance = 0; + channelToCopy.used_quota = 0; + if (!channelToCopy) { + showError("渠道未找到,请刷新页面后重试。"); + return; + } + try { + const newChannel = {...channelToCopy, id: undefined}; + const response = await API.post('/api/channel/', newChannel); + if (response.data.success) { + showSuccess("渠道复制成功"); + await refresh(); + } else { + showError(response.data.message); + } + } catch (error) { + showError("渠道复制失败: " + error.message); + } + }; + const refresh = async () => { await loadChannels(activePage - 1, pageSize, idSort); };