File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { MenuBarEvent , IMenuBar , IMenuBarItem } from 'mo/core/workbench/menuBar' ;
2
+ import { emit } from 'mo/services/eventService' ;
3
+ import { singleton } from 'tsyringe' ;
4
+
5
+ @singleton ( )
6
+ export class MenuBarService implements IMenuBar {
7
+ data : IMenuBarItem [ ] ;
8
+
9
+ constructor ( data : IMenuBarItem [ ] = [ ] ) {
10
+ this . data = data ;
11
+ }
12
+
13
+ @emit ( MenuBarEvent . onClick )
14
+ public onClick ( event : React . MouseEvent , item : IMenuBarItem ) {
15
+ console . log ( 'onClick:' , this . data ) ;
16
+ }
17
+
18
+ @emit ( MenuBarEvent . DataChanged )
19
+ public push ( data : IMenuBarItem | IMenuBarItem [ ] ) {
20
+ if ( Array . isArray ( data ) ) {
21
+ this . data = this . data . concat ( data ) ;
22
+ } else {
23
+ this . data . push ( data ) ;
24
+ }
25
+ }
26
+
27
+ public remove ( index : number ) {
28
+ this . data . splice ( index , 1 ) ;
29
+ }
30
+
31
+ public update ( ) {
32
+ // this.data.
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments