lilei 3 rokov pred
rodič
commit
ed816966df
2 zmenil súbory, kde vykonal 54 pridanie a 2 odobranie
  1. 7 0
      public/index.html
  2. 47 2
      src/views/user/Login.vue

+ 7 - 0
public/index.html

@@ -12,6 +12,13 @@
     <% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.css) { %>
     <link rel="stylesheet" href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" />
     <% } %>
+     <script>
+      var userAgent = navigator.userAgent.toLowerCase()
+      var isElectronApp = userAgent.indexOf(' electron/') > -1
+      if (isElectronApp){
+         var ipcRenderer = require('electron').ipcRenderer
+      }
+     </script>
      <script src="./menus.js"></script>
   </head>
   <body>

+ 47 - 2
src/views/user/Login.vue

@@ -112,6 +112,25 @@
       @success="stepCaptchaSuccess"
       @cancel="stepCaptchaCancel"
     ></two-step-captcha>
+    <!-- ElectronApp 更新 -->
+    <a-modal
+      title="正在更新新版本,请稍候..."
+      width="60%"
+      :visible="dialogVisible"
+      :closable="false"
+      :maskClosable="false"
+      centered
+      :footer="null"
+    >
+      <div style="width:100%;height:20vh;line-height:20vh;text-align:center">
+        <a-progress
+          status="success"
+          :strokeWidth="20"
+          :percent="percentage"
+          :width="strokeWidth"
+        ></a-progress>
+      </div>
+    </a-modal>
   </div>
 </template>
 
@@ -122,7 +141,6 @@ import { mapActions } from 'vuex'
 import { timeFix } from '@/utils/util'
 import { getSmsCaptcha, get2step } from '@/api/login'
 import { updateTheme } from '@/components/SettingDrawer/settingConfig'
-
 export default {
   components: {
     TwoStepCaptcha
@@ -146,7 +164,34 @@ export default {
       },
       rememberMe: true,
       username: '',
-      password: ''
+      password: '',
+      // 客户端升级弹框
+      dialogVisible: false,
+      percentage: 0,
+      strokeWidth: 200
+    }
+  },
+  mounted () {
+    const _this = this
+    if (isElectronApp) {
+      // 接收主进程版本更新消息
+      ipcRenderer.on('message', (event, arg) => {
+        console.log(arg)
+        if (arg.cmd == 'update-available') {
+          // 显示升级对话框
+          _this.dialogVisible = true
+        } else if (arg.cmd == 'download-progress') {
+          console.log(arg.message.percent)
+          const percent = Math.round(parseFloat(arg.message.percent))
+          _this.percentage = percent
+        } else if (arg.cmd == 'error') {
+          _this.dialogVisible = false
+          _this.$message.error('更新失败')
+        } else if (arg.cmd == 'update-downloaded') {
+          _this.dialogVisible = false
+        }
+      })
+      ipcRenderer.send('checkForUpdate')
     }
   },
   created () {