Ver código fonte

软件更新功能修改

laiguoran 6 anos atrás
pai
commit
c0defe0636

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
data/sc_software.json


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "startup",
-  "version": "0.1.15",
+  "version": "0.1.16",
   "author": "珠海纵横软件有限公司",
   "description": "纵横Z+ 造价工作平台",
   "license": null,

+ 5 - 2
src/main/main-process/exe-install.js

@@ -61,11 +61,14 @@ const exeinstall = function (win) {
               exeinfo.id = GetFileNameNoExt(exeinfo.exeName) + '-' + RndNum(10)
               db.read().get('sc_exeData').insert(exeinfo).write()
             }
-            // 查找是否存在旧版本的软件,升级后屏蔽并删除旧版本
+            // 查找是否存在旧版本的软件,升级后判断旧版本(相同文件夹升级则删除,不同文件夹则保留)
             let exedatalist = await db.read().get('sc_exeData').filter({ product_id: info.product_id, down_id: info.down_id }).value()
             for (let j in exedatalist) {
-              if (exedatalist[j].product_version !== info.version) {
+              if (exedatalist[j].product_version !== info.version && exedatalist[j].path === regeditMsg.path) {
                 await db.read().get('sc_exeData').updateById(exedatalist[j].id, { isshow: false }).write()
+              } else {
+                // 把旧版本的更新提示设为false
+                await db.read().get('sc_exeData').updateById(exedatalist[j].id, { show_tip: false }).write()
               }
             }
             await db.read().get('sc_exeData').removeWhere({ isshow: false }).write()

+ 11 - 1
src/main/main-process/updateInstall.js

@@ -28,7 +28,7 @@ const updateInstall = function (win) {
       try {
         // let flag = false
         // 每次自动获取更新软件内容先让数据库isshow都为false,然后再执行getExeDataList方法里把isshow包含的变true,
-        // 最后再检测把还是false的删除,完成已删除软件功能(手动添加的exe信息除外)
+        // 最后再检测把还是false的软件进行判断文件夹和软件是否还在,有则保留,否则删除,完成已删除软件功能(手动添加的exe信息除外)
         await productAndExeDataIsshow()
         let softwarelist = result.data.keys
         let promiseArr = []
@@ -122,6 +122,16 @@ const updateInstall = function (win) {
     // if (manualnum === 0 && !flag && allnum !== 0) {
     //   db.read().get('sc_productData').updateById('1', { isshow: false }).write()
     // }
+    // 对还是isshow:false的软件进行文件夹文件查询,如果还在则保留,不存在则删除
+    if (num !== 0) {
+      let deleteExeData = await db.read().get('sc_exeData').filter({ auto: true, isshow: false }).value()
+      for (let exe in deleteExeData) {
+        let exePath = path.join(exe.path, exe.exeName)
+        if (fse.pathExistsSync(exePath)) {
+          db.read().get('sc_exeData').updateById(exe.id, { isshow: true }).write()
+        }
+      }
+    }
     db.read().get('sc_exeData').removeWhere({ auto: true, isshow: false }).write()
     return num
   }

Diferenças do arquivo suprimidas por serem muito extensas
+ 816 - 6
src/renderer/assets/font-awesome/fontawesome-all.css


+ 16 - 2
src/renderer/assets/global.css

@@ -248,7 +248,7 @@ body{
 .el-progress-bar__inner,.el-progress-bar__outer {
   border-radius: .25rem !important;
 }
-.download-header {
+.download-header, .update-header {
   cursor: pointer;
   font-size: 12px !important;
 }
@@ -265,6 +265,13 @@ body{
   font-size: 12px;
   background: #ff9900;
 }
+.badge-red {
+  font-size: 12px;
+  background: #f00;
+}
+.badge {
+  color: #fff;
+}
 .software-list{
   position: absolute;
   top: 0;
@@ -500,7 +507,7 @@ body{
   cursor: pointer;
   font-size: 12px !important;
 }
-.downloadlist {
+.downloadlist, .updatelist {
   min-width: 500px!important;
   max-height: 450px!important;
   padding: 10px 15px!important;
@@ -582,4 +589,11 @@ body{
 
 .header i{
   cursor:pointer;
+}
+.details-title a{
+  color:#333!important;
+}
+.details-title a:hover{
+  background:#fff;
+  text-decoration: none;
 }

+ 11 - 3
src/renderer/components/StartUpPage.vue

@@ -15,11 +15,14 @@
         <div class="ml-auto p-2 pt-3 webkit-drag">
           <div class="d-flex flex-wrap">
             <div class="">
-              <usb-header ref="usb" v-on:softwareDownload="relationDownload"></usb-header>
+              <update-header ref="update" v-on:softwareDownload="relationDownload"></update-header>
             </div>
             <div class="">
               <download-header ref="download"></download-header>
             </div>
+            <div class="mr-5">
+              <usb-header ref="usb" v-on:softwareDownload="relationDownload"></usb-header>
+            </div>
             <div class="">
               <div class="mr-3"><i class="fas fa-minus" @click="minimizeWindow"></i></div>
             </div>
@@ -31,7 +34,7 @@
       </div>
     </el-header>
     <el-main>
-      <router-view v-on:softwareDownload="relationDownload"></router-view>
+      <router-view v-on:softwareDownload="relationDownload" v-on:softwareUpdate="relationUpdate"></router-view>
     </el-main>
     <software-update></software-update>
   </el-container>
@@ -43,6 +46,7 @@
   import SoftwareUpdate from './StartUpPage/SoftwareUpdate'
   import UsbHeader from './StartUpPage/UsbHeader'
   import DownloadHeader from './StartUpPage/DownloadHeader'
+  import UpdateHeader from './StartUpPage/UpdateHeader'
   const electron = require('electron').remote
   const BrowserWindow = electron.BrowserWindow
   const fs = require('fs-extra')
@@ -51,7 +55,7 @@
   export default {
     name: 'element-page',
     mixins: [mixin],
-    components: { SoftwareUpdate, UsbHeader, DownloadHeader },
+    components: { SoftwareUpdate, UsbHeader, DownloadHeader, UpdateHeader },
     data: () => ({
       version: pkg.version,
       iconShow: false
@@ -153,8 +157,12 @@
         }
       },
       relationDownload (downID) {
+        console.log(downID)
         this.$refs.download.adddownload(downID)
       },
+      relationUpdate () {
+        this.$refs.update.fetchData()
+      },
       checkOnline () {
         if (!navigator.onLine) {
           return false

+ 7 - 3
src/renderer/components/StartUpPage/DownloadHeader.vue

@@ -1,7 +1,9 @@
 <template>
   <el-dropdown class="download-header float-left mr-3" ref="downloadmenu" trigger="click" :hide-on-click=false>
     <span class="el-dropdown-link">
-      <i class="fas fa-download"></i><span class="badge badge-pill badge-info badge-orange ml-2" v-show="downloadNum !== 0">{{ downloadNum }}</span>
+      <span class="badge badge-orange">
+        <i class="fas fa-download"></i> {{ downloadNum }}
+      </span>
     </span>
     <!--<el-button @click="testbtn">test</el-button>-->
     <el-dropdown-menu slot="dropdown" class="downloadlist">
@@ -45,7 +47,7 @@
     mixins: [mixin],
     data () {
       return {
-        downloadNum: '',
+        downloadNum: 0,
         downloads: ''
       }
     },
@@ -232,7 +234,9 @@
         }
       },
       testbtn () {
-        console.log(this.$route.path)
+        // console.log('C:\\Program Files (x86)\\纵横软件\\纵横结算决算计量一体化软件(云版)')
+        // this.$electron.shell.openItem('C:\\Program Files (x86)\\纵横软件\\纵横结算决算计量一体化软件(云版)')
+        window.open('http://softmicroindex.smartcost.com.cn/')
       },
       installbtn (id, index) {
         // 安装exe监测,5s后开始监听安装状态

+ 1 - 0
src/renderer/components/StartUpPage/SoftwareStartup.vue

@@ -98,6 +98,7 @@
             if (self.$refs.startupDetail !== undefined) {
               self.$refs.startupDetail.fetchData()
             }
+            self.$emit('softwareUpdate')
           } else {
             self.$router.push({
               name: 'software-startup-detail',

+ 8 - 79
src/renderer/components/StartUpPage/SoftwareStartupDetail.vue

@@ -16,26 +16,14 @@
           <div class="details" v-for="exe in exelist" :key="exe.id">
             <div class="float-right">
               <button class="btn btn-white btn-sm" @click="openExebtn(exe.id)"><i class="fas fa-play mr-2"></i>启动</button>
-              <button v-if="exe.show_tip === true" class="btn btn-success btn-sm ml-2" @click="updateExebtn(exe.id)">新版本</button>
-              <el-dialog
-                      title="软件更新"
-                      :visible.sync="dialogVisible"
-                      width="55%">
-                <div class="modal-body" v-html="productVer"></div>
-                <span slot="footer" class="dialog-footer">
-                  <button class="btn btn-sm btn-primary btn-blue" @click="downloadbtn(did, version)">下载更新</button>&nbsp;&nbsp;
-                  <button class="btn btn-sm btn-secondary" @click="ignorebtn(prid, doid)">忽略该版本</button>
-                </span>
-              </el-dialog>
             </div>
             <div class="details-title">
-              <div class="w-25 d-inline-block" v-if="exe.versionName !== ''">{{ exe.versionName }}</div>
-              <div v-else>{{ exe.fileName }}</div>
+              <div class="w-25 d-inline-block" v-if="exe.versionName !== ''"><a @click="openFolder(exe.path)" :title="exe.path">{{ exe.versionName }}</a></div>
+              <div v-else><a @click="openFolder(exe.path)" :title="exe.path">{{ exe.fileName }}</a></div>
               <div class="d-inline-block" v-if="exe.keyNumber !== ''">锁号:{{ exe.keyNumber }}</div>
             </div>
             <div class="w-25 d-inline-block">{{ exe.fileVersion }}</div>
             <div class="inline-block">{{ exe.fileDescription }}</div>
-            <div class="software-stitle">{{ exe.path }}</div>
           </div>
         </el-tab-pane>
         <el-tab-pane v-if="products.id != 1" class="software-content" name="second" v-html="products.content">
@@ -50,7 +38,6 @@
   import mixin from '../mixin'
   const path = require('path')
   const fs = require('fs')
-  const fse = require('fs-extra')
   const ffi = require('ffi')
   export default {
     mixins: [mixin],
@@ -58,12 +45,7 @@
       return {
         activeName: 'first',
         products: '',
-        exelist: '',
-        dialogVisible: false,
-        productVer: '',
-        did: '',
-        version: '',
-        prid: ''
+        exelist: ''
       }
     },
     created () {
@@ -84,25 +66,8 @@
       fetchData () {
         let productid = this.$route.params.productid === undefined ? this.$db.read().get('sc_productData').last().value().id : this.$route.params.productid
         this.$db.read().set('sc_hadInstall.url', '/softwarestartup/' + productid).write()
-        let products = this.$db.read().get('sc_productData').getById(productid).value()
-        this.products = products
-        let exelist = this.$db.read().get('sc_exeData').filter({ pid: productid }).orderBy('addtime', 'desc').value()
-        let softwarejson = path.join('data/sc_software.json')
-        let scdownlist = fse.readJsonSync(softwarejson).sc_down
-        for (let i = 0; i < exelist.length; i++) {
-          let scdownInfo = scdownlist.find(function (item) {
-            return item.down_id === exelist[i].down_id
-          })
-          if (scdownInfo !== undefined && scdownInfo.version !== exelist[i].show_updateVersion) {
-            exelist[i].show_updateVersion = scdownInfo.version
-            exelist[i].show_tip = true
-            this.$db.read().get('sc_exeData').updateById(exelist[i].id, { show_updateVersion: scdownInfo.version, show_tip: true }).write()
-          } else if (scdownInfo !== undefined && scdownInfo.version === exelist[i].product_version) {
-            exelist[i].show_tip = false
-            this.$db.read().get('sc_exeData').updateById(exelist[i].id, { show_updateVersion: scdownInfo.version, show_tip: false }).write()
-          }
-        }
-        this.exelist = exelist
+        this.products = this.$db.read().get('sc_productData').getById(productid).value()
+        this.exelist = this.$db.read().get('sc_exeData').filter({ pid: productid }).orderBy('addtime', 'desc').value()
         if (productid === '1') {
           this.activeName = 'first'
         }
@@ -150,45 +115,6 @@
           })
         }
       },
-      updateExebtn (id) {
-        let info = this.$db.read().get('sc_exeData').getById(id).value()
-        let softwarejson = path.join('data/sc_software.json')
-        let scdownlist = fse.readJsonSync(softwarejson).sc_down
-        let scdowninfo = scdownlist.find(function (item) {
-          return item.down_id === info.down_id
-        })
-        let addhtml = '<p>当前版本:<b>' + info.product_version + '</b>&nbsp;&nbsp;|&nbsp;&nbsp;升级版本:<b>' + info.show_updateVersion + '</b></p>'
-        this.productVer = addhtml + scdowninfo.versionDesc
-        this.dialogVisible = true
-        this.doid = info.id
-        this.did = info.down_id
-        this.version = scdowninfo.version
-        this.prid = info.pid
-      },
-      downloadbtn (id, version) {
-        let downloaditem = this.$db.read().get('sc_download').find({ down_id: id, version: version, delete: false }).value()
-        if (!downloaditem) {
-          this.$parent.$emit('softwareDownload', id)
-        } else {
-          let softwarejson = path.join('data/sc_software.json')
-          let scdownlist = fse.readJsonSync(softwarejson).sc_down
-          let scdowninfo = scdownlist.find(function (item) {
-            return item.down_id === id
-          })
-          this.$message({
-            showClose: true,
-            message: scdowninfo.fulltitle + '已存在下载列中',
-            iconClass: '',
-            type: 'warning'
-          })
-        }
-        this.dialogVisible = false
-      },
-      ignorebtn (pid, id) {
-        this.$db.read().get('sc_exeData').updateById(id, { show_tip: false }).write()
-        this.exelist = this.$db.read().get('sc_exeData').filter({ pid: pid }).orderBy('addtime', 'desc').value()
-        this.dialogVisible = false
-      },
       checkOnline () {
         if (!navigator.onLine) {
           return false
@@ -207,6 +133,9 @@
         } catch (err) {
           console.error('ffi.Library', err)
         }
+      },
+      openFolder (path) {
+        this.$electron.shell.openItem(path)
       }
     }
   }

+ 120 - 0
src/renderer/components/StartUpPage/UpdateHeader.vue

@@ -0,0 +1,120 @@
+<template>
+  <el-dropdown ref="updatemenu" class="update-header float-left mr-3" trigger="click" :hide-on-click=false>
+    <span class="el-dropdown-link">
+      <span class="badge badge-red">
+        <i class="fas fa-arrow-up"></i> {{ updateNum }}</span>
+    </span>
+    <el-dropdown-menu slot="dropdown" class="updatelist">
+      <div class="downloaditem" v-for="item in updates" :key="item.id">
+        <div class="pb-2">
+          <div class="float-right"><button class="btn btn-success btn-sm ml-2" @click="downloadbtn(item.down_id, item.show_updateVersion)">更新</button></div>
+          <div>{{ item.simpleName }} {{ item.versionName }}</div>
+          <div class="text-secondary">当前版本:{{ item.product_version }}&nbsp;&nbsp;  |  &nbsp;&nbsp;升级版本:{{ item.show_updateVersion }}</div>
+        </div>
+      </div>
+    </el-dropdown-menu>
+  </el-dropdown>
+</template>
+
+<script>
+  import mixin from '../mixin'
+  const path = require('path')
+  const fse = require('fs-extra')
+  export default {
+    mixins: [mixin],
+    data: () => ({
+      updates: '',
+      updateNum: 0
+    }),
+    created () {
+      this.fetchData()
+    },
+    methods: {
+      fetchData () {
+        let exelist = this.$db.read().get('sc_exeData').orderBy('addtime', 'desc').value()
+        let softwarejson = path.join('data/sc_software.json')
+        let scdownlist = fse.readJsonSync(softwarejson).sc_down
+        let notUpdateDownIDList = [] // 获取不需要更新的down_id
+        let updateExeList = [] // 获取需要更新的down_id
+        for (let i = 0; i < exelist.length; i++) {
+          let scdownInfo = scdownlist.find(function (item) {
+            return item.down_id === exelist[i].down_id
+          })
+          // 先过滤大部分不用更新或已经检测的down_id
+          if (!this.inArray(exelist[i].down_id, notUpdateDownIDList)) {
+            if (scdownInfo !== undefined && scdownInfo.version === exelist[i].product_version) {
+              notUpdateDownIDList.push(exelist[i].down_id)
+            } else if (scdownInfo !== undefined && scdownInfo.version !== exelist[i].product_version && exelist[i].exeName !== 'BillsEditor.exe') {
+              exelist[i].show_updateVersion = scdownInfo.version
+              updateExeList.push(exelist[i])
+            }
+          }
+          // updateExeList 找出down_id相同的一个最高版本提示更新
+          let updateExeMsgList = []
+          for (let exe of updateExeList) {
+            if (!this.inArray(exe.down_id, notUpdateDownIDList) && exe.exeName !== 'BillsEditor.exe') {
+              let version = exe.product_version.split('.').join('')
+              let exeMsgIndex = updateExeMsgList.findIndex(function (item) {
+                return item.down_id === exe.down_id
+              })
+              if (!exeMsgIndex || exeMsgIndex === -1) {
+                let updateInfo = {
+                  down_id: exe.down_id,
+                  version: version,
+                  id: exe.id,
+                  updateVersion: exe.show_updateVersion
+                }
+                updateExeMsgList.push(updateInfo)
+              } else if (version > updateExeMsgList[exeMsgIndex].version) {
+                let updateInfo = {
+                  down_id: exe.down_id,
+                  version: version,
+                  id: exe.id,
+                  updateVersion: exe.show_updateVersion
+                }
+                updateExeMsgList.splice(exeMsgIndex, 1, updateInfo)
+              }
+            }
+          }
+          for (let exemsg of updateExeMsgList) {
+            this.$db.read().get('sc_exeData').updateById(exemsg.id, { show_updateVersion: exemsg.updateVersion, show_tip: true }).write()
+          }
+          // 再把所有notUpdateDownIDList 里down_id相同的软件进行更新提示消除
+          for (let notUpdateDownID of notUpdateDownIDList) {
+            this.$db.read().get('sc_exeData').updateWhere({ down_id: notUpdateDownID }, { show_tip: false }).write()
+          }
+        }
+        this.updateNum = this.$db.read().get('sc_exeData').filter({ show_tip: true }).size().value()
+        this.updates = this.$db.read().get('sc_exeData').filter({ show_tip: true }).value()
+      },
+      downloadbtn (id, version) {
+        let downloaditem = this.$db.read().get('sc_download').find({ down_id: id, version: version, delete: false }).value()
+        if (!downloaditem) {
+          this.$refs.updatemenu.hide()
+          console.log(id)
+          this.$emit('softwareDownload', id)
+        } else {
+          let softwarejson = path.join('data/sc_software.json')
+          let scdownlist = fse.readJsonSync(softwarejson).sc_down
+          let scdowninfo = scdownlist.find(function (item) {
+            return item.down_id === id
+          })
+          this.$message({
+            showClose: true,
+            message: scdowninfo.fulltitle + '已存在下载列中',
+            iconClass: '',
+            type: 'warning'
+          })
+        }
+      },
+      inArray (val, arr) {
+        for (let i in arr) {
+          if (arr[i] === val) {
+            return true
+          }
+        }
+        return false
+      }
+    }
+  }
+</script>