From 4ff163c1edc5f56fcf31ed163b08130d414971d5 Mon Sep 17 00:00:00 2001 From: src48597962 <48597962@qq.com> Date: Sun, 12 Feb 2023 20:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SrcJyAlist.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SrcJyAlist.js | 65 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 16 deletions(-) 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);