mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-07-12 16:01:56 +08:00
fix: 修复内存泄漏和添加保存按钮加载状态
- router.js: 防止 hashchange 监听器重复绑定 - sidebar.js: 用事件委托替代每次重新绑定事件 - logs.js: 搜索定时器提升为模块级变量,添加 cleanup 导出 - models/agents/gateway/mcp: 保存按钮添加 disabled + 加载文本
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user