|
@@ -222,13 +222,13 @@ export function hideBadge() {
|
|
|
|
|
|
export async function setMessageCount () {
|
|
|
const { accessToken: token = '', uid = '' } = await getChromeStorage('userInfo') || {}
|
|
|
+ alarmFun();
|
|
|
if(token) {
|
|
|
getMessageInfo();
|
|
|
// setInterval(() => {
|
|
|
// getMessageInfo();
|
|
|
// }, 10000);
|
|
|
// 60000
|
|
|
- alarmFun();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -238,20 +238,22 @@ function alarmFun() {
|
|
|
//1分鐘之後開始(該值至少大於1)
|
|
|
delayInMinutes: 1,
|
|
|
//與上方等同的寫法是
|
|
|
- //when : Date.now() + 6000,
|
|
|
+ // when : Date.now() + 6000,
|
|
|
//開始後每一分鐘執行一次(該值至少大於1)
|
|
|
periodInMinutes : 1
|
|
|
};
|
|
|
|
|
|
//每次加載就清空定時器
|
|
|
- // chrome.alarms.clearAll();
|
|
|
+ chrome.alarms.clearAll();
|
|
|
+
|
|
|
//創造定時器
|
|
|
chrome.alarms.create('testAlarm',alarmInfo);
|
|
|
-
|
|
|
+ console.log("onAlarm-1",);
|
|
|
chrome.alarms.onAlarm.addListener(function(alarm) {
|
|
|
- getMessageInfo();
|
|
|
//計算定時器觸發次數
|
|
|
console.log("onAlarm-" , ++count, alarm);
|
|
|
+
|
|
|
+ getMessageInfo();
|
|
|
});
|
|
|
}
|
|
|
|