-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path主页.js
More file actions
235 lines (235 loc) · 8.43 KB
/
Copy path主页.js
File metadata and controls
235 lines (235 loc) · 8.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
js:
var d = [];
if (getAppVersion() < 3204) {
setResult([{
title: "您当前版本不支持本小程序,请更新至最新版本",
url: "https://haikuo.lanzoui.com/u/GoldRiver"
}])
} else {
const {
getFiles,
getLink
} = $.require('hiker://page/api');
const {color,small}=$.require('hiker://page/utils');
var path = getMyVar("path", "");
d.push({
title: '⚙️设置',
col_type: 'scroll_button',
url: 'hiker://page/settings#noHistory##noRecordHistory#',
extra: {
version: MY_RULE.version
}
});
let sub_urls = $.get_sub_urls();
let rstrip = $.rstrip;
var base_path = rstrip(getMyVar("baseurl", sub_urls[0].url), '/');
let nowSub = sub_urls.find(x=>rstrip(x.url,'/')===base_path);
sub_urls.forEach((item) => {
var isClicked = base_path === rstrip(item.url, '/');
d.push({
title: isClicked ? "‘‘’’<strong><font color='#1E90FF'>" + item.name + "</front></strong>" : item.name,
url: isClicked ? base_path + path : $(rstrip(item.url, '/')+"#noLoading#").lazyRule(() => {
input = input.split('#')[0];
putMyVar("baseurl", input);
clearMyVar("path");
refreshPage(false);
return "toast://切换成功"
}),
col_type: "scroll_button"
});
});
d.push({
col_type: "blank_block"
});
d.push({
title: "‘‘’’<strong><font color='#1E90FF'>...</front></strong>",
url: $('#noLoading#').lazyRule((path) => {
// 返回上级
path.pop();
putMyVar("path", path.join("/"));
if(getItem('clear_change','')){
clearMyVar('search','');
}
refreshPage(false);
return "hiker://empty"
}, path.split("/")),
col_type: "scroll_button"
});
d.push({
title: "🏠首页",
col_type: "scroll_button",
url: $('#noLoading#').lazyRule(() => {
putMyVar("path", "");
if(getItem('clear_refresh','')){
clearMyVar('search','');
}
refreshPage(false);
return "hiker://empty"
}),
});
let paths = "";
for (item of path.split("/")) {
if (item !== "") {
paths += "/" + item;
d.push({
title: item,
col_type: "scroll_button",
url: $('#noLoading#').lazyRule((paths) => {
putMyVar("path", paths);
if(getItem('clear_change','')){
clearMyVar('search','');
}
refreshPage(false);
return "hiker://empty"
}, paths)
})
}
}
let sorts = ["名称", "类型", "大小", '时间'];
let nsort = getMyVar('sort', '名称');
let nsearch = getMyVar('search','');
sorts.forEach(item => {
let cc = nsort === item + "-";
let isClicked = nsort === item;
d.push({
title: cc || isClicked ? "‘‘’’<strong><font color='#1E90FF'>" + item + (cc ? "∧" : "∨") + "</front></strong>" : item,
col_type: "flex_button",
url: $('#noLoading#').lazyRule((item, isClicked) => {
if (isClicked) {
putMyVar("sort", item + "-");
} else {
putMyVar("sort", item);
if(getItem('clear_change','')){
clearMyVar('search','');
}
}
refreshPage(false);
return "hiker://empty"
}, item, isClicked)
});
});
let filterOption = getItem('filterOption','全部');
let filter_rules = JSON.parse(readFile('filter_rules.json', 0) || '[]').filter(x=>x.active);
let filterSels = ['全部','文件','文件夹'];
filterSels = filterSels.concat(filter_rules.map(x=>x.name));
let filterSel = filterSels.map(it=>it===filterOption?color(it,'#12b668'):it);
filterSel.push(color('自定义过滤','#d96715'));
d.push({
title:'⏳'+color(filterOption,'#d96715'),
col_type:'flex_button',
url:$(filterSel,2,'选择要显示的内容').select((filterOption)=>{
input = pdfh(input,'body&&Text').replace('““””','');
if(input==='自定义过滤'){
return 'hiker://page/superSettings#noHistory##noRecordHistory#'
}
if(filterOption!==input){
setItem('filterOption',input);
refreshPage(false);
}
return 'hiker://empty'
},filterOption),
});
d.push({
title:nsearch?"🔍"+small(color(':'+nsearch,'#12b668')):'🔍',
col_type:'flex_button',
url:$(nsearch,'输入要搜索的内容。支持正则。如\\.js').input((nsearch)=>{
if(input!==nsearch){
putMyVar('search',input);
refreshPage(false);
}
return 'hiker://empty'
},nsearch),
});
d.push({
title: color("🕓历史","#d96715"),
url: "hiker://page/history#noHistory##noRecordHistory#",
col_type: "flex_button"
});
let dirInfo = getFiles(path,filterOption);
if(dirInfo.can_upload){
d.push({
title: color("⛅访客","#15ab21"),
url: "hiker://page/upload#noHistory##noRecordHistory#",
col_type: "flex_button"
});
}
// log(nowSub);
if(path.split('/').length>1&&nowSub&&nowSub.webdav&&nowSub.webdav.user){
let web_dav = nowSub.webdav;
// log(webdav);
d.push({
title: color("📂创建","#15ab21"),
url: $('','请输入待创建的文件夹名称').input((user,pwd,base_path,path)=>{
if(input){
let url = base_path +'/dav'+path;
log(url);
let webdav = buildWebDav(url, user, pwd);
webdav.makeDir(input);
refreshPage(false);
return "toast://文件夹"+input+"创建完毕"
}
return 'hiker://empty'
},web_dav.user,web_dav.pwd,base_path,path),
col_type: "flex_button"
});
d.push({
title: color("☁上传","#15ab21"),
url: "hiker://page/webdavUpload#noHistory##noRecordHistory#",
col_type: "flex_button"
});
}
d.push({
title:color('🔍全局','#12b668'),
col_type:'flex_button',
url:'hiker://page/search?page=fypage#noHistory##noRecordHistory#',
});
d.push({
col_type: "line_blank"
});
let clickOption = getItem('clickOption', '打开');
let showZimu = getItem('showZimu','开');
dirInfo.result.forEach(item => {
if (item.url) {
d.push({
title: item.title,
img: item.img,
url: item.url,
col_type: item.col_type,
});
} else {
// let it_type = item.extra.type;
let it_type = item.type;
let url = 'hiker://empty';
let title = item.extra.name || item.title;
let id=item.extra.id;
if (it_type === 1) {
url = $('#noLoading#').lazyRule((item, title) => {
putMyVar("path", $.rstrip(getMyVar("path", ""),'/' )+ "/" + title);
if(getItem('clear_change','')){
clearMyVar('search','');
}
refreshPage(false);
return "hiker://empty"
}, item, title);
} else if (it_type === 3 || /\.m3u8$/.test(title)) { //3是媒体,禁用下载和跳转
url = getLink(title, null,'打开', showZimu,'#isVideo=true#');
} else if (it_type === 6) {
url = getLink(title, null,'打开', showZimu,"#.jpg");
} else { //跟随系统预览和下载
url = getLink(title, null,clickOption,showZimu);
}
d.push({
title: item.title,
img: item.img,
url: url,
col_type: item.col_type,
extra: {
id:id,
type: it_type,
title: title,
}
});
}
});
setResult(d);
}