mirror of
https://gitee.com/bitdance-team/chrome-extension
synced 2025-01-25 12:40:26 +08:00
【重大Bug】解决Git自动合并导致番茄钟代码混乱问题,出现问题的commit: 2cf513d
This commit is contained in:
parent
dcd8d152cc
commit
9ec752892c
@ -75,69 +75,15 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
}
|
||||
|
||||
//创建结束通知:待完成
|
||||
|
||||
chrome.storage.sync.set({
|
||||
status,
|
||||
});
|
||||
|
||||
//后台播放完成提示音乐
|
||||
if (message.action === "play") {
|
||||
// audio.play();
|
||||
}
|
||||
sendResponse();
|
||||
}
|
||||
|
||||
const { status, content } = message;
|
||||
|
||||
if (status === "start") {
|
||||
// sendResponse({
|
||||
// status:message.status
|
||||
// })
|
||||
countdown({ ...content, status });
|
||||
} else if (status === "paused") {
|
||||
clearTimeout(timer);
|
||||
chrome.storage.sync.get("pomoData", ({ pomoData }) => {
|
||||
console.log(pomoData);
|
||||
chrome.storage.sync.set({ pomoData: { ...pomoData, status: "paused" } });
|
||||
});
|
||||
} else if (status === "reset") {
|
||||
clearTimeout(timer);
|
||||
chrome.storage.sync.set({
|
||||
pomoData: {
|
||||
minutes: 24,
|
||||
seconds: 60,
|
||||
countdownTimer: "25:00",
|
||||
status: "init",
|
||||
},
|
||||
});
|
||||
chrome.browserAction.setBadgeText({ text: "" });
|
||||
} else if (status === "init") {
|
||||
//init初始化
|
||||
chrome.storage.sync.set({
|
||||
pomoData: {
|
||||
minutes: 24,
|
||||
seconds: 60,
|
||||
countdownTimer: "25:00",
|
||||
status: "init"
|
||||
},
|
||||
});
|
||||
} else {
|
||||
//playend 初始化
|
||||
chrome.storage.sync.set({
|
||||
pomoData: {
|
||||
minutes: 24,
|
||||
seconds: 60,
|
||||
countdownTimer: "25:00",
|
||||
status: "playend",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
//后台播放完成提示音乐
|
||||
if (status === "playend") {
|
||||
// audio.play();
|
||||
console.log("playend***")
|
||||
}
|
||||
sendResponse();
|
||||
console.log(`离开 assets\html\pomodoro\background.js 中的onMessage Listener`)
|
||||
return true;
|
||||
});
|
||||
@ -156,13 +102,7 @@ function countdown({ minutes, seconds, status }) {
|
||||
// countdownTimer.innerHTML = currentTimer; 拿到
|
||||
console.log("分秒=============", minutes, seconds);
|
||||
|
||||
//番茄钟结束桌面提醒
|
||||
if(currentTimer === "00:00"){
|
||||
showPomoNotification();
|
||||
}
|
||||
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
chrome.storage.sync.set({
|
||||
pomoData: {
|
||||
seconds: seconds,
|
||||
minutes: minutes,
|
||||
@ -170,7 +110,7 @@ function countdown({ minutes, seconds, status }) {
|
||||
status,
|
||||
},
|
||||
},
|
||||
function () {
|
||||
function() {
|
||||
if (!chrome.runtime.error) {
|
||||
console.log("started");
|
||||
}
|
||||
@ -189,36 +129,6 @@ function countdown({ minutes, seconds, status }) {
|
||||
}
|
||||
});
|
||||
|
||||
console.log(currentTimer);
|
||||
// count down every second, when a minute is up, countdown one minute
|
||||
// when time reaches 0:00, reset
|
||||
if (seconds > 0) {
|
||||
timer = setTimeout(() => {
|
||||
countdown({ minutes, seconds, status });
|
||||
}, 1000);
|
||||
} else if (minutes > 0) {
|
||||
seconds = 60;
|
||||
minutes--;
|
||||
chrome.storage.sync.set(
|
||||
{
|
||||
pomoData: {
|
||||
seconds: seconds,
|
||||
minutes: minutes,
|
||||
countdownTimer: currentTimer,
|
||||
status,
|
||||
},
|
||||
function() {
|
||||
if (!chrome.runtime.error) {
|
||||
console.log("started");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//设置badge文本用来显示剩余分钟数
|
||||
chrome.storage.sync.get("pomoData", ({ pomoData }) => {
|
||||
chrome.browserAction.setBadgeText({ text: pomoData.minutes.toString() + ":" + pomoData.seconds.toString() });
|
||||
});
|
||||
|
||||
console.log(currentTimer);
|
||||
// count down every second, when a minute is up, countdown one minute
|
||||
// when time reaches 0:00, reset
|
||||
@ -252,7 +162,6 @@ chrome.browserAction.setBadgeBackgroundColor({ color: "#DD4A48" });
|
||||
|
||||
//桌面通知
|
||||
function showPomoNotification(){
|
||||
|
||||
new Notification("番茄钟🍅",{
|
||||
//图标暂时未设置
|
||||
icon:'48.png',
|
||||
|
Loading…
x
Reference in New Issue
Block a user