@@ -4,12 +4,23 @@ import { mapMenu } from "./helper";
4
4
import state from "../state" ;
5
5
import { menubar } from "menubar" ;
6
6
import { notifyLaravel } from "../utils" ;
7
+ import { join } from "path" ;
7
8
const router = express . Router ( ) ;
8
9
router . post ( "/label" , ( req , res ) => {
9
10
res . sendStatus ( 200 ) ;
10
11
const { label } = req . body ;
11
12
state . activeMenuBar . tray . setTitle ( label ) ;
12
13
} ) ;
14
+ router . post ( "/tooltip" , ( req , res ) => {
15
+ res . sendStatus ( 200 ) ;
16
+ const { tooltip } = req . body ;
17
+ state . activeMenuBar . tray . setToolTip ( tooltip ) ;
18
+ } ) ;
19
+ router . post ( "/icon" , ( req , res ) => {
20
+ res . sendStatus ( 200 ) ;
21
+ const { icon } = req . body ;
22
+ state . activeMenuBar . tray . setImage ( icon ) ;
23
+ } ) ;
13
24
router . post ( "/context-menu" , ( req , res ) => {
14
25
res . sendStatus ( 200 ) ;
15
26
const { contextMenu } = req . body ;
@@ -25,12 +36,21 @@ router.post("/hide", (req, res) => {
25
36
} ) ;
26
37
router . post ( "/create" , ( req , res ) => {
27
38
res . sendStatus ( 200 ) ;
28
- const { width, height, url, label, alwaysOnTop, vibrancy, backgroundColor, transparency, icon, showDockIcon, onlyShowContextWindow , windowPosition, contextMenu } = req . body ;
29
- if ( onlyShowContextWindow === true ) {
39
+ const { width, height, url, label, alwaysOnTop, vibrancy, backgroundColor, transparency, icon, showDockIcon, onlyShowContextMenu , windowPosition, contextMenu, tooltip , resizable , event , } = req . body ;
40
+ if ( onlyShowContextMenu ) {
30
41
const tray = new Tray ( icon || state . icon . replace ( "icon.png" , "IconTemplate.png" ) ) ;
31
42
tray . setContextMenu ( buildMenu ( contextMenu ) ) ;
43
+ if ( event ) {
44
+ tray . on ( 'click' , ( e ) => {
45
+ notifyLaravel ( 'events' , {
46
+ event,
47
+ payload : e ,
48
+ } ) ;
49
+ } ) ;
50
+ }
32
51
state . activeMenuBar = menubar ( {
33
52
tray,
53
+ tooltip,
34
54
index : false ,
35
55
showDockIcon,
36
56
showOnAllWorkspaces : false ,
@@ -44,21 +64,25 @@ router.post("/create", (req, res) => {
44
64
else {
45
65
state . activeMenuBar = menubar ( {
46
66
icon : icon || state . icon . replace ( "icon.png" , "IconTemplate.png" ) ,
67
+ preloadWindow : true ,
68
+ tooltip,
47
69
index : url ,
48
70
showDockIcon,
49
71
showOnAllWorkspaces : false ,
50
72
windowPosition : windowPosition !== null && windowPosition !== void 0 ? windowPosition : "trayCenter" ,
51
73
browserWindow : {
52
74
width,
53
75
height,
76
+ resizable,
54
77
alwaysOnTop,
55
78
vibrancy,
56
79
backgroundColor,
57
80
transparent : transparency ,
58
81
webPreferences : {
82
+ preload : join ( __dirname , '../../electron-plugin/dist/preload/index.js' ) ,
59
83
nodeIntegration : true ,
60
84
sandbox : false ,
61
- contextIsolation : false
85
+ contextIsolation : false ,
62
86
}
63
87
}
64
88
} ) ;
@@ -86,7 +110,7 @@ router.post("/create", (req, res) => {
86
110
]
87
111
} ) ;
88
112
} ) ;
89
- if ( onlyShowContextWindow !== true ) {
113
+ if ( ! onlyShowContextMenu ) {
90
114
state . activeMenuBar . tray . on ( "right-click" , ( ) => {
91
115
notifyLaravel ( "events" , {
92
116
event : "\\Native\\Laravel\\Events\\MenuBar\\MenuBarContextMenuOpened"
0 commit comments