Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix: count vision_creator tags and gate review approval on candidate status

Peach local maintenance7f97035f661f
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index 3f52d714f..569300f4a 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -1,5 +1,7 @@
# Peach 交接与长期工作约定
+本文件只保存跨任务长期有效的事实和工作规则,不记录逐次聊天流水。
+
## 界面、媒体与复核的既定判据
- 卡片实体链接必须由同一个 `{kind,name}` 结构生成,禁止先独立选择显示名、再根据其他字段推断类型。此前 `FSDSS-376-C.mp4` 显示演员 `新ありな`,却因同时存在厂牌而生成 `/studios/新ありな`;真实 ledger 关系是演员 `新ありな`、厂牌 `FALENO`,错误只在前端映射。
@@ -11,15 +13,16 @@
- 分片缓存写在 `stream_root/<asset>/<size>-<mtime>-<秒数>/<index>.ts`,不随响应删除:回放、断线重连和多设备都会重复请求同一段,每次重跑 FFmpeg 等于让 CloudDrive 再预取一次块。缓存按最后访问时间淘汰,指纹带文件大小和 mtime,换了片源自然失效。FFmpeg 并发有信号量闸门(默认 CPU 核数一半),播放器本身就会并发预取多段。
- 回收站的物理删除只有一条实现:`purge_assets()`,`/api/batch` 的 `delete` 和 `/api/trash/empty` 共用它。顺序固定为先删媒体文件、再删账本行,删不掉的文件整条跳过并在 `blocked` 里回报,前端必须把 `blocked` 显示出来。反过来先删行会留下没人认领的媒体文件,那是真正不可恢复的丢失;留一条指向缺失文件的回收站行至少还能看见和重试。`asset_search` 不列入 `ASSET_REFERENCE_TABLES`,FTS 行由 `0004` 的删除触发器负责。
- 复核候选文件名带批次日期,代码里只认前缀并取目录里最新的一份;把日期写死会让下一批生成后页面静默变空。候选行必须有稳定主键(`board`/`studio`/`entity_id`),缺主键的行跳过并计数,绝不退化成行号——行号会在 CSV 重排后把历史决定挪到别的条目上。候选目录走 `PeachSettings.candidate_root`,不是模块常量,否则测试会读到真实的 `R:\peach-data\generated`。
-- 批准的权威值只能来自候选文件本身,请求体里的 `creator`/`tags` 只当确认,不一致直接拒绝。否则「批准候选 X」能写入与 X 无关的标签,而 `review_decision` 留痕仍写着 X 通过——留痕说通过、实际写了别的,是最糟的组合。未勾选即整条通过,但受 `REVIEW_APPLY_LIMIT` 约束,超限必须显式勾选。
+- 批准的权威值只能来自候选文件本身,请求体里的 `creator`/`tags` 只当确认,不一致直接拒绝;只有 `status=candidate` 的创作者候选可以批准,`skip` 行必须在页面禁用批准。否则「批准候选 X」能写入与 X 无关的标签,而 `review_decision` 留痕仍写着 X 通过——留痕说通过、实际写了别的,是最糟的组合。未勾选即整条通过,但受 `REVIEW_APPLY_LIMIT` 约束,超限必须显式勾选。
- 抽帧的 bt709 覆盖重试只针对坏色彩元数据(stderr 命中 `reserved/unsupported/invalid` + 色彩词)。无条件重试会让网盘超时这类必然失败的文件每帧白跑第二次,单帧最坏耗时从 45 秒翻到 90 秒。判据依赖 stderr,所以不能丢弃 `capture_output` 的错误流。
- Logo 与头像在界面上都渲染成方框(厂牌方图、女优 160×160 圆头像),候选按实测像素比例处理,判据在 `peach.images.classify`:长宽比 ≤1.35 直接用,更长的补自身四角底色填成正方形(`pad_to_square`,不是刷白也不是裁切),短边 <128 才拒绝。只有 URL 没有实测尺寸不算候选。
- **AV 厂牌 Logo 的来源是厂牌自己的社交账号头像**:社交头像天然是正方形且由品牌本人发布。取证顺序是 handle → `unavatar.io` 解析出 `pbs.twimg.com` 真实地址 → 从平台 CDN 下载 → 实测,unavatar 只用于解析地址,provenance 两者都记(`scripts/fetch_studio_avatar_candidates.py`)。r18.dev 详情 JSON 只有 `maker.name`/`label.name` 和作品封面,没有 Logo 资源,已排除。
- **能解析不等于是对的品牌**:`@bazooka` 确实存在且能取到 400×400 头像,但那是 2007 年注册的通用账号,不是这个 AV 厂牌;Wikimedia 搜同名也给出 16:9 的泡泡糖品牌图。所以 handle 必须逐个取证确认,脚本默认不猜,`--guess-handles` 的产出一律标 `needs_confirmation` 且不自动采纳。查不到就留空。
+- 社交 handle 只采信**厂牌自有域名页面上**的链接。日文维基条目的外链里混着引用来源的新闻站,直接抓会把新闻站自己的账号当成厂牌的——实测 `妄想族` 条目就抓出了 `@news_postseven` 与 `@taishurxjp`。官网链接也不必然指向主号:`gloryquest.tv` 链的是 `@lG_Ql`「社内クリエイティ部(BOT)」,头像压着 18+ 徽标,反而不如 `@gloryquest_av` 的干净字标合适。所以官网只用来确认归属,选哪个号仍要看图。
+- AV 厂牌官网普遍先给年龄确认页,不穿过它只能拿到约 10 KB 的空壳。判据必须是锚文本而不是 URL:否定链接指向站外(实测 `dasdas.jp`、`muku.tv` 的「いいえ」都指向 dmm.com),肯定链接「はい(入室する)」指向站内,两者的 href 看不出区别。跟错就离开了厂牌域名,抓到的账号也就不再属于这个厂牌。实现见 `scripts/find_studio_socials.py`,`test_age_gate_is_crossed_by_the_affirmative_link_only` 守这条线。
- 二手结论不能当证据:搜索摘要曾称 `@EBODY_` 已注销,实测直接解析到 400×400 活跃头像。凡是「某账号/端点已失效」这类判断,取证方式是自己请求一次,不是转述搜索结果。
-- 人工复核入口固定为 `/review`,候选 API 为 `GET /api/review`、`POST /api/review/decision`。候选来自 `R:\peach-data\generated` 下的 CSV;审核状态写 `review_decision`。只有创作者标签 `approved` 会按候选创作者和标签写入 `vision_creator_review` 关系,Logo/头像/媒体失败先只记录决定,不能伪造已下载资源或自动写媒体真相。
+- 人工复核入口固定为 `/review`,候选 API 为 `GET /api/review`、`POST /api/review/decision`。候选来自 `R:\peach-data\generated` 下的 CSV;审核状态写 `review_decision`。只有创作者标签 `approved` 会按候选创作者和标签写入 `vision_creator_review` 关系;该来源也必须进入统计的标签覆盖和 Top 标签口径。Logo/头像/媒体失败先只记录决定,不能伪造已下载资源或自动写媒体真相。
-本文件只保存跨任务长期有效的事实和工作规则,不记录逐次聊天流水。
## 无摩擦接手
@@ -35,7 +38,6 @@
表作为回退,并在此处写明未取得。
- 无论哪个 harness,触发都是概率性的:必须每次成立的规则要由脚本、测试或 hook 强制,不能只写成技能。
- 用户不是消息中转站。结论、进度、待办和证据必须写入共享文档或机器可读产物。
-- 面向用户阅读的文档叙述统一使用中文;代码标识、命令、协议和专有名词保留英文。
## 并行智能体与 Git 工作树
@@ -51,10 +53,9 @@
- 含中文的 `.ps1` 必须带 UTF-8 BOM。没有 BOM 时 Windows PowerShell 5.1 按 ANSI(简中系统即 GBK)读文件,中文被解成乱码后引号配对错乱,脚本在解析期就失败并闪退;报错行还会落在纯 ASCII 的语句上(实测 `test.ps1` 报在第 18 行的 `Join-Path`,真正的坏行在别处),极难定位。pwsh 7 默认按 UTF-8 读无 BOM 文件,同一份字节实测 7.6.3 解析通过、5.1 报 2 处错误。所以**默认终端是 pwsh 7 也不能免疫**:双击 `.ps1` 或右键「使用 PowerShell 运行」走的是文件关联的 `powershell.exe`(5.1),解析失败后窗口立即关闭,连报错都来不及看。`test_powershell_scripts_with_chinese_carry_a_utf8_bom` 守这条线。
- 权限规则里的反斜杠必须双写。匹配器把 `\` 当转义字符,JSON 写 `"& .\\scripts\\test.ps1"` 解码成单反斜杠后 `\s`、`\t` 不再是字面反斜杠,规则匹配不上,非交互会话直接判拒、任务中断。正确写法是 JSON 里 `"& .\\\\scripts\\\\test.ps1"`;旁证是自动生成过的可用规则 `'R:\\\\media\\\\创作者'` 与 `\\(Get-ChildItem`,路径和括号一律双写。用正斜杠写的规则不受影响。改完要新开会话才生效——配置在会话启动时加载。
- `.claude/settings.local.json` 在 `.gitignore` 里,26 个 worktree 无一带有它,所以写在那里的允许规则只在主工作树生效——而项目规矩要求测试在 worktree 里跑。`& .\scripts\test.ps1` 的允许规则因此放在被跟踪的 `.claude/settings.json`,随代码进入每个 worktree。手工拼 venv 路径的命令(`python.exe -m unittest *` 等)刻意不上提到共享配置:那是 AGENTS.md 明令禁止的路径,共享化等于给违规开绿灯。
-
-- 2026-08-17:PowerShell 工具会在调用中途被 session teardown 掐断并错标成用户拒绝(`anthropics/claude-code`
- issue 83486)。改从 Bash 侧跑 `pwsh -NoProfile -File ./scripts/test.ps1`(`powershell.exe` 5.1 按 ANSI
- 读中文会报 `UnexpectedToken`),实测全量 203 项 21 秒通过。入口不变,仍禁止手工拼 venv 路径。
+- 2026-08-17:PowerShell 工具会在调用中途被 session teardown 掐断,丢失的结果被错标成用户拒绝
+ (`anthropics/claude-code` issue 83486,前台长 timeout 和后台写法都中过)。改从 Bash 侧跑
+ `pwsh -NoProfile -File ./scripts/test.ps1`,实测全量 203 项 21 秒通过。入口不变,仍禁止手工拼 venv 路径。
## Claude 在本项目中的实际能力边界
@@ -229,7 +230,7 @@ Claude 的 `.claude/settings.json` 已配置 Stop、StopFailure、SessionEnd hoo
- 页面不得按结果总数一次构建全部卡片。首页默认每批 60,可在设置中改为 30/60/90;短片栏 18、相关推荐默认 20(可选 12/20/30)、沉浸队列 60、实体作品 48、艺人索引 120、标签索引 180。疑似广告候选可在服务端统一评分,但浏览器也必须按当前首页批量分段追加。
- 实体页的总数只用于标题和首批分页判断,第二页起请求使用 `count=0`,通过多取一条判断是否还有下一页,不得重复执行全量 `COUNT(*)`。首页无限滚动同样只在首批计算总数。
- `q_tops`、艺人索引和实体关联艺人的代表图必须使用单条相关子查询取得,禁止按每个人物再发一次 SQL 的 N+1 实现。
-- 首页聚合数据在浏览器会话中合并并缓存 30 秒;相邻筛选复用同一进行中的请求。首页、顶部聚合、索引和实体页都有请求序号,迟到的旧响应不得覆盖新状态或再次重建 DOM。
+- 首页聚合数据在浏览器会话中合并并缓存 30 秒;相邻筛选复用同一进行中的请求。所有页面表面的异步响应都必须核对请求序号和当前路由,迟到的旧响应不得覆盖新状态或再次重建 DOM。
- 所有返回首页的入口必须复用 `showHomeSurfaces()`,同时清除实体页状态、隐藏统计/索引页,并恢复 `#tiers` 与 `#tagbar`。统计页会把这两层写成内联 `display:none`,不能只靠重新取首页数据恢复,否则 Logo 回首页会留下空白顶栏。
- 顶部标签条只能横向滚动,纵向必须隐藏溢出;卡片身份只显示在头像/名称链接,不得再复制成内容标签。搜索推荐词必须是能直接提交的真实关键词,例如 `ABW`,不得写成无法命中的说明短语 `ABW 番号`。
- 「已标记」是正向收藏入口,只包含 profile 的 `liked=1` 或至少记录过一次高潮的作品;不喜欢、看过和待删分别属于负反馈、观看状态和处置流程,不得混入。
diff --git a/docs/STATUS.md b/docs/STATUS.md
index 9c6af8ab2..5f7b1449c 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -128,9 +128,9 @@
<!-- job-status:start -->
<!-- 由 scripts/job_status.py 生成,勿手改;数字现算于账本与产物 -->
-<!-- generated 2026-08-18T07:42Z -->
+<!-- generated 2026-08-18T08:43Z -->
-- 最近自动交接:`claude` / `SessionEnd` / `other`,2026-08-18T07:40:38+00:00。
+- 最近自动交接:`claude` / `SessionEnd` / `other`,2026-08-18T08:43:51+00:00。
- 资产 81769 条,其中视频 24889 条。
- 待抽帧(可抽 / 缺时长待 probe / 合计):
- `local`:3 / 1 / 4
diff --git a/src/peach/web_contract.py b/src/peach/web_contract.py
index d7665b233..8bdbc5d0f 100644
--- a/src/peach/web_contract.py
+++ b/src/peach/web_contract.py
@@ -725,10 +725,12 @@ def q_stats(contract: WebContract):
"SELECT source k, count(*) n, count(DISTINCT asset_id) assets "
"FROM asset_tag GROUP BY source ORDER BY n DESC")]
out["tag_cov"] = one("SELECT count(DISTINCT asset_id) FROM asset_tag "
- "WHERE source IN ('name','r18','vision','vision-creator')")
+ "WHERE source IN ('name','r18','vision','vision-creator',"
+ "'vision_creator','vision_creator_review')")
out["top_tags"] = [dict(r, cat=tag_cat(r["k"])) for r in c.execute(
"SELECT t.tag k, count(*) n FROM asset_tag t JOIN asset a ON a.id=t.asset_id "
- "WHERE a.medium='video' AND t.source IN ('name','r18','vision','vision-creator') "
+ "WHERE a.medium='video' AND t.source IN ('name','r18','vision','vision-creator',"
+ "'vision_creator','vision_creator_review') "
"AND NOT EXISTS(SELECT 1 FROM entity performer WHERE performer.kind='performer' "
"AND performer.normalized_name=lower(trim(t.tag))) "
"GROUP BY t.tag ORDER BY n DESC LIMIT 30")]
@@ -851,7 +853,7 @@ def _review_rows(contract: WebContract, category: str) -> tuple[list[dict], str
decision = decisions.get(row["item_key"], {})
row["decision"] = decision.get("status", "pending")
row["decision_note"] = decision.get("note", "")
- row["preview_url"] = row.get("source_url") or row.get("avatar_url") or ""
+ row["preview_url"] = row.get("resolved_url") or row.get("source_url") or row.get("avatar_url") or ""
return rows, source, skipped
@@ -912,6 +914,9 @@ def w_review_decision(contract: WebContract, body):
if candidate is None:
connection.rollback(); connection.close()
raise ValueError("候选不在当前批次,无法批准")
+ if str(candidate.get("status") or "").strip() != "candidate":
+ connection.rollback(); connection.close()
+ raise ValueError("只有 candidate 状态的复核项可以批准")
creator = str(candidate.get("creator") or "").strip()
tags = [tag.strip() for tag in str(candidate.get("tags") or "").split("|") if tag.strip()]
claimed_creator = str(body.get("creator", "")).strip()
diff --git a/tests/test_rm_web.py b/tests/test_rm_web.py
index e834439a1..e5faf559b 100644
--- a/tests/test_rm_web.py
+++ b/tests/test_rm_web.py
@@ -160,6 +160,16 @@ class WebDataTests(unittest.TestCase):
self.assertNotIn("path", result["items"][0])
self.assertNotIn("snapshot_path", result["items"][0])
+ def test_reviewed_creator_tags_are_included_in_tag_coverage(self):
+ con = sqlite3.connect(self.db_path)
+ con.execute(
+ "INSERT INTO asset_tag(asset_id,tag,source) VALUES(2,'审核标签','vision_creator_review')"
+ )
+ con.commit(); con.close()
+ stats = rm_web.q_stats(self.contract)
+ self.assertEqual(stats["tag_cov"], 2)
+ self.assertIn("审核标签", {row["k"] for row in stats["top_tags"]})
+
def test_items_support_duration_range(self):
result = rm_web.q_items(
self.contract, {"dur_min": "90", "dur_max": "110", "limit": "10"},
@@ -567,6 +577,19 @@ class ReviewQueueTests(unittest.TestCase):
"category": "creator_tags", "item_key": "已消失的候选", "status": "approved",
})
+ def test_skip_candidate_cannot_be_approved(self):
+ """机械批次明确跳过的聚合目录不能从复核页误批准回真相层。"""
+ self.write_candidates("creator-tags-candidate-20260817.csv",
+ [{"board": "b1", "creator": "ukiru", "tags": "足系", "status": "skip"}])
+ with self.assertRaises(ValueError):
+ rm_web.w_review_decision(self.contract, {
+ "category": "creator_tags", "item_key": "b1", "status": "approved",
+ })
+ con = sqlite3.connect(self.db_path)
+ self.assertEqual(con.execute("SELECT count(*) FROM asset_tag").fetchone()[0], 0)
+ self.assertEqual(con.execute("SELECT count(*) FROM review_decision").fetchone()[0], 0)
+ con.close()
+
def test_unselected_approval_is_capped_instead_of_tagging_everything(self):
self.write_candidates("creator-tags-candidate-20260817.csv",
[{"board": "b1", "creator": "ukiru", "tags": "足系", "status": "candidate"}])
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index ba2f9da93..f230f8cc0 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -103,6 +103,100 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains(".select-mode .cardopenhit,.select-mode .hovertools,.select-mode .previewcounter")
self.assertPageContains("if(selectMode)releaseHoverPreviews()")
+ def test_manage_collects_the_four_admin_entries_behind_one_top_level_icon(self):
+ """统计、疑似广告、回收站、人工复核各占一个顶层图标时,侧栏一半是管理入口。
+
+ 它们合并到「管理」下的二级导航;URL 保持原样,只是多了一条共用导航条。
+ """
+ self.assertPageContains("['manage','管理','settings']")
+ self.assertPageContains("const MANAGE_SECTIONS=[")
+ for section in ("'stats','统计'", "'ads','疑似广告'", "'trash','回收站'", "'review','人工复核'"):
+ self.assertPageContains(section)
+ self.assertPageContains("function manageSection()")
+ self.assertPageContains("function buildManageBar()")
+ self.assertPageContains('id="managebar"')
+ self.assertPageContains("if(k==='manage'){openManage();return}")
+ # 顶层图标里不再各自占位
+ edge = self.page.split("const EDGE_ICONS=[", 1)[1].split("];", 1)[0]
+ for gone in ("'trash'", "'ads'", "'stats'", "'review'"):
+ self.assertNotIn(gone, edge, f"{gone} 应该已经收进管理,不再是顶层入口")
+ self.assertIn("'manage'", edge)
+
+ def test_review_reuses_the_standard_selection_instead_of_its_own_mode(self):
+ """复核页曾自造「多选模式」按钮加框选,只在这一页生效,用户得先发现再记住。
+
+ 现在与主网格一致:点一下切换,Shift 选一段。
+ """
+ self.assertPageLacks("reviewSelectMode")
+ self.assertPageLacks("reviewmarquee")
+ self.assertPageLacks("review-select-mode")
+ self.assertPageContains("function wireReviewAssets(root)")
+ self.assertPageContains("if(e.shiftKey&&anchor!==null)")
+ self.assertPageContains("[data-pick-all]")
+ self.assertPageContains("[data-pick-none]")
+ self.assertPageContains('[data-review-asset][aria-pressed="true"]')
+ self.assertPageContains("const canApprove=reviewCategory!=='creator_tags'||String(row.status||'').trim()==='candidate'")
+ self.assertPageContains("${canApprove?'':' disabled'}")
+
+ def test_surface_navigation_clears_stale_panels_and_ignores_late_responses(self):
+ """跨页面请求返回较慢时,旧统计/复核响应不能覆盖当前页面。"""
+ self.assertPageContains("if(location.pathname!=='/review')return")
+ self.assertPageContains("if(requestSeq!==indexRequestSeq||location.pathname!=='/'+kind)return")
+ self.assertPageContains("decodeURIComponent(location.pathname)!==decodeURIComponent(expectedPath)")
+ index = self.page.split("async function openIndex", 1)[1].split("const d=await api", 1)[0]
+ self.assertIn("showHomeSurfaces();", index)
+ self.assertPageContains("if(!$('#stats').hidden){\n if(location.pathname==='/review'){await openReview(false);return}")
+
+ def test_immersive_close_restores_the_home_surface(self):
+ self.assertPageContains("document.body.style.overflow='';showHomeSurfaces();load(true)")
+
+ def test_review_asset_picker_wraps_instead_of_scrolling_sideways(self):
+ """一个创作者可能有几十条候选,横向滚动条要一直拉才能看完。"""
+ self.assertPageContains(".reviewasset-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr))")
+ self.assertPageContains(".reviewasset.picked{opacity:1;outline:2px solid var(--tungsten)")
+ self.assertPageContains('.reviewitem[data-decision="approved"]::before{background:var(--keep)}')
+
+ def test_top_level_highlight_is_exclusive_and_covers_index_pages(self):
+ """首页原来只看 state.state,进管理区和索引页时它仍然亮着,两个入口同时高亮。"""
+ self.assertPageContains("if(k==='performers'||k==='tags')return path==='/'+k")
+ self.assertPageContains("if(k==='')return path==='/'&&!manageSection()&&!state.state")
+ self.assertPageContains("buildEdge(); // 顶层高亮跟随管理区")
+
+ def test_manage_surfaces_hide_the_home_rails(self):
+ """回收站和疑似广告是行政列表,不该顶着首页的人物/厂牌横条。
+
+ `showHomeSurfaces` 会先把横条恢复出来,所以隐藏必须排在它之后,否则被立刻覆盖。
+ """
+ self.assertPageContains("if(current){$('#tiers').style.display='none';$('#tagbar').style.display='none'}")
+ home = self.page.split("function showHomeSurfaces(){", 1)[1].split("}", 1)[0]
+ self.assertLess(home.index("$('#tiers').style.display=''"), home.index("buildManageBar()"),
+ "buildManageBar 必须排在恢复首页横条之后,否则隐藏会被覆盖")
+
+ def test_search_suggestions_come_from_real_data_in_bulk(self):
+ """写死的 6 个词翻两次就重复。顶部聚合只有几十条,也不够;索引接口一次给近千条。"""
+ self.assertPageContains("async function loadSearchPool()")
+ self.assertPageContains("['performers','creators','tags'].map(")
+ self.assertPageContains("`/api/index?kind=${kind}&limit=400`")
+ self.assertPageContains("Promise.all([loadSearchHistory(),loadSearchPool()])")
+ self.assertPageContains("[...searchPool()]")
+
+ def test_admin_surfaces_fill_wide_screens(self):
+ """统计和复核是信息密集的行政界面,宽屏下居中会浪费两侧空间。"""
+ self.assertPageContains(".stats{padding:8px 0 42px}")
+ self.assertPageContains(".review{padding:8px 0 42px}")
+ self.assertPageLacks("max-width:1440px")
+
+ def test_returning_home_from_any_surface_moves_the_highlight(self):
+ """点回首页时路径还停在 /review 之类上,navOn('') 仍然为假,高亮不切换。"""
+ self.assertPageContains("if(location.pathname!=='/')route('/');")
+ self.assertEqual(self.page.count("if(location.pathname!=='/')route('/');"), 2,
+ "抽屉和窄栏两处导航都要修")
+
+ def test_ads_icon_matches_the_lucide_stroke_style(self):
+ """图标库里没有表示广告的图形,自绘的感叹号必须和其余图标同风格。"""
+ self.assertPageContains('<symbol id="i-alert" viewBox="0 0 24 24">')
+ self.assertPageContains("['ads','疑似广告','alert']")
+
def test_pending_delete_is_visible_without_deleting_media(self):
self.assertPageContains("it.disposal==='trash'?'pending-delete':''")
self.assertPageContains(".card.pending-delete .poster")
@@ -198,7 +292,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("if(!mixContext)api('/api/related?id='")
self.assertPageContains("batchWithMix(d.items,location.pathname==='/'&&state.state!=='trash')")
self.assertPageContains("location.pathname!=='/'||state.orient==='竖屏'||state.state==='ads'||state.state==='trash'")
- self.assertPageContains("if(k==='trash')route('/trash')")
+ self.assertPageContains("route(section==='trash'?'/trash':'/')")
self.assertPageContains("if(path==='/trash')")
self.assertPageContains("/api/trash/empty")
@@ -315,7 +409,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("document.querySelectorAll('#grid > .card[data-id]')")
def test_recycle_bin_has_its_own_route_and_reports_undeletable_files(self):
- self.assertPageContains("if(k==='trash')route('/trash')")
+ self.assertPageContains("route(section==='trash'?'/trash':'/')")
self.assertPageContains("if(path==='/trash'){")
self.assertPageContains("/api/trash/empty")
self.assertPageContains("r.blocked&&r.blocked.length")
diff --git a/web/index.html b/web/index.html
index 32a3600c3..780b0bc8f 100644
--- a/web/index.html
+++ b/web/index.html
@@ -97,8 +97,9 @@ button,input,textarea{font:inherit;color:inherit}
.search input{flex:1;min-width:0;background:none;border:0;outline:none;font-size:15px}
.search>svg{width:21px;height:21px;flex:none;stroke:var(--muted);fill:none;stroke-width:1.8;stroke-linecap:round}
.searchmenu{position:absolute;z-index:130;left:0;right:0;top:calc(100% + 8px);padding:8px;
- border:1px solid var(--border-10);border-radius:14px;background:var(--frost-panel);
- box-shadow:0 22px 56px -20px #000b;backdrop-filter:saturate(1.5) blur(20px)}
+ border:1px solid var(--border-10);border-radius:14px;
+ background:color-mix(in srgb,var(--surface) 96%,var(--ground));
+ box-shadow:0 22px 56px -20px #000b;backdrop-filter:saturate(1.5) blur(26px)}
.searchmenu[hidden]{display:none}.searchgroup+ .searchgroup{border-top:1px solid var(--line-soft);margin-top:7px;padding-top:7px}
.searchgroup h3{margin:6px 10px;color:var(--muted);font-size:10px;letter-spacing:.14em}
.searchoption{width:100%;height:38px;border:0;border-radius:8px;background:transparent;color:var(--ink);
@@ -163,10 +164,13 @@ button,input,textarea{font:inherit;color:inherit}
.combo .cb b:hover{opacity:1}
.combo .clr{background:none;border:0;color:var(--muted);cursor:pointer;font-size:12px;text-decoration:underline}
/* 统计页 */
-.stats{padding:8px 0 42px;max-width:1440px;margin:0 auto}
-.review{padding:8px 0 42px;max-width:1440px;margin:0 auto}.reviewhead{display:flex;align-items:center;gap:14px;padding:10px 2px 18px;border-bottom:1px solid var(--line-soft);margin-bottom:18px}.reviewhead h2{margin:0;font-size:26px}.reviewtabs{display:flex;gap:7px;overflow-x:auto;margin-bottom:16px}.reviewtabs button,.reviewitem button{border:1px solid var(--border-15);border-radius:999px;background:transparent;color:var(--ink-2);padding:8px 13px;cursor:pointer}.reviewtabs button[aria-pressed="true"],.reviewitem button.approve{background:var(--tungsten-soft);border-color:var(--tungsten);color:var(--ink)}.reviewsection{margin-bottom:20px}.reviewsection h3{margin:0 0 9px;font-size:15px}.reviewlist{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:10px}.reviewitem{background:var(--surface);border:1px solid var(--line-soft);border-radius:12px;padding:13px;min-width:0}.reviewitem[data-decision="approved"]{border-color:var(--keep)}.reviewitem[data-decision="rejected"],.reviewitem[data-decision="skipped"]{opacity:.55}.reviewitem h4{margin:0 0 6px;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.reviewitem p{margin:4px 0;color:var(--muted);font-size:12px;line-height:1.5;overflow-wrap:anywhere}.reviewtags{display:flex;flex-wrap:wrap;gap:5px;margin:8px 0}.reviewtags span{padding:3px 8px;border:1px solid var(--border-15);border-radius:999px;font-size:11px}.reviewactions{display:flex;gap:6px;margin-top:10px}.reviewactions button{border-radius:8px;padding:6px 10px}.reviewactions .reject{color:var(--drop)}.reviewasset-grid{display:flex;gap:6px;overflow-x:auto;padding:7px 0;position:relative;scrollbar-width:thin}.reviewasset{position:relative;flex:0 0 108px;height:82px;border:1px solid var(--border-10);border-radius:7px;overflow:hidden;background:#000;cursor:pointer}.reviewasset img{width:100%;height:100%;object-fit:cover;display:block}.reviewasset input{position:absolute;top:6px;right:6px;width:18px;height:18px;accent-color:var(--tungsten);z-index:2}.reviewasset-grid.marquee-active{cursor:crosshair}.reviewasset-grid.marquee-active .reviewasset{user-select:none}.reviewmarquee{position:fixed;z-index:300;border:1px solid var(--tungsten);background:color-mix(in srgb,var(--tungsten) 16%,transparent);pointer-events:none}
-.statshead{display:flex;align-items:center;justify-content:flex-start;gap:14px;padding:10px 2px 18px;
- border-bottom:1px solid var(--line-soft);margin-bottom:18px}
+.stats{padding:8px 0 42px}
+.review{padding:8px 0 42px}.reviewhead{display:flex;align-items:baseline;gap:12px;padding:2px 2px 14px;margin-bottom:14px}.reviewhead h2{margin:0;font-size:22px}.reviewtabs{display:flex;gap:6px;overflow-x:auto;margin-bottom:18px;scrollbar-width:none}.reviewtabs::-webkit-scrollbar{display:none}.reviewtabs button{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--border-15);border-radius:999px;background:transparent;color:var(--ink-2);padding:7px 14px;cursor:pointer;font-size:13px;white-space:nowrap}.reviewtabs button:hover{border-color:var(--tungsten);color:var(--ink)}.reviewtabs button[aria-pressed="true"]{background:var(--tungsten-soft);border-color:var(--tungsten);color:var(--tungsten);font-weight:600}.reviewtabs .n{color:var(--muted);font-size:11px}.reviewsection{margin-bottom:20px}.reviewsection h3{margin:0 0 9px;font-size:15px}.reviewlist{display:grid;grid-template-columns:repeat(auto-fill,minmax(360px,1fr));gap:14px}
+/* 判定状态用左侧色条表达:整卡描边在一列里扫过去时反而认不出来 */
+.reviewitem{position:relative;background:var(--surface);border:1px solid var(--line-soft);border-radius:12px;padding:15px 15px 13px 18px;min-width:0;overflow:hidden}.reviewitem::before{content:'';position:absolute;left:0;top:0;bottom:0;width:3px;background:transparent}.reviewitem[data-decision="approved"]::before{background:var(--keep)}.reviewitem[data-decision="rejected"]::before{background:var(--drop)}.reviewitem[data-decision="skipped"]::before{background:var(--muted)}.reviewitem[data-decision="rejected"],.reviewitem[data-decision="skipped"]{opacity:.6}.reviewitem h4{margin:0 0 6px;font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.reviewitem p{margin:4px 0;color:var(--muted);font-size:12px;line-height:1.55;overflow-wrap:anywhere}.reviewtags{display:flex;flex-wrap:wrap;gap:5px;margin:9px 0}.reviewtags span{padding:3px 9px;border:1px solid var(--border-15);border-radius:999px;font-size:11.5px;color:var(--ink-2)}
+/* 资产选择用换行网格而不是横向滚动条:一个创作者可能有几十条候选,横拉看不完 */
+.reviewpick{margin:10px 0 4px;border:1px solid var(--border-10);border-radius:10px;background:var(--overlay-5);padding:8px}.reviewpickhead{display:flex;align-items:center;gap:8px;margin-bottom:8px;font-size:11.5px;color:var(--muted)}.reviewpickhead button{border:1px solid var(--border-15);border-radius:7px;background:transparent;color:var(--ink-2);padding:3px 10px;font-size:11.5px;cursor:pointer}.reviewpickhead button:hover{border-color:var(--tungsten);color:var(--ink)}.reviewpickhead [data-picked-count]{margin-right:auto}.reviewasset-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:6px;max-height:268px;overflow-y:auto;scrollbar-width:thin}.reviewasset{position:relative;aspect-ratio:16/10;border:0;padding:0;border-radius:7px;overflow:hidden;background:#000;cursor:pointer;opacity:.5;transition:opacity .12s ease}.reviewasset img{width:100%;height:100%;object-fit:cover;display:block}.reviewasset .pickmark{position:absolute;top:4px;right:4px;width:19px;height:19px;border-radius:50%;display:none;place-items:center;background:var(--tungsten);color:#fff}.reviewasset .pickmark svg{width:12px;height:12px;stroke:currentColor;fill:none;stroke-width:3}.reviewasset.picked{opacity:1;outline:2px solid var(--tungsten);outline-offset:-2px}.reviewasset.picked .pickmark{display:grid}.reviewactions{display:flex;gap:7px;margin-top:12px}.reviewactions button{border:1px solid var(--border-15);border-radius:8px;background:transparent;color:var(--ink-2);padding:7px 14px;font-size:13px;cursor:pointer}.reviewactions button:hover{border-color:var(--tungsten);color:var(--ink)}.reviewactions .approve{background:var(--tungsten);border-color:var(--tungsten);color:#fff;font-weight:600}.reviewactions .approve:hover{background:color-mix(in srgb,var(--tungsten) 82%,#000);color:#fff}.reviewactions .skip{color:var(--meter)}.reviewactions .skip:hover{background:var(--meter);border-color:var(--meter);color:#fff}.reviewactions .reject{color:var(--drop)}.reviewactions .reject:hover{background:var(--drop);border-color:var(--drop);color:#fff}
+.statshead{display:flex;align-items:baseline;gap:12px;padding:2px 2px 14px;margin-bottom:14px}
.stats h2{margin:0 0 4px;font-size:26px}
.stats .sub{color:var(--muted);margin:0}
.scards{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px;margin-bottom:18px}
@@ -280,6 +284,16 @@ button,input,textarea{font:inherit;color:inherit}
/* ── 主区:满屏,大图 ── */
main{position:relative;z-index:1;padding:14px 16px 90px}
+/* 管理区二级导航:统计 / 疑似广告 / 回收站 / 人工复核 共用一条 */
+.managebar{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin:0 0 16px;
+ padding:6px;border:1px solid var(--line-soft);border-radius:12px;background:var(--surface);width:max-content;max-width:100%}
+.managebar[hidden]{display:none}
+.managebar button{display:inline-flex;align-items:center;gap:7px;border:0;border-radius:9px;
+ background:transparent;color:var(--ink-2);padding:8px 14px;cursor:pointer;font-size:13px;white-space:nowrap}
+.managebar button svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;
+ stroke-linecap:round;stroke-linejoin:round}
+.managebar button:hover{background:var(--hover);color:var(--ink)}
+.managebar button[aria-pressed="true"]{background:var(--tungsten-soft);color:var(--tungsten);font-weight:600}
.count{position:sticky;top:calc(var(--topH) + var(--filterH));z-index:60;
min-height:var(--sortH);color:var(--ink-2);margin:0 -16px 12px;padding:8px 16px;
display:flex;align-items:center;gap:10px;flex-wrap:nowrap;
@@ -784,7 +798,7 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
}
#searchBtn{display:none}
</style>
-<style>.reviewimage{width:160px;height:112px;border-radius:8px;overflow:hidden;background:#000;margin:8px 0}.reviewimage img{width:100%;height:100%;object-fit:contain;display:block}.review-select-mode .reviewasset{cursor:crosshair}</style>
+<style>.reviewimage{width:160px;height:112px;border-radius:8px;overflow:hidden;background:#000;margin:8px 0}.reviewimage img{width:100%;height:100%;object-fit:contain;display:block}</style>
</head>
<body>
<!-- Lucide static 1.31.0, ISC. Local pinned subset; no CDN/runtime dependency.
@@ -810,6 +824,9 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
<symbol id="i-thumbs-up" viewBox="0 0 24 24"><path d="M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"/><path d="M7 10v12"/></symbol>
<symbol id="i-thumbs-down" viewBox="0 0 24 24"><path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"/><path d="M17 14V2"/></symbol>
<symbol id="i-eye" viewBox="0 0 24 24"><path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/></symbol>
+ <!-- 图标库里没有表示广告的图形;按 Lucide 的 24×24 描边风格自绘一个感叹号圆标,
+ 线宽、圆角端点与其余图标一致,不至于在同一条导航里显得格格不入。 -->
+ <symbol id="i-alert" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 8v4"/><path d="M12 16h.01"/></symbol>
<symbol id="i-trash" viewBox="0 0 24 24"><path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></symbol>
<symbol id="i-plus" viewBox="0 0 24 24"><path d="M5 12h14"/><path d="M12 5v14"/></symbol>
<symbol id="i-check" viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></symbol>
@@ -849,6 +866,7 @@ body.drawer-open .edge{opacity:0;pointer-events:none} /* 展开时窄栏让位
<section class="stage" id="stage" hidden></section>
<div class="combo" id="combo"></div>
<section class="index" id="index" hidden></section>
+ <nav class="managebar" id="managebar" hidden></nav>
<section class="stats" id="stats" hidden></section>
<div class="count mono" id="count">载入中…</div>
<div class="grid" id="grid"></div>
@@ -1421,12 +1439,13 @@ async function buildBars(){
const k=b.dataset.nav;
closeDrawerAfterNav();
if(k==='immerse'){openTok();return}
- if(k==='stats'){openStats();return}
- if(k==='review'){openReview();return}
+ if(k==='manage'){openManage();return}
if(k==='performers'||k==='tags'){openIndex(k);return}
if(k==='shorts'){state.orient='竖屏';state.state=''}
else{state.orient='';state.state=k}
- if(k==='trash')route('/trash');
+ // 从管理区/索引页点回列表类入口时,路径还停在原处,高亮不会切换。
+ if(location.pathname!=='/')route('/');
+ showHomeSurfaces();
buildEdge();buildBars();load(true)});
const bind=()=>$('#drawer').querySelectorAll('.chip').forEach(b=>b.onclick=()=>{
const k=b.dataset.key,v=b.dataset.val;
@@ -1514,7 +1533,7 @@ async function openStats(push=true){
document.body.classList.remove('entity-open');
disposeStage(false);
const d=await api('/api/stats');
- $('#stats').hidden=false; $('#index').hidden=true; $('#grid').innerHTML='';
+ $('#stats').hidden=false; $('#index').hidden=true; $('#grid').innerHTML='';buildManageBar();
$('#count').textContent=''; $('#loadSentinel').hidden=true; $('#shortsSec').hidden=true;
$('#tiers').style.display='none'; $('#tagbar').style.display='none';
const a=d.attribution, cs=d.consumption;
@@ -1525,10 +1544,7 @@ async function openStats(push=true){
const card=(t,body)=>`<div class="scard2"><h3>${t}</h3>${body}</div>`;
const kv=(k,v,u)=>`<div class="kv"><span>${k}</span><b>${v}${u?`<span class="u">${u}</span>`:''}</b></div>`;
$('#stats').innerHTML=`
- <div class="statshead"><button class="backbtn" id="statsBack" title="返回浏览" aria-label="返回浏览">${icon('arrow-left')}</button>
- <div><h2 class="disp">统计与管理</h2>
- </div>
- </div>
+ <div class="statshead"><h2 class="disp">统计</h2></div>
<div class="scards">
${card('库存', d.by_loc.map(l=>kv(LOC[l.k]||l.k, l.videos.toLocaleString(), gb(l.bytes))).join('')
+ kv('合计', d.by_loc.reduce((s,l)=>s+l.videos,0).toLocaleString(),
@@ -1567,7 +1583,6 @@ async function openStats(push=true){
return kv(esc((r.creator?r.creator+' · ':'')+r.name).slice(0,90),
`真实看 ${real.toFixed(0)}% / 到达 ${mx.toFixed(0)}%`,
real<mx-25?'快进扫过':(r.o_count?`⌀ ${r.o_count}`:''));}).join('')}</div>`:''}`;
- $('#statsBack').onclick=()=>closeStats();
$('#stats').querySelectorAll('[data-k]').forEach(b=>b.onclick=()=>{
closeStats(); toggleTag(b.dataset.k)});
window.scrollTo({top:0,behavior:'smooth'});
@@ -1576,39 +1591,47 @@ function showHomeSurfaces(){
document.body.classList.remove('entity-open');
$('#stats').hidden=true;$('#index').hidden=true;
$('#tiers').style.display='';$('#tagbar').style.display='';
+ buildManageBar(); // 放在最后:管理区要盖掉上面刚恢复的首页横条
}
function closeStats(push=true){if(push)route('/');showHomeSurfaces();load(true)}
-let reviewData=null,reviewCategory='creator_tags',reviewSelectMode=false;
+let reviewData=null,reviewCategory='creator_tags';
const REVIEW_LABELS={creator_tags:'创作者标签',studio_logos:'厂牌 Logo',performer_avatars:'女优头像',media_failure:'媒体失败'};
async function openReview(push=true){
releaseHoverPreviews();disposeStage(false);document.body.classList.remove('entity-open');
if(push)route('/review');
+ buildManageBar();
$('#stats').hidden=false;$('#index').hidden=true;$('#grid').innerHTML='';$('#count').textContent='';
$('#loadSentinel').hidden=true;$('#shortsSec').hidden=true;$('#tiers').style.display='none';$('#tagbar').style.display='none';
reviewData=await api('/api/review');
+ if(location.pathname!=='/review')return;
const render=()=>{
const rows=reviewData.sections[reviewCategory]||[];
const title=REVIEW_LABELS[reviewCategory];
const value=row=>row.tags||row.japanese_name||row.path||row.suggested_query||'';
- $('#stats').innerHTML=`<div class="review"><div class="reviewhead"><button class="backbtn" id="reviewBack" title="返回浏览" aria-label="返回浏览">${icon('arrow-left')}</button><h2 class="disp">人工复核</h2><span class="mono" style="color:var(--muted)">候选不会自动写入真相</span><button class="pill" id="reviewSelectMode" aria-pressed="${reviewSelectMode}">${icon('square-check-big')}多选模式</button></div>
- <div class="reviewtabs">${Object.entries(REVIEW_LABELS).map(([key,label])=>`<button data-review-tab="${key}" aria-pressed="${key===reviewCategory}">${label} <span class="mono">${reviewData.counts[key]||0}</span></button>`).join('')}</div>
- <section class="reviewsection"><h3>${title}</h3><div class="reviewlist">${rows.length?rows.map(row=>{
+ $('#stats').innerHTML=`<div class="review"><div class="reviewhead"><h2 class="disp">人工复核</h2></div>
+ <div class="reviewtabs">${Object.entries(REVIEW_LABELS).map(([key,label])=>`<button data-review-tab="${key}" aria-pressed="${key===reviewCategory}">${label} <span class="n mono">${reviewData.counts[key]||0}</span></button>`).join('')}</div>
+ <section class="reviewsection"><div class="reviewlist">${rows.length?rows.map(row=>{
const key=row.item_key,decision=row.decision||'pending';
const tags=String(row.tags||'').split('|').filter(Boolean).map(tag=>`<span>${esc(tag)}</span>`).join('');
const titleText=row.creator||row.studio||row.current_name||row.name||key;
const evidence=row.reason||row.evidence||row.note||row.decision_note||'';
+ const canApprove=reviewCategory!=='creator_tags'||String(row.status||'').trim()==='candidate';
+ const approveLabel=canApprove?'通过':'已跳过';
+ const assets=row.preview_assets||[];
const preview=reviewCategory==='creator_tags'
- ? `<div class="reviewasset-grid">${(row.preview_assets||[]).map(asset=>`<label class="reviewasset" title="${esc(asset.name)}"><img src="/poster?id=${asset.id}&c=4" alt="" loading="lazy"><input type="checkbox" data-review-asset="${asset.id}" checked></label>`).join('')}</div>`
- : (row.preview_url?`<div class="reviewimage"><img src="${esc(row.preview_url)}" alt="" loading="lazy"></div>`:'<p class="empty">未取得图片预览</p>');
- return `<article class="reviewitem" data-review-key="${esc(key)}" data-decision="${esc(decision)}"><h4>${esc(titleText)}</h4><p>${esc(row.board||row.assets?`样本/资产:${row.video_count||row.assets||''}`:'')}</p>${tags?`<div class="reviewtags">${tags}</div>`:''}${preview}<p>${esc(evidence)}</p><div class="reviewactions"><button class="approve" data-review-status="approved">通过</button><button data-review-status="skipped">跳过</button><button class="reject" data-review-status="rejected">拒绝</button></div></article>`}).join(''):'<p class="empty">暂无候选</p>'}</div></section></div>`;
- $('#reviewBack').onclick=()=>{route('/');showHomeSurfaces();load(true)};
- $('#reviewSelectMode').onclick=()=>{reviewSelectMode=!reviewSelectMode;document.body.classList.toggle('review-select-mode',reviewSelectMode);$('#reviewSelectMode').setAttribute('aria-pressed',reviewSelectMode);wireReviewSelection($('#stats'))};
- wireReviewSelection($('#stats'));
+ ? (assets.length?`<div class="reviewpick"><div class="reviewpickhead"><span class="mono" data-picked-count></span>
+ <button type="button" data-pick-all>全选</button><button type="button" data-pick-none>清空</button></div>
+ <div class="reviewasset-grid">${assets.map(asset=>`<button type="button" class="reviewasset picked" data-review-asset="${asset.id}" aria-pressed="true" title="${esc(asset.name)}"><img src="/poster?id=${asset.id}&c=4" alt="" loading="lazy"><span class="pickmark">${icon('check')}</span></button>`).join('')}</div></div>`
+ // 空白一片会被当成界面坏了。真实原因是这些作品还没抽帧,说清楚比留白好。
+ : `<p class="empty">这 ${esc(row.video_count||'')} 条作品尚未抽帧,暂无预览;批准后仍会按候选写入标签</p>`)
+ : (row.preview_url?`<div class="reviewimage"><img src="${esc(row.preview_url)}" alt="" loading="lazy" onerror="this.closest('.reviewimage').remove()"></div>`:'<p class="empty">未取得图片预览</p>');
+ return `<article class="reviewitem" data-review-key="${esc(key)}" data-decision="${esc(decision)}"><h4>${esc(titleText)}</h4><p>${esc(row.board||row.assets?`样本/资产:${row.video_count||row.assets||''}`:'')}</p>${tags?`<div class="reviewtags">${tags}</div>`:''}${preview}<p>${esc(evidence)}</p><div class="reviewactions"><button class="approve" data-review-status="approved"${canApprove?'':' disabled'}>${approveLabel}</button><button class="skip" data-review-status="skipped">跳过</button><button class="reject" data-review-status="rejected">拒绝</button></div></article>`}).join(''):'<p class="empty">暂无候选</p>'}</div></section></div>`;
+ wireReviewAssets($('#stats'));
$('#stats').querySelectorAll('[data-review-tab]').forEach(button=>button.onclick=()=>{reviewCategory=button.dataset.reviewTab;render()});
$('#stats').querySelectorAll('[data-review-status]').forEach(button=>button.onclick=async()=>{
const item=button.closest('[data-review-key]'),row=rows.find(x=>String(x.item_key)===item.dataset.reviewKey);button.disabled=true;
- const selectedIds=[...item.querySelectorAll('[data-review-asset]:checked')].map(input=>+input.dataset.reviewAsset);
+ const selectedIds=[...item.querySelectorAll('[data-review-asset][aria-pressed="true"]')].map(cell=>+cell.dataset.reviewAsset);
const result=await api('/api/review/decision',{method:'POST',body:JSON.stringify({category:reviewCategory,item_key:item.dataset.reviewKey,status:button.dataset.reviewStatus,creator:row.creator,tags:row.tags,studio:row.studio,entity_id:row.entity_id,avatar_url:row.avatar_url,selected_ids:selectedIds})});
if(result.ok){row.decision=button.dataset.reviewStatus;item.dataset.decision=row.decision}
button.disabled=false;
@@ -1617,15 +1640,30 @@ async function openReview(push=true){
render();window.scrollTo({top:0,behavior:'smooth'});
}
-function wireReviewSelection(root){
- root.querySelectorAll('.reviewasset-grid').forEach(grid=>{
- if(grid.dataset.selectionWired)return;grid.dataset.selectionWired='1';
- let start=null,marquee=null;
- const finish=e=>{if(!start)return;grid.releasePointerCapture?.(e.pointerId);marquee?.remove();start=null;marquee=null};
- grid.addEventListener('pointerdown',e=>{
- if(!reviewSelectMode||e.button!==0)return;start={x:e.clientX,y:e.clientY};marquee=document.createElement('div');marquee.className='reviewmarquee';document.body.appendChild(marquee);grid.setPointerCapture?.(e.pointerId);e.preventDefault()});
- grid.addEventListener('pointermove',e=>{if(!start||!marquee)return;const left=Math.min(start.x,e.clientX),top=Math.min(start.y,e.clientY),right=Math.max(start.x,e.clientX),bottom=Math.max(start.y,e.clientY);Object.assign(marquee.style,{left:left+'px',top:top+'px',width:right-left+'px',height:bottom-top+'px'});const box={left,top,right,bottom};grid.querySelectorAll('.reviewasset').forEach(card=>{const r=card.getBoundingClientRect(),hit=r.right>=box.left&&r.left<=box.right&&r.bottom>=box.top&&r.top<=box.bottom;const input=card.querySelector('input');if(hit&&input)input.checked=true})});
- grid.addEventListener('pointerup',finish);grid.addEventListener('pointercancel',finish);
+function wireReviewAssets(root){
+ /* 复核页不再自造「多选模式」和框选:交互与主网格一致——点一下切换,Shift 选一段。
+ 多一套只在这一页生效的选择方式,用户得先发现它、再记住它。 */
+ root.querySelectorAll('.reviewpick').forEach(pick=>{
+ const cells=[...pick.querySelectorAll('.reviewasset')];
+ const readout=pick.querySelector('[data-picked-count]');
+ let anchor=null;
+ const paint=()=>{
+ const n=cells.filter(c=>c.getAttribute('aria-pressed')==='true').length;
+ if(readout)readout.textContent=`已选 ${n} / ${cells.length}`;
+ };
+ const set=(cell,on)=>{cell.setAttribute('aria-pressed',on);cell.classList.toggle('picked',on)};
+ cells.forEach((cell,index)=>{
+ cell.onclick=e=>{
+ if(e.shiftKey&&anchor!==null){
+ const [a,b]=[Math.min(anchor,index),Math.max(anchor,index)];
+ for(let i=a;i<=b;i++)set(cells[i],true);
+ }else set(cell,cell.getAttribute('aria-pressed')!=='true');
+ anchor=index;paint();
+ };
+ });
+ pick.querySelector('[data-pick-all]').onclick=()=>{cells.forEach(c=>set(c,true));paint()};
+ pick.querySelector('[data-pick-none]').onclick=()=>{cells.forEach(c=>set(c,false));paint()};
+ paint();
});
}
@@ -1645,13 +1683,14 @@ async function openIndex(kind,q,push=true){
indexQuery.set('view',tagIndexMode);
if(tagIndexCategory!=='all')indexQuery.set('category',tagIndexCategory)}
if(push)route('/'+kind+(indexQuery.size?'?'+indexQuery:''),!!q);
+ showHomeSurfaces();
disposeStage(false);
const indexApi=offset=>'/api/index?kind='+kind+'&limit='+indexLimit+'&offset='+offset+
(q?'&q='+encodeURIComponent(q):'')+
(kind==='tags'&&tagIndexCategory!=='all'?'&category='+encodeURIComponent(tagIndexCategory):'');
const d=await api(indexApi(0));
- if(requestSeq!==indexRequestSeq)return;
- $('#index').hidden=false; $('#grid').innerHTML=''; $('#count').textContent='';
+ if(requestSeq!==indexRequestSeq||location.pathname!=='/'+kind)return;
+ $('#index').hidden=false;buildEdge(); $('#grid').innerHTML=''; $('#count').textContent='';
$('#loadSentinel').hidden=true; $('#shortsSec').hidden=true;
const title=kind==='performers'?'艺人':(kind==='creators'?'创作者':'标签');
const tagItems=[...d.items];
@@ -1745,13 +1784,16 @@ async function openEntity(kind,name,push=true,requestedTag){
const entityTag=requestedTag===undefined
? (push?'':new URLSearchParams(location.search).get('tag')||'')
: requestedTag;
- if(push)route(entityPath(kind,name)+(entityTag?'?tag='+encodeURIComponent(entityTag):''));
+ const expectedPath=entityPath(kind,name);
+ if(push)route(expectedPath+(entityTag?'?tag='+encodeURIComponent(entityTag):''));
+ showHomeSurfaces();
disposeStage(false);
const seq=++entityRequestSeq;
const [d,items]=await Promise.all([
api(`/api/entity?kind=${encodeURIComponent(kind)}&name=${encodeURIComponent(name)}`),
fetchEntityItems(kind,name,entityTag)]);
- if(d.error||seq!==entityRequestSeq)return;
+ if(d.error||seq!==entityRequestSeq||
+ decodeURIComponent(location.pathname)!==decodeURIComponent(expectedPath))return;
document.body.classList.add('entity-open');
$('#index').hidden=false;$('#grid').innerHTML='';$('#count').textContent='';
$('#loadSentinel').hidden=true;$('#shortsSec').hidden=true;
@@ -1804,16 +1846,52 @@ const EDGE_ICONS=[
['performers','艺人','user-round'],
['tags','标签','tags'],
['flagged','已标记','star'],
- ['trash','回收站','trash'],
- ['ads','疑似广告','list-filter'],
['immerse','沉浸模式','play'],
- ['stats','统计与管理','chart'],
+ ['manage','管理','settings'],
+];
+/* 统计、疑似广告、回收站、人工复核都是「管理」下的二级入口,不再各占一个顶层图标。
+ URL 保持原样(/stats、/trash、/review、?state=ads),只是多了一层共同的导航条。 */
+const MANAGE_SECTIONS=[
+ ['stats','统计','chart'],
+ ['ads','疑似广告','alert'],
+ ['trash','回收站','trash'],
['review','人工复核','square-check-big'],
];
+function manageSection(){
+ const path=decodeURIComponent(location.pathname);
+ if(path==='/stats')return 'stats';
+ if(path==='/review')return 'review';
+ if(path==='/trash')return 'trash';
+ return state.state==='ads'?'ads':'';
+}
+function buildManageBar(){
+ const current=manageSection(),bar=$('#managebar');
+ bar.hidden=!current;
+ // 管理区是行政界面,不该顶着首页的人物/厂牌横条和标签筛选。
+ if(current){$('#tiers').style.display='none';$('#tagbar').style.display='none'}
+ buildEdge(); // 顶层高亮跟随管理区;否则从首页进来时仍停在「首页」上
+ if(!current)return;
+ bar.innerHTML=MANAGE_SECTIONS.map(([k,label,ic])=>
+ `<button data-manage="${k}" aria-pressed="${k===current}">${icon(ic)}<span>${label}</span></button>`).join('');
+ bar.querySelectorAll('[data-manage]').forEach(b=>b.onclick=()=>openManage(b.dataset.manage));
+}
+function openManage(section='stats'){
+ if(section==='stats'){openStats();return}
+ if(section==='review'){openReview();return}
+ state.orient='';state.state=section==='trash'?'trash':'ads';
+ route(section==='trash'?'/trash':'/');
+ showHomeSurfaces();buildEdge();buildBars();load(true);
+}
function navOn(k){
- if(['immerse','stats','performers','tags','review'].includes(k))return false;
+ const path=decodeURIComponent(location.pathname);
+ if(k==='manage')return !!manageSection();
+ if(k==='performers'||k==='tags')return path==='/'+k;
+ if(k==='immerse')return path==='/immerse';
if(k==='shorts')return state.orient==='竖屏';
- return state.state===k && state.orient!=='竖屏';
+ // 首页只在真的停在首页列表上时亮:管理区、索引页、实体页都不算,
+ // 否则它会和当前所在的入口同时高亮。
+ if(k==='')return path==='/'&&!manageSection()&&!state.state&&state.orient!=='竖屏';
+ return path==='/'&&state.state===k&&state.orient!=='竖屏';
}
function buildEdge(){
$('#edge').innerHTML=EDGE_ICONS.map(([k,t,ic])=>
@@ -1832,11 +1910,11 @@ function buildEdge(){
const k=b.dataset.nav;
closeDrawerAfterNav(); // 点了就收起抽屉,且短暂禁止悬停把它立刻弹回
if(k==='immerse'){openTok();return}
- if(k==='stats'){openStats();return}
- if(k==='review'){openReview();return}
+ if(k==='manage'){openManage();return}
if(k==='performers'||k==='tags'){openIndex(k);return}
if(k==='shorts'){state.orient='竖屏';state.state=''}else{state.orient='';state.state=k}
- if(k==='trash')route('/trash');
+ if(location.pathname!=='/')route('/');
+ showHomeSurfaces();
buildEdge();buildBars();load(true)});
}
let edgeT=null;
@@ -1906,6 +1984,7 @@ async function load(reset){
const d=await api('/api/items?'+p);cache(d.items);
if(requestSeq!==loadRequestSeq)return;
if(reset)total=d.total;
+ buildManageBar();
const html=batchWithMix(d.items,location.pathname==='/'&&state.state!=='trash');
if(reset)releaseHoverPreviews($('#grid'));
if(reset)$('#grid').innerHTML=html; else $('#grid').insertAdjacentHTML('beforeend',html);
@@ -1923,6 +2002,30 @@ const loadObserver=new IntersectionObserver(entries=>{
},{rootMargin:'320px'});
loadObserver.observe($('#loadSentinel'));
const SEARCH_HINTS=['Prestige','FC2','Sakura Misaki','丝袜','足交','ABW'];
+/* 推荐词取自真实数据,所以每一条都保证能搜到东西;写死的常量池只有 6 个词,
+ 翻两次就重复。顶部聚合只给几十条,不够;索引接口一次能给近千条名字。 */
+let searchPoolCache=null;
+function searchPool(){
+ if(searchPoolCache&&searchPoolCache.length)return searchPoolCache;
+ const pool=[];
+ const take=list=>(list||[]).forEach(x=>{const v=x&&x.k;if(v)pool.push(String(v))});
+ if(typeof facets==='object'&&facets){take(facets.creators);take(facets.tagperformers);take(facets.tags)}
+ const seen=new Set();
+ const unique=pool.filter(v=>v.length>1&&!seen.has(v)&&seen.add(v));
+ return unique.length>=8?unique:SEARCH_HINTS;
+}
+async function loadSearchPool(){
+ if(searchPoolCache)return searchPoolCache;
+ try{
+ const lists=await Promise.all(['performers','creators','tags'].map(
+ kind=>api(`/api/index?kind=${kind}&limit=400`)));
+ const seen=new Set();
+ const names=lists.flatMap(d=>(d.items||[]).map(x=>String(x.k||'')))
+ .filter(v=>v.length>1&&!seen.has(v)&&seen.add(v));
+ if(names.length>=50)searchPoolCache=names;
+ }catch(e){/* 取不到就退回聚合结果,不影响搜索本身 */}
+ return searchPool();
+}
const searchSuggestion=SEARCH_HINTS[Math.floor(Math.random()*SEARCH_HINTS.length)];
$('#q').dataset.suggestion=searchSuggestion;$('#q').placeholder=searchSuggestion;
let searchHistory=[];
@@ -1931,7 +2034,7 @@ const loadSearchHistory=()=>api('/api/search-history?limit='+appSettings.searchH
const writeSearchHistory=list=>{searchHistory=list.slice(0,appSettings.searchHistoryLimit);return searchHistory};
const rememberSearch=async query=>{if(!query)return;await api('/api/search-history',{method:'POST',body:JSON.stringify({query})});writeSearchHistory([query,...readSearchHistory().filter(x=>foldName(x)!==foldName(query))])};
function renderSearchMenu(){const menu=$('#searchMenu'),history=readSearchHistory();
- const recommendations=[...SEARCH_HINTS].sort(()=>Math.random()-.5).filter(x=>!history.some(h=>foldName(h)===foldName(x))).slice(0,5);
+ const recommendations=[...searchPool()].sort(()=>Math.random()-.5).filter(x=>!history.some(h=>foldName(h)===foldName(x))).slice(0,5);
const row=(value,type)=>`<div class="searchoption" data-search-value="${esc(value)}">${icon(type==='history'?'history':'sparkles')}<span>${esc(value)}</span>${type==='history'?`<button class="removehistory" data-remove-history="${esc(value)}" aria-label="删除历史 ${esc(value)}">${icon('x')}</button>`:''}</div>`;
menu.innerHTML=(history.length?`<section class="searchgroup"><h3>搜索记录</h3>${history.map(x=>row(x,'history')).join('')}</section>`:'')+
`<section class="searchgroup"><h3>推荐</h3>${recommendations.map(x=>row(x,'recommend')).join('')}</section>`;
@@ -1946,7 +2049,7 @@ const runSearch=(useSuggestion=false,committed=false)=>{let query=$('#q').value.
state.q=query;route(state.q?'/?q='+encodeURIComponent(state.q):'/',true);load(true)};
$('#q').oninput=()=>{if(!$('#searchMenu').hidden)renderSearchMenu()};
$('#q').onkeydown=e=>{if(e.key==='Enter'){e.preventDefault();runSearch(true,true);$('#searchMenu').hidden=true;$('#q').blur()}};
-$('#q').addEventListener('focus',()=>{loadSearchHistory().then(renderSearchMenu)});
+$('#q').addEventListener('focus',()=>{Promise.all([loadSearchHistory(),loadSearchPool()]).then(renderSearchMenu)});
const SHORTS_ROW_OFFSET=2; // 竖屏条插在第几行之后,0 表示置顶
async function loadShorts(requestSeq=loadRequestSeq){
@@ -2348,7 +2451,7 @@ $('#brandHome').onclick=e=>{e.preventDefault();
route('/');$('#q').value='';disposeStage(false);buildBars();load(true);window.scrollTo({top:0,behavior:'smooth'})};
$('#tokClose').onclick=()=>{setTokLoading(false);route('/');$('#tok').hidden=true;$('#tokTrack').querySelectorAll('video').forEach(v=>{
v.pause();v.removeAttribute('src');v.load();if(v.id!=='tokVid')v.remove()});
- const v=$('#tokVid');if(v){v.style.transform='translateX(-50%)'}tokSwitching=false;document.body.style.overflow=''};
+ const v=$('#tokVid');if(v){v.style.transform='translateX(-50%)'}tokSwitching=false;document.body.style.overflow='';showHomeSurfaces();load(true)};
let wl=0;
$('#tok').addEventListener('wheel',e=>{const n=Date.now();if(n-wl<260)return;wl=n;tokNext(e.deltaY>0?1:-1)},{passive:true});
let ty=0;
@@ -2384,7 +2487,10 @@ document.addEventListener('keydown',e=>{
async function refreshAll(automatic=false){
if(automatic&&(!appSettings.autoRefresh||document.hidden||location.pathname!=='/'||
!$('#stage').hidden||!$('#tok').hidden||selectMode||selected.size||document.activeElement===$('#q')))return false;
- if(!$('#stats').hidden){await openStats();return} // 统计页只刷统计
+ if(!$('#stats').hidden){
+ if(location.pathname==='/review'){await openReview(false);return}
+ await openStats(false);return
+ } // 统计/复核页只刷新当前表面
if(!$('#index').hidden){return}
state.sort='seed'; state.seed=String(Date.now()%99991);
await load(true);