Peach: Local-first video metadata scraper and media manager.
fix(web): 收藏导航复用设置滚动与标题反馈
longmeidaoea2e71b507ec
diff --git a/frontend/e2e/follow-feed.test.ts b/frontend/e2e/follow-feed.test.tsindex cafa7f35b..7664f9e5a 100644--- a/frontend/e2e/follow-feed.test.ts+++ b/frontend/e2e/follow-feed.test.ts@@ -258,7 +258,7 @@ describe('关注页岛', () => {}});- it('来源角标接得住指针,悬停能读到来源名;点它照样进详情', { timeout: 60_000 }, async () => {+ it('封面左上角可打开详情,悬停时隐藏来源角标', { timeout: 60_000 }, async () => {const opened = await openFollowFeed(browser, '/follow', DESKTOP);try {const page = opened.page;@@ -271,11 +271,11 @@ describe('关注页岛', () => {});assert.equal(hit.badge, true, '角标中心命中的不是角标本身');assert.ok(hit.title, '角标没有来源名');- await card.locator('[data-media-badge]').hover();- const tip = page.locator('#board-control-tooltip');- await tip.waitFor({ state: 'visible', timeout: 5_000 });- assert.equal(await tip.textContent(), hit.title);- await card.locator('[data-media-badge]').click();+ const corner = (await card.locator('[data-media-badge]').boundingBox())!;+ await card.hover();+ assert.equal(await card.locator('[data-media-badge]').isVisible(), false);+ assert.equal(await card.locator('[data-follow-sources]').evaluate(node => getComputedStyle(node).pointerEvents), 'none');+ await page.mouse.click(corner.x + corner.width / 2, corner.y + corner.height / 2);await page.waitForURL(`**/posts/${id}`);assert.deepEqual(withoutPlayer(opened.problems), []);} finally {diff --git a/frontend/src/react/library-shortcuts/shortcut-controls.tsx b/frontend/src/react/library-shortcuts/shortcut-controls.tsxindex 34cfc3fc3..7b450f9d9 100644--- a/frontend/src/react/library-shortcuts/shortcut-controls.tsx+++ b/frontend/src/react/library-shortcuts/shortcut-controls.tsx@@ -1,5 +1,5 @@import { useEffect, useId, useLayoutEffect, useRef, useState, type FormEvent, type KeyboardEvent } from 'react';-import { attachOverlayScrollbar, spinnerHtml } from '@peach/legacy/ui';+import { attachOverlayScrollbar, revealTexts, spinnerHtml, wireHorizontalScroller } from '@peach/legacy/ui';import { Button } from '@/components/base/buttons/button';import { Input } from '@/components/base/input/input';import { errorMessage } from '../../api';@@ -70,12 +70,22 @@ function ShortcutContents({ currentHref, kind, close }: { currentHref?: () => streturn () => media.removeEventListener('change', changed);}, []);const navigation = useRef<HTMLDivElement>(null);+ const head = useRef<HTMLDivElement>(null);+ const previousScope = useRef(scope);const pane = useRef<HTMLSpanElement>(null);const content = useRef<HTMLDivElement>(null);const scroll = useRef<(() => void) | null>(null);const glide = useViewGlide(pane, navigation, '[role="tab"][aria-selected="true"]', scope, { axis: 'y' });useLayoutEffect(() => { if (content.current) scroll.current = attachOverlayScrollbar(content.current) || null }, []);+ useLayoutEffect(() => {+ const scroller = wireHorizontalScroller(navigation.current);+ return () => scroller?.destroy();+ }, []);useLayoutEffect(() => { if (content.current) content.current.scrollTop = 0 }, [scope]);+ useLayoutEffect(() => {+ if (previousScope.current !== scope) revealTexts(head.current, 'h2');+ previousScope.current = scope;+ }, [scope]);useLayoutEffect(() => { scroll.current?.() });const label = SCOPES.find(([value]) => value === scope)?.[1] || '全部';const selectWithKeys = (event: KeyboardEvent<HTMLDivElement>) => {@@ -101,7 +111,7 @@ function ShortcutContents({ currentHref, kind, close }: { currentHref?: () => stconst rows = (data?.favorites || []).filter((row) => (scope === 'all' || row.kind === scope)&& row.name.toLocaleLowerCase().includes(search.trim().toLocaleLowerCase()));return <div data-shortcuts-panel="">- <div data-shortcuts-head="">+ <div ref={head} data-shortcuts-head=""><h2 className="text-title-2-semibold text-text-primary">{label}</h2><SettingsDialogClose label="关闭我的收藏" onPress={close} /></div>diff --git a/web/dist/peach-app.js b/web/dist/peach-app.jsindex 87ec4b011..f8dc72931 100644--- a/web/dist/peach-app.js+++ b/web/dist/peach-app.js@@ -40661,20 +40661,25 @@ function Zve({ currentHref: e, kind: t, close: n }) {let e = matchMedia("(max-width: 760px)"), t = () => h(e.matches);return e.addEventListener("change", t), () => e.removeEventListener("change", t);}, []);- let g = (0, b.useRef)(null), _ = (0, b.useRef)(null), v = (0, b.useRef)(null), y = (0, b.useRef)(null), S = GA(_, g, "[role=\"tab\"][aria-selected=\"true\"]", s, { axis: "y" });+ let g = (0, b.useRef)(null), _ = (0, b.useRef)(null), v = (0, b.useRef)(s), y = (0, b.useRef)(null), S = (0, b.useRef)(null), C = (0, b.useRef)(null), w = GA(y, g, "[role=\"tab\"][aria-selected=\"true\"]", s, { axis: "y" });(0, b.useLayoutEffect)(() => {- v.current && (y.current = ya(v.current) || null);+ S.current && (C.current = ya(S.current) || null);}, []), (0, b.useLayoutEffect)(() => {- v.current && (v.current.scrollTop = 0);+ let e = Fo(g.current);+ return () => e?.destroy();+ }, []), (0, b.useLayoutEffect)(() => {+ S.current && (S.current.scrollTop = 0);+ }, [s]), (0, b.useLayoutEffect)(() => {+ v.current !== s && po(_.current, "h2"), v.current = s;}, [s]), (0, b.useLayoutEffect)(() => {- y.current?.();+ C.current?.();});- let C = qN.find(([e]) => e === s)?.[1] || "全部", w = (e) => {+ let T = qN.find(([e]) => e === s)?.[1] || "全部", E = (e) => {let t = [...e.currentTarget.querySelectorAll("[role=\"tab\"]")], n = t.indexOf(e.target);if (n < 0) return;let r = e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : ["ArrowDown", "ArrowRight"].includes(e.key) ? (n + 1) % t.length : ["ArrowUp", "ArrowLeft"].includes(e.key) ? (n + t.length - 1) % t.length : -1;r < 0 || (e.preventDefault(), t[r].click(), t[r].focus());- }, T = (t) => {+ }, D = (t) => {t.preventDefault(), e && a.trim() && !i.isPending && i.mutate({action: "save_filter",name: a.trim(),@@ -40682,15 +40687,16 @@ function Zve({ currentHref: e, kind: t, close: n }) {}, { onSuccess: () => {o(""), f("筛选已保存");} });- }, E = r.data, D = (E?.favorites || []).filter((e) => (s === "all" || e.kind === s) && e.name.toLocaleLowerCase().includes(l.trim().toLocaleLowerCase()));+ }, O = r.data, k = (O?.favorites || []).filter((e) => (s === "all" || e.kind === s) && e.name.toLocaleLowerCase().includes(l.trim().toLocaleLowerCase()));return /* @__PURE__ */ (0, x.jsxs)("div", {"data-shortcuts-panel": "",children: [/* @__PURE__ */ (0, x.jsxs)("div", {+ ref: _,"data-shortcuts-head": "",children: [/* @__PURE__ */ (0, x.jsx)("h2", {className: "text-title-2-semibold text-text-primary",- children: C+ children: T}), /* @__PURE__ */ (0, x.jsx)(RN, {label: "关闭我的收藏",onPress: n@@ -40706,11 +40712,11 @@ function Zve({ currentHref: e, kind: t, close: n }) {"data-glass-pane": m ? "" : void 0,role: "tablist","aria-label": "收藏类型",- onKeyDown: w,- onPointerLeave: S.leave,+ onKeyDown: E,+ onPointerLeave: w.leave,children: [/* @__PURE__ */ (0, x.jsx)("span", {- ref: _,+ ref: y,"data-view-glide": "","data-shortcuts-glide": "","aria-hidden": "true",@@ -40722,7 +40728,7 @@ function Zve({ currentHref: e, kind: t, close: n }) {children: "我的收藏"}),qN.map(([e, t]) => {- let n = KN[e] || WN, r = e === "filters" ? E?.filters.length || 0 : (E?.favorites || []).filter((t) => e === "all" || t.kind === e).length;+ let n = KN[e] || WN, r = e === "filters" ? O?.filters.length || 0 : (O?.favorites || []).filter((t) => e === "all" || t.kind === e).length;return /* @__PURE__ */ (0, x.jsxs)("button", {type: "button",role: "tab",@@ -40731,7 +40737,7 @@ function Zve({ currentHref: e, kind: t, close: n }) {"aria-label": t,"aria-selected": s === e,tabIndex: s === e ? 0 : -1,- onPointerEnter: S.hover,+ onPointerEnter: w.hover,onClick: () => c(e),children: [/* @__PURE__ */ (0, x.jsx)(n, {@@ -40762,7 +40768,7 @@ function Zve({ currentHref: e, kind: t, close: n }) {})]}),/* @__PURE__ */ (0, x.jsxs)("div", {- ref: v,+ ref: S,"data-shortcuts-content": "",role: "tabpanel",id: `${p}-content`,@@ -40788,14 +40794,14 @@ function Zve({ currentHref: e, kind: t, close: n }) {tone: "error",children: B(i.error)}) : null,- E ? s === "filters" ? /* @__PURE__ */ (0, x.jsxs)(x.Fragment, { children: [- E.filters.length ? null : /* @__PURE__ */ (0, x.jsx)(Yk, {+ O ? s === "filters" ? /* @__PURE__ */ (0, x.jsxs)(x.Fragment, { children: [+ O.filters.length ? null : /* @__PURE__ */ (0, x.jsx)(Yk, {shell: "plain",icon: LN("list-filter"),title: "还没有保存的筛选",children: "在馆藏页保存当前条件,随时打开。"}),- E.filters.map((e) => /* @__PURE__ */ (0, x.jsxs)("div", {+ O.filters.map((e) => /* @__PURE__ */ (0, x.jsxs)("div", {className: "flex min-w-0 items-center justify-between gap-2",children: [/* @__PURE__ */ (0, x.jsx)("a", {href: e.href,@@ -40818,7 +40824,7 @@ function Zve({ currentHref: e, kind: t, close: n }) {})]}, e.id)),e ? /* @__PURE__ */ (0, x.jsxs)("form", {- onSubmit: T,+ onSubmit: D,className: "flex flex-col gap-3","aria-label": "保存当前筛选",children: [@@ -40849,15 +40855,15 @@ function Zve({ currentHref: e, kind: t, close: n }) {value: l,onChange: u}),- D.length ? null : /* @__PURE__ */ (0, x.jsx)(Yk, {+ k.length ? null : /* @__PURE__ */ (0, x.jsx)(Yk, {shell: "plain",icon: WN,- title: l ? "没有匹配的收藏" : E.favorites.length ? "还没有此类收藏" : "还没有收藏",+ title: l ? "没有匹配的收藏" : O.favorites.length ? "还没有此类收藏" : "还没有收藏",children: l ? "试试其他名称。" : "在资料页或标签页收藏常用内容。"}),/* @__PURE__ */ (0, x.jsx)("div", {"data-shortcuts-list": "",- children: D.map((e) => /* @__PURE__ */ (0, x.jsxs)("div", {+ children: k.map((e) => /* @__PURE__ */ (0, x.jsxs)("div", {"data-shortcuts-row": "",className: "flex min-w-0 items-center justify-between gap-3",children: [/* @__PURE__ */ (0, x.jsxs)("a", {