Przeglądaj źródła

fix(1.52.0 -> 1.53.0):优化网络设置IP配置功能

- 在 ip.tsx 中移除硬编码的模拟网络数据,实现异步网络信息获取
- 添加 ServerConfig 类型约束,提高代码类型安全性
- 改进网络接口列表渲染逻辑,过滤无效IP地址
- 优化错误处理和API响应验证,确保数据获取的可靠性

改动文件:
- .vscode/launch.json
- src/pages/system/SettingsModal/sections/Network/ip.tsx
- CHANGELOG.md
- package.json
szy 6 dni temu
rodzic
commit
c37dbe08a9

+ 7 - 0
.vscode/launch.json

@@ -1,6 +1,13 @@
 {
   "version": "0.2.1",
   "configurations": [
+    {
+      "name": "Launch Chrome",
+      "request": "launch",
+      "type": "chrome",
+      "url": "http://localhost:10086",
+      "webRoot": "${workspaceFolder}"
+    },
     {
       "name": "Debug Electron Main Process",
       "type": "node",

+ 15 - 0
CHANGELOG.md

@@ -2,6 +2,21 @@
 
 本项目的所有重要变更都将记录在此文件中。
 
+## [1.53.0] - 2026-01-06 14:03
+
+### 修复 (Fixed)
+
+- **优化网络设置IP配置功能** - 重构IP设置组件,使用真实网络API替代模拟数据,提升功能完整性和用户体验
+  - 在 ip.tsx 中移除硬编码的模拟网络数据,实现异步网络信息获取
+  - 添加 ServerConfig 类型约束,提高代码类型安全性
+  - 改进网络接口列表渲染逻辑,过滤无效IP地址
+  - 优化错误处理和API响应验证,确保数据获取的可靠性
+
+**改动文件:**
+
+- .vscode/launch.json
+- src/pages/system/SettingsModal/sections/Network/ip.tsx
+
 ## [1.52.0] - 2026-01-06 13:14
 
 ### 新增 (Added)

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "zsis",
-  "version": "1.52.0",
+  "version": "1.53.0",
   "private": true,
   "description": "医学成像系统",
   "main": "main.js",

+ 24 - 60
src/pages/system/SettingsModal/sections/Network/ip.tsx

@@ -1,60 +1,18 @@
 import React, { useEffect, useState } from 'react';
 import { Radio, Card, Button, Typography, Space, Tag } from 'antd';
 import { InfoCircleOutlined } from '@ant-design/icons';
-import ConfigService from '../../../../../features/serverConfig/services/ConfigService';
+import ConfigService, {
+  DEFAULT_SERVER_CONFIG,
+} from '../../../../../features/serverConfig/services/ConfigService';
 import { getNetInfo, NetInfo } from '../../../../../API/system/network';
 import { SPACING } from '../../constants';
+import { ServerConfig } from '@/features/serverConfig/types';
 
 const Ip: React.FC = () => {
   const [netList, setNetList] = useState<NetInfo[]>([]);
-  const [serverInfo, setServerInfo] = useState({});
-
-  const getNetInfoData = async (): Promise<void> => {
-    const res = getNetInfo();
-    console.log('res', res);
-    setNetList([
-      {
-        name: 'eth0',
-        ipv4: '192.168.100.100',
-        ipv6: '',
-        flags: 'up|broadcast|multicast',
-        enabled: true,
-        type: 'ethernet',
-        state: 'connected',
-        connection: '(externally)  eth0',
-      },
-      {
-        name: 'eth0',
-        ipv4: '127.0.0.1',
-        ipv6: '',
-        flags: 'up|broadcast|multicast',
-        enabled: true,
-        type: 'ethernet',
-        state: 'connected',
-        connection: '(externally)  eth0',
-      },
-      {
-        name: 'eth1',
-        ipv4: '192.168.11.252',
-        ipv6: '',
-        flags: 'up|broadcast|multicast',
-        enabled: true,
-        type: 'ethernet',
-        state: 'connected',
-        connection: '(externally)  eth1',
-      },
-      {
-        name: 'wlP4p65s0',
-        ipv4: '192.168.110.13',
-        ipv6: 'fe80::a7d6:8818:341c:5656',
-        flags: 'up|broadcast|multicast|running',
-        enabled: true,
-        type: 'wifi',
-        state: 'connected',
-        connection: 'zskkxk_5G',
-      },
-    ]);
-  };
+  const [serverInfo, setServerInfo] = useState<ServerConfig>(
+    DEFAULT_SERVER_CONFIG
+  );
 
   const { Text } = Typography;
 
@@ -75,9 +33,13 @@ const Ip: React.FC = () => {
     const serveRes = await ConfigService.getServerConfig();
     setServerInfo(serveRes);
   };
-
+  const getNetInfoData = async (): Promise<void> => {
+    const res = await getNetInfo();
+    if (res?.code === '0x000000') {
+      setNetList(res?.data || []);
+    }
+  };
   const saveServerInfo = () => {
-    console.log('serverInfo==========================>', serverInfo);
     ConfigService.saveServerConfig(serverInfo);
   };
 
@@ -89,21 +51,23 @@ const Ip: React.FC = () => {
   return (
     <div style={{ padding: SPACING.LG }}>
       <Space direction="vertical" style={{ display: 'flex' }}>
-        {serverInfo.ip}
         <Card title="IP地址配置" variant="borderless">
           <Radio.Group
             style={radioStyle}
             onChange={onChange}
             value={serverInfo.ip}
           >
-            {netList.map((k) => (
-              <Radio key={k.ipv4} value={k.ipv4}>
-                {k.ipv4}{' '}
-                {k.type === 'wifi' && (
-                  <Tag bordered={false}>{k.connection}</Tag>
-                )}
-              </Radio>
-            ))}
+            {netList.map(
+              (k) =>
+                k.ipv4 && (
+                  <Radio key={k.ipv4} value={k.ipv4}>
+                    {k.ipv4}
+                    {k.type === 'wifi' && (
+                      <Tag bordered={false}>{k.connection}</Tag>
+                    )}
+                  </Radio>
+                )
+            )}
           </Radio.Group>
         </Card>
         <Text type="secondary">