Skip to content

Commit b0a8aee

Browse files
authored
Add endpoint to resize MenuBar window (#163)
* Add endpoint to resize MenuBar window * Reinstated wrongfully deleted yarn.lock
1 parent 45d9f99 commit b0a8aee

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

resources/js/electron-plugin/dist/index.js

+18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class NativePHP {
2323
constructor() {
2424
this.processes = [];
2525
this.schedulerInterval = undefined;
26+
this.mainWindow = null;
2627
}
2728
bootstrap(app, icon, phpBinary, cert) {
2829
initialize();
@@ -66,6 +67,16 @@ class NativePHP {
6667
}
6768
event.preventDefault();
6869
});
70+
if (process.platform === 'win32') {
71+
app.on('second-instance', (event, commandLine, workingDirectory) => {
72+
if (this.mainWindow) {
73+
if (this.mainWindow.isMinimized())
74+
this.mainWindow.restore();
75+
this.mainWindow.focus();
76+
}
77+
this.handleDeepLink(commandLine.pop());
78+
});
79+
}
6980
}
7081
bootstrapApp(app) {
7182
return __awaiter(this, void 0, void 0, function* () {
@@ -124,6 +135,13 @@ class NativePHP {
124135
else {
125136
app.setAsDefaultProtocolClient(deepLinkProtocol);
126137
}
138+
if (process.platform === 'win32') {
139+
const gotTheLock = app.requestSingleInstanceLock();
140+
if (!gotTheLock) {
141+
app.quit();
142+
return;
143+
}
144+
}
127145
}
128146
}
129147
startAutoUpdater(config) {

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

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ router.post("/hide", (req, res) => {
3535
res.sendStatus(200);
3636
state.activeMenuBar.hideWindow();
3737
});
38+
router.post("/resize", (req, res) => {
39+
res.sendStatus(200);
40+
const { width, height } = req.body;
41+
state.activeMenuBar.window.setSize(width, height);
42+
});
3843
router.post("/create", (req, res) => {
3944
res.sendStatus(200);
4045
let shouldSendCreatedEvent = true;

resources/js/electron-plugin/src/server/api/menuBar.ts

+8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ router.post("/hide", (req, res) => {
5353
state.activeMenuBar.hideWindow();
5454
});
5555

56+
router.post("/resize", (req, res) => {
57+
res.sendStatus(200);
58+
59+
const { width, height } = req.body;
60+
61+
state.activeMenuBar.window.setSize(width, height);
62+
});
63+
5664
router.post("/create", (req, res) => {
5765
res.sendStatus(200);
5866

0 commit comments

Comments
 (0)