mirror of https://gitee.com/xiaonuobase/snowy
【新增】前端增加一个获取随机码方法跟验证方式
parent
563bdda3fa
commit
0ec1157932
|
@ -59,5 +59,9 @@ export const rules = {
|
||||||
initialYesBackslashChart: {
|
initialYesBackslashChart: {
|
||||||
pattern: /^\/[^/].*$/,
|
pattern: /^\/[^/].*$/,
|
||||||
message: '首字母必须是反斜杠 “/”'
|
message: '首字母必须是反斜杠 “/”'
|
||||||
|
},
|
||||||
|
mustBeLetters: {
|
||||||
|
pattern: /^[a-zA-Z]+$/,
|
||||||
|
message: '输入内容必须是英文字母'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,17 @@ tool.snowyUuid = () => {
|
||||||
return 'xn' + uuid.slice(2)
|
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) => {
|
tool.parseTime = (time, cFormat) => {
|
||||||
if (time == null || time.length === 0) {
|
if (time == null || time.length === 0) {
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in New Issue