统一全系统资源加载、轻量趋势与缓存恢复
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Alert, App, Button, Descriptions, Form, Input, Modal, Tabs } from 'antd';
|
||||
import { api } from './api';
|
||||
import type { AuthUser } from './types';
|
||||
@@ -20,6 +20,7 @@ export default function PersonalAccount({ user, tab, onClose, onUserChange, onUn
|
||||
const [form] = Form.useForm<PasswordValues>();
|
||||
const [activeTab, setActiveTab] = useState<AccountTab>('profile');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const savingRef = useRef(false);
|
||||
const [error, setError] = useState('');
|
||||
const forced = user.forcePasswordChange === true;
|
||||
const open = tab !== null || forced;
|
||||
@@ -29,6 +30,8 @@ export default function PersonalAccount({ user, tab, onClose, onUserChange, onUn
|
||||
}, [open, tab, forced, form]);
|
||||
|
||||
const save = async (values: PasswordValues) => {
|
||||
if (savingRef.current) return;
|
||||
savingRef.current = true;
|
||||
setBusy(true); setError('');
|
||||
try {
|
||||
await api.changePassword(values.currentPassword, values.newPassword);
|
||||
@@ -38,7 +41,7 @@ export default function PersonalAccount({ user, tab, onClose, onUserChange, onUn
|
||||
message.success('密码已修改,下次登录请使用新密码');
|
||||
} catch (failure) {
|
||||
if (!onUnauthorized(failure)) setError(failure instanceof Error ? failure.message : '修改失败,请重试');
|
||||
} finally { setBusy(false); }
|
||||
} finally { savingRef.current = false; setBusy(false); }
|
||||
};
|
||||
|
||||
return <Modal className="personal-account-modal" open={open} title="个人账户" width={520} footer={null}
|
||||
|
||||
Reference in New Issue
Block a user