|
|
@@ -0,0 +1,123 @@
|
|
|
+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 { getNetInfo, NetInfo } from '../../../../../API/system/network';
|
|
|
+import { SPACING } from '../../constants';
|
|
|
+
|
|
|
+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 { Text } = Typography;
|
|
|
+
|
|
|
+ const radioStyle: React.CSSProperties = {
|
|
|
+ display: 'flex',
|
|
|
+ flexDirection: 'column',
|
|
|
+ gap: 8,
|
|
|
+ };
|
|
|
+
|
|
|
+ const onChange = (e) => {
|
|
|
+ setServerInfo((serverInfo) => ({
|
|
|
+ ...serverInfo,
|
|
|
+ ip: e.target.value,
|
|
|
+ }));
|
|
|
+ };
|
|
|
+
|
|
|
+ const getServerInfo = async () => {
|
|
|
+ const serveRes = await ConfigService.getServerConfig();
|
|
|
+ setServerInfo(serveRes);
|
|
|
+ };
|
|
|
+
|
|
|
+ const saveServerInfo = () => {
|
|
|
+ console.log('serverInfo==========================>', serverInfo);
|
|
|
+ ConfigService.saveServerConfig(serverInfo);
|
|
|
+ };
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ getServerInfo();
|
|
|
+ getNetInfoData();
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ 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>
|
|
|
+ ))}
|
|
|
+ </Radio.Group>
|
|
|
+ </Card>
|
|
|
+ <Text type="secondary">
|
|
|
+ <InfoCircleOutlined style={{ marginRight: 6 }} />
|
|
|
+ 选择IP地址,保存后需要重启软件才能生效
|
|
|
+ </Text>
|
|
|
+ <div>
|
|
|
+ <Button type="primary" onClick={saveServerInfo}>
|
|
|
+ 保存
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </Space>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default Ip;
|