|
@@ -1,33 +1,35 @@
|
|
|
<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 ml-2" v-show="downloadNum !== 0">{{ downloadNum }}</span>
|
|
|
+ <i class="fas fa-download"></i><span class="badge badge-pill badge-info badge-orange ml-2" v-show="downloadNum !== 0">{{ downloadNum }}</span>
|
|
|
</span>
|
|
|
<!--<el-button @click="testbtn">test</el-button>-->
|
|
|
<el-dropdown-menu slot="dropdown" class="downloadlist">
|
|
|
<div v-for="(item, index) in downloads" v-show="!item.delete" :key="item.id" class="downloaditem">
|
|
|
- <div class="pb-2" v-if="item.isfinish === false">
|
|
|
- <span class="float-right">
|
|
|
- <span v-if="item.show">
|
|
|
- <i v-show="item.pause" class="far fa-pause-circle" @click="operationDownload('pause', item.id, index)"></i>
|
|
|
- <i v-show="item.resume" class="far fa-play-circle" @click="operationDownload('resume', item.id, index)"></i>
|
|
|
- <i v-show="item.start" class="far fa-play-circle" @click="operationDownload('start', item.id, index)"></i>
|
|
|
- </span>
|
|
|
- {{ item.size }}
|
|
|
- </span>
|
|
|
- {{ item.fulltitle }}
|
|
|
+ <div class="pb-2"><span class="float-right">{{ item.size }}</span>{{ item.fulltitle }}</div>
|
|
|
+ <div class="pb-2">
|
|
|
+ <div class="progress-content" v-if="item.isfinish === false">
|
|
|
+ <div class="float-right">
|
|
|
+ <span v-if="item.show">
|
|
|
+ <i v-show="item.pause" class="far fa-pause-circle text-secondary mr-2" @click="operationDownload('pause', item.id, index)"></i>
|
|
|
+ <i v-show="item.resume" class="far fa-play-circle text-secondary mr-2" @click="operationDownload('resume', item.id, index)"></i>
|
|
|
+ <i v-show="item.start" class="far fa-play-circle text-secondary mr-2" @click="operationDownload('start', item.id, index)"></i>
|
|
|
+ </span>
|
|
|
+ <i class="fas fa-times text-danger" @click="deleteDownload(item.id, index)"></i>
|
|
|
+ </div>
|
|
|
+ <div class="progress-width">
|
|
|
+ <el-progress :text-inside="true" :stroke-width="18" :percentage="item.percent" status="success"></el-progress>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="progress-content" v-else>
|
|
|
+ <div class="float-right"><i class="fas fa-times text-danger" @click="deleteDownload(item.id, index)"></i></div>
|
|
|
+ <div class="progress-width">
|
|
|
+ <button v-if="item.status === 2" @click="installbtn(item.id, index)" class="btn btn-blue btn-sm btn-lg btn-block">安装软件</button>
|
|
|
+ <button v-else-if="item.status === 3" class="btn btn-secondary btn-sm btn-lg btn-block">正在安装本软件...</button>
|
|
|
+ <button v-else-if="item.status === 4" class="btn btn-success btn-sm btn-lg btn-block">已安装</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="pb-2" v-else>
|
|
|
- <span class="float-right">
|
|
|
- <i class="fas fa-times text-danger" @click="deleteDownload(item.id, index)"></i>
|
|
|
- </span>{{ item.fulltitle }}
|
|
|
- </div>
|
|
|
- <div class="pb-2" v-if="item.status === 1">
|
|
|
- <el-progress :text-inside="true" :stroke-width="18" :percentage="item.percent" status="success"></el-progress>
|
|
|
- </div>
|
|
|
- <el-button v-else-if="item.status === 2" @click="installbtn(item.id, index)" type="primary" size="medium" class="btn-sm btn-block btn-blue">安装软件</el-button>
|
|
|
- <el-button v-else-if="item.status === 3" type="primary" size="medium" class="btn-sm btn-block btn-blue">正在安装本软件...</el-button>
|
|
|
- <el-button v-else-if="item.status === 4" type="primary" size="medium" class="btn-sm btn-block btn-blue">已安装</el-button>
|
|
|
</div>
|
|
|
</el-dropdown-menu>
|
|
|
</el-dropdown>
|
|
@@ -54,6 +56,9 @@
|
|
|
info.percent = percent
|
|
|
console.log(info)
|
|
|
this.downloads.splice(msg.index, 1, info)
|
|
|
+ if (!this.checkOnline() && info.pause === true) {
|
|
|
+ this.operationDownload('pause', msg.id, msg.index)
|
|
|
+ }
|
|
|
})
|
|
|
this.$db._.mixin(lodashId)
|
|
|
this.downloads = this.$db.read().get('sc_download').value()
|
|
@@ -69,18 +74,21 @@
|
|
|
this.$db.read().get('sc_download').getById(msg.id).assign(info).write()
|
|
|
// 通知下载完成
|
|
|
let notification = {
|
|
|
- title: '下载器',
|
|
|
+ title: '启动器',
|
|
|
body: info.fulltitle + '下载完成'
|
|
|
}
|
|
|
let myNotification = new window.Notification(notification.title, notification)
|
|
|
this.downloads.splice(msg.index, 1, info)
|
|
|
// 下载完成当前后 获取下一个info并启动它,没有则停止
|
|
|
- let info2 = this.$db.read().get('sc_download').find({isfinish: false}).value()
|
|
|
+ let info2 = this.$db.read().get('sc_download').find({ status: 1 }).value()
|
|
|
if (info2 !== undefined) {
|
|
|
info2.show = true
|
|
|
+ info2.status = 5
|
|
|
this.$db.read().get('sc_download').getById(info2.id).assign(info2).write()
|
|
|
- let index = this.downloads.length - this.$db.read().get('sc_download').filter({isfinish: false}).size().value()
|
|
|
- console.log(index)
|
|
|
+ // let index = this.downloads.length - this.$db.read().get('sc_download').filter({ status: 6 }).size().value()
|
|
|
+ let index = this.downloads.findIndex(function (item) {
|
|
|
+ return item.id === info2.id
|
|
|
+ })
|
|
|
this.downloads.splice(index, 1, info2)
|
|
|
this.operationDownload('start', info2.id, index)
|
|
|
}
|
|
@@ -115,36 +123,61 @@
|
|
|
}
|
|
|
},
|
|
|
operationDownload (status, id, index) {
|
|
|
+ let info = this.$db.read().get('sc_download').getById(id).value()
|
|
|
if (this.checkOnline()) {
|
|
|
- let info = this.$db.read().get('sc_download').getById(id).value()
|
|
|
if (status === 'start') {
|
|
|
this.$electron.ipcRenderer.send('download', {id: id, index: index})
|
|
|
info.start = false
|
|
|
info.resume = false
|
|
|
info.pause = true
|
|
|
- } else if (status === 'pause') {
|
|
|
- this.$electron.ipcRenderer.send(status, id)
|
|
|
- info.pause = false
|
|
|
- info.resume = true
|
|
|
- info.start = false
|
|
|
} else if (status === 'resume') {
|
|
|
this.$electron.ipcRenderer.send(status, id)
|
|
|
info.pause = true
|
|
|
info.resume = false
|
|
|
info.start = false
|
|
|
}
|
|
|
- this.downloads.splice(index, 1, info)
|
|
|
- this.$db.read().get('sc_download').getById(id).assign(info).write()
|
|
|
}
|
|
|
+ if (status === 'pause') {
|
|
|
+ this.$electron.ipcRenderer.send(status, id)
|
|
|
+ info.pause = false
|
|
|
+ info.resume = true
|
|
|
+ info.start = false
|
|
|
+ }
|
|
|
+ this.downloads.splice(index, 1, info)
|
|
|
+ this.$db.read().get('sc_download').getById(id).assign(info).write()
|
|
|
},
|
|
|
deleteDownload (id, index) {
|
|
|
try {
|
|
|
let info = this.$db.read().get('sc_download').getById(id).value()
|
|
|
+ if (info.status === 5) {
|
|
|
+ if (info.start === false) {
|
|
|
+ this.$electron.ipcRenderer.send('cancel', id)
|
|
|
+ info.show = false
|
|
|
+ info.start = true
|
|
|
+ info.pause = false
|
|
|
+ info.resume = false
|
|
|
+ }
|
|
|
+ // 改变下一个数据的下载状态,没有则结束
|
|
|
+ let info2 = this.$db.read().get('sc_download').find({status: 1}).value()
|
|
|
+ if (info2 !== undefined) {
|
|
|
+ info2.show = true
|
|
|
+ info2.status = 5
|
|
|
+ this.$db.read().get('sc_download').getById(info2.id).assign(info2).write()
|
|
|
+ let index2 = this.downloads.findIndex(function (item) {
|
|
|
+ return item.id === info2.id
|
|
|
+ })
|
|
|
+ console.log('info2:' + index2)
|
|
|
+ this.downloads.splice(index2, 1, info2)
|
|
|
+ // this.operationDownload('start', info2.id, index)
|
|
|
+ }
|
|
|
+ }
|
|
|
info.delete = true
|
|
|
- // this.$db.read().get('sc_download').removeById(id).write()
|
|
|
- // this.downloads.splice(index, 1)
|
|
|
+ info.status = 6
|
|
|
this.$db.read().get('sc_download').getById(id).assign(info).write()
|
|
|
+ console.log('info:' + index)
|
|
|
this.downloads.splice(index, 1, info)
|
|
|
+ // this.$db.read().get('sc_download').removeById(id).write()
|
|
|
+ // this.downloads.splice(index, 1)
|
|
|
this.downloadNum = this.$db.read().get('sc_download').filter({delete: false}).size().value()
|
|
|
// fs.removeSync(info.savepath)
|
|
|
} catch (err) {
|
|
@@ -159,6 +192,9 @@
|
|
|
let downinfo = downlist.find(function (item) {
|
|
|
return item.down_id === downID
|
|
|
})
|
|
|
+ delete downinfo.regedits
|
|
|
+ delete downinfo.versionDesc
|
|
|
+
|
|
|
downinfo.isfinish = false
|
|
|
downinfo.percent = 0
|
|
|
downinfo.savepath = downinfo.down_url.substring(downinfo.down_url.lastIndexOf('/') + 1)
|
|
@@ -181,28 +217,29 @@
|
|
|
productinfo = this.$db.read().get('sc_productData').insert(scproductinfo).write()
|
|
|
}
|
|
|
downinfo.pid = productinfo.id
|
|
|
- downinfo.version = productinfo.version
|
|
|
let info = this.$db.read().get('sc_download').insert(downinfo).write()
|
|
|
this.downloads.push(downinfo)
|
|
|
this.downloadNum = this.$db.read().get('sc_download').filter({delete: false}).size().value()
|
|
|
// 如果downloads中没有未下载的info,就让新增的info进入下载过程
|
|
|
- let info2 = this.$db.read().get('sc_download').find({isfinish: false}).value()
|
|
|
- if (info2 !== undefined && info.id === info2.id) {
|
|
|
+ let info2 = this.$db.read().get('sc_download').find({status: 5}).value()
|
|
|
+ let info3 = this.$db.read().get('sc_download').find({status: 1}).value()
|
|
|
+ if (info2 === undefined && info.id === info3.id) {
|
|
|
info.show = true
|
|
|
+ info.status = 5
|
|
|
this.$db.read().get('sc_download').getById(info.id).assign(info).write()
|
|
|
this.operationDownload('start', info.id, this.downloads.length - 1)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
testbtn () {
|
|
|
- this.adddownload('326')
|
|
|
+ console.log(this.$route.path)
|
|
|
},
|
|
|
installbtn (id, index) {
|
|
|
// 安装exe监测,5s后开始监听安装状态
|
|
|
let info = this.$db.read().get('sc_download').getById(id).value()
|
|
|
if (info.status === 2) {
|
|
|
// 判断启动器是否已安装本软件
|
|
|
- let exesqlinfo = this.$db.read().get('sc_exeData').find({ regeditName: info.regedit, fileVersion: info.version }).value()
|
|
|
+ let exesqlinfo = this.$db.read().get('sc_exeData').find({ regeditName: info.regedit, product_version: info.version }).value()
|
|
|
if (exesqlinfo !== undefined) {
|
|
|
this.$message({
|
|
|
message: `启动器已存在相同版本的 ${info.fulltitle} 软件`,
|
|
@@ -257,54 +294,4 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</script>
|
|
|
-
|
|
|
-<style>
|
|
|
- .downloadlist {
|
|
|
- min-width: 400px!important;
|
|
|
- max-height: 450px!important;
|
|
|
- padding: 10px 15px!important;
|
|
|
- overflow-y: auto!important;
|
|
|
- }
|
|
|
-
|
|
|
- .downloaditem {
|
|
|
- border: 1px solid #dee2e6;
|
|
|
- background: #fefaf9;
|
|
|
- border-radius: 7px;
|
|
|
- padding: 10px;
|
|
|
- margin: 15px 0;
|
|
|
- }
|
|
|
-
|
|
|
- .text-danger {
|
|
|
- color: #dc3545!important;
|
|
|
- }
|
|
|
- .el-progress.is-success .el-progress-bar__inner {
|
|
|
- background-color: #28a745 !important;
|
|
|
- }
|
|
|
- .el-progress-bar__inner,.el-progress-bar__outer {
|
|
|
- border-radius: .25rem !important;
|
|
|
- }
|
|
|
- .badge-info {
|
|
|
- color: #fff;
|
|
|
- background-color: #ff9900;
|
|
|
- }
|
|
|
- .badge-pill {
|
|
|
- padding-right: .6em;
|
|
|
- padding-left: .6em;
|
|
|
- border-radius: 10rem;
|
|
|
- }
|
|
|
- .badge {
|
|
|
- display: inline-block;
|
|
|
- padding-top: .25em;
|
|
|
- padding-bottom: .25em;
|
|
|
- font-size: 75%;
|
|
|
- font-weight: 700;
|
|
|
- line-height: 1;
|
|
|
- text-align: center;
|
|
|
- white-space: nowrap;
|
|
|
- vertical-align: baseline;
|
|
|
- }
|
|
|
- .download-header {
|
|
|
- cursor: pointer;
|
|
|
- }
|
|
|
-</style>
|
|
|
+</script>
|