From 7a621d6e25ccbf6797eea8397f52bd8092666a97 Mon Sep 17 00:00:00 2001 From: simonzhangs <2863389578@qq.com> Date: Wed, 9 Feb 2022 17:45:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=95=AA=E8=8C=84?= =?UTF-8?q?=E9=92=9F=E5=88=9D=E5=A7=8B=E7=95=8C=E9=9D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/html/pomodoro/assets/js/popup.js | 27 +------------------ .../assets/html/pomodoro/background.js | 2 +- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/packages/shell-chrome/assets/html/pomodoro/assets/js/popup.js b/packages/shell-chrome/assets/html/pomodoro/assets/js/popup.js index 122fa0a..8d58bfd 100644 --- a/packages/shell-chrome/assets/html/pomodoro/assets/js/popup.js +++ b/packages/shell-chrome/assets/html/pomodoro/assets/js/popup.js @@ -1,29 +1,4 @@ -// const btn = document.querySelector("#switch"); - -// chrome.storage.sync.get("linkOpen", ({ linkOpen }) => { -// btn.checked = linkOpen; -// }); - -// btn.addEventListener("change", () => { -// if (btn.checked) { -// chrome.storage.sync.set({ linkOpen: true }); -// } else { -// chrome.storage.sync.set({ linkOpen: false }); -// } -// // 获取当前tab窗口 -// chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { -// chrome.scripting.executeScript({ -// target: { tabId: tabs[0].id }, -// func: refreshPage, -// }); -// }); -// }); - -// // 刷新页面 -// function refreshPage() { -// window.location.reload(); -// } - +//元素获取 const startBtn = document.getElementById("start-btn"); const resetBtn = document.getElementById("reset-btn"); const endBtn = document.getElementById("end-btn"); diff --git a/packages/shell-chrome/assets/html/pomodoro/background.js b/packages/shell-chrome/assets/html/pomodoro/background.js index b73afc7..a3cbb73 100644 --- a/packages/shell-chrome/assets/html/pomodoro/background.js +++ b/packages/shell-chrome/assets/html/pomodoro/background.js @@ -59,7 +59,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { minutes: 24, seconds: 60, countdownTimer: "25:00", - status: "start", + status:"init" }, }); } else { 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 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=95=AA=E8=8C=84?= =?UTF-8?q?=E9=92=9F=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:'你已经完成一个番茄钟!' + }) +} + From 46799db029e499505ec18cee2b21501fcf3d948a Mon Sep 17 00:00:00 2001 From: Coding Zhang <2291200076@qq.com> Date: Wed, 9 Feb 2022 18:42:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=95=AA=E8=8C=84?= =?UTF-8?q?=E9=92=9F=E5=AE=8C=E6=88=90=E5=90=8EBadge=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shell-chrome/assets/html/pomodoro/background.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/shell-chrome/assets/html/pomodoro/background.js b/packages/shell-chrome/assets/html/pomodoro/background.js index a3cbb73..f730a0c 100644 --- a/packages/shell-chrome/assets/html/pomodoro/background.js +++ b/packages/shell-chrome/assets/html/pomodoro/background.js @@ -59,7 +59,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { minutes: 24, seconds: 60, countdownTimer: "25:00", - status:"init" + status: "init" }, }); } else { @@ -120,7 +120,14 @@ function countdown({ minutes, seconds, status }) { //设置badge文本用来显示剩余分钟数 chrome.storage.sync.get("pomoData", ({ pomoData }) => { - chrome.browserAction.setBadgeText({ text: pomoData.minutes.toString() + ":" + pomoData.seconds.toString() }); + if (pomoData.minutes == 0 && pomoData.seconds == 0) { + chrome.browserAction.setBadgeText({ text: "√" }); + setTimeout(() => { + chrome.browserAction.setBadgeText({ text: "" }); + }, 2000) + } else { + chrome.browserAction.setBadgeText({ text: pomoData.minutes.toString() + ":" + pomoData.seconds.toString() }); + } }); console.log(currentTimer);