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: ,