71
71
:placeholder =" $t('pages.setting.editSource.sift.placeholder.linkTip')" class =" input w-100%" />
72
72
<t-button block @click =" actionClass" >{{ $t('pages.setting.editSource.sift.rule.try') }}</t-button >
73
73
</div >
74
+ <div class =" code-op-item card" >
75
+ <t-button block @click =" batchResults" >{{ $t('pages.setting.editSource.sift.rule.br') }}</t-button >
76
+ </div >
74
77
<div class =" code-op-item card" >
75
78
<t-input v-model =" form.filter" :label =" $t('pages.setting.editSource.sift.rule.filter')"
76
79
:placeholder =" $t('pages.setting.editSource.sift.placeholder.filterTip')" class =" input w-100%" />
@@ -144,6 +147,9 @@ import { t } from '@/locales';
144
147
import { useSettingStore } from ' @/store' ;
145
148
import { getHtml , copyToClipboardApi , encodeGzip , encodeBtoa } from ' @/utils/tool' ;
146
149
import { getFilters , processCategories } from ' @/utils/drpy/lab/hipyFilter' ;
150
+ import axios from ' axios' ;
151
+ import { json } from ' node:stream/consumers' ;
152
+
147
153
148
154
const storeSetting = useSettingStore ();
149
155
@@ -402,7 +408,6 @@ const actionClass = () => {
402
408
MessagePlugin .warning (t (' pages.setting.editSource.sift.message.sourceFirst' ));
403
409
return ;
404
410
}
405
-
406
411
const response = processCategories (contentHtml , class_parse , cate_exclude , reurl , url );
407
412
408
413
const transformData = (data ) => {
@@ -411,14 +416,80 @@ const actionClass = () => {
411
416
412
417
return titles .map ((title , index ) => ({
413
418
title: title .trim (),
414
- value: ms [index ].trim ()
419
+ id: ms [index ].trim (),
420
+ surl: form .value .reurl .replace (" fyclass" , ms [index ].trim ())
415
421
}));
416
422
}
417
423
if (response ?.title && response ?.m ) form .value .content .debug = transformData (response );
418
424
changeNav (' debug' , ' class' );
419
425
};
420
426
427
+
428
+ const batchResults = () => {
429
+ let r = form .value .content .debug ;
430
+ // console.log(r);
431
+ const { filterInfo = ' ' , filter = ' ' , matchs } = form .value ;
432
+ if (! (filterInfo && filter )) {
433
+ MessagePlugin .warning (t (' pages.setting.editSource.sift.message.inputNoFilterAndFilterInfo' ));
434
+ return ;
435
+ };
436
+ // 调用batchFetch并处理结果
437
+ batchFetch (r )
438
+ .then (results => {
439
+ let rs = {};
440
+ results .map (item => {
441
+ const newMatchs = {
442
+ ' 剧情' : matchs .plot ,
443
+ ' 地区' : matchs .area ,
444
+ ' 语言' : matchs .lang ,
445
+ ' 年份' : matchs .year ,
446
+ ' 字母' : matchs .letter ,
447
+ ' 排序' : matchs .sort ,
448
+ }
449
+ const response: any = getFilters (item .body , item .id , filter , filterInfo , newMatchs , ' ' ).filters ;
450
+ // console.log(response)
451
+ if (response ) {
452
+ rs [item .id ] = response ;
453
+ }
454
+ })
455
+ console .log (rs );
456
+ form .value .content .debug = JSON .stringify (rs , null , 2 );
457
+ changeNav (' debug' , ' class' );
458
+ })
459
+ .catch (error => {
460
+ console .error (' Failed to fetch data:' , error );
461
+ });
462
+ };
463
+
464
+
465
+
466
+
467
+ const batchFetch = async (obj ) => {
468
+ const promises = obj .map (x => {
469
+ return axios .get (x .surl );
470
+ });
471
+ try {
472
+ // 等待所有请求完成
473
+ const responses = await Promise .all (promises );
474
+ // 所有请求都成功后,提取结果数据并关联id
475
+ const results = responses .map ((response , index ) => {
476
+ console .log (index )
477
+ const { id } = obj [index ]; // 获取对应的id
478
+ return {
479
+ id: id ,
480
+ body: response .data // 假设响应体的数据在response.data中
481
+ };
482
+ });
483
+ return results ; // 返回结果数组
484
+ } catch (error ) {
485
+ // 如果有任何一个请求失败,则捕捉错误
486
+ console .error (' There was an error with one of the requests:' , error );
487
+ throw error ; // 抛出错误,以便调用者可以处理
488
+ }
489
+ };
490
+
421
491
const actionFilter = () => {
492
+ console .log (form .value )
422
493
const { filterInfo = ' ' , filter = ' ' , matchs } = form .value ;
423
494
const contentHtml = form .value .content .source ;
424
495
if (! (filterInfo && filter )) {
0 commit comments