25 lines
684 B
TypeScript
25 lines
684 B
TypeScript
|
// 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')
|
|||
|
}
|
|||
|
|
|||
|
})
|