@@ -45,7 +45,6 @@ import TouchBarManager from './ui/TouchBarManager'
4545import TrayManager from './ui/TrayManager'
4646import DockManager from './ui/DockManager'
4747import ThemeManager from './ui/ThemeManager'
48- import PriorityManager from './core/PriorityManager'
4948
5049export default class Application extends EventEmitter {
5150 constructor ( ) {
@@ -119,8 +118,6 @@ export default class Application extends EventEmitter {
119118
120119 this . initUpdaterManager ( )
121120
122- this . initPriorityManager ( )
123-
124121 this . handleCommands ( )
125122
126123 this . handleEvents ( )
@@ -1096,7 +1093,11 @@ export default class Application extends EventEmitter {
10961093 const key = 'custom-keymap'
10971094 this . configListeners [ key ] = userConfig . onDidChange ( key , async ( newValue , oldValue ) => {
10981095 logger . info ( `[Motrix] detected ${ key } value change event:` , newValue , oldValue )
1099- this . menuManager . setup ( this . locale )
1096+ if ( this . menuManager ) {
1097+ this . menuManager . setup ( this . locale )
1098+ } else {
1099+ logger . warn ( '[Motrix] menuManager not initialized' )
1100+ }
11001101 } )
11011102 }
11021103
@@ -1134,7 +1135,11 @@ export default class Application extends EventEmitter {
11341135 }
11351136
11361137 logger . info ( '[Motrix] setup protocols client:' , newValue )
1137- this . protocolManager . setup ( newValue )
1138+ if ( this . protocolManager ) {
1139+ this . protocolManager . setup ( newValue )
1140+ } else {
1141+ logger . warn ( '[Motrix] protocolManager not initialized' )
1142+ }
11381143 } )
11391144 }
11401145
@@ -1243,21 +1248,6 @@ export default class Application extends EventEmitter {
12431248 } )
12441249 }
12451250
1246- watchPriorityEngineChange ( ) {
1247- const { userConfig } = this . configManager
1248- const key = 'enablePriorityEngine'
1249- this . configListeners [ key ] = userConfig . onDidChange ( key , async ( newValue , oldValue ) => {
1250- logger . info ( `[Motrix] detected ${ key } value change event:` , newValue , oldValue )
1251- if ( this . priorityManager ) {
1252- if ( newValue ) {
1253- this . priorityManager . enable ( )
1254- } else {
1255- this . priorityManager . disable ( )
1256- }
1257- }
1258- } )
1259- }
1260-
12611251 watchShowProgressBarChange ( ) {
12621252 const { userConfig } = this . configManager
12631253 const key = 'show-progress-bar'
@@ -1614,7 +1604,7 @@ export default class Application extends EventEmitter {
16141604 this . emit ( 'ready' )
16151605 } )
16161606
1617- if ( is . macOS ( ) ) {
1607+ if ( is . macOS ( ) && this . touchBarManager ) {
16181608 this . touchBarManager . setup ( page , win )
16191609 }
16201610 }
@@ -2101,20 +2091,6 @@ export default class Application extends EventEmitter {
21012091 this . handleUpdaterEvents ( )
21022092 }
21032093
2104- initPriorityManager ( ) {
2105- this . priorityManager = new PriorityManager ( {
2106- configManager : this . configManager
2107- } )
2108- }
2109-
2110- startPriorityManager ( ) {
2111- if ( ! this . priorityManager ) return
2112-
2113- this . priorityManager . init ( {
2114- engine : this . engineClient
2115- } )
2116- }
2117-
21182094 handleUpdaterEvents ( ) {
21192095 this . updateManager . on ( 'checking' , ( event ) => {
21202096 this . menuManager . updateMenuItemEnabledState ( 'app.check-for-updates' , false )
@@ -2958,24 +2934,17 @@ export default class Application extends EventEmitter {
29582934 return
29592935 }
29602936 logger . info ( '[Motrix] setup protocols client:' , protocols )
2961- this . protocolManager . setup ( protocols )
2937+ if ( this . protocolManager ) {
2938+ this . protocolManager . setup ( protocols )
2939+ } else {
2940+ logger . warn ( '[Motrix] protocolManager not initialized' )
2941+ }
29622942 } )
29632943
29642944 this . on ( 'application:open-external' , ( url ) => {
29652945 this . openExternal ( url )
29662946 } )
29672947
2968- this . on ( 'application:toggle-priority-engine' , ( enabled ) => {
2969- logger . info ( '[Motrix] toggle priority engine:' , enabled )
2970- if ( this . priorityManager ) {
2971- if ( enabled ) {
2972- this . priorityManager . enable ( )
2973- } else {
2974- this . priorityManager . disable ( )
2975- }
2976- }
2977- } )
2978-
29792948 this . on ( 'task-progress:control' , ( payload = { } ) => {
29802949 const window = this . windowManager . getWindow ( 'index' )
29812950 if ( ! window ) {
@@ -3146,9 +3115,6 @@ export default class Application extends EventEmitter {
31463115 this . adjustMenu ( )
31473116 this . scheduleCheckTaskPlan ( 2000 )
31483117
3149- // 启动优先级管理器
3150- this . startPriorityManager ( )
3151-
31523118 // 监听主窗口加载完成事件,确保前端组件已挂载后再发送更新状态
31533119 const mainWindow = this . windowManager . getWindow ( 'index' )
31543120 if ( mainWindow ) {
@@ -3174,7 +3140,6 @@ export default class Application extends EventEmitter {
31743140 this . watchLocaleChange ( )
31753141 this . watchThemeChange ( )
31763142 this . watchAutoCheckUpdateChange ( )
3177- this . watchPriorityEngineChange ( )
31783143
31793144 this . on ( 'download-status-change' , ( downloading ) => {
31803145 this . trayManager . handleDownloadStatusChange ( downloading )
@@ -3196,11 +3161,6 @@ export default class Application extends EventEmitter {
31963161 this . dockManager . openDock ( path )
31973162 this . _taskPlanHasCompletionSinceEnabled = true
31983163
3199- // 通知优先级管理器任务完成
3200- if ( this . priorityManager ) {
3201- this . priorityManager . onTaskComplete ( task . gid )
3202- }
3203-
32043164 // 执行安全扫描
32053165 this . performSecurityScan ( task , path )
32063166
@@ -3211,10 +3171,6 @@ export default class Application extends EventEmitter {
32113171 } )
32123172
32133173 this . on ( 'download-start' , ( event ) => {
3214- // 通知优先级管理器任务开始
3215- if ( this . priorityManager ) {
3216- this . priorityManager . onTaskStart ( )
3217- }
32183174 } )
32193175
32203176 if ( this . configManager . userConfig . get ( 'show-progress-bar' ) ) {
@@ -3509,23 +3465,6 @@ export default class Application extends EventEmitter {
35093465 }
35103466 } )
35113467
3512- // 优先级管理相关
3513- ipcMain . handle ( 'priority:status' , async ( ) => {
3514- if ( this . priorityManager ) {
3515- const status = this . priorityManager . getStatus ( )
3516- return { success : true , ...status }
3517- }
3518- return { success : false , error : 'PriorityManager not initialized' }
3519- } )
3520-
3521- ipcMain . handle ( 'priority:rebalance' , async ( ) => {
3522- if ( this . priorityManager ) {
3523- await this . priorityManager . rebalanceResources ( )
3524- return { success : true }
3525- }
3526- return { success : false , error : 'PriorityManager not initialized' }
3527- } )
3528-
35293468 // Get progress window size
35303469 ipcMain . handle ( 'get-progress-window-size' , async ( event ) => {
35313470 try {
0 commit comments