Skip to content

Commit 4b38962

Browse files
simonhampgithub-actions[bot]
authored andcommittedNov 14, 2024·
Build plugin
1 parent 6ee19ca commit 4b38962

File tree

1 file changed

+28
-4
lines changed
  • resources/js/electron-plugin/dist/server/api

1 file changed

+28
-4
lines changed
 

‎resources/js/electron-plugin/dist/server/api/menuBar.js

+28-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@ import { mapMenu } from "./helper";
44
import state from "../state";
55
import { menubar } from "menubar";
66
import { notifyLaravel } from "../utils";
7+
import { join } from "path";
78
const router = express.Router();
89
router.post("/label", (req, res) => {
910
res.sendStatus(200);
1011
const { label } = req.body;
1112
state.activeMenuBar.tray.setTitle(label);
1213
});
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+
});
1324
router.post("/context-menu", (req, res) => {
1425
res.sendStatus(200);
1526
const { contextMenu } = req.body;
@@ -25,12 +36,21 @@ router.post("/hide", (req, res) => {
2536
});
2637
router.post("/create", (req, res) => {
2738
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) {
3041
const tray = new Tray(icon || state.icon.replace("icon.png", "IconTemplate.png"));
3142
tray.setContextMenu(buildMenu(contextMenu));
43+
if (event) {
44+
tray.on('click', (e) => {
45+
notifyLaravel('events', {
46+
event,
47+
payload: e,
48+
});
49+
});
50+
}
3251
state.activeMenuBar = menubar({
3352
tray,
53+
tooltip,
3454
index: false,
3555
showDockIcon,
3656
showOnAllWorkspaces: false,
@@ -44,21 +64,25 @@ router.post("/create", (req, res) => {
4464
else {
4565
state.activeMenuBar = menubar({
4666
icon: icon || state.icon.replace("icon.png", "IconTemplate.png"),
67+
preloadWindow: true,
68+
tooltip,
4769
index: url,
4870
showDockIcon,
4971
showOnAllWorkspaces: false,
5072
windowPosition: windowPosition !== null && windowPosition !== void 0 ? windowPosition : "trayCenter",
5173
browserWindow: {
5274
width,
5375
height,
76+
resizable,
5477
alwaysOnTop,
5578
vibrancy,
5679
backgroundColor,
5780
transparent: transparency,
5881
webPreferences: {
82+
preload: join(__dirname, '../../electron-plugin/dist/preload/index.js'),
5983
nodeIntegration: true,
6084
sandbox: false,
61-
contextIsolation: false
85+
contextIsolation: false,
6286
}
6387
}
6488
});
@@ -86,7 +110,7 @@ router.post("/create", (req, res) => {
86110
]
87111
});
88112
});
89-
if (onlyShowContextWindow !== true) {
113+
if (!onlyShowContextMenu) {
90114
state.activeMenuBar.tray.on("right-click", () => {
91115
notifyLaravel("events", {
92116
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarContextMenuOpened"

0 commit comments

Comments
 (0)
Please sign in to comment.