From 3ec3909698141936b9690471f8738313cd89d208 Mon Sep 17 00:00:00 2001 From: simonzhangs <2863389578@qq.com> Date: Wed, 9 Feb 2022 18:42:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=95=AA=E8=8C=84=E9=92=9F?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=A1=8C=E9=9D=A2=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/html/pomodoro/background.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/shell-chrome/assets/html/pomodoro/background.js b/packages/shell-chrome/assets/html/pomodoro/background.js index a3cbb73..31f5e94 100644 --- a/packages/shell-chrome/assets/html/pomodoro/background.js +++ b/packages/shell-chrome/assets/html/pomodoro/background.js @@ -74,14 +74,10 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { }); } - //创建结束通知:待完成 - - chrome.storage.sync.set({ - status, - }); //后台播放完成提示音乐 - if (message.action === "play") { + if (status === "playend") { // audio.play(); + console.log("playend***") } sendResponse(); console.log(`离开 assets\html\pomodoro\background.js 中的onMessage Listener`) @@ -102,6 +98,11 @@ function countdown({ minutes, seconds, status }) { // countdownTimer.innerHTML = currentTimer; 拿到 console.log("分秒=============", minutes, seconds); + //番茄钟结束桌面提醒 + if(currentTimer === "00:00"){ + showPomoNotification(); + } + chrome.storage.sync.set( { pomoData: { @@ -154,3 +155,14 @@ function countdown({ minutes, seconds, status }) { //设置badge文本背景颜色 chrome.browserAction.setBadgeBackgroundColor({ color: "#DD4A48" }); + +//桌面通知 +function showPomoNotification(){ + + new Notification("番茄钟🍅",{ + //图标暂时未设置 + icon:'48.png', + body:'你已经完成一个番茄钟!' + }) +} +