mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-25 02:00:09 +08:00
🐛 fix(sidebar): 修复断开连接后无法重连及状态残留问题
- 递归清除断开连接/关闭数据库时所有子节点的 loadedKeys 和 connectionStates - 解决 Ant Design Tree 因状态残留导致不再触发 loadData 的问题 - DataGrid: 优化 ResizeObserver 逻辑,引入 requestAnimationFrame 解决标签页切换高度塌陷 - DataGrid: 为每个表格实例生成唯一 ID 以隔离 CSS 样式冲突 - CSS: 强制禁止侧边栏文字选中,优化右键菜单触发区域
This commit is contained in:
@@ -10,19 +10,7 @@ import (
|
||||
// Generic DB Methods
|
||||
|
||||
func (a *App) DBConnect(config connection.ConnectionConfig) connection.QueryResult {
|
||||
key := getCacheKey(config)
|
||||
|
||||
// Use an anonymous function to scope the lock
|
||||
func() {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if oldDB, ok := a.dbCache[key]; ok {
|
||||
oldDB.Close()
|
||||
delete(a.dbCache, key)
|
||||
}
|
||||
}()
|
||||
|
||||
// getDatabase acquires the lock internally, so we must be unlocked here
|
||||
// getDatabase checks cache and Pings. If valid, reuses. If not, connects.
|
||||
_, err := a.getDatabase(config)
|
||||
if err != nil {
|
||||
return connection.QueryResult{Success: false, Message: err.Error()}
|
||||
@@ -32,17 +20,6 @@ func (a *App) DBConnect(config connection.ConnectionConfig) connection.QueryResu
|
||||
}
|
||||
|
||||
func (a *App) TestConnection(config connection.ConnectionConfig) connection.QueryResult {
|
||||
// Force close existing cached connection if any to ensure fresh test
|
||||
key := getCacheKey(config)
|
||||
func() {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if oldDB, ok := a.dbCache[key]; ok {
|
||||
oldDB.Close()
|
||||
delete(a.dbCache, key)
|
||||
}
|
||||
}()
|
||||
|
||||
_, err := a.getDatabase(config)
|
||||
if err != nil {
|
||||
return connection.QueryResult{Success: false, Message: err.Error()}
|
||||
|
||||
Reference in New Issue
Block a user