优化:文件服务器安全重构+编辑器增强+搜索排序+更新面板Markdown渲染
- 路径校验提取validateFilePath+sentinel error替代字符串匹配 - requireUpdateAPI收敛7处重复nil检查 - 端口18765统一为8073,消除分散魔法数字 - CodeMirror添加搜索功能+滚动位置LRU缓存恢复 - 文件列表新增列排序+搜索过滤 - Toolbar重排:快捷访问内嵌+搜索框集成+历史改图标 - 重命名零闪烁:updateFilePath草稿迁移 - changelog用marked渲染+sanitizeHtml防XSS - MigrateTabConfig扩展map驱动覆盖openclaw-manager→version迁移 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -136,40 +136,66 @@ func (api *ConfigAPI) SaveAppConfig(req SaveAppConfigRequest) (map[string]interf
|
||||
}, nil
|
||||
}
|
||||
|
||||
// MigrateTabConfig 迁移旧配置
|
||||
// MigrateTabConfig 迁移旧配置(device 移除 + openclaw-manager 重命名)
|
||||
func (api *ConfigAPI) MigrateTabConfig() error {
|
||||
config, _ := api.configService.GetTabConfig()
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 检查是否包含 device
|
||||
hasDevice := false
|
||||
needMigrate := false
|
||||
|
||||
// 检查是否包含需要迁移的旧 key
|
||||
for _, tab := range config.AvailableTabs {
|
||||
if tab.Key == "device" {
|
||||
hasDevice = true
|
||||
if tab.Key == "device" || tab.Key == "openclaw-manager" {
|
||||
needMigrate = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasDevice {
|
||||
if !needMigrate {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 过滤掉 device
|
||||
// 映射:旧 key → 新 key(不需要的移除)
|
||||
keyMap := map[string]string{
|
||||
"openclaw-manager": "version",
|
||||
// "device": "" // 直接过滤
|
||||
}
|
||||
|
||||
newTabs := make([]service.TabDefinition, 0, len(config.AvailableTabs))
|
||||
newVisible := make([]string, 0, len(config.VisibleTabs))
|
||||
seenKeys := map[string]bool{}
|
||||
|
||||
for _, tab := range config.AvailableTabs {
|
||||
if tab.Key != "device" {
|
||||
newKey, shouldRename := keyMap[tab.Key]
|
||||
if shouldRename {
|
||||
if newKey == "" {
|
||||
continue // 移除(如 device)
|
||||
}
|
||||
if seenKeys[newKey] {
|
||||
continue // 避免重复
|
||||
}
|
||||
seenKeys[newKey] = true
|
||||
newTabs = append(newTabs, service.TabDefinition{Key: newKey, Title: tab.Title, Enabled: tab.Enabled})
|
||||
} else {
|
||||
newTabs = append(newTabs, tab)
|
||||
}
|
||||
}
|
||||
for _, key := range config.VisibleTabs {
|
||||
if key != "device" {
|
||||
if newKey, ok := keyMap[key]; ok {
|
||||
if newKey != "" && !seenKeys[newKey] {
|
||||
newVisible = append(newVisible, newKey)
|
||||
}
|
||||
// newKey == "" 时跳过(如 device)
|
||||
} else {
|
||||
newVisible = append(newVisible, key)
|
||||
}
|
||||
}
|
||||
|
||||
defaultTab := config.DefaultTab
|
||||
if newKey, ok := keyMap[defaultTab]; ok && newKey != "" {
|
||||
defaultTab = newKey
|
||||
}
|
||||
if defaultTab == "device" {
|
||||
defaultTab = "file-system"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user