@funhub/platform 0.1.147 → 0.1.149

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{pUserEditUserInfo as r}from"../../../../../service/generated/client.mjs";import{uploadFile as i}from"../../../../../utils/upload-file.mjs";import{Avatar as a,AvatarFallback as o,AvatarImage as s}from"../../../../ui/avatar.mjs";import{Box as c}from"../../../../ui/box.mjs";import{Input as l}from"../../../../ui/input.mjs";import{Dialog as u,DialogContent as d}from"../../../../ui/dialog.mjs";import{Text as f}from"../../../../ui/text.mjs";import{useDeleteRequest as p}from"../../../../../hooks/query/use-query.mjs";import{ImageCropModal as m}from"../../../../common/image-crop-modal/image-crop-modal.mjs";import{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";const S=`https://guadd-sg-ccs-sing-dev.s3.ap-southeast-1.amazonaws.com/default/default_avatar.png`,C=[`image/jpeg`,`image/png`];function w(e){let t=e.name.toLowerCase(),n=e.type.toLowerCase();return C.includes(n)||/\.(?:jpg|jpeg|png)$/i.test(t)}function T({isMine:C,src:T,alt:E,onUnauthorizedClick:D}){let O=x(`components.pages.profile`),k=h(null),{userId:A,setUserInfo:j,userInfo:M}=n(),N=p(),[P,F]=g(!1),[I,L]=g(!1),[R,z]=g(``),[B,V]=g(!1);function H(){if(!B){if(C){F(!0);return}D?.()}}function U(){R&&(URL.revokeObjectURL(R),z(``))}function W(){F(!1)}function G(){B||k.current?.click()}function K(e){let t=e.target.files?.[0];if(t){if(!w(t)){b.error(O(`client.imageTypeInvalid`)),e.target&&(e.target.value=``);return}if(t.size>5242880){b.error(O(`client.imageTooLarge`)),e.target&&(e.target.value=``);return}z(URL.createObjectURL(t)),L(!0),e.target&&(e.target.value=``)}}async function q(e){if(!A){b.error(O(`client.loginRequiredForUpload`));return}try{V(!0);let t=await i(new File([e],`avatar.jpg`,{type:`image/jpeg`}),1);await r({user_id:String(A),avatar:t.objectKey}),j({...M,avatar:t.objectKey}),N([`user-profile`,`mine`]),N([`user-edit-info`,String(A)]),F(!1),L(!1),b.success(O(`client.mediaUpdateSuccess`))}catch(e){console.error(`上传头像失败`,e),b.error(O(`client.uploadFailed`))}finally{U(),V(!1)}}function J(){L(!1),U()}return y(_,{children:[C||D?v(t,{variant:`ghost`,size:`icon`,className:`!absolute bottom-3 left-0 h-22 w-22 rounded-full p-0 hover:bg-transparent`,onClick:H,"aria-label":`打开头像预览`,children:y(a,{className:`w-22 h-22`,children:[v(s,{src:T||S,alt:E||`avatar`}),v(o,{})]})}):y(a,{className:`!absolute bottom-3 left-0 w-22 h-22`,children:[v(s,{src:T||S,alt:E||`avatar`}),v(o,{})]}),v(u,{open:P,onOpenChange:W,children:v(d,{showCloseButton:!1,className:`bg-black !m-0 !p-0 !fixed !inset-0 !w-screen !h-screen !max-w-none !rounded-none !top-0 !left-0 !translate-x-0 !translate-y-0 !transform-none z-[9999] !pointer-events-auto`,children:y(c,{className:`relative flex h-full w-full flex-col items-center justify-center`,children:[v(t,{variant:`ghost`,size:`icon`,className:`absolute left-0 top-0 h-14 w-14 text-white hover:bg-transparent hover:text-white/80`,onClick:W,"aria-label":`关闭头像预览`,children:v(`svg`,{className:`w-4 h-4`,xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 16 16`,children:v(`path`,{d:`M14.55.2a.889.889 0 0 1 1.25 1.25l-.06.067L9.255 8l6.483 6.482.06.069a.888.888 0 0 1-1.25 1.25l-.067-.062L8 9.256l-6.482 6.483A.888.888 0 1 1 .26 14.482L6.742 8 .26 1.517.2 1.45A.888.888 0 0 1 1.45.2l.067.062 6.482 6.482L14.482.261l.068-.062Z`})})}),y(a,{className:`w-50 h-50`,children:[v(s,{src:T||S,alt:E||`avatar`}),v(o,{})]}),y(t,{variant:`ghost`,className:e(`absolute bottom-8 left-0 right-0 mx-auto flex w-[366px] max-w-[90%] items-center justify-between rounded-3xl bg-white/10 px-3 py-3 transition-colors hover:bg-white/20`,`active:scale-95`),onClick:G,disabled:B,children:[v(f,{as:`span`,className:`text-base font-medium text-white`,children:B?`上传中...`:`更换头像`}),y(`svg`,{className:`w-6 h-6 text-white`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:[v(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z`}),v(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 13a3 3 0 11-6 0 3 3 0 016 0z`})]})]})]})})}),v(l,{ref:k,type:`file`,accept:`.jpg,.jpeg,.png,image/jpeg,image/png`,className:`hidden`,onChange:K}),v(m,{open:I,onClose:J,imageSrc:R,onConfirm:q})]})}export{T as UserProfileAvatar};
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{gUserGetUserEditInfo as r,pUserEditUserInfo as i}from"../../../../../service/generated/client.mjs";import{uploadFile as a}from"../../../../../utils/upload-file.mjs";import{Avatar as o,AvatarFallback as s,AvatarImage as c}from"../../../../ui/avatar.mjs";import{Box as l}from"../../../../ui/box.mjs";import{Input as u}from"../../../../ui/input.mjs";import{Dialog as d,DialogContent as f}from"../../../../ui/dialog.mjs";import{Text as p}from"../../../../ui/text.mjs";import{useDeleteRequest as m}from"../../../../../hooks/query/use-query.mjs";import{ImageCropModal as h}from"../../../../common/image-crop-modal/image-crop-modal.mjs";import{useRef as g,useState as _}from"react";import{Fragment as v,jsx as y,jsxs as b}from"react/jsx-runtime";import{toast as x}from"sonner";import{useTranslations as S}from"next-intl";const C=`https://guadd-sg-ccs-sing-dev.s3.ap-southeast-1.amazonaws.com/default/default_avatar.png`,w=[`image/jpeg`,`image/png`];function T(e){let t=e.name.toLowerCase(),n=e.type.toLowerCase();return w.includes(n)||/\.(?:jpg|jpeg|png)$/i.test(t)}function E({isMine:w,src:E,alt:D,onUnauthorizedClick:O}){let k=S(`components.pages.profile`),A=g(null),{userId:j,setUserInfo:M,userInfo:N}=n(),P=m(),[F,I]=_(!1),[L,R]=_(!1),[z,B]=_(``),[V,H]=_(!1);function U(){if(!V){if(w){I(!0);return}O?.()}}function W(){z&&(URL.revokeObjectURL(z),B(``))}function G(){I(!1)}function K(){V||A.current?.click()}async function q(e){let t=(await r({user_id:String(j)})).data;return{user_id:String(j),nick_name:t?.nick_name??N?.nick_name??void 0,avatar:e||void 0,signature:t?.signature??N?.signature??void 0,gender:t?.gender??N?.gender??void 0}}function J(e){let t=e.target.files?.[0];if(t){if(!T(t)){x.error(k(`client.imageTypeInvalid`)),e.target&&(e.target.value=``);return}if(t.size>5242880){x.error(k(`client.imageTooLarge`)),e.target&&(e.target.value=``);return}B(URL.createObjectURL(t)),R(!0),e.target&&(e.target.value=``)}}async function Y(e){if(!j){x.error(k(`client.loginRequiredForUpload`));return}try{H(!0);let t=await a(new File([e],`avatar.jpg`,{type:`image/jpeg`}),1),n=await q(t.objectKey);await i(n),M({...N,nick_name:n.nick_name,avatar:t.objectKey,signature:n.signature,gender:n.gender}),P([`user-profile`,`mine`]),P([`user-profile`,`profile`,String(j)]),P([`user-edit-info`,String(j)]),I(!1),R(!1),x.success(k(`client.mediaUpdateSuccess`))}catch(e){console.error(`上传头像失败`,e),x.error(k(`client.uploadFailed`))}finally{W(),H(!1)}}function X(){R(!1),W()}return b(v,{children:[w||O?y(t,{variant:`ghost`,size:`icon`,className:`!absolute bottom-3 left-0 h-22 w-22 rounded-full p-0 hover:bg-transparent`,onClick:U,"aria-label":`打开头像预览`,children:b(o,{className:`w-22 h-22`,children:[y(c,{src:E||C,alt:D||`avatar`}),y(s,{})]})}):b(o,{className:`!absolute bottom-3 left-0 w-22 h-22`,children:[y(c,{src:E||C,alt:D||`avatar`}),y(s,{})]}),y(d,{open:F,onOpenChange:G,children:y(f,{showCloseButton:!1,className:`bg-black !m-0 !p-0 !fixed !inset-0 !w-screen !h-screen !max-w-none !rounded-none !top-0 !left-0 !translate-x-0 !translate-y-0 !transform-none z-[9999] !pointer-events-auto`,children:b(l,{className:`relative flex h-full w-full flex-col items-center justify-center`,children:[y(t,{variant:`ghost`,size:`icon`,className:`absolute left-0 top-0 h-14 w-14 text-white hover:bg-transparent hover:text-white/80`,onClick:G,"aria-label":`关闭头像预览`,children:y(`svg`,{className:`w-4 h-4`,xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 16 16`,children:y(`path`,{d:`M14.55.2a.889.889 0 0 1 1.25 1.25l-.06.067L9.255 8l6.483 6.482.06.069a.888.888 0 0 1-1.25 1.25l-.067-.062L8 9.256l-6.482 6.483A.888.888 0 1 1 .26 14.482L6.742 8 .26 1.517.2 1.45A.888.888 0 0 1 1.45.2l.067.062 6.482 6.482L14.482.261l.068-.062Z`})})}),b(o,{className:`w-50 h-50`,children:[y(c,{src:E||C,alt:D||`avatar`}),y(s,{})]}),b(t,{variant:`ghost`,className:e(`absolute bottom-8 left-0 right-0 mx-auto flex w-[366px] max-w-[90%] items-center justify-between rounded-3xl bg-white/10 px-3 py-3 transition-colors hover:bg-white/20`,`active:scale-95`),onClick:K,disabled:V,children:[y(p,{as:`span`,className:`text-base font-medium text-white`,children:V?`上传中...`:`更换头像`}),b(`svg`,{className:`w-6 h-6 text-white`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:[y(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z`}),y(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 13a3 3 0 11-6 0 3 3 0 016 0z`})]})]})]})})}),y(u,{ref:A,type:`file`,accept:`.jpg,.jpeg,.png,image/jpeg,image/png`,className:`hidden`,onChange:J}),y(h,{open:L,onClose:X,imageSrc:z,onConfirm:Y})]})}export{E as UserProfileAvatar};
@@ -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{gCommunityGetContentList as n,pCommunityAddContentToCollection as r}from"../../../service/generated/client.mjs";import{Box as i}from"../../ui/box.mjs";import{useDeleteRequest as a,useMutation as o,usePaginated as s}from"../../../hooks/query/use-query.mjs";import{HeaderNav as c}from"../../common/header-nav/client.mjs";import{UserActivityList as l}from"../../common/list/user-activity-list/user-activity-list.mjs";import{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";function g(e){return{type:e.type,content_id:e.content_id||``,author:{nick_name:e.author?.nickname||``,nickname:e.author?.nickname||``,avatar:e.author?.avatar_url||``},content:e.content||``,medias:e.medias||[],like_count:e.like_count||0,is_liked:e.interaction?.is_liked||!1,dislike_count:e.dislike_count||0,is_dislike:e.interaction?.is_dislike||!1,comment_count:e.comment_count||0}}function _({id:_}){let{userId:v}=t(),y=_,[b,x]=d(()=>new Set),S=a(),{mutateAsync:C,isPending:w}=o(async e=>await r({collection_id:y,content_id:e})),{data:T,isFetching:E,fetchNextPage:D,hasNextPage:O}=s({key:[`collection-add`,y,v],initialPageParam:1,async queryFn(e){if(!v)return{data:{list:[],total:0}};let t=await n({user_id:v,page:e,collection_id:y,page_size:10}),r=t.data?.data?.contents??[];return{data:{list:r,total:t.data?.data?.total??r.length,has_more:t.data?.data?.has_more?!0:void 0}}},getNextPageParam(e,t){let n=e?.data||{},r=n.list||[];if(typeof n.has_more==`boolean`)return n.has_more?t.length+1:void 0;if(!(r.length===0||n.total===0))return t.length+1}}),k=h(`components.pages.collectionAdd`),A=u(()=>T?.pages.flatMap(e=>((e?.data).list||[]).map(e=>g(e)))??[],[T]);function j(e){w||x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function M(){if(w)return;if(!y){m.error(k(`page.collectionNotFound`));return}if(!v){m.error(k(`page.userNotFound`));return}let e=Array.from(b);if(e.length===0){m.error(k(`page.selectPostFirst`));return}let t=m.loading(k(`page.submitting`));try{await Promise.all(e.map(e=>C(e))),m.success(k(`page.submitSuccess`),{id:t}),x(new Set),S([`collection-add`,y,v]),S([`collection-detail`,y])}catch(e){console.error(`添加合集失败`,e),m.error(k(`page.submitFailed`),{id:t})}}let N=b.size;return p(i,{className:`bg-bg2 !min-h-screen`,children:[f(c,{className:`!bg-bg2`,title:k(`page.title`),rightChild:p(e,{onClick:M,disabled:w||N===0,children:[k(`page.done`),`(`,N,`)`]})}),f(l,{list:A,loading:E,hasMore:O,loadMore:async()=>{D()},emptyText:k(`page.emptyPublish`),showGroupHeaders:!1,isEditMode:!0,selectedIds:b,onToggleSelection:j})]})}export{_ as CollectionAddPage};
2
+ "use client";import{Button as e}from"../../ui/button.mjs";import{useUserStore as t}from"../../../store/modules/user-store.mjs";import{gCommunityGetContentList as n,pCommunityAddContentToCollection as r}from"../../../service/generated/client.mjs";import{Box as i}from"../../ui/box.mjs";import{useDeleteRequest as a,useMutation as o,usePaginated as s}from"../../../hooks/query/use-query.mjs";import{HeaderNav as c}from"../../common/header-nav/client.mjs";import{UserActivityList as l}from"../../common/list/user-activity-list/user-activity-list.mjs";import{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{useRouter as h}from"next/navigation";import{useTranslations as g}from"next-intl";function _(e){return{type:e.type,content_id:e.content_id||``,author:{nick_name:e.author?.nickname||``,nickname:e.author?.nickname||``,avatar:e.author?.avatar_url||``},content:e.content||``,medias:e.medias||[],like_count:e.like_count||0,is_liked:e.interaction?.is_liked||!1,dislike_count:e.dislike_count||0,is_dislike:e.interaction?.is_dislike||!1,comment_count:e.comment_count||0}}function v({id:v}){let{userId:y}=t(),b=v,[x,S]=d(()=>new Set),C=a(),{mutateAsync:w,isPending:T}=o(async e=>await r({collection_id:b,content_id:e})),{data:E,isFetching:D,fetchNextPage:O,hasNextPage:k}=s({key:[`collection-add`,b,y],initialPageParam:1,async queryFn(e){if(!y)return{data:{list:[],total:0}};let t=await n({user_id:y,page:e,collection_id:b,page_size:10}),r=t.data?.data?.contents??[];return{data:{list:r,total:t.data?.data?.total??r.length,has_more:t.data?.data?.has_more?!0:void 0}}},getNextPageParam(e,t){let n=e?.data||{},r=n.list||[];if(typeof n.has_more==`boolean`)return n.has_more?t.length+1:void 0;if(!(r.length===0||n.total===0))return t.length+1}}),A=g(`components.pages.collectionAdd`),j=u(()=>E?.pages.flatMap(e=>((e?.data).list||[]).map(e=>_(e)))??[],[E]);function M(e){T||S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function N(){if(T)return;if(!b){m.error(A(`page.collectionNotFound`));return}if(!y){m.error(A(`page.userNotFound`));return}let e=Array.from(x);if(e.length===0){m.error(A(`page.selectPostFirst`));return}let t=m.loading(A(`page.submitting`));try{await Promise.all(e.map(e=>w(e))),m.success(A(`page.submitSuccess`),{id:t}),S(new Set),C([`collection-add`,b,y]),C([`collection-detail`,b])}catch(e){console.error(`添加合集失败`,e),m.error(A(`page.submitFailed`),{id:t})}}let P=h(),F=x.size;return p(i,{className:`bg-bg2 !min-h-screen`,children:[f(c,{onBack:()=>P.back(),className:`!bg-bg2`,title:A(`page.title`),rightChild:p(e,{onClick:N,disabled:T||F===0,children:[A(`page.done`),`(`,F,`)`]})}),f(l,{list:j,loading:D,hasMore:k,loadMore:async()=>{O()},emptyText:A(`page.emptyPublish`),showGroupHeaders:!1,isEditMode:!0,selectedIds:x,onToggleSelection:M})]})}export{v as CollectionAddPage};
@@ -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{gCommunityGetCollectionInfo as n,pCommunityCreateCollection as r,pCommunityUpdateCollection as i}from"../../../service/generated/client.mjs";import{useRouter as a}from"../../../utils/use-compatible-router.mjs";import{Box as o}from"../../ui/box.mjs";import{InputGroup as s,InputGroupAddon as c,InputGroupTextarea as l}from"../../ui/input-group.mjs";import{Field as u,FieldLabel as d}from"../../ui/field.mjs";import{useDeleteRequest as f,useRequest as p}from"../../../hooks/query/use-query.mjs";import{HeaderNav as m}from"../../common/header-nav/client.mjs";import{useEffect as h,useRef as g,useState as _}from"react";import{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({mode:S=`create`,collectionId:C}){let w=x(`components.pages.collectionCreate`),T=a(),{userId:E}=t(),D=f();g(null);let O=S===`edit`&&!!C,k=g(!1),[A,j]=_(!1),[M,N]=_(!1),[P,F]=_(``),[I,L]=_({title:``,description:``}),R=p([`collection-detail`,C],()=>n({collection_id:C}),{enabled:!!(O&&C)}).data?.data?.data?.collection;h(()=>{!O||k.current||!R||(L({title:R.title??``,description:R.description??``}),F(R.cover_image??``),k.current=!0)},[R,O]);function z(e,t){L(n=>({...n,[e]:t}))}async function B(){if(A)return;let e=I.title.trim(),t=I.description.trim();if(!e){b.error(w(`form.titleRequired`));return}if(O&&!C){b.error(w(`form.collectionNotFound`));return}try{j(!0);let n=b.loading(w(O?`form.saving`:`form.creating`)),a=O?await i({collection_id:C,title:e,description:t,cover_image:P}):await r({title:e,description:t,cover_image:P});if(a.code===0){b.success(w(O?`form.saveSuccess`:`form.createSuccess`),{id:n}),E&&D([`user-profile`,`mine`,E,`user-collection-created`,E]),O&&C&&D([`collection-detail`,C]),T.back();return}b.error(a.message||w(O?`form.saveFailed`:`form.createFailed`),{id:n})}catch(e){console.error(O?`编辑合集失败`:`创建合集失败`,e),b.error(w(O?`form.saveFailed`:`form.createFailed`))}finally{j(!1)}}return y(o,{className:`min-h-screen !bg-bg2`,children:[v(m,{title:w(O?`form.editTitle`:`form.createTitle`),className:`!bg-bg2`,rightChild:v(e,{onClick:B,disabled:A||M,children:w(A?O?`form.saving`:`form.creating`:O?`form.save`:`form.create`)})}),y(o,{className:`pb-3`,children:[y(u,{className:`!bg-bg2 px-3 border-none`,children:[v(d,{required:!0,children:w(`form.label`)}),y(s,{children:[v(l,{className:`!bg-bg1 p-2.5`,maxLength:50,placeholder:w(`form.titlePlaceholder`),value:I.title,onChange:e=>z(`title`,e.target.value)}),v(c,{className:`!bg-bg1`,align:`block-end`,children:v(`div`,{className:`text-right w-full`,children:y(`span`,{className:`text-xs`,children:[I.title.length,`/50`]})})})]})]}),y(u,{className:`border-none px-3 bg-bg2! `,children:[v(d,{children:w(`form.descriptionLabel`)}),y(s,{children:[v(l,{className:`!bg-bg1 p-2.5`,maxLength:100,placeholder:w(`form.descriptionPlaceholder`),value:I.description,onChange:e=>z(`description`,e.target.value)}),v(c,{className:`!bg-bg1`,align:`block-end`,children:v(`div`,{className:`text-right w-full`,children:y(`span`,{className:`text-xs`,children:[I.description.length,`/100`]})})})]})]})]})]})}export{S as CollectionCreateForm};
2
+ "use client";import{Button as e}from"../../ui/button.mjs";import{useUserStore as t}from"../../../store/modules/user-store.mjs";import{gCommunityGetCollectionInfo as n,pCommunityCreateCollection as r,pCommunityUpdateCollection as i}from"../../../service/generated/client.mjs";import{useRouter as a}from"../../../utils/use-compatible-router.mjs";import{Box as o}from"../../ui/box.mjs";import{InputGroup as s,InputGroupAddon as c,InputGroupTextarea as l}from"../../ui/input-group.mjs";import{Field as u,FieldLabel as d}from"../../ui/field.mjs";import{useDeleteRequest as f,useRequest as p}from"../../../hooks/query/use-query.mjs";import{HeaderNav as m}from"../../common/header-nav/client.mjs";import{useEffect as h,useRef as g,useState as _}from"react";import{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({mode:S=`create`,collectionId:C}){let w=x(`components.pages.collectionCreate`),T=a(),{userId:E}=t(),D=f();g(null);let O=S===`edit`&&!!C,k=g(!1),[A,j]=_(!1),[M,N]=_(!1),[P,F]=_(``),[I,L]=_({title:``,description:``}),R=p([`collection-detail`,C],()=>n({collection_id:C}),{enabled:!!(O&&C)}).data?.data?.data?.collection;h(()=>{!O||k.current||!R||(L({title:R.title??``,description:R.description??``}),F(R.cover_image??``),k.current=!0)},[R,O]);function z(e,t){L(n=>({...n,[e]:t}))}async function B(){if(A)return;let e=I.title.trim(),t=I.description.trim();if(!e){b.error(w(`form.titleRequired`));return}if(O&&!C){b.error(w(`form.collectionNotFound`));return}try{j(!0);let n=b.loading(w(O?`form.saving`:`form.creating`)),a=O?await i({collection_id:C,title:e,description:t,cover_image:P}):await r({title:e,description:t,cover_image:P});if(a.code===0){b.success(w(O?`form.saveSuccess`:`form.createSuccess`),{id:n}),E&&D([`user-profile`,`mine`,E,`user-collection-created`,E]),O&&C&&D([`collection-detail`,C]),T.back();return}b.error(a.message||w(O?`form.saveFailed`:`form.createFailed`),{id:n})}catch(e){console.error(O?`编辑合集失败`:`创建合集失败`,e),b.error(w(O?`form.saveFailed`:`form.createFailed`))}finally{j(!1)}}return y(o,{className:`min-h-screen !bg-bg2`,children:[v(m,{title:w(O?`form.editTitle`:`form.createTitle`),onBack:()=>T.back(),className:`!bg-bg2`,rightChild:v(e,{onClick:B,disabled:A||M,children:w(A?O?`form.saving`:`form.creating`:O?`form.save`:`form.create`)})}),y(o,{className:`pb-3`,children:[y(u,{className:`!bg-bg2 px-3 border-none`,children:[v(d,{required:!0,children:w(`form.label`)}),y(s,{children:[v(l,{className:`!bg-bg1 p-2.5`,maxLength:50,placeholder:w(`form.titlePlaceholder`),value:I.title,onChange:e=>z(`title`,e.target.value)}),v(c,{className:`!bg-bg1`,align:`block-end`,children:v(`div`,{className:`text-right w-full`,children:y(`span`,{className:`text-xs`,children:[I.title.length,`/50`]})})})]})]}),y(u,{className:`border-none px-3 bg-bg2! `,children:[v(d,{children:w(`form.descriptionLabel`)}),y(s,{children:[v(l,{className:`!bg-bg1 p-2.5`,maxLength:100,placeholder:w(`form.descriptionPlaceholder`),value:I.description,onChange:e=>z(`description`,e.target.value)}),v(c,{className:`!bg-bg1`,align:`block-end`,children:v(`div`,{className:`text-right w-full`,children:y(`span`,{className:`text-xs`,children:[I.description.length,`/100`]})})})]})]})]})]})}export{S as CollectionCreateForm};
@@ -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?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
9
+ variant?: "default" | "link" | "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?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
10
+ variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
11
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 组件属性。 */
@@ -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 Image from "next/image";
4
+ import NextImage from "next/image";
5
5
 
6
6
  //#region components/ui/image.d.ts
7
7
  /** BaseImageProps 属性定义。 */
8
- type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof Image>, 'className' | 'src' | 'alt' | 'width' | 'height' | 'loading' | 'priority' | 'fill' | 'style'>;
8
+ type BaseImageProps = Omit<React.ComponentPropsWithoutRef<typeof NextImage>, '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$1(props: ImageProps): react_jsx_runtime0.JSX.Element;
30
+ declare function Image(props: ImageProps): react_jsx_runtime0.JSX.Element;
31
31
  //#endregion
32
- export { BaseImageProps, CommonImageProps, Image$1 as Image, ImageProps, ImagePropsWithFill, ImagePropsWithSize };
32
+ export { BaseImageProps, CommonImageProps, 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.147",
4
+ "version": "0.1.149",
5
5
  "private": false,
6
6
  "sideEffects": [
7
7
  "**/*.css"