From 702d10f6b4cfa619c32fbe2000e9bfe8a446503f Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Mon, 23 Sep 2024 08:09:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/system/menu/data.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/web-antd/src/views/system/menu/data.tsx b/apps/web-antd/src/views/system/menu/data.tsx index 426626bc..7b8d437b 100644 --- a/apps/web-antd/src/views/system/menu/data.tsx +++ b/apps/web-antd/src/views/system/menu/data.tsx @@ -137,11 +137,15 @@ export const drawerSchema: FormSchemaGetter = () => [ rules: (model) => { // 非链接时为必填项 if (model.path && !/^https?:\/\//.test(model.path)) { - // TODO 有bug 不会显示此处的校验信息 - console.log('非链接时必填组件路径'); - return z.string({ message: '非链接时必填组件路径' }); + return z + .string() + .min(1, { message: '非链接时必填组件路径' }) + .refine((val) => !val.startsWith('/') && !val.endsWith('/'), { + message: '组件路径开头/末尾不需要带/', + }); } - return z.string({ message: '请输入' }).optional(); + // 为链接时非必填 + return z.string().optional(); }, // 类型为菜单时显示 show: (values) => values.menuType === 'C',