Skip to content

A full-featured download manager.

fix: change task option

Dr_rOotd5fc962bcae8
diff --git a/src/renderer/api/Api.js b/src/renderer/api/Api.js
index bfda467f..1dfcfaca 100644
--- a/src/renderer/api/Api.js
+++ b/src/renderer/api/Api.js
@@ -5,6 +5,7 @@ import Aria2 from 'aria2'
import {
separateConfig,
compactUndefined,
+ formatOptionsForEngine,
mergeTaskResult,
changeKeysToCamelCase,
changeKeysToKebabCase
@@ -119,10 +120,7 @@ export default class Api {
}
changeGlobalOption (options) {
- const args = {}
- Object.keys(options).forEach((key) => {
- args[key] = `${options[key]}`
- })
+ const args = formatOptionsForEngine(options)
return this.client.call('changeGlobalOption', args)
}
@@ -148,6 +146,16 @@ export default class Api {
})
}
+ changeOption (params = {}) {
+ let { gid, options = {} } = params
+ options = formatOptionsForEngine(options)
+
+ const kebabOptions = changeKeysToKebabCase(options)
+ const args = compactUndefined([gid, kebabOptions])
+
+ return this.client.call('changeOption', ...args)
+ }
+
getGlobalStat () {
return this.client.call('getGlobalStat')
}
diff --git a/src/renderer/store/modules/task.js b/src/renderer/store/modules/task.js
index cd2f5eae..9d4590d7 100644
--- a/src/renderer/store/modules/task.js
+++ b/src/renderer/store/modules/task.js
@@ -84,6 +84,10 @@ const actions = {
})
})
},
+ changeTaskOption (_, payload) {
+ const { gid, options } = payload
+ return api.changeOption({ gid, options })
+ },
removeTask ({ dispatch }, task) {
const { gid } = task
return api.forcePauseTask({ gid })
diff --git a/src/shared/utils.js b/src/shared/utils.js
index 1aa57e59..9d298d05 100644
--- a/src/shared/utils.js
+++ b/src/shared/utils.js
@@ -550,3 +550,13 @@ export function parseHeader (header = '') {
return result
}
+
+export function formatOptionsForEngine (options) {
+ const result = {}
+
+ Object.keys(options).forEach((key) => {
+ result[key] = `${options[key]}`
+ })
+
+ return result
+}