临时提交

This commit is contained in:
fengfeng 2026-02-02 12:04:37 +08:00
parent a81869c96d
commit 9635b00e07
2 changed files with 16 additions and 3 deletions

View File

@ -53,7 +53,7 @@ function getFirstAvailableId(ids: number[]) : number {
} }
function generateNodeData(nodes : NodeData[]) : NodeData | null { function generateNodeData(nodes : NodeData[]) : NodeData | null {
const hostId = getFirstAvailableId(nodes.map(n => n.hostId)) const hostId = getFirstAvailableId(nodes.filter(n => n.groupId == 0).map(n => n.hostId))
if(hostId > 255) return null if(hostId > 255) return null
const privateKey = generateWireGuardPrivateKey(); const privateKey = generateWireGuardPrivateKey();

View File

@ -1,5 +1,6 @@
import { useState, ReactNode } from 'react'; import { useState, ReactNode } from 'react';
import { NodeData, Settings } from '../types/graph'; import { NodeData, Settings } from '../types/graph';
import { generateWireGuardPrivateKey } from '../utils/wireguardConfig'
import './NodeEditor.css'; import './NodeEditor.css';
@ -39,6 +40,10 @@ export default function NodeEditor({
// onClose(); // onClose();
}; };
const handleGenerateKey = (): void => {
handleInputChange('privateKey', generateWireGuardPrivateKey())
}
return ( return (
<div className="node-editor-overlay"> <div className="node-editor-overlay">
<div className="node-editor"> <div className="node-editor">
@ -70,12 +75,20 @@ export default function NodeEditor({
<div className="item-group"> <div className="item-group">
<input <input
value={formData.privateKey || ''} value={formData.privateKey || ''}
onChange={(e) => handleInputChange('privateKey', e.target.value)}
readOnly readOnly
/> />
<button className="btn-interect"></button> <button className="btn-interect" onClick={handleGenerateKey}></button>
</div> </div>
</div>
<div className="form-group">
<label>ID</label>
<input
type="text"
value={formData.hostId || ''}
onChange={(e) => handleInputChange('hostId', e.target.value)}
placeholder="将用作为虚拟地址的最后一位。同一子网下主机ID不能重复不得超过255"
/>
</div> </div>
<div className="form-group"> <div className="form-group">