From 1838a26494ac922321d19bddad173f5e45028ae5 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Thu, 20 Nov 2025 17:16:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resource/Server/List/components/ServerEditDialog.tsx | 4 +++- frontend/src/pages/Resource/Server/List/schema.ts | 3 ++- frontend/src/pages/Resource/Server/List/service.ts | 5 +++-- frontend/src/pages/Resource/Server/List/types.ts | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/Resource/Server/List/components/ServerEditDialog.tsx b/frontend/src/pages/Resource/Server/List/components/ServerEditDialog.tsx index d65f156a..e9132720 100644 --- a/frontend/src/pages/Resource/Server/List/components/ServerEditDialog.tsx +++ b/frontend/src/pages/Resource/Server/List/components/ServerEditDialog.tsx @@ -30,7 +30,7 @@ import { } from '@/components/ui/select'; import { useToast } from '@/components/ui/use-toast'; import type { ServerResponse, ServerCategoryResponse } from '../types'; -import { OsType, OsTypeLabels, AuthType, AuthTypeLabels } from '../types'; +import { OsType, OsTypeLabels, AuthType, AuthTypeLabels, ServerStatus } from '../types'; import { createServer, updateServer, getServerCategories } from '../service'; import { serverFormSchema, type ServerFormValues } from '../schema'; import { Eye, EyeOff, X, Plus } from 'lucide-react'; @@ -111,6 +111,7 @@ export const ServerEditDialog: React.FC = ({ osType: server.osType, osVersion: server.osVersion || '', hostname: server.hostname || '', + status: server.status, description: server.description || '', cpuCores: server.cpuCores, memorySize: server.memorySize, @@ -131,6 +132,7 @@ export const ServerEditDialog: React.FC = ({ osType: undefined, osVersion: '', hostname: '', + status: ServerStatus.UNKNOWN, description: '', cpuCores: undefined, memorySize: undefined, diff --git a/frontend/src/pages/Resource/Server/List/schema.ts b/frontend/src/pages/Resource/Server/List/schema.ts index a34ba9ff..1c610f9c 100644 --- a/frontend/src/pages/Resource/Server/List/schema.ts +++ b/frontend/src/pages/Resource/Server/List/schema.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { OsType, AuthType } from './types'; +import { OsType, AuthType, ServerStatus } from './types'; /** * 服务器分类表单校验 @@ -41,6 +41,7 @@ export const serverFormSchema = z.object({ osType: z.nativeEnum(OsType).optional(), osVersion: z.string().max(100, '操作系统版本不能超过100个字符').optional(), hostname: z.string().max(100, '主机名不能超过100个字符').optional(), + status: z.nativeEnum(ServerStatus).optional(), description: z.string().max(500, '描述不能超过500个字符').optional(), cpuCores: z.number().min(1, 'CPU核心数必须大于0').optional(), memorySize: z.number().min(1, '内存大小必须大于0').optional(), diff --git a/frontend/src/pages/Resource/Server/List/service.ts b/frontend/src/pages/Resource/Server/List/service.ts index b1d121e2..d67a3473 100644 --- a/frontend/src/pages/Resource/Server/List/service.ts +++ b/frontend/src/pages/Resource/Server/List/service.ts @@ -6,6 +6,7 @@ import type { ServerResponse, ServerRequest, } from './types'; +import type { ServerFormValues } from './schema'; import type { Page } from '@/types/base'; // API 基础路径 @@ -87,13 +88,13 @@ export const getServer = (id: number) => /** * 创建服务器 */ -export const createServer = (data: ServerRequest) => +export const createServer = (data: ServerFormValues) => request.post(SERVER_URL, data); /** * 更新服务器 */ -export const updateServer = (id: number, data: ServerRequest) => +export const updateServer = (id: number, data: ServerFormValues) => request.put(`${SERVER_URL}/${id}`, data); /** diff --git a/frontend/src/pages/Resource/Server/List/types.ts b/frontend/src/pages/Resource/Server/List/types.ts index 78d5e2b5..893aab9a 100644 --- a/frontend/src/pages/Resource/Server/List/types.ts +++ b/frontend/src/pages/Resource/Server/List/types.ts @@ -182,6 +182,8 @@ export interface ServerRequest { osVersion?: string; /** 主机名 */ hostname?: string; + /** 连接状态(更新时保留原状态) */ + status?: ServerStatus; /** 描述 */ description?: string; /** CPU核心数 */