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