迁移屏蔠菜单事件绑定
This commit is contained in:
@@ -4,6 +4,7 @@ export const BLOCKABLE_SYSTEM_SENDERS = ["钓鱼播报", "星海小博士", "百
|
||||
export const BLOCKED_SYSTEM_SENDERS_STORAGE_KEY = "chat_blocked_system_senders";
|
||||
export const CHAT_SOUND_MUTED_STORAGE_KEY = "chat_sound_muted";
|
||||
let soundMuteEventsBound = false;
|
||||
let blockMenuEventsBound = false;
|
||||
|
||||
/**
|
||||
* 规整聊天室偏好对象,过滤非法配置并补齐默认值。
|
||||
@@ -167,6 +168,35 @@ export function bindSoundMuteControl(onChange) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定系统播报屏蔽菜单打开与菜单内点击拦截事件。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindBlockMenuControls() {
|
||||
if (blockMenuEventsBound || typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
blockMenuEventsBound = true;
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!(event.target instanceof Element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const trigger = event.target.closest("[data-chat-block-menu-toggle]");
|
||||
if (trigger) {
|
||||
event.preventDefault();
|
||||
window.toggleBlockMenu?.(event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.target.closest("[data-chat-block-menu]")) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前登录账号没有服务端偏好时,判断是否需要迁移旧本地偏好。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user