Skip to content

Commit

Permalink
fix: reruin#192
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Jun 5, 2020
1 parent 1cf269c commit a64ff21
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 31 deletions.
5 changes: 3 additions & 2 deletions app/views/default/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ block content
section.wrap(style="margin-top:64px;border-top:1px solid #eee;")
article.markdown-body(style="padding:32px;")
| !{readme}
script(src='https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js')
script(src='/script/sort.js')

-if(writeable)
script(src='https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js')
script(src='/script/upload.js')
script(src='/script/sort.js')
include partial/footer


Expand Down
74 changes: 45 additions & 29 deletions plugins/drive.189cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,38 +364,54 @@ module.exports = ({ request, cache, getConfig, querystring, base64, saveDrive, g
}

if(!path) path = -11
let resp = await fetchData(id,{
url:`https://cloud.189.cn/v2/listFiles.action?fileId=${path}&mediaType=&keyword=&inGroupSpace=false&orderBy=1&order=ASC&pageNum=1&pageSize=9999&noCache=${Math.random()}`,
method:'GET',
headers:{
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
'Cookie': cookies,
},
json:true
})

if (!resp || !resp.body) {
return { id, type: 'folder', protocol: defaultProtocol,body:resp.msg || '解析错误' }
}
let children = resp.body.data.map( file => {
let item = {
id: manager.stringify({username , path:file.fileId}),
name: file.fileName,
protocol: defaultProtocol,
created_at: file.createTime,
updated_at: file.lastOpTime,
type: file.isFolder ? 'folder' : 'file',
}
if( item.type != 'folder' ){
item.ext = file.fileType
item.size = parseInt(file.fileSize)
item.url = 'https:'+file.downloadUrl

if(file.icon) item.icon = file.icon.smallUrl
let children = [] , pageNum = 1
while(true){
let resp = await fetchData(id,{
url:`https://cloud.189.cn/v2/listFiles.action?fileId=${path}&mediaType=&keyword=&inGroupSpace=false&orderBy=1&order=ASC&pageNum=${pageNum}&pageSize=9999&noCache=${Math.random()}`,
method:'GET',
headers:{
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
'Cookie': cookies,
},
json:true
})

if (!resp || !resp.body) {
return { id, type: 'folder', protocol: defaultProtocol,body:resp.msg || '解析错误' }
}

return item
})
for(let file of resp.body.data){
let item = {
id: manager.stringify({username , path:file.fileId}),
name: file.fileName,
protocol: defaultProtocol,
created_at: file.createTime,
updated_at: file.lastOpTime,
type: file.isFolder ? 'folder' : 'file',
}
if( item.type != 'folder' ){
item.ext = file.fileType
item.size = parseInt(file.fileSize)
item.url = 'https:'+file.downloadUrl

if(file.icon) item.icon = file.icon.smallUrl
}
children.push(item)
}

let count = resp.body.recordCount
let currentCount = resp.body.pageNum * resp.body.pageSize

if( currentCount < count ){
//翻页
pageNum++
continue
}else{
break;
}
}

let result = { id, type: 'folder', protocol: defaultProtocol }
result.$cached_at = Date.now()
result.children = children
Expand Down

0 comments on commit a64ff21

Please sign in to comment.