哆啦好梦 пре 2 година
родитељ
комит
99ba0ec588

+ 1 - 1
README.md

@@ -21,7 +21,7 @@
 - 🍩 **为什么使用?** 桌面软件(办公方向、 个人工具),仍然是未来十几年PC端需求之一,提高工作效率
 - 🍉 **简单:** 只需懂 JavaScript
 - 🍑 **愿景:** 所有开发者都能学会桌面软件研发
-- 🍰 **gitee:** https://gitee.com/dromara/electron-egg **3600+**
+- 🍰 **gitee:** https://gitee.com/dromara/electron-egg **3700+**
 - 🍨 **github:** https://github.com/dromara/electron-egg **1000+**
 - 🏆 码云最有价值开源项目
     ![](https://wallace5303.gitee.io/ee/images/electron-egg/ee-zs.png)    

+ 1 - 1
README.zh-CN.md

@@ -21,7 +21,7 @@
 - 🍩 **为什么使用?** 桌面软件(办公方向、 个人工具),仍然是未来十几年PC端需求之一,提高工作效率
 - 🍉 **简单:** 只需懂 JavaScript
 - 🍑 **愿景:** 所有开发者都能学会桌面软件研发
-- 🍰 **gitee:** https://gitee.com/dromara/electron-egg **3600+**
+- 🍰 **gitee:** https://gitee.com/dromara/electron-egg **3700+**
 - 🍨 **github:** https://github.com/dromara/electron-egg **1000+**
 - 🏆 码云最有价值开源项目
     ![](https://wallace5303.gitee.io/ee/images/electron-egg/ee-zs.png)    

+ 5 - 2
electron/addon/autoUpdater/index.js

@@ -102,9 +102,12 @@ class AutoUpdaterAddon {
       info.status = status.downloaded;
       info.desc = '下载完成';
       this.sendStatusToWindow(info);
-      // quit and update
-      // app.appQuit();
       autoUpdater.quitAndInstall();
+      // const mainWindow = CoreWindow.getMainWindow();
+      // if (mainWindow) {
+      //   mainWindow.destroy()
+      // }
+      // electronApp.appQuit()
     });
   }
 

+ 9 - 0
electron/addon/javaServer/index.js

@@ -45,7 +45,16 @@ class JavaServerAddon {
    * @since 1.0.0
    */
   async check () {
+    Log.info("进入-----检查服务是否启动------"+this.javaServer);
+    if(this.javaServer == undefined){
+      Log.info("[addon:javaServer:check] status-----------"+false);
+      return false;
+    }
     
+    const flag = await this.javaServer.isRun(Conf.getValue('addons.javaServer'));
+    Log.info("[addon:javaServer:check] status-----------"+flag);
+
+    return flag;    
   }
 
   /**

+ 26 - 0
electron/addon/javaServer/server.js

@@ -95,6 +95,32 @@ class JavaServer {
       // todo linux
     }
   }
+
+  /**
+   * 服务是否运行中
+   */
+  async isRun(cfg){
+    const jarName = cfg.name;
+    if (is.windows()) {
+      const resultList = ps.lookup({
+        command: "java",
+        where: 'caption="javaw.exe"',
+        arguments: jarName,
+      });
+  
+      Log.info("[addon:javaServer] resultList:", resultList);
+      return resultList.length>0;
+    } else if (is.macOS()) {
+      const cmd = `ps -ef | grep java | grep ${jarName} | grep -v grep | awk '{print $2}' `;
+      Log.info("[addon:javaServer:isRun] cmdStr:", cmd);
+      const result = execSync(cmd);
+      Log.info('[addon:javaServer:isRun] result:', result.toString());
+      //不等于空说明正在运行
+      return result.toString()!==""
+    } else {
+      // todo linux
+    }
+  }  
 }
 
 module.exports = JavaServer;

+ 1 - 7
electron/addon/tray/index.js

@@ -1,4 +1,4 @@
-const { Tray, Menu, shell } = require('electron');
+const { Tray, Menu } = require('electron');
 const path = require('path');
 const Ps = require('ee-core/ps');
 const Log = require('ee-core/log');
@@ -62,12 +62,6 @@ class TrayAddon {
     this.tray.setToolTip(cfg.title);
     const contextMenu = Menu.buildFromTemplate(trayMenuTemplate);
     this.tray.setContextMenu(contextMenu);
-
-    // 使用默认浏览器打开链接
-    mainWindow.webContents.setWindowOpenHandler(({ url }) => {
-      shell.openExternal(url);
-      return { action: 'deny' }
-    })    
   }
 }
 

+ 76 - 0
electron/config/bin.js

@@ -0,0 +1,76 @@
+/**
+ * ee-bin 配置
+ * 仅适用于开发环境
+ */
+module.exports = {
+  /**
+   * development serve ("frontend" "electron" )
+   * ee-bin dev
+   */
+  dev: {
+    frontend: {
+      directory: './frontend',
+      cmd: 'npm',
+      args: ['run', 'dev'],
+      protocol: 'http://',
+      hostname: 'localhost',
+      port: 8080,
+      indexPath: 'index.html'
+    },
+    electron: {
+      directory: './',
+      cmd: 'electron',
+      args: ['.', '--env=local'],
+    }
+  },
+
+  /**
+   * 前端构建
+   * ee-bin build
+   */
+  build: {
+    directory: './frontend',
+    cmd: 'npm',
+    args: ['run', 'build'],
+  },
+
+  /**
+   * 移动资源
+   * ee-bin rd
+   */
+  rd: {
+    dist: './frontend/dist',
+    target: './public/dist'
+  },
+
+  /**
+   * 预发布模式(prod)
+   * ee-bin start
+   */
+  start: {
+    directory: './',
+    cmd: 'electron',
+    args: ['.', '--env=prod']
+  },
+
+  /**
+   * 加密
+   */  
+  encrypt: {
+    type: 'confusion',
+    files: [
+      'electron/**/*.(js|json)',
+      '!electron/config/encrypt.js',
+      '!electron/config/nodemon.json',
+      '!electron/config/builder.json',
+      '!electron/config/bin.json',
+    ],
+    fileExt: ['.js'],
+    confusionOptions: {
+      compact: true,      
+      stringArray: true,
+      stringArrayEncoding: ['none'],
+      deadCodeInjection: false,
+    }
+  }
+};

+ 2 - 23
electron/config/config.default.js

@@ -10,27 +10,6 @@ module.exports = (appInfo) => {
   const config = {};
 
   /**
-   * 应用模式配置
-   */
-  config.developmentMode = {
-    default: 'vue',
-    mode: {
-      vue: {
-        hostname: 'localhost',
-        port: 8080
-      },
-      react: {
-        hostname: 'localhost',
-        port: 3000
-      },
-      html: {
-        hostname: 'localhost',
-        indexPage: 'index.html'
-      },
-    }
-  };
-
-  /**
    * 开发者工具
    */
   config.openDevTools = false;
@@ -38,7 +17,7 @@ module.exports = (appInfo) => {
   /**
    * 应用程序顶部菜单
    */
-  config.openAppMenu = 'dev-show';
+  config.openAppMenu = true;
 
   /**
    * 主窗口
@@ -50,7 +29,7 @@ module.exports = (appInfo) => {
     minWidth: 800,
     minHeight: 650,
     webPreferences: {
-      //webSecurity: false, // 跨域问题 -> 打开注释
+      webSecurity: false,
       contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
       nodeIntegration: true,
       //preload: path.join(appInfo.baseDir, 'preload', 'bridge.js'),

+ 3 - 1
electron/config/config.local.js

@@ -9,7 +9,9 @@ module.exports = (appInfo) => {
   /**
    * 开发者工具
    */
-  config.openDevTools = true;
+  config.openDevTools = {
+    mode: 'undocked'
+  };
 
   /**
    * 应用程序顶部菜单

+ 0 - 20
electron/config/encrypt.js

@@ -1,20 +0,0 @@
-/**
- * 加密配置
- * @param type - confusion | bytecode | strict
- */
-module.exports = {
-  type: 'confusion',
-  files: [
-    'electron/**/*.(js|json)',
-    '!electron/config/encrypt.js',
-    '!electron/config/nodemon.json',
-    '!electron/config/builder.json',
-  ],
-  fileExt: ['.js'],
-  confusionOptions: {
-    compact: true,      
-    stringArray: true,
-    stringArrayEncoding: ['none'],
-    deadCodeInjection: false,
-  }
-};

+ 1 - 0
electron/index.js

@@ -32,6 +32,7 @@ class Index extends Application {
       const win = this.electron.mainWindow;
       win.once('ready-to-show', () => {
         win.show();
+        win.focus();
       })
     }
   }

+ 15 - 12
package.json

@@ -1,13 +1,21 @@
 {
   "name": "ee",
-  "version": "3.6.0",
+  "version": "3.7.0",
   "description": "A fast, desktop software development framework",
   "main": "main.js",
   "scripts": {
-    "start": "electron . ",
-    "dev": "electron . --env=local",
+    "dev": "ee-bin dev",
+    "dev-frontend": "ee-bin dev --serve=frontend",
+    "dev-electron": "ee-bin dev --serve=electron",
+    "build-frontend": "ee-bin build",
+    "start": "ee-bin start",
+    "rd": "ee-bin rd",
+    "encrypt": "ee-bin encrypt",
+    "clean": "ee-bin clean",
+    "icon": "ee-bin icon",
     "reload": "nodemon --config ./electron/config/nodemon.json",
-    "test": "set DEBUG=* && electron . --env=local",
+    "rebuild": "electron-rebuild",
+    "re-sqlite": "electron-rebuild -f -w better-sqlite3",
     "build-w": "electron-builder --config=./electron/config/builder.json -w=nsis --x64",
     "build-w-32": "electron-builder --config=./electron/config/builder.json -w=nsis --ia32",
     "build-w-64": "electron-builder --config=./electron/config/builder.json -w=nsis --x64",
@@ -25,12 +33,7 @@
     "build-l-armv7l": "electron-builder --config=./electron/config/builder.json -l=deb --armv7l",
     "build-lr-64": "electron-builder --config=./electron/config/builder.json -l=rpm --x64",
     "build-lp-64": "electron-builder --config=./electron/config/builder.json -l=pacman --x64",
-    "rd": "ee-bin rd",
-    "encrypt": "ee-bin encrypt",
-    "clean": "ee-bin clean",
-    "icon": "ee-bin icon",
-    "rebuild": "electron-rebuild",
-    "re-sqlite": "electron-rebuild -f -w better-sqlite3"
+    "test": "set DEBUG=* && electron . --env=local"
   },
   "repository": "https://github.com/dromara/electron-egg.git",
   "keywords": [
@@ -43,7 +46,7 @@
   "devDependencies": {
     "@electron/rebuild": "^3.2.13",
     "debug": "^4.3.3",
-    "ee-bin": "^1.1.0",
+    "ee-bin": "^1.2.0",
     "electron": "^21.4.4",
     "electron-builder": "^23.6.0",
     "eslint": "^5.13.0",
@@ -52,7 +55,7 @@
   },
   "dependencies": {
     "dayjs": "^1.10.7",
-    "ee-core": "^2.4.0",
+    "ee-core": "^2.5.0",
     "electron-updater": "^5.3.0",
     "lodash": "^4.17.21"
   }