A full-featured download manager.
add drag file
raistlin9162e6b8bb5fafe
diff --git a/src/renderer/components/Main.vue b/src/renderer/components/Main.vueindex f2828611..6da99a21 100644--- a/src/renderer/components/Main.vue+++ b/src/renderer/components/Main.vue@@ -40,6 +40,28 @@})},methods: {+ },+ created () {+ document.ondragover = document.ondrop = (ev) => {+ ev.preventDefault()+ }++ document.body.ondrop = (ev) => {+ ev.preventDefault()++ const fileList = [...ev.dataTransfer.files]+ .map(item => ({ raw: item, name: item.name }))+ .filter(item => /\.torrent$/.test(item.name))+ if (!fileList.length) {+ return+ }++ this.$store.dispatch('app/showAddTaskDialog', 'torrent')++ this.$nextTick(() => {+ this.$store.dispatch('app/addTaskAddTorrents', { fileList })+ })+ }}}</script>diff --git a/src/renderer/components/Task/SelectTorrent.vue b/src/renderer/components/Task/SelectTorrent.vueindex a8a6650b..226ec517 100644--- a/src/renderer/components/Task/SelectTorrent.vue+++ b/src/renderer/components/Task/SelectTorrent.vue@@ -35,11 +35,18 @@computed: {...mapState('preference', {config: state => state.config+ }),+ ...mapState('app', {+ torrents: state => state.addTaskTorrents})},- methods: {- handleChange (file, fileList) {- console.log('file===>', file)+ watch: {+ torrents (fileList) {+ const file = fileList[0]+ if (fileList.length === 0) {+ this.name = ''+ return+ }if (!file.raw) {return}@@ -54,6 +61,12 @@this.$emit('change', torrent, file, fileList)})}+ },+ methods: {+ handleChange (file, fileList) {+ this.$store.dispatch('app/addTaskAddTorrents', { fileList })+ console.log('file===>', file)+ }}}</script>diff --git a/src/renderer/store/modules/app.js b/src/renderer/store/modules/app.jsindex ba2c1cf4..553b8219 100644--- a/src/renderer/store/modules/app.js+++ b/src/renderer/store/modules/app.js@@ -21,7 +21,8 @@ const state = {numWaiting: 0},addTaskVisible: false,- addTaskType: 'uri'+ addTaskType: 'uri',+ addTaskTorrents: []}const getters = {@@ -43,6 +44,9 @@ const mutations = {CHANGE_ADD_TASK_TYPE (state, taskType) {state.addTaskType = taskType},+ CHANGE_ADD_TASK_TORRENTS (state, fileList) {+ state.addTaskTorrents = [...fileList]+ },UPDATE_INTERVAL (state, millisecond) {let interval = millisecondif (millisecond > MAX_INTERVAL) {@@ -121,10 +125,14 @@ const actions = {},hideAddTaskDialog ({ commit }) {commit('CHANGE_ADD_TASK_VISIBLE', false)+ commit('CHANGE_ADD_TASK_TORRENTS', [])},changeAddTaskType ({ commit }, taskType) {commit('CHANGE_ADD_TASK_TYPE', taskType)},+ addTaskAddTorrents ({ commit }, { fileList }) {+ commit('CHANGE_ADD_TASK_TORRENTS', fileList)+ },updateInterval ({ commit }, millisecond) {commit('UPDATE_INTERVAL', millisecond)},