index.jsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact [email protected]
  14. */
  15. import React from 'react';
  16. import { Banner } from '@douyinfe/semi-ui';
  17. import { IconAlertTriangle } from '@douyinfe/semi-icons';
  18. import CardPro from '../../common/ui/CardPro';
  19. import ChannelsTable from './ChannelsTable';
  20. import ChannelsActions from './ChannelsActions';
  21. import ChannelsFilters from './ChannelsFilters';
  22. import ChannelsTabs from './ChannelsTabs';
  23. import { useChannelsData } from '../../../hooks/channels/useChannelsData';
  24. import { useIsMobile } from '../../../hooks/common/useIsMobile';
  25. import BatchTagModal from './modals/BatchTagModal';
  26. import ModelTestModal from './modals/ModelTestModal';
  27. import ColumnSelectorModal from './modals/ColumnSelectorModal';
  28. import EditChannelModal from './modals/EditChannelModal';
  29. import EditTagModal from './modals/EditTagModal';
  30. import MultiKeyManageModal from './modals/MultiKeyManageModal';
  31. import { createCardProPagination } from '../../../helpers/utils';
  32. const ChannelsPage = () => {
  33. const channelsData = useChannelsData();
  34. const isMobile = useIsMobile();
  35. return (
  36. <>
  37. {/* Modals */}
  38. <ColumnSelectorModal {...channelsData} />
  39. <EditTagModal
  40. visible={channelsData.showEditTag}
  41. tag={channelsData.editingTag}
  42. handleClose={() => channelsData.setShowEditTag(false)}
  43. refresh={channelsData.refresh}
  44. />
  45. <EditChannelModal
  46. refresh={channelsData.refresh}
  47. visible={channelsData.showEdit}
  48. handleClose={channelsData.closeEdit}
  49. editingChannel={channelsData.editingChannel}
  50. />
  51. <BatchTagModal {...channelsData} />
  52. <ModelTestModal {...channelsData} />
  53. <MultiKeyManageModal
  54. visible={channelsData.showMultiKeyManageModal}
  55. onCancel={() => channelsData.setShowMultiKeyManageModal(false)}
  56. channel={channelsData.currentMultiKeyChannel}
  57. onRefresh={channelsData.refresh}
  58. />
  59. {/* Main Content */}
  60. {channelsData.globalPassThroughEnabled ? (
  61. <Banner
  62. type='warning'
  63. closeIcon={null}
  64. icon={
  65. <IconAlertTriangle
  66. size='large'
  67. style={{ color: 'var(--semi-color-warning)' }}
  68. />
  69. }
  70. description={channelsData.t(
  71. '已开启全局请求透传:参数覆写、模型重定向、渠道适配等 NewAPI 内置功能将失效,非最佳实践;如因此产生问题,请勿提交 issue 反馈。',
  72. )}
  73. style={{ marginBottom: 12 }}
  74. />
  75. ) : null}
  76. <CardPro
  77. type='type3'
  78. tabsArea={<ChannelsTabs {...channelsData} />}
  79. actionsArea={<ChannelsActions {...channelsData} />}
  80. searchArea={<ChannelsFilters {...channelsData} />}
  81. paginationArea={createCardProPagination({
  82. currentPage: channelsData.activePage,
  83. pageSize: channelsData.pageSize,
  84. total: channelsData.channelCount,
  85. onPageChange: channelsData.handlePageChange,
  86. onPageSizeChange: channelsData.handlePageSizeChange,
  87. isMobile: isMobile,
  88. t: channelsData.t,
  89. })}
  90. t={channelsData.t}
  91. >
  92. <ChannelsTable {...channelsData} />
  93. </CardPro>
  94. </>
  95. );
  96. };
  97. export default ChannelsPage;