@funhub/platform 0.1.76 → 0.1.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
 
2
- "use client";import{useUserStore as e}from"../../../../../store/modules/user-store.mjs";import{Box as t}from"../../../../ui/box.mjs";import{Text as n}from"../../../../ui/text.mjs";import{useLoginModalStore as r}from"../../../../../store/modules/login-modal-store.mjs";import{useDeleteRequest as i}from"../../../../../hooks/query/use-query.mjs";import{debounceFun as a}from"../../../../../utils/tools.mjs";import o from"../../../../common/interaction-animations.module.mjs";import s from"../../../../common/collection-popup/index.mjs";import{useContentOperate as c}from"../../../../../hooks/use-content-operate.mjs";import l from"../../../../../assets/icons/detail/check-ok.mjs";import u from"../../../../../assets/icons/detail/collect_nor.mjs";import d from"../../../../../assets/icons/detail/collect_sel.mjs";import f from"../../../../../assets/icons/detail/give_like.mjs";import p from"../../../../../assets/icons/detail/give_like_sel.mjs";import m from"../../../../../assets/icons/detail/share.mjs";import{useCallback as h,useMemo as g,useRef as _,useState as v}from"react";import{jsx as y,jsxs as b}from"react/jsx-runtime";import{toast as x}from"sonner";import{useTranslations as S}from"next-intl";function C({mode:C=`renderer`,information:E,onUpdate:D}){let O=C===`editor`||!E?.id||E.id.startsWith(`preview-`),k=S(`components.biz.business.detail`),[A,j]=v(!1),[M,N]=v(!1),P=_(0),F=e(e=>e.userId),I=e(e=>e.isLogin),L=i(),R=h(()=>{F&&(L([`user-profile`,`mine`,F,`user-like-video`]),L([`user-profile`,`mine`,F,`user-like-post`]),L([`user-profile`,`mine`,F,`user-collect-video`,F]),L([`user-profile`,`mine`,F,`user-collect-post`,F]))},[L,F]),{likeAnimation:z,handleLikeOperate:B,handleDefaultCollectionOperate:V,handleShareOperate:H}=c({id:E.id,isLike:E.like||!1,isDislike:E.dislike||!1,isCollect:E.collect||!1,likeCnt:T(E.static?.like_cnt),dislikeCnt:T(E.static?.dislike_cnt),contentType:E.content_type,prefetchDefaultCollection:!O,animationClasses:{like:o.likeShakeAnimation,dislike:o.dislikeShakeAnimation}}),U=h(e=>{D?.({...e})},[D]),W=h(async()=>{if(A)return;if(!I){r.getState().open();return}let e=Date.now();if(e-P.current<300)return;P.current=e,j(!0);let t=E.like||!1,n=E.dislike||!1,i=T(E.static?.like_cnt),a=T(E.static?.dislike_cnt),o=!t,s=Math.max(0,i+(o?1:-1)),c=o?!1:n,l=o&&n?Math.max(0,a-1):a;U({like:o,dislike:c,static:{...E.static,like_cnt:s,dislike_cnt:l}});try{let e=await B();if(!e){U({like:t,dislike:n,static:{...E.static,like_cnt:i,dislike_cnt:a}});return}U({like:e.isLike,dislike:e.isDislike??c,static:{...E.static,like_cnt:e.likeCnt,dislike_cnt:e.dislikeCnt??l}}),R(),window.sensors?.track?.(`detail_like_click`,{object_id:E.id,action:e.isLike?`点赞`:`取消点赞`,like_count:e.likeCnt})}catch(e){console.error(`点赞操作失败:`,e),x.error(k(`detailOperate.operateFailed`))}finally{j(!1)}},[B,E,R,A,I,k,U]),G=g(()=>E.id,[E.id]),K=h(()=>{H(({isCollect:e})=>{U({collect:e})},G)},[H,G,U]);async function q(e){return await new Promise(e=>setTimeout(e,300)),e}let J=h(()=>{s.show({mode:`select`,onCollect:async e=>{try{await q({contentId:E.id,collectionId:e}),U({collect:!0}),R(),x.success(k(`detailOperate.modifyCollectionSuccess`))}catch(e){console.error(`修改收藏夹失败:`,e),x.error(k(`detailOperate.collectFailed`))}}})},[E.id,R,k,U]),Y=h(e=>{let t=e||k(`detailOperate.defaultCollection`);x.custom(e=>b(`div`,{className:`flex items-center justify-between gap-[16px] px-[16px] py-[12px] rounded-[12px] bg-black text-white shadow-lg min-w-[280px]`,children:[b(`div`,{className:`flex items-center gap-[10px]`,children:[y(`div`,{className:`w-[24px] h-[24px] rounded-full bg-white flex items-center justify-center`,children:y(l,{className:`w-[14px] h-[14px]`})}),b(`div`,{className:`flex items-center gap-[6px]`,children:[y(`span`,{className:`text-[14px] leading-[20px]`,children:k(`detailOperate.collectAdded`)}),y(`span`,{className:`text-[14px] leading-[20px] font-semibold`,children:t})]})]}),y(`button`,{type:`button`,className:`text-[14px] text-theme5 font-semibold`,onClick:()=>{x.dismiss(e),J()},children:k(`detailOperate.modifyCollection`)})]}))},[J,k]),X=h(async()=>{if(M)return;if(!I){r.getState().open();return}let e=E.collect||!1;N(!0),window.sensors?.track?.(`detail_fav_click`,{object_id:E.id,action:e?`取消收藏`:`收藏`});try{let t=await V({currentCollect:e,onUpdate:({isCollect:e})=>{U({collect:e})}});if(!t?.success){x.error(t?.message||k(`detailOperate.collectFailed`));return}R(),window.sensors?.track?.(`detail_fav_click`,{object_id:E.id,action:t.isCollect?`收藏`:`取消收藏`}),!e&&t.isCollect&&Y(t.collectionTitle),e&&t.isCollect===!1&&x.success(k(`detailOperate.uncollectSuccess`))}catch(e){console.error(`收藏操作失败:`,e),x.error(e?.message||k(`detailOperate.collectFailed`))}finally{N(!1)}},[V,E.collect,E.id,R,M,I,Y,k,U]),Z=g(()=>a(X,300),[X]);return b(t,{className:`w-full h-[42px] mt-[16px] flex items-center justify-between ${O?`pointer-events-none`:``}`,children:[b(t,{className:`w-[25%] h-full flex flex-col items-center justify-center ${A?`opacity-50 cursor-not-allowed`:`cursor-pointer`}`,onClick:W,children:[E.like?y(p,{className:`w-[20px] h-[20px] ${z.animationClass}`}):y(f,{className:`w-[20px] h-[20px] text-text2`}),y(n,{className:`text-[12px] text-text2 leading-[20px]`,children:E.static?E.static.like_cnt===0?k(`detailOperate.like`):w(E.static?.like_cnt):k(`detailOperate.like`)})]}),b(t,{className:`w-[25%] h-full flex flex-col items-center justify-center ${M?`opacity-50 cursor-not-allowed`:`cursor-pointer`}`,onClick:Z,children:[E.collect?y(d,{className:`w-[20px] h-[20px]`}):y(u,{className:`w-[20px] h-[20px] text-text2`}),y(n,{className:`text-[12px] text-text2 leading-[20px]`,children:k(`detailOperate.collection`)})]}),b(t,{className:`w-[25%] h-full flex flex-col items-center justify-center cursor-pointer`,onClick:K,children:[y(m,{className:`w-[20px] h-[20px] text-text2`}),y(n,{className:`text-[12px] text-text2 leading-[20px]`,children:k(`detailOperate.share`)})]})]})}function w(e){let t=Number(e||0);return Number.isNaN(t)||t<=0?`0`:t>=1e4?`${(t/1e4).toFixed(1)}w`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function T(e){if(e==null)return 0;if(typeof e==`number`)return e;let t=Number(e);return Number.isNaN(t)?0:t}export{C as DetailOperate};
2
+ "use client";import{useUserStore as e}from"../../../../../store/modules/user-store.mjs";import{pCommunityMoveCollectionContent as t}from"../../../../../service/generated/client.mjs";import{Box as n}from"../../../../ui/box.mjs";import{Text as r}from"../../../../ui/text.mjs";import{useLoginModalStore as i}from"../../../../../store/modules/login-modal-store.mjs";import{useDeleteRequest as a}from"../../../../../hooks/query/use-query.mjs";import{debounceFun as o}from"../../../../../utils/tools.mjs";import s from"../../../../common/interaction-animations.module.mjs";import c from"../../../../common/collection-popup/index.mjs";import{useContentOperate as l}from"../../../../../hooks/use-content-operate.mjs";import u from"../../../../../assets/icons/detail/check-ok.mjs";import d from"../../../../../assets/icons/detail/collect_nor.mjs";import f from"../../../../../assets/icons/detail/collect_sel.mjs";import p from"../../../../../assets/icons/detail/give_like.mjs";import m from"../../../../../assets/icons/detail/give_like_sel.mjs";import h from"../../../../../assets/icons/detail/share.mjs";import{useCallback as g,useMemo as _,useRef as v,useState as y}from"react";import{jsx as b,jsxs as x}from"react/jsx-runtime";import{toast as S}from"sonner";import{useTranslations as C}from"next-intl";function w({mode:w=`renderer`,information:D,onUpdate:O}){let k=w===`editor`||!D?.id||D.id.startsWith(`preview-`),A=C(`components.biz.business.detail`),[j,M]=y(!1),[N,P]=y(!1),F=v(0),I=e(e=>e.userId),L=e(e=>e.isLogin),R=a(),z=g(()=>{I&&(R([`user-profile`,`mine`,I,`user-like-video`]),R([`user-profile`,`mine`,I,`user-like-post`]),R([`user-profile`,`mine`,I,`user-collect-video`,I]),R([`user-profile`,`mine`,I,`user-collect-post`,I]))},[R,I]),{likeAnimation:B,handleLikeOperate:V,handleDefaultCollectionOperate:H,handleShareOperate:U}=l({id:D.id,isLike:D.like||!1,isDislike:D.dislike||!1,isCollect:D.collect||!1,likeCnt:E(D.static?.like_cnt),dislikeCnt:E(D.static?.dislike_cnt),contentType:D.content_type,prefetchDefaultCollection:!k,animationClasses:{like:s.likeShakeAnimation,dislike:s.dislikeShakeAnimation}}),W=g(e=>{O?.({...e})},[O]),G=g(async()=>{if(j)return;if(!L){i.getState().open();return}let e=Date.now();if(e-F.current<300)return;F.current=e,M(!0);let t=D.like||!1,n=D.dislike||!1,r=E(D.static?.like_cnt),a=E(D.static?.dislike_cnt),o=!t,s=Math.max(0,r+(o?1:-1)),c=o?!1:n,l=o&&n?Math.max(0,a-1):a;W({like:o,dislike:c,static:{...D.static,like_cnt:s,dislike_cnt:l}});try{let e=await V();if(!e){W({like:t,dislike:n,static:{...D.static,like_cnt:r,dislike_cnt:a}});return}W({like:e.isLike,dislike:e.isDislike??c,static:{...D.static,like_cnt:e.likeCnt,dislike_cnt:e.dislikeCnt??l}}),z(),window.sensors?.track?.(`detail_like_click`,{object_id:D.id,action:e.isLike?`点赞`:`取消点赞`,like_count:e.likeCnt})}catch(e){console.error(`点赞操作失败:`,e),S.error(A(`detailOperate.operateFailed`))}finally{M(!1)}},[V,D,z,j,L,A,W]),K=_(()=>D.id,[D.id]),q=g(()=>{U(({isCollect:e})=>{W({collect:e})},K)},[U,K,W]),J=g(()=>{c.show({mode:`select`,onCollect:async e=>{try{let n=await t({new_collection_id:e,content_id:D.id});if(n.code!==0)throw Error(n.message||A(`detailOperate.collectFailed`));W({collect:!0}),z(),S.success(A(`detailOperate.modifyCollectionSuccess`))}catch(e){console.error(`修改收藏夹失败:`,e),S.error(A(`detailOperate.collectFailed`))}}})},[D.id,z,A,W]),Y=g(e=>{let t=e||A(`detailOperate.defaultCollection`);S.custom(e=>x(`div`,{className:`flex items-center justify-between gap-[16px] px-[16px] py-[12px] rounded-[12px] bg-black text-white shadow-lg min-w-[280px]`,children:[x(`div`,{className:`flex items-center gap-[10px]`,children:[b(`div`,{className:`w-[24px] h-[24px] rounded-full bg-white flex items-center justify-center`,children:b(u,{className:`w-[14px] h-[14px]`})}),x(`div`,{className:`flex items-center gap-[6px]`,children:[b(`span`,{className:`text-[14px] leading-[20px]`,children:A(`detailOperate.collectAdded`)}),b(`span`,{className:`text-[14px] leading-[20px] font-semibold`,children:t})]})]}),b(`button`,{type:`button`,className:`text-[14px] text-theme5 font-semibold`,onClick:()=>{S.dismiss(e),J()},children:A(`detailOperate.modifyCollection`)})]}))},[J,A]),X=g(async()=>{if(N)return;if(!L){i.getState().open();return}let e=D.collect||!1;P(!0),window.sensors?.track?.(`detail_fav_click`,{object_id:D.id,action:e?`取消收藏`:`收藏`});try{let t=await H({currentCollect:e,onUpdate:({isCollect:e})=>{W({collect:e})}});if(!t?.success){S.error(t?.message||A(`detailOperate.collectFailed`));return}z(),window.sensors?.track?.(`detail_fav_click`,{object_id:D.id,action:t.isCollect?`收藏`:`取消收藏`}),!e&&t.isCollect&&Y(t.collectionTitle),e&&t.isCollect===!1&&S.success(A(`detailOperate.uncollectSuccess`))}catch(e){console.error(`收藏操作失败:`,e),S.error(e?.message||A(`detailOperate.collectFailed`))}finally{P(!1)}},[H,D.collect,D.id,z,N,L,Y,A,W]),Z=_(()=>o(X,300),[X]);return x(n,{className:`w-full h-[42px] mt-[16px] flex items-center justify-between ${k?`pointer-events-none`:``}`,children:[x(n,{className:`w-[25%] h-full flex flex-col items-center justify-center ${j?`opacity-50 cursor-not-allowed`:`cursor-pointer`}`,onClick:G,children:[D.like?b(m,{className:`w-[20px] h-[20px] ${B.animationClass}`}):b(p,{className:`w-[20px] h-[20px] text-text2`}),b(r,{className:`text-[12px] text-text2 leading-[20px]`,children:D.static?D.static.like_cnt===0?A(`detailOperate.like`):T(D.static?.like_cnt):A(`detailOperate.like`)})]}),x(n,{className:`w-[25%] h-full flex flex-col items-center justify-center ${N?`opacity-50 cursor-not-allowed`:`cursor-pointer`}`,onClick:Z,children:[D.collect?b(f,{className:`w-[20px] h-[20px]`}):b(d,{className:`w-[20px] h-[20px] text-text2`}),b(r,{className:`text-[12px] text-text2 leading-[20px]`,children:A(`detailOperate.collection`)})]}),x(n,{className:`w-[25%] h-full flex flex-col items-center justify-center cursor-pointer`,onClick:q,children:[b(h,{className:`w-[20px] h-[20px] text-text2`}),b(r,{className:`text-[12px] text-text2 leading-[20px]`,children:A(`detailOperate.share`)})]})]})}function T(e){let t=Number(e||0);return Number.isNaN(t)||t<=0?`0`:t>=1e4?`${(t/1e4).toFixed(1)}w`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function E(e){if(e==null)return 0;if(typeof e==`number`)return e;let t=Number(e);return Number.isNaN(t)?0:t}export{w as DetailOperate};
@@ -1,2 +1,2 @@
1
1
 
2
- "use client";import{Box as e}from"../../ui/box.mjs";import{Sheet as t,SheetContent as n,SheetHeader as r,SheetTitle as i}from"../../ui/sheet.mjs";import{Switch as a}from"../../ui/switch.mjs";import{Text as o}from"../../ui/text.mjs";import{useKeepAliveState as s}from"../keep-scroll-position/index.mjs";import c from"../../../assets/icons/close.mjs";import l from"../../../assets/icons/common/right_arrow.mjs";import u from"../../ui/popup.mjs";import{useCardDecoration as d}from"../../../hooks/use-card-decoration.mjs";import{useCallback as f,useEffect as p,useMemo as m,useRef as h,useState as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";import{toast as b}from"sonner";import{useTranslations as x}from"next-intl";function S(e,t,n){return(e||[]).map((e,r)=>{let i=Number.parseInt(e?.id||``,10),a=Number.isNaN(i)?r+1:i,o=e?.id||``,s=Number.isNaN(i)&&o||n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:s}})}function C(e,t,n){return(e||[]).map((e,r)=>{let i=Number(e?.id),a=Number.isNaN(i)?r+1:i,o=n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:o}})}function w(e,t,n){return e<=0?n(`singleContent`):n(t===`1`?`completedSeriesTotal`:`ongoingSeriesTotal`,{total:e})}function T(e){return e.mode===`detail`?v(D,{information:e.information,series_num:e.series_num,onEpisodeChange:e.onEpisodeChange}):v(E,{open:e.open,variant:e.variant,title:e.title,updateStatus:e.updateStatus,summaryText:e.summaryText,seriesList:e.seriesList,activeEpisodeId:e.activeEpisodeId,showEpisodeTitle:e.showEpisodeTitle,onToggleTitle:e.onToggleTitle,onClose:e.onClose,onSelectEpisode:e.onSelectEpisode,popupBodyStyle:e.popupBodyStyle})}function E({open:s,variant:l,title:d,updateStatus:f,summaryText:_,seriesList:b,activeEpisodeId:C,showEpisodeTitle:T=!1,onToggleTitle:E,onClose:D,onSelectEpisode:O,popupBodyStyle:k}){let A=x(`components.common.seriesEpisodes`),j=!!E,M=j&&T,N=h(null),P=h(null),F=m(()=>S(b,`episode`,e=>A(`episodeLabel`,{episode:e})),[b,A]),I=m(()=>{if(F.length===0)return[];let e=[];return F.forEach((t,n)=>{let r=Math.floor(n/50);e[r]||(e[r]=[]),e[r].push(t)}),e},[F]),L=m(()=>{if(!C)return 0;let e=F.findIndex(e=>e.id===C);return e<0?0:Math.floor(e/50)},[C,F]),[R,z]=g(L);p(()=>{z(L)},[L]);let B=m(()=>typeof _==`string`&&_.trim()?_:w(F.length,f,A),[F.length,_,A,f]),V=d||A(`selectorTitle`);function H(){let e=N.current;if(e){P.current&&=(window.cancelAnimationFrame(P.current),null),e.scrollTop=0;try{e.scrollTo({top:0,left:0,behavior:`auto`})}catch{}P.current=window.requestAnimationFrame(()=>{P.current=null;let e=N.current;e&&(e.scrollTop=0)})}}p(()=>{s&&H()},[s,T,R]);function U(e){E&&(E(e),H())}function W(e){O?.(e.id,e.series_num),D()}let G=M?2:5,K=I.length>1?v(`div`,{className:`w-full flex gap-[8px] overflow-x-auto`,children:I.map((e,t)=>{if(e.length===0)return null;let n=t===R,r=t*50+1,i=Math.min((t+1)*50,F.length);return y(`div`,{className:`shrink-0 px-[16px] py-[6px] rounded-[16px] text-[14px] transition-colors cursor-pointer relative overflow-hidden ${n?`text-theme5 bg-bg2`:`text-text2 bg-bg2`}`,onClick:()=>{z(t),H()},children:[r,`-`,i,n&&v(`div`,{className:`absolute w-full h-full top-0 left-0 opacity-20 bg-theme5`})]},`series-group-${t}`)})}):null,q=y(`div`,{className:`pb-[8px] flex justify-between`,children:[v(`span`,{className:`text-[16px] text-text1`,children:B}),j&&y(`div`,{className:`flex items-center gap-[4px]`,children:[v(a,{size:`sm`,className:`data-checked:bg-theme5 h-[20px] w-[33px]`,checked:T,onCheckedChange:e=>{U(!!e)}}),v(`button`,{type:`button`,className:`text-[16px] text-text1`,onClick:()=>{U(!T)},children:A(`episodeTitle`)})]})]}),J=v(`div`,{className:`grid w-full gap-2 ${G===2?`grid-cols-2`:`grid-cols-5`}`,children:(I[R]||[]).map((e,t)=>{let n=!!(C&&e.id===C);return v(`button`,{type:`button`,"data-episode-id":e.id,onClick:()=>{W(e)},className:`flex items-center justify-center w-full h-[60px] rounded-[8px] border border-line1 border-solid text-[16px] cursor-pointer select-none transition-colors relative overflow-hidden ${n?`font-bold text-theme5 bg-line1`:`text-text1`} ${M?`h-[72px] px-[10px] text-[14px]`:``} ${t%G===0?``:`border-l-0`}`,children:M?v(`span`,{className:`leading-[22px] line-clamp-2`,children:e.title}):e.series_num},e.id)})});return l===`sheet`?v(t,{open:s,onOpenChange:e=>!e&&D(),children:y(n,{side:`bottom`,showCloseButton:!0,className:`min-h-[50vh] max-h-[70vh] bg-bg1 text-text1 rounded-t-2xl border-t border-white/10`,children:[v(r,{className:`pt-3 pb-0`,children:v(i,{className:`flex items-center justify-between text-lg text-text1`,children:V})}),y(`div`,{className:`px-4 pb-2 flex flex-col gap-3`,children:[K,q]}),v(`div`,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto px-4`,children:J})]})}):v(u,{open:s,onOpenChange:e=>{e||D()},showCloseButton:!1,className:`border-0 bg-transparent p-0`,children:y(e,{className:`w-full flex flex-col bg-bg1 px-[12px] text-text1`,style:{minHeight:`60vh`,...k},children:[y(e,{className:`flex justify-between items-center h-[48px]`,children:[v(o,{className:`text-[16px] font-bold text-text1`,children:V}),v(e,{className:`pl-[12px] h-full flex items-center`,onClick:D,children:v(c,{className:`w-[14px] h-[14px] text-text1 cursor-pointer`})})]}),y(e,{className:`flex-1 h-0 w-full pb-[12px] flex flex-col gap-3`,children:[K,q,v(e,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto`,children:J})]})]})})}function D({information:t,series_num:n,onEpisodeChange:r}){let i=x(`components.common`),{getTitleText:a}=d(),[c,u]=s(`detail-series-popup-${t.id}`,!1),[S,w]=s(`detail-series-title-toggle-${t.id}`,!1),T=m(()=>C((t.links||[]).map(e=>({id:e.id,name:e.name})),t.id||`episode`,e=>i(`seriesEpisodes.episodeLabel`,{episode:e})),[t.id,t.links,i]),D=t.update_status===`1`?i(`seriesEpisodes.completedSeriesTotal`,{total:t.links.length}):i(`seriesEpisodes.ongoingSeriesUpdatedTo`,{total:t.links.length}),O=m(()=>t.links[n-1]?.id||t.links[0]?.id||``,[t.links,n]);function k(e){if(typeof window>`u`)return;let{search:t,hash:n}=window.location;window.history.replaceState(window.history.state,``,`${e}${t}${n}`)}let A=h(null),j=f(e=>{let t=A.current?.querySelector(`[data-content-id="${e}"]`);t&&A.current&&A.current.scrollTo({left:t.offsetLeft-10,behavior:`smooth`})},[]);p(()=>{j(O)},[O,j]);let M=f(e=>{if(e!==n){if(!t.links[e-1]){b.error(i(`seriesEpisodes.episodeNotFound`));return}try{r(e);let n=a(t)||t.name||``,i=encodeURIComponent(n);k(`/video/${t.id}/${i}/episode/${e}`)}catch(e){console.error(`切换剧集失败`,e),b.error(i(`seriesEpisodes.episodeSwitchFailed`))}}},[a,t,r,n,i]),N=f(e=>{setTimeout(()=>{j(e)},200)},[j]),[P,F]=g(`auto`),I=f(()=>{if(typeof window>`u`)return;let e=document.getElementById(`selectPopupPosition`),t=window.visualViewport?.height||window.innerHeight;if(e){let n=Math.max(0,t-e.offsetTop);n>0&&F(`${n}px`)}},[]);return p(()=>{if(!c)return;I();let e=()=>{I()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[I,c]),T.length===0?null:y(_,{children:[y(e,{className:`w-full mt-[16px] flex flex-col items-end mb-[4px]`,children:[y(e,{className:`w-fit flex items-center px-[12px] h-[28px]`,onClick:()=>u(!0),children:[v(o,{className:`text-[14px] text-text2 leading-[20px]`,children:D}),v(l,{className:`w-[11px] h-[18px] ml-[4px] text-text2`})]}),v(`div`,{ref:A,className:`w-full mt-[12px] overflow-x-auto px-[12px] flex gap-x-[8px] ${S?`h-[76px]`:`h-[60px]`}`,children:T.map((e,t)=>v(`div`,{"data-content-id":e.id,className:`shrink-0 h-[full] px-[18px] rounded-[6px] border border-line1 flex items-center ${S?`w-[162px]`:`w-[60px] !px-[0] justify-center`} ${e.id===O?`!border-theme5 bg-line1`:``}`,onClick:()=>M(t+1),children:v(o,{className:`text-[16px] text-text1 leading-[22px] line-clamp-2 ${e.id===O?`font-bold !text-theme5`:``}`,children:S?e.title:e.series_num})},e.id))})]}),v(E,{title:i(`seriesEpisodes.selectorTitle`),variant:`popup`,open:c,updateStatus:t.update_status,summaryText:D,seriesList:(t.links||[]).map(e=>({id:e.id,name:e.name})),activeEpisodeId:O,showEpisodeTitle:S,onToggleTitle:e=>{w(e),N(O)},onClose:()=>u(!1),onSelectEpisode:(e,t)=>{u(!1),M(t),j(e)},popupBodyStyle:{height:P}})]})}export{T as SeriesEpisodes};
2
+ "use client";import{Box as e}from"../../ui/box.mjs";import{Sheet as t,SheetContent as n,SheetHeader as r,SheetTitle as i}from"../../ui/sheet.mjs";import{Switch as a}from"../../ui/switch.mjs";import{Text as o}from"../../ui/text.mjs";import{useKeepAliveState as s}from"../keep-scroll-position/index.mjs";import c from"../../../assets/icons/close.mjs";import l from"../../../assets/icons/common/right_arrow.mjs";import u from"../../ui/popup.mjs";import{useCardDecoration as d}from"../../../hooks/use-card-decoration.mjs";import{useCallback as f,useEffect as p,useMemo as m,useRef as h,useState as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";import{toast as b}from"sonner";import{useTranslations as x}from"next-intl";function S(e,t,n){return(e||[]).map((e,r)=>{let i=Number.parseInt(e?.id||``,10),a=Number.isNaN(i)?r+1:i,o=e?.id||``,s=Number.isNaN(i)&&o||n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:s}})}function C(e,t,n){return(e||[]).map((e,r)=>{let i=Number(e?.id),a=Number.isNaN(i)?r+1:i,o=n(a);return{id:e?.id||`${t}-${a}`,series_num:a,title:o}})}function w(e,t,n){return e<=0?n(`singleContent`):n(t===`1`?`completedSeriesTotal`:`ongoingSeriesTotal`,{total:e})}function T(e){return e.mode===`detail`?v(D,{information:e.information,series_num:e.series_num,onEpisodeChange:e.onEpisodeChange}):v(E,{open:e.open,variant:e.variant,title:e.title,updateStatus:e.updateStatus,summaryText:e.summaryText,seriesList:e.seriesList,activeEpisodeId:e.activeEpisodeId,showEpisodeTitle:e.showEpisodeTitle,onToggleTitle:e.onToggleTitle,onClose:e.onClose,onSelectEpisode:e.onSelectEpisode,popupBodyStyle:e.popupBodyStyle})}function E({open:s,variant:l,title:d,updateStatus:f,summaryText:_,seriesList:b,activeEpisodeId:C,showEpisodeTitle:T=!1,onToggleTitle:E,onClose:D,onSelectEpisode:O,popupBodyStyle:k}){let A=x(`components.common.seriesEpisodes`),j=!!E,M=j&&T,N=h(null),P=h(null),F=m(()=>S(b,`episode`,e=>A(`episodeLabel`,{episode:e})),[b,A]),I=m(()=>{if(F.length===0)return[];let e=[];return F.forEach((t,n)=>{let r=Math.floor(n/50);e[r]||(e[r]=[]),e[r].push(t)}),e},[F]),L=m(()=>{if(!C)return 0;let e=F.findIndex(e=>e.id===C);return e<0?0:Math.floor(e/50)},[C,F]),[R,z]=g(L);p(()=>{z(L)},[L]);let B=m(()=>typeof _==`string`&&_.trim()?_:w(F.length,f,A),[F.length,_,A,f]),V=d||A(`selectorTitle`);function H(){let e=N.current;if(e){P.current&&=(window.cancelAnimationFrame(P.current),null),e.scrollTop=0;try{e.scrollTo({top:0,left:0,behavior:`auto`})}catch{}P.current=window.requestAnimationFrame(()=>{P.current=null;let e=N.current;e&&(e.scrollTop=0)})}}p(()=>{s&&H()},[s,T,R]);function U(e){E&&(E(e),H())}function W(e){O?.(e.id,e.series_num),D()}let G=M?2:5,K=I.length>1?v(`div`,{className:`shrink-0 w-full flex gap-[8px] overflow-x-auto`,children:I.map((e,t)=>{if(e.length===0)return null;let n=t===R,r=t*50+1,i=Math.min((t+1)*50,F.length);return y(`div`,{className:`shrink-0 px-[16px] py-[6px] rounded-[16px] text-[14px] transition-colors cursor-pointer relative overflow-hidden ${n?`text-theme5 bg-bg2`:`text-text2 bg-bg2`}`,onClick:()=>{z(t),H()},children:[r,`-`,i,n&&v(`div`,{className:`absolute w-full h-full top-0 left-0 opacity-20 bg-theme5`})]},`series-group-${t}`)})}):null,q=y(`div`,{className:`pb-[8px] flex justify-between`,children:[v(`span`,{className:`text-[16px] text-text1`,children:B}),j&&y(`div`,{className:`flex items-center gap-[4px]`,children:[v(a,{size:`sm`,className:`data-checked:bg-theme5 h-[20px] w-[33px]`,checked:T,onCheckedChange:e=>{U(!!e)}}),v(`button`,{type:`button`,className:`text-[16px] text-text1`,onClick:()=>{U(!T)},children:A(`episodeTitle`)})]})]}),J=v(`div`,{className:`grid w-full gap-2 ${G===2?`grid-cols-2`:`grid-cols-5`}`,children:(I[R]||[]).map((e,t)=>{let n=!!(C&&e.id===C);return v(`button`,{type:`button`,"data-episode-id":e.id,onClick:()=>{W(e)},className:`flex items-center justify-center w-full h-[60px] rounded-[8px] border border-line1 border-solid text-[16px] cursor-pointer select-none transition-colors relative overflow-hidden ${n?`font-bold text-theme5 bg-line1`:`text-text1`} ${M?`h-[72px] px-[10px] text-[14px]`:``} ${t%G===0?``:`border-l-0`}`,children:M?v(`span`,{className:`leading-[22px] line-clamp-2`,children:e.title}):e.series_num},e.id)})});return l===`sheet`?v(t,{open:s,onOpenChange:e=>!e&&D(),children:y(n,{side:`bottom`,showCloseButton:!0,className:`min-h-[50vh] max-h-[70vh] bg-bg1 text-text1 rounded-t-2xl border-t border-white/10`,children:[v(r,{className:`pt-3 pb-0`,children:v(i,{className:`flex items-center justify-between text-lg text-text1`,children:V})}),y(`div`,{className:`px-4 pb-2 flex flex-col gap-3`,children:[K,q]}),v(`div`,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto px-4`,children:J})]})}):v(u,{open:s,onOpenChange:e=>{e||D()},showCloseButton:!1,className:`border-0 bg-transparent p-0`,children:y(e,{className:`w-full flex flex-col bg-bg1 px-[12px] text-text1`,style:{height:`70vh`,...k,maxHeight:`70vh`},children:[y(e,{className:`shrink-0 flex justify-between items-center h-[48px]`,children:[v(o,{className:`text-[16px] font-bold text-text1`,children:V}),v(e,{className:`pl-[12px] h-full flex items-center`,onClick:D,children:v(c,{className:`w-[14px] h-[14px] text-text1 cursor-pointer`})})]}),y(e,{className:`flex-1 h-0 w-full pb-[12px] flex flex-col gap-3`,children:[K,q,v(e,{ref:N,className:`flex-1 h-0 pt-[4px] pb-[12px] overflow-y-auto`,children:J})]})]})})}function D({information:t,series_num:n,onEpisodeChange:r}){let i=x(`components.common`),{getTitleText:a}=d(),[c,u]=s(`detail-series-popup-${t.id}`,!1),[S,w]=s(`detail-series-title-toggle-${t.id}`,!1),T=m(()=>C((t.links||[]).map(e=>({id:e.id,name:e.name})),t.id||`episode`,e=>i(`seriesEpisodes.episodeLabel`,{episode:e})),[t.id,t.links,i]),D=t.update_status===`1`?i(`seriesEpisodes.completedSeriesTotal`,{total:t.links.length}):i(`seriesEpisodes.ongoingSeriesUpdatedTo`,{total:t.links.length}),O=m(()=>t.links[n-1]?.id||t.links[0]?.id||``,[t.links,n]);function k(e){if(typeof window>`u`)return;let{search:t,hash:n}=window.location;window.history.replaceState(window.history.state,``,`${e}${t}${n}`)}let A=h(null),j=f(e=>{let t=A.current?.querySelector(`[data-content-id="${e}"]`);t&&A.current&&A.current.scrollTo({left:t.offsetLeft-10,behavior:`smooth`})},[]);p(()=>{j(O)},[O,j]);let M=f(e=>{if(e!==n){if(!t.links[e-1]){b.error(i(`seriesEpisodes.episodeNotFound`));return}try{r(e);let n=a(t)||t.name||``,i=encodeURIComponent(n);k(`/video/${t.id}/${i}/episode/${e}`)}catch(e){console.error(`切换剧集失败`,e),b.error(i(`seriesEpisodes.episodeSwitchFailed`))}}},[a,t,r,n,i]),N=f(e=>{setTimeout(()=>{j(e)},200)},[j]),[P,F]=g(`70vh`),I=f(()=>{if(typeof window>`u`)return;let e=document.getElementById(`selectPopupPosition`),t=window.visualViewport?.height||window.innerHeight;if(!e){F(`70vh`);return}let n=Math.max(0,t-e.offsetTop);if(n<=0){F(`70vh`);return}F(`${n}px`)},[]);return p(()=>{if(!c)return;I();let e=()=>{I()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[I,c]),T.length===0?null:y(_,{children:[y(e,{className:`w-full mt-[16px] flex flex-col items-end mb-[4px]`,children:[y(e,{className:`w-fit flex items-center px-[12px] h-[28px]`,onClick:()=>u(!0),children:[v(o,{className:`text-[14px] text-text2 leading-[20px]`,children:D}),v(l,{className:`w-[11px] h-[18px] ml-[4px] text-text2`})]}),v(`div`,{ref:A,className:`w-full mt-[12px] overflow-x-auto px-[12px] flex gap-x-[8px] ${S?`h-[76px]`:`h-[60px]`}`,children:T.map((e,t)=>v(`div`,{"data-content-id":e.id,className:`shrink-0 h-[full] px-[18px] rounded-[6px] border border-line1 flex items-center ${S?`w-[162px]`:`w-[60px] !px-[0] justify-center`} ${e.id===O?`!border-theme5 bg-line1`:``}`,onClick:()=>M(t+1),children:v(o,{className:`text-[16px] text-text1 leading-[22px] line-clamp-2 ${e.id===O?`font-bold !text-theme5`:``}`,children:S?e.title:e.series_num})},e.id))})]}),v(E,{title:i(`seriesEpisodes.selectorTitle`),variant:`popup`,open:c,updateStatus:t.update_status,summaryText:D,seriesList:(t.links||[]).map(e=>({id:e.id,name:e.name})),activeEpisodeId:O,showEpisodeTitle:S,onToggleTitle:e=>{w(e),N(O)},onClose:()=>u(!1),onSelectEpisode:(e,t)=>{u(!1),M(t),j(e)},popupBodyStyle:{height:P}})]})}export{T as SeriesEpisodes};
@@ -6,7 +6,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
6
6
  //#region components/ui/badge.d.ts
7
7
  /** badgeVariants 工具定义。 */
8
8
  declare const badgeVariants: (props?: ({
9
- variant?: "default" | "link" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
9
+ variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
10
10
  } & class_variance_authority_types0.ClassProp) | undefined) => string;
11
11
  /** Badge 组件。 */
12
12
  declare function Badge({
@@ -7,7 +7,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
7
7
  //#region components/ui/button.d.ts
8
8
  /** buttonVariants 工具定义。 */
9
9
  declare const buttonVariants: (props?: ({
10
- variant?: "default" | "link" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
10
+ variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
11
11
  size?: "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
12
12
  } & class_variance_authority_types0.ClassProp) | undefined) => string;
13
13
  /** Button 组件属性。 */
@@ -1,11 +1,11 @@
1
1
 
2
2
  import * as React from "react";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
- import NextImage from "next/image";
4
+ import Image from "next/image";
5
5
 
6
6
  //#region components/ui/image.d.ts
7
7
  /** BaseImageProps 属性定义。 */
8
- type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof NextImage>, 'className' | 'src' | 'alt' | 'width' | 'height' | 'loading' | 'priority' | 'fill' | 'style'>;
8
+ type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof Image>, 'className' | 'src' | 'alt' | 'width' | 'height' | 'loading' | 'priority' | 'fill' | 'style'>;
9
9
  type CommonImageProps = BaseImageProps & {
10
10
  /** 图片地址,支持普通 URL、默认资源路径和加密地址。 */src: string; /** 图片替代文本。 */
11
11
  alt?: string; /** 图片类名。 */
@@ -27,6 +27,6 @@ type ImagePropsWithSize = CommonImageProps & {
27
27
  /** ImageProps 属性定义。 */
28
28
  type ImageProps = ImagePropsWithFill | ImagePropsWithSize;
29
29
  /** 图片组件:支持 bnc 解密、默认资源域名拼接与错误占位。 */
30
- declare function Image(props: ImageProps): react_jsx_runtime0.JSX.Element;
30
+ declare function Image$1(props: ImageProps): react_jsx_runtime0.JSX.Element;
31
31
  //#endregion
32
- export { BaseImageProps, CommonImageProps, Image, ImageProps, ImagePropsWithFill, ImagePropsWithSize };
32
+ export { BaseImageProps, CommonImageProps, Image$1 as Image, ImageProps, ImagePropsWithFill, ImagePropsWithSize };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@funhub/platform",
3
3
  "type": "module",
4
- "version": "0.1.76",
4
+ "version": "0.1.77",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "**/*.css"