@funhub/platform 0.1.112 → 0.1.113
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,pInteractionFollow as a,pInteractionUnfollow as o}from"../../../../../service/generated/client.mjs";import{Box as s}from"../../../../ui/box.mjs";import{Skeleton as c}from"../../../../ui/skeleton.mjs";import{Text as l}from"../../../../ui/text.mjs";import{useLoginModalStore as u}from"../../../../../store/modules/login-modal-store.mjs";import{useDeleteRequest as d,useMutation as f,useRequest as p,useUpdateRequest as m}from"../../../../../hooks/query/use-query.mjs";import{LeftArrowIcon as h}from"../../../../common/icons/left-arrow.mjs";import{SettingIcon as g}from"../../../../common/icons/setting.mjs";import{UserProfileAvatar as _}from"./user-profile-avatar.mjs";import{UserProfileCoverBackground as v}from"./user-profile-cover-background.mjs";import{useEffect as y,useMemo as b,useState as x}from"react";import{jsx as S,jsxs as C}from"react/jsx-runtime";import{toast as w}from"sonner";import{useTranslations as T}from"next-intl";import E from"next/link";import{useRouter as ee}from"next/navigation";const D=n.persist,O=`https://guadd-sg-ccs-sing-dev.s3.ap-southeast-1.amazonaws.com/default/default_avatar.png`,k=`/images/mine/img_mine_head_bg.png`;function A({showBackButton:n,isMine:r,enableCustomBackground:i,className:a}){return C(s,{className:e(`flex flex-col relative`,a),children:[C(s,{className:`absolute top-0 p-3 z-10 flex items-center justify-between w-full`,children:[S(t,{variant:`ghost`,size:`icon-xs`,className:e(`h-4 w-4 p-0 hover:bg-transparent`,{invisible:!n}),disabled:!0,children:S(h,{className:`w-4 h-4`})}),S(s,{className:e({invisible:!r}),children:S(g,{})})]}),S(s,{className:i?`h-33.75`:`h-24`,children:S(c,{className:`h-full w-full rounded-none`})}),C(s,{className:`flex-1 px-3`,children:[C(s,{className:`relative flex justify-end`,children:[S(c,{className:`absolute bottom-3 left-0 h-22 w-22 rounded-full`}),S(s,{className:`py-4 h-12`})]}),C(s,{className:`flex items-center justify-between gap-1`,children:[S(c,{className:`h-7 w-[132px]`}),S(c,{className:`h-10 w-[104px] rounded-full shrink-0`})]}),C(s,{className:`min-h-11 pt-1 pb-0 flex flex-col gap-2`,children:[S(c,{className:`h-4 w-[76%]`}),S(c,{className:`h-4 w-[58%]`})]})]})]})}function te({userId:e,currentUserId:n,isFollowing:r}){let i=T(`components.pages.profile`),{open:s}=u(),c=d(),l=m(),{mutateAsync:p,isPending:h}=f(async e=>a(e)),{mutateAsync:g,isPending:_}=f(async e=>o(e)),v=h||_;async function y(){if(!v){if(!n){s();return}try{if(r){let t=await g({app_id:0,follower_id:n,followee_id:e});t.code===0?(w.success(i(`client.unfollowSuccess`)),b(!1),c([`check-follow`,e]),c([`user-profile`,`profile`,e])):w.error(t.message||i(`client.unfollowFailed`))}else{let t=await p({app_id:0,follower_id:n,followee_id:e});t.code===0?(w.success(i(`client.followSuccess`)),b(!0),c([`check-follow`,e]),c([`user-profile`,`profile`,e])):w.error(t.message||i(`client.followFailed`))}}catch(e){console.error(`关注操作失败`,e),w.error(i(`client.operationFailed`))}}}function b(t){l([`user-profile`,`profile`,e],e=>!e||!e.data?e:{...e,data:{...e.data,is_following:t}})}return S(t,{variant:r?`outline`:`default`,className:`rounded-full disabled:opacity-100`,onClick:y,disabled:v,children:i(v?`client.processing`:r?`client.followed`:`client.follow`)})}function j({id:a,enableCustomBackground:o=!0,showBackButton:c=!0,requireLogin:d=!1,isEditorPreview:f=!1,className:m,mode:w=`renderer`}){let j=T(`components.pages.profile`);T(`components.pages.profile.components`);let M=f||w===`editor`,N=!M,ne=ee(),{open:re}=u(),{isLogin:P,userId:F,token:ie}=n(),[ae,I]=x(!1);y(()=>{if(!D){I(!0);return}I(D.hasHydrated());let e=D.onHydrate(()=>{I(!1)}),t=D.onFinishHydration(()=>{I(!0)});return()=>{e(),t()}},[]);let L=M?!1:P&&!!F&&!!ie,R=M?``:F,z=R,B=a==null||!!a&&!!z&&a===z,oe=!B&&!!a,V=B?[`user-profile`,`mine`]:[`user-profile`,`profile`,a],{data:H,isLoading:U}=p(M?[`editor-preview`,...V]:V,()=>a?i({target_user_id:a,user_id:R||a}):r({user_id:a||R||``}),{staleTime:0,enabled:N&&(!!a||!!R)}),W=b(()=>{let e=H?H.data:void 0;return e?{userId:e.user_id,isFollowing:e.is_following||!1,name:e.nick_name||`User${a??``}`,avatar:e.avatar||O,followingCnt:e.following_count??0,followersCnt:e.follower_count??0,likeCnt:e.like_count??0,signature:e.signature||``,background:e.bg_image||k}:{}},[a,H]),G=M||d&&B&&!L,K=!G&&!L&&oe,q=B&&L&&!G,J=!L,se=o&&q,ce=o&&J,le={name:j(`client.welcomeToPlanet`),description:j(`client.exploreAdventures`),avatar:O,followingCnt:0,followersCnt:0,likeCnt:0,background:k};function Y(){re()}function X(){ne.back()}let ue=G?S(t,{className:`rounded-full`,size:`lg`,onClick:Y,children:j(`client.loginNow`)}):K?S(t,{className:`rounded-full`,size:`lg`,onClick:Y,children:j(`client.follow`)}):L?B?S(E,{href:`/edit`,children:S(t,{variant:`outline`,className:`rounded-full`,children:j(`client.editProfile`)})}):S(te,{userId:a||``,currentUserId:R,isFollowing:W?.isFollowing}):S(t,{className:`rounded-full`,size:`lg`,onClick:Y,children:j(`client.loginNow`)}),Z=G?le:W,Q=Z.name||``,$=Z.description||Z.signature||``;Z.followingCnt,Z.followersCnt,Z.likeCnt;let de=Z.avatar||``;return N&&U&&!H?S(A,{showBackButton:c,isMine:B,enableCustomBackground:o,className:m}):C(s,{className:e(`flex flex-col relative`,m),children:[C(s,{className:`absolute top-0 p-3 z-10 flex items-center justify-between w-full`,children:[S(t,{variant:`ghost`,size:`icon-xs`,onClick:X,className:e(`h-4 w-4 p-0 hover:bg-transparent`,{invisible:!c}),children:S(h,{className:`w-4 h-4`})}),S(E,{href:`/settings`,className:e({invisible:!B}),children:S(g,{})})]}),S(v,{isMine:se,enableCustomBackground:o,src:Z.background,onUnauthorizedClick:ce?Y:void 0}),C(s,{className:`flex-1 px-3`,children:[C(s,{className:`relative flex justify-end`,children:[S(_,{isMine:q,src:de,alt:Q||`avatar`,onUnauthorizedClick:J?Y:void 0}),S(s,{className:`flex divide-x divide-text1/5 py-4 h-12`})]}),C(s,{className:`flex items-center justify-between gap-1`,children:[P&&B?S(E,{href:`/edit`,children:S(l,{as:`p`,className:`text-text1 max-w-[14em] text-xl overflow-hidden whitespace-nowrap text-ellipsis font-bold `,children:Q})}):S(l,{as:`p`,className:`text-text1 max-w-[14em] text-xl overflow-hidden whitespace-nowrap text-ellipsis font-bold `,children:Q}),ue]})
|
|
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,pInteractionFollow as a,pInteractionUnfollow as o}from"../../../../../service/generated/client.mjs";import{Box as s}from"../../../../ui/box.mjs";import{Skeleton as c}from"../../../../ui/skeleton.mjs";import{Text as l}from"../../../../ui/text.mjs";import{useLoginModalStore as u}from"../../../../../store/modules/login-modal-store.mjs";import{useDeleteRequest as d,useMutation as f,useRequest as p,useUpdateRequest as m}from"../../../../../hooks/query/use-query.mjs";import{LeftArrowIcon as h}from"../../../../common/icons/left-arrow.mjs";import{SettingIcon as g}from"../../../../common/icons/setting.mjs";import{UserProfileAvatar as _}from"./user-profile-avatar.mjs";import{UserProfileCoverBackground as v}from"./user-profile-cover-background.mjs";import{useEffect as y,useMemo as b,useState as x}from"react";import{jsx as S,jsxs as C}from"react/jsx-runtime";import{toast as w}from"sonner";import{useTranslations as T}from"next-intl";import E from"next/link";import{useRouter as ee}from"next/navigation";const D=n.persist,O=`https://guadd-sg-ccs-sing-dev.s3.ap-southeast-1.amazonaws.com/default/default_avatar.png`,k=`/images/mine/img_mine_head_bg.png`;function A({showBackButton:n,isMine:r,enableCustomBackground:i,className:a}){return C(s,{className:e(`flex flex-col relative`,a),children:[C(s,{className:`absolute top-0 p-3 z-10 flex items-center justify-between w-full`,children:[S(t,{variant:`ghost`,size:`icon-xs`,className:e(`h-4 w-4 p-0 hover:bg-transparent`,{invisible:!n}),disabled:!0,children:S(h,{className:`w-4 h-4`})}),S(s,{className:e({invisible:!r}),children:S(g,{})})]}),S(s,{className:i?`h-33.75`:`h-24`,children:S(c,{className:`h-full w-full rounded-none`})}),C(s,{className:`flex-1 px-3`,children:[C(s,{className:`relative flex justify-end`,children:[S(c,{className:`absolute bottom-3 left-0 h-22 w-22 rounded-full`}),S(s,{className:`py-4 h-12`})]}),C(s,{className:`flex items-center justify-between gap-1`,children:[S(c,{className:`h-7 w-[132px]`}),S(c,{className:`h-10 w-[104px] rounded-full shrink-0`})]}),C(s,{className:`min-h-11 pt-1 pb-0 flex flex-col gap-2`,children:[S(c,{className:`h-4 w-[76%]`}),S(c,{className:`h-4 w-[58%]`})]})]})]})}function te({userId:e,currentUserId:n,isFollowing:r}){let i=T(`components.pages.profile`),{open:s}=u(),c=d(),l=m(),{mutateAsync:p,isPending:h}=f(async e=>a(e)),{mutateAsync:g,isPending:_}=f(async e=>o(e)),v=h||_;async function y(){if(!v){if(!n){s();return}try{if(r){let t=await g({app_id:0,follower_id:n,followee_id:e});t.code===0?(w.success(i(`client.unfollowSuccess`)),b(!1),c([`check-follow`,e]),c([`user-profile`,`profile`,e])):w.error(t.message||i(`client.unfollowFailed`))}else{let t=await p({app_id:0,follower_id:n,followee_id:e});t.code===0?(w.success(i(`client.followSuccess`)),b(!0),c([`check-follow`,e]),c([`user-profile`,`profile`,e])):w.error(t.message||i(`client.followFailed`))}}catch(e){console.error(`关注操作失败`,e),w.error(i(`client.operationFailed`))}}}function b(t){l([`user-profile`,`profile`,e],e=>!e||!e.data?e:{...e,data:{...e.data,is_following:t}})}return S(t,{variant:r?`outline`:`default`,className:`rounded-full disabled:opacity-100`,onClick:y,disabled:v,children:i(v?`client.processing`:r?`client.followed`:`client.follow`)})}function j({id:a,enableCustomBackground:o=!0,showBackButton:c=!0,requireLogin:d=!1,isEditorPreview:f=!1,className:m,mode:w=`renderer`}){let j=T(`components.pages.profile`);T(`components.pages.profile.components`);let M=f||w===`editor`,N=!M,ne=ee(),{open:re}=u(),{isLogin:P,userId:F,token:ie}=n(),[ae,I]=x(!1);y(()=>{if(!D){I(!0);return}I(D.hasHydrated());let e=D.onHydrate(()=>{I(!1)}),t=D.onFinishHydration(()=>{I(!0)});return()=>{e(),t()}},[]);let L=M?!1:P&&!!F&&!!ie,R=M?``:F,z=R,B=a==null||!!a&&!!z&&a===z,oe=!B&&!!a,V=B?[`user-profile`,`mine`]:[`user-profile`,`profile`,a],{data:H,isLoading:U}=p(M?[`editor-preview`,...V]:V,()=>a?i({target_user_id:a,user_id:R||a}):r({user_id:a||R||``}),{staleTime:0,enabled:N&&(!!a||!!R)}),W=b(()=>{let e=H?H.data:void 0;return e?{userId:e.user_id,isFollowing:e.is_following||!1,name:e.nick_name||`User${a??``}`,avatar:e.avatar||O,followingCnt:e.following_count??0,followersCnt:e.follower_count??0,likeCnt:e.like_count??0,signature:e.signature||``,background:e.bg_image||k}:{}},[a,H]),G=M||d&&B&&!L,K=!G&&!L&&oe,q=B&&L&&!G,J=!L,se=o&&q,ce=o&&J,le={name:j(`client.welcomeToPlanet`),description:j(`client.exploreAdventures`),avatar:O,followingCnt:0,followersCnt:0,likeCnt:0,background:k};function Y(){re()}function X(){ne.back()}let ue=G?S(t,{className:`rounded-full`,size:`lg`,onClick:Y,children:j(`client.loginNow`)}):K?S(t,{className:`rounded-full`,size:`lg`,onClick:Y,children:j(`client.follow`)}):L?B?S(E,{href:`/edit`,children:S(t,{variant:`outline`,className:`rounded-full`,children:j(`client.editProfile`)})}):S(te,{userId:a||``,currentUserId:R,isFollowing:W?.isFollowing}):S(t,{className:`rounded-full`,size:`lg`,onClick:Y,children:j(`client.loginNow`)}),Z=G?le:W,Q=Z.name||``,$=Z.description||Z.signature||``;Z.followingCnt,Z.followersCnt,Z.likeCnt;let de=Z.avatar||``;return N&&U&&!H?S(A,{showBackButton:c,isMine:B,enableCustomBackground:o,className:m}):C(s,{className:e(`flex flex-col relative`,m),children:[C(s,{className:`absolute top-0 p-3 z-10 flex items-center justify-between w-full`,children:[S(t,{variant:`ghost`,size:`icon-xs`,onClick:X,className:e(`h-4 w-4 p-0 hover:bg-transparent`,{invisible:!c}),children:S(h,{className:`w-4 h-4`})}),S(E,{href:`/settings`,className:e({invisible:!B}),children:S(g,{})})]}),S(v,{isMine:se,enableCustomBackground:o,src:Z.background,onUnauthorizedClick:ce?Y:void 0}),C(s,{className:`flex-1 px-3`,children:[C(s,{className:`relative flex justify-end`,children:[S(_,{isMine:q,src:de,alt:Q||`avatar`,onUnauthorizedClick:J?Y:void 0}),S(s,{className:`flex divide-x divide-text1/5 py-4 h-12`})]}),C(s,{className:`flex items-center justify-between gap-1`,children:[P&&B?S(E,{href:`/edit`,children:S(l,{as:`p`,className:`text-text1 max-w-[14em] text-xl overflow-hidden whitespace-nowrap text-ellipsis font-bold `,children:Q})}):S(l,{as:`p`,className:`text-text1 max-w-[14em] text-xl overflow-hidden whitespace-nowrap text-ellipsis font-bold `,children:Q}),ue]}),$&&S(s,{className:`min-h-11 pt-1 pb-0`,children:S(l,{as:`p`,className:`text-sm line-clamp-2 break-all text-text1/66`,children:$})})]})]})}export{j as UserProfileHeaderClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Button as e}from"../../../../../../ui/button.mjs";import{useUserStore as t}from"../../../../../../../store/modules/user-store.mjs";import{gCommunityGetSubscribedCollections as n,gCommunityGetUserCollections as r,gInteractionListCollects as i,pInteractionBatchDeleteCollects as a}from"../../../../../../../service/generated/client.mjs";import{Box as o}from"../../../../../../ui/box.mjs";import{Checkbox as ee}from"../../../../../../ui/checkbox.mjs";import{Tabs as te,TabsList as ne,TabsTrigger as s}from"../../../../../../ui/tabs.mjs";import{Text as re}from"../../../../../../ui/text.mjs";import{useMutation as ie,usePaginated as c,useUpdateRequest as ae}from"../../../../../../../hooks/query/use-query.mjs";import{DeleteConfirmDialog as oe}from"../../../../../../common/delete-confirm-dialog/delete-confirm-dialog.mjs";import{CollectionList as se}from"../../../../../../common/list/collection-list/collection-list.mjs";import{PostList as ce}from"../../../../../../common/list/post-list/post-list.mjs";import{VideoList as le}from"../../../../../../common/list/video-list/video-list.mjs";import{useEffect as l,useMemo as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{toast as m}from"sonner";import{useTranslations as h}from"next-intl";import g from"dayjs";import ue from"next/link";import{parseAsString as _,useQueryState as v}from"nuqs";const y={video:1,post:2};function de(e,t){if(!e)return e;let n=0,r=e.pages.map(e=>({page:e,filteredList:(e.data?.list??
|
|
2
|
+
"use client";import{Button as e}from"../../../../../../ui/button.mjs";import{useUserStore as t}from"../../../../../../../store/modules/user-store.mjs";import{gCommunityGetSubscribedCollections as n,gCommunityGetUserCollections as r,gInteractionListCollects as i,pInteractionBatchDeleteCollects as a}from"../../../../../../../service/generated/client.mjs";import{Box as o}from"../../../../../../ui/box.mjs";import{Checkbox as ee}from"../../../../../../ui/checkbox.mjs";import{Tabs as te,TabsList as ne,TabsTrigger as s}from"../../../../../../ui/tabs.mjs";import{Text as re}from"../../../../../../ui/text.mjs";import{useMutation as ie,usePaginated as c,useUpdateRequest as ae}from"../../../../../../../hooks/query/use-query.mjs";import{DeleteConfirmDialog as oe}from"../../../../../../common/delete-confirm-dialog/delete-confirm-dialog.mjs";import{CollectionList as se}from"../../../../../../common/list/collection-list/collection-list.mjs";import{PostList as ce}from"../../../../../../common/list/post-list/post-list.mjs";import{VideoList as le}from"../../../../../../common/list/video-list/video-list.mjs";import{useEffect as l,useMemo as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{toast as m}from"sonner";import{useTranslations as h}from"next-intl";import g from"dayjs";import ue from"next/link";import{parseAsString as _,useQueryState as v}from"nuqs";const y={video:1,post:2};function de(e,t){if(!e)return e;let n=0,r=e.pages.map(e=>({page:e,filteredList:(e.data?.list??w).filter(e=>{let r=e?.id??``,i=t.has(r);return i&&(n+=1),!i})}));return{...e,pages:r.map(({page:e,filteredList:t})=>{if(!e.data)return e;let r=typeof e.data.total==`number`?Math.max(0,e.data.total-n):e.data.total;return{...e,data:{...e.data,list:t,total:r}}})}}function b(e){if(e.cover_image)return e.cover_image;let t=``;return e.medias?.find(e=>e?(!e.is_video&&!t&&e.media_url&&(t=e.media_url),!!e.cover_image):!1)?.cover_image||t}function fe(e,t){let n=t[e.content_id||``]?.create_time,r=b(e);return{id:e.content_id||``,title:e.content||``,coverImage:r,publishTime:g(n).toDate().getTime()}}function pe(e,t){let n=t[e.id||``]?.create_time;return{is_more_link:e.is_more_link,id:e.id||``,title:e.name||``,coverImage:e.img_x||``,duration:Number(e.duration??0),authorName:e.up_user||e.source_username||``,viewCount:e.play_count??0,publishTime:g(n).toDate().getTime()}}function x(e){let t=b(e);return{contentType:e.source_type,id:e.content_id,title:e.title||e.content,coverImage:t,isVideo:!1,isMovie:!1}}function S(e){return Array.from({length:3},(t,n)=>({id:`${e}-placeholder-${n}`,isPlaceholder:!0}))}function C(e){let t=e.contents??[],n=(Array.isArray(t)?t:[]).slice(0,3).map(x),r=e.content_count??n.length;return{id:e.collection_id||``,title:e.title||``,contentCount:r,contents:r===0?S(e.collection_id||`collection`):n}}const w=[],me=[`video`,`post`,`collection`],he=[`created`,`subscribed`];function T({mode:g=`renderer`,userId:b,showCreateAction:x=!1,queryKeyPrefix:S,isMine:T=!1}){let ge=h(),E=h(`components.pages.profile.components.tabs`),D=g===`renderer`,O=S??[],[k,A]=v(`collectTab`,_.withDefault(`video`)),[j,M]=v(`collectCollectionTab`,_.withDefault(`created`)),N=u(()=>me.includes(k)?k:`video`,[k]),P=u(()=>he.includes(j)?j:`created`,[j]),[F,I]=d(!1),[_e,L]=d(!1),[R,z]=d(()=>new Set),{userId:ve,userInfo:ye}=t(),B=b||ve||ye?.userId||``,be=ae();async function xe(e,t){if(!B)return{data:{list:[],total:0}};let n=await i({user_id:B,folder_id:``,content_type:t,page:e,page_size:10}),r=n.data.collect_infos?.reduce((e,t)=>(t.content_id&&(e[t.content_id]=t),e),{})||{},a=t===y.video?(n.data?.video_infos??[]).map(e=>pe(e,r)):(n.data?.post_infos??[]).map(e=>fe(e,r));return{data:{list:a,total:n.data?.total??a.length}}}let V=c({key:[...O,`user-collect-video`,B],initialPageParam:1,async queryFn(e){return xe(e,y.video)},options:{staleTime:0,enabled:D},getNextPageParam(e,t){if((e?.data?.list||[]).length!==0)return t.length+1}}),H=c({key:[...O,`user-collect-post`,B],initialPageParam:1,options:{staleTime:0,enabled:D},async queryFn(e){return{data:{list:[],total:0,has_more:!1}}},getNextPageParam(e,t){if((e?.data?.list||[]).length!==0)return t.length+1}});async function Se(e){if(!B)return{data:{list:[],total:0}};let t=await r({page:e,user_id:b,page_size:10}),n=t.data?.data?.collections??[];return{data:{list:n.map(C),total:t.data?.data?.total??n.length}}}async function Ce(e){if(!B)return{data:{list:[],total:0}};let t=(await n({page:e,user_id:b,page_size:10})).data?.data,r=t?.collections??[];return{data:{list:r.map(C),total:t?.total??r.length}}}let U=c({key:[...O,`user-collection-created`,B],initialPageParam:1,options:{staleTime:0,enabled:D},async queryFn(e){return Se(e)},getNextPageParam(e,t){if((e?.data?.list||[]).length!==0)return t.length+1}}),W=c({key:[...O,`user-collection-subscribed`,B],initialPageParam:1,options:{staleTime:0,enabled:D},async queryFn(e){return Ce(e)},getNextPageParam(e,t){if((e?.data?.list||[]).length!==0)return t.length+1}}),G=u(()=>V.data?.pages.flatMap(e=>e.data?.list??w)??w,[V.data]),K=u(()=>H.data?.pages.flatMap(e=>e.data?.list??w)??w,[H.data]),we=u(()=>U.data?.pages.flatMap(e=>e.data?.list??w)??w,[U.data]),Te=u(()=>W.data?.pages.flatMap(e=>e.data?.list??w)??w,[W.data]),Ee=N===`video`?G:N===`post`?K:w,q=new Set(Ee.map(e=>e.id)),J=N===`video`?V:H,Y=P===`created`?U:W,De=P===`created`?we:Te,X=N===`video`,Oe=[...O,`user-collect-video`,B],ke=[...O,`user-collect-post`,B],{mutateAsync:Ae,isPending:Z}=ie(async e=>await a({app_id:0,user_id:B,folder_id:``,content_type:X?1:2,content_ids:e})),je=()=>{I(!F),z(new Set)};l(()=>{z(new Set),N===`collection`&&I(!1)},[N]),l(()=>{k!==N&&A(N)},[N,k,A]),l(()=>{j!==P&&M(P)},[P,j,M]);let Q=e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Me=()=>{R.size===q.size&&q.size>0?z(new Set):z(new Set(q))};function Ne(){R.size===0||Z||L(!0)}function Pe(){Z||L(!1)}async function Fe(){if(!(R.size===0||Z)){if(!B){m.error(E(`collectTab.pleaseLogin`));return}try{let e=Array.from(R),t=await Ae(e);if(t.code===0){m.success(E(`collectTab.uncollectedSuccess`));let t=new Set(e);be(X?Oe:ke,e=>de(e,t)),L(!1),z(new Set),I(!1)}else m.error(t.message||E(`collectTab.uncollectFailed`))}catch(e){console.error(`取消收藏失败`,e),m.error(E(`collectTab.operationFailed`))}}}let $=async()=>{if(D){if(N===`collection`){await Y.fetchNextPage();return}await J.fetchNextPage()}};return p(o,{children:[p(o,{className:`flex justify-between items-center`,children:[f(te,{value:N,onValueChange:e=>{A(e)},children:p(ne,{variant:`tag`,children:[f(s,{value:`video`,className:`text-sm`,children:E(`collectTab.video`)}),f(s,{value:`collection`,className:`text-sm`,children:E(`collectTab.collections`)})]})}),N===`collection`?x&&f(ue,{href:`/collection/create`,className:`flex items-center justify-center rounded-full text-text3 text-sm`,children:ge(`components.pages.collectionCreate.form.create`)}):T&&f(e,{variant:`ghost`,size:`sm`,className:`h-6.25 px-0 text-sm text-text3`,onClick:je,children:E(F?`collectTab.cancel`:`collectTab.edit`)})]}),f(o,{className:`pt-2`,children:N===`video`?f(le,{list:G,showVideoProgress:!1,loading:J.isFetching,hasMore:J.hasNextPage??!1,loadMore:$,emptyText:E(`collectTab.emptyContent`),isEditMode:F,selectedIds:R,onToggleSelection:Q}):N===`post`?f(ce,{list:K,loading:J.isFetching,hasMore:J.hasNextPage??!1,loadMore:$,emptyText:E(`collectTab.emptyContent`),isEditMode:F,selectedIds:R,onToggleSelection:Q}):f(se,{list:De,loading:Y.isFetching,hasMore:Y.hasNextPage??!1,loadMore:$,emptyText:E(`collectTab.emptyContent`)})}),F&&N!==`collection`&&p(o,{className:`fixed left-0 z-10 flex w-full items-center justify-between bg-bg1 px-3 py-2 bottom-[var(--tab-bar-height)]`,children:[p(o,{className:`flex items-center gap-2`,children:[f(ee,{checked:R.size===q.size&&q.size>0,onCheckedChange:Me}),f(re,{className:`text-sm text-text1`,children:E(`collectTab.selectAll`)})]}),f(e,{className:`rounded-full py-2.5 h-auto px-6.5`,variant:R.size>0?`default`:`outline`,disabled:R.size===0||Z,onClick:Ne,children:E(Z?`collectTab.processing`:`collectTab.delete`)})]}),f(oe,{open:_e,onOpenChange:L,onCancel:Pe,onConfirm:Fe,title:``,description:E(`collectTab.deleteConfirmDescription`),confirmText:E(`collectTab.delete`),cancelText:E(`collectTab.cancel`),isConfirming:Z})]})}export{T as CollectTab};
|
|
@@ -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?: "
|
|
9
|
+
variant?: "default" | "destructive" | "secondary" | "outline" | "ghost" | "link" | null | undefined;
|
|
10
10
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
11
|
/** Badge 组件。 */
|
|
12
12
|
declare function Badge({
|
|
@@ -7,8 +7,8 @@ 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?: "
|
|
11
|
-
size?: "default" | "
|
|
10
|
+
variant?: "default" | "destructive" | "secondary" | "outline" | "ghost" | "link" | null | undefined;
|
|
11
|
+
size?: "default" | "xs" | "sm" | "lg" | "icon" | "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> & {
|