重构消息通知弹窗
This commit is contained in:
parent
21f0b965bc
commit
1838a26494
@ -30,7 +30,7 @@ import {
|
|||||||
} from '@/components/ui/select';
|
} from '@/components/ui/select';
|
||||||
import { useToast } from '@/components/ui/use-toast';
|
import { useToast } from '@/components/ui/use-toast';
|
||||||
import type { ServerResponse, ServerCategoryResponse } from '../types';
|
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 { createServer, updateServer, getServerCategories } from '../service';
|
||||||
import { serverFormSchema, type ServerFormValues } from '../schema';
|
import { serverFormSchema, type ServerFormValues } from '../schema';
|
||||||
import { Eye, EyeOff, X, Plus } from 'lucide-react';
|
import { Eye, EyeOff, X, Plus } from 'lucide-react';
|
||||||
@ -111,6 +111,7 @@ export const ServerEditDialog: React.FC<ServerEditDialogProps> = ({
|
|||||||
osType: server.osType,
|
osType: server.osType,
|
||||||
osVersion: server.osVersion || '',
|
osVersion: server.osVersion || '',
|
||||||
hostname: server.hostname || '',
|
hostname: server.hostname || '',
|
||||||
|
status: server.status,
|
||||||
description: server.description || '',
|
description: server.description || '',
|
||||||
cpuCores: server.cpuCores,
|
cpuCores: server.cpuCores,
|
||||||
memorySize: server.memorySize,
|
memorySize: server.memorySize,
|
||||||
@ -131,6 +132,7 @@ export const ServerEditDialog: React.FC<ServerEditDialogProps> = ({
|
|||||||
osType: undefined,
|
osType: undefined,
|
||||||
osVersion: '',
|
osVersion: '',
|
||||||
hostname: '',
|
hostname: '',
|
||||||
|
status: ServerStatus.UNKNOWN,
|
||||||
description: '',
|
description: '',
|
||||||
cpuCores: undefined,
|
cpuCores: undefined,
|
||||||
memorySize: undefined,
|
memorySize: undefined,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { z } from 'zod';
|
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(),
|
osType: z.nativeEnum(OsType).optional(),
|
||||||
osVersion: z.string().max(100, '操作系统版本不能超过100个字符').optional(),
|
osVersion: z.string().max(100, '操作系统版本不能超过100个字符').optional(),
|
||||||
hostname: 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(),
|
description: z.string().max(500, '描述不能超过500个字符').optional(),
|
||||||
cpuCores: z.number().min(1, 'CPU核心数必须大于0').optional(),
|
cpuCores: z.number().min(1, 'CPU核心数必须大于0').optional(),
|
||||||
memorySize: z.number().min(1, '内存大小必须大于0').optional(),
|
memorySize: z.number().min(1, '内存大小必须大于0').optional(),
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import type {
|
|||||||
ServerResponse,
|
ServerResponse,
|
||||||
ServerRequest,
|
ServerRequest,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
import type { ServerFormValues } from './schema';
|
||||||
import type { Page } from '@/types/base';
|
import type { Page } from '@/types/base';
|
||||||
|
|
||||||
// API 基础路径
|
// 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);
|
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);
|
request.put<ServerResponse>(`${SERVER_URL}/${id}`, data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -182,6 +182,8 @@ export interface ServerRequest {
|
|||||||
osVersion?: string;
|
osVersion?: string;
|
||||||
/** 主机名 */
|
/** 主机名 */
|
||||||
hostname?: string;
|
hostname?: string;
|
||||||
|
/** 连接状态(更新时保留原状态) */
|
||||||
|
status?: ServerStatus;
|
||||||
/** 描述 */
|
/** 描述 */
|
||||||
description?: string;
|
description?: string;
|
||||||
/** CPU核心数 */
|
/** CPU核心数 */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user