@funhub/platform 0.1.113 → 0.1.115
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{cn as e}from"../../../../../utils/cn.mjs";import{Button as t}from"../../../../ui/button.mjs";import{useUserStore as n}from"../../../../../store/modules/user-store.mjs";import{gUserGetUserInfo as r,gUserViewUserInfo as i
|
|
2
|
+
"use client";import{cn as e}from"../../../../../utils/cn.mjs";import{Button as t}from"../../../../ui/button.mjs";import{useUserStore as n}from"../../../../../store/modules/user-store.mjs";import{gUserGetUserInfo as r,gUserViewUserInfo as i}from"../../../../../service/generated/client.mjs";import{Box as a}from"../../../../ui/box.mjs";import{Skeleton as o}from"../../../../ui/skeleton.mjs";import{Text as s}from"../../../../ui/text.mjs";import{useLoginModalStore as c}from"../../../../../store/modules/login-modal-store.mjs";import{useRequest as l}from"../../../../../hooks/query/use-query.mjs";import{LeftArrowIcon as u}from"../../../../common/icons/left-arrow.mjs";import{SettingIcon as d}from"../../../../common/icons/setting.mjs";import{UserProfileAvatar as f}from"./user-profile-avatar.mjs";import{UserProfileCoverBackground as ee}from"./user-profile-cover-background.mjs";import{useEffect as te,useMemo as p,useState as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";import{useTranslations as _}from"next-intl";import v from"next/link";import{useRouter as y}from"next/navigation";const b=n.persist,x=`https://guadd-sg-ccs-sing-dev.s3.ap-southeast-1.amazonaws.com/default/default_avatar.png`,S=`/images/mine/img_mine_head_bg.png`;function C({showBackButton:n,isMine:r,enableCustomBackground:i,className:s}){return g(a,{className:e(`flex flex-col relative`,s),children:[g(a,{className:`absolute top-0 p-3 z-10 flex items-center justify-between w-full`,children:[h(t,{variant:`ghost`,size:`icon-xs`,className:e(`h-4 w-4 p-0 hover:bg-transparent`,{invisible:!n}),disabled:!0,children:h(u,{className:`w-4 h-4`})}),h(a,{className:e({invisible:!r}),children:h(d,{})})]}),h(a,{className:i?`h-33.75`:`h-24`,children:h(o,{className:`h-full w-full rounded-none`})}),g(a,{className:`flex-1 px-3`,children:[g(a,{className:`relative flex justify-end`,children:[h(o,{className:`absolute bottom-3 left-0 h-22 w-22 rounded-full`}),h(a,{className:`py-4 h-12`})]}),g(a,{className:`flex items-center justify-between gap-1`,children:[h(o,{className:`h-7 w-[132px]`}),h(o,{className:`h-10 w-[104px] rounded-full shrink-0`})]}),g(a,{className:`min-h-11 pt-1 pb-0 flex flex-col gap-2`,children:[h(o,{className:`h-4 w-[76%]`}),h(o,{className:`h-4 w-[58%]`})]})]})]})}function w({id:o,enableCustomBackground:w=!0,showBackButton:T=!0,requireLogin:E=!1,isEditorPreview:D=!1,className:O,mode:k=`renderer`}){let A=_(`components.pages.profile`),j=D||k===`editor`,M=!j,ne=y(),{open:re}=c(),{isLogin:N,userId:P,token:F}=n(),[ie,I]=m(!1);te(()=>{if(!b){I(!0);return}I(b.hasHydrated());let e=b.onHydrate(()=>{I(!1)}),t=b.onFinishHydration(()=>{I(!0)});return()=>{e(),t()}},[]);let L=j?!1:N&&!!P&&!!F,R=j?``:P,z=R,B=o==null||!!o&&!!z&&o===z,V=B?[`user-profile`,`mine`]:[`user-profile`,`profile`,o],{data:H,isLoading:U}=l(j?[`editor-preview`,...V]:V,()=>o?i({target_user_id:o,user_id:R||o}):r({user_id:o||R||``}),{staleTime:0,enabled:M&&(!!o||!!R)}),W=p(()=>{let e=H?H.data:void 0;return e?{userId:e.user_id,isFollowing:e.is_following||!1,name:e.nick_name||`User${o??``}`,avatar:e.avatar||x,followingCnt:e.following_count??0,followersCnt:e.follower_count??0,likeCnt:e.like_count??0,signature:e.signature||``,background:e.bg_image||S}:{}},[o,H]),G=j||E&&B&&!L,K=B&&L&&!G,q=!L,J=w&&K,Y=w&&q,ae={name:A(`client.welcomeToPlanet`),description:A(`client.exploreAdventures`),avatar:x,followingCnt:0,followersCnt:0,likeCnt:0,background:S};function X(){re()}function oe(){ne.back()}let se=G?h(t,{className:`rounded-full`,size:`lg`,onClick:X,children:A(`client.loginNow`)}):B?h(v,{href:`/edit`,children:h(t,{variant:`outline`,className:`rounded-full`,children:A(`client.editProfile`)})}):null,Z=G?ae:W,Q=Z.name||``,$=Z.description||Z.signature||``,ce=Z.avatar||``;return M&&U&&!H?h(C,{showBackButton:T,isMine:B,enableCustomBackground:w,className:O}):g(a,{className:e(`flex flex-col relative`,O),children:[g(a,{className:`absolute top-0 p-3 z-10 flex items-center justify-between w-full`,children:[h(t,{variant:`ghost`,size:`icon-xs`,onClick:oe,className:e(`h-4 w-4 p-0 hover:bg-transparent`,{invisible:!T}),children:h(u,{className:`w-4 h-4`})}),h(v,{href:`/settings`,className:e({invisible:!B}),children:h(d,{})})]}),h(ee,{isMine:J,enableCustomBackground:w,src:Z.background,onUnauthorizedClick:Y?X:void 0}),g(a,{className:`flex-1 px-3`,children:[g(a,{className:`relative flex justify-end`,children:[h(f,{isMine:K,src:ce,alt:Q||`avatar`,onUnauthorizedClick:q?X:void 0}),h(a,{className:`flex divide-x divide-text1/5 py-4 h-12`})]}),g(a,{className:`flex items-center justify-between gap-1`,children:[N&&B?h(v,{href:`/edit`,children:h(s,{as:`p`,className:`text-text1 max-w-[14em] text-xl overflow-hidden whitespace-nowrap text-ellipsis font-bold `,children:Q})}):h(s,{as:`p`,className:`text-text1 max-w-[14em] text-xl overflow-hidden whitespace-nowrap text-ellipsis font-bold `,children:Q}),se]}),$&&h(a,{className:`min-h-11 pt-1 pb-0`,children:h(s,{as:`p`,className:`text-sm line-clamp-2 break-all text-text1/66`,children:$})})]})]})}export{w as UserProfileHeaderClient};
|
|
@@ -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{useUserStore as n}from"../../../store/modules/user-store.mjs";import{gContentGetRecommendVideoList as r}from"../../../service/generated/client.mjs";import{Image as i}from"../../ui/image.mjs";import{Box as a}from"../../ui/box.mjs";import{Item as o}from"../../ui/item.mjs";import{List as s}from"../../ui/list.mjs";import{Skeleton as c}from"../../ui/skeleton.mjs";import{Text as l}from"../../ui/text.mjs";import{usePaginated as u,useUpdateRequest as d}from"../../../hooks/query/use-query.mjs";import{useRequireLogin as f}from"../../../hooks/use-auth.mjs";import{eventKey as p}from"../../../constants/event-key.mjs";import m from"../../../assets/icons/right_arrow.mjs";import
|
|
2
|
+
"use client";import{Button as e}from"../../ui/button.mjs";import t from"../../../utils/event-bus.mjs";import{useUserStore as n}from"../../../store/modules/user-store.mjs";import{gContentGetRecommendVideoList as r}from"../../../service/generated/client.mjs";import{Image as i}from"../../ui/image.mjs";import{Box as a}from"../../ui/box.mjs";import{Item as o}from"../../ui/item.mjs";import{List as s}from"../../ui/list.mjs";import{Skeleton as c}from"../../ui/skeleton.mjs";import{Text as l}from"../../ui/text.mjs";import{usePaginated as u,useUpdateRequest as d}from"../../../hooks/query/use-query.mjs";import{useRequireLogin as f}from"../../../hooks/use-auth.mjs";import{eventKey as p}from"../../../constants/event-key.mjs";import m from"../../../assets/icons/right_arrow.mjs";import h from"../../../assets/images/user/default_avatar.mjs";import{memo as g,useCallback as _,useEffect as v,useMemo as y,useState as b}from"react";import{jsx as x,jsxs as S}from"react/jsx-runtime";import{useTranslations as C}from"next-intl";import w from"next/link";const T=typeof h==`string`?h:h.src;function E(){return x(a,{className:`w-full`,children:Array.from({length:6}).map((e,t)=>S(a,{className:`w-full h-[56px] flex items-center justify-between mb-[12px]`,children:[S(a,{className:`flex items-center`,children:[x(c,{className:`w-[56px] h-[56px] rounded-[28px]`}),S(a,{className:`ml-[8px]`,children:[x(c,{className:`w-[120px] h-[18px] mb-[8px]`}),x(c,{className:`w-[72px] h-[14px]`})]})]}),x(c,{className:`w-[76px] h-[34px] rounded-[18px]`})]},`search-user-skeleton-${t}`))})}const D=g(({item:e,onUpdate:t})=>{let r=C(`components.pages.search.searchResult`),{userInfo:o}=n();return _(n=>{t({...e,is_following:n?1:0})},[e,t]),x(a,{className:`w-full h-[56px] bg-bg1 flex flex-row items-center justify-between mb-[12px]`,children:S(w,{className:`cursor-pointer flex flex-row items-center justify-center`,href:`/profile/${e.user_id}`,children:[x(a,{className:`w-[56px] h-[56px] rounded-[28px] overflow-hidden bg-bg2 relative`,children:x(i,{src:e.avatar||T,fill:!0,objectFit:`cover`,alt:e.nick_name})}),S(a,{className:`flex flex-col ml-[8px]`,children:[x(l,{as:`span`,className:`text-text1 text-[16px] leading-[24px] h-[24px] font-bold w-[200px] inline-block truncate`,children:e.nick_name}),S(l,{as:`span`,className:`text-text2 leading-[22px] text-[14px]`,children:[e.follower_count??0,r(`searchUser.followersSuffix`)]})]})]})})});D.displayName=`UserItem`;const O=g(({list:n})=>{let r=f(),[i,o]=b({});v(()=>{o({})},[n]);let s=_(e=>{e.user_id&&o(t=>({...t,[e.user_id]:e.is_following?1:0}))},[]),c=y(()=>n.slice(0,3).map(e=>{let t=e.user_id||``;return!t||i[t]===void 0?e:{...e,is_following:i[t]}}),[i,n,3]),u=n.length>3,d=_(()=>{t.emit(p.EXCHANGE_SEARCH_TYPE,`user`)},[]);return c.length===0?null:S(a,{className:`w-full pt-[12px]`,children:[x(a,{className:`px-[12px]`,children:c.map((e,t)=>x(D,{item:e,onUpdate:e=>{r(()=>s(e))}},String(e.user_id??t)))}),u&&x(a,{className:`w-full flex items-center justify-center`,children:S(e,{variant:`ghost`,className:`w-fit h-[46px] leading-[46px] mx-auto mt-[-12px] text-[14px] text-text2`,onClick:d,children:[x(l,{as:`span`,children:`查看更多`}),x(m,{className:`w-[12px] h-[12px]`})]})})]})});O.displayName=`SearchUserWithLimit`;const k=g(({inputVal:e,sort:t,refreshVersion:n})=>{let i=C(`components.pages.search.searchResult`),c=f(),l=_(async n=>await r({data_type:2,extra_params:JSON.stringify({type:4,keywords:e,sort:t}),page:n||1,page_size:20}),[e,t]),p=y(()=>[`searchByKeyForUser`,e,4,t,n],[e,t,n]),m=u({key:p,initialPageParam:1,async queryFn(e){return(await l(e))?.data?.users??{has_more:!1,total:0,list:[]}},getNextPageParam(e,t){if(e.has_more)return t.length+1}}),h=d(),g=_((e,t)=>{e&&h(p,n=>n&&{...n,pages:n.pages.map(n=>({...n,list:(n.list??[]).map(n=>n.user_id===e?{...n,is_following:t?1:0}:n)}))})},[h,p]),v=async e=>{try{await m.fetchNextPage()}catch(e){console.error(`获取用户列表失败`,e)}},b=(m?.data?.pages??[]).flatMap(e=>e.list??[]),S=!!(m?.isPending||m?.isFetching);return S&&b.length===0?x(E,{}):x(a,{className:`w-full`,children:x(s,{loading:S,hasMore:m?.hasNextPage??!1,loadMore:v,empty:`nodata`,emptyText:i(`searchUser.emptyResult`),children:b.map((e,t)=>x(o,{children:x(D,{item:e,onUpdate:e=>{c(()=>{g(e.user_id||``,!!e.is_following)})}})},String(e.user_id??t)))})})});k.displayName=`SearchUserWithPagination`;const A=g(e=>e.mode===`all`?x(O,{list:e.list??[]}):x(k,{inputVal:e.inputVal??``,sort:e.sort??1,refreshVersion:e.refreshVersion??0}));A.displayName=`SearchUser`;export{A as default};
|