feat: 首页适配移动端,新增工具:随机密码生成

This commit is contained in:
taoran
2023-12-04 17:57:20 +08:00
parent 24b80f04c2
commit 48bf2b2198
10 changed files with 262 additions and 21 deletions
+18 -1
View File
@@ -50,9 +50,26 @@ export function copy(resStr: string) {
}
}
/**
* 按指定字符生成随机字符串(场景:生成随机密码)
*
* @param char
* @param length
* @returns
*/
export function genRandomStrByChars(chars: string, length: number): string {
let password = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * chars.length);
password += chars[randomIndex];
}
return password;
}
const StringUtils = {
transferred,
copy
copy,
genRandomStrByChars
}
export default StringUtils