Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
feat: 支持给BrowserWindow传递初始化参数
Browse files Browse the repository at this point in the history
  • Loading branch information
asforest committed Dec 7, 2021
1 parent 6bd25af commit 01d6f51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
17 changes: 11 additions & 6 deletions src/main/Updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ export class Updater
this.printEnvironment()

// 初始化窗口
// 加载默认窗口宽高
let winWidth = this.readField('window_width', 'number', 400)
let winHeight = this.readField('window_height', 'number', 300)
let frameless = this.readField('frameless', 'boolean', false)
let transparent = this.readField('transparent', 'boolean', false)
await this.uwin.create(winWidth, winHeight, frameless, transparent)
await this.uwin.create({
width: this.readField('window_width', 'number', 400),
height: this.readField('window_height', 'number', 300),
frame: !this.readField('frameless', 'boolean', false),
transparent: this.readField('transparent', 'boolean', false),
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
...this.readField('window_config', 'object', {})
})

// 加载图标
let iconpath = this.readField('icon', 'string')
Expand Down
17 changes: 4 additions & 13 deletions src/main/UpdaterWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export class UpdaterWindow
})
}

async create(width: number, height: number, frameless: boolean, transparent: boolean): Promise<void>
async create(configs: any): Promise<void>
{
await new Promise((a, b) => {
let cre = () => {
this.createWindow(width, height, frameless, transparent)
this.createWindow(configs)
a(undefined)
}

Expand Down Expand Up @@ -123,18 +123,9 @@ export class UpdaterWindow
})
}

private createWindow(width: number, height: number, frameless: boolean, transparent: boolean)
private createWindow(configs: any)
{
this.win = new BrowserWindow({
width: width,
height: height,
frame: !frameless,
transparent: transparent,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
})
this.win = new BrowserWindow(configs)

if(app.isPackaged)
this.win.setMenuBarVisibility(false)
Expand Down

0 comments on commit 01d6f51

Please sign in to comment.