Merge pull request #1957 from dataease/pr@dev@fix_link_pwd

fix: 增加公共链接密码强度
This commit is contained in:
fit2cloud-chenyw 2022-03-23 15:03:18 +08:00 committed by GitHub
commit d5e5960054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -5,3 +5,14 @@ export function pdfTemplateReplaceAll(content, source, target) {
return content return content
} }
export function randomRange(min, max) {
let returnStr = ''
const range = (max ? Math.round(Math.random() * (max - min)) + min : min)
const charStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
for (var i = 0; i < range; i++) {
var index = Math.round(Math.random() * (charStr.length - 1))
returnStr += charStr.substring(index, index + 1)
}
return returnStr
}

View File

@ -77,6 +77,7 @@ import {
shortUrl, shortUrl,
setOverTime setOverTime
} from '@/api/link' } from '@/api/link'
import { randomRange } from '@/utils/StringUtils'
export default { export default {
name: 'LinkGenerate', name: 'LinkGenerate',
@ -171,14 +172,7 @@ export default {
}, },
createPwd() { createPwd() {
const randomNum = () => { return randomRange(this.pwdNums)
return Math.floor(Math.random() * 10) + ''
}
let result = ''
for (let index = 0; index < this.pwdNums; index++) {
result += randomNum()
}
return result
}, },
resetPwd() { resetPwd() {