登录界面增加忘记密码. 后台增加密码重置
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
fetchAdminWorkerLevels,
|
||||
fetchAdminWorkerUsers,
|
||||
fetchAdminWorkerWithdrawalAccounts,
|
||||
resetAdminWorkerPassword,
|
||||
reviewAdminWorkerUser,
|
||||
saveAdminWorkerWithdrawalAccount,
|
||||
} from '@/services/admin'
|
||||
@@ -53,12 +54,14 @@ export default function WorkersPanel() {
|
||||
const [creditWorker, setCreditWorker] = useState<WorkerUser | null>(null)
|
||||
const [levelWorker, setLevelWorker] = useState<WorkerUser | null>(null)
|
||||
const [withdrawalAccountWorker, setWithdrawalAccountWorker] = useState<WorkerUser | null>(null)
|
||||
const [resetPasswordWorker, setResetPasswordWorker] = useState<WorkerUser | null>(null)
|
||||
const [withdrawalAccounts, setWithdrawalAccounts] = useState<AdminWorkerWithdrawalAccount[]>([])
|
||||
const [loadingWithdrawalAccounts, setLoadingWithdrawalAccounts] = useState(false)
|
||||
const [savingWithdrawalAccount, setSavingWithdrawalAccount] = useState(false)
|
||||
const [creditForm] = Form.useForm()
|
||||
const [levelForm] = Form.useForm<{ levelId?: number }>()
|
||||
const [withdrawalAccountForm] = Form.useForm<WithdrawalAccountFormValues>()
|
||||
const [resetPasswordForm] = Form.useForm<{ password: string }>()
|
||||
const withdrawalAccountChannel = Form.useWatch('accountChannel', withdrawalAccountForm)
|
||||
|
||||
const workersQuery = useQuery({
|
||||
@@ -145,6 +148,21 @@ export default function WorkersPanel() {
|
||||
}
|
||||
}
|
||||
|
||||
async function submitResetPassword(values: { password: string }) {
|
||||
if (!resetPasswordWorker) return
|
||||
try {
|
||||
await resetAdminWorkerPassword(resetPasswordWorker.workerId, {
|
||||
password: values.password.trim(),
|
||||
})
|
||||
message.success('打手密码已重置,旧登录设备已退出')
|
||||
setResetPasswordWorker(null)
|
||||
resetPasswordForm.resetFields()
|
||||
await refreshWorkers()
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '重置打手密码失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function submitLevel(values: { levelId?: number }) {
|
||||
if (!levelWorker) return
|
||||
try {
|
||||
@@ -306,6 +324,7 @@ export default function WorkersPanel() {
|
||||
调等级
|
||||
</Button>
|
||||
<Button onClick={() => setCreditWorker(row)}>充值</Button>
|
||||
<Button onClick={() => setResetPasswordWorker(row)}>重置密码</Button>
|
||||
<Button onClick={() => void openWithdrawalAccountModal(row)}>提现信息</Button>
|
||||
</Space>
|
||||
),
|
||||
@@ -387,6 +406,45 @@ export default function WorkersPanel() {
|
||||
scroll={{ x: 1000 }}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title="重置打手密码"
|
||||
open={Boolean(resetPasswordWorker)}
|
||||
onCancel={() => {
|
||||
setResetPasswordWorker(null)
|
||||
resetPasswordForm.resetFields()
|
||||
}}
|
||||
onOk={() => resetPasswordForm.submit()}
|
||||
destroyOnHidden
|
||||
>
|
||||
<Form form={resetPasswordForm} layout="vertical" onFinish={submitResetPassword}>
|
||||
<Form.Item label="打手">
|
||||
<Typography.Text>
|
||||
{resetPasswordWorker?.displayName || resetPasswordWorker?.username || '-'}
|
||||
</Typography.Text>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="新密码"
|
||||
name="password"
|
||||
rules={[
|
||||
{ required: true, message: '请输入新密码' },
|
||||
{ min: 6, message: '密码至少 6 位' },
|
||||
{
|
||||
validator: (_, value) =>
|
||||
!value ||
|
||||
(/[A-Z]/.test(value) &&
|
||||
/[a-z]/.test(value) &&
|
||||
/\d/.test(value) &&
|
||||
/[\p{P}\p{S}]/u.test(value))
|
||||
? Promise.resolve()
|
||||
: Promise.reject(new Error('密码需包含大写字母、小写字母、数字和标点符号')),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password placeholder="至少 6 位,包含大小写、数字和标点" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
title="编辑打手提现信息"
|
||||
open={Boolean(withdrawalAccountWorker)}
|
||||
|
||||
Reference in New Issue
Block a user