electron-egg electron-egg
首页
  • v4.x
  • v3.x
  • v2.x
插件
  • v4.x
  • v3.x
demo
支持
知识点
案例
交流
  • GitHub (opens new window)
  • Gitee (opens new window)
首页
  • v4.x
  • v3.x
  • v2.x
插件
  • v4.x
  • v3.x
demo
支持
知识点
案例
交流
  • GitHub (opens new window)
  • Gitee (opens new window)
❤️成为赞助商
  • 快速入门

    • 介绍
    • EE框架是什么?
    • 安装
    • 第三方使用
    • 快速开始
    • 配置

      • 基础
      • 开发
        • 加密
        • 打包
      • 命令
    • 基础功能

    • 生成软件

    • 升级

    • 跨语言支持

    • 更新记录
    • 常见问题
    • v3
    • 快速入门
    • 配置
    哆啦好梦
    2024-02-01
    目录

    开发

    # bin.js

    ee-bin: v1.2.0

    ee-core: v2.5.0

    开发环境使用的各种命令及工具配置。

    # 文件位置

    ./electron/config/bin.js
    

    源码:bin.js (opens new window)

    # 配置说明

    /**
     * ee-bin 配置
     * 仅适用于开发环境
     */
    module.exports = {
      /**
       * 命令:ee-bin dev
       * 
       * 开发模式服务配置
       */
      dev: {
        // frontend:前端服务
        // 说明:该配置的意思是,进入 frontend 目录,执行 npm run dev
        // 运行后的服务为 http://localhost:8080 
        // 如果 protocol 属性为 'file://' 那么不会执行命令,项目直接加载 indexPath 对应的文件。
        frontend: {
          directory: './frontend', // frontend 目录
          cmd: 'npm',              // 命令
          args: ['run', 'dev'],    // 参数
          protocol: 'http://',     // 协议:'http://' 'file://'
          hostname: 'localhost',   // hostname
          port: 8080,              // port
          indexPath: 'index.html'  // 'file://'协议时有效,入口文件
          force: false,            // 强制加载前端服务
          sync: false,            // (非常住进程才能使用) 是否同步执行命令
        },
        // electron:主进程服务
        // 说明:该配置的意思是,在根目录,执行 electron . --env=local
        electron: {
          directory: './',
          cmd: 'electron',
          args: ['.', '--env=local'], // --env: local|prod; '--color=always' 控制台颜色
          loadingPage: '/public/html/loading.html', // ee-bin@v1.4.0 如果前端启动时间过长,可先加载一个loading页
          sync: false,            // (非常住进程才能使用) 是否同步执行命令
        }
      },
    
      /**
       * 构建
       * 
       * ee-bin@v1.4.0
       * ee-core@v2.7.0
       * 
       * 命令:ee-bin build
       * 说明:用来构建前端、go、或者自定义命令
       * 举例1:ee-bin build --cmds=frontend (构建 前端 dist资源)
       * 举例2:ee-bin build --cmds=go_w (构建 go windows平台程序)
       * 举例3:ee-bin build --cmds=go_m (构建 go macos平台程序)
       * 举例4:ee-bin build --cmds=go_l (构建 go linux平台程序)
       */
      build: {
        // 前端
        frontend: {
          directory: './frontend',
          cmd: 'npm',
          args: ['run', 'build'],
        },
        //(可选)go
        go_w: {
          directory: './go',
          cmd: 'go',
          args: ['build', '-o=../build/extraResources/goapp.exe'],
        },
        go_m: {
          directory: './go',
          cmd: 'go',
          args: ['build', '-o=../build/extraResources/goapp'],
        },
        go_l: {
          directory: './go',
          cmd: 'go',
          args: ['build', '-o=../build/extraResources/goapp'],
        }
      },
    
      /**
       * 前端构建
       * 
       * ee-bin < v1.4.0
       * ee-core < v2.7.0
       * 
       * 命令:ee-bin build
       * 说明:该配置的意思是,进入 frontend 目录,执行 npm run build
       */
      build: {
        directory: './frontend',
        cmd: 'npm',
        args: ['run', 'build'],
      },
    
      /**
       * 移动资源
       * 
       * ee-bin@v1.4.0
       * ee-core@v2.7.0
       * 
       * 命令:ee-bin move
       * 说明:移动前端、go、配置等静态资源到指定目录,供生产环境使用。支持文件、目录。
       * 
       * 举例1:ee-bin move --flag=frontend_dist (移动 前端 dist资源)
       * 举例2:ee-bin move --flag=go_static,go_config,go_package,go_images (移动 go 资源)
       */
      move: {
        frontend_dist: {
          dist: './frontend/dist',
          target: './public/dist'
        },
        go_static: {
          dist: './frontend/dist',
          target: './go/public/dist'
        },
        go_config: {
          dist: './go/config',
          target: './go/public/config'
        },
        go_package: {
          dist: './package.json',
          target: './go/public/package.json'
        },
        go_images: {
          dist: './public/images',
          target: './go/public/images'
        }
      },
    
      /**
       * 移动资源
       * 
       * ee-bin < v1.4.0
       * ee-core < v2.7.0
       * 
       * 命令:ee-bin rd
       * 说明:将 dist 内容移动到 target,仅支持目录,推荐使用move替代
       */
      rd: {
        dist: './frontend/dist',
        target: './public/dist'
      },
    
      /**
       * 预发布模式(prod)
       * 命令:ee-bin start
       * 说明:该配置的意思是,在根目录,执行 electron . --env=prod
       */
      start: {
        directory: './',
        cmd: 'electron',
        args: ['.', '--env=prod']
      },
    
      /**
       * 加密
       * 命令:ee-bin encrypt
       * 说明:多种加密功能,保护您的源码安全。
       */  
      encrypt: {
        // confusion - 压缩混淆加密
        // bytecode - 字节码加密
        // strict - 先混淆加密,然后字节码加密 
        type: 'confusion',
        // 文件匹配
        // ! 符号开头的意思是过滤
        files: [
          'electron/**/*.(js|json)',
          '!electron/config/encrypt.js',
          '!electron/config/nodemon.json',
          '!electron/config/builder.json',
          '!electron/config/bin.json',
        ],
        // 需要加密的文件后缀,暂时只支持js
        fileExt: ['.js'],
        // 混淆加密配置
        confusionOptions: {
          // 压缩成一行
          compact: true, 
          // 删除字符串文字并将其放置在一个特殊数组中     
          stringArray: true,
          // 对stringArray的所有字符串文字进行编码,值:'none' | 'base64' | 'rc4'
          stringArrayEncoding: ['none'],
          // 注入死代码,注:影响性能
          deadCodeInjection: false,
        }
      },
    
      /**
       * 执行自定义命令
       * ee-bin exec
       */
      exec: {
        node_v: {
          directory: './',
          cmd: 'node',
          args: ['-v'],
          sync: false,            // (非常住进程才能使用) 是否同步执行命令
        },
        npm_v: {
          directory: './',
          cmd: 'npm',
          args: ['-v'],
          sync: false,            // (非常住进程才能使用) 是否同步执行命令
        },
        python: {
          directory: './python',
          cmd: 'python',
          args: ['./main.py', '--port=7074'],
          stdio: "inherit", // ignore
        },
      },  
    };
    
    上次更新: 2025/06/06, 07:21:49
    基础
    加密

    ← 基础 加密→

    Theme by Vdoing | Copyright © 2023-2025 哆啦好梦 | 京ICP备15041380号-2
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式
    ×