@funhub/platform 0.1.113 → 0.1.114

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]}),$&&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};
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};
@@ -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" | "destructive" | "secondary" | "outline" | "ghost" | "link" | 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,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?: "default" | "destructive" | "secondary" | "outline" | "ghost" | "link" | null | undefined;
11
- size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
10
+ variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
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> & {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@funhub/platform",
3
3
  "type": "module",
4
- "version": "0.1.113",
4
+ "version": "0.1.114",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "**/*.css"