Your Name 1912bcd25b
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
chore: sync all remaining local workspace changes
2026-05-08 11:26:57 +08:00

538 lines
18 KiB
JavaScript

/*
* Extracted from browser-delivered Turbopack chunk: e85c4c56b542d703.84dd924ae8.js
* Module id: 320562
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
var t = e.i(462214),
r = e.i(358379),
n = e.i(325528);
e.i(693602);
var a = e.i(452678),
o = e.i(284309),
i = e.i(41671),
l = e.i(395);
e.i(260097);
var s = e.i(632341),
c = e.i(930686),
u = e.i(756156),
d = e.i(254119),
p = e.i(216257),
m = e.i(2876),
f = e.i(775989);
let h = new Map(),
g = 0;
async function y(e) {
try {
let t = await fetch(e, {
method: "GET",
credentials: "omit",
mode: "cors",
cache: "default",
});
await t.arrayBuffer();
} finally {
g--;
}
}
let v = (0, r.memo)(function ({
project: e,
activeTagName: v,
storeSource: x = "community",
onClick: b,
onLike: w,
className: N = "",
}) {
let C = (0, d.useIsMobileSimple)(),
{
coverUrl: E,
avatar: T,
nickname: k,
name: A,
templateUuid: S,
snapshotId: _,
finalOutput: j,
ownerUuid: R,
awardedTag: L,
tags: O,
userTags: M,
} = e,
D = (0, p.useCommunityStore)((t) => t.items.find((t) => t.id === e.id)),
P = (0, p.useActivityAwardedStore)((t) =>
t.items.find((t) => t.id === e.id),
),
I = "activityAwarded" === x ? P : D,
U = I?.isLiked ?? e.isLiked,
F = I?.likeCount ?? e.likeCount,
H = (0, o.useRouter)(),
z = (0, r.useRef)(null),
[G, B] = (0, r.useState)(!1),
[W, Y] = (0, r.useState)(void 0),
$ = (0, r.useRef)(!1),
V = (0, r.useRef)(!1),
X = (0, r.useMemo)(() => M?.[0]?.icon, [M]),
K = (0, r.useMemo)(
() => O?.find((e) => 5 === e.tagType && 0 === e.parentTag)?.tagLabel,
[O],
),
Z = (0, r.useMemo)(
() => (L?.length && K ? `${K} - ${L?.[0]}` : ""),
[L, K],
);
(0, u.useHlsPlayback)(z, W, { preferMinResolution: !0 });
let q = (0, r.useCallback)(() => {
if (!j || C) return;
($.current = !0),
(function (e) {
if (!e || "string" != typeof e || h.has(e) || g >= 2) return;
g++;
let t = y(e).finally(() => h.delete(e));
h.set(e, t);
})(((0, f.isHlsUrl)(j) ? j : (0, f.videoToHlsUrl)(j)) || j),
S && H.prefetch(`/detail/${S}`);
let e = z.current;
e &&
(V.current
? ((e.currentTime = 0), e.play().catch(() => void 0), B(!0))
: Y(j));
}, [j, C, S, H]),
J = (0, r.useCallback)(() => {
($.current = !1), B(!1);
let e = z.current;
e && e.pause();
}, []),
Q = (0, r.useCallback)(() => {
(V.current = !0),
$.current && (B(!0), z.current?.play().catch(() => void 0));
}, []),
ee = (0, r.useCallback)(
(e) => {
e.stopPropagation(), w?.(e);
},
[w],
);
return (0, t.jsxs)("div", {
className: `group relative cursor-pointer overflow-hidden rounded-lg transition-colors duration-200 hover:bg-[#F5F5F5] sm:rounded-xl dark:hover:bg-[rgba(31,31,31,0.85)] ${N}`,
onClick: b,
children: [
(0, t.jsxs)("div", {
className:
"relative aspect-video w-full overflow-hidden rounded-lg sm:rounded-xl",
onMouseEnter: q,
onMouseLeave: J,
children: [
(0, t.jsx)(l.default, {
src: (0, a.compressByFormatAndResizeWidth)(
E || c.DEFAULT_COVER_URL,
900,
),
alt: A || "社区作品",
className:
"bg-bg-surface h-full w-full object-cover transition-transform duration-300",
}),
j &&
(0, t.jsx)("video", {
ref: z,
className: `absolute inset-0 h-full w-full object-cover transition-opacity duration-200 ${G ? "opacity-100" : "opacity-0"}`,
loop: !0,
playsInline: !0,
preload: "none",
disablePictureInPicture: !0,
disableRemotePlayback: !0,
crossOrigin: "anonymous",
onLoadedData: Q,
}),
],
}),
Z &&
(0, t.jsxs)("div", {
className:
"absolute left-2 top-2 flex items-center gap-0.5 rounded-lg bg-black/65 px-2 py-1 text-xs text-[#ffc65d] opacity-100 backdrop-blur-[16px] group-hover:opacity-0 group-hover:delay-0",
children: [
(0, t.jsx)(i.Icons.RiceEar, { className: "text-[14px]" }),
Z,
(0, t.jsx)(i.Icons.RiceEar, {
className: "scale-x-[-1] text-[14px]",
}),
],
}),
(0, t.jsx)("div", {
className:
"absolute right-3 top-3 flex items-center gap-1 opacity-0 transition-opacity delay-150 duration-200 group-hover:opacity-100 group-hover:delay-0",
children: (0, t.jsxs)("div", {
className:
"flex cursor-pointer items-center gap-1 rounded-lg bg-black/40 px-3 py-2 backdrop-blur-[1px] transition-colors hover:bg-black/60",
onClick: ee,
children: [
(0, t.jsx)("span", {
className:
"flex h-4 w-4 shrink-0 items-center justify-center",
children: U
? (0, t.jsx)(i.Icons.LikeF, {
className: "text-status-error h-4 w-4",
})
: (0, t.jsx)(i.Icons.LikeL, {
className: "h-4 w-4 text-white",
}),
}),
(0, t.jsx)("span", {
className: `text-xs font-medium tabular-nums ${U ? "text-status-error" : "text-white"}`,
children: (0, m.countFormat)(F),
}),
],
}),
}),
(0, t.jsx)("div", {
className: "px-2 py-3",
onClick: (e) => e.stopPropagation(),
children: (0, t.jsxs)("div", {
className: "flex items-center justify-between",
children: [
(0, t.jsxs)("div", {
className: "min-w-0 flex-1",
children: [
(0, t.jsxs)("div", {
className: "flex items-center gap-2",
onClick: (e) => {
e.stopPropagation(),
R &&
window.open(
`${n.config.siteUrl}/userpage/${R}/publish/libtv`,
"_blank",
);
},
children: [
(0, t.jsx)("div", {
className:
"border-hair border-border-default bg-bg-surface-secondary h-5 w-5 shrink-0 overflow-hidden rounded-full",
children: (0, t.jsx)("img", {
src: (0, a.compressByFormatAndResizeWidth)(
T || c.DEFAULT_AVATAR,
60,
),
alt: k,
className: "h-full w-full object-cover",
}),
}),
(0, t.jsx)("span", {
className: "text-fg-default truncate text-sm",
children: k,
}),
X &&
(0, t.jsx)("div", {
className: "flex flex-shrink-0 items-center gap-1",
children: (0, t.jsx)("img", {
src: X,
alt: "AuthorTag",
className: "h-4",
}),
}),
],
}),
(0, t.jsx)("p", {
className: "text-fg-secondary mt-1 truncate text-xs",
children: A || "",
}),
],
}),
(0, t.jsx)(s.ViewProcessModal, {
tabName: v,
templateUuid: S,
project: e,
className:
"max-w-0 shrink-0 overflow-hidden opacity-0 transition-all delay-150 duration-200 group-hover:max-w-[150px] group-hover:opacity-100 group-hover:delay-0",
disabled: !_,
}),
],
}),
}),
],
});
});
e.s(["default", 0, v], 334761);
var x = e.i(23741),
b = e.i(369965).default ? r.useLayoutEffect : r.useEffect,
w = e.i(230564);
let N = (e, t) => void 0 !== t[e],
C = {};
var E = e.i(247212),
T = e.i(365117),
k = e.i(58372);
let A = "1" === x.default.env.NEXT_PUBLIC_DEBUG_FEED;
function S(e, t) {
A && console.debug(`[liblibtv-feed] ${e}`, t ?? "");
}
function _({
onFetch: e,
renderCard: n,
storeAdapter: a,
cacheKey: o,
pageSize: i = 20,
maxColumnCount: l = 4,
columnGutter: s = 16,
rowGutter: c = 16,
padding: u = 0,
ratio: d,
stickyTop: p = 0,
emptyText: m = "暂无作品",
minHeight: f = "calc(100vh - 150px)",
className: h = "",
}) {
let g = (0, r.useRef)(null),
[y, v] = (0, r.useState)(!1),
[x, A] = (0, r.useState)(void 0),
{
items: _,
setItems: j,
reset: R,
cacheMeta: L,
setCacheMeta: O,
cacheScrollY: M,
setCacheScrollY: D,
} = a,
P = (0, r.useRef)(_);
P.current = _;
let I = null != o;
b(() => {
if (!I || !o) return;
let { keyword: e = "", tagCode: t } = o;
_.length > 0 &&
null !== L &&
L.keyword === (e?.trim?.() ?? "") &&
L.tagCode === t &&
M > 0 &&
g.current &&
((g.current.style.minHeight = `${M + window.innerHeight}px`),
window.scrollTo(0, M)),
v(!0);
}, []);
let U = (0, k.usePageLoader)({
onFetch: async (t) => {
let r = await e(t);
return (
I &&
o &&
O({
page: t.page + 1,
hasMore: r.hasMore,
keyword: o.keyword?.trim?.() ?? "",
tagCode: o.tagCode,
}),
r
);
},
pagers: { page: 1, size: i },
}),
{ items: F, isLoaded: H, hasMore: z, isLoading: G } = U,
B = G && H,
W = (0, r.useRef)(U);
W.current = U;
let Y = _.length > 0 ? _ : F,
$ = (0, r.useMemo)(
() => Math.min(16, Math.max(8, Math.floor(i / 2))),
[i],
),
V = (function (e, t) {
void 0 === t && (t = C);
let {
isItemLoaded: n,
minimumBatchSize: a = 16,
threshold: o = 16,
totalItems: i = 9e9,
} = t,
l = (0, w.default)(e),
s = (0, w.default)(n);
return r.useCallback(
(e, t, r) => {
let n = (function (e, t, r, n, a, o) {
void 0 === e && (e = N),
void 0 === t && (t = 16),
void 0 === n && (n = 9e9);
let i = [],
l,
s,
c = a;
for (; c <= o; c++)
e(c, r)
? void 0 !== l &&
void 0 !== s &&
(i.push(l, s), (l = s = void 0))
: ((s = c), void 0 === l && (l = c));
if (void 0 !== l && void 0 !== s) {
let a = Math.min(Math.max(s, l + t - 1), n - 1);
for (c = s + 1; c <= a; c++)
if (e(c, r)) break;
else s = c;
i.push(l, s);
}
if (i.length) {
let n = i[0],
a = i[1];
for (; a - n + 1 < t && n > 0; ) {
let t = n - 1;
if (e(t, r)) break;
i[0] = n = t;
}
}
return i;
})(
s.current,
a,
r,
i,
Math.max(0, e - o),
Math.min(i - 1, (t || 0) + o),
);
for (let e = 0; e < n.length - 1; ++e) l.current(n[e], n[++e], r);
},
[i, a, o, l, s],
);
})(
(0, r.useCallback)((e, t, r) => {
let n = W.current;
n.isLoading || !n.hasMore
? S("skip loadMore", {
startIndex: e,
stopIndex: t,
itemCount: r.length,
isLoading: n.isLoading,
hasMore: n.hasMore,
})
: (S("loadMore", {
startIndex: e,
stopIndex: t,
itemCount: r.length,
}),
n.loadMore());
}, []),
{ totalItems: z ? 9e9 : Y.length, threshold: $, minimumBatchSize: $ },
);
(0, r.useEffect)(() => {
F.length > 0 && j(F);
}, [F, j]),
(0, r.useEffect)(() => {
_.length > 0 &&
void 0 !== x &&
requestAnimationFrame(() => {
A(void 0);
let e = document.querySelector("html");
e && (e.style.height = "");
});
}, [_.length, x]);
let X = (0, r.useRef)(0);
(0, r.useEffect)(() => {
if (!I) return;
X.current = window.scrollY;
let e = () => {
X.current = window.scrollY;
};
return (
window.addEventListener("scroll", e, { passive: !0 }),
() => {
window.removeEventListener("scroll", e), D(X.current);
}
);
}, [I, D]),
(0, r.useEffect)(() => {
if (!I || !o) {
v(!0), R(), U.refresh();
return;
}
let { keyword: e = "", tagCode: t } = o;
_.length > 0 &&
null !== L &&
L.keyword === (e?.trim?.() ?? "") &&
L.tagCode === t &&
L
? (U.restoreFromCache(_, L.page, L.hasMore),
requestAnimationFrame(() => {
g.current && (g.current.style.minHeight = "");
}))
: (R(), U.refresh());
}, []);
let K = (0, r.useRef)(!0);
(0, r.useEffect)(() => {
if (!I || !o) return;
if (K.current) {
K.current = !1;
return;
}
let e =
p > 0 && g.current && g.current.getBoundingClientRect().top <= p + 60;
g.current && A(g.current.offsetHeight),
R(),
U.refresh()
.finally(() => {
A(void 0);
})
.then(() => {
if (e && g.current) {
let e = g.current.previousElementSibling?.offsetHeight ?? 0,
t = 0,
r = g.current;
for (; r; ) (t += r.offsetTop), (r = r.offsetParent);
window.scrollTo({ top: t - p - e, behavior: "instant" });
}
});
}, [o?.keyword, o?.tagCode]);
let Z = (0, r.useRef)(n);
Z.current = n;
let q = (0, r.useCallback)((e) => {
let { data: t, index: r, width: n } = e,
a = P.current;
return Z.current({ data: t, index: r, width: n, storeItems: a });
}, []);
return (0, t.jsxs)("div", {
ref: g,
className: h,
style: { minHeight: void 0 !== x ? x : f },
children: [
!_.length &&
(G || !H) &&
(0, t.jsx)(T.MasonryLoading, {
padding: u,
maxColumnCount: l,
columnGutter: s,
rowGutter: c,
ratio: d,
}),
!_.length &&
!F.length &&
H &&
!G &&
(0, t.jsx)("div", {
className:
"flex flex-col items-center justify-center py-20 text-white/40",
children: (0, t.jsx)("p", { className: "text-lg", children: m }),
}),
(_.length > 0 || F.length > 0) &&
y &&
(0, t.jsxs)(t.Fragment, {
children: [
(0, t.jsx)(E.default, {
items: Y,
render: q,
onRender: V,
maxColumnCount: l,
columnGutter: s,
rowGutter: c,
padding: u,
ratio: d,
}),
B && (0, t.jsx)(T.BottomLoading, {}),
!z &&
H &&
(_.length > 0 || F.length > 0) &&
(0, t.jsx)(T.NoMoreItems, {}),
],
}),
],
});
}
e.s([], 973652), e.s(["GenericMasonryList", () => _], 320562);
};
export default moduleFactory;