feat: menu

This commit is contained in:
2025-09-17 10:41:00 +08:00
parent 9d5a289929
commit aada97ed22
27 changed files with 973 additions and 527 deletions

View File

@@ -0,0 +1,43 @@
// 常用的校验规则配置
// rules: [
// { required: true, message: '请输入用户名' },
// { min: 3, max: 20, message: '用户名长度为3-20个字符' },
// { pattern: /^[a-zA-Z0-9_]+$/, message: '用户名只能包含字母、数字和下划线' },
// ],
const commonRules = {
// 必填
required: { required: true, message: "此项为必填项" },
// 邮箱
email: { type: "email", message: "请输入正确的邮箱格式" },
// 手机号
phone: { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号格式" },
// 身份证
idCard: {
pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
message: "请输入正确的身份证号",
},
// 密码强度
strongPassword: {
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d@$!%*?&]{8,}$/,
message: "密码必须包含大小写字母、数字至少8位",
},
// 数字范围
numberRange: (min: number, max: number) => ({
type: "number",
min,
max,
message: `请输入${min}-${max}之间的数字`,
}),
// 字符长度
lengthRange: (min: number, max: number) => ({
min,
max,
message: `长度为${min}-${max}个字符`,
}),
};

View File

@@ -2,7 +2,8 @@
import React from "react";
import { ProColumns } from "@ant-design/pro-components";
import { Tag } from "antd";
import { ICONS, IconType } from "@/constants/icons";
import { history, useIntl } from "@umijs/max";
import { ICONS, IconType } from "@/constants/antd/icons";
import {
TableAction,
ToolbarAction,
@@ -129,13 +130,18 @@ export const createCommonToolbarActions = (handlers: {
onImport?: () => void;
}): ToolbarAction[] => {
const actions: ToolbarAction[] = [];
if (handlers.onAdd) {
actions.push(
createToolbarAction("add", "新建", "add", handlers.onAdd, {
type: "primary",
permission: "add",
})
createToolbarAction(
"add",
useIntl().formatMessage({ id: "pages.searchTable.new" }),
"add",
handlers.onAdd,
{
type: "primary",
permission: "add",
}
)
);
}