electron 学习

javascript 复制代码
const { app, BrowserWindow } = require('electron');
const path = require('path');
function createWindow () {
  let mainWin = new BrowserWindow({
    x: 100,
    y: 100,
    show:false, // 默认不显示窗体
    width: 800,
    height: 800,
    maxHeight: 1000,
    maxWidth: 1000,
    minHeight: 400,
    minWidth: 400,
    // frame:false, // 只显示内容,隐藏默认菜单栏
    resizable: false, // 不允许缩放
    // transparent:true, // 透明窗体设置
    autoHideMenuBar:true, // 隐藏menu菜单
    icon: 'ty.ico',
    // icon: path.resolve(__dirname, 'ty.ico'),
    title:'ty 学习1' // 这里配置后,就要删掉页面的title配置,不然不生效
  })
  mainWin.loadFile('index.html'); // 这个要放到 ready-to-show 上面
  mainWin.on('ready-to-show', () => { // 监听事件,展示窗体
    mainWin.show();
  })

  mainWin.webContents.on('did-finish-load', () => {
    console.log('22-did-finish-load');
  })
  mainWin.webContents.on('dom-ready', () => {
    console.log('11-dom-ready');
  })
  mainWin.on('close', () => {
    console.log('33-window close');
    mainWin = null;
  })
}

app.on('ready', () => {
  createWindow();
  console.log('00-ready')
});
app.on('window-all-closed', () => {
  console.log('44-window-all-close');
  app.quit()
})
app.on('before-quit', () => {
  console.log('55-before-quit')
})
app.on('will-quit', () => {
  console.log('66-will-quit')
})
app.on('quit', () => {
  console.log('77-will-quit')
})
相关推荐
风清云淡_A2 分钟前
【react18】在styled-components中引入图片报错
前端·reactjs
兔子坨坨29 分钟前
IDEA连接github(上传项目)
java·git·学习·github
GUIQU.1 小时前
【Node.js】Web开发框架
前端·node.js
Brookty1 小时前
【MySQL】数据库约束
数据库·后端·学习·mysql
小石(努力版)1 小时前
嵌入式STM32学习——串口USART 2.0(printf重定义及串口发送)
stm32·嵌入式硬件·学习
决战软件之巅1 小时前
vue调后台接口
前端·javascript·vue.js
A_aspectJ1 小时前
基于Bootstrap 的网页html css 登录页制作成品
前端·css·bootstrap·html
诸葛亮的芭蕉扇1 小时前
StreamSaver实现大文件下载解决方案
前端·javascript·vue.js·node.js
重生之后端学习1 小时前
03-Web后端基础(Maven基础)
java·前端·spring boot·后端·spring·tomcat·maven
gong191723169672 小时前
解释一下React事件系统中的事件委托机制
前端·javascript·react.js