新增下载失败时显示搜索按钮
parent
81985b0e31
commit
5edf51810d
|
@ -21,12 +21,12 @@ div(:class="$style.btns")
|
||||||
button(type="button" v-if="fileBtn" title="定位文件" @click.stop="handleClick('file')")
|
button(type="button" v-if="fileBtn" title="定位文件" @click.stop="handleClick('file')")
|
||||||
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='-61 0 512 512' space='preserve')
|
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='-61 0 512 512' space='preserve')
|
||||||
use(xlink:href='#icon-musicFile')
|
use(xlink:href='#icon-musicFile')
|
||||||
button(type="button" v-if="removeBtn" title="移除" @click.stop="handleClick('remove')")
|
|
||||||
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 212.982 212.982' space='preserve')
|
|
||||||
use(xlink:href='#icon-delete')
|
|
||||||
button(type="button" v-if="searchBtn" title="搜索" @click.stop="handleClick('search')")
|
button(type="button" v-if="searchBtn" title="搜索" @click.stop="handleClick('search')")
|
||||||
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 30.239 30.239' space='preserve')
|
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 30.239 30.239' space='preserve')
|
||||||
use(xlink:href='#icon-search')
|
use(xlink:href='#icon-search')
|
||||||
|
button(type="button" v-if="removeBtn" title="移除" @click.stop="handleClick('remove')")
|
||||||
|
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 212.982 212.982' space='preserve')
|
||||||
|
use(xlink:href='#icon-delete')
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,21 @@ const refreshUrl = function(commit, downloadInfo) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
* @param {*} path
|
||||||
|
*/
|
||||||
|
const deleteFile = path => new Promise((resolve, reject) => {
|
||||||
|
fs.access(path, fs.constants.F_OK, err => {
|
||||||
|
if (err) return reject(err)
|
||||||
|
fs.unlink(path, err => {
|
||||||
|
if (err) return reject(err)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
const actions = {
|
const actions = {
|
||||||
createDownload({ state, rootState, commit }, { musicInfo, type }) {
|
createDownload({ state, rootState, commit }, { musicInfo, type }) {
|
||||||
|
@ -280,7 +295,9 @@ const actions = {
|
||||||
}
|
}
|
||||||
commit('removeTask', index)
|
commit('removeTask', index)
|
||||||
if (dls[info.key]) delete dls[info.key]
|
if (dls[info.key]) delete dls[info.key]
|
||||||
|
;(info.status != state.downloadStatus.COMPLETED ? deleteFile(info.filePath) : Promise.resolve()).finally(() => {
|
||||||
this.dispatch('download/startTask')
|
this.dispatch('download/startTask')
|
||||||
|
})
|
||||||
},
|
},
|
||||||
removeTaskMultiple({ commit, rootState, state }, list) {
|
removeTaskMultiple({ commit, rootState, state }, list) {
|
||||||
list.forEach(item => {
|
list.forEach(item => {
|
||||||
|
|
|
@ -28,9 +28,10 @@ div(:class="$style.download")
|
||||||
td.break(style="width: 15%;") {{item.statusText}}
|
td.break(style="width: 15%;") {{item.statusText}}
|
||||||
td.break(style="width: 10%;") {{item.type && item.type.toUpperCase()}}
|
td.break(style="width: 10%;") {{item.type && item.type.toUpperCase()}}
|
||||||
td(style="width: 20%; padding-left: 0; padding-right: 0;")
|
td(style="width: 20%; padding-left: 0; padding-right: 0;")
|
||||||
material-list-buttons(:index="index" :download-btn="false" :file-btn="true" :start-btn="!item.isComplate && item.status != downloadStatus.WAITING && (item.status != downloadStatus.RUN)"
|
material-list-buttons(:index="index" :download-btn="false" :file-btn="item.status != downloadStatus.ERROR"
|
||||||
|
:start-btn="!item.isComplate && item.status != downloadStatus.WAITING && (item.status != downloadStatus.RUN)"
|
||||||
:pause-btn="!item.isComplate && (item.status == downloadStatus.RUN || item.status == downloadStatus.WAITING)" :list-add-btn="false"
|
:pause-btn="!item.isComplate && (item.status == downloadStatus.RUN || item.status == downloadStatus.WAITING)" :list-add-btn="false"
|
||||||
:play-btn="item.status == downloadStatus.COMPLETED" @btn-click="handleListBtnClick")
|
:play-btn="item.status == downloadStatus.COMPLETED" :search-btn="item.status == downloadStatus.ERROR" @btn-click="handleListBtnClick")
|
||||||
material-flow-btn(:show="isShowEditBtn" :play-btn="false" :download-btn="false" :add-btn="false" :start-btn="true" :pause-btn="true" @btn-click="handleFlowBtnClick")
|
material-flow-btn(:show="isShowEditBtn" :play-btn="false" :download-btn="false" :add-btn="false" :start-btn="true" :pause-btn="true" @btn-click="handleFlowBtnClick")
|
||||||
div(:class="$style.noItem" v-else)
|
div(:class="$style.noItem" v-else)
|
||||||
</template>
|
</template>
|
||||||
|
@ -185,6 +186,9 @@ export default {
|
||||||
case 'file':
|
case 'file':
|
||||||
this.handleOpenFolder(index)
|
this.handleOpenFolder(index)
|
||||||
break
|
break
|
||||||
|
case 'search':
|
||||||
|
this.handleSearch(index)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleSelectAllData(isSelect) {
|
handleSelectAllData(isSelect) {
|
||||||
|
@ -232,6 +236,15 @@ export default {
|
||||||
if (!checkPath(path)) return
|
if (!checkPath(path)) return
|
||||||
openDirInExplorer(path)
|
openDirInExplorer(path)
|
||||||
},
|
},
|
||||||
|
handleSearch(index) {
|
||||||
|
const info = this.list[index].musicInfo
|
||||||
|
this.$router.push({
|
||||||
|
path: 'search',
|
||||||
|
query: {
|
||||||
|
text: `${info.name} ${info.singer}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue