295295 v-if =" compareTableIsVisible"
296296 :name =" name"
297297 :compare-data =" compareData"
298+ :show-refresh =" true"
298299 @closeCompare =" closeCompare"
300+ @refresh =" refreshCompare"
299301 />
300302</template >
301303
@@ -582,32 +584,60 @@ const openAppUrl = () => {
582584 }
583585};
584586
585- const compareSub = async () => {
587+ const fetchCompareData = async (data ? : any ) => {
586588 Toast .loading (" 生成节点对比中..." , {
587589 id: " compare" ,
588590 cover: true ,
589591 duration: 1500 ,
590592 });
591- const res = await useSubsApi ().compareSub (
592- props .type ,
593- props .sub ?? props .collection ,
594- );
595- if (res ?.data ?.status === " success" ) {
596- compareData .value = res .data .data ;
593+ try {
594+ const res = await subsApi .compareSub (
595+ props .type ,
596+ data ?? props .sub ?? props .collection ,
597+ );
598+ if (res ?.data ?.status === " success" ) {
599+ compareData .value = res .data .data ;
600+ } else {
601+ compareData .value = null ;
602+ }
603+ } catch (e ) {
604+ console .error (e );
605+ compareData .value = null ;
606+ }
607+ Toast .hide (" compare" );
608+ };
609+
610+ const openComparePanel = () => {
611+ scrollTop = document .documentElement .scrollTop || document .body .scrollTop ;
612+ globalStore .setSavedPositions (route .path , { left: 0 , top: scrollTop });
597613
598- scrollTop = document .documentElement .scrollTop || document .body .scrollTop ;
614+ document .querySelector (" html" ).style [" overflow-y" ] = " hidden" ;
615+ document .querySelector (" html" ).style .height = " 100%" ;
616+ document .body .style .height = " 100%" ;
617+ document .body .style [" overflow-y" ] = " hidden" ;
618+ (document .querySelector (" #app" ) as HTMLElement ).style [" overflow-y" ] = " hidden" ;
619+ (document .querySelector (" #app" ) as HTMLElement ).style .height = " 100%" ;
599620
600- globalStore .setSavedPositions (route .path , { left: 0 , top: scrollTop });
621+ compareTableIsVisible .value = true ;
622+ };
601623
602- document .querySelector (" html" ).style [" overflow-y" ] = " hidden" ;
603- document .querySelector (" html" ).style .height = " 100%" ;
604- document .body .style .height = " 100%" ;
605- document .body .style [" overflow-y" ] = " hidden" ;
606- (document .querySelector (" #app" ) as HTMLElement ).style [" overflow-y" ] =
607- " hidden" ;
608- (document .querySelector (" #app" ) as HTMLElement ).style .height = " 100%" ;
624+ const compareSub = async () => {
625+ await fetchCompareData ();
626+ openComparePanel ();
627+ };
609628
610- compareTableIsVisible .value = true ;
629+ const refreshCompare = async () => {
630+ try {
631+ // 重新获取最新订阅/组合订阅信息
632+ const type = props .type === ' collection' ? ' collection' : ' sub' ;
633+ const infoRes = await subsApi .getOne (type , name );
634+ const latestData = (infoRes ?.data ?.status === ' success' ? infoRes .data .data : null ) ?? (props .sub ?? props .collection );
635+ await fetchCompareData (latestData );
636+ // 同步更新 store,使进入编辑器时数据一致
637+ subsStore .setOneData (props .type === ' collection' ? ' collections' : ' subs' , name , latestData );
638+ } catch (e ) {
639+ console .error (e );
640+ compareData .value = null ;
611641 Toast .hide (" compare" );
612642 }
613643};
@@ -904,6 +934,7 @@ const onClickRefresh = async () => {
904934 display : -webkit-box ;
905935 -webkit-box-orient : vertical ;
906936 -webkit-line-clamp : 1 ;
937+ line-clamp : 1 ;
907938 word-wrap : break-word ;
908939 word-break : break-all ;
909940 overflow : hidden ;
@@ -961,6 +992,7 @@ const onClickRefresh = async () => {
961992 display : -webkit-box ;
962993 -webkit-box-orient : vertical ;
963994 -webkit-line-clamp : 3 ;
995+ line-clamp : 3 ;
964996 word-wrap : break-word ;
965997 word-break : break-all ;
966998 overflow : hidden ;
@@ -977,6 +1009,7 @@ const onClickRefresh = async () => {
9771009 display : -webkit-box ;
9781010 -webkit-box-orient : vertical ;
9791011 -webkit-line-clamp : 2 ;
1012+ line-clamp : 2 ;
9801013 word-wrap : break-word ;
9811014 word-break : break-all ;
9821015 overflow : hidden ;
@@ -994,6 +1027,7 @@ const onClickRefresh = async () => {
9941027 display : -webkit-box ;
9951028 -webkit-box-orient : vertical ;
9961029 -webkit-line-clamp : 1 ;
1030+ line-clamp : 1 ;
9971031 word-wrap : break-word ;
9981032 word-break : break-all ;
9991033 overflow : hidden ;
0 commit comments