From f1fb378d1e62e0e6c625cfd32e871e68401b8929 Mon Sep 17 00:00:00 2001 From: LCJ-MinYa <1049468118@qq.com> Date: Thu, 22 May 2025 10:32:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=A4=E6=96=AD=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=98=AF=E5=90=A6=E4=B8=BA=E6=8C=87=E5=AE=9A=E7=9A=84?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/tools.ts | 9 +++++++ src/views/demo/tools/index.vue | 45 +++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 3e0c91d..3c8b689 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -95,6 +95,15 @@ export const date = { }, }; +/** 判断字符串不能为指定的特殊字符 */ +export const isSpecialChar = (str: string, specialChars?: string): boolean => { + if (!specialChars) { + specialChars = `~~!!@#$¥%^&*()_+-={}[]【】|\\:;"''""“”<>《》,,.。??/;;…`; + } + const specialCharsArr = specialChars.split(''); + return specialCharsArr.some((char) => str.includes(char)); +}; + export const generateUUID = () => { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { const r = (Math.random() * 16) | 0, diff --git a/src/views/demo/tools/index.vue b/src/views/demo/tools/index.vue index cbe6593..0df8d7a 100644 --- a/src/views/demo/tools/index.vue +++ b/src/views/demo/tools/index.vue @@ -1,15 +1,52 @@ -