A full-featured download manager.
feat: support thunder links
Dr_rOot334d4e638678
diff --git a/src/renderer/components/Task/AddTask.vue b/src/renderer/components/Task/AddTask.vueindex 31a45fee..c6496a85 100644--- a/src/renderer/components/Task/AddTask.vue+++ b/src/renderer/components/Task/AddTask.vue@@ -20,6 +20,7 @@:autosize="{ minRows: 3, maxRows: 5 }"auto-complete="off"placeholder="添加多个下载链接时,请确保每行只有一个链接"+ @change="handleUriChange"v-model="form.uris"></el-input></el-form-item>@@ -110,12 +111,12 @@<script>import is from 'electron-is'import { mapState } from 'vuex'- import { isEmpty, compact } from 'lodash'+ import { isEmpty } from 'lodash'import SelectDirectory from '@/components/Native/SelectDirectory'import SelectTorrent from '@/components/Task/SelectTorrent'import { prettifyDir } from '@/components/Native/utils'import '@/components/Icons/inbox'- import { splitTextRows, needCheckCopyright } from '@shared/utils'+ import { splitTaskLinks, needCheckCopyright } from '@shared/utils'const initialForm = (state) => {const { dir, split, newTaskShowDownloading } = state.preference.config@@ -210,6 +211,18 @@console.log(tab, tab.name, event)this.$store.dispatch('app/changeAddTaskType', tab.name)},+ handleUriChange () {+ // el-input does not support @paste event ?+ // https://github.com/ElemeFE/element/blob/master/packages/input/src/input.vue+ const { uris } = this.form+ if (uris.includes('thunder://')) {+ this.$message({+ type: 'warning',+ message: '友情提示:迅雷链接解码之后的资源不一定存在',+ duration: 6000+ })+ }+ },handleTorrentChange (torrent, file, fileList) {// TODO 种子选择部分文件下载// console.log('handleTorrentChange===>', torrent, file, fileList)@@ -270,7 +283,7 @@},buildUriPayload (form) {let { uris } = form- uris = compact(splitTextRows(uris))+ uris = splitTaskLinks(uris)const options = this.buildOption(form)const result = {uris,@@ -309,8 +322,7 @@}},checkCopyright (type, form) {- let { uris } = form- uris = compact(splitTextRows(uris))+ const { uris } = formreturn new Promise((resolve, reject) => {if (type !== 'uri') {diff --git a/src/shared/utils.js b/src/shared/utils.jsindex f1691514..09ce971e 100644--- a/src/shared/utils.js+++ b/src/shared/utils.js@@ -1,6 +1,7 @@import {isEmpty,isNaN,+ compact,parseInt,isFunction,camelCase,@@ -268,7 +269,8 @@ export function isAudioOrVideo (uri = '') {return result}-export function needCheckCopyright (uris) {+export function needCheckCopyright (links = '') {+ const uris = splitTaskLinks(links)const avs = uris.filter(uri => {return isAudioOrVideo(uri)})@@ -276,3 +278,22 @@ export function needCheckCopyright (uris) {const result = avs.length > 0return result}++export function decodeThunderLink (url = '') {+ if (!url.startsWith('thunder://')) {+ return url+ }++ let result = url.split('thunder://')[1]+ result = Buffer.from(result, 'base64').toString('utf8')+ result = result.substr(2, result.length - 4)+ return result+}++export function splitTaskLinks (links = '') {+ const temp = compact(splitTextRows(links))+ const result = temp.map((item) => {+ return decodeThunderLink(item)+ })+ return result+}