seeder-st2110-components 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2306,15 +2306,16 @@ const NetworkSettingsModal = _ref2 => {
2306
2306
  const [lanConfigs, setLanConfigs] = react.useState([]);
2307
2307
  const [submitLoading, setSubmitLoading] = react.useState(false);
2308
2308
  const [isInitialized, setIsInitialized] = react.useState(false);
2309
- const hasFetchedRef = react.useRef(false);
2310
- const hasInitializedRef = react.useRef(false); // 确保表单初始值只设置一次
2311
-
2309
+ const initializationStatus = react.useRef({
2310
+ hasFetched: false,
2311
+ hasInitialized: false
2312
+ });
2312
2313
  react.useEffect(() => {
2313
2314
  if (!open) return;
2314
2315
  const fetchData = async () => {
2315
- if (hasFetchedRef.current) return;
2316
+ if (initializationStatus.current.hasFetched) return;
2316
2317
  try {
2317
- hasFetchedRef.current = true;
2318
+ initializationStatus.current.hasFetched = true;
2318
2319
  const promises = [];
2319
2320
  if (sections.includes('LAN')) {
2320
2321
  promises.push(getLanConfig());
@@ -2338,6 +2339,7 @@ const NetworkSettingsModal = _ref2 => {
2338
2339
  setIsInitialized(true);
2339
2340
  } catch (error) {
2340
2341
  console.error('Failed to fetch data:', error);
2342
+ initializationStatus.current.hasFetched = false; // 出错时重置
2341
2343
  }
2342
2344
  };
2343
2345
  fetchData();
@@ -2350,7 +2352,10 @@ const NetworkSettingsModal = _ref2 => {
2350
2352
  setLanConfigs([]);
2351
2353
  setSt2110Interfaces([]);
2352
2354
  form.resetFields();
2353
- hasFetchedRef.current = false;
2355
+ initializationStatus.current = {
2356
+ hasFetched: false,
2357
+ hasInitialized: false
2358
+ };
2354
2359
  }
2355
2360
  }, [open, form]);
2356
2361
 
@@ -2377,9 +2382,9 @@ const NetworkSettingsModal = _ref2 => {
2377
2382
 
2378
2383
  // 当初始值准备好后设置表单值
2379
2384
  react.useEffect(() => {
2380
- if (isInitialized && !hasInitializedRef.current) {
2385
+ if (isInitialized && !initializationStatus.current.hasInitialized) {
2381
2386
  form.setFieldsValue(initialValues);
2382
- hasInitializedRef.current = true;
2387
+ initializationStatus.current.hasInitialized = true;
2383
2388
  }
2384
2389
  }, [isInitialized, form, initialValues]);
2385
2390
  const handleSuccess = react.useCallback(async function () {
@@ -2427,8 +2432,7 @@ const NetworkSettingsModal = _ref2 => {
2427
2432
  const st2110Data = {
2428
2433
  st2110_interfaces: values.QSFP.map((item, index) => ({
2429
2434
  id: st2110Interfaces?.[index]?.id,
2430
- ip_address: item.ip_address,
2431
- enable_rx_video_demand_start: st2110Interfaces?.[index]?.enable_rx_video_demand_start
2435
+ ip_address: item.ip_address
2432
2436
  }))
2433
2437
  };
2434
2438
  updatePromises.push(updateSysConfig(st2110Data));