mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-03 03:10:50 +08:00
为筛选按钮容器 .auth-file-filter 改用事件委托,并在重新渲染时移除旧监听器,避免多次绑定导致回调重复执行。
This commit is contained in:
23
app.js
23
app.js
@@ -3260,12 +3260,23 @@ class CLIProxyManager {
|
|||||||
|
|
||||||
// 绑定认证文件筛选事件
|
// 绑定认证文件筛选事件
|
||||||
bindAuthFileFilterEvents() {
|
bindAuthFileFilterEvents() {
|
||||||
const filterBtns = document.querySelectorAll('.auth-file-filter .filter-btn');
|
const filterContainer = document.querySelector('.auth-file-filter');
|
||||||
filterBtns.forEach(btn => {
|
if (!filterContainer) return;
|
||||||
btn.addEventListener('click', (e) => {
|
|
||||||
this.handleFilterClick(e.target);
|
// 清理旧的监听器,避免重复绑定
|
||||||
});
|
if (filterContainer._filterListener) {
|
||||||
});
|
filterContainer.removeEventListener('click', filterContainer._filterListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
const listener = (event) => {
|
||||||
|
const button = event.target.closest('.filter-btn');
|
||||||
|
if (!button || !filterContainer.contains(button)) return;
|
||||||
|
event.preventDefault();
|
||||||
|
this.handleFilterClick(button);
|
||||||
|
};
|
||||||
|
|
||||||
|
filterContainer._filterListener = listener;
|
||||||
|
filterContainer.addEventListener('click', listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定认证文件操作按钮事件(使用事件委托)
|
// 绑定认证文件操作按钮事件(使用事件委托)
|
||||||
|
|||||||
Reference in New Issue
Block a user