From 0ec1157932d4619fad85291aa53977794f82afed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BF=9E=E5=AE=9D=E5=B1=B1?= <1253070437@qq.com> Date: Sun, 3 Nov 2024 20:34:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E7=A0=81=E6=96=B9=E6=B3=95=E8=B7=9F=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snowy-admin-web/src/utils/formRules.js | 4 ++++ snowy-admin-web/src/utils/tool.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/snowy-admin-web/src/utils/formRules.js b/snowy-admin-web/src/utils/formRules.js index d7e0ce65..bff29df8 100644 --- a/snowy-admin-web/src/utils/formRules.js +++ b/snowy-admin-web/src/utils/formRules.js @@ -59,5 +59,9 @@ export const rules = { initialYesBackslashChart: { pattern: /^\/[^/].*$/, message: '首字母必须是反斜杠 “/”' + }, + mustBeLetters: { + pattern: /^[a-zA-Z]+$/, + message: '输入内容必须是英文字母' } } diff --git a/snowy-admin-web/src/utils/tool.js b/snowy-admin-web/src/utils/tool.js index e43efe1f..8784f807 100644 --- a/snowy-admin-web/src/utils/tool.js +++ b/snowy-admin-web/src/utils/tool.js @@ -166,6 +166,17 @@ tool.snowyUuid = () => { return 'xn' + uuid.slice(2) } +// 输入位数获得英文字母大小写随机码 +tool.generateString = (length = 8) => { + let result = '' + let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + let charactersLength = characters.length + for (let i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)) + } + return result +} + tool.parseTime = (time, cFormat) => { if (time == null || time.length === 0) { return ''