From 554fedaefef8931288569f0b82b830b9192888ea Mon Sep 17 00:00:00 2001 From: shuaiplus <2327005759@qq.com> Date: Sat, 24 May 2025 21:39:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=9A=E7=9F=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BB=A5=E9=98=B2=E6=AD=A2=E9=87=8D=E5=A4=8D=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/js/main.js | 4 +--- client/js/util.settings.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/client/js/main.js b/client/js/main.js index dcaa942..8c3dde2 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -65,7 +65,7 @@ import { // Set global configuration parameters window.config = { wsAddress: 'wss://crypt.works/ws', // WebSocket 服务器地址 / WebSocket server address - debug: false // 是否开启调试模式 / Enable debug mode + debug: true // 是否开启调试模式 / Enable debug mode }; // 把一些函数挂载到 window 对象上供其他模块使用 @@ -78,8 +78,6 @@ window.setupEmojiPicker = setupEmojiPicker; // 当 DOM 内容加载完成后执行初始化逻辑 // Run initialization logic when the DOM content is fully loaded window.addEventListener('DOMContentLoaded', () => { - const loginContainer = $id('login-container'); // 登录容器 / Login container - const chatContainer = $id('chat-container'); // 聊天容器 / Chat container const loginForm = $id('login-form'); // 登录表单 / Login form if (loginForm) { diff --git a/client/js/util.settings.js b/client/js/util.settings.js index 81a76f7..6dcbc6f 100644 --- a/client/js/util.settings.js +++ b/client/js/util.settings.js @@ -92,9 +92,13 @@ function setupSettingsPanel() { if (soundCheckbox) soundCheckbox.checked = false; saveSettings(settings); applySettings(settings); - new Notification('Notifications enabled', { - body: 'You will receive alerts here.' - }) + // 防止重复通知,添加一个标志位 + if (!panel._notificationShown) { + new Notification('Notifications enabled', { + body: 'You will receive alerts here.' + }); + panel._notificationShown = true; // 设置标志位 + } } else { settings.notify = false; e.target.checked = false; @@ -106,7 +110,11 @@ function setupSettingsPanel() { } else { settings.notify = false; saveSettings(settings); - applySettings(settings) + applySettings(settings); + // 重置标志位 + if (panel._notificationShown) { + panel._notificationShown = false; + } } }); on(soundCheckbox, 'change', e => {