gaoshuaixing 3 lat temu
rodzic
commit
0748fa39b8

+ 0 - 1
app/public/css/chunk-4922ae20.42e97468.css

@@ -1 +0,0 @@
-#app-demo-window[data-v-667bcd63]{padding:0 10px;text-align:left;width:100%}#app-demo-window .one-block-1[data-v-667bcd63]{font-size:16px;padding-top:10px}#app-demo-window .one-block-2[data-v-667bcd63]{padding-top:10px}

+ 1 - 0
app/public/css/chunk-ae66c8d4.8aafba3e.css

@@ -0,0 +1 @@
+#app-demo-window[data-v-4c883c70]{padding:0 10px;text-align:left;width:100%}#app-demo-window .one-block-1[data-v-4c883c70]{font-size:16px;padding-top:10px}#app-demo-window .one-block-2[data-v-4c883c70]{padding-top:10px}

Plik diff jest za duży
+ 0 - 0
app/public/index.html


Plik diff jest za duży
+ 0 - 0
app/public/js/app.708bbbaf.js


Plik diff jest za duży
+ 0 - 0
app/public/js/app.708bbbaf.js.map


Plik diff jest za duży
+ 0 - 0
app/public/js/app.bef35947.js


Plik diff jest za duży
+ 0 - 0
app/public/js/app.bef35947.js.map


+ 0 - 2
app/public/js/chunk-4922ae20.1bf6678e.js

@@ -1,2 +0,0 @@
-(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4922ae20"],{"2e16":function(t,n,e){"use strict";e.r(n);var o=function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("div",{attrs:{id:"app-demo-window"}},[t._m(0),e("div",{staticClass:"one-block-2"},[e("a-space",[e("a-button",{on:{click:function(n){return t.checkForUpdater()}}},[t._v("检查更新")]),e("a-button",{on:{click:function(n){return t.download()}}},[t._v("下载并安装")])],1)],1)])},a=[function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("div",{staticClass:"one-block-1"},[e("span",[t._v(" 1. 自动更新 ")])])}],c={data:function(){return{status:0}},mounted:function(){this.init()},methods:{init:function(){var t=this;t.$ipc.on("app.updater",(function(n,e){e=JSON.parse(e),console.log("app updater:",e);var o=e.desc;t.status=e.status,t.$message.info(o)}))},checkForUpdater:function(){var t=this;t.$ipcCallMain("example.checkForUpdater").then((function(t){console.log(t)}))},download:function(){if(1===this.status){var t=this;t.$ipcCallMain("example.downloadApp").then((function(t){console.log(t)}))}else this.$message.info("没有可用版本")}}},i=c,s=(e("d1e9"),e("2877")),u=Object(s["a"])(i,o,a,!1,null,"667bcd63",null);n["default"]=u.exports},"55bb":function(t,n,e){},d1e9:function(t,n,e){"use strict";e("55bb")}}]);
-//# sourceMappingURL=chunk-4922ae20.1bf6678e.js.map

Plik diff jest za duży
+ 0 - 0
app/public/js/chunk-4922ae20.1bf6678e.js.map


+ 2 - 0
app/public/js/chunk-ae66c8d4.7e6bed84.js

@@ -0,0 +1,2 @@
+(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-ae66c8d4"],{"2e16":function(t,e,n){"use strict";n.r(e);var s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{attrs:{id:"app-demo-window"}},[t._m(0),n("div",{staticClass:"one-block-2"},[n("a-space",[n("a-button",{on:{click:function(e){return t.checkForUpdater()}}},[t._v("检查更新")]),n("a-button",{on:{click:function(e){return t.download()}}},[t._v("下载并安装")])],1)],1),t._m(1),n("div",{staticClass:"one-block-2"},[n("a-progress",{attrs:{percent:t.percentNumber,status:"active"}}),n("a-space",[t._v(" "+t._s(t.progress)+" ")])],1)])},c=[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"one-block-1"},[n("span",[t._v(" 1. 自动更新 ")])])},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"one-block-1"},[n("span",[t._v(" 2. 下载进度 ")])])}],a={data:function(){return{status:0,progress:"",percentNumber:0}},mounted:function(){this.init()},methods:{init:function(){var t=this;t.$ipc.on("app.updater",(function(e,n){n=JSON.parse(n),t.status=n.status,3==n.status?(t.progress=n.desc,t.percentNumber=n.percentNumber):t.$message.info(n.desc)}))},checkForUpdater:function(){var t=this;t.$ipcCallMain("example.checkForUpdater").then((function(t){console.log(t)}))},download:function(){if(1===this.status){var t=this;t.$ipcCallMain("example.downloadApp").then((function(t){console.log(t)}))}else this.$message.info("没有可用版本")}}},o=a,i=(n("e4d1"),n("2877")),r=Object(i["a"])(o,s,c,!1,null,"4c883c70",null);e["default"]=r.exports},a00b:function(t,e,n){},e4d1:function(t,e,n){"use strict";n("a00b")}}]);
+//# sourceMappingURL=chunk-ae66c8d4.7e6bed84.js.map

Plik diff jest za duży
+ 0 - 0
app/public/js/chunk-ae66c8d4.7e6bed84.js.map


Plik diff jest za duży
+ 0 - 0
app/view/index.ejs


+ 5 - 5
electron/config.js

@@ -52,15 +52,15 @@ const config = {
     workers: 1
     workers: 1
   },
   },
   autoUpdate: {
   autoUpdate: {
-    force: false, // 强制更新
-    autoDownload: false, // 是否自动下载
     windows: true, // windows可以开启;macOs 需要签名验证
     windows: true, // windows可以开启;macOs 需要签名验证
     macOS: false,
     macOS: false,
     linux: false,
     linux: false,
     options: {
     options: {
-      provider: 'generic', // or github, s3, bintray
-      url: '' // resource dir, end with '/'
-    }
+      provider: 'generic',
+      url: 'https://kaka996.coding.net/p/resource/d/tx-resource2/git/raw/master/ee' // resource dir
+    },
+    force: false, // 强制更新
+    autoDownload: false, // 是否自动下载
   },
   },
   awakeProtocol: {
   awakeProtocol: {
     protocol: 'electron-egg', // 自定义协议名(默认你的应用名称-英文)
     protocol: 'electron-egg', // 自定义协议名(默认你的应用名称-英文)

+ 38 - 6
electron/lib/autoUpdater.js

@@ -7,6 +7,7 @@ const {app} = require('electron');
 const eLogger = require('./eLogger').get();
 const eLogger = require('./eLogger').get();
 const helper = require('./helper');
 const helper = require('./helper');
 const constant = require('./constant');
 const constant = require('./constant');
+const path = require('path');
 
 
 /**
 /**
  * 安装模块
  * 安装模块
@@ -26,6 +27,9 @@ exports.setup = function () {
 
 
   // 是否自动下载
   // 是否自动下载
   autoUpdater.autoDownload = updateConfig.force ? true : false;
   autoUpdater.autoDownload = updateConfig.force ? true : false;
+  //if (process.env.EE_SERVER_ENV == 'local') {
+    autoUpdater.updateConfigPath = path.join(__dirname, '../../out/dev-app-update.yml')
+  //}
 
 
   try {
   try {
     autoUpdater.setFeedURL(updateConfig.options);
     autoUpdater.setFeedURL(updateConfig.options);
@@ -54,18 +58,24 @@ exports.setup = function () {
     sendStatusToWindow(info);
     sendStatusToWindow(info);
   })
   })
   autoUpdater.on('download-progress', (progressObj) => {
   autoUpdater.on('download-progress', (progressObj) => {
-    let text = "下载进度: " + progressObj.bytesPerSecond;
-    text = text + ' - 已下载 ' + progressObj.percent + '%';
-    text = text + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
+    let percentStr = String(progressObj.percent);
+    let endIndex = percentStr.indexOf('.') != -1 ? percentStr.indexOf('.') : percentStr.length;
+    let percentNumber = percentStr.substring(0, endIndex);
+    let totalSize = bytesChange(progressObj.total);
+    let transferredSize = bytesChange(progressObj.transferred);
+    let text = '已下载 ' + percentNumber + '%';
+    text = text + ' (' + transferredSize + "/" + totalSize + ')';
 
 
     let info = {
     let info = {
       status: constant.appUpdaterStatus.downloading,
       status: constant.appUpdaterStatus.downloading,
-      desc: text
+      desc: text,
+      percentNumber: percentNumber,
+      totalSize: totalSize,
+      transferredSize: transferredSize
     }
     }
     sendStatusToWindow(info);
     sendStatusToWindow(info);
   })
   })
   autoUpdater.on('update-downloaded', (info) => {
   autoUpdater.on('update-downloaded', (info) => {
-    console.log('downloaded info:', info)
     info.status = constant.appUpdaterStatus.downloaded;
     info.status = constant.appUpdaterStatus.downloaded;
     info.desc = '下载完成';
     info.desc = '下载完成';
     sendStatusToWindow(info);
     sendStatusToWindow(info);
@@ -73,7 +83,6 @@ exports.setup = function () {
     helper.appQuit();
     helper.appQuit();
     autoUpdater.quitAndInstall();
     autoUpdater.quitAndInstall();
   });
   });
-
 };
 };
 
 
 exports.checkUpdate = function () {
 exports.checkUpdate = function () {
@@ -90,4 +99,27 @@ function sendStatusToWindow(content = {}) {
   MAIN_WINDOW.webContents.send(constant.ipcChannels.appUpdater, textJson);
   MAIN_WINDOW.webContents.send(constant.ipcChannels.appUpdater, textJson);
 }
 }
 
 
+
+function bytesChange (limit) {
+  let size = "";
+  if(limit < 0.1 * 1024){                            
+    size = limit.toFixed(2) + "B"
+  }else if(limit < 0.1 * 1024 * 1024){            
+    size = (limit/1024).toFixed(2) + "KB"
+  }else if(limit < 0.1 * 1024 * 1024 * 1024){        
+    size = (limit/(1024 * 1024)).toFixed(2) + "MB"
+  }else{                                            
+    size = (limit/(1024 * 1024 * 1024)).toFixed(2) + "GB"
+  }
+
+  let sizeStr = size + "";                        
+  let index = sizeStr.indexOf(".");                    
+  let dou = sizeStr.substring(index + 1 , index + 3)            
+  if(dou == "00"){
+      return sizeStr.substring(0, index) + sizeStr.substring(index + 3, index + 5)
+  }
+
+  return size;
+}
+
 exports = module.exports;
 exports = module.exports;

+ 2 - 14
frontend/src/App.vue

@@ -12,20 +12,8 @@ export default {
     return {};
     return {};
   },
   },
   watch: {},
   watch: {},
-  mounted () {
-    // 初始化一个公共消息通信频道
-    this.initIpc();
-  },
-  methods: {
-    initIpc () {
-      const self = this;
-      // 公共频道
-      self.$ipc.on('public.message', (event, result) => {
-        // 使用ant-desing-vue, message组件
-        self.$message.info(result);
-      })
-    },
-  }
+  mounted () {},
+  methods: {}
 }
 }
 </script>
 </script>
 <style>
 <style>

+ 13 - 7
frontend/src/views/demo/updater/Index.vue

@@ -11,16 +11,17 @@
         <a-button @click="download()">下载并安装</a-button>
         <a-button @click="download()">下载并安装</a-button>
       </a-space>
       </a-space>
     </div>
     </div>
-    <!-- <div class="one-block-1">
+    <div class="one-block-1">
       <span>
       <span>
-        2. 新窗口中加载html内容
+        2. 下载进度
       </span>
       </span>
     </div>  
     </div>  
     <div class="one-block-2">
     <div class="one-block-2">
+      <a-progress :percent="percentNumber" status="active" />
       <a-space>
       <a-space>
-        <a-button @click="createWindow(1)">打开html页面</a-button>
+        {{ progress }}
       </a-space>
       </a-space>
-    </div> -->
+    </div>
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
@@ -29,6 +30,8 @@ export default {
   data() {
   data() {
     return {
     return {
       status: 0, // -1:异常,1:有可用更新,2:没有可用更新,3:下载中, 4:下载完成
       status: 0, // -1:异常,1:有可用更新,2:没有可用更新,3:下载中, 4:下载完成
+      progress: '',
+      percentNumber: 0
     };
     };
   },
   },
   mounted () {
   mounted () {
@@ -39,10 +42,13 @@ export default {
       const self = this;
       const self = this;
       self.$ipc.on('app.updater', (event, result) => {
       self.$ipc.on('app.updater', (event, result) => {
         result = JSON.parse(result);
         result = JSON.parse(result);
-        console.log('app updater:', result);
-        let text = result.desc;
         self.status = result.status;
         self.status = result.status;
-        self.$message.info(text);
+        if (result.status == 3) {
+          self.progress = result.desc;
+          self.percentNumber = result.percentNumber;
+        } else {
+          self.$message.info(result.desc);
+        }
       })
       })
     },
     },
     checkForUpdater () {
     checkForUpdater () {

+ 15 - 6
main.js

@@ -12,19 +12,21 @@ global.MAIN_WINDOW = null;
 global.APP_TRAY = null;
 global.APP_TRAY = null;
 global.CAN_QUIT = false;
 global.CAN_QUIT = false;
 
 
-// Initialize 
-setup()
-
 // argv
 // argv
 let ENV = 'prod'
 let ENV = 'prod'
 for (let i = 0; i < process.argv.length; i++) {
 for (let i = 0; i < process.argv.length; i++) {
   const tmpArgv = process.argv[i]
   const tmpArgv = process.argv[i]
   if (tmpArgv.indexOf('--env=') !== -1) {
   if (tmpArgv.indexOf('--env=') !== -1) {
-    ENV = tmpArgv.substr(6)
+    ENV = tmpArgv.substring(6)
   }
   }
 }
 }
-const eggConfig = electronConfig.get('egg', ENV)
-eggConfig.env = ENV
+process.env.EE_SERVER_ENV = ENV;
+
+// Initialize 
+setup()
+
+const eggConfig = electronConfig.get('egg', process.env.EE_SERVER_ENV)
+eggConfig.env = process.env.EE_SERVER_ENV
 
 
 // eLogger
 // eLogger
 const eLogger = require('./electron/lib/eLogger').get()
 const eLogger = require('./electron/lib/eLogger').get()
@@ -145,4 +147,11 @@ function loadMainUrl (url) {
   MAIN_WINDOW.loadURL(url)
   MAIN_WINDOW.loadURL(url)
 }
 }
 
 
+/**
+ * Catch exception
+ */
+process.on('uncaughtException', function(err) {
+  eLogger.error(err);
+});
+
 initialize()
 initialize()

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "electron-egg",
   "name": "electron-egg",
-  "version": "1.16.3",
+  "version": "1.16.2",
   "description": "A fast, desktop software development framework",
   "description": "A fast, desktop software development framework",
   "main": "main.js",
   "main": "main.js",
   "scripts": {
   "scripts": {

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików