Archived
Fix tray window sizing #6
@@ -2,6 +2,8 @@ export const MANAGEMENT_URL = 'https://vpn.vyntehome.com';
|
|||||||
export const GATEWAY_HOST = new URL(MANAGEMENT_URL).host;
|
export const GATEWAY_HOST = new URL(MANAGEMENT_URL).host;
|
||||||
export const APP_NAME = "Vynte Connect";
|
export const APP_NAME = "Vynte Connect";
|
||||||
export const POLL_INTERVAL_MS = 5000;
|
export const POLL_INTERVAL_MS = 5000;
|
||||||
|
export const WINDOW_WIDTH = 384;
|
||||||
|
export const WINDOW_HEIGHT = 420;
|
||||||
export const DEFAULT_STATUS = {
|
export const DEFAULT_STATUS = {
|
||||||
state: "checking",
|
state: "checking",
|
||||||
title: `Checking ${GATEWAY_HOST}`,
|
title: `Checking ${GATEWAY_HOST}`,
|
||||||
|
|||||||
+10
-7
@@ -1,7 +1,7 @@
|
|||||||
import { app, BrowserWindow, ipcMain, nativeImage, shell, Tray } from 'electron';
|
import { app, BrowserWindow, ipcMain, nativeImage, shell, Tray } from 'electron';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import started from 'electron-squirrel-startup';
|
import started from 'electron-squirrel-startup';
|
||||||
import { APP_NAME, DEFAULT_STATUS, GATEWAY_HOST, MANAGEMENT_URL, POLL_INTERVAL_MS } from './config';
|
import { APP_NAME, DEFAULT_STATUS, GATEWAY_HOST, MANAGEMENT_URL, POLL_INTERVAL_MS, WINDOW_HEIGHT, WINDOW_WIDTH } from './config';
|
||||||
import { NetBirdClient } from './netbird';
|
import { NetBirdClient } from './netbird';
|
||||||
import { baseStatus, normalizeStatus } from './status';
|
import { baseStatus, normalizeStatus } from './status';
|
||||||
|
|
||||||
@@ -145,8 +145,8 @@ async function logout() {
|
|||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
window = new BrowserWindow({
|
window = new BrowserWindow({
|
||||||
width: 384,
|
width: WINDOW_WIDTH,
|
||||||
height: 430,
|
height: WINDOW_HEIGHT,
|
||||||
show: false,
|
show: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
frame: false,
|
frame: false,
|
||||||
@@ -171,10 +171,13 @@ function createWindow() {
|
|||||||
|
|
||||||
function showWindow() {
|
function showWindow() {
|
||||||
const bounds = tray.getBounds();
|
const bounds = tray.getBounds();
|
||||||
const windowBounds = window.getBounds();
|
const x = Math.round(bounds.x - WINDOW_WIDTH);
|
||||||
const x = Math.round(bounds.x + bounds.width - windowBounds.width);
|
const y = Math.round(bounds.y - WINDOW_HEIGHT);
|
||||||
const y = Math.round(bounds.y - windowBounds.height - 8);
|
window.setBounds({
|
||||||
window.setPosition(Math.max(x, 0), Math.max(y, 0), false);
|
width: WINDOW_WIDTH,
|
||||||
|
height: WINDOW_HEIGHT,
|
||||||
|
x, y
|
||||||
|
});
|
||||||
window.show();
|
window.show();
|
||||||
window.focus();
|
window.focus();
|
||||||
broadcastStatus();
|
broadcastStatus();
|
||||||
|
|||||||
+3
-2
@@ -30,6 +30,7 @@ export class NetBirdClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated???
|
||||||
runElevated(args: string[]): Promise<Omit<CommandResult, 'code'>> {
|
runElevated(args: string[]): Promise<Omit<CommandResult, 'code'>> {
|
||||||
const quotedExe = this.executablePath.replace(/'/g, "''");
|
const quotedExe = this.executablePath.replace(/'/g, "''");
|
||||||
const quotedArgs = args.map(arg => `'${String(arg).replace(/'/g, "''")}'`).join(',');
|
const quotedArgs = args.map(arg => `'${String(arg).replace(/'/g, "''")}'`).join(',');
|
||||||
@@ -67,7 +68,7 @@ export class NetBirdClient {
|
|||||||
|
|
||||||
if (status.ok) return true;
|
if (status.ok) return true;
|
||||||
|
|
||||||
await this.runElevated([
|
await this.run([
|
||||||
'service',
|
'service',
|
||||||
'install',
|
'install',
|
||||||
'--management-url',
|
'--management-url',
|
||||||
@@ -78,7 +79,7 @@ export class NetBirdClient {
|
|||||||
'info'
|
'info'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await this.runElevated(['service', 'start']);
|
await this.run(['service', 'start']);
|
||||||
|
|
||||||
for (let index = 0; index < 20; index++) {
|
for (let index = 0; index < 20; index++) {
|
||||||
const check = await this.status({ timeout: 8000 });
|
const check = await this.status({ timeout: 8000 });
|
||||||
|
|||||||
Reference in New Issue
Block a user