Просмотр исходного кода

🧹 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
t0ng7u 6 месяцев назад
Родитель
Сommit
d47190f1fd
1 измененных файлов с 0 добавлено и 24 удалено
  1. 0 24
      web/src/components/settings/PersonalSetting.jsx

+ 0 - 24
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);