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 @@ -