From d47190f1fd9c9d17973f6b069a04ef9cab974ed7 Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Fri, 22 Aug 2025 23:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20refactor(settings):=20remove=20m?= =?UTF-8?q?odels=20API=20usage=20from=20Personal=20Settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../components/settings/PersonalSetting.jsx | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/web/src/components/settings/PersonalSetting.jsx b/web/src/components/settings/PersonalSetting.jsx index 0c98509e..6ae55cfa 100644 --- a/web/src/components/settings/PersonalSetting.jsx +++ b/web/src/components/settings/PersonalSetting.jsx @@ -65,7 +65,6 @@ const PersonalSetting = () => { const [disableButton, setDisableButton] = useState(false); const [countdown, setCountdown] = useState(30); const [systemToken, setSystemToken] = useState(''); - const [models, setModels] = useState([]); const [notificationSettings, setNotificationSettings] = useState({ warningType: 'email', warningThreshold: 100000, @@ -75,7 +74,6 @@ const PersonalSetting = () => { acceptUnsetModelRatioModel: false, recordIpLog: false, }); - const [modelsLoading, setModelsLoading] = useState(true); useEffect(() => { let status = localStorage.getItem('status'); @@ -90,7 +88,6 @@ const PersonalSetting = () => { getUserData().then((res) => { console.log(userState); }); - loadModels().then(); }, []); 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) => { e.target.select(); await copy(e.target.value);