diff --git a/SrcJyAlist.js b/SrcJyAlist.js index cf64cd1c..1ddb1087 100644 --- a/SrcJyAlist.js +++ b/SrcJyAlist.js @@ -55,21 +55,11 @@ function yiji() { let json = JSON.parse(gethtml(alistapi.server + "/api/fs/list", "", alistapi.password)); if(json.code==200){ let dirlist = getlist(json.data.content,1); - dirlist.forEach(item => { - d.push({ - title: item.name, - img: item.thumb || "https://gitcode.net/qq_32394351/dr/-/raw/master/img/文件类型/文件夹.svg", - url: $("hiker://empty#noRecordHistory##noHistory#").rule((api) => { - require(config.依赖.match(/http(s)?:\/\/.*\//)[0] + 'SrcJyAlist.js'); - Alistlist(api); - },alistapi), - col_type: 'avatar', - extra: { - path: "/"+item.name - } - }) - }) + d = d.concat(arrayAdd(dirlist,1,alistapi)); + let filelist = getlist(json.data.content,0); + d = d.concat(arrayAdd(filelist,0,alistapi)); + /* filelist.forEach(item => { d.push({ title: item.name, @@ -84,18 +74,60 @@ function yiji() { }, alistapi.server+"/api/fs/get", "/"+item.name, alistapi.password), col_type: 'avatar', }) - }) + })*/ } }catch(e){ } } setResult(d); } - +function arrayAdd(list,isdir,alistapi){ + let d = []; + if(isdir){ + list.forEach(item => { + d.push({ + title: item.name, + img: item.thumb || "https://gitcode.net/qq_32394351/dr/-/raw/master/img/文件类型/文件夹.svg", + url: $("hiker://empty#noRecordHistory##noHistory#").rule((api) => { + require(config.依赖.match(/http(s)?:\/\/.*\//)[0] + 'SrcJyAlist.js'); + Alistlist(api); + },alistapi), + col_type: 'avatar', + extra: { + path: (MY_PARAMS.path||"") + "/" + item.name + } + }) + }) + }else{ + list.forEach(item => { + d.push({ + title: item.name, + img: item.thumb || "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg@Referer=", + url: $().lazyRule((apiurl,path,password) => { + require(config.依赖.match(/http(s)?:\/\/.*\//)[0] + 'SrcJyAlist.js'); + let json = JSON.parse(gethtml(apiurl, path, password)); + log(json.data.raw_url); + if(json.code==200){ + return json.data.raw_url; + } + return "hiker://empty"; + }, alistapi.server + "/api/fs/get", (MY_PARAMS.path||"") + "/" + item.name, alistapi.password), + col_type: 'avatar', + }) + }) + } + return d; +} function Alistlist(alistapi){ let d = []; try{ let json = JSON.parse(gethtml(alistapi.server + "/api/fs/list", MY_PARAMS.path, alistapi.password)); if(json.code==200){ + let dirlist = getlist(json.data.content,1); + d = d.concat(arrayAdd(dirlist,1,alistapi)); + + let filelist = getlist(json.data.content,0); + d = d.concat(arrayAdd(filelist,0,alistapi)); + /* let dirlist = getlist(json.data.content,1); dirlist.forEach(item => { d.push({ @@ -128,6 +160,7 @@ function Alistlist(alistapi){ col_type: 'avatar', }) }) + */ } }catch(e){ } setResult(d);