Skip to content

A full-featured download manager.

fix: select torrent counld not replace

Dr_rOot02f0b66500dd
diff --git a/src/renderer/components/Task/SelectTorrent.vue b/src/renderer/components/Task/SelectTorrent.vue
index 226ec517..50a6a776 100644
--- a/src/renderer/components/Task/SelectTorrent.vue
+++ b/src/renderer/components/Task/SelectTorrent.vue
@@ -3,8 +3,11 @@
class="upload-torrent"
drag
action="/"
+ :limit="1"
+ :multiple="false"
accept=".torrent"
:on-change="handleChange"
+ :on-exceed="handleExceed"
:auto-upload="false"
:show-file-list="false">
<i class="upload-inbox-icon"><mo-icon name="inbox" width="24" height="24" /></i>
@@ -19,7 +22,7 @@
import { mapState } from 'vuex'
import parseTorrent from 'parse-torrent'
import '@/components/Icons/inbox'
- import { getAsBase64 } from '@shared/utils'
+ import { getAsBase64, buildFileList } from '@shared/utils'
export default {
name: 'mo-select-torrent',
@@ -65,7 +68,10 @@
methods: {
handleChange (file, fileList) {
this.$store.dispatch('app/addTaskAddTorrents', { fileList })
- console.log('file===>', file)
+ },
+ handleExceed (files) {
+ const fileList = buildFileList(files[0])
+ this.$store.dispatch('app/addTaskAddTorrents', { fileList })
}
}
}
diff --git a/src/shared/utils.js b/src/shared/utils.js
index 5141d677..c80a0e55 100644
--- a/src/shared/utils.js
+++ b/src/shared/utils.js
@@ -370,3 +370,17 @@ export function detectResource (content) {
return content.includes(type)
})
}
+
+export function buildFileList (rawFile) {
+ rawFile.uid = Date.now()
+ let file = {
+ status: 'ready',
+ name: rawFile.name,
+ size: rawFile.size,
+ percentage: 0,
+ uid: rawFile.uid,
+ raw: rawFile
+ }
+ const fileList = [file]
+ return fileList
+}