From 7c7639a1e9f114fdb0e9327e7c167ca3c8b0173e Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Fri, 24 Apr 2026 17:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=92=AD=E6=8A=A5=E5=BC=80=E5=85=B3=E5=B9=B6=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E6=94=B6=E8=B4=A7=E5=88=97=E8=A1=A8=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E6=92=AD=E6=8A=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/store/modules/setting.js | 16 +++ core/utils/tool.js | 16 +++ pages/settings/index.vue | 66 +++++++++-- pages/work/storage/receiving/receiving.vue | 131 +++++++++++++++++++-- 4 files changed, 211 insertions(+), 18 deletions(-) diff --git a/core/store/modules/setting.js b/core/store/modules/setting.js index c607a31..e171ec0 100644 --- a/core/store/modules/setting.js +++ b/core/store/modules/setting.js @@ -12,6 +12,9 @@ const defaultSettings = { 'scan.sound': 'true', 'scan.vibrate': 'true', 'scan.auto_focus': 'true', + + // 声音与通知 + 'voice.enabled': 'true', // 界面相关 'ui.theme': 'light', @@ -242,6 +245,19 @@ const getters = { auto_focus: state.settings['scan.auto_focus'] === 'true' }; }, + + // 获取声音与通知设置 + voiceSettings: state => { + if (Object.keys(state.settings).length === 0) { + return { + enabled: defaultSettings['voice.enabled'] === 'true' + }; + } + + return { + enabled: state.settings['voice.enabled'] === 'true' + }; + }, // 获取界面设置 uiSettings: state => { diff --git a/core/utils/tool.js b/core/utils/tool.js index 53e6300..78141a5 100644 --- a/core/utils/tool.js +++ b/core/utils/tool.js @@ -148,6 +148,22 @@ export default { * @return {Promise} */ speakText(text = '', options = {}) { + try { + const saved = uni.getStorageSync('app_settings'); + let settings = null; + if (typeof saved === 'string' && saved) { + settings = JSON.parse(saved); + } else if (saved && typeof saved === 'object') { + settings = saved; + } + + if (settings && settings['voice.enabled'] === 'false') { + return Promise.resolve(false); + } + } catch (error) { + console.warn('[tools.speakText] 读取语音播报开关失败,使用默认开启:', error); + } + return voice.speak(text, options); }, diff --git a/pages/settings/index.vue b/pages/settings/index.vue index ec1bbe7..c69c877 100644 --- a/pages/settings/index.vue +++ b/pages/settings/index.vue @@ -12,12 +12,22 @@ - -