|  | @@ -224,12 +224,32 @@ export async function setMessageCount () {
 | 
	
		
			
				|  |  |      const { accessToken: token = '', uid = '' } = await getChromeStorage('userInfo') || {}
 | 
	
		
			
				|  |  |      if(token) {
 | 
	
		
			
				|  |  |          getMessageInfo();
 | 
	
		
			
				|  |  | -        setInterval(() => {
 | 
	
		
			
				|  |  | -            getMessageInfo();
 | 
	
		
			
				|  |  | -        }, 60000);
 | 
	
		
			
				|  |  | +        createAlarm();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +function createAlarm() {
 | 
	
		
			
				|  |  | +    let alarmInfo = {
 | 
	
		
			
				|  |  | +        //1分鐘之後開始(該值不能小於1) 
 | 
	
		
			
				|  |  | +        delayInMinutes: 1, 
 | 
	
		
			
				|  |  | +        //與上方等同的寫法是 
 | 
	
		
			
				|  |  | +        // when : Date.now() + n,
 | 
	
		
			
				|  |  | +        //開始後每一分鐘執行一次(該值不能小于1) 
 | 
	
		
			
				|  |  | +        periodInMinutes : 1 
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //每次加載就清空定時器
 | 
	
		
			
				|  |  | +    chrome.alarms.clearAll();
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    chrome.alarms.onAlarm.addListener(function(alarm) {
 | 
	
		
			
				|  |  | +        console.log("onAlarm-", alarm);
 | 
	
		
			
				|  |  | +        getMessageInfo();
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //創造定時器
 | 
	
		
			
				|  |  | +    chrome.alarms.create('denetChromeAlarm',alarmInfo);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  export  function getMessageInfo () {
 | 
	
		
			
				|  |  |      fetchAllMessageInfo().then(res => {
 | 
	
		
			
				|  |  |          if(res.code == 0) {
 |