zoukankan      html  css  js  c++  java
  • Electron(四)封装配置

    src/renderer/util/option.js

    export const mainOption = {
       1000,
      height: 520,
      // width 和 height 将设置为 web 页面的尺寸
      useContentSize: true,
      // 窗口在屏幕居中
      center: true,
      // 窗口是否可以改变尺寸 开启后maximizable失效
      resizable: false,
      // 窗口是否可以移动
      // movable: true,
      // 窗口是否可以最小化
      minimizable: true,
      // 窗口是否可以最大化
      maximizable: true,
      // 置顶窗口
      alwaysOnTop: false,
      webPreferences: {
        // 是否开启 DevTools,开发模式默认位true
        // devTools:true,
        //  是否集成Node
        // nodeIntegration: false,
        // 禁用同源策略
        webSecurity: false,
        // 是否允许一个使用 https的界面来展示由 http URLs 传过来的资源。默认false
        allowDisplayingInsecureContent: false,
        // 是否允许一个使用 https的界面来渲染由 http URLs 提交的html,css,javascript。默认为 false。
        allowRunningInsecureContent: false,
        nativeWindowOpen: true
      },
      show: false,
      backgroundColor: '#fff'
    };

    src/main/index.js

    import {app, BrowserWindow} from 'electron'
    import {mainOption} from "../renderer/util/option";
    
    /**
     * Set `__static` path to static files in production
     * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
     */
    if (process.env.NODE_ENV !== 'development') {
      global.__static = require('path').join(__dirname, '/static').replace(/\/g, '\\')
    }
    
    let mainWindow;
    const winURL = process.env.NODE_ENV === 'development'
      ? `http://localhost:9080`
      : `file://${__dirname}/index.html`;
    
    const createWindow = () => {
      mainWindow = new BrowserWindow(mainOption);
      mainWindow.once('ready-to-show', () => {
        mainWindow.show()
      });
      mainWindow.loadURL(winURL);
      mainWindow.setMenu(null);
      mainWindow.on('closed', () => {
        mainWindow = null
      });
    };
    // 完成初始化
    app.on('ready', createWindow);
    
    
    // 当所有的窗口都被关闭时触发
    app.on('window-all-closed', () => {
      if (process.platform !== 'darwin') {
        app.quit()
      }
    });
    
    app.on('activate', () => {
      if (mainWindow === null) {
        createWindow()
      }
    });
    /**
     * Auto Updater
     *
     * Uncomment the following code below and install `electron-updater` to
     * support auto updating. Code Signing with a valid certificate is required.
     * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating
     */
    
    /*
    import { autoUpdater } from 'electron-updater'
    
    autoUpdater.on('update-downloaded', () => {
      autoUpdater.quitAndInstall()
    })
    
    app.on('ready', () => {
      if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates()
    })
     */
  • 相关阅读:
    centos、mac的grafana安装和简单使用
    通过k8s(Kubernetes)搭建jmeter的压测环境master-slave架构,实现弹性伸缩
    burpsuite破解版
    jvm调优
    火狐firefox、谷歌chrome等浏览器扩展、插件介绍
    关于Chrome谷歌浏览器开发者工具网络Network中返回无数据的问题
    微博登录过程分析
    SQL SERVER大话存储结构(4)_复合索引与包含索引
    千万级别数据表,单列索引和多列索引性能对比
    Showplan 逻辑运算符和物理运算符参考
  • 原文地址:https://www.cnblogs.com/ronle/p/11867050.html
Copyright © 2011-2022 走看看