迁移字号选择器事件绑定
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// 聊天室字号偏好控制,保留旧的 localStorage key 以兼容已有用户设置。
|
||||
|
||||
export const CHAT_FONT_SIZE_STORAGE_KEY = "chat_font_size";
|
||||
let fontSizeEventsBound = false;
|
||||
|
||||
/**
|
||||
* 应用字号到聊天消息窗口,并保存到 localStorage。
|
||||
@@ -43,3 +44,23 @@ export function restoreChatFontSize() {
|
||||
|
||||
return saved ? applyFontSize(saved) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定字号选择器事件。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindChatFontSizeControl() {
|
||||
if (fontSizeEventsBound || typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
fontSizeEventsBound = true;
|
||||
document.addEventListener("change", (event) => {
|
||||
if (!(event.target instanceof HTMLSelectElement) || event.target.id !== "font_size_select") {
|
||||
return;
|
||||
}
|
||||
|
||||
applyFontSize(event.target.value);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user