electron-app-example/src/background.ts
2024-09-21 23:31:33 +08:00

26 lines
685 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// electron 主进程文件
import { app, BrowserWindow} from 'electron'
app.whenReady().then(()=>{
const win = new BrowserWindow({
height: 600,
width: 800,
webPreferences:{
nodeIntegration: true, // 可以在渲染进程汇总使用node的api为了安全默认false
contextIsolation: false, // 关闭渲染进程的沙箱
webSecurity: false, // 关闭跨域检测
}
})
// win.webContents.openDevTools() // 开发环境打开控制台
if(process.argv[2]) // 开发环境
{
win.loadURL(process.argv[2])
}
else // 生产环境
{
win.loadFile('index.html')
}
})