Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 实体播放墙沿用规范筛选范围

longmeidaob6d694bdd6f7
diff --git a/frontend/src/application/catalog.js b/frontend/src/application/catalog.js
index b8bf0fe46..9aedf1351 100644
--- a/frontend/src/application/catalog.js
+++ b/frontend/src/application/catalog.js
@@ -533,7 +533,12 @@ export function installCatalog7() {
}
export function installCatalog12() {
-applicationEffects.handler($('#wallBtn'), 'onclick', ()=>{setSelectMode(false,true);navigationState.navigatePath(wallAddress(undefined,{...entityState.activeFilterState(),jav:javActive()?'1':''}))});
+applicationEffects.handler($('#wallBtn'), 'onclick', ()=>{
+ setSelectMode(false,true);
+ const context=currentBarsContext(),filters={...entityState.activeFilterState(),jav:javActive()?'1':''};
+ if(context.type==='entity'&&context.kind!=='tag')filters[context.kind]=context.name;
+ navigationState.navigatePath(wallAddress(undefined,filters));
+});
catalogState.mixRelatedCache = new Map();
catalogState.reduceMotion = ()=>matchMedia('(prefers-reduced-motion:reduce)').matches;
catalogState.tagList = (value=state.tag)=>String(value||'').split(',').filter(Boolean);
diff --git a/frontend/src/react/bundle.d.ts b/frontend/src/react/bundle.d.ts
index f89c7240d..5689119d2 100644
--- a/frontend/src/react/bundle.d.ts
+++ b/frontend/src/react/bundle.d.ts
@@ -320,7 +320,7 @@ export interface StatsProps {
export interface TasteProps {
/** 点一条名次:回目录并按它筛选。`kind` 是 `tag`/`creator`/`performer`。 */
onSignal(kind: string, name: string): void;
- /** 去口味总结里指的那一页(`#/manage/scraping` 这类遗留路由)。 */
+ /** 打开口味总结指向的页面。 */
navigate(route: string): void;
/** 写操作在服务端落地之后的过去时回执。 */
toast(message: string): void;
diff --git a/frontend/src/react/settings/configuration-page.css b/frontend/src/react/settings/configuration-page.css
index c6d2b999f..baec2fef6 100644
--- a/frontend/src/react/settings/configuration-page.css
+++ b/frontend/src/react/settings/configuration-page.css
@@ -1,4 +1,4 @@
-/* 配置页(/configuration)与诊断页的外壳:正文跟管理区页头钉在同一条中线上(web/board.css 里
+/* 配置页(/settings/library)与诊断页的外壳:正文跟管理区页头钉在同一条中线上(web/board.css 里
`.scraping-page` 那一条的说明),配置骨架(`configuration-skeleton.ts`、`ui-kit/skeleton.ts`)也挂这一层。
分组小标题 `h2.ui-configgroup` 只在外壳里占位,字已经写在页签上,样式里不显示。 */
.ui-configpage{width:100%;max-width:var(--board-content);margin:0 auto;display:grid;gap:20px}
diff --git a/frontend/src/react/video-wall/wall-route.ts b/frontend/src/react/video-wall/wall-route.ts
index 0c8aa0da3..ed6e6518f 100644
--- a/frontend/src/react/video-wall/wall-route.ts
+++ b/frontend/src/react/video-wall/wall-route.ts
@@ -1,15 +1,23 @@
import { peachHistory } from '@peach/history';
import { isCatalogPath, ROUTE_STATES } from '@peach/legacy/core';
+import { entityLinkName } from '../../core/entity-links';
export function wallAddress(from = `${location.pathname}${location.search}`, filters: Readonly<Record<string, string>> = {}): string {
const source = new URL(from, location.origin);
const [section, ...parts] = source.pathname.split('/').filter(Boolean);
- const kind = ({ performers: 'performer', creators: 'creator', studios: 'studio', series: 'series' } as Record<string, string>)[section || ''];
+ const kind = ({ performers: 'performer', creators: 'creator', studios: 'studio', series: 'series', tags: 'tag' } as Record<string, string>)[section || ''];
const scoped = (isCatalogPath(source.pathname) && source.pathname !== '/junk-files') || source.pathname === '/jav' || !!(kind && parts.length);
const params = new URLSearchParams(scoped ? source.search : '');
for (const [key, value] of Object.entries(filters)) if (value && (scoped || ['jav','loc'].includes(key))) params.set(key, value);
if (scoped && ROUTE_STATES[source.pathname]) params.set('state', ROUTE_STATES[source.pathname]!);
- if (kind && parts.length) params.set(kind, decodeURIComponent(parts.join('/')));
+ if (kind && parts.length) {
+ const identity = decodeURIComponent(parts.join('/'));
+ const name = /^[0-9]+$/.test(identity) ? entityLinkName(kind, Number(identity)) : identity;
+ if (name && kind === 'tag') {
+ params.set('tag', [...new Set([name, ...(params.get('tag') || '').split(',').filter(Boolean)])].join(','));
+ params.set('tag_match', 'all');
+ } else if (name && !params.has(kind)) params.set(kind, name);
+ }
params.set('returnTo', `${source.pathname}${source.search}`);
return `/wall?${params}`;
}
diff --git a/frontend/test/react/wall-route.test.ts b/frontend/test/react/wall-route.test.ts
index 30a870440..56b8b73fe 100644
--- a/frontend/test/react/wall-route.test.ts
+++ b/frontend/test/react/wall-route.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import { wallAddress } from '../../src/react/video-wall/wall-route';
+import { registerEntityLink } from '../../src/core/entity-links';
describe('播放墙独立入口', () => {
it('全局入口保留返回地址,非作品页使用馆藏范围', () => {
@@ -34,4 +35,18 @@ describe('播放墙独立入口', () => {
expect(target.searchParams.get('tag')).toBe('风景');
expect(target.searchParams.get('jav')).toBe('1');
});
+ it('数字实体地址转换为规范名字,显式上下文保持优先', () => {
+ registerEntityLink('performer', 'Alice', 71);
+ const target = new URL(wallAddress('/performers/71?jav=1', { tag: '风景' }), location.origin);
+ expect(target.searchParams.get('performer')).toBe('Alice');
+ expect(target.searchParams.get('returnTo')).toBe('/performers/71?jav=1');
+ expect(new URL(wallAddress('/performers/71', { performer: '当前规范名' }), location.origin)
+ .searchParams.get('performer')).toBe('当前规范名');
+ });
+ it('标签资料进入播放墙时沿用标签交集', () => {
+ registerEntityLink('tag', '巨乳', 72);
+ const target = new URL(wallAddress('/tags/72?tag=口交'), location.origin);
+ expect(target.searchParams.get('tag')).toBe('巨乳,口交');
+ expect(target.searchParams.get('tag_match')).toBe('all');
+ });
});
diff --git a/src/peach/web_state.py b/src/peach/web_state.py
index e92a57d7e..f184f77e6 100644
--- a/src/peach/web_state.py
+++ b/src/peach/web_state.py
@@ -171,7 +171,7 @@ class WebContract:
self.revision_cache_keys: set[str] = set()
self.aggregate_locks: dict[str, threading.RLock] = {}
self.follow_check_lock = threading.Lock()
- #: 任务中心。每个后台任务的开始、进度与结束都写这一张表,`/activity` 只读它。
+ #: 任务中心。每个后台任务的开始、进度与结束都写这一张表,`/tasks` 只读它。
#: 只读端由 `api` 关掉写入:那边的账本是复制来的,写一行就是一处合不回去的分叉。
self.task_runs = TaskRunStore(self.database)
#: 云下载后处理复用 Web 层的垃圾评分与整理设置,但核心后继不反向依赖 Web。
diff --git a/tests/test_entity_redirect.py b/tests/test_entity_redirect.py
index bfd154b8a..f5c30225f 100644
--- a/tests/test_entity_redirect.py
+++ b/tests/test_entity_redirect.py
@@ -329,6 +329,9 @@ class EntityRedirectRouteTests(unittest.TestCase):
facets = q_facets(contract, filters={'tag': 'Tag A'})
self.assertEqual(facets['stats']['total'], profile['asset_count'])
self.assertEqual({item['k']: item['n'] for item in facets['tags']}, {'Tag A': 1, 'Visible only': 1})
+ scoped_facets = q_facets(contract, scope_kind='tag', scope_name='Tag A')
+ self.assertEqual(scoped_facets['stats']['total'], profile['asset_count'])
+ self.assertEqual(scoped_facets['tags'], facets['tags'])
with sqlite3.connect(self.app.state.settings.db_path) as connection:
connection.execute("UPDATE asset_tag_preference SET hidden=0 WHERE normalized_tag='tag a'")
diff --git a/web/dist/peach-app.js b/web/dist/peach-app.js
index 1bf8c70ae..d6c742d2b 100644
--- a/web/dist/peach-app.js
+++ b/web/dist/peach-app.js
@@ -46996,10 +46996,15 @@ function Cbe(e = `${location.pathname}${location.search}`, t = {}) {
performers: "performer",
creators: "creator",
studios: "studio",
- series: "series"
+ series: "series",
+ tags: "tag"
}[r || ""], o = Nt(n.pathname) && n.pathname !== "/junk-files" || n.pathname === "/jav" || !!(a && i.length), s = new URLSearchParams(o ? n.search : "");
for (let [e, n] of Object.entries(t)) n && (o || ["jav", "loc"].includes(e)) && s.set(e, n);
- return o && jt[n.pathname] && s.set("state", jt[n.pathname]), a && i.length && s.set(a, decodeURIComponent(i.join("/"))), s.set("returnTo", `${n.pathname}${n.search}`), `/wall?${s}`;
+ if (o && jt[n.pathname] && s.set("state", jt[n.pathname]), a && i.length) {
+ let e = decodeURIComponent(i.join("/")), t = /^[0-9]+$/.test(e) ? xt(a, Number(e)) : e;
+ t && a === "tag" ? (s.set("tag", [.../* @__PURE__ */ new Set([t, ...(s.get("tag") || "").split(",").filter(Boolean)])].join(",")), s.set("tag_match", "all")) : t && !s.has(a) && s.set(a, t);
+ }
+ return s.set("returnTo", `${n.pathname}${n.search}`), `/wall?${s}`;
}
function GP() {
let e = new URLSearchParams(FO.navigation.location.search).get("returnTo") || "/";
@@ -102756,10 +102761,12 @@ function Rlt() {
}
function zlt() {
Y5.handler(L("#wallBtn"), "onclick", () => {
- y7(!1, !0), Q.navigatePath(Cbe(void 0, {
+ y7(!1, !0);
+ let e = l7(), t = {
...o7.activeFilterState(),
jav: V7() ? "1" : ""
- }));
+ };
+ e.type === "entity" && e.kind !== "tag" && (t[e.kind] = e.name), Q.navigatePath(Cbe(void 0, t));
}), X.mixRelatedCache = /* @__PURE__ */ new Map(), X.reduceMotion = () => matchMedia("(prefers-reduced-motion:reduce)").matches, X.tagList = (e = W.tag) => String(e || "").split(",").filter(Boolean), X.tagPressed = (e, t) => X.tagList(e).includes(String(t)), X.withTagToggled = (e, t) => {
let n = X.tagList(e), r = n.indexOf(t);
return r >= 0 ? n.splice(r, 1) : n.push(t), n.join(",");