v1.0.1: 多拓扑管理、Web SSH终端、扫描进度修复、拓扑连线优化
- 修复扫描进度条不动的问题(分4阶段更新进度) - 新增Web SSH远程终端(xterm.js + WebSocket) - 新增多拓扑管理(创建/切换拓扑、全局设备池) - 简化新建拓扑流程(仅需名称,创建后选择设备) - 修复拓扑Builder设备去重(按IP去重) - 修复启动时拓扑设备不加载到Builder的问题 - 优化MAC前缀匹配(避免歧义前缀导致错误连线) - 拓扑连线改为无向(去除箭头) - 设备详情面板加宽到600px
Este cometimento está contido em:
@@ -4,9 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"network-topology-discovery/pkg/models"
|
||||
"os"
|
||||
"sync"
|
||||
"network-topology-discovery/pkg/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -17,8 +17,13 @@ type Storage struct {
|
||||
devices map[string]models.Device
|
||||
}
|
||||
|
||||
// NewStorage 创建存储实例
|
||||
// NewStorage 创建存储实例(兼容旧版,使用默认文件)
|
||||
func NewStorage(filePath string) (*Storage, error) {
|
||||
return NewStorageForTopology(filePath)
|
||||
}
|
||||
|
||||
// NewStorageForTopology 为特定拓扑创建存储实例
|
||||
func NewStorageForTopology(filePath string) (*Storage, error) {
|
||||
s := &Storage{
|
||||
filePath: filePath,
|
||||
devices: make(map[string]models.Device),
|
||||
@@ -36,6 +41,24 @@ func NewStorage(filePath string) (*Storage, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// SetFilePath 切换存储文件路径(用于切换拓扑)
|
||||
func (s *Storage) SetFilePath(filePath string) error {
|
||||
s.mu.Lock()
|
||||
s.filePath = filePath
|
||||
s.devices = make(map[string]models.Device)
|
||||
s.mu.Unlock()
|
||||
|
||||
// 重新加载数据
|
||||
if err := s.load(); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("failed to load storage: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Storage switched to: %s", filePath)
|
||||
return nil
|
||||
}
|
||||
|
||||
// load 从文件加载数据
|
||||
func (s *Storage) load() error {
|
||||
data, err := os.ReadFile(s.filePath)
|
||||
|
||||
Criar uma nova questão referindo esta
Bloquear um utilizador