重构消息通知弹窗
This commit is contained in:
parent
21f0b965bc
commit
1838a26494
@ -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<ServerEditDialogProps> = ({
|
||||
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<ServerEditDialogProps> = ({
|
||||
osType: undefined,
|
||||
osVersion: '',
|
||||
hostname: '',
|
||||
status: ServerStatus.UNKNOWN,
|
||||
description: '',
|
||||
cpuCores: undefined,
|
||||
memorySize: undefined,
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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<ServerResponse>(SERVER_URL, data);
|
||||
|
||||
/**
|
||||
* 更新服务器
|
||||
*/
|
||||
export const updateServer = (id: number, data: ServerRequest) =>
|
||||
export const updateServer = (id: number, data: ServerFormValues) =>
|
||||
request.put<ServerResponse>(`${SERVER_URL}/${id}`, data);
|
||||
|
||||
/**
|
||||
|
||||
@ -182,6 +182,8 @@ export interface ServerRequest {
|
||||
osVersion?: string;
|
||||
/** 主机名 */
|
||||
hostname?: string;
|
||||
/** 连接状态(更新时保留原状态) */
|
||||
status?: ServerStatus;
|
||||
/** 描述 */
|
||||
description?: string;
|
||||
/** CPU核心数 */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user