From 5186227a467bd34dc253e64b23bc96d3a07bb399 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 17 十一月 2021 17:39:53 +0800
Subject: [PATCH] 添加用户权限控制

---
 src/utils/validate.js |   76 +++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/utils/validate.js b/src/utils/validate.js
index 01100ed..bd15ad4 100644
--- a/src/utils/validate.js
+++ b/src/utils/validate.js
@@ -5,7 +5,7 @@
  * @returns {boolean}
  */
 export function isExternal(path) {
-  return /^(https?:|mailto:|tel:)/.test(path)
+  return /^(https?:|mailto:|tel:)/.test(path);
 }
 
 /**
@@ -15,7 +15,7 @@
  * @returns {boolean}
  */
 export function isPassword(str) {
-  return str.length >= 6
+  return str.length >= 5;
 }
 
 /**
@@ -25,8 +25,8 @@
  * @returns {boolean}
  */
 export function isNumber(value) {
-  const reg = /^[0-9]*$/
-  return reg.test(value)
+  const reg = /^[0-9]*$/;
+  return reg.test(value);
 }
 
 /**
@@ -36,8 +36,8 @@
  * @returns {boolean}
  */
 export function isName(value) {
-  const reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/
-  return reg.test(value)
+  const reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/;
+  return reg.test(value);
 }
 
 /**
@@ -48,8 +48,8 @@
  */
 export function isIP(ip) {
   const reg =
-    /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
-  return reg.test(ip)
+    /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
+  return reg.test(ip);
 }
 
 /**
@@ -60,8 +60,8 @@
  */
 export function isUrl(url) {
   const reg =
-    /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
-  return reg.test(url)
+    /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/;
+  return reg.test(url);
 }
 
 /**
@@ -71,8 +71,8 @@
  * @returns {boolean}
  */
 export function isLowerCase(str) {
-  const reg = /^[a-z]+$/
-  return reg.test(str)
+  const reg = /^[a-z]+$/;
+  return reg.test(str);
 }
 
 /**
@@ -82,8 +82,8 @@
  * @returns {boolean}
  */
 export function isUpperCase(str) {
-  const reg = /^[A-Z]+$/
-  return reg.test(str)
+  const reg = /^[A-Z]+$/;
+  return reg.test(str);
 }
 
 /**
@@ -93,8 +93,8 @@
  * @returns {boolean}
  */
 export function isAlphabets(str) {
-  const reg = /^[A-Za-z]+$/
-  return reg.test(str)
+  const reg = /^[A-Za-z]+$/;
+  return reg.test(str);
 }
 
 /**
@@ -104,7 +104,7 @@
  * @returns {boolean}
  */
 export function isString(str) {
-  return typeof str === 'string' || str instanceof String
+  return typeof str === "string" || str instanceof String;
 }
 
 /**
@@ -114,10 +114,10 @@
  * @returns {arg is any[]|boolean}
  */
 export function isArray(arg) {
-  if (typeof Array.isArray === 'undefined') {
-    return Object.prototype.toString.call(arg) === '[object Array]'
+  if (typeof Array.isArray === "undefined") {
+    return Object.prototype.toString.call(arg) === "[object Array]";
   }
-  return Array.isArray(arg)
+  return Array.isArray(arg);
 }
 
 /**
@@ -128,8 +128,8 @@
  */
 export function isPort(str) {
   const reg =
-    /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/
-  return reg.test(str)
+    /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/;
+  return reg.test(str);
 }
 
 /**
@@ -139,8 +139,8 @@
  * @returns {boolean}
  */
 export function isPhone(str) {
-  const reg = /^1\d{10}$/
-  return reg.test(str)
+  const reg = /^1\d{10}$/;
+  return reg.test(str);
 }
 
 /**
@@ -151,8 +151,8 @@
  */
 export function isIdCard(str) {
   const reg =
-    /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
-  return reg.test(str)
+    /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
+  return reg.test(str);
 }
 
 /**
@@ -162,8 +162,8 @@
  * @returns {boolean}
  */
 export function isEmail(str) {
-  const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
-  return reg.test(str)
+  const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
+  return reg.test(str);
 }
 
 /**
@@ -173,8 +173,8 @@
  * @returns {boolean}
  */
 export function isChina(str) {
-  const reg = /^[\u4E00-\u9FA5]{2,4}$/
-  return reg.test(str)
+  const reg = /^[\u4E00-\u9FA5]{2,4}$/;
+  return reg.test(str);
 }
 
 /**
@@ -187,10 +187,10 @@
   return (
     str == null ||
     false ||
-    str === '' ||
-    str.trim() === '' ||
-    str.toLocaleLowerCase().trim() === 'null'
-  )
+    str === "" ||
+    str.trim() === "" ||
+    str.toLocaleLowerCase().trim() === "null"
+  );
 }
 
 /**
@@ -201,8 +201,8 @@
  */
 export function isTel(str) {
   const reg =
-    /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |杞�)*([0-9]{1,4}))?$/
-  return reg.test(str)
+    /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |杞�)*([0-9]{1,4}))?$/;
+  return reg.test(str);
 }
 
 /**
@@ -212,6 +212,6 @@
  * @returns {boolean}
  */
 export function isNum(str) {
-  const reg = /^\d+(\.\d{1,2})?$/
-  return reg.test(str)
+  const reg = /^\d+(\.\d{1,2})?$/;
+  return reg.test(str);
 }

--
Gitblit v1.8.0