mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-13 13:39:48 +01:00
detect screen size
This commit is contained in:
parent
64fc0f335a
commit
35179e06ec
17
src/emain.ts
17
src/emain.ts
@ -75,10 +75,10 @@ function createRemotesWindow() {
|
||||
win.webContents.on("will-navigate", shNavHandler);
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
function createWindow(size : {width : number, height : number}) {
|
||||
let win = new electron.BrowserWindow({
|
||||
width: 1800,
|
||||
height: 1200,
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "../src/preload.js"),
|
||||
},
|
||||
@ -137,8 +137,17 @@ function createRemotesWindow() {
|
||||
return win;
|
||||
}
|
||||
|
||||
// primary display { width: 1680, height: 1050 }
|
||||
app.whenReady().then(() => {
|
||||
MainWindow = createWindow();
|
||||
let primaryDisplay = electron.screen.getPrimaryDisplay();
|
||||
let size = {width: 1800, height: 1200};
|
||||
if (primaryDisplay.size.width - 100 < size.width) {
|
||||
size.width = primaryDisplay.size.width - 100;
|
||||
}
|
||||
if (primaryDisplay.size.height - 100 < size.height) {
|
||||
size.height = primaryDisplay.size.height - 100;
|
||||
}
|
||||
MainWindow = createWindow(size);
|
||||
|
||||
app.on('activate', () => {
|
||||
if (electron.BrowserWindow.getAllWindows().length === 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user