mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
build: use typescript for internal Electron JS code (#16441)
This commit is contained in:
38
default_app/default_app.ts
Normal file
38
default_app/default_app.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { app, BrowserWindow, BrowserWindowConstructorOptions } from 'electron'
|
||||
import * as path from 'path'
|
||||
|
||||
let mainWindow: BrowserWindow | null = null
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', () => {
|
||||
app.quit()
|
||||
})
|
||||
|
||||
export const load = async (appUrl: string) => {
|
||||
await app.whenReady()
|
||||
|
||||
const options: BrowserWindowConstructorOptions = {
|
||||
width: 900,
|
||||
height: 600,
|
||||
autoHideMenuBar: true,
|
||||
backgroundColor: '#FFFFFF',
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
preload: path.resolve(__dirname, 'renderer.js'),
|
||||
webviewTag: false
|
||||
},
|
||||
useContentSize: true,
|
||||
show: false
|
||||
}
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
options.icon = path.join(__dirname, 'icon.png')
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(options)
|
||||
|
||||
mainWindow.on('ready-to-show', () => mainWindow!.show())
|
||||
|
||||
mainWindow.loadURL(appUrl)
|
||||
mainWindow.focus()
|
||||
}
|
||||
Reference in New Issue
Block a user