fix: 修复内存泄漏和添加保存按钮加载状态

- router.js: 防止 hashchange 监听器重复绑定
- sidebar.js: 用事件委托替代每次重新绑定事件
- logs.js: 搜索定时器提升为模块级变量,添加 cleanup 导出
- models/agents/gateway/mcp: 保存按钮添加 disabled + 加载文本
This commit is contained in:
晴天
2026-02-26 23:35:33 +08:00
parent 352b85405d
commit c2e3f738b5
7 changed files with 78 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ const routes = {}
let _contentEl = null
let _loadId = 0
let _currentCleanup = null
let _initialized = false
export function registerRoute(path, loader) {
routes[path] = loader
@@ -16,7 +17,10 @@ export function navigate(path) {
export function initRouter(contentEl) {
_contentEl = contentEl
window.addEventListener('hashchange', () => loadRoute())
if (!_initialized) {
window.addEventListener('hashchange', () => loadRoute())
_initialized = true
}
loadRoute()
}