소스 검색

第2版内容,(未解决打包问题版本)

laiguoran 6 년 전
부모
커밋
2d6474d491

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
data/sc_software.json


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "startup",
-  "version": "0.1.1",
+  "version": "0.1.2",
   "author": "珠海纵横软件有限公司",
   "description": "启动器",
   "license": null,

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 0
src/database/index.js


+ 16 - 1
src/main/index.js

@@ -52,15 +52,30 @@ function initialize () {
         backgroundThrottling: false
       }
     }
-
     mainWindow = new BrowserWindow(windowOptions)
     mainWindow.loadURL(winURL)
+    // mainWindow.webContents.openDevTools()
 
     mainWindow.on('closed', () => {
       mainWindow = null
     })
   }
 
+  let shouldQuit = app.makeSingleInstance(function (commandLine, workingDirectory) {
+    // 当另一个实例运行的时候,这里将会被调用,我们需要激活应用的窗口
+    if (mainWindow) {
+      if (mainWindow.isMinimized()) mainWindow.restore()
+      mainWindow.focus()
+    }
+    return true
+  })
+
+  // 这个实例是多余的实例,需要退出
+  if (shouldQuit) {
+    app.quit()
+    return
+  }
+
   app.on('ready', function () {
     createWindow()
     loadJS(mainWindow)

+ 2 - 0
src/main/main-process/file-select.js

@@ -83,9 +83,11 @@ async function checkExeName (Directory, files) {
         fileVersion: files[i].FileVersion,
         productName: files[i].ProductName,
         productVersion: files[i].ProductVersion,
+        fileDescription: files[i].FileDescription,
         exeName: files[i].exeName,
         pid: '1',
         keyNumber: '',
+        keytype: '',
         addtime: Date.parse(new Date()) / 1000,
         isshow: true,
         auto: false

+ 129 - 80
src/main/main-process/updateInstall.js

@@ -19,6 +19,8 @@ const regeditPath32 = 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Unins
 const regeditPath = isOSWin64() ? regeditPath64 : regeditPath32
 const regedit = require('regedit')
 let globalNUM = 0
+let globalSoftware = []
+let globalExe = []
 
 const updateInstall = function (win) {
   ipcMain.on('updateInstall', function () {
@@ -32,7 +34,14 @@ const updateInstall = function (win) {
         let promiseArr = []
         for (let i in softwarelist) {
           if (softwarelist[i].indexOf('SmartCost_') !== -1) {
-            promiseArr.push(getExeDataList(softwarelist[i]))
+            await getExeDataList(softwarelist[i])
+          }
+        }
+        await sleep(3000)
+        if (globalSoftware !== []) {
+          for (let i in globalSoftware) {
+            globalSoftware[i].exeName = globalExe[i]
+            promiseArr.push(insertData(globalSoftware[i]))
           }
         }
         await Promise.all(promiseArr)
@@ -44,13 +53,20 @@ const updateInstall = function (win) {
             await db.read().set('sc_hadInstall.url', '/softwarestartup/' + gourl).write()
             if (promiseArr !== undefined && promiseArr.length !== 0) {
               win.webContents.send('successUpdate', { id: gourl, num: globalNUM, delnum: delnum })
+              console.log(globalSoftware)
               globalNUM = 0
+              globalSoftware = []
+              globalExe = []
             } else {
               win.webContents.send('failedUpdate', { id: '1' })
             }
           })
-          .catch(function () {
+          .catch(function (err) {
             win.webContents.send('failedUpdate', { id: '1' })
+            console.log(err)
+            globalNUM = 0
+            globalSoftware = []
+            globalExe = []
           })
       } catch (err) {
         console.log(err)
@@ -94,6 +110,24 @@ const updateInstall = function (win) {
     setTimeout(resolve, timeout)
   })
 
+  // 取文件名不带后缀
+  function GetFileNameNoExt (filepath) {
+    if (filepath !== '') {
+      let names = filepath.split('\\')
+      let pos = names[names.length - 1].lastIndexOf('.')
+      return names[names.length - 1].substring(0, pos)
+    }
+  }
+
+  // 产生随机数函数
+  function RndNum (n) {
+    let rnd = ''
+    for (let i = 0; i < n; i++) {
+      rnd += Math.floor(Math.random() * 10)
+    }
+    return rnd
+  }
+
   /**
    * 判断文件名是否包含纵横软件exe的部分名称
    * @param item
@@ -113,90 +147,105 @@ const updateInstall = function (win) {
   }
 
   /**
-   * node 循环和异步解决方案
-   * @param Info
+   * 数据入库
+   *
    */
-  function getExeDataList (Info) {
+  function insertData (exeData) {
     return new Promise(resolve => {
-      // setTimeout(function () {
-      regedit.list(regeditPath + '\\' + Info).on('data', async function (result) {
-        let values = result.data.values
-        let simpleVersion = values['DisplayVersion'] === undefined || values['DisplayVersion'] === null ? '' : values['DisplayVersion'].value.split('_')
-        let exeData = {
-          path: values['Inno Setup: App Path'].value,
-          name: values['DisplayName'].value,
-          regeditName: Info,
-          fileName: values['Inno Setup: Icon Group'].value,
-          simpleName: simpleVersion === '' ? '' : simpleVersion[0],
-          versionName: simpleVersion === '' ? '' : simpleVersion[1]
-        }
-        let dirname = await fs.readdirSync(exeData.path)
-        dirname.forEach(async function (item, index) {
-          if (path.extname(item) === '.exe' && existSoftwareName(item)) {
-            let pathstr = path.join('data/fileInfo.dll')
-            let libm = ffi.Library(pathstr, {
-              'GetFileInfo': ['string', ['string']]
-            })
-            let fileinfo = JSON.parse(await libm.GetFileInfo(path.join(exeData.path, item)))
-            exeData.fileVersion = fileinfo.FileVersion
-            exeData.productName = fileinfo.ProductName
-            exeData.productVersion = fileinfo.ProductVersion
-            exeData.exeName = item
-            let dbExeData = await db.read().get('sc_exeData').find({ exeName: exeData.exeName, path: exeData.path, fileVersion: exeData.fileVersion }).value()
-            if (dbExeData === undefined || dbExeData === null) {
-              // 先判断是否存在该产品数据库(同时关联到sc_sofeware.json文件数据),再加入安装包数据库
-              if (exeData.simpleName !== '') {
-                let softwarejson = path.join('data/sc_software.json')
-                let productInfo = await db.read().get('sc_productData').find({ title: exeData.simpleName }).value()
-                if (productInfo === undefined || productInfo === null) {
-                  let productlist = await fse.readJsonSync(softwarejson).sc_product
-                  for (let i in productlist) {
-                    if (productlist[i].title === exeData.simpleName) {
-                      let productInfo2 = {
-                        readid: productlist[i].product_id,
-                        title: productlist[i].title,
-                        productName: productlist[i].productName,
-                        src: productlist[i].src,
-                        addtime: Date.parse(new Date()) / 1000,
-                        isshow: true
-                      }
-                      let insertproudct = await db.read().get('sc_productData').insert(productInfo2).write()
-                      exeData.pid = insertproudct.id
-                      productInfo = insertproudct
-                      break
-                    }
-                  }
-                } else {
-                  exeData.pid = productInfo.id
-                  await db.read().get('sc_productData').updateById(productInfo.id, { isshow: true }).write()
-                }
-                // 获取json文件中的锁号,更新到exe当中
-                let downlist = await fse.readJsonSync(softwarejson).sc_down
-                for (let j in downlist) {
-                  if (productInfo.readid === downlist[j].product_id && exeData.versionName === downlist[j].title) {
-                    exeData.keyNumber = downlist[j].key_number
-                    break
-                  }
+      let pathstr = path.join('data/fileInfo.dll')
+      let libm = ffi.Library(pathstr, {
+        'GetFileInfo': ['string', ['string']]
+      })
+      let fileinfo = JSON.parse(libm.GetFileInfo(path.join(exeData.path, exeData.exeName)))
+      exeData.fileVersion = fileinfo.FileVersion
+      exeData.productName = fileinfo.ProductName
+      exeData.productVersion = fileinfo.ProductVersion
+      exeData.fileDescription = fileinfo.FileDescription
+      let dbExeData = db.read().get('sc_exeData').find({ exeName: exeData.exeName, path: exeData.path, fileVersion: exeData.fileVersion }).value()
+      if (dbExeData === undefined || dbExeData === null) {
+        // 先判断是否存在该产品数据库(同时关联到sc_sofeware.json文件数据),再加入安装包数据库
+        if (exeData.simpleName !== '') {
+          let softwarejson = path.join('data/sc_software.json')
+          let productInfo = db.read().get('sc_productData').find({ title: exeData.simpleName }).value()
+          if (productInfo === undefined || productInfo === null) {
+            let productlist = fse.readJsonSync(softwarejson).sc_product
+            for (let i in productlist) {
+              if (productlist[i].title === exeData.simpleName) {
+                let productInfo2 = {
+                  readid: productlist[i].product_id,
+                  title: productlist[i].title,
+                  productName: productlist[i].productName,
+                  src: productlist[i].src,
+                  content: productlist[i].content,
+                  addtime: Date.parse(new Date()) / 1000,
+                  isshow: true
                 }
-              } else {
-                exeData.pid = '1'
-                exeData.keyNumber = ''
-                await db.read().get('sc_productData').updateById('1', { isshow: true }).write()
+                let insertproudct = db.read().get('sc_productData').insert(productInfo2).write()
+                exeData.pid = insertproudct.id
+                productInfo = insertproudct
+                break
               }
-              exeData.addtime = Date.parse(new Date()) / 1000
-              exeData.isshow = true
-              exeData.auto = true
-              ++globalNUM
-              await db.read().get('sc_exeData').insert(exeData).write()
-            } else {
-              await db.read().get('sc_productData').updateById(dbExeData.pid, { isshow: true }).write()
-              await db.read().get('sc_exeData').updateById(dbExeData.id, { isshow: true }).write()
             }
+          } else {
+            exeData.pid = productInfo.id
+            db.read().get('sc_productData').updateById(productInfo.id, { isshow: true }).write()
           }
-        })
-        resolve()
-      })
-      // }, 1000)
+          // 获取json文件中的锁号,更新到exe当中
+          let downlist = fse.readJsonSync(softwarejson).sc_down
+          for (let j in downlist) {
+            if (productInfo.readid === downlist[j].product_id && exeData.versionName === downlist[j].title) {
+              exeData.keyNumber = downlist[j].key_number
+              exeData.keytype = downlist[j].keytype
+              break
+            }
+          }
+        } else {
+          exeData.pid = '1'
+          exeData.keyNumber = ''
+          exeData.keytype = ''
+          db.read().get('sc_productData').updateById('1', { isshow: true }).write()
+        }
+        exeData.addtime = Date.parse(new Date()) / 1000
+        exeData.isshow = true
+        exeData.auto = true
+        exeData.id = GetFileNameNoExt(exeData.exeName) + '-' + RndNum(10)
+        ++globalNUM
+        db.read().get('sc_exeData').insert(exeData).write()
+      } else {
+        db.read().get('sc_productData').updateById(dbExeData.pid, { isshow: true }).write()
+        db.read().get('sc_exeData').updateById(dbExeData.id, { isshow: true }).write()
+      }
+      resolve(exeData)
+    })
+  }
+
+  /**
+   * node 循环和异步解决方案
+   * @param Info
+   */
+  function getExeDataList (Info) {
+    // setTimeout(function () {
+    regedit.list(regeditPath + '\\' + Info).on('data', async function (result) {
+      let values = result.data.values
+      let simpleVersion = values['DisplayVersion'] === undefined || values['DisplayVersion'] === null ? '' : values['DisplayVersion'].value.split('_')
+      let regeditData = {
+        path: values['Inno Setup: App Path'].value,
+        name: values['DisplayName'].value,
+        regeditName: Info,
+        fileName: values['Inno Setup: Icon Group'].value,
+        simpleName: simpleVersion === '' ? '' : simpleVersion[0],
+        versionName: simpleVersion === '' ? '' : simpleVersion[1]
+      }
+      let dirname = await fs.readdirSync(regeditData.path)
+      for (let i in dirname) {
+        if (path.extname(dirname[i]) === '.exe' && existSoftwareName(dirname[i])) {
+          let exeData = regeditData
+          // exeData.exeName = diraname[i]
+          // 这里必须分离2个数组记录值并在外面合并,push才不会出错,否则会重复exeName名,未知bug,坑
+          globalSoftware.push(exeData)
+          globalExe.push(dirname[i])
+        }
+      }
     })
   }
 }

+ 6 - 6
src/main/main-process/usb-ffi.js

@@ -45,13 +45,13 @@ async function testUsb (webContents) {
       //   let productNum = productlist[i].split(':')[0]
       //   let productVerList = productlist[i].split(':')[1].split(';')
       // }
+      webContents.send('usbIn', { lockmsg: alllist })
+      const notification = new Notification({
+        title: '软件锁',
+        body: '启动器检测到软件锁'
+      })
+      notification.show()
     }
-    webContents.send('usbIn')
-    const notification = new Notification({
-      title: '软件锁',
-      body: '启动器检测到软件锁'
-    })
-    notification.show()
   } catch (err) {
     console.error(err)
   }

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

@@ -3,7 +3,7 @@
     <el-header class="media p-3 header border-bottom shadow-sm">
       <div class="media-body">
         <div class="float-right webkit-drag">
-          <usb-header></usb-header>
+          <usb-header ref="usb" v-on:softwareDownload="relationDownload"></usb-header>
           <download-header ref="download"></download-header>
           <div class="float-left mr-3"><i class="fas fa-minus" @click="minimizeWindow"></i></div>
           <div class="float-right"><i class="fas fa-times" @click="closeWindow"></i></div>

+ 31 - 11
src/renderer/components/StartUpPage/SoftwareDetail.vue

@@ -11,8 +11,8 @@
       </div>
     </div>
     <div class="pt-3">
-      <el-tabs v-model="activeName" type="card">
-        <el-tab-pane class="pt-3 pl-3 software-content" name="first">
+      <el-tabs v-model="activeName" type="card" @tab-click="checkOnline">
+        <el-tab-pane class="pl-3 software-content" name="first">
           <span slot="label">下载软件</span>
           <div class="details" v-for="down in downlist">
             <h5 class="w-25 d-inline-block">{{ down.title }}</h5>
@@ -22,15 +22,7 @@
             </div>
           </div>
         </el-tab-pane>
-        <el-tab-pane label="软件详情" class="pt-3 pl-3 software-content" name="second">
-          <p><strong><span style="color:#e36c09">产品介绍:</span></strong></p>
-          <p>纵横公路造价软件2008年通过交通部测评,数据准确,品质保证。具有“模板克隆、定位查询、企业定额、清单调价、参数化设计、实时计算等功能。纵横公路软件以简洁的界面、个性化的资源、高效的算法和完善的管理让您的造价管理工作得心应手。</p>
-          <p><strong><span style="color:#e36c09">使用说明:</span></strong></p>
-          <p><a href="http://d2.smartcost.com.cn/doc/gongchengzaojiaguanlishouce.rar" target="blank">《纵横公路工程造价管理系统》简易操作手册</a></p><p><a href="http://d2.smartcost.com.cn/doc/zhaotoubiao.rar" target="blank">纵横公路造价软件招投标版功能演示</a></p>
-          <p><a href="http://d2.smartcost.com.cn/doc/gaiyusuan.rar" target="blank">纵横公路造价软件概预算版功能演示</a></p><p><a href="http://d2.smartcost.com.cn/doc/wangluoban.zip" target="blank">纵横工程造价软件免费网络版注册教程</a></p>
-          <p><a href="http://d2.smartcost.com.cn/doc/badianshiyonggongneng.zip" target="blank">纵横公路造价软件设计院客户8点实用功能</a></p>
-          <p><strong><span style="color:#e36c09">操作指引:</span></strong></p>
-          <p><img title="公路造价操作流程图.png" src="http://smartcost.com.cn/global/upload/img/20151028/14459972402207.png"></p>
+        <el-tab-pane label="软件详情" class="pl-3 software-content" name="second" v-html="items.content">
         </el-tab-pane>
       </el-tabs>
     </div>
@@ -54,6 +46,15 @@
     created () {
       this.fetchData()
     },
+    watch: {
+      'activeName': function (val) {
+        if (val === 'second') {
+          if (!this.checkOnline()) {
+            this.$message.error('当前网络不可用,图片信息将无法加载')
+          }
+        }
+      }
+    },
     methods: {
       fetchData () {
         this.loading = true
@@ -93,9 +94,25 @@
             type: 'warning'
           })
         }
+      },
+      checkOnline () {
+        if (!navigator.onLine) {
+          return false
+        } else {
+          return true
+        }
       }
     }
   }
+
+  /**
+   * 原生方法打开v-html引入a标签的点击事件
+   * @type {Electron}
+   */
+  const electron = require('electron')
+  window.openURL = function (url) {
+    electron.shell.openExternal(url)
+  }
 </script>
 
 <style>
@@ -130,4 +147,7 @@
   .d-inline-block {
     display: inline-block!important;
   }
+  .software-content a{
+    cursor: pointer;
+  }
 </style>

+ 4 - 4
src/renderer/components/StartUpPage/SoftwareList.vue

@@ -43,13 +43,13 @@
       if (this.checkOnline()) {
         let version = fs.readJsonSync(softwarejson).startup_version
         let self = this
-        this.$http.get('http://smartcost.com.cn/startup/sc_version.json')
+        this.$http.get('http://www.smartcost.com.cn/startup/sc_version.json')
           .then(function (response) {
             if (version === response.data.startup_version) {
               self.softwarelist = fs.readJsonSync(softwarejson).sc_product
             } else {
               self.loading = true
-              self.$http.get('http://smartcost.com.cn/startup/sc_software.json')
+              self.$http.get('http://www.smartcost.com.cn/startup/sc_software.json')
                 .then(function (response2) {
                   fs.writeJsonSync(softwarejson, response2.data)
                   self.softwarelist = response2.data.sc_product
@@ -61,8 +61,8 @@
                 })
             }
           })
-          .catch(function (error) {
-            self.$message.error(error)
+          .catch(function () {
+            self.$message.error('网络不佳,无法获取最新列表')
           })
       } else {
         this.softwarelist = fs.readJsonSync(softwarejson).sc_product

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

@@ -53,6 +53,7 @@
         self.loading = false
         let num = msg.num
         let delnum = msg.delnum
+        this.$electron.ipcRenderer.send('testUsb')
         if (num !== 0 && delnum !== 0) {
           self.$message({
             message: `新增了 ${num} 个纵横软件`,
@@ -99,6 +100,7 @@
         self.loading = false
         self.$message.info('你的电脑还没安装过纵横软件')
         let id = msg.id
+        this.$electron.ipcRenderer.send('testUsb')
         if (self.$route.params.productid === id) {
           self.fetchData()
           self.$refs.startupDetail.fetchData()

+ 36 - 12
src/renderer/components/StartUpPage/SoftwareStartupDetail.vue

@@ -15,22 +15,15 @@
             <h5 class="w-25 d-inline-block" v-if="exe.versionName !== ''">{{ exe.versionName }}</h5>
             <h5 v-else>{{ exe.fileName }}</h5>
             <div class="w-50 d-inline-block" v-if="exe.keyNumber !== ''">锁号:{{ exe.keyNumber }}</div>
-            <div class="w-50 d-inline-block"><b>{{ exe.fileVersion }}</b></div>
+            <div class="w-25 d-inline-block"><b>{{ exe.fileVersion }}</b></div>
+            <div class="w-50 d-inline-block">{{ exe.fileDescription }}</div>
             <div class="float-right">
               <el-button type="primary" class="btn btn-primary btn-blue btn-sm d-inline-block" @click="openExebtn(exe.id)">启动软件</el-button>
             </div>
             <div>{{ exe.path }}</div>
           </div>
         </el-tab-pane>
-        <el-tab-pane label="软件详情" class="pt-3 pl-3 software-content" name="second">
-          <p><strong><span style="color:#e36c09">产品介绍:</span></strong></p>
-          <p>纵横公路造价软件2008年通过交通部测评,数据准确,品质保证。具有“模板克隆、定位查询、企业定额、清单调价、参数化设计、实时计算等功能。纵横公路软件以简洁的界面、个性化的资源、高效的算法和完善的管理让您的造价管理工作得心应手。</p>
-          <p><strong><span style="color:#e36c09">使用说明:</span></strong></p>
-          <p><a href="http://d2.smartcost.com.cn/doc/gongchengzaojiaguanlishouce.rar" target="blank">《纵横公路工程造价管理系统》简易操作手册</a></p><p><a href="http://d2.smartcost.com.cn/doc/zhaotoubiao.rar" target="blank">纵横公路造价软件招投标版功能演示</a></p>
-          <p><a href="http://d2.smartcost.com.cn/doc/gaiyusuan.rar" target="blank">纵横公路造价软件概预算版功能演示</a></p><p><a href="http://d2.smartcost.com.cn/doc/wangluoban.zip" target="blank">纵横工程造价软件免费网络版注册教程</a></p>
-          <p><a href="http://d2.smartcost.com.cn/doc/badianshiyonggongneng.zip" target="blank">纵横公路造价软件设计院客户8点实用功能</a></p>
-          <p><strong><span style="color:#e36c09">操作指引:</span></strong></p>
-          <p><img title="公路造价操作流程图.png" src="http://smartcost.com.cn/global/upload/img/20151028/14459972402207.png"></p>
+        <el-tab-pane label="软件详情" v-if="products.id != 1" class="pl-3 software-content" name="second" v-html="products.content">
         </el-tab-pane>
       </el-tabs>
     </div>
@@ -55,7 +48,14 @@
     },
     watch: {
       // 如果路由有变化,会再次执行该方法
-      '$route': 'fetchData'
+      '$route': 'fetchData',
+      'activeName': function (val) {
+        if (val === 'second') {
+          if (!this.checkOnline()) {
+            this.$message.error('当前网络不可用,图片信息将无法加载')
+          }
+        }
+      }
     },
     methods: {
       fetchData () {
@@ -63,11 +63,13 @@
         this.$db.read().set('sc_hadInstall.url', '/softwarestartup/' + productid).write()
         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'
+        }
       },
       openExebtn (id) {
         let info = this.$db.read().get('sc_exeData').getById(id).value()
         let file = fs.existsSync(path.join(info.path, info.exeName))
-        console.log(file)
         let self = this
         if (file) {
           self.$message.success('正在启动软件...')
@@ -89,9 +91,25 @@
           }).catch(() => {
           })
         }
+      },
+      checkOnline () {
+        if (!navigator.onLine) {
+          return false
+        } else {
+          return true
+        }
       }
     }
   }
+
+  /**
+   * 原生方法打开v-html引入a标签的点击事件
+   * @type {Electron}
+   */
+  const electron = require('electron')
+  window.openURL = function (url) {
+    electron.shell.openExternal(url)
+  }
 </script>
 
 <style>
@@ -173,4 +191,10 @@
   .d-inline-block {
     display: inline-block!important;
   }
+  .software-content a{
+    cursor: pointer;
+  }
+  .software-content img{
+    width: 100%;
+  }
 </style>

+ 108 - 10
src/renderer/components/StartUpPage/UsbHeader.vue

@@ -1,32 +1,130 @@
 <template>
-  <div v-show="usbshow" class="usb-header float-left mr-3">
-    <div class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+  <el-dropdown ref="usbmenu" v-if="usbshow" class="usb-header float-left mr-3" trigger="click" :hide-on-click=false>
+    <span class="el-dropdown-link">
       <i class="fab fa-usb"></i>
-    </div>
-  </div>
+    </span>
+    <el-dropdown-menu slot="dropdown" class="downloadlist">
+      <div class="downloading" v-for="lock in lockList">
+        <div class="pb-2 border-bottom">
+          <span class="float-right"></span>
+          <h4>{{ lock.name }}</h4>
+        </div>
+        <div class="pt-3 pb-2" v-for="product in lock.prolist">
+          <div class="float-right">
+            <el-button type="primary" class="btn btn-primary btn-blue btn-sm" v-if="product.status === 1" @click="openProduct(product.startpath)">启动</el-button>
+            <el-button type="primary" class="btn btn-primary btn-blue btn-sm" v-else-if="product.status === 2" @click="downloadProduct(product.down_name, product.down_url, product.down_size)">下载</el-button>
+          </div>
+          {{ product.title }}
+        </div>
+      </div>
+    </el-dropdown-menu>
+  </el-dropdown>
 </template>
 
 <script>
   import mixin from '../mixin'
+  const fs = require('fs-extra')
+  const path = require('path')
   export default {
     mixins: [mixin],
     data: () => ({
-      usbshow: false
+      usbshow: false,
+      lockList: ''
     }),
     created () {
-      //  this.$electron.ipcRenderer.send('testUsb')
-      this.$electron.ipcRenderer.on('usbIn', (event) => {
+      this.$electron.ipcRenderer.send('testUsb')
+      this.$electron.ipcRenderer.on('usbIn', async (event, result) => {
         this.usbshow = true
+        let alllist = result.lockmsg
+        let productlist = alllist.split('|')
+        let locklist = []
+        let softwarejson = path.join('data/sc_software.json')
+        let downlist = fs.readJsonSync(softwarejson).sc_down
+        let exelist = await this.$db.read().get('sc_exeData').value()
+        // 锁号先关联已安装软件列表提供启动,若不存在则再关联官网软件列表提供下载
+        for (let i in productlist) {
+          let productNum = productlist[i].split(':')[0]
+          let productVerList = productlist[i].split(':')[1].split(';')
+          let data = {
+            name: productNum
+          }
+          let prolist = []
+          for (let j in productVerList) {
+            let pdata
+            let flag = true
+            for (let z in exelist) {
+              if (exelist[z].keytype !== '' && this.in_array(productVerList[j], exelist[z].keytype.split(','))) {
+                pdata = {
+                  title: exelist[z].simpleName + ' ' + exelist[z].versionName + ' ' + exelist[z].fileDescription,
+                  status: 1,
+                  startpath: path.join(exelist[z].path, exelist[z].exeName)
+                }
+                flag = false
+                prolist.push(pdata)
+              }
+            }
+            if (flag) {
+              for (let z in downlist) {
+                if (this.in_array(productVerList[j], downlist[z].keytype.split(','))) {
+                  pdata = {
+                    title: downlist[z].product_title + ' ' + downlist[z].title,
+                    status: 2,
+                    down_url: downlist[z].down_url,
+                    down_size: downlist[z].size,
+                    down_name: downlist[z].fulltitle
+                  }
+                  flag = false
+                  prolist.push(pdata)
+                  break
+                }
+              }
+            }
+          }
+          data.prolist = prolist
+          locklist.push(data)
+        }
+        this.lockList = locklist
       })
       this.$electron.ipcRenderer.on('usbOut', (event) => {
         this.usbshow = false
       })
+    },
+    methods: {
+      in_array (val, arr) {
+        for (let i in arr) {
+          if (arr[i] === val) {
+            return true
+          }
+        }
+        return false
+      },
+      openProduct (item) {
+        this.$electron.shell.openItem(item)
+      },
+      downloadProduct (name, downloadpath, size) {
+        // 先判断是否已在下载列表中,再加入列表中
+        let downloaditem = this.$db.read().get('sc_download').find({name: name, delete: false}).value()
+        if (!downloaditem) {
+          this.$refs.usbmenu.hide()
+          this.$emit('softwareDownload', name, downloadpath, size)
+        } else {
+          this.$message({
+            showClose: true,
+            message: name + '已存在下载列中',
+            iconClass: '',
+            type: 'warning'
+          })
+        }
+      }
     }
   }
-  const app = require('electron').remote.app
-  console.log(app.getPath('userData'))
 </script>
 
 <style>
-
+  .downloadlist {
+    min-width: 400px!important;
+    max-height: 450px!important;
+    padding: 10px 15px!important;
+    overflow-y: auto!important;
+  }
 </style>