mirror of
https://gitee.com/bitdance-team/chrome-extension
synced 2025-01-26 21:20:26 +08:00
Merge branch 'pomo_bug_fixed_temp' into develop
This commit is contained in:
commit
26d49dd1e9
@ -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 startBtn = document.getElementById("start-btn");
|
||||||
const resetBtn = document.getElementById("reset-btn");
|
const resetBtn = document.getElementById("reset-btn");
|
||||||
const endBtn = document.getElementById("end-btn");
|
const endBtn = document.getElementById("end-btn");
|
||||||
|
@ -59,7 +59,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||||||
minutes: 24,
|
minutes: 24,
|
||||||
seconds: 60,
|
seconds: 60,
|
||||||
countdownTimer: "25:00",
|
countdownTimer: "25:00",
|
||||||
status: "start",
|
status: "init"
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -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();
|
// audio.play();
|
||||||
|
console.log("playend***")
|
||||||
}
|
}
|
||||||
sendResponse();
|
sendResponse();
|
||||||
console.log(`离开 assets\html\pomodoro\background.js 中的onMessage Listener`)
|
console.log(`离开 assets\html\pomodoro\background.js 中的onMessage Listener`)
|
||||||
@ -102,6 +98,11 @@ function countdown({ minutes, seconds, status }) {
|
|||||||
// countdownTimer.innerHTML = currentTimer; 拿到
|
// countdownTimer.innerHTML = currentTimer; 拿到
|
||||||
console.log("分秒=============", minutes, seconds);
|
console.log("分秒=============", minutes, seconds);
|
||||||
|
|
||||||
|
//番茄钟结束桌面提醒
|
||||||
|
if(currentTimer === "00:00"){
|
||||||
|
showPomoNotification();
|
||||||
|
}
|
||||||
|
|
||||||
chrome.storage.sync.set(
|
chrome.storage.sync.set(
|
||||||
{
|
{
|
||||||
pomoData: {
|
pomoData: {
|
||||||
@ -120,7 +121,14 @@ function countdown({ minutes, seconds, status }) {
|
|||||||
|
|
||||||
//设置badge文本用来显示剩余分钟数
|
//设置badge文本用来显示剩余分钟数
|
||||||
chrome.storage.sync.get("pomoData", ({ pomoData }) => {
|
chrome.storage.sync.get("pomoData", ({ pomoData }) => {
|
||||||
|
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() });
|
chrome.browserAction.setBadgeText({ text: pomoData.minutes.toString() + ":" + pomoData.seconds.toString() });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(currentTimer);
|
console.log(currentTimer);
|
||||||
@ -154,3 +162,14 @@ function countdown({ minutes, seconds, status }) {
|
|||||||
|
|
||||||
//设置badge文本背景颜色
|
//设置badge文本背景颜色
|
||||||
chrome.browserAction.setBadgeBackgroundColor({ color: "#DD4A48" });
|
chrome.browserAction.setBadgeBackgroundColor({ color: "#DD4A48" });
|
||||||
|
|
||||||
|
//桌面通知
|
||||||
|
function showPomoNotification(){
|
||||||
|
|
||||||
|
new Notification("番茄钟🍅",{
|
||||||
|
//图标暂时未设置
|
||||||
|
icon:'48.png',
|
||||||
|
body:'你已经完成一个番茄钟!'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user