@funhub/platform 0.1.90 → 0.1.92
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.
- package/dist/components/biz/business/image-text-recommend/client.mjs +1 -1
- package/dist/components/biz/business/search-history/client.mjs +1 -1
- package/dist/components/biz/business/tab-bar/client.d.mts +1 -0
- package/dist/components/biz/business/tab-bar/client.mjs +1 -1
- package/dist/components/ui/button.d.mts +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import e from"../../../../utils/get-res-url.mjs";import{pContentBatchGetVideoDetail as t,pContentGetPopularVideoList as n}from"../../../../service/generated/client.mjs";import{pContentBatchGetVideoDetailKey as r,pContentGetPopularVideoListKey as i}from"../../../../service/generated/tanstack.mjs";import{Image as a}from"../../../ui/image.mjs";import{Box as o}from"../../../ui/box.mjs";import{Text as s}from"../../../ui/text.mjs";import{IMAGE_TEXT_RECOMMEND_FIXED_BATCH_SIZE as c,buildImageTextRecommendChosenTags as l,buildImageTextRecommendRemoteMap as u,buildImageTextRecommendSmartPicked as d,getImageTextRecommendFixedIds as f,getImageTextRecommendLayoutTags as ee,resolveImageTextRecommendVideoId as te}from"../../../../hooks/image-text-recommend.mjs";import{useRequest as p}from"../../../../hooks/query/use-query.mjs";import ne from"../../../../assets/images/frame.mjs";import re from"../../../../assets/images/subscript.mjs";import{buildSmartPopularQuery as ie,buildStableChosenTags as ae}from"./shared/query.mjs";import{useCallback as m,useEffect as h,useMemo as g,useRef as oe,useState as _}from"react";import{Fragment as se,jsx as v,jsxs as y}from"react/jsx-runtime";import{useTranslations as ce}from"next-intl";import le from"next/link";const b=[];function x(e){return typeof e==`string`?e:e.src}function ue(t,n){if(!t||!t.trim())return x(n);if(t.startsWith(`http`)||t.startsWith(`//`)||t.startsWith(`data:`))return t;let r=e();return r?`${r}${t.startsWith(`/`)?t:`/${t}`}`:t}function S(e){if(e==null)return``;let t=e;return t.img_y||t.media?.img_y||``}function C(e){return e==null?``:e.name||``}function w(e){let
|
|
2
|
+
"use client";import e from"../../../../utils/get-res-url.mjs";import{pContentBatchGetVideoDetail as t,pContentGetPopularVideoList as n}from"../../../../service/generated/client.mjs";import{pContentBatchGetVideoDetailKey as r,pContentGetPopularVideoListKey as i}from"../../../../service/generated/tanstack.mjs";import{Image as a}from"../../../ui/image.mjs";import{Box as o}from"../../../ui/box.mjs";import{Text as s}from"../../../ui/text.mjs";import{IMAGE_TEXT_RECOMMEND_FIXED_BATCH_SIZE as c,buildImageTextRecommendChosenTags as l,buildImageTextRecommendRemoteMap as u,buildImageTextRecommendSmartPicked as d,getImageTextRecommendFixedIds as f,getImageTextRecommendLayoutTags as ee,resolveImageTextRecommendVideoId as te}from"../../../../hooks/image-text-recommend.mjs";import{useRequest as p}from"../../../../hooks/query/use-query.mjs";import ne from"../../../../assets/images/frame.mjs";import re from"../../../../assets/images/subscript.mjs";import{buildSmartPopularQuery as ie,buildStableChosenTags as ae}from"./shared/query.mjs";import{useCallback as m,useEffect as h,useMemo as g,useRef as oe,useState as _}from"react";import{Fragment as se,jsx as v,jsxs as y}from"react/jsx-runtime";import{useTranslations as ce}from"next-intl";import le from"next/link";const b=[];function x(e){return typeof e==`string`?e:e.src}function ue(t,n){if(!t||!t.trim())return x(n);if(t.startsWith(`http`)||t.startsWith(`//`)||t.startsWith(`data:`))return t;let r=e();return r?`${r}${t.startsWith(`/`)?t:`/${t}`}`:t}function S(e){if(e==null)return``;let t=e;return t.img_y||t.media?.img_y||``}function C(e){return e==null?``:e.name||``}function w(e,t=!1){let n=e,r=t?n.type:n.content_type;return typeof r==`number`?r:n.is_more_link===!0||Number(n.episode_cnt||n.episode_count||n.episodes?.length||n.links?.length||0)>1?2:1}function T(e){if(!Number.isFinite(e)||e<=0)return``;let t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=e=>String(e).padStart(2,`0`);return n>0?`${a(n)}:${a(r)}:${a(i)}`:`${a(r)}:${a(i)}`}function E(e,t){let n=e,r=n?.links?.length??0;if(!Number.isFinite(r)||r<=0)return``;let i=n.update_status;return t(r,i===0||i===`0`)}function de(e,t,n){return e?w(e,n)===2&&t?E(e,t):T(Number(e.duration??e.detail?.duration??0)):``}function fe(e,t){if(!(e??``).trim())return``;let n=encodeURIComponent((t??``).trim()||``);return`/video/${e.trim()}/${n}/episode/1`}function pe(e,t){if(!e)return``;let n=e,r=t?Number(n.static?.browse_count??0):Number(n.browse_count??0);if(!Number.isFinite(r)||r<=0)return``;if(r>=1e6){let e=(r/1e6).toFixed(1);return e.endsWith(`.0`)?`${e.slice(0,-2)}M`:`${e}M`}if(r>=1e3){let e=(r/1e3).toFixed(1);return e.endsWith(`.0`)?`${e.slice(0,-2)}k`:`${e}k`}return Math.floor(r).toString()}function me(){let e=new Date,t=new Date(e);return t.setHours(24,0,0,0),t.getTime()-e.getTime()}function D(e){let{title:w,items:T=b,commonPlayCount:E,commonEpisodes:D,layout:O,mode:k=`renderer`}=e,A=ce(`components.biz.business.imageTextRecommend`),j=k===`renderer`,M=k===`editor`,[N,P]=_({}),[F,I]=_([]),[L,R]=_(0),[z,B]=_(void 0),V=oe(null),H=!!O?.enabled,U=g(()=>ee(O),[O]),W=T?.length??0,G=g(()=>f(T,H),[H,T]),K=g(()=>G.slice(0,c),[G]),q=g(()=>ae(U,W),[U,W]),J=g(()=>ie(q,W),[q,W]),{data:Y}=p(i(J),()=>n(J),{enabled:j&&!M&&H&&T.length>0,staleTime:1/0}),{data:X}=p(r({ids:K}),()=>t({ids:K}),{enabled:j&&!M&&!H&&K.length>0,staleTime:1/0}),Z=g(()=>H&&W>c?Math.ceil(W/c):G.length>0?Math.ceil(G.length/c):0,[H,W,G.length]),Q=m((e,t)=>A(t?`updatedTo`:`allEpisodes`,{count:e}),[A]),he=m(async(e,n)=>{if(e.length===0)return;let r=u((await t({ids:e})).data?.videos??[]);P(e=>n?{...e,...r}:r)},[]);h(()=>{if(M)return;if(H){let e=Y?.data?.videos??[];W>c?(I(e.slice(0,c)),B(Y?.data?.cursor),R(e.length>0?1:0)):(I(d(e,q,W)),R(0)),P({});return}if(K.length===0){P({}),I([]),R(0),B(void 0);return}let e=X?.data?.videos??[];P(u(e)),I([]),B(void 0),R(e.length>0?1:0)},[M,H,Y,X,q,K,W]),h(()=>{if(M||Z<1||L<1||L>=Z)return;let e=V.current;if(!e)return;let t=new IntersectionObserver(e=>{let[t]=e;if(!t?.isIntersecting)return;let r=L;if(H){let e=l(U,W);n({page_size:c,cursor:z,tags:e.length?Array.from(new Set(e)):void 0}).then(e=>{let t=e.data?.videos??[];I(e=>[...e,...t.slice(0,c)]),B(e.data?.cursor),R(r+1)}).catch(()=>{})}else{let e=r*c,t=G.slice(e,e+c);t.length>0&&(he(t,!0),R(r+1))}},{root:null,rootMargin:`0px`,threshold:0});return t.observe(e),()=>t.disconnect()},[M,H,G,L,Z,U,W,z,he]),h(()=>{if(M||!H||W<=0)return;let e,t=!1;function r(){e=window.setTimeout(()=>{let e=l(U,W);n({page_size:Math.max(20,W*10),tags:e.length?Array.from(new Set(e)):void 0}).then(n=>{t||I(d(n.data?.videos??[],e,W))}).catch(()=>{t||I([])}).finally(()=>{t||r()})},me())}return r(),()=>{t=!0,e!==void 0&&window.clearTimeout(e)}},[M,H,U,W]);let $=g(()=>!T||T.length===0?b:M?T:H&&W>c?T.slice(0,F.length):T,[T,M,H,W,F.length]),ge=g(()=>$.length?$.map((e,t)=>{let n=String(e?.contentId??``).trim(),r=H?F[t]:n?N[n]:void 0,i=H?r?C(r):(e?.title??``).trim():(e?.title??``).trim()||(r?C(r):``),a=(e?.cover??``).trim(),o=H?S(r)||a:a||(e?.useVideoPoster?S(r):``),s=H&&String(r?.description??r?.content_description??``).trim()||(e?.contentDescription??``).trim(),c=de(r,Q,H),l=pe(r,H);return{...e,contentId:n||(r?te(r):``),title:i,cover:o,contentDescription:s,episodeOrDurationText:c,playCountText:l}}):b,[Q,H,$,N,F]);if(!T||T.length===0)return null;let _e=L>=1&&L<Z?H?F.length-2:L*c-2:-1;return y(o,{className:M?`bg-bg1 px-3 py-3 pointer-events-none`:`bg-bg1 px-3 py-3`,children:[w&&v(o,{className:`mb-3 flex items-center justify-between`,children:v(s,{className:`text-[18px] font-bold text-text1 leading-[26px]`,children:w})}),v(o,{className:`flex overflow-x-auto pb-2 scrollbar-hide space-x-2`,children:ge.map((e,t)=>{let n=H?E:e.showPlayCount??!1,r=(e.playCountText??``).trim(),i=r!==``,c=H?D:e.showEpisodes??!1,l=(e.episodeOrDurationText??``).trim(),u=c&&l!==``,d=k===`renderer`?fe(e.contentId??``,e.title??``):``,f=y(se,{children:[y(o,{className:`relative rounded-lg overflow-hidden bg-bg2 w-[116px] h-[134px]`,children:[M||e.cover?v(a,{src:ue(e.cover,ne),alt:e.title??``,fill:!0,className:`object-cover`}):v(o,{className:`w-full h-full flex items-center justify-center`,children:v(s,{className:`text-text3 text-xs`,children:A(`noCover`)})}),!H&&(e.badge??``).trim()?v(o,{className:`absolute top-0 right-0 w-8 h-8`,children:v(a,{src:(e.badge??``).trim()||x(re),alt:``,fill:!0,sizes:`32px`,className:`object-contain object-right-top`,unoptimized:!0})}):null,y(o,{className:`absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/80 to-transparent pb-1 pt-3 px-1 flex justify-between items-center gap-1`,children:[v(o,{className:`flex items-center min-w-0 shrink`,children:n&&i?y(o,{className:`flex items-center gap-1 rounded bg-overlay px-1 py-0`,children:[v(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`10`,viewBox:`0 0 12 10`,fill:`none`,className:`shrink-0`,"aria-hidden":!0,children:v(`path`,{d:`M7.56 5.18437L5.013 6.56737C4.893 6.63337 4.761 6.66937 4.638 6.66937C4.269 6.66937 4.002 6.38737 4.002 5.99737V3.28237C4.002 2.89237 4.269 2.61037 4.638 2.61037C4.764 2.61037 4.893 2.64637 5.013 2.70937L7.572 4.09237C7.803 4.21837 7.938 4.41637 7.938 4.63237C7.938 4.85137 7.8 5.05537 7.56 5.18437ZM9.807 9.27637L2.133 8.52937C0.954 8.52937 0 7.57537 0 6.39637V2.79937C0 1.62037 0.954 0.666368 2.133 0.666368L9.81 0.000367165C10.989 0.000367165 11.943 0.954367 11.943 2.13337V7.14337C11.9422 7.70935 11.7168 8.25188 11.3163 8.65181C10.9158 9.05174 10.373 9.27637 9.807 9.27637ZM10.875 2.13337C10.875 1.99351 10.8475 1.85502 10.7939 1.72581C10.7404 1.5966 10.662 1.47919 10.5631 1.3803C10.4642 1.2814 10.3468 1.20296 10.2176 1.14944C10.0883 1.09591 9.94986 1.06837 9.81 1.06837L2.133 1.73437C1.99314 1.73437 1.85465 1.76191 1.72544 1.81544C1.59623 1.86896 1.47883 1.9474 1.37993 2.0463C1.28104 2.14519 1.20259 2.2626 1.14907 2.39181C1.09555 2.52102 1.068 2.65951 1.068 2.79937V6.39637C1.068 6.67882 1.1802 6.94971 1.37993 7.14944C1.57966 7.34916 1.85054 7.46137 2.133 7.46137L9.807 8.20837C9.94686 8.20837 10.0853 8.18082 10.2146 8.1273C10.3438 8.07378 10.4612 7.99533 10.5601 7.89644C10.659 7.79754 10.7374 7.68014 10.7909 7.55093C10.8445 7.42171 10.872 7.28323 10.872 7.14337V2.13337H10.875Z`,fill:`white`})}),v(s,{className:`text-white text-[12px] leading-[20px]`,children:r})]}):null}),v(o,{className:`flex items-center shrink-0`,children:u?v(s,{className:`text-white text-[12px] leading-[20px]`,children:l}):null})]})]}),v(o,{className:`mt-2 py-2`,children:v(s,{className:`text-[16px] text-text1 font-bold leading-[24px] line-clamp-1`,children:e.title})})]});return v(o,{ref:t===_e?V:void 0,className:`flex-shrink-0 w-[116px]`,children:d?v(le,{href:d,className:`block`,children:f}):f},t)})})]})}export{D as ImageTextRecommendClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Button as e}from"../../../ui/button.mjs";import t from"../../../../utils/event-bus.mjs";import{Box as n}from"../../../ui/box.mjs";import{Text as r}from"../../../ui/text.mjs";import{eventKey as i}from"../../../../constants/event-key.mjs";import{DeleteConfirmDialog as a}from"../../../common/delete-confirm-dialog/delete-confirm-dialog.mjs";import{useCallback as o,useEffect as s,useMemo as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{usePathname as f,useRouter as p,useSearchParams as m}from"next/navigation";function h(e,t){let n=Array.from(e);return n.length<=t?e:`${n.slice(0,t).join(``)}...`}function g(g){let{title:_,rows:v=1,clearText:y,confirmDescription:b,storageKey:x=`guest`,onHistoryClick:S,mode:C=`renderer`}=g,w=_??`搜索历史`,T=y??`清空`,E=b??`确定要清除所有搜索历史吗?`,D=c(()=>[`搜索历史1`,`搜索历史2`,`搜索历史3`],[]),[O,k]=l([]),[A,j]=l(!1),M=p(),N=f(),P=m(),F=`search_history_${x}`,I=o(()=>{let e=[];try{let t=localStorage.getItem(F);if(t)try{let n=JSON.parse(t);e=Array.isArray(n)?n:[]}catch{e=[]}k(e)}catch(e){console.error(`Failed to parse search history`,e),k([])}},[F]);s(()=>(I(),t.on(i.SEARCH_HISTORY_UPDATE,I),()=>t.off(i.SEARCH_HISTORY_UPDATE,I)),[I]);let L=()=>{k([]),localStorage.removeItem(F),j(!1),t.emit(i.SEARCH_HISTORY_UPDATE)},R=c(()=>(O.length?O:C===`editor`?D:[]).slice(0,v*10),[O,C,D,v]);if(R.length===0)return null;let z=e=>{if(S){S(e);return}let t=new URLSearchParams(P.toString());t.set(`q`,e);let n=N.includes(`/search-result`)?N:`/search-result`;M.push(`${n}?${t.toString()}`)};return d(n,{className:`px-4 py-2`,children:[d(n,{className:`flex justify-between items-center mb-2`,children:[u(r,{className:`text-[16px] font-bold text-text1`,children:w}),u(e,{variant:`ghost`,size:`sm`,className:`text-text3 text-[12px] p-0 h-auto`,onClick:()=>j(!0),children:T})]}),u(n,{className:`flex flex-wrap gap-2 overflow-hidden`,style:{maxHeight:`${v*
|
|
2
|
+
"use client";import{Button as e}from"../../../ui/button.mjs";import t from"../../../../utils/event-bus.mjs";import{Box as n}from"../../../ui/box.mjs";import{Text as r}from"../../../ui/text.mjs";import{eventKey as i}from"../../../../constants/event-key.mjs";import{DeleteConfirmDialog as a}from"../../../common/delete-confirm-dialog/delete-confirm-dialog.mjs";import{useCallback as o,useEffect as s,useMemo as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{usePathname as f,useRouter as p,useSearchParams as m}from"next/navigation";function h(e,t){let n=Array.from(e);return n.length<=t?e:`${n.slice(0,t).join(``)}...`}function g(g){let{title:_,rows:v=1,clearText:y,confirmDescription:b,storageKey:x=`guest`,onHistoryClick:S,mode:C=`renderer`}=g,w=_??`搜索历史`,T=y??`清空`,E=b??`确定要清除所有搜索历史吗?`,D=c(()=>[`搜索历史1`,`搜索历史2`,`搜索历史3`],[]),[O,k]=l([]),[A,j]=l(!1),M=p(),N=f(),P=m(),F=`search_history_${x}`,I=o(()=>{let e=[];try{let t=localStorage.getItem(F);if(t)try{let n=JSON.parse(t);e=Array.isArray(n)?n:[]}catch{e=[]}k(e)}catch(e){console.error(`Failed to parse search history`,e),k([])}},[F]);s(()=>(I(),t.on(i.SEARCH_HISTORY_UPDATE,I),()=>t.off(i.SEARCH_HISTORY_UPDATE,I)),[I]);let L=()=>{k([]),localStorage.removeItem(F),j(!1),t.emit(i.SEARCH_HISTORY_UPDATE)},R=c(()=>(O.length?O:C===`editor`?D:[]).slice(0,v*10),[O,C,D,v]);if(R.length===0)return null;let z=e=>{if(S){S(e);return}let t=new URLSearchParams(P.toString());t.set(`q`,e);let n=N.includes(`/search-result`)?N:`/search-result`;M.push(`${n}?${t.toString()}`)};return d(n,{className:`px-4 py-2`,children:[d(n,{className:`flex justify-between items-center mb-2`,children:[u(r,{className:`text-[16px] font-bold text-text1`,children:w}),u(e,{variant:`ghost`,size:`sm`,className:`text-text3 text-[12px] p-0 h-auto`,onClick:()=>j(!0),children:T})]}),u(n,{className:`flex flex-wrap gap-2 overflow-hidden`,style:{maxHeight:`${v*30}px`},children:R.map((e,t)=>u(n,{className:`px-3 py-1 bg-bg2 rounded-full cursor-pointer`,onClick:()=>z(e),children:u(r,{className:`text-[14px] text-text2`,children:h(e,8)})},t))}),u(a,{open:A,onOpenChange:j,onConfirm:L,title:``,description:E})]})}export{g as SearchHistoryClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import{
|
|
2
|
+
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import{useMemo as r}from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";import o from"next/link";import{usePathname as s}from"next/navigation";const c=[];function l(e){return e.split(`?`)[0].replace(/\/+$/,``)||`/`}function u(e){if(e.configType===1)switch(e.functionPageType){case`搜索`:return`/search`;case`个人中心`:return`/user/mine`;case`内容列表`:return`/video-list?tags=${e.tags}&title=${e.title}`;default:return`/`}let t=(e.domainId??``).toString().trim();return t?`/domain/${t}`:`/`}function d(e,t){let n=l(t);if(e.configType===1){let t=l(u(e).split(`?`)[0]);return n===t||n.startsWith(`${t}/`)}let r=e.domainId.trim();if(!r)return n===`/`||n.startsWith(`/category/`);let i=`/domain/${r}`;return n===i||n.startsWith(`${i}/`)}function f(e,t){return e.findIndex(e=>d(e,t))}function p(l){let{items:d=c,mode:p=`renderer`}=l,m=s(),h=r(()=>{if(p===`editor`)return 0;let e=f(d??[],m);return e>=0?e:0},[d,m,p]),g=r(()=>(d??[]).some(e=>e.label.trim()!==``),[d]);if(!d?.length)return null;function _(e){p===`editor`&&e.preventDefault()}let v=`flex min-w-0 flex-1 cursor-pointer flex-col items-center justify-center ${g?`gap-1`:``}`;return i(t,{className:`fixed bottom-0 left-0 right-0 z-50 safe-area-bottom bg-bg1 border-t border-line1 backdrop-blur-[2px] py-3 shadow-[0px_-4px_10px_0px_rgba(0,0,0,0.02)]`,children:i(t,{className:`flex w-full items-center`,children:d.map((r,s)=>{let c=h===s,l=c?r.activeIcon:r.icon,d=r.label;return a(o,{href:u(r),className:v,"data-index":s,onClick:_,children:[i(t,{className:`relative size-[22px] shrink-0`,children:l?i(e,{src:l,alt:d,fill:!0,className:`object-contain`}):i(t,{"data-active":c,className:`size-full rounded-sm bg-text3 data-[active=true]:bg-theme5`})}),g&&i(n,{"data-active":c,className:`truncate text-center text-[10px] leading-[10px] font-medium min-w-0 max-w-full px-0.5 text-text2 data-[active=true]:text-theme5`,children:d})]},s)})})})}export{p as TabBarClient};
|
|
@@ -8,7 +8,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
8
8
|
/** buttonVariants 工具定义。 */
|
|
9
9
|
declare const buttonVariants: (props?: ({
|
|
10
10
|
variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
|
|
11
|
-
size?: "default" | "
|
|
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 组件属性。 */
|
|
14
14
|
type ButtonProps = Button.Props & VariantProps<typeof buttonVariants> & {
|