PricingTable.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 support@quantumnous.com
  14. */
  15. import React, { useMemo } from 'react';
  16. import { Card, Table, Empty } from '@douyinfe/semi-ui';
  17. import {
  18. IllustrationNoResult,
  19. IllustrationNoResultDark
  20. } from '@douyinfe/semi-illustrations';
  21. import { getPricingTableColumns } from './PricingTableColumns.js';
  22. const PricingTable = ({
  23. filteredModels,
  24. loading,
  25. rowSelection,
  26. pageSize,
  27. setPageSize,
  28. selectedGroup,
  29. usableGroup,
  30. groupRatio,
  31. copyText,
  32. setModalImageUrl,
  33. setIsModalOpenurl,
  34. currency,
  35. showWithRecharge,
  36. tokenUnit,
  37. setTokenUnit,
  38. displayPrice,
  39. filteredValue,
  40. handleGroupClick,
  41. showRatio,
  42. t
  43. }) => {
  44. const columns = useMemo(() => {
  45. return getPricingTableColumns({
  46. t,
  47. selectedGroup,
  48. usableGroup,
  49. groupRatio,
  50. copyText,
  51. setModalImageUrl,
  52. setIsModalOpenurl,
  53. currency,
  54. showWithRecharge,
  55. tokenUnit,
  56. setTokenUnit,
  57. displayPrice,
  58. handleGroupClick,
  59. showRatio,
  60. });
  61. }, [
  62. t,
  63. selectedGroup,
  64. usableGroup,
  65. groupRatio,
  66. copyText,
  67. setModalImageUrl,
  68. setIsModalOpenurl,
  69. currency,
  70. showWithRecharge,
  71. tokenUnit,
  72. setTokenUnit,
  73. displayPrice,
  74. handleGroupClick,
  75. showRatio,
  76. ]);
  77. // 更新列定义中的 filteredValue
  78. const tableColumns = useMemo(() => {
  79. return columns.map(column => {
  80. if (column.dataIndex === 'model_name') {
  81. return {
  82. ...column,
  83. filteredValue
  84. };
  85. }
  86. return column;
  87. });
  88. }, [columns, filteredValue]);
  89. const ModelTable = useMemo(() => (
  90. <Card className="!rounded-xl overflow-hidden" bordered={false}>
  91. <Table
  92. columns={tableColumns}
  93. dataSource={filteredModels}
  94. loading={loading}
  95. rowSelection={rowSelection}
  96. className="custom-table"
  97. empty={
  98. <Empty
  99. image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
  100. darkModeImage={<IllustrationNoResultDark style={{ width: 150, height: 150 }} />}
  101. description={t('搜索无结果')}
  102. style={{ padding: 30 }}
  103. />
  104. }
  105. pagination={{
  106. defaultPageSize: 10,
  107. pageSize: pageSize,
  108. showSizeChanger: true,
  109. pageSizeOptions: [10, 20, 50, 100],
  110. onPageSizeChange: (size) => setPageSize(size),
  111. }}
  112. />
  113. </Card>
  114. ), [filteredModels, loading, tableColumns, rowSelection, pageSize, setPageSize, t]);
  115. return ModelTable;
  116. };
  117. export default PricingTable;