Compare commits
2 Commits
696b906f48
...
9f6b860f5f
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f6b860f5f | |||
| 1d4805fcd7 |
@ -233,4 +233,9 @@
|
|||||||
.close-btn:focus-visible {
|
.close-btn:focus-visible {
|
||||||
background-color: #f3f4f6;
|
background-color: #f3f4f6;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* react-select fallback:确保菜单出现在顶层 */
|
||||||
|
.react-select__menu {
|
||||||
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
154
src/components/SettingsEditor.css
Normal file
154
src/components/SettingsEditor.css
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
|
||||||
|
/* 子网项布局:一行内显示,按钮靠右 */
|
||||||
|
.subnet-add-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-add-row .subnet-input {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-node-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border: 1px solid #f0f0f0;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-node-label {
|
||||||
|
color: #333;
|
||||||
|
font-size: 13px;
|
||||||
|
flex: 1;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-node-item .btn-node-remove {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #ef4444;
|
||||||
|
color: #ef4444;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-node-item .btn-node-remove:hover {
|
||||||
|
background: #fff5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 删除子网行:分割线 + 按钮靠右 */
|
||||||
|
.subnet-remove-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 10px;
|
||||||
|
margin-top: 8px;
|
||||||
|
border-top: 1px solid #eef2f5; /* 横杠分隔 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-remove-subnet {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #ef4444;
|
||||||
|
color: #ef4444;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-remove-subnet:hover {
|
||||||
|
background: #fff5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 顶部“添加子网”区域优化 */
|
||||||
|
.add-subnet {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-subnet .subnet-input {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
padding: 8px 10px;
|
||||||
|
border: 1px solid #e6e6e6;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-subnet .btn-add {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid #1677ff;
|
||||||
|
background: #1677ff;
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-subnet .btn-add:hover {
|
||||||
|
filter: brightness(1.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-list > label {
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 节点名称与 CIDR 区分样式 */
|
||||||
|
.subnet-node-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-node-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-node-label .node-name {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #0f172a;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subnet-node-label .cidr-tag {
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', 'Courier New', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #6b7280;
|
||||||
|
background: #f3f4f6;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ import { useState, ReactNode } from 'react';
|
|||||||
import { Settings, SubnetInfo, AppEdge, AppNode } from '../types/graph';
|
import { Settings, SubnetInfo, AppEdge, AppNode } from '../types/graph';
|
||||||
import { useReactFlow} from '@xyflow/react';
|
import { useReactFlow} from '@xyflow/react';
|
||||||
import './FormEditor.css';
|
import './FormEditor.css';
|
||||||
|
import './SettingsEditor.css';
|
||||||
import Folder from './Folder';
|
import Folder from './Folder';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { IPUtils } from '../utils/iputils';
|
import { IPUtils } from '../utils/iputils';
|
||||||
@ -105,12 +106,15 @@ function SubnetItem({index, subnets, setSubnets} : SubnetProps) : ReactNode {
|
|||||||
setSubnets(subnets.filter((_, idx) => idx != index));
|
setSubnets(subnets.filter((_, idx) => idx != index));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (<Folder title={subnetInfo.subnet.toString()}>
|
return (<Folder title={subnetInfo.subnet.toString()}>
|
||||||
<div>
|
<div className="subnet-add-row">
|
||||||
<Select
|
<Select
|
||||||
onChange={setSelectedOption}
|
onChange={setSelectedOption}
|
||||||
options={options}
|
options={options}
|
||||||
placeholder="请选择节点..."
|
placeholder="请选择节点..."
|
||||||
|
menuPosition="fixed"
|
||||||
|
menuPortalTarget={typeof document !== 'undefined' ? document.body : undefined}
|
||||||
|
styles={{ menuPortal: (base) => ({ ...base, zIndex: 9999 }) }}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@ -124,15 +128,18 @@ function SubnetItem({index, subnets, setSubnets} : SubnetProps) : ReactNode {
|
|||||||
const node = getNode(nodeInfo.nodeId);
|
const node = getNode(nodeInfo.nodeId);
|
||||||
if(!node) return <></>
|
if(!node) return <></>
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="subnet-node-item" key={nodeInfo.nodeId}>
|
||||||
<label>- {`${node.data.label}: ${nodeInfo.cidr?.toString()}`}</label>
|
<label className="subnet-node-label">
|
||||||
<button onClick={_ => handleRemoveNodeSubnet(nodeInfo.nodeId)}>删除</button>
|
<span className="node-name" title={node.data.label}>{node.data.label}</span>
|
||||||
|
<span className="cidr-tag">{nodeInfo.cidr?.toString() || ''}</span>
|
||||||
|
</label>
|
||||||
|
<button className="btn-node-remove" onClick={_ => handleRemoveNodeSubnet(nodeInfo.nodeId)}>删除</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<div>
|
<div className="subnet-remove-row">
|
||||||
<button onClick={_ => handleRemoveSubnet()}>删除子网</button>
|
<button className="btn-remove-subnet" onClick={_ => handleRemoveSubnet()}>删除子网</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</Folder>
|
</Folder>
|
||||||
@ -244,7 +251,7 @@ export default function SettingsEditor({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="subnet-list">
|
<div className="subnet-list">
|
||||||
<label>已添加的子网:</label>
|
{subnets.length > 0 && (<label>已添加的子网:</label>)}
|
||||||
{subnets.map((_, idx) =>
|
{subnets.map((_, idx) =>
|
||||||
<SubnetItem
|
<SubnetItem
|
||||||
key={idx}
|
key={idx}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user