From 6b6628b2b6c5ee15ba8eb1376b074941dcecd6ae Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Mon, 10 Aug 2026 17:44:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(mealSurplus):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E5=91=8A=E8=AD=A6=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BD=99=E9=87=8F=E4=B8=8D=E8=B6=B3=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E6=92=AD=E6=8A=A5=E8=8F=9C=E5=93=81=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- src/views/dataBoard/dataBoard.vue | 1450 +++++++++-------- .../mealSurplusInformation.vue | 58 + 2 files changed, 813 insertions(+), 695 deletions(-) diff --git a/src/views/dataBoard/dataBoard.vue b/src/views/dataBoard/dataBoard.vue index df56ae9..cff6545 100644 --- a/src/views/dataBoard/dataBoard.vue +++ b/src/views/dataBoard/dataBoard.vue @@ -1,7 +1,7 @@ + \ No newline at end of file diff --git a/src/views/mealSurplusInformation/mealSurplusInformation.vue b/src/views/mealSurplusInformation/mealSurplusInformation.vue index e268a36..dd24458 100644 --- a/src/views/mealSurplusInformation/mealSurplusInformation.vue +++ b/src/views/mealSurplusInformation/mealSurplusInformation.vue @@ -119,16 +119,66 @@ export default { nutritionList: [], // 营养秤实时数据 unmadeList: [], // 未制作列表 madeList: [], // 已制作列表 + speechQueue: [], // 语音播报队列 [{dishName, spoken}] + speaking: false, // 是否正在播报 } }, created() { this.getKitchenInfo(); }, methods: { + // 语音播报:Web Speech API 依次播报队列中未播报的菜品 + speakWarning() { + if (this.speaking) return; + const unspoken = this.speechQueue.filter(item => !item.spoken); + if (!unspoken.length) return; + + this.speaking = true; + let index = 0; + + const utterance = new SpeechSynthesisUtterance(); + utterance.lang = 'zh-CN'; + utterance.rate = 0.9; + utterance.volume = 1; + + const playNext = () => { + if (index >= unspoken.length) { + this.speaking = false; + return; + } + const item = unspoken[index]; + index++; + utterance.text = `${item.dishName}、余量不足,请注意补餐`; + console.log('[TTS] 开始播报:', utterance.text); + utterance.onend = () => { + item.spoken = true; + console.log('[TTS] 播报完成:', item.dishName); + playNext(); + }; + utterance.onerror = (e) => { + console.error('[TTS] 播报错误:', e.error); + item.spoken = true; + playNext(); + }; + speechSynthesis.speak(utterance); + }; + + playNext(); + }, getKitchenInfo() { var params = {}; var _this = this; + let date = new Date(); + let year = date.getFullYear(); + let month = date.getMonth() + 1; + let day = date.getDate(); + let hour = date.getHours(); + let minute = date.getMinutes(); + let second = date.getSeconds(); + const times = "现在是:" + year + "年" + month + "月" + day + "号," + hour + "点" + minute + "分" + second + "秒"; + _this.speechQueue.push({dishName: times, spoken: false}); + httpRequest("GET", "https://dev.yixiong-tech.com:8081/nutrition/neglect/large-screen/kitchen", params, { "X-DEVICE-CODE": "XIAOMI-00999", "authorization": "57ee87183f2a4fa59683ec9ef41c8f5d" @@ -165,6 +215,14 @@ export default { } } + // 余量不足的菜品直接推入播报队列 + _this.nutritionList.forEach(function(item) { + if (item.lowStock) { + _this.speechQueue.push({dishName: item.dishName, spoken: false}); + } + }); + _this.speakWarning(); + setTimeout(function() { _this.getKitchenInfo(); }, 10000);