@funhub/platform 0.1.157 → 0.1.159
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{useFollowIdsState as t}from"../../../../../store/modules/follow-ids-store.mjs";import{useUserStore as n}from"../../../../../store/modules/user-store.mjs";import{followUser as r,unfollowUser as i}from"../../../../../utils/follow-service.mjs";import a from"../../../../../assets/icons/common/follow_sel.mjs";import
|
|
2
|
+
"use client";import{cn as e}from"../../../../../utils/cn.mjs";import{useFollowIdsState as t}from"../../../../../store/modules/follow-ids-store.mjs";import{useUserStore as n}from"../../../../../store/modules/user-store.mjs";import{followUser as r,unfollowUser as i}from"../../../../../utils/follow-service.mjs";import{useLoginModalStore as a}from"../../../../../store/modules/login-modal-store.mjs";import o from"../../../../../assets/icons/common/follow_sel.mjs";import s from"../../../../../assets/icons/common/follow_user.mjs";import{UnfollowConfirmDialog as c}from"../../../../common/follow-button/unfollow-confirm-dialog.mjs";import{useEffect as l,useState as u}from"react";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";import{useTranslations as m}from"next-intl";function h({information:e,onUpdate:o}){let{isLogin:s,userId:m,userInfo:h}=n(),_=m||h?.userId||``,v=e.author,y=e.up_user||v?.user_id||``,b=!!(_&&y&&_===y),[x,S]=u(!!e.is_followed),[C,w]=u(!1),[T,E]=u(!1);l(()=>{S(!!e.is_followed)},[e.id,e.is_followed]);async function D(){if(!s||!_){a.getState().open();return}if(!y){console.warn(`用户信息不完整,无法执行关注操作`);return}E(!0);let e=!x;try{let n;if(n=e?await r({app_id:0,follower_id:_,followee_id:y}):await i({app_id:0,follower_id:_,followee_id:y}),n.success){S(e),o({is_followed:e});let{followIds:n,setFollowIds:r}=t.getState(),i=new Set(n);e?i.add(y):i.delete(y),r(Array.from(i))}else console.error(`关注操作失败:`,n.message)}catch(e){console.error(`关注操作异常:`,e)}finally{E(!1)}}function O(){if(!T){if(!s||!_){a.getState().open();return}if(x){w(!0);return}D()}}function k(){w(!1),D()}function A(){w(!1)}return p(d,{children:[e.up_user&&y&&!b?f(g,{followed:x,loading:T,onToggle:O}):null,f(c,{open:C,onOpenChange:w,onCancel:A,onConfirm:k})]})}function g({followed:t,loading:n=!1,onToggle:r}){let i=m(`components.biz.business.detail`);return f(`button`,{type:`button`,disabled:n,className:e(`flex h-7 items-center rounded-full border border-solid px-3 text-xs font-medium transition-colors`,n&&`opacity-50 cursor-not-allowed`,t?`border-text3 text-text3`:`border-theme5 text-theme5`),onClick:r,children:t?p(d,{children:[f(o,{className:`w-[12px] h-[12px] text-text3 shrink-0`}),f(`span`,{className:`text-text3 text-[12px] leading-[18px] ml-[4px] shrink-0`,children:i(`detailFollowAction.following`)})]}):p(d,{children:[f(s,{className:`block w-[12px] h-[12px] text-theme5 shrink-0`}),f(`span`,{className:`block text-theme5 text-[12px] leading-[18px] ml-[4px] shrink-0`,children:i(`detailFollowAction.follow`)})]})})}export{h as DetailFollowAction};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{decryptImageToUint8Array as e}from"../../../../../utils/decrypt-image-client.mjs";import{gContentGetVideoDetail as
|
|
2
|
+
"use client";import{decryptImageToUint8Array as e}from"../../../../../utils/decrypt-image-client.mjs";import{useUserStore as t}from"../../../../../store/modules/user-store.mjs";import{gContentGetVideoDetail as n,pInteractionBrowse as r}from"../../../../../service/generated/client.mjs";import{uint8ArrayToBase64 as i}from"../../../../../utils/uint8.mjs";import{resolveM3u8Urls as a,resolveVideoPlayerSrc as o}from"../../../../common/video-player/process-m3u8-cache.mjs";import{useLoginModalStore as s}from"../../../../../store/modules/login-modal-store.mjs";import{batchQueryContentInteractions as c}from"../../../../../hooks/use-content-operate.mjs";import{useCallback as l,useEffect as u,useRef as d}from"react";import{usePathname as f}from"next/navigation";import{useQueryClient as p}from"@tanstack/react-query";const m=new Map,h=new Map;function g(){if(typeof window>`u`)return!1;let e={open:!1};return window.dispatchEvent(new CustomEvent(`funhub:detail-series-popup-query`,{detail:e})),!!e.open}function _(){typeof window>`u`||window.dispatchEvent(new Event(`funhub:detail-series-popup-close`))}function v(e){let t=Math.floor(Number(e)||1);return t>0?t:1}function y(e){let t=typeof e==`string`?e:typeof window>`u`?``:window.location.pathname,n=String(t||``).split(`/`).filter(Boolean),r=n.findIndex(e=>e===`video`||e===`webview`);if(r<0)return{detailId:``,currentSeriesNum:1,episodeIndex:0};let i=n[r+1]||``;try{let e=decodeURIComponent(i),t=n.slice(r+1),a=t.findIndex(e=>e===`episode`),o=v(a>=0?t[a+1]:t[2]);return{detailId:e,currentSeriesNum:o,episodeIndex:Math.max(0,o-1)}}catch{let e=n.slice(r+1),t=e.findIndex(e=>e===`episode`),a=v(t>=0?e[t+1]:e[2]);return{detailId:i,currentSeriesNum:a,episodeIndex:Math.max(0,a-1)}}}function b(e){for(;e.size>5;){let t=e.keys().next().value;if(!t)break;e.delete(t)}}function x(e){let t=e,n=t?.data?.video||t?.video||t;if(!(!n||typeof n!=`object`))return{...n,content_type:1,episode_cnt:n.links?.length||0}}function S(e){let t=String(e||``).trim();return t?[[`video-detail`,t]]:[]}function C(v){let{enabled:C=!0}=v,w=p(),T=y(f()).detailId,E=d({detailId:``}),D=d(null),O=d(new Map),k=d(new Map);u(()=>{E.current={detailId:T},D.current=null},[T]);let A=l(async e=>{let t=String(e||``).trim();if(!t)return;if(E.current.detailId===t&&E.current.information)return E.current.information;let r=m.get(t);if(r)return E.current={detailId:t,information:r},r;let i=S(t).map(e=>w.getQueryData(e)).map(x).find(Boolean);if(i)return E.current={detailId:t,information:i},m.set(t,i),i;if(D.current?.detailId===t)return await D.current.promise;if(h.has(t)){let e=await h.get(t);return e&&(E.current={detailId:t,information:e}),e}let a=n({id:t}).then(e=>{let n=x(e);if(n)return E.current={detailId:t,information:n},m.set(t,n),n});D.current={detailId:t,promise:a},h.set(t,a);try{return await a}finally{D.current?.detailId===t&&(D.current=null),h.get(t)===a&&h.delete(t)}},[w]),j=l(async t=>{let n=String(t||``).trim();if(!n)return``;let r=O.current.get(n);if(r)return r;let a=k.current.get(n);if(a)return await a;let o=(async()=>{try{let t=await e(n);if(!t)return``;let r=i(t.bytes);return O.current.delete(n),O.current.set(n,r),b(O.current),r}catch{return``}finally{k.current.delete(n)}})();return k.current.set(n,o),await o},[]),M=l(async e=>{let t=String(e||``).trim();if(!t)return``;let n=j(t),r,i=new Promise(e=>{r=setTimeout(()=>{e(``)},150)}),a=await Promise.race([n,i]);return r!==void 0&&clearTimeout(r),a},[j]),N=l(async()=>{let e;for(let t=0;t<2;t++){let t=y();if(e=await A(t.detailId),y().detailId===t.detailId)break}let t=y(),n=a(Array.isArray(e?.links)?e.links:[],t.currentSeriesNum),r=n[0]?await o(n[0]):``,i=e?.name||``,s=String(t.detailId||``).trim(),c=t.currentSeriesNum;return{poster:await M(String(e?.img_y||e?.img_x||e?.preview_images?.[0]||``).trim()),src:r,title:i,contentId:s,episode:c}},[A,M]),P=l(async()=>{if(!t.getState().isLogin)return null;let e=y();if(!e.detailId)return null;let n=await c([e.detailId],1);return n?.interaction_list?.[0]?n.interaction_list[0].browse_record:null},[]),F=l(async e=>{if(!t.getState().isLogin)return;let n=y();if(!n.detailId)return;let i=e.browse_episode||n.currentSeriesNum,a=Date.now(),o=String(e.browse_key||a);try{await r({app_id:0,content_type:1,content_id:n.detailId,browse_duration:Number(e.browse_duration||0),browse_episode:String(i),browse_key:o,browse_page_ts:a})}catch{console.error(`上报播放进度失败`)}},[]),I=l(()=>{let e=s.getState(),t=!!e.isOpen,n=g();return!t&&!n?!0:(t&&e.close(),n&&_(),!1)},[]);u(()=>{if(!C||typeof window>`u`)return;let e=window;return e.getVideoInfoAsync=N,e.getVideoBrowseRecordAsync=P,e.reportVideoProgress=F,e.guardWebViewNavigation=I,()=>{e.getVideoInfoAsync===N&&delete e.getVideoInfoAsync,e.getVideoBrowseRecordAsync===P&&delete e.getVideoBrowseRecordAsync,e.reportVideoProgress===F&&delete e.reportVideoProgress,e.guardWebViewNavigation===I&&delete e.guardWebViewNavigation}},[P,N,I,C,F])}export{C as useVideoDetailWebViewBridge};
|
|
@@ -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 组件属性。 */
|