@@ -56,17 +56,10 @@ class BaseWindow extends Events {
5656 // 注册到窗口中心
5757 windowCenter . _register ( name , this ) ;
5858 }
59-
60- // 发布通知
61- publisher ( eventName , params = { } ) {
62- ipc . _publisher ( { header : { fromId : this . name , eventName } , body : params } ) ;
63- this . emit ( eventName , params ) ;
64- }
65-
6659 open ( option = { } ) {
6760 try {
6861 if ( this . instance === null ) {
69- const _option = Object . assign ( defaultOption , this . option , option ) ;
62+ const _option = Object . assign ( { } , defaultOption , this . option , option ) ;
7063 this . instance = new BrowserWindow ( _option ) ;
7164 // 窗口ID,必须
7265 this . instance . windowId = this . name ;
@@ -92,6 +85,24 @@ class BaseWindow extends Events {
9285 getInstance ( ) {
9386 return this . instance ;
9487 }
88+
89+ // 发布通知
90+ publisher ( eventName , params = { } ) {
91+ ipc . _publisher ( { header : { fromId : this . name , eventName } , body : params } ) ;
92+ this . emit ( eventName , params ) ;
93+ }
94+
95+ request ( eventName = '' , data = { } , timeout ) {
96+ return ipc . request ( this . name , eventName , data , timeout ) ;
97+ }
98+
99+ subscribe ( eventName = '' , callback ) {
100+ return ipc . subscribe ( this . name , eventName , callback ) ;
101+ }
102+
103+ unsubscribe ( eventName , callback ) {
104+ return ipc . unsubscribe ( this . name , eventName , callback ) ;
105+ }
95106}
96107
97108module . exports = BaseWindow ;
0 commit comments