@@ -206,7 +206,6 @@ export default class ReminderPlugin extends Plugin {
206206 } ;
207207 this . preloadedAudio . volume = 1 ; // 恢复正常音量
208208 this . audioEnabled = true ;
209- console . log ( '音频播放已启用' ) ;
210209 }
211210 } catch ( error ) {
212211 console . warn ( '音频预加载失败,将使用静音模式:' , error ) ;
@@ -326,12 +325,10 @@ export default class ReminderPlugin extends Plugin {
326325 try {
327326 const soundPath = await this . getNotificationSound ( ) ;
328327 if ( ! soundPath ) {
329- console . log ( '通知声音路径为空,静音模式' ) ;
330328 return ;
331329 }
332330
333331 if ( ! this . audioEnabled ) {
334- console . log ( '音频未启用,需要用户交互后才能播放声音' ) ;
335332 return ;
336333 }
337334 // 如果已经在播放提示音,则避免重复播放
@@ -381,7 +378,6 @@ export default class ReminderPlugin extends Plugin {
381378
382379 // 如果是权限错误,提示用户
383380 if ( error . name === 'NotAllowedError' ) {
384- console . log ( '提示:点击页面任意位置后,音频通知将自动启用' ) ;
385381 }
386382 }
387383 }
@@ -521,11 +517,6 @@ export default class ReminderPlugin extends Plugin {
521517 return ;
522518 }
523519
524- console . log ( '番茄钟Tab初始化' , {
525- isStandaloneWindow,
526- windowId : this . windowId ,
527- tabId : tab . id
528- } ) ;
529520
530521 // 动态导入PomodoroTimer避免循环依赖
531522 import ( "./components/PomodoroTimer" ) . then ( ( { PomodoroTimer } ) => {
@@ -535,15 +526,12 @@ export default class ReminderPlugin extends Plugin {
535526 const standardTabId = this . name + POMODORO_TAB_TYPE ;
536527 this . tabViews . set ( standardTabId , pomodoroTimer ) ;
537528
538- console . log ( '番茄钟实例已保存到tabViews, key:' , standardTabId ) ;
539529
540530 // 如果这是一个独立窗口,延迟通知其他窗口(确保广播通道已建立)
541531 if ( isStandaloneWindow ) {
542- console . log ( '番茄钟在独立窗口中打开,延迟通知其他窗口...' ) ;
543532
544533 // 延迟发送,确保广播通道已建立
545534 setTimeout ( ( ) => {
546- console . log ( '发送番茄钟窗口打开通知' , this . windowId ) ;
547535 this . broadcastMessage ( "pomodoro_window_opened" , {
548536 windowId : this . windowId
549537 } , true ) ; // 强制发送
@@ -553,17 +541,14 @@ export default class ReminderPlugin extends Plugin {
553541 } ) as any ,
554542 destroy : ( ( ) => {
555543 // 当番茄钟Tab关闭时,清除标记并通知其他窗口
556- console . log ( '番茄钟Tab销毁' ) ;
557544
558545 // 清理tabViews中的引用
559546 const standardTabId = this . name + POMODORO_TAB_TYPE ;
560547 if ( this . tabViews . has ( standardTabId ) ) {
561- console . log ( '清理tabViews中的番茄钟实例, key:' , standardTabId ) ;
562548 this . tabViews . delete ( standardTabId ) ;
563549 }
564550
565551 if ( this . pomodoroWindowId === this . windowId ) {
566- console . log ( '清除番茄钟窗口标记' ) ;
567552 this . pomodoroWindowId = null ;
568553 // 通知其他窗口番茄钟窗口已关闭
569554 this . broadcastMessage ( "pomodoro_window_closed" , {
@@ -1299,7 +1284,6 @@ export default class ReminderPlugin extends Plugin {
12991284 if ( ! elements || ! elements . length ) {
13001285 return ;
13011286 }
1302- console . log ( t ( "handleDocumentTreeMenuLog" ) , elements ) ;
13031287 // 获取所有选中的文档ID
13041288 const documentIds = Array . from ( elements )
13051289 . map ( ( element : Element ) => element . getAttribute ( "data-node-id" ) )
@@ -2973,7 +2957,6 @@ export default class ReminderPlugin extends Plugin {
29732957 }
29742958
29752959 onunload ( ) {
2976- console . log ( "Reminder Plugin unloaded" ) ;
29772960
29782961 // 清理广播通信
29792962 this . cleanupBroadcastChannel ( ) ;
@@ -3027,9 +3010,8 @@ export default class ReminderPlugin extends Plugin {
30273010 const enableNotification = async ( ) => {
30283011 const permission = await Notification . requestPermission ( ) ;
30293012 if ( permission === 'granted' ) {
3030- console . log ( '系统通知权限已获取' ) ;
30313013 } else {
3032- console . log ( '系统通知权限被拒绝' ) ;
3014+ console . error ( '系统通知权限被拒绝' ) ;
30333015 }
30343016
30353017 // 移除事件监听器
@@ -3095,7 +3077,6 @@ export default class ReminderPlugin extends Plugin {
30953077 try {
30963078 // 先检查是否已有独立窗口
30973079 if ( this . pomodoroWindowId ) {
3098- console . log ( '检测到已存在番茄钟独立窗口,尝试更新状态...' , this . pomodoroWindowId ) ;
30993080
31003081 // 通过广播更新已有窗口的番茄钟状态
31013082 // 如果没有提供inheritState,设置标志让独立窗口继承自己当前的状态
@@ -3112,7 +3093,6 @@ export default class ReminderPlugin extends Plugin {
31123093 }
31133094
31143095 // 如果没有独立窗口,则打开新窗口
3115- console . log ( '没有检测到独立窗口,准备打开新窗口...' ) ;
31163096 const tabId = this . name + POMODORO_TAB_TYPE ;
31173097
31183098 // 创建tab
@@ -3139,7 +3119,6 @@ export default class ReminderPlugin extends Plugin {
31393119 tab : await tab ,
31403120 } ) ;
31413121
3142- console . log ( '新窗口已打开' ) ;
31433122
31443123 } catch ( error ) {
31453124 console . error ( '打开独立窗口失败:' , error ) ;
@@ -3159,7 +3138,6 @@ export default class ReminderPlugin extends Plugin {
31593138 // 订阅广播频道
31603139 await this . subscribeToBroadcastChannel ( ) ;
31613140
3162- console . log ( 'Broadcast Channel has been initialized, Window ID:' , this . windowId ) ;
31633141
31643142 // 发送初始化消息到其他窗口(用于发现其他窗口)
31653143 this . broadcastMessage ( "window_online" , {
@@ -3170,7 +3148,6 @@ export default class ReminderPlugin extends Plugin {
31703148 // 等待一小段时间,让其他窗口响应
31713149 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
31723150
3173- console . log ( '广播通道初始化完成,已发现窗口数:' , this . otherWindowIds . size ) ;
31743151
31753152 // 监听页面卸载事件,确保窗口关闭时发送下线通知
31763153 window . addEventListener ( "beforeunload" , ( ) => {
@@ -3193,7 +3170,6 @@ export default class ReminderPlugin extends Plugin {
31933170
31943171 // 监听连接打开
31953172 this . websocket . onopen = ( ) => {
3196- console . log ( "Broadcast channel connected" ) ;
31973173 this . clearReconnectTimer ( ) ;
31983174 resolve ( ) ;
31993175 } ;
@@ -3217,7 +3193,6 @@ export default class ReminderPlugin extends Plugin {
32173193
32183194 // 监听连接关闭
32193195 this . websocket . onclose = ( event ) => {
3220- console . log ( "Broadcast channel connection closed:" , event . code , event . reason ) ;
32213196 this . scheduleReconnect ( ) ;
32223197 } ;
32233198
@@ -3235,7 +3210,6 @@ export default class ReminderPlugin extends Plugin {
32353210 private scheduleReconnect ( ) {
32363211 this . clearReconnectTimer ( ) ;
32373212 this . reconnectTimer = window . setTimeout ( ( ) => {
3238- console . log ( "Attempting to reconnect to broadcast channel..." ) ;
32393213 this . subscribeToBroadcastChannel ( ) . catch ( error => {
32403214 console . error ( "Failed to reconnect to broadcast channel:" , error ) ;
32413215 } ) ;
@@ -3256,16 +3230,13 @@ export default class ReminderPlugin extends Plugin {
32563230 * 处理窗口下线通知
32573231 */
32583232 private handleWindowOffline ( windowId : string ) {
3259- console . log ( "收到窗口下线通知:" , windowId ) ;
32603233 this . otherWindowIds . delete ( windowId ) ;
32613234
32623235 // 如果是番茄钟窗口下线,清除标记
32633236 if ( this . pomodoroWindowId === windowId ) {
3264- console . log ( "番茄钟窗口下线,清除标记:" , windowId ) ;
32653237 this . pomodoroWindowId = null ;
32663238 }
32673239
3268- console . log ( "窗口下线处理完成,当前其他窗口数:" , this . otherWindowIds . size , "番茄钟窗口ID:" , this . pomodoroWindowId ) ;
32693240 }
32703241
32713242 /**
@@ -3305,11 +3276,9 @@ export default class ReminderPlugin extends Plugin {
33053276 * 处理来自其他窗口的广播消息
33063277 */
33073278 private async handleBroadcastMessage ( data : any ) {
3308- console . log ( "Received broadcast message:" , data ) ;
33093279
33103280 // 忽略来自当前窗口的消息
33113281 if ( data . windowId === this . windowId ) {
3312- console . log ( "Ignoring message from current window:" , data . windowId ) ;
33133282 return ;
33143283 }
33153284
@@ -3318,7 +3287,6 @@ export default class ReminderPlugin extends Plugin {
33183287
33193288 switch ( data . type ) {
33203289 case "window_online" :
3321- console . log ( "New window detected:" , data . windowId ) ;
33223290 // 向新上线的窗口发送反馈,告知自己的存在
33233291 this . broadcastMessage ( "window_online_feedback" , {
33243292 windowId : this . windowId ,
@@ -3332,32 +3300,26 @@ export default class ReminderPlugin extends Plugin {
33323300 }
33333301 break ;
33343302 case "window_online_feedback" :
3335- console . log ( "Received online feedback from:" , data . windowId ) ;
33363303 this . otherWindowIds . add ( data . windowId ) ;
33373304 break ;
33383305 case "window_offline" :
33393306 this . handleWindowOffline ( data . windowId ) ;
33403307 break ;
33413308 case "pomodoro_window_opened" :
33423309 // 记录番茄钟窗口ID
3343- console . log ( "收到番茄钟窗口打开通知,窗口ID:" , data . windowId ) ;
33443310 this . pomodoroWindowId = data . windowId ;
3345- console . log ( "Pomodoro window opened in another window:" , data . windowId ) ;
33463311 break ;
33473312 case "pomodoro_window_closed" :
33483313 // 清除番茄钟窗口ID
33493314 if ( this . pomodoroWindowId === data . windowId ) {
3350- console . log ( "番茄钟窗口已关闭,清除标记:" , data . windowId ) ;
33513315 this . pomodoroWindowId = null ;
33523316 }
33533317 break ;
33543318 case "pomodoro_update" :
33553319 // 如果当前是番茄钟独立窗口,更新番茄钟状态
3356- console . log ( "收到番茄钟更新请求" ) ;
33573320 await this . updatePomodoroState ( data ) ;
33583321 break ;
33593322 default :
3360- console . log ( "Unknown broadcast message type:" , data . type ) ;
33613323 }
33623324 }
33633325
@@ -3368,46 +3330,26 @@ export default class ReminderPlugin extends Plugin {
33683330 try {
33693331 const { reminder, settings, isCountUp, inheritState, shouldInheritCurrentState } = data ;
33703332
3371- console . log ( '尝试更新番茄钟状态:' , {
3372- reminder : reminder ?. title ,
3373- isCountUp,
3374- hasInheritState : ! ! inheritState ,
3375- shouldInheritCurrentState : ! ! shouldInheritCurrentState
3376- } ) ;
33773333
33783334 // 查找当前窗口的番茄钟Tab
33793335 const tabId = this . name + POMODORO_TAB_TYPE ;
3380- console . log ( '查找番茄钟Tab, ID:' , tabId ) ;
3381- console . log ( '当前tabViews:' , Array . from ( this . tabViews . keys ( ) ) ) ;
33823336
33833337 const pomodoroView = this . tabViews . get ( tabId ) ;
33843338
33853339 if ( pomodoroView ) {
3386- console . log ( '找到番茄钟视图,类型:' , pomodoroView . constructor . name ) ;
33873340
33883341 // 如果需要继承当前状态,先获取当前状态
33893342 let finalInheritState = inheritState ;
33903343 if ( shouldInheritCurrentState && typeof pomodoroView . getCurrentState === 'function' ) {
3391- console . log ( '需要继承当前状态,调用 getCurrentState()' ) ;
33923344 finalInheritState = pomodoroView . getCurrentState ( ) ;
3393- console . log ( '获取到的当前状态:' , {
3394- isRunning : finalInheritState . isRunning ,
3395- isWorkPhase : finalInheritState . isWorkPhase ,
3396- timeElapsed : finalInheritState . timeElapsed ,
3397- timeLeft : finalInheritState . timeLeft ,
3398- completedPomodoros : finalInheritState . completedPomodoros
3399- } ) ;
3345+
34003346 } else if ( inheritState ) {
3401- console . log ( '使用提供的 inheritState' ) ;
34023347 } else {
3403- console . log ( '没有继承状态,将重置番茄钟' ) ;
34043348 }
34053349
34063350 if ( typeof pomodoroView . updateState === 'function' ) {
34073351 // 如果番茄钟视图有更新状态的方法,调用它
3408- console . log ( '调用updateState方法,finalInheritState:' , ! ! finalInheritState ) ;
34093352 await pomodoroView . updateState ( reminder , settings , isCountUp , finalInheritState ) ;
3410- console . log ( '✓ 番茄钟状态已成功更新' ) ;
34113353 } else {
34123354 console . warn ( '番茄钟视图不支持updateState方法,尝试重新创建' ) ;
34133355 // 如果视图不支持更新,销毁并重建
@@ -3421,7 +3363,6 @@ export default class ReminderPlugin extends Plugin {
34213363 }
34223364 } else {
34233365 // 如果没有现有的番茄钟视图,尝试创建新的
3424- console . log ( '未找到番茄钟视图,尝试创建新的' ) ;
34253366 await this . recreatePomodoroTimer ( tabId , reminder , settings , isCountUp , inheritState ) ;
34263367 }
34273368 } catch ( error ) {
@@ -3441,7 +3382,6 @@ export default class ReminderPlugin extends Plugin {
34413382 inheritState ?: any
34423383 ) {
34433384 try {
3444- console . log ( '开始重新创建番茄钟' ) ;
34453385
34463386 // 动态导入PomodoroTimer
34473387 const { PomodoroTimer } = await import ( "./components/PomodoroTimer" ) ;
@@ -3452,11 +3392,9 @@ export default class ReminderPlugin extends Plugin {
34523392 console . error ( '未找到番茄钟容器, tabId:' , tabId ) ;
34533393 // 尝试其他方式查找容器
34543394 const allContainers = document . querySelectorAll ( '[data-type="' + POMODORO_TAB_TYPE + '"]' ) ;
3455- console . log ( '找到的所有番茄钟类型容器:' , allContainers . length ) ;
34563395
34573396 if ( allContainers . length > 0 ) {
34583397 const targetContainer = allContainers [ 0 ] as HTMLElement ;
3459- console . log ( '使用第一个找到的容器' ) ;
34603398
34613399 // 清空容器
34623400 targetContainer . innerHTML = '' ;
@@ -3472,14 +3410,12 @@ export default class ReminderPlugin extends Plugin {
34723410 ) ;
34733411
34743412 this . tabViews . set ( tabId , pomodoroTimer ) ;
3475- console . log ( '✓ 番茄钟已成功重新创建(使用备用容器)' ) ;
34763413 } else {
34773414 console . error ( '完全找不到番茄钟容器' ) ;
34783415 }
34793416 return ;
34803417 }
34813418
3482- console . log ( '找到番茄钟容器' ) ;
34833419
34843420 // 清空容器
34853421 container . innerHTML = '' ;
@@ -3495,7 +3431,6 @@ export default class ReminderPlugin extends Plugin {
34953431 ) ;
34963432
34973433 this . tabViews . set ( tabId , pomodoroTimer ) ;
3498- console . log ( '✓ 番茄钟已成功重新创建' ) ;
34993434 } catch ( error ) {
35003435 console . error ( '重新创建番茄钟失败:' , error ) ;
35013436 throw error ;
@@ -3508,7 +3443,6 @@ export default class ReminderPlugin extends Plugin {
35083443 private broadcastMessage ( type : string , data : any = { } , force = false ) {
35093444 // 如果不是强制发送且不存在其他窗口,则跳过广播
35103445 if ( ! force && this . otherWindowIds . size === 0 ) {
3511- console . log ( "跳过广播(无其他窗口):" , type , "force:" , force , "otherWindows:" , this . otherWindowIds . size ) ;
35123446 return ;
35133447 }
35143448
@@ -3521,7 +3455,6 @@ export default class ReminderPlugin extends Plugin {
35213455
35223456 // 通过 WebSocket 连接发送消息
35233457 this . postBroadcastMessage ( JSON . stringify ( message ) ) ;
3524- console . log ( "发送跨窗口消息:" , type , "windowId:" , this . windowId , "otherWindows:" , this . otherWindowIds . size ) ;
35253458 }
35263459
35273460 /**
0 commit comments