🧹 refactor(settings): remove models API usage from Personal Settings
Personal Settings no longer needs to fetch `/api/user/models` since models are now displayed directly. This change removes the unused data flow to simplify the component and avoid unnecessary requests. Changes: - Removed `models` and `modelsLoading` state from `web/src/components/settings/PersonalSetting.jsx` - Removed `loadModels` function and its invocation in the initial effect - Kept UI behavior unchanged; no functional differences on the Personal Settings page Notes: - Lint passes with no new issues - Other parts of the app still using `/api/user/models` (e.g., Tokens pages) are intentionally left intact Rationale: - Models are already displayed; the API call in Personal Settings became redundant
This commit is contained in:
@@ -65,7 +65,6 @@ const PersonalSetting = () => {
|
|||||||
const [disableButton, setDisableButton] = useState(false);
|
const [disableButton, setDisableButton] = useState(false);
|
||||||
const [countdown, setCountdown] = useState(30);
|
const [countdown, setCountdown] = useState(30);
|
||||||
const [systemToken, setSystemToken] = useState('');
|
const [systemToken, setSystemToken] = useState('');
|
||||||
const [models, setModels] = useState([]);
|
|
||||||
const [notificationSettings, setNotificationSettings] = useState({
|
const [notificationSettings, setNotificationSettings] = useState({
|
||||||
warningType: 'email',
|
warningType: 'email',
|
||||||
warningThreshold: 100000,
|
warningThreshold: 100000,
|
||||||
@@ -75,7 +74,6 @@ const PersonalSetting = () => {
|
|||||||
acceptUnsetModelRatioModel: false,
|
acceptUnsetModelRatioModel: false,
|
||||||
recordIpLog: false,
|
recordIpLog: false,
|
||||||
});
|
});
|
||||||
const [modelsLoading, setModelsLoading] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let status = localStorage.getItem('status');
|
let status = localStorage.getItem('status');
|
||||||
@@ -90,7 +88,6 @@ const PersonalSetting = () => {
|
|||||||
getUserData().then((res) => {
|
getUserData().then((res) => {
|
||||||
console.log(userState);
|
console.log(userState);
|
||||||
});
|
});
|
||||||
loadModels().then();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -148,27 +145,6 @@ const PersonalSetting = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadModels = async () => {
|
|
||||||
setModelsLoading(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
let res = await API.get(`/api/user/models`);
|
|
||||||
const { success, message, data } = res.data;
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
if (data != null) {
|
|
||||||
setModels(data);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
showError(message);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
showError(t('加载模型列表失败'));
|
|
||||||
} finally {
|
|
||||||
setModelsLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSystemTokenClick = async (e) => {
|
const handleSystemTokenClick = async (e) => {
|
||||||
e.target.select();
|
e.target.select();
|
||||||
await copy(e.target.value);
|
await copy(e.target.value);
|
||||||
|
|||||||
Reference in New Issue
Block a user