Skip to content

Commit

Permalink
Build plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp authored and github-actions[bot] committed Nov 14, 2024
1 parent 6ee19ca commit 4b38962
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions resources/js/electron-plugin/dist/server/api/menuBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ import { mapMenu } from "./helper";
import state from "../state";
import { menubar } from "menubar";
import { notifyLaravel } from "../utils";
import { join } from "path";
const router = express.Router();
router.post("/label", (req, res) => {
res.sendStatus(200);
const { label } = req.body;
state.activeMenuBar.tray.setTitle(label);
});
router.post("/tooltip", (req, res) => {
res.sendStatus(200);
const { tooltip } = req.body;
state.activeMenuBar.tray.setToolTip(tooltip);
});
router.post("/icon", (req, res) => {
res.sendStatus(200);
const { icon } = req.body;
state.activeMenuBar.tray.setImage(icon);
});
router.post("/context-menu", (req, res) => {
res.sendStatus(200);
const { contextMenu } = req.body;
Expand All @@ -25,12 +36,21 @@ router.post("/hide", (req, res) => {
});
router.post("/create", (req, res) => {
res.sendStatus(200);
const { width, height, url, label, alwaysOnTop, vibrancy, backgroundColor, transparency, icon, showDockIcon, onlyShowContextWindow, windowPosition, contextMenu } = req.body;
if (onlyShowContextWindow === true) {
const { width, height, url, label, alwaysOnTop, vibrancy, backgroundColor, transparency, icon, showDockIcon, onlyShowContextMenu, windowPosition, contextMenu, tooltip, resizable, event, } = req.body;
if (onlyShowContextMenu) {
const tray = new Tray(icon || state.icon.replace("icon.png", "IconTemplate.png"));
tray.setContextMenu(buildMenu(contextMenu));
if (event) {
tray.on('click', (e) => {
notifyLaravel('events', {
event,
payload: e,
});
});
}
state.activeMenuBar = menubar({
tray,
tooltip,
index: false,
showDockIcon,
showOnAllWorkspaces: false,
Expand All @@ -44,21 +64,25 @@ router.post("/create", (req, res) => {
else {
state.activeMenuBar = menubar({
icon: icon || state.icon.replace("icon.png", "IconTemplate.png"),
preloadWindow: true,
tooltip,
index: url,
showDockIcon,
showOnAllWorkspaces: false,
windowPosition: windowPosition !== null && windowPosition !== void 0 ? windowPosition : "trayCenter",
browserWindow: {
width,
height,
resizable,
alwaysOnTop,
vibrancy,
backgroundColor,
transparent: transparency,
webPreferences: {
preload: join(__dirname, '../../electron-plugin/dist/preload/index.js'),
nodeIntegration: true,
sandbox: false,
contextIsolation: false
contextIsolation: false,
}
}
});
Expand Down Expand Up @@ -86,7 +110,7 @@ router.post("/create", (req, res) => {
]
});
});
if (onlyShowContextWindow !== true) {
if (!onlyShowContextMenu) {
state.activeMenuBar.tray.on("right-click", () => {
notifyLaravel("events", {
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarContextMenuOpened"
Expand Down

0 comments on commit 4b38962

Please sign in to comment.