88import DefForm from "./_defForm" ;
99import { http } from "./_http" ;
1010import tplEdt from "./tpl/edt.html" ;
11- import "./style/style.css"
11+ import "./style/style.css" ;
1212
1313if ( typeof __GM_api !== "undefined" ) {
1414 _log ( __GM_api ) ;
@@ -47,6 +47,17 @@ const gob = {
4747 } ,
4848 // 获取种子列表: torrents/info?tag=test 或 category=test
4949 apiTorrents ( filter = "" , fn = ( ) => { } ) {
50+ // category 查询
51+ const tryCategory = ( ) => {
52+ const url = gob . apiUrl ( `torrents/info?category=${ filter } ` ) ;
53+ gob . http . get ( url ) . then ( ( res ) => {
54+ gob . data . listTorrent = gob . parseReq ( res , "json" ) ;
55+ fn ( ) ;
56+ } ) . catch ( ( ) => {
57+ gob . data . listTorrent = [ ] ;
58+ fn ( ) ;
59+ } ) ;
60+ } ;
5061 // tag 查询
5162 const tryTag = ( ) => {
5263 const url = gob . apiUrl ( `torrents/info?tag=${ filter } ` ) ;
@@ -55,25 +66,16 @@ const gob = {
5566 if ( list . length > 0 ) {
5667 gob . data . listTorrent = list ;
5768 fn ( ) ;
58- } else {
69+ }
70+ else {
5971 tryCategory ( ) ;
6072 }
6173 } ) . catch ( tryCategory ) ;
6274 } ;
63- // category 查询
64- const tryCategory = ( ) => {
65- const url = gob . apiUrl ( `torrents/info?category=${ filter } ` ) ;
66- gob . http . get ( url ) . then ( ( res ) => {
67- gob . data . listTorrent = gob . parseReq ( res , "json" ) ;
68- fn ( ) ;
69- } ) . catch ( ( ) => {
70- gob . data . listTorrent = [ ] ;
71- fn ( ) ;
72- } ) ;
73- } ;
7475 if ( filter ) {
7576 tryTag ( ) ;
76- } else {
77+ }
78+ else {
7779 // 如果为空,查询所有
7880 const url = gob . apiUrl ( "torrents/info" ) ;
7981 gob . http . get ( url ) . then ( ( res ) => {
0 commit comments