Browse Source

【新增】前端增加一个获取随机码方法跟验证方式

pull/240/head
俞宝山 3 weeks ago
parent
commit
0ec1157932
  1. 4
      snowy-admin-web/src/utils/formRules.js
  2. 11
      snowy-admin-web/src/utils/tool.js

4
snowy-admin-web/src/utils/formRules.js

@ -59,5 +59,9 @@ export const rules = {
initialYesBackslashChart: {
pattern: /^\/[^/].*$/,
message: '首字母必须是反斜杠 “/”'
},
mustBeLetters: {
pattern: /^[a-zA-Z]+$/,
message: '输入内容必须是英文字母'
}
}

11
snowy-admin-web/src/utils/tool.js

@ -166,6 +166,17 @@ tool.snowyUuid = () => {
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) => {
if (time == null || time.length === 0) {
return ''

Loading…
Cancel
Save