From 7b25c9962f7d35db70b249ca78f79bbdd955ddf6 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 13 Aug 2024 09:40:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E7=BD=AE=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=A4=A7=E5=B0=8F=E5=86=99=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E5=8A=A0=E6=95=B0=E5=AD=97=EF=BC=8C=E6=89=8D=E8=83=BD=E8=BF=99?= =?UTF-8?q?=E5=9B=BD=E5=86=85=E4=BE=9B=E5=BA=94=E5=95=86=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Account.js | 14 ++++++++++++++ src/views/account/Management.jsx | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/stores/Account.js b/src/stores/Account.js index 186a989..7a692c2 100644 --- a/src/stores/Account.js +++ b/src/stores/Account.js @@ -68,6 +68,20 @@ export const fetchTravelAgencyByName = async (name) => { return errcode !== 0 ? {} : result } +export const genRandomPassword = () => { + let result = '' + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + const charactersLength = characters.length + + for (let i = 0; i < 6; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)) + } + + result += '@' + (Math.floor(Math.random() * 900) + 100) + + return result +} + const useAccountStore = create(devtools((set) => ({ accountList: [], diff --git a/src/views/account/Management.jsx b/src/views/account/Management.jsx index 4740326..6f88084 100644 --- a/src/views/account/Management.jsx +++ b/src/views/account/Management.jsx @@ -1,5 +1,5 @@ import SearchForm from '@/components/SearchForm' -import useAccountStore, { fetchRoleList, fetchTravelAgencyByName } from '@/stores/Account' +import useAccountStore, { fetchRoleList, fetchTravelAgencyByName, genRandomPassword } from '@/stores/Account' import useFormStore from '@/stores/Form' import { isEmpty } from '@/utils/commons' import { ExclamationCircleFilled } from '@ant-design/icons' @@ -195,7 +195,7 @@ function Management() { const showResetPasswordConfirm = (account) => { const confirmTitle = t('account:action.resetPassword.tile') - const randomPassword = account.username + '@' + (Math.floor(Math.random() * 900) + 100) + const randomPassword = genRandomPassword() modal.confirm({ title: confirmTitle, icon: ,