BrowserWindow
创建并控制浏览器窗口
新建窗口
ts
import { BrowserWindow } from "electron"
let win: BrowserWindow = new BrowserWindow({
width: 400,
height: 200,
title: "Main window",
icon: join(__dirname, "../../packages/icon/logo.ico"),
webPreferences: {
preload: join(__dirname, "../preload/index.cjs"),
nodeIntegration: true,
contextIsolation: false,
webSecurity: false
}
})
import { BrowserWindow } from "electron"
let win: BrowserWindow = new BrowserWindow({
width: 400,
height: 200,
title: "Main window",
icon: join(__dirname, "../../packages/icon/logo.ico"),
webPreferences: {
preload: join(__dirname, "../preload/index.cjs"),
nodeIntegration: true,
contextIsolation: false,
webSecurity: false
}
})
窗口最小化
ts
win.minimize()
win.minimize()
窗口关闭
ts
win.hide()
win.hide()
窗口不可以调整大小
ts
win.resizable = false
win.resizable = false
窗口固定
位于其他应用之上
ts
win.setAlwaysOnTop(true)
win.setAlwaysOnTop(true)