add comment
This commit is contained in:
@@ -29,6 +29,10 @@ class BtDonwold {
|
||||
})
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加下载任务
|
||||
* @param {string} file 文件地址
|
||||
*/
|
||||
addTask(file) {
|
||||
const form = new FormData()
|
||||
form.append('savepath', 'd:/bt');
|
||||
@@ -48,6 +52,11 @@ class BtDonwold {
|
||||
})
|
||||
|
||||
}
|
||||
/**
|
||||
* 将base64字符串转化为文件
|
||||
* @param {string} base64str 要转换的base64字符串
|
||||
* @param {string} file 保存到的文件路径
|
||||
*/
|
||||
base64_decode(base64str, file) {
|
||||
// create buffer object from base64 encoded string, it is important to tell the constructor that the string is base64 encoded
|
||||
var bitmap = new Buffer.from(base64str, 'base64');
|
||||
@@ -55,12 +64,20 @@ class BtDonwold {
|
||||
fs.writeFileSync(file, bitmap);
|
||||
console.log('******** File created from base64 encoded string ********');
|
||||
}
|
||||
/**
|
||||
* 将文件转化为base64
|
||||
* @param {string} file 文件地址
|
||||
* @returns 文件转化后的base64字符串
|
||||
*/
|
||||
base64_encode(file) {
|
||||
// read binary data
|
||||
var bitmap = fs.readFileSync(file);
|
||||
// convert binary data to base64 encoded string
|
||||
return new Buffer.from(bitmap).toString('base64');
|
||||
}
|
||||
/**
|
||||
* 获取下载列表
|
||||
*/
|
||||
async getList() {
|
||||
let { data: { torrents } } = await axios.get("/api/v2/sync/maindata")
|
||||
// console.log(data.torrents)
|
||||
@@ -78,6 +95,10 @@ class BtDonwold {
|
||||
console.log(list)
|
||||
|
||||
}
|
||||
/**
|
||||
* 根据hashes删除任务
|
||||
* @param {string} hashes 删除任务的hashes
|
||||
*/
|
||||
async delete(hashes) {
|
||||
try{
|
||||
const form = new FormData()
|
||||
Reference in New Issue
Block a user