File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- setInterval ( ( ) => {
2- const date = new Date ( ) ;
3- const hour = date . getHours ( ) ;
4- const minute = date . getMinutes ( ) ;
5- noticeAlert ( hour , minute ) ;
6- } , 60000 ) ;
7-
81// 发送闹钟提醒
92function noticeAlert ( hour , minute ) {
103 chrome . storage . local . get ( [ 'noticeList' ] , ( result ) => {
114 const res = result . noticeList ;
125 if ( res !== undefined && res !== null && res !== '' ) {
136 try {
147 const rows = JSON . parse ( res ) ;
15- console . log ( rows ) ;
168 for ( let i = 0 ; i < rows . length ; i += 1 ) {
17- if ( rows [ i ] . hour === hour || rows [ i ] . hour === - 1 ) {
9+ if ( parseInt ( rows [ i ] . hour , 10 ) === hour || parseInt ( rows [ i ] . hour , 10 ) === - 1 ) {
1810 if ( parseInt ( rows [ i ] . minute , 10 ) === minute ) {
1911 chrome . notifications . create ( null , {
2012 type : 'basic' ,
@@ -31,3 +23,11 @@ function noticeAlert(hour, minute) {
3123 }
3224 } ) ;
3325}
26+
27+ chrome . alarms . create ( { periodInMinutes : 1 } ) ;
28+ chrome . alarms . onAlarm . addListener ( ( ) => {
29+ const date = new Date ( ) ;
30+ const hour = date . getHours ( ) ;
31+ const minute = date . getMinutes ( ) ;
32+ noticeAlert ( hour , minute ) ;
33+ } ) ;
You can’t perform that action at this time.
0 commit comments