perf[utils]: optimizate variable name
This commit is contained in:
parent
054e9c4a73
commit
5224a00ddc
|
@ -1,8 +0,0 @@
|
||||||
/**
|
|
||||||
* Created by jiachenpan on 17/3/8.
|
|
||||||
*/
|
|
||||||
export default function createUniqueString() {
|
|
||||||
const timestamp = +new Date() + ''
|
|
||||||
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
|
||||||
return (+(randomNum + timestamp)).toString(32)
|
|
||||||
}
|
|
|
@ -294,3 +294,9 @@ export function deepClone(source) {
|
||||||
export function uniqueArr(arr) {
|
export function uniqueArr(arr) {
|
||||||
return Array.from(new Set(arr))
|
return Array.from(new Set(arr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createUniqueString() {
|
||||||
|
const timestamp = +new Date() + ''
|
||||||
|
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
||||||
|
return (+(randomNum + timestamp)).toString(32)
|
||||||
|
}
|
||||||
|
|
|
@ -2,35 +2,35 @@
|
||||||
* Created by jiachenpan on 16/11/18.
|
* Created by jiachenpan on 16/11/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export function isExternal(path) {
|
||||||
|
return /^(https?:|mailto:|tel:)/.test(path)
|
||||||
|
}
|
||||||
|
|
||||||
export function validUsername(str) {
|
export function validUsername(str) {
|
||||||
const valid_map = ['admin', 'editor']
|
const valid_map = ['admin', 'editor']
|
||||||
return valid_map.indexOf(str.trim()) >= 0
|
return valid_map.indexOf(str.trim()) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isExternal(path) {
|
|
||||||
return /^(https?:|mailto:|tel:)/.test(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 合法uri*/
|
/* 合法uri*/
|
||||||
export function validateURL(textval) {
|
export function validURL(url) {
|
||||||
const urlregex = /^(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.,?'\\+&%$#=~_-]+))*$/
|
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 urlregex.test(textval)
|
return reg.test(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 小写字母*/
|
/* 小写字母*/
|
||||||
export function validateLowerCase(str) {
|
export function validLowerCase(str) {
|
||||||
const reg = /^[a-z]+$/
|
const reg = /^[a-z]+$/
|
||||||
return reg.test(str)
|
return reg.test(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 大写字母*/
|
/* 大写字母*/
|
||||||
export function validateUpperCase(str) {
|
export function validUpperCase(str) {
|
||||||
const reg = /^[A-Z]+$/
|
const reg = /^[A-Z]+$/
|
||||||
return reg.test(str)
|
return reg.test(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 大小写字母*/
|
/* 大小写字母*/
|
||||||
export function validateAlphabets(str) {
|
export function validAlphabets(str) {
|
||||||
const reg = /^[A-Za-z]+$/
|
const reg = /^[A-Za-z]+$/
|
||||||
return reg.test(str)
|
return reg.test(str)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ export function validateAlphabets(str) {
|
||||||
* @param email
|
* @param email
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function validateEmail(email) {
|
export function validEmail(email) {
|
||||||
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||||
return re.test(email)
|
return re.test(email)
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ import Tinymce from '@/components/Tinymce'
|
||||||
import Upload from '@/components/Upload/singleImage3'
|
import Upload from '@/components/Upload/singleImage3'
|
||||||
import MDinput from '@/components/MDinput'
|
import MDinput from '@/components/MDinput'
|
||||||
import Sticky from '@/components/Sticky' // 粘性header组件
|
import Sticky from '@/components/Sticky' // 粘性header组件
|
||||||
import { validateURL } from '@/utils/validate'
|
import { validURL } from '@/utils/validate'
|
||||||
import { fetchArticle } from '@/api/article'
|
import { fetchArticle } from '@/api/article'
|
||||||
import { userSearch } from '@/api/remoteSearch'
|
import { userSearch } from '@/api/remoteSearch'
|
||||||
import Warning from './Warning'
|
import Warning from './Warning'
|
||||||
|
@ -121,7 +121,7 @@ export default {
|
||||||
}
|
}
|
||||||
const validateSourceUri = (rule, value, callback) => {
|
const validateSourceUri = (rule, value, callback) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
if (validateURL(value)) {
|
if (validURL(value)) {
|
||||||
callback()
|
callback()
|
||||||
} else {
|
} else {
|
||||||
this.$message({
|
this.$message({
|
||||||
|
|
Loading…
Reference in New Issue