@funhub/platform 0.1.86 → 0.1.88
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{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
|
|
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){let t=typeof e.path==`string`?e.path.trim():``;if(t)return t;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 n=(e.domainId??``).toString().trim();return n?`/domain/${n}`:`/`}function d(e,t){let n=l(t),r=l(u(e).split(`?`)[0]);return r===`/`?n===`/`:n===r||n.startsWith(`${r}/`)}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(()=>p===`editor`?0:f(d??[],m),[d,m,p]),g=r(()=>(d??[]).some(e=>e.label!=null&&String(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.activeIcon:r.icon,d=typeof r.label==`string`?r.label:String(r.label??``);return a(o,{href:u(r),className:v,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};
|
|
@@ -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,gUserViewUserInfo as r,pCommunityDeleteCollection as i,pCommunityRemoveContentFromCollection as a,pCommunitySubscribeCollection as o,pInteractionBatchDeleteCollects as s}from"../../../service/generated/client.mjs";import{Box as c}from"../../ui/box.mjs";import{Checkbox as ee}from"../../ui/checkbox.mjs";import{Drawer as te,DrawerContent as ne,DrawerDescription as re,DrawerTitle as ie}from"../../ui/drawer.mjs";import{List as ae}from"../../ui/list.mjs";import{Text as l}from"../../ui/text.mjs";import{useLoginModalStore as oe}from"../../../store/modules/login-modal-store.mjs";import{useDeleteRequest as se,useMutation as u,useRequest as d,useUpdateRequest as ce}from"../../../hooks/query/use-query.mjs";import{ShareDrawer as le}from"../../common/share-popup/share-drawer.mjs";import{SharePlatformEnum as f}from"../../../types/share.mjs";import p from"../../../utils/share-manager.mjs";import{
|
|
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,gUserViewUserInfo as r,pCommunityDeleteCollection as i,pCommunityRemoveContentFromCollection as a,pCommunitySubscribeCollection as o,pInteractionBatchDeleteCollects as s}from"../../../service/generated/client.mjs";import{Box as c}from"../../ui/box.mjs";import{Checkbox as ee}from"../../ui/checkbox.mjs";import{Drawer as te,DrawerContent as ne,DrawerDescription as re,DrawerTitle as ie}from"../../ui/drawer.mjs";import{List as ae}from"../../ui/list.mjs";import{Text as l}from"../../ui/text.mjs";import{useLoginModalStore as oe}from"../../../store/modules/login-modal-store.mjs";import{useDeleteRequest as se,useMutation as u,useRequest as d,useUpdateRequest as ce}from"../../../hooks/query/use-query.mjs";import{ShareDrawer as le}from"../../common/share-popup/share-drawer.mjs";import{SharePlatformEnum as f}from"../../../types/share.mjs";import p from"../../../utils/share-manager.mjs";import{DeleteConfirmDialog as m}from"../../common/delete-confirm-dialog/delete-confirm-dialog.mjs";import{HeaderNav as ue}from"../../common/header-nav/client.mjs";import{MoreIcon as de}from"../../common/icons/more.mjs";import{CollectionDetailCard as fe}from"./_components/collection-detail-card.mjs";import{useEffect as pe,useMemo as h,useState as g}from"react";import{jsx as _,jsxs as v}from"react/jsx-runtime";import{toast as y}from"sonner";import{useTranslations as me}from"next-intl";import{useRouter as b,useSearchParams as he}from"next/navigation";function x(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 S(e){let t=e.detail.info?.video_duration;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.medias?.find(e=>{let t=e?.video_duration;return typeof t==`number`&&Number.isFinite(t)&&t>0})?.video_duration;return typeof n==`number`&&Number.isFinite(n)&&n>0?Math.floor(n):0}function C(e){let t=e.detail.info?.play_count;if(typeof t==`number`&&Number.isFinite(t))return Math.max(0,Math.floor(t));let n=e.detail.view_count||e.viewCount;return typeof n==`number`&&Number.isFinite(n)?Math.max(0,Math.floor(n)):0}function ge(e){let t=e.detail,n=t.info,r=String(n?.cover_image||t.cover_image||x(e)||``),i=String(n?.text||n?.title||t.title||t.content||``),a=t.author_score??0,o=Array.isArray(t.tags)?t.tags:[];return{id:e.content_id?String(e.content_id):String(e.id),title:i,type:typeof e.type==`number`?e.type:0,coverImage:r,score:a,collectedAt:t.create_time==null?void 0:String(t.create_time),tags:o,duration:S(e),viewCount:C(e),publishTime:String(t.create_time??t.update_time??``),is_more_link:n?.is_more_link??!1,authorName:``}}function w({id:x}){let S=me(`components.pages.collectionDetail`),C=b(),w=he(),{userId:T,isLogin:E}=t(),{open:D}=oe(),O=se();ce();let k=d([`collection-detail`,x],()=>n({collection_id:x})),A=k.data?.data?.data?.collection?.user_id,j=!!(A&&T&&String(A)===String(T)),_e=d([`user-info`,A],()=>r({target_user_id:A,user_id:A})),[ve,M]=g(!1),[N,P]=g(!1),[F,I]=g(!1),[L,R]=g(!1),[z,B]=g(!1),[V,H]=g(()=>new Set),[U,W]=g(null);pe(()=>{!N&&L&&(I(!0),R(!1))},[N,L]);let G=k.data?.data?.data?.collection,K=G?.contents,q=h(()=>K?K.map(e=>({content_id:e.content_id,id:Number(e.content_id),detail:e,type:Number(e.source_type??0),medias:e.medias,cover_image:e.cover_image,viewCount:e.view_count})):[],[K]).map(ge),J=h(()=>new Set(q.map(e=>e.id)),[q]),Y=J.size>0&&V.size===J.size;G?.cover_image,G?.content_count,G?.is_subscribe;let{mutateAsync:ye,isPending:be}=u(async e=>await o({collection_id:x,subscribe:e})),{mutateAsync:xe,isPending:Se}=u(async e=>await a({collection_id:x,content_id:e})),{mutateAsync:Ce,isPending:X}=u(async e=>await i({collection_id:e})),{mutateAsync:we,isPending:Z}=u(async e=>await s({app_id:0,user_id:T,folder_id:x,content_type:1,content_ids:e})),Q=_e.data?.data;Q?.avatar,Q?.nick_name;let Te=j&&G?.is_default===!1;function Ee(e){W({kind:`content`,id:e.id,type:e.type,title:e.title,isCollected:!0}),M(!0)}function De(){if(j){P(!0);return}W({kind:`collection`,id:x}),M(!0)}function Oe(){if(!E||!T){y.error(S(`detail.pleaseLogin`)),D();return}if(!j){y.error(S(`detail.operationFailed`));return}P(!1),H(new Set),B(!0)}function ke(){H(new Set),B(!1)}function Ae(e){H(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function je(){if(Y){H(new Set);return}H(new Set(J))}async function Me(){if(!(V.size===0||Z)){if(!E||!T){y.error(S(`detail.pleaseLogin`)),D();return}try{let e=await we(Array.from(V));if(e.code===0){y.success(S(`detail.uncollectSuccess`)),O([`collection-detail`,x]),O([`user-profile`,`mine`]),O([`user-profile`,`profile`,A]),H(new Set),B(!1);return}y.error(e.message||S(`detail.uncollectFailed`))}catch(e){console.error(`批量取消收藏失败`,e),y.error(S(`detail.operationFailed`))}}}function Ne(e){if(typeof window>`u`)return``;if(e.kind===`collection`)return`${window.location.origin}/collection/${e.id}`;let t=e.title?encodeURIComponent(e.title):`detail`,n=e.type===1?`/video/${e.id}/${t}`:`/post/${e.id}`;return`${window.location.origin}${n}`}function $(e){if(!U)return;let t=Ne(U);t&&p.showSharePopup({type:e,data:{id:U.id},copyUrl:t})}function Pe(){$(f.WECHAT)}function Fe(){$(f.QQ)}function Ie(){$(f.WECHAT_MOMENTS)}function Le(){if(!Se){if(!E||!T){y.error(S(`detail.pleaseLogin`)),D();return}!U||U.kind!==`content`||xe(U.id).then(e=>{if(e.code===0){y.success(S(`detail.uncollectSuccess`)),O([`collection-detail`,x]),W(e=>e&&{...e,isCollected:!1});return}y.error(e.message||S(`detail.uncollectFailed`))}).catch(e=>{console.error(`取消收藏失败`,e),y.error(S(`detail.operationFailed`))})}}function Re(){let e=new URLSearchParams(w.toString());e.set(`id`,x),e.set(`type`,`edit`),C.push(`/collection/create?${e.toString()}`),P(!1),M(!1)}function ze(){if(!X){if(!E||!T){y.error(S(`detail.pleaseLogin`)),D();return}if(!Te){y.error(S(`detail.defaultCollectionDeleteNotSupported`));return}R(!0),P(!1)}}async function Be(){if(!X)try{let e=await Ce(x);if(e.code===0){y.success(S(`detail.deleteSuccess`)),O([`collection-detail`,x]),O([`user-profile`,`mine`]),O([`user-profile`,`profile`,A]),I(!1),P(!1),M(!1),C.back();return}y.error(e.message||S(`detail.deleteFailed`))}catch(e){console.error(`删除合集失败`,e),y.error(S(`detail.operationFailed`))}}return v(c,{className:`flex flex-col bg-bg1 min-h-screen ${z?`pb-28`:`pb-6`}`,children:[_(ue,{title:G?.title??``,rightChild:j?z?_(`button`,{type:`button`,onClick:ke,className:`px-2 py-1 text-sm text-text1`,children:S(`detail.done`)}):_(`button`,{type:`button`,onClick:De,className:`p-2`,children:_(de,{})}):void 0}),_(c,{className:`px-4 flex items-start gap-4`,children:v(c,{className:`flex-1 flex flex-col gap-2`,children:[_(c,{className:`flex items-center justify-between`}),_(c,{className:`text-text2 text-sm`,children:G?.description})]})}),_(c,{className:`px-4 ${z?`pb-20`:``}`,children:_(ae,{loading:k.isLoading,hasMore:!1,emptyText:S(`detail.emptyContent`),className:`divide-y divide-text1/5`,children:q.map(e=>_(fe,{...e,onOpenShare:Ee,isEditMode:z,isSelected:V.has(e.id),onToggleSelection:Ae},e.id))})}),z&&v(c,{style:{paddingBottom:`calc(12px + env(safe-area-inset-bottom, 0px))`},className:`fixed left-0 right-0 bottom-0 z-10 bg-bg1 border-t border-text1/10 px-4 pt-3 flex items-center justify-between`,children:[v(c,{className:`flex items-center gap-2`,children:[_(ee,{checked:Y,onCheckedChange:je}),_(l,{className:`text-sm text-text1`,children:S(`detail.selectAll`)})]}),_(e,{className:`rounded-full py-2.5 h-auto px-6.5`,variant:V.size>0?`default`:`outline`,disabled:V.size===0||Z,onClick:Me,children:S(Z?`detail.deleting`:`detail.delete`)})]}),v(te,{open:N,onOpenChange:P,children:[_(ie,{className:`hidden`,children:S(`detail.collectionManageTitle`)}),_(re,{className:`hidden`,children:S(`detail.collectionManageTitle`)}),v(ne,{className:`z-[2000]`,children:[v(c,{className:`px-4 py-5`,children:[_(l,{className:`text-base font-bold text-text1 text-center `,children:S(`detail.collectionManageTitle`)}),v(c,{className:`mt-4 border-t border-text1/10`,children:[_(`button`,{className:`w-full text-left py-4 border-b border-text1/10`,onClick:Re,children:_(l,{className:`text-text1`,children:S(`detail.editCollection`)})}),_(`button`,{className:`w-full text-left py-4 border-b border-text1/10`,onClick:Oe,children:_(l,{className:`text-text1`,children:S(`detail.manageCollection`)})}),_(`button`,{className:`w-full text-left py-4 ${X?`opacity-60 cursor-not-allowed`:``}`,onClick:ze,disabled:X,children:_(l,{className:`text-destructive`,children:S(X?`detail.deleting`:`detail.deleteCollection`)})})]})]}),_(e,{className:`w-full h-auto py-4 text-lg text-text1`,size:`lg`,onClick:()=>P(!1),variant:`secondary`,children:S(`detail.cancel`)})]})]}),_(le,{isShowCollect:U?.kind===`content`&&j&&E,isCollected:U?.isCollected,open:ve,onOpenChange:M,onShareWeChat:Pe,onShareQQ:Fe,onShareMoments:Ie,onUncollect:Le}),_(m,{open:F,onOpenChange:I,onConfirm:Be,title:S(`detail.deleteCollection`),isConfirming:X})]})}export{w as CollectionDetail};
|
|
@@ -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" | "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?: "
|
|
10
|
+
variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
|
|
11
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 组件属性。 */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{getItem as e,setItem as t}from"./db.mjs";import{createBncDecryptWorker as n}from"./decrypt.worker.mjs";import r from"./get-res-url.mjs";let i=null;function a(){if(typeof window>`u`)return null;if(i)return i;let e=[];function t(){let e={worker:n(),busy:!1,current:null},t=()=>{try{e.worker.terminate()}catch{}e.worker=n(),e.busy=!1,e.current=null,r(e)},r=e=>{e.worker.addEventListener(`message`,t=>{let n=t.data;if(!e.current||n?.id!==e.current.id)return;let{resolve:r}=e.current;e.current=null,e.busy=!1,r(n),d()}),e.worker.addEventListener(`error`,n=>{if(e.current){let{reject:t}=e.current;e.current=null,e.busy=!1,t(n)}t(),d()})};return r(e),e}for(let n=0;n<4;n++)e.push(t());return i=e,i}const o=[];function s(e){if(!e)return!1;let t=e.split(`?`)[0];return/bnc$/i.test(t)||/xxx$/i.test(t)}function c(e){let t=String(e||``).split(`?`)[0].toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)(?:\.?(?:bnc|xxx))?$/i)?.[1];return t===`jpg`||t===`jpeg`?`image/jpeg`:t===`png`?`image/png`:t===`gif`?`image/gif`:t===`webp`?`image/webp`:`application/octet-stream`}async function l(n,i){if(!n?.trim())return null;if(s(n)){let r=await e(n);if(r instanceof ArrayBuffer)return{buffer:r,contentType:c(n)};let{buffer:a,contentType:o,error:s}=await f(n,i);return s?null:(await t(n,a),{buffer:a,contentType:o??c(n)})}let a=r(),o=n.startsWith(`http`)?n:n.startsWith(`/`)?a?`${a}${n}`:n:a?`${a}/${n}`:`/${n}`,l=await fetch(o);return l.ok?{buffer:await l.arrayBuffer(),contentType:l.headers.get(`content-type`)||c(n)}:null}async function u(e,t){let n=await l(e,t);return n?{bytes:new Uint8Array(n.buffer),contentType:n.contentType}:null}function d(){let e=a();if(e)for(let t of e){if(t.busy)continue;let e=o.shift();if(!e)return;t.busy=!0,t.current={id:e.id,resolve:e.resolve,reject:e.reject};let n={id:e.id,mode:`bnc-url`,url:e.url,apiRes:r(),secretKey:e.secretKey};t.worker.postMessage(n)}}function f(e,t){if(!a())return Promise.resolve({id:`no-worker`,buffer:new ArrayBuffer(0),error:`worker not available`});let n=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`;return new Promise((r,i)=>{o.push({id:n,url:e,secretKey:t,resolve:r,reject:i}),d()})}async function
|
|
2
|
+
"use client";import{getItem as e,setItem as t}from"./db.mjs";import{createBncDecryptWorker as n}from"./decrypt.worker.mjs";import r from"./get-res-url.mjs";let i=null;function a(){if(typeof window>`u`)return null;if(i)return i;let e=[];function t(){let e={worker:n(),busy:!1,current:null},t=()=>{try{e.worker.terminate()}catch{}e.worker=n(),e.busy=!1,e.current=null,r(e)},r=e=>{e.worker.addEventListener(`message`,t=>{let n=t.data;if(!e.current||n?.id!==e.current.id)return;let{resolve:r}=e.current;e.current=null,e.busy=!1,r(n),d()}),e.worker.addEventListener(`error`,n=>{if(e.current){let{reject:t}=e.current;e.current=null,e.busy=!1,t(n)}t(),d()})};return r(e),e}for(let n=0;n<4;n++)e.push(t());return i=e,i}const o=[];function s(e){if(!e)return!1;let t=e.split(`?`)[0];return/bnc$/i.test(t)||/xxx$/i.test(t)}function c(e){let t=String(e||``).split(`?`)[0].toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)(?:\.?(?:bnc|xxx))?$/i)?.[1];return t===`jpg`||t===`jpeg`?`image/jpeg`:t===`png`?`image/png`:t===`gif`?`image/gif`:t===`webp`?`image/webp`:`application/octet-stream`}async function l(n,i){if(!n?.trim())return null;if(s(n)){let r=await e(n);if(r instanceof ArrayBuffer)return{buffer:r,contentType:c(n)};let{buffer:a,contentType:o,error:s}=await f(n,i);return s?null:(await t(n,a),{buffer:a,contentType:o??c(n)})}let a=r(),o=n.startsWith(`http`)?n:n.startsWith(`/`)?a?`${a}${n}`:n:a?`${a}/${n}`:`/${n}`,l=await fetch(o);return l.ok?{buffer:await l.arrayBuffer(),contentType:l.headers.get(`content-type`)||c(n)}:null}async function u(e,t){let n=await l(e,t);return n?{bytes:new Uint8Array(n.buffer),contentType:n.contentType}:null}function d(){let e=a();if(e)for(let t of e){if(t.busy)continue;let e=o.shift();if(!e)return;t.busy=!0,t.current={id:e.id,resolve:e.resolve,reject:e.reject};let n={id:e.id,mode:`bnc-url`,url:e.url,apiRes:r(),secretKey:e.secretKey};t.worker.postMessage(n)}}function f(e,t){if(!a())return Promise.resolve({id:`no-worker`,buffer:new ArrayBuffer(0),error:`worker not available`});let n=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`;return new Promise((r,i)=>{o.push({id:n,url:e,secretKey:t,resolve:r,reject:i}),d()})}function p(e){return e.startsWith(`default/`)||e.startsWith(`/default/`)||e.startsWith(`/images/default`)}function m(e){return/^(https?:)?\/\//.test(e)||e.startsWith(`data:`)}async function h(n,i){let a=await e(n);if(a instanceof ArrayBuffer)return URL.createObjectURL(new Blob([a],{type:c(n)}));if(s(n)){let{buffer:e,contentType:r,error:a}=await f(n,i);return a?``:(await t(n,e),URL.createObjectURL(new Blob([e],{type:r??c(n)})))}else{let e=r();return p(n)?e?`${e}${n.startsWith(`/`)?n:`/${n}`}`:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4//8/LwAJCQMLCIuEYQAAAABJRU5ErkJggg==`:m(n)?n:n.startsWith(`/md-204`)?`${e}${n.startsWith(`/`)?n:`/${n}`}`:n}}export{l as decryptImageToArrayBuffer,u as decryptImageToUint8Array,h as decryptImageUrl,c as guessImageContentTypeFromUrl,s as isEncryptedImageUrl};
|