提交 23177795 编写于 作者: A acgotaku

fix fold path

上级 58375fbd
......@@ -39,7 +39,8 @@ class Disk {
if (type === '0' && item.classList.contains('selected')) {
selected.push({
isdir: true,
cate_id: item.getAttribute('cate_id')
cate_id: item.getAttribute('cate_id'),
path: ''
})
}
})
......
......@@ -39,7 +39,7 @@ class Home extends Downloader {
}
selectedFile.forEach((item) => {
if (item.isdir) {
this.addFolder(item.cate_id)
this.addFolder(item)
} else {
this.addFile(item)
}
......@@ -73,10 +73,6 @@ class Home extends Downloader {
getSelected () {
window.postMessage({ type: 'getSelected' }, location.origin)
}
getPrefixLength () {
const path = Core.getHashParameter('list/path') || Core.getHashParameter('path')
return path.length === 1 ? path.length : path.length + 1
}
getFile (file) {
const options = {
credentials: 'include',
......@@ -98,6 +94,7 @@ class Home extends Downloader {
})
}
getFiles (files) {
console.log(files)
const list = Object.keys(files).map(item => this.getFile(item))
return new Promise((resolve) => {
Promise.all(list).then((items) => {
......
......@@ -22,8 +22,8 @@ class Downloader {
this.files = {}
this.completedCount = 0
}
addFolder (cateId) {
this.folders.push(cateId)
addFolder (item) {
this.folders.push(item)
}
addFile (file) {
this.files[file.pick_code] = file
......@@ -35,19 +35,19 @@ class Downloader {
if (this.folders.length !== 0) {
this.completedCount++
Core.showToast(`正在获取文件列表... ${this.completedCount}/${this.completedCount + this.folders.length - 1}`, 'inf')
const cid = this.folders.pop()
this.listParameter.search.cid = cid
const fold = this.folders.pop()
this.listParameter.search.cid = fold.cate_id
fetch(`${this.listParameter.url}${Core.objectToQueryString(this.listParameter.search)}`, this.listParameter.options).then((response) => {
if (response.ok) {
response.json().then((data) => {
setTimeout(() => this.getNextFile(taskId), this.interval)
let path = ''
for (var i = 1; i < data.path.length; i++) {
path += data.path[i].name + '/'
}
let path = fold.path + data.path[data.path.length - 1].name + '/'
data.data.forEach((item) => {
if (!item.sha) {
this.folders.push(item.cid)
this.folders.push({
cate_id: item.cid,
path
})
} else {
this.files[item.pc] = {
path,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册