From de9d18a2fe2de1fc9ea383ea71c44aa006da91df Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Sat, 19 Jul 2025 00:58:18 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(channels):=20migr?= =?UTF-8?q?ate=20edit=20components=20to=20modals=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move EditChannel and EditTagModal from standalone pages to modal components within the channels module structure for consistency with other table modules. Changes: - Move EditChannel.js → components/table/channels/modals/EditChannelModal.jsx - Move EditTagModal.js → components/table/channels/modals/EditTagModal.jsx - Update import paths in channels/index.jsx - Remove standalone routes for EditChannel from App.js - Delete original files from pages/Channel/ This change aligns the channels module with the established modular pattern used by tokens, users, redemptions, and other table modules, centralizing all channel management functionality within integrated modal components instead of separate page routes. BREAKING CHANGE: EditChannel standalone routes (/console/channel/edit/:id and /console/channel/add) have been removed. All channel editing is now handled through modal components within the main channels page. --- web/src/App.js | 17 --------- web/src/components/table/channels/index.jsx | 6 +-- .../channels/modals/EditChannelModal.jsx} | 38 +++++++++---------- .../table/channels/modals/EditTagModal.jsx} | 6 +-- 4 files changed, 24 insertions(+), 43 deletions(-) rename web/src/{pages/Channel/EditChannel.js => components/table/channels/modals/EditChannelModal.jsx} (98%) rename web/src/{pages/Channel/EditTagModal.js => components/table/channels/modals/EditTagModal.jsx} (99%) diff --git a/web/src/App.js b/web/src/App.js index 41ab040e..bab3707c 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -12,7 +12,6 @@ import PasswordResetForm from './components/auth/PasswordResetForm.js'; import PasswordResetConfirm from './components/auth/PasswordResetConfirm.js'; import Channel from './pages/Channel'; import Token from './pages/Token'; -import EditChannel from './pages/Channel/EditChannel'; import Redemption from './pages/Redemption'; import TopUp from './pages/TopUp'; import Log from './pages/Log'; @@ -61,22 +60,6 @@ function App() { } /> - } key={location.pathname}> - - - } - /> - } key={location.pathname}> - - - } - /> { const channelsData = useChannelsData(); @@ -24,7 +24,7 @@ const ChannelsPage = () => { handleClose={() => channelsData.setShowEditTag(false)} refresh={channelsData.refresh} /> - { +const EditChannelModal = (props) => { const { t } = useTranslation(); - const navigate = useNavigate(); const channelId = props.editingChannel.id; const isEdit = channelId !== undefined; const [loading, setLoading] = useState(isEdit); @@ -193,7 +191,7 @@ const EditChannel = (props) => { setInputs((inputs) => ({ ...inputs, models: localModels })); } setBasicModels(localModels); - + // 重置手动输入模式状态 setUseManualInput(false); } @@ -726,9 +724,9 @@ const EditChannel = (props) => { onClick, ...rest } = renderProps; - + const searchWords = channelSearchValue ? [channelSearchValue] : []; - + // 构建样式类名 const optionClassName = [ 'flex items-center gap-3 px-3 py-2 transition-all duration-200 rounded-lg mx-2 my-1', @@ -738,12 +736,12 @@ const EditChannel = (props) => { !disabled && 'hover:bg-gray-50 hover:shadow-md cursor-pointer', className ].filter(Boolean).join(' '); - + return ( -
!disabled && onClick()} + onClick={() => !disabled && onClick()} onMouseEnter={e => onMouseEnter()} >
@@ -751,8 +749,8 @@ const EditChannel = (props) => { {getChannelIcon(value)}
- @@ -760,7 +758,7 @@ const EditChannel = (props) => { {selected && (
- +
)} @@ -926,7 +924,7 @@ const EditChannel = (props) => {
)} - + {batch && ( { className='!rounded-lg mb-3' /> )} - + {useManualInput && !batch ? ( { ); }; -export default EditChannel; +export default EditChannelModal; \ No newline at end of file diff --git a/web/src/pages/Channel/EditTagModal.js b/web/src/components/table/channels/modals/EditTagModal.jsx similarity index 99% rename from web/src/pages/Channel/EditTagModal.js rename to web/src/components/table/channels/modals/EditTagModal.jsx index 433d4f09..9ebc8bd6 100644 --- a/web/src/pages/Channel/EditTagModal.js +++ b/web/src/components/table/channels/modals/EditTagModal.jsx @@ -6,7 +6,7 @@ import { showSuccess, showWarning, verifyJSON, -} from '../../helpers'; +} from '../../../../helpers'; import { SideSheet, Space, @@ -26,7 +26,7 @@ import { IconUser, IconCode, } from '@douyinfe/semi-icons'; -import { getChannelModels } from '../../helpers'; +import { getChannelModels } from '../../../../helpers'; import { useTranslation } from 'react-i18next'; const { Text, Title } = Typography; @@ -441,4 +441,4 @@ const EditTagModal = (props) => { ); }; -export default EditTagModal; +export default EditTagModal; \ No newline at end of file