From 3d9520471916e30d3a50904c85d5177a5003bf2f Mon Sep 17 00:00:00 2001 From: Timlzh Date: Tue, 3 Jun 2025 18:06:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E9=A1=B5=E9=9D=A2=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-build.yml | 2 +- .github/workflows/frontend-build.yml | 2 +- frontend/src/components/DataTable.tsx | 88 ++++++++++++++++----------- 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/.github/workflows/backend-build.yml b/.github/workflows/backend-build.yml index 3db61c6..616dfdf 100644 --- a/.github/workflows/backend-build.yml +++ b/.github/workflows/backend-build.yml @@ -2,7 +2,7 @@ name: Backend Docker Build and Publish on: push: - branches: [main, master, workflow-dev] + branches: [main, master, workflow-dev, dev] paths: - "backend/**" tags: ["v*.*.*"] diff --git a/.github/workflows/frontend-build.yml b/.github/workflows/frontend-build.yml index bd985ae..ed8fe97 100644 --- a/.github/workflows/frontend-build.yml +++ b/.github/workflows/frontend-build.yml @@ -2,7 +2,7 @@ name: Frontend Docker Build and Publish on: push: - branches: [main, master, workflow-dev] + branches: [main, master, workflow-dev, dev] paths: - "frontend/**" tags: ["v*.*.*"] diff --git a/frontend/src/components/DataTable.tsx b/frontend/src/components/DataTable.tsx index bad437f..d4bb7e2 100644 --- a/frontend/src/components/DataTable.tsx +++ b/frontend/src/components/DataTable.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode, useState, KeyboardEvent } from "react"; +import React, { ReactNode, useMemo, useState } from "react"; import { Table, TableHeader, @@ -19,7 +19,7 @@ import { DropdownSection, } from "@heroui/dropdown"; import { Tooltip } from "@heroui/tooltip"; -import { NumberInput } from "@heroui/number-input"; +import { Input } from "@heroui/input"; import LoadingSpinner from "./LoadingSpinner"; import ErrorDisplay from "./ErrorDisplay"; @@ -105,6 +105,7 @@ export interface DataTableProps { selectedKeys?: Selection; onSelectionChange?: (keys: Set) => void; selectionToolbarContent?: ReactNode; + showJumper?: boolean; } // 通用DataTable组件 @@ -142,6 +143,7 @@ export const DataTable = ({ selectedKeys, onSelectionChange, selectionToolbarContent, + showJumper = true, }: DataTableProps) => { // 获取表头列 const headerColumns = React.useMemo(() => { @@ -155,25 +157,46 @@ export const DataTable = ({ // 每页行数 const pageSizeOptions = [5, 10, 15, 30, 50]; const [pageSizeSelectedKeys, setPageSizeSelectedKeys] = useState( - new Set([selectedSize.toString()]), + pageSizeOptions.includes(selectedSize) + ? new Set([selectedSize.toString()]) + : new Set(["custom"]), ); // 自定义页面大小 - const [customPageSize, setCustomPageSize] = useState(null); + const [customPageSize, setCustomPageSize] = useState( + selectedSize.toString(), + ); + + // 验证自定义页面大小的函数 + const validateCustomPageSize = (value: string): boolean => { + return ( + value.match(/^\d+$/) && + Number(value) >= minPageSize && + Number(value) <= maxPageSize + ); + }; + + // 判断自定义页面大小是否无效 + const isInvalidCustomPageSize = useMemo(() => { + return !validateCustomPageSize(customPageSize); + }, [customPageSize, minPageSize, maxPageSize]); // 处理自定义页面大小应用 const applyCustomPageSize = () => { - if ( - customPageSize === null || - customPageSize < minPageSize || - customPageSize > maxPageSize - ) { + if (isInvalidCustomPageSize) { return; } - setSize?.(customPageSize); - setPageSizeSelectedKeys(new Set([customPageSize.toString()])); - setCustomPageSize(selectedSize); + const customPageSizeNumber = Number(customPageSize); + + setSize?.(customPageSizeNumber); + if (pageSizeOptions.includes(customPageSizeNumber)) { + setPageSizeSelectedKeys(new Set([customPageSize])); + } else { + setPageSizeSelectedKeys(new Set(["custom"])); + } + + setCustomPageSize(customPageSize); onPageChange(1); }; @@ -191,7 +214,7 @@ export const DataTable = ({ {pages > 1 && ( @@ -300,6 +323,7 @@ export const DataTable = ({ if (key && key !== "custom") { setSize(Number(key)); setPageSizeSelectedKeys(new Set([key])); + setCustomPageSize(key); onPageChange(1); } }} @@ -327,36 +351,18 @@ export const DataTable = ({ } startContent={ - { - if (value < minPageSize) { - return `页面大小不能小于 ${minPageSize}`; - } - - if (value > maxPageSize) { - return `页面大小不能大于 ${maxPageSize}`; - } - - return null; - }} value={customPageSize} onKeyDown={handleKeyDown} - onValueChange={(value) => { - setCustomPageSize(value); - }} + onValueChange={setCustomPageSize} /> } textValue="自定义页面大小" @@ -396,6 +402,16 @@ export const DataTable = ({ selectionMode, selectedKeys, selectionToolbarContent, + pages, + setSize, + selectedSize, + pageSizeSelectedKeys, + customPageSize, + isInvalidCustomPageSize, + minPageSize, + maxPageSize, + applyCustomPageSize, + handleKeyDown, ]); // 渲染表格 From 3e5bb144227cd057a09221f12ff6ad79d0b995b1 Mon Sep 17 00:00:00 2001 From: Timlzh Date: Sat, 7 Jun 2025 19:10:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E6=9A=82=E6=97=B6=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E6=8A=BD=E5=B1=89=E4=B8=AD=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=94=B1=E4=BA=8E=E6=9C=AA=E6=89=BE=E5=88=B0?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/DataTable.tsx | 76 ++++++++++--------- .../src/components/endpoints/DetailDrawer.tsx | 1 + .../src/components/models/DetailDrawer.tsx | 1 + 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/frontend/src/components/DataTable.tsx b/frontend/src/components/DataTable.tsx index d4bb7e2..2982880 100644 --- a/frontend/src/components/DataTable.tsx +++ b/frontend/src/components/DataTable.tsx @@ -106,6 +106,7 @@ export interface DataTableProps { onSelectionChange?: (keys: Set) => void; selectionToolbarContent?: ReactNode; showJumper?: boolean; + showCustomPageSize?: boolean; } // 通用DataTable组件 @@ -144,6 +145,7 @@ export const DataTable = ({ onSelectionChange, selectionToolbarContent, showJumper = true, + showCustomPageSize = true, }: DataTableProps) => { // 获取表头列 const headerColumns = React.useMemo(() => { @@ -333,41 +335,45 @@ export const DataTable = ({ {size} ))} - - { - e.preventDefault(); - e.stopPropagation(); - applyCustomPageSize(); - }} - > - 应用 - - } - startContent={ - - } - textValue="自定义页面大小" - /> - + {showCustomPageSize && ( + + { + e.preventDefault(); + e.stopPropagation(); + applyCustomPageSize(); + }} + > + 应用 + + } + startContent={ + + } + textValue="自定义页面大小" + /> + + )} )} diff --git a/frontend/src/components/endpoints/DetailDrawer.tsx b/frontend/src/components/endpoints/DetailDrawer.tsx index a1d77e6..8fabf77 100644 --- a/frontend/src/components/endpoints/DetailDrawer.tsx +++ b/frontend/src/components/endpoints/DetailDrawer.tsx @@ -251,6 +251,7 @@ const EndpointDetailDrawer = ({ renderCell={renderCell} selectedSize={size} setSize={setSize} + showCustomPageSize={false} title="可用模型" total={endpoint.ai_models.total} onPageChange={handlePageChange} diff --git a/frontend/src/components/models/DetailDrawer.tsx b/frontend/src/components/models/DetailDrawer.tsx index d913aad..aeec424 100644 --- a/frontend/src/components/models/DetailDrawer.tsx +++ b/frontend/src/components/models/DetailDrawer.tsx @@ -241,6 +241,7 @@ const ModelDetailDrawer = ({ id, isOpen, onClose }: ModelDetailProps) => { renderCell={renderCell} selectedSize={size} setSize={setSize} + showCustomPageSize={false} title="可用端点" total={model.endpoints.total} onPageChange={handlePageChange} From 573cffc2c794ea3b2fc2038378a5e0f53fd0781c Mon Sep 17 00:00:00 2001 From: Timlzh Date: Sat, 7 Jun 2025 19:12:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E9=9D=9E=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/settings.tsx | 56 +++++++++++++++++---------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/frontend/src/pages/settings.tsx b/frontend/src/pages/settings.tsx index b4f4d79..9305577 100644 --- a/frontend/src/pages/settings.tsx +++ b/frontend/src/pages/settings.tsx @@ -178,34 +178,36 @@ const Settings = () => { - -

系统设置

-
-
-
- - setUpdateEndpointTaskInterval(Number(e.target.value)) - } - /> -
-
- + {isAdmin && ( + +

系统设置

+ +
+
+ + setUpdateEndpointTaskInterval(Number(e.target.value)) + } + /> +
+
+ +
-
- - + + + )}

账户信息