Skip to content

Commit 0300222

Browse files
committed
Merge branch 'feature/task_list_201905312258'
# Conflicts: # src/renderer/components/Native/EngineClient.vue
2 parents 79495cb + 4b8de78 commit 0300222

File tree

16 files changed

+295
-70
lines changed

16 files changed

+295
-70
lines changed

src/renderer/api/Api.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ export default class Api {
136136
})
137137
}
138138

139+
getOption (params = {}) {
140+
const { gid } = params
141+
const args = compactUndefined([gid])
142+
143+
return new Promise((resolve) => {
144+
this.client.call('getOption', ...args)
145+
.then((data) => {
146+
resolve(changeKeysToCamelCase(data))
147+
})
148+
})
149+
}
150+
139151
getGlobalStat () {
140152
return this.client.call('getGlobalStat')
141153
}
@@ -145,8 +157,9 @@ export default class Api {
145157
uris,
146158
options
147159
} = params
160+
const kebabOptions = changeKeysToKebabCase(options)
148161
const tasks = uris.map((uri) => {
149-
const args = compactUndefined([[uri], options])
162+
const args = compactUndefined([[uri], kebabOptions])
150163
return [ 'aria2.addUri', ...args ]
151164
})
152165
return this.client.multicall(tasks)
@@ -157,7 +170,8 @@ export default class Api {
157170
torrent,
158171
options
159172
} = params
160-
const args = compactUndefined([torrent, [], options])
173+
const kebabOptions = changeKeysToKebabCase(options)
174+
const args = compactUndefined([torrent, [], kebabOptions])
161175
return this.client.call('addTorrent', ...args)
162176
}
163177

@@ -166,7 +180,8 @@ export default class Api {
166180
metalink,
167181
options
168182
} = params
169-
const args = compactUndefined([metalink, options])
183+
const kebabOptions = changeKeysToKebabCase(options)
184+
const args = compactUndefined([metalink, kebabOptions])
170185
return this.client.call('addMetalink', ...args)
171186
}
172187

Loading
Loading

src/renderer/components/Aside/Index.vue

-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
}
4646
},
4747
methods: {
48-
open (link) {
49-
this.$electron.shell.openExternal(link)
50-
},
5148
showAddTask (taskType = 'uri') {
5249
this.$store.dispatch('app/showAddTaskDialog', taskType)
5350
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Icon from '@/components/Icons/Icon'
2+
3+
Icon.register({
4+
'task-history': {
5+
'width': 24,
6+
'height': 24,
7+
'paths': [{
8+
'd': 'M12,0C5.383,0,0,5.383,0,12s5.383,12,12,12s12-5.383,12-12S18.617,0,12,0z M19,13h-8V5h2v6h6V13z'
9+
}]
10+
}
11+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Icon from '@/components/Icons/Icon'
2+
3+
Icon.register({
4+
'task-restart': {
5+
'width': 24,
6+
'height': 24,
7+
'raw': `<path data-cap="butt" fill="none" stroke="currentColor" stroke-miterlimit="10" d="M6.121,20.121 C7.727,21.22,9.907,22,12,22c5.523,0,10-4.477,10-10c0-5.523-4.477-10-10-10C8.101,2,4.728,4.233,3.078,7.488"/>
8+
<polyline fill="none" stroke="currentColor" stroke-miterlimit="10" points="2.278,1.588 3.078,7.488 9.078,6.688 "/>
9+
<circle data-color="color-2" fill="none" stroke-miterlimit="10" cx="4" cy="18" r="3"/>`,
10+
'g': {
11+
'stroke': 'currentColor',
12+
'stroke-linecap': 'round',
13+
'stroke-linejoin': 'round',
14+
'stroke-width': '2'
15+
}
16+
}
17+
})

src/renderer/components/Native/EngineClient.vue

+11-2
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,21 @@
9292
})
9393
},
9494
onDownloadError (event) {
95-
console.log('aria2 onDownloadError', event)
9695
const [{ gid }] = event
9796
this.fetchTaskItem({ gid })
9897
.then((task) => {
9998
const taskName = getTaskName(task)
99+
const { errorCode, errorMessage } = task
100+
console.error(`[Motrix] download error===> Gid: ${gid}, #${errorCode}, ${errorMessage}`)
100101
const message = this.$t('task.download-error-message', { taskName })
101-
this.$msg.error(message)
102+
const link = `<a target="_blank" href="https://github.com/agalwood/Motrix/wiki/Error#${errorCode}" rel="noopener noreferrer">#${errorCode}</a>`
103+
this.$msg({
104+
type: 'error',
105+
showClose: true,
106+
duration: 5000,
107+
dangerouslyUseHTMLString: true,
108+
message: `${message} ${link}`
109+
})
102110
})
103111
},
104112
onDownloadComplete (event) {
@@ -196,6 +204,7 @@
196204
polling () {
197205
this.$store.dispatch('app/fetchGlobalStat')
198206
this.$store.dispatch('task/fetchList')
207+
199208
if (this.taskItemInfoVisible && this.currentTaskItem) {
200209
this.$store.dispatch('task/fetchItem', this.currentTaskItem.gid)
201210
}

src/renderer/components/Native/utils.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ export function moveTaskFilesToTrash (task, messages = {}) {
6262
return false
6363
}
6464

65-
const deleteResult1 = remote.shell.moveItemToTrash(path)
66-
if (!deleteResult1 && delFailMsg) {
67-
Message.error(delFailMsg)
65+
let deleteResult1 = true
66+
const isFileExist = existsSync(path)
67+
if (isFileExist) {
68+
deleteResult1 = remote.shell.moveItemToTrash(path)
69+
if (!deleteResult1 && delFailMsg) {
70+
Message.error(delFailMsg)
71+
}
6872
}
6973

7074
let deleteResult2 = true

src/renderer/components/Task/AddTask.vue

+7-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
import '@/components/Icons/inbox'
128128
129129
const initialForm = (state) => {
130-
const { addTaskUrl } = state.app
130+
const { addTaskUrl, addTaskOptions } = state.app
131131
const { dir, split, newTaskShowDownloading } = state.preference.config
132132
const result = {
133133
uris: addTaskUrl,
@@ -139,7 +139,8 @@
139139
cookie: '',
140140
dir,
141141
split,
142-
newTaskShowDownloading
142+
newTaskShowDownloading,
143+
...addTaskOptions
143144
}
144145
return result
145146
}
@@ -222,6 +223,7 @@
222223
},
223224
handleClose (done) {
224225
this.$store.dispatch('app/hideAddTaskDialog')
226+
this.$store.dispatch('app/updateAddTaskOptions', {})
225227
},
226228
handleClosed () {
227229
this.reset()
@@ -258,6 +260,7 @@
258260
this.form.dir = dir
259261
},
260262
reset () {
263+
this.showAdvanced = false
261264
this.form = initialForm(this.$store.state)
262265
},
263266
handleCancel (formName) {
@@ -302,7 +305,7 @@
302305
selectFile !== SELECTED_ALL_FILES &&
303306
selectFile !== NONE_SELECTED_FILES
304307
) {
305-
result['select-file'] = selectFile
308+
result.selectFile = selectFile
306309
}
307310
}
308311
@@ -369,6 +372,7 @@
369372
370373
try {
371374
this.addTask(this.type, this.form)
375+
372376
this.$store.dispatch('app/hideAddTaskDialog')
373377
if (this.form.newTaskShowDownloading) {
374378
this.$router.push({

src/renderer/components/Task/Index.vue

-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@
4747
'status': 'onStatusChange'
4848
},
4949
methods: {
50-
open (link) {
51-
this.$electron.shell.openExternal(link)
52-
},
5350
onStatusChange () {
5451
this.changeCurrentList()
5552
},

0 commit comments

Comments
 (0)