Skip to content

armgit / peach

Public Imported from GitHub
0

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

完善统计口味预览与在线播放统计

longmeidao779ec403990e
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index dda706826..302cedc17 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -68,14 +68,14 @@ Claude 的 `.claude/settings.json` 已配置 Stop、StopFailure、SessionEnd hoo
其余上游黑话词(兜底、落盘、闭环、链路)一律改写成具体机制。
## 参考产品证据登记
-
具体快照、URL、版本、SHA 与 Peach 差异统一登记在 `docs/reference-sources.json` 和 `docs/reference-snapshots/`;获取、失效复核与接受更新的流程见 `.claude/skills/peach-reference-evidence/SKILL.md`。本文件不再复制会随上游变化的测量值。
**Vercel Geist Grid(2026-08-28)**:官方页 `https://vercel.com/geist/grid` 的实时 DOM 使用资源类
`grid-module__AMTIxG__grid`;网格引导线由父级统一拥有,单元透明、0 圆角,示例按阅读顺序逐行排列,
并明确要求各断点可预测重排、可点击单元独立显示 focus。Peach 复用共享边线与 3/2/1 列重排,
但 Tag 仍保留 6px 小圆角,普通排行不复制演示页的大留白或装饰性引导线。
**Vercel Geist 控件(2026-08-28)**:官方 introduction 页实测普通操作使用 4/6px 圆角、图标操作为 32×32px,圆形留给 emoji 反馈等特殊语义。Peach 的普通操作和关闭按钮因此统一用 `--control-radius:6px`,菜单与 Modal 使用 `--floating-radius:12px`,状态标记使用 `--badge-radius:4px`;Tag 保持胶囊,媒体左右切换与头像保留圆形。全站字号、顶栏、搜索、播放列表、设置、管理、详情、关注与移动端共用这套语义 token;弹层自己的滚动容器必须使用 `overscroll-behavior:contain`,粘性标题栏要设置 `scroll-padding-top`,不能遮住键盘焦点。锁定版本、完整测量和有意差异见 `vercel-geist-controls-measured.md`。**Vercel Geist MiddleTruncate(2026-08-30)**:官方页 <https://vercel.com/geist/middle-truncate> 规定只对文件路径、URL、ID、SHA 等首尾都有信息的值做中间省略;单个 `…` 随容器宽度重算,复制和无障碍名称保留完整原文,外层不得再套 `text-overflow:ellipsis`。Peach 用原生 ES module 适配这套行为,不引入 React;资源标识必须显式使用 `data-middle-truncate`,标题、说明、人名和标签保留末尾省略;页面源门槛登记全部末尾省略选择器,任何新增截断都必须先分类。实时浏览器 DOM/CSS/JS 本轮未取得,通道错误与候选判断见 `vercel-geist-middle-truncate.md`。
-**Vercel Tooltip/Collapse/Context Card/Projects/Analytics/Speed Insights 与 Geist Note/Progress/Switch/Fieldset/Scroller/Empty State(2026-08-30)**:登录态项目页确认搜索占剩余宽度、筛选为方形图标钮、主操作在右,菜单无展开动画且内部滚动;Analytics 与 Speed Insights 都使用「全局筛选或来源 Switch → 横向摘要指标带 → 主详情 → 同层 tablist 数据面板」层级,不把每个维度堆成独立 Bento。Peach 的统计页用真实库存、观看、覆盖和系统盘指标复用该层级;口味页以浏览器记录/Peach 内部作为真实证据来源,不伪造体验分或时间图。Tooltip 固定在视口内,来源菜单不得套用 Collapse motion,作者别名才使用 Collapse;短元数据浮层最多一个主动作,Escape 关闭并交还焦点,瞬时成功回执用 Toast,错误恢复留在原位置;Note 只放字段/卡片/分区旁的持久上下文,页面问题用 Banner;Progress 必须有真实 value/max 和 ARIA,Switch 只用于 2–3 个互斥视图,布尔值用 Toggle;Fieldset 同组卡片固定同高,变化正文放单一 Scroller,Footer 保持固定动作区;Empty State 必须把图标、标题、说明和可选动作收在同一组件,且与上方工具条保持统一间距。完整 URL、资源 SHA、浏览器失败与恢复路径和 Peach 差异见 `vercel-geist-semantics-measured.md`、`vercel-geist-note-progress-switch-analytics.md` 与 `vercel-geist-fieldset-scroller-empty-state.md`;实现门槛见 `peach-web-ui`。
+**Vercel Tooltip/Collapse/Context Card/Projects/Analytics/Speed Insights 与 Geist Note/Progress/Switch/Fieldset/Scroller/Empty State(2026-08-30)**:登录态项目页确认搜索占剩余宽度、筛选为方形图标钮、主操作在右,菜单无展开动画且内部滚动;Analytics 与 Speed Insights 都使用「全局筛选或来源 Switch → 横向摘要指标带 → 主详情 → 同层 tablist 数据面板」层级,不把每个维度堆成独立 Bento。Peach 的统计页用真实库存、观看、覆盖和系统盘/资源盘/网盘使用空间复用该层级;口味页以浏览器记录/Peach 内部作为真实证据来源,不伪造体验分或时间图。Tooltip 固定在视口内,来源菜单不得套用 Collapse motion,作者别名才使用 Collapse;短元数据浮层最多一个主动作,Escape 关闭并交还焦点,瞬时成功回执用 Toast,错误恢复留在原位置;Note 只放字段/卡片/分区旁的持久上下文,页面问题用 Banner;Progress 必须有真实 value/max 和 ARIA,Switch 只用于 2–3 个互斥视图,布尔值用 Toggle;Fieldset 同组卡片固定同高,变化正文放单一 Scroller,Footer 保持固定动作区;Empty State 必须把图标、标题、说明和可选动作收在同一组件,且与上方工具条保持统一间距。完整 URL、资源 SHA、浏览器失败与恢复路径和 Peach 差异见 `vercel-geist-semantics-measured.md`、`vercel-geist-note-progress-switch-analytics.md` 与 `vercel-geist-fieldset-scroller-empty-state.md`;实现门槛见 `peach-web-ui`。
+**Vercel Geist Table/Home(2026-08-30)**:同形可比较数据使用语义 `table`,数字列保持 tabular numerals;Peach 因此把系统盘、资源盘、115 与 PikPak 容量放进同一张使用空间表。内容标签是固定 Top 排行和直接筛选,不伪装成可排序数据表,桌面使用保持 DOM 排名顺序的双栏有序列表,手机回到单栏。Vercel Table 的交互 DOM 与计算样式本轮未取得,Home 只确认共享对齐和清晰分区;失败通道、已取得原则与有意差异见 `vercel-geist-table-ranking.md`。
默认 Note、只读提示和 info 入口统一复用图片详情已有的本地 Lucide 圆圈 `i`,不复制未开放许可的 Geist 私有 SVG。**Vercel Command Menu/Search Input/Spinner/Loading Dots(2026-08-30)**:设置覆盖层使用锁定 Dialog CSS 的 350ms、`cubic-bezier(.4,0,.2,1)` 与 -40px 淡入轨迹,普通菜单仍无动画;Search Input 的搜索图标在查询期间原位换成 Spinner。用户直接触发的检查、加载、保存与应用使用 Spinner,后台抓取和扫描进度使用 Loading Dots;“没有更多历史内容”是中性、可关闭的 Note,不得登记为红色故障。证据哈希、未取得面与 Peach 差异见 `vercel-geist-command-search-loading.md`。
**Beeg 资料页(2026-08-30)**:Reislin 与 SweetieFox 页面证据锁定的顺序是头像与名称、简介、外部链接、关联艺人轨道、标签轨道、内容;轨道不另加可见标题。Peach 的女优/厂牌资料页和关注页复用这个阅读顺序;资料页有照片时只显示一个 32×32px `PicsIcon`,放在标签左侧,选中代表照片视图,再点一次回到视频,不保留独立的「视频/照片」文字标签栏。合集详情继续使用普通详情的左媒体、右信息,下方另设 Mix/分卷/播放列表/多视频的横向切换带。锁定样式摘要、哈希、未取得面和主动差异见 `beeg-profile-layout.md`。
YouTube Shorts 沉浸页使用用户截图记录 `docs/reference-snapshots/youtube-shorts-immersive-user-screenshot.md`:竖屏复用中央 9:16 舞台和外置动作列,横屏使用在整个视口视觉居中的 16:9 舞台并把动作列收进视频右侧;Peach 保留自己的反馈语义,不复制订阅或社交动作。沉浸视频每次加载都要带独立 `session`,切片、关闭、失败和页面离开时取消旧会话;只清浏览器的 `src` 不足以停止 CloudDrive 预读或 FFmpeg。普通播放器控制栏另使用用户截图与 YouTube 官方帮助记录 `docs/reference-snapshots/youtube-player-controls-user-screenshot.md`:进度独占上排,播放/音量/时间在左下,画中画/设置/影院/全屏在右下使用同高圆形按钮;已播段、圆点和卡片观看进度统一使用 Peach 蓝。键盘仍按设置前后跳转,控制栏不重复画 10 秒按钮;本地时刻预览复用九宫格接触表,在线视频只显示时刻。设置浮层只列真实能力:氛围模式全局开关、播放速度和实际清晰度;影院模式用按钮或 `T` 切换为大播放器,详情移到下方。Peach 不复制没有实际能力的字幕、睡眠定时或自动播放按钮。
diff --git a/docs/STATUS.md b/docs/STATUS.md
index 4a2b749c5..466ee2615 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -39,6 +39,7 @@ undefine
## 本批修正与验证
- 2026-08-30 普通详情与在线关注播放器继续按锁定的 YouTube 证据收口:左下、右下五个可见按钮统一为 40×40 圆框并共用基线,左上统计圆钮与加载速度固定同高;设置浮层只列真实的氛围模式、播放速度和清晰度,氛围模式沿用 32×18 当前帧取色与模糊扩散并新增全局持久开关;影院按钮与 `T` 在不进入全屏时扩展播放器,详情和队列移到下方。1440×900 与 390×844 的真实在线关注视频实测浮层、开关、1.25× 速度、影院布局、无横向溢出和控制台 0 错误;生产页五个圆框均为 40×40、设置浮层 340×192/22px 圆角,氛围状态已恢复为开启。集成后 `catalog` 455 项全绿;全量 1295 项只剩与本批无关且前两轮通过的预览并发计时用例在高负载下瞬态失败,随后 `catalog` 中同域复核通过。生产 `app.js`/`app.css` 严格 HTTPS 哈希与 `master` 一致,项目 CA `/healthz` 返回 0.7.13、writer、非只读;纯前端资源无需重启,本轮未写真实 ledger、未替换 EXE。
+- 2026-08-30 完成统计/口味预览反馈:全站最深底色从 `#020408` 提亮为 `#080A0D`,覆盖关注管理、输入与登录表面;关注页直接在线播放新增独立观看事实,不再要求先保存成 asset,真实 ledger 尚未应用新迁移。统计页用系统盘、资源盘、115 与 PikPak 的使用空间表替代单一系统盘,标签 Top 排行在桌面分成两栏、手机单栏;重复分隔线、管理导航/标题对齐、口味数据源说明间距和 `Tag` 文案一并修正。Vercel Table/Home 的已取得原则、浏览器超时与有意差异已锁定。重放到最新主分支后 Windows 正式全量 1303 项通过、13 项按平台跳过;临时副本的 1280×900 与 390×844 实测页面横向溢出 0、管理导航相对内容区居中、标题与阅读列左边一致、存储表 4 行、标签排行 2/1 栏、可见面板唯一且控制台警告/错误 0。更新后预览保留在 8924;未写真实 ledger、未替换 EXE、未部署或重启 80/443。
- 2026-08-30 依据登录态 Vercel Analytics 与 Speed Insights 当前页面重做统计/口味两页:统计页用库存、观看、标签覆盖和系统盘四个真实指标构成横向指标轨,单项主详情与标签/最近观看/标签来源 tablist 同层切换;口味页以浏览器记录/Peach 内部作为真实证据来源,摘要、主详情和 Tag/创作者/女优等排行随来源切换,不伪造体验分或时间图。实际浏览器首轮发现显式 `display:grid` 覆盖 `hidden`,已补隐藏门槛和页面源测试。真实 ledger 与浏览历史的一致临时副本在 1280×900、390×844 下实测:统计详情、统计维度、口味来源和口味维度均只显示当前面板,页面级横向溢出 0,指标轨只在自身内部滚动,控制台错误 0。重放到当前 master 后 Windows 正式全量 1290 项通过、13 项按平台跳过;一次性预览和临时副本已删除,本轮未写真实 ledger、未替换 EXE、未部署或重启 80/443。
- 2026-08-30 修复详情播放器与在线保存回归:关注详情的保存按钮在异步请求前固定 DOM 引用,Firefox 不再因 `event.currentTarget` 归零报错;关注视频改用首页详情同一套 Video.js,控制栏统一垂直几何并新增真实 `qualityLevels` 清晰度菜单,单一路源只显示实测分辨率/原画,不伪造 720p、480p。关注 API 只新增安全 MIME 投影,原始媒体 URL 仍不进入 JSON。详情右栏将“整列背景”和“76vh 可滚动内容”拆层,本地、在线资产、关注、图片及合集分支共用,背景不再随内容上限截短。正式 Windows 全量 1277 项通过、13 项按平台跳过;临时账本浏览器实测保存 POST 200、按钮变为“已保存”、在线视频为 Video.js,桌面与 390×844 控件对齐、清晰度菜单在视口内且无横向溢出。改动已合入 `master`,Windows 托盘及 80/443 源码服务已重启,项目 CA 严格 HTTPS `/healthz` 返回 0.7.13、writer、非只读,生产 `app.js`/`app.css` 已包含修复。生产 `/item/128423` 在 1280×720 实测右栏、媒体和网格行同高 435.375px,横向溢出 0;生产关注详情导航被媒体请求拖至浏览器控制超时,最终生产 DOM 复测未取得,未用静态资源代替该结论。本轮未替换 EXE、未触发关注检查、未写真实 ledger;独立 8918 进程保持不动。
- 2026-08-30 修正管理页与小图模式的剩余几何回归:重复文件和回收站的标题说明改用同一个 `pagelede` 元素与样式,空回收站不再保留隐藏计数栏高度;统计页删除空 `statshead` 并移除容器上内边距;Progress 暗轨改用 `line-soft`,资源同步去掉父网格之外的额外上边线、上内边距和上外边距;JAV 小图对整页混合卡片固定标题/身份/标签三行,缺字段保留行高,长字段省略。Windows 正式全量 1273 项通过、13 项按平台跳过。改动已合入 `master`,生产 `app.css`/`app.js` SHA-256 与源码一致;项目 CA 严格 HTTPS `/healthz` 返回 0.7.13、writer、非只读,纯前端资源无需重启。内置浏览器能在 1 秒内列出已加载的“统计 · Peach”标签,但 `goto`、Playwright evaluate、CDP evaluate 和截图均在 10–30 秒超时并重置控制连接,计算样式和桌面/手机视觉验收未取得;这不是页面未加载的证据,未用静态测试冒充视觉通过。本轮未替换 EXE、未重启服务、未写真实 ledger。
diff --git a/docs/reference-snapshots/vercel-geist-table-ranking.md b/docs/reference-snapshots/vercel-geist-table-ranking.md
new file mode 100644
index 000000000..19176daf4
--- /dev/null
+++ b/docs/reference-snapshots/vercel-geist-table-ranking.md
@@ -0,0 +1,20 @@
+# Vercel Geist Table 与首页布局证据(2026-08-30)
+
+## 请求与取得通道
+
+- 目标:`https://vercel.com/geist/table`、`https://vercel.com/home`。
+- 登录态内置浏览器先后两次读取 Table,均在 30 秒超时并重置控制连接;可交互 DOM、计算样式与截图未取得。
+- 直接读取 Table 返回 HTTP 400,原因是该入口声明的 `text/markdown` 内容类型不受读取通道支持;正文未取得。
+- 官方索引结果取得 Table 当前的使用原则:同形、可比较的数据使用语义 table;可排序表头使用 button;数字使用 tabular numerals;空态置于表格外;名称采用专名或名词短语。
+- Vercel Home 当前 HTML 已取得,只确认共享对齐线与分区清晰的页面层级;没有取得可复用的标签排行组件,因此不从首页猜测排行像素或交互。
+
+## Peach 采用与差异
+
+- 使用空间的四个位置属于同形可比较数据,使用原生 `table`,列为位置、已用、可用与使用率;数字列使用 tabular numerals。
+- 内容标签是固定 Top 30 排行并可直接筛选,不提供虚假的列排序;桌面以两栏有序列表提高扫描密度,DOM 顺序保持排名顺序,390px 手机回到单栏。
+- 表格与排行都复用 Peach 既有 `--line-soft`、字号和 1100px 阅读列,不复制未取得的 Vercel 像素、动效或内部组件实现。
+
+## 复核入口
+
+- https://vercel.com/geist/table
+- https://vercel.com/home
diff --git a/docs/reference-sources.json b/docs/reference-sources.json
index d785e54da..e033839bf 100644
--- a/docs/reference-sources.json
+++ b/docs/reference-sources.json
@@ -16,6 +16,20 @@
"tests/test_follow_web.py"
]
},
+ {
+ "id": "vercel-geist-table-ranking",
+ "name": "Vercel Geist Table 与首页排行布局证据",
+ "url": "https://vercel.com/geist/table",
+ "snapshot": "docs/reference-snapshots/vercel-geist-table-ranking.md",
+ "checked_on": "2026-08-30",
+ "sha256": "b43ee5b96e91a959fe6fa655de316f4438e6ec83fcfbdeae1f8bb7cf6d5d9e15",
+ "role": "统计页使用空间语义表格与标签排行密度的项目级依据;未取得的 Vercel DOM 和像素不作复刻证据。",
+ "consumers": [
+ "web/app.css",
+ "web/app.js",
+ "tests/test_web_ui.py"
+ ]
+ },
{
"id": "vercel-web-interface-guidelines",
"name": "Vercel Web Interface Guidelines",
diff --git a/migrations/0022_follow_playback.sql b/migrations/0022_follow_playback.sql
new file mode 100644
index 000000000..76fd6234e
--- /dev/null
+++ b/migrations/0022_follow_playback.sql
@@ -0,0 +1,14 @@
+-- 关注页直接在线播放同样属于观看行为;不要求先把候选保存成 asset。
+-- follow_item 的 new/seen/saved/ignored 是当前收件箱状态,不能承担不可回退的播放历史。
+CREATE TABLE IF NOT EXISTS follow_playback(
+ follow_item_id INTEGER NOT NULL REFERENCES follow_item(id) ON DELETE CASCADE,
+ profile_id TEXT NOT NULL DEFAULT 'local-default' REFERENCES profile(id),
+ play_count INTEGER NOT NULL DEFAULT 0 CHECK(play_count >= 0),
+ play_seconds REAL NOT NULL DEFAULT 0 CHECK(play_seconds >= 0),
+ max_reached REAL NOT NULL DEFAULT 0 CHECK(max_reached >= 0 AND max_reached <= 1),
+ last_played REAL,
+ PRIMARY KEY(follow_item_id, profile_id)
+);
+
+CREATE INDEX IF NOT EXISTS idx_follow_playback_profile_time
+ON follow_playback(profile_id, last_played DESC);
diff --git a/src/peach/api.py b/src/peach/api.py
index 08aac66d5..acb6683f1 100644
--- a/src/peach/api.py
+++ b/src/peach/api.py
@@ -354,7 +354,7 @@ def create_app(
'<meta name="viewport" content="width=device-width,initial-scale=1">'
'<meta name="color-scheme" content="dark"><title>登录 Peach</title>'
'<style>'
- '*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#020408;color:#f5f7fb}'
+ '*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#080A0D;color:#f5f7fb}'
'body{min-height:100dvh;display:grid;place-items:center;padding:24px;font:15px/1.45 system-ui,sans-serif}'
'main{width:min(360px,100%);padding:30px;border:1px solid rgba(255,255,255,.12);border-radius:20px;'
'background:rgba(30,32,37,.9);box-shadow:0 24px 80px rgba(0,0,0,.48)}'
diff --git a/src/peach/web_contract.py b/src/peach/web_contract.py
index 6c0b0c67d..c9faad70e 100644
--- a/src/peach/web_contract.py
+++ b/src/peach/web_contract.py
@@ -54,7 +54,8 @@ from .taste_history import (
from .web_follow import (
q_follow, q_follow_credentials, q_follow_schedule,
w_follow_check, w_follow_credential, w_follow_resolve, w_follow_schedule,
- w_follow_author_alias, w_follow_save, w_follow_source, w_follow_status,
+ w_follow_activity, w_follow_author_alias, w_follow_play, w_follow_save,
+ w_follow_source, w_follow_status,
)
from .web_activity import (
DEFAULT_PROFILE_ID,
@@ -1327,8 +1328,48 @@ def q_index(contract: WebContract, kind, q="", limit=600, offset=0, category="")
result["categories"] = category_counts
return result
+_STORAGE_LABELS = {
+ "system": "系统盘",
+ "local": "资源盘",
+ "115": "115 网盘",
+ "pikpak": "PikPak 网盘",
+}
+
+
+def _storage_volumes() -> list[dict[str, object]]:
+ """返回当前主机可验证的系统卷、资源盘和网盘容量。"""
+ declarations = [("system", system_volume(), True)] + [
+ (location, translate_ledger_path(root), False)
+ for location, root in LOCATION_ROOT_DECLARATIONS.items()
+ ]
+ volumes: list[dict[str, object]] = []
+ for kind, root, is_system in declarations:
+ mounted = not is_unmapped(root) and (is_system or root_online(root))
+ row: dict[str, object] = {
+ "kind": kind,
+ "label": _STORAGE_LABELS[kind],
+ "root": str(root) if not is_unmapped(root) else None,
+ "online": mounted,
+ "free": None,
+ "used": None,
+ "total": None,
+ }
+ if mounted:
+ try:
+ usage = shutil.disk_usage(root)
+ row.update(
+ free=usage.free,
+ used=max(usage.total - usage.free, 0),
+ total=usage.total,
+ )
+ except OSError:
+ pass
+ volumes.append(row)
+ return volumes
+
+
def q_stats(contract: WebContract):
- """统计页:库存 / 归属 / 标签 / 消费 / 磁盘。原来挤在顶栏右上角,信息量太小又碍眼。"""
+ """统计页:库存 / 归属 / 标签 / 本地与在线播放 / 各存储卷。"""
with contract.read_connection() as c:
out = {}
out["by_loc"] = [dict(r) for r in c.execute(
@@ -1367,9 +1408,29 @@ def q_stats(contract: WebContract):
"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")]
+ tables = {row[0] for row in c.execute(
+ "SELECT name FROM sqlite_schema WHERE type='table'"
+ )}
+ library_played = one("SELECT count(*) FROM asset WHERE play_count>0")
+ library_seconds = one("SELECT COALESCE(sum(play_seconds),0) FROM asset")
+ online_played = 0
+ online_seconds = 0
+ if "follow_playback" in tables:
+ online_played = one(
+ "SELECT count(*) FROM follow_playback fp JOIN follow_item fi "
+ "ON fi.id=fp.follow_item_id WHERE fp.play_count>0 AND (fi.asset_id IS NULL OR "
+ "NOT EXISTS(SELECT 1 FROM asset a WHERE a.id=fi.asset_id AND a.play_count>0))"
+ )
+ online_seconds = one(
+ "SELECT COALESCE(sum(play_seconds),0) FROM follow_playback"
+ )
out["consumption"] = {
- "played": one("SELECT count(*) FROM asset WHERE play_count>0"),
- "play_seconds": one("SELECT COALESCE(sum(play_seconds),0) FROM asset"),
+ "played": library_played + online_played,
+ "library_played": library_played,
+ "online_played": online_played,
+ "play_seconds": library_seconds + online_seconds,
+ "library_play_seconds": library_seconds,
+ "online_play_seconds": online_seconds,
"o_total": one("SELECT COALESCE(sum(o_count),0) FROM asset"),
"dislike": one("SELECT count(*) FROM asset WHERE feedback='dislike'"),
"seen": one("SELECT count(*) FROM asset WHERE feedback='seen'"),
@@ -1377,17 +1438,37 @@ def q_stats(contract: WebContract):
"skimmed": one("SELECT count(*) FROM asset WHERE duration>0 AND play_seconds>0 "
"AND max_reached>0.6 AND play_seconds/duration < max_reached-0.25"),
}
- out["recent"] = [dict(r) for r in c.execute(
- "SELECT id,name,creator,play_seconds,duration,max_reached,leave_ratio,o_count "
- "FROM asset WHERE last_played IS NOT NULL ORDER BY last_played DESC LIMIT 12")]
- try:
- volume = system_volume()
- du = shutil.disk_usage(volume)
- out["system_disk"] = {"root": str(volume), "free": du.free, "total": du.total}
- out["disk_c"] = out["system_disk"] # 0.6.x 客户端兼容别名
- except Exception:
- out["system_disk"] = None
- out["disk_c"] = None
+ recent = [dict(r, kind="library") for r in c.execute(
+ "SELECT id,name,creator,play_seconds,duration,max_reached,leave_ratio,o_count,"
+ "CAST(last_played AS REAL) last_played FROM asset WHERE last_played IS NOT NULL "
+ "ORDER BY CAST(last_played AS REAL) DESC LIMIT 12")]
+ if "follow_playback" in tables:
+ recent.extend(dict(r, kind="online", leave_ratio=None, o_count=0) for r in c.execute(
+ "SELECT fi.id,fi.title name,fs.label creator,fp.play_seconds,fi.duration,"
+ "fp.max_reached,fp.last_played FROM follow_playback fp "
+ "JOIN follow_item fi ON fi.id=fp.follow_item_id "
+ "JOIN follow_source fs ON fs.id=fi.source_id WHERE fp.last_played IS NOT NULL "
+ "ORDER BY fp.last_played DESC LIMIT 12"
+ ))
+ out["recent"] = sorted(
+ recent, key=lambda row: float(row.get("last_played") or 0), reverse=True,
+ )[:12]
+ out["storage_volumes"] = _storage_volumes()
+ measured = [row for row in out["storage_volumes"] if row["total"] is not None]
+ out["storage_summary"] = {
+ "volumes": len(out["storage_volumes"]),
+ "online": sum(1 for row in out["storage_volumes"] if row["online"]),
+ "measured": len(measured),
+ "free": sum(int(row["free"]) for row in measured),
+ "used": sum(int(row["used"]) for row in measured),
+ "total": sum(int(row["total"]) for row in measured),
+ }
+ system = next((row for row in out["storage_volumes"] if row["kind"] == "system"), None)
+ out["system_disk"] = (
+ {"root": system["root"], "free": system["free"], "total": system["total"]}
+ if system and system["total"] is not None else None
+ )
+ out["disk_c"] = out["system_disk"] # 0.6.x 客户端兼容别名
return out
@@ -1910,6 +1991,8 @@ POST_HANDLERS = {
"/api/follow/credential": w_follow_credential,
"/api/follow/status": w_follow_status,
"/api/follow/save": w_follow_save,
+ "/api/follow/play": w_follow_play,
+ "/api/follow/activity": w_follow_activity,
"/api/activity": w_activity,
"/api/play": w_play,
"/api/feedback": w_feedback,
diff --git a/src/peach/web_follow.py b/src/peach/web_follow.py
index a1d3433fc..f59d4f4e4 100644
--- a/src/peach/web_follow.py
+++ b/src/peach/web_follow.py
@@ -705,6 +705,62 @@ def w_follow_status(contract, body) -> dict:
return result
+def _follow_playback_row(connection, item_id: int):
+ row = connection.execute(
+ "SELECT id,status FROM follow_item WHERE id=?", (item_id,),
+ ).fetchone()
+ if row is None:
+ raise ValueError("follow item not found")
+ return row
+
+
+def w_follow_play(contract, body) -> dict:
+ """记录一次关注页直接播放;候选无需先保存成 asset。"""
+ item_id = int(body["item"])
+ contract.cache_bust()
+ with contract.database.write_transaction() as connection:
+ row = _follow_playback_row(connection, item_id)
+ stamp = datetime.now(timezone.utc).timestamp()
+ connection.execute(
+ "INSERT INTO follow_playback(follow_item_id,profile_id,play_count,last_played) "
+ "VALUES(?,'local-default',1,?) ON CONFLICT(follow_item_id,profile_id) "
+ "DO UPDATE SET play_count=follow_playback.play_count+1,last_played=excluded.last_played",
+ (item_id, stamp),
+ )
+ if row["status"] == "new":
+ connection.execute(
+ "UPDATE follow_item SET status='seen' WHERE id=?", (item_id,),
+ )
+ return {"ok": True, "item": item_id, "status": "seen" if row["status"] == "new" else row["status"]}
+
+
+def w_follow_activity(contract, body) -> dict:
+ """累计关注页在线播放的真实时长与最远到达位置。"""
+ item_id = int(body["item"])
+ position = max(float(body.get("position", 0)), 0)
+ duration = max(float(body.get("duration", 0)), 0)
+ delta = max(float(body.get("delta", 0)), 0)
+ ended = bool(body.get("ended"))
+ ratio = 1.0 if ended else (min(position / duration, 1.0) if duration > 0 else 0.0)
+ contract.cache_bust()
+ with contract.database.write_transaction() as connection:
+ _follow_playback_row(connection, item_id)
+ stamp = datetime.now(timezone.utc).timestamp()
+ connection.execute(
+ "INSERT INTO follow_playback(follow_item_id,profile_id,play_count,play_seconds,max_reached,last_played) "
+ "VALUES(?,'local-default',1,?,?,?) ON CONFLICT(follow_item_id,profile_id) DO UPDATE SET "
+ "play_seconds=follow_playback.play_seconds+excluded.play_seconds,"
+ "max_reached=max(follow_playback.max_reached,excluded.max_reached),"
+ "last_played=excluded.last_played",
+ (item_id, delta, ratio, stamp),
+ )
+ result = connection.execute(
+ "SELECT play_seconds,max_reached FROM follow_playback "
+ "WHERE follow_item_id=? AND profile_id='local-default'", (item_id,),
+ ).fetchone()
+ return {"ok": True, "item": item_id, **dict(result)}
+
+
def w_follow_save(contract, body) -> dict:
item_ids = _write_item_ids(body)
with contract.database.write_transaction() as connection:
diff --git a/tests/test_follow_web.py b/tests/test_follow_web.py
index 31cdaa2e5..f036db89b 100644
--- a/tests/test_follow_web.py
+++ b/tests/test_follow_web.py
@@ -370,6 +370,32 @@ class FollowContractTests(unittest.TestCase):
self.assertEqual(result["items"], items)
self.assertEqual(self._get(status="seen")["counts"]["seen"], 2)
+ def test_direct_online_play_counts_without_saving_an_asset(self):
+ self._seed()
+ item = self._get()["groups"][0]["primary"]["id"]
+
+ started = self._post("/api/follow/play", {"item": item})
+ activity = self._post("/api/follow/activity", {
+ "item": item, "position": 12, "duration": 20, "delta": 10,
+ })
+
+ self.assertEqual(started["status"], "seen")
+ self.assertEqual(activity["play_seconds"], 10)
+ self.assertEqual(activity["max_reached"], 0.6)
+ with self.contract.database.read_connection() as connection:
+ row = dict(connection.execute(
+ "SELECT play_count,play_seconds,max_reached FROM follow_playback "
+ "WHERE follow_item_id=?", (item,),
+ ).fetchone())
+ self.assertEqual(row, {"play_count": 1, "play_seconds": 10.0,
+ "max_reached": 0.6})
+
+ stats = self._get("/api/stats")
+ self.assertEqual(stats["consumption"]["online_played"], 1)
+ self.assertEqual(stats["consumption"]["played"], 1)
+ self.assertEqual(stats["consumption"]["online_play_seconds"], 10)
+ self.assertEqual(stats["recent"][0]["kind"], "online")
+
def test_feed_ignores_a_nonsense_limit_instead_of_failing(self):
self._seed()
self.assertEqual(len(self._get(limit="nope")["groups"]), 1)
@@ -1453,7 +1479,8 @@ class FollowWebSourceTests(unittest.TestCase):
def test_follow_video_uses_the_shared_videojs_player_and_quality_control(self):
self.assertPageContains('class="video-js vjs-big-play-centered" controls playsinline preload="metadata"')
- self.assertPageContains("if(followVideo){const followPlayer=mountDetailPlayer(item,followVideo,false,{")
+ self.assertPageContains("if(followVideo){")
+ self.assertPageContains("const followPlayer=mountDetailPlayer(item,followVideo,false,{")
self.assertPageContains("source:{src,type:selectedMedia?.media_type||item.media_type||'video/mp4'}")
self.assertPageContains("function mountPlayerQualityControl(player,video,fallbackHeight=0)")
self.assertPageContains('aria-label="播放器设置"')
@@ -1463,6 +1490,9 @@ class FollowWebSourceTests(unittest.TestCase):
self.assertPageContains("const stopFollowAmbient=mountPlayerAmbient(followVideo)")
self.assertPageContains("followPlayer?.one?.('dispose',stopFollowAmbient)")
self.assertPageContains("mountPlayerTheaterControl(player,root)")
+ self.assertPageContains("wireFollowTelemetry(item,followVideo)")
+ self.assertPageContains("api('/api/follow/play'")
+ self.assertPageContains("api('/api/follow/activity'")
def test_follow_detail_save_keeps_the_button_after_the_async_request(self):
self.assertPageContains("const button=event.currentTarget;")
diff --git a/tests/test_migrations.py b/tests/test_migrations.py
index 4fd1a006d..899ef529f 100644
--- a/tests/test_migrations.py
+++ b/tests/test_migrations.py
@@ -24,7 +24,7 @@ class MigrationTests(unittest.TestCase):
backup = self.root / "before.db"
done = upgrade(self.db, MIGRATIONS, backup)
self.assertEqual([m.version for m in done],
- ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021"])
+ ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021", "0022"])
self.assertTrue(backup.exists())
con = sqlite3.connect(self.db)
tables = {row[0] for row in con.execute(
@@ -39,9 +39,9 @@ class MigrationTests(unittest.TestCase):
"entity_external_ref", "asset_entity", "entity_link",
"entity_search_term", "watch_queue", "asset_preference", "asset_quality_goal",
"playlist", "playlist_item",
- "asset_tag_preference", "asset_search",
+ "asset_tag_preference", "asset_search", "follow_playback",
"schema_migration"} <= tables)
- self.assertEqual(versions, ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021"])
+ self.assertEqual(versions, ["0000", "0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", "0009", "0010", "0011", "0012", "0013", "0014", "0015", "0016", "0017", "0018", "0019", "0020", "0021", "0022"])
self.assertEqual(upgrade(self.db, MIGRATIONS), [])
self.assertEqual(plan(self.db, MIGRATIONS)[1], [])
@@ -292,7 +292,7 @@ class MigrationTests(unittest.TestCase):
base_migrations = self.root / "base-migrations"
base_migrations.mkdir()
for path in sorted(MIGRATIONS.glob("*.sql")):
- if not path.name.startswith(("0020_", "0021_")):
+ if not path.name.startswith(("0020_", "0021_", "0022_")):
shutil.copyfile(path, base_migrations / path.name)
sqlite3.connect(self.db).close()
upgrade(self.db, base_migrations)
diff --git a/tests/test_reference_updates.py b/tests/test_reference_updates.py
index 8e5e31146..e09d94952 100644
--- a/tests/test_reference_updates.py
+++ b/tests/test_reference_updates.py
@@ -32,6 +32,7 @@ class ReferenceUpdateTests(unittest.TestCase):
"fiu758-studio-logo-discovery", "rule34-follow-tags-and-collections",
"f95-masked-gofile-media", "follow-fanbox-gofile-paheal",
"fanbox-browser-transport", "beeg-profile-layout",
+ "vercel-geist-table-ranking",
"vercel-geist-fieldset-scroller-empty-state",
"vercel-geist-command-search-loading",
"youtube-player-controls-user-screenshot"},
diff --git a/tests/test_rm_web.py b/tests/test_rm_web.py
index 4cb9afc7a..078227b08 100644
--- a/tests/test_rm_web.py
+++ b/tests/test_rm_web.py
@@ -233,6 +233,27 @@ class WebDataTests(unittest.TestCase):
)
self.assertIs(stats["disk_c"], stats["system_disk"])
+ def test_stats_report_system_resource_and_cloud_volumes(self):
+ usage = type("Usage", (), {"free": 20, "total": 100})
+ declarations = {"local": "R:/media", "115": "B:/", "pikpak": "A:/"}
+ with mock.patch.object(rm_web, "LOCATION_ROOT_DECLARATIONS", declarations), \
+ mock.patch.object(rm_web, "system_volume", return_value=Path("X:/")), \
+ mock.patch.object(rm_web, "translate_ledger_path",
+ side_effect=lambda value: Path(value)), \
+ mock.patch.object(rm_web, "root_online", return_value=True), \
+ mock.patch("shutil.disk_usage", return_value=usage):
+ stats = rm_web.q_stats(self.contract)
+
+ self.assertEqual(
+ [(row["kind"], row["label"]) for row in stats["storage_volumes"]],
+ [("system", "系统盘"), ("local", "资源盘"),
+ ("115", "115 网盘"), ("pikpak", "PikPak 网盘")],
+ )
+ self.assertEqual(stats["storage_summary"], {
+ "volumes": 4, "online": 4, "measured": 4,
+ "free": 80, "used": 320, "total": 400,
+ })
+
def test_items_support_duration_range(self):
result = rm_web.q_items(
self.contract, {"dur_min": "90", "dur_max": "110", "limit": "10"},
@@ -549,6 +570,7 @@ class WebDataTests(unittest.TestCase):
"/api/purge-missing", "/api/review/auto-apply",
"/api/resource-sync/scan", "/api/resource-sync/apply",
"/api/follow/check", "/api/follow/status", "/api/follow/save",
+ "/api/follow/play", "/api/follow/activity",
"/api/follow/source", "/api/follow/resolve", "/api/follow/credential",
"/api/follow/author-alias", "/api/follow/schedule",
"/api/taste/refresh", "/api/taste/source", "/api/settings",
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 0a2e97e15..a2060f394 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -151,7 +151,7 @@ class WebUiSourceTests(unittest.TestCase):
def test_browser_chrome_focus_and_mobile_inputs_follow_the_ui_checklist(self):
self.assertPageContains('<meta name="theme-color" content="#FFFFFF"')
- self.assertPageContains('<meta name="theme-color" content="#020408"')
+ self.assertPageContains('<meta name="theme-color" content="#080A0D"')
# 聚焦环用 color-mix 柔化:边框 72% 主调 + 26% 的外圈,仍是「看得见的焦点」。
self.assertPageContains('.search:focus-within{border-color:color-mix(in srgb,var(--tungsten) 72%,transparent);box-shadow:')
self.assertPageContains('@media (max-width:760px){input,textarea,select{font-size:16px!important}}')
@@ -765,9 +765,9 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("[data-taste-evidence-panel][hidden]")
self.assertPageContains("[data-taste-dimension-panel][hidden]")
self.assertPageContains('data-taste-dimension="${source}:${key}"')
- self.assertPageContains("sourceTabs('browser',[['tags','Tag']")
- self.assertPageContains("sourceTabs('peach',[['tags','Tag'],['creators','创作者'],['performers','女优']])")
- self.assertPageContains("不自动给 Tag 降权")
+ self.assertPageContains("sourceTabs('browser',[['tags','标签']")
+ self.assertPageContains("sourceTabs('peach',[['tags','标签'],['creators','创作者'],['performers','女优']])")
+ self.assertPageContains("不自动给标签降权")
self.assertPageContains("rank.browser_tags||[]")
self.assertPageContains("rank.peach_performers||rank.performers||[]")
self.assertPageContains("visual==='domain'")
@@ -1145,7 +1145,16 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains(".review{--review-fieldset-height:440px;padding:0 0 42px}")
self.assertPageLacks("max-width:1440px")
self.assertPageContains(".insightpage,.tastepage{width:min(1100px,100%);margin:0 auto")
- self.assertPageContains("metricTab('disk','系统盘可用'")
+ self.assertPageContains("metricTab('storage','使用空间'")
+ self.assertPageContains('class="insightdatatable"')
+ self.assertPageContains('<th>位置</th><th>已用</th><th>可用</th><th>使用率</th>')
+ self.assertPageContains('class="insightranking"')
+ self.assertPageContains("grid-template-columns:repeat(2,minmax(0,1fr))")
+ self.assertPageContains("border-top:1px solid var(--line-soft);border-left:1px solid var(--line-soft);list-style:none")
+ self.assertPageContains(".insighttable{border-top:0}")
+ self.assertPageContains(".insight-layout .managebar{margin-left:auto;margin-right:auto}")
+ self.assertPageContains(".insight-layout .managetitle,.insight-layout .pagelede{width:min(1100px,100%)")
+ self.assertPageContains(".tasteprivacy{margin:12px 16px 0")
def test_duplicate_and_trash_descriptions_share_one_page_lede(self):
self.assertPageContains('class="pagelede mono" id="manageLede" hidden')
@@ -1369,9 +1378,9 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("background:transparent;border-bottom:1px solid transparent")
self.assertPageContains(
".tagbar.is-stuck,.count.is-stuck,.entitycollectionhead.is-stuck"
- "{background:color-mix(in srgb,#020408 84%,transparent)"
+ "{background:color-mix(in srgb,#080A0D 84%,transparent)"
)
- self.assertPageContains("background:color-mix(in srgb,#020408 84%,transparent)")
+ self.assertPageContains("background:color-mix(in srgb,#080A0D 84%,transparent)")
self.assertPageContains("backdrop-filter:saturate(1.35) blur(16px)")
self.assertPageContains("function updateStickySurfaces()")
self.assertPageContains("css.position==='sticky'")
@@ -1833,7 +1842,7 @@ class WebUiSourceTests(unittest.TestCase):
".playerstats dd", ".relatedperson .nm", ".reviewentity b",
".reviewitem h4", ".searchoption span",
".sgrid.mixgrid>.mixqueue .mixqueuehead span", ".sidebarorderlabel>b",
- ".insighttablerow span", ".metricstrip small,.tastesummary>small",
+ ".insightrankrow>span:nth-child(2)", ".insighttablerow span", ".metricstrip small,.tastesummary>small",
".tagpickitem .pickname", ".tasterank b,.tasterank small",
".tastesource b,.tastesource small", ".tg",
".tokui .toktitle", "body[data-density=\"dense\"] .card .ctags .tg",
diff --git a/web/app.css b/web/app.css
index 5d8cd638b..9cde42b1b 100644
--- a/web/app.css
+++ b/web/app.css
@@ -1,10 +1,8 @@
/* 色板:灯箱 / 接触印相。底色带棕不是纯黑,中性灰偏暖向主调靠。
钨丝灯琥珀作主调,冷青只给数据,语义色(免费/计费/丢弃)与主调分开。 */
-/* 深色的 ground→surface 曾经是 #020408 → #222222,从 2% 亮度跳到 13%;而浅色是
- #FFFFFF → #F7F8FA,只差 3%。深色那一档本身就是离群值,看着像一块突兀的灰。
- 2026-08-26 按浅色自己的比例校回:深色表面改成 #0C0F14,抽屉的 frost 同样压到近黑,
- 与导航栏、左侧栏(都用 --ground)连成一片。这也和实测的 Vercel 相符——
- 页面纯黑、卡片 rgb(10,10,10),只抬一档。 */
+/* 深色只保留轻微层级,不让输入框、关注管理和数据详情陷进近乎纯黑的第三档。
+ 2026-08-30 按实际画面回执,把 ground 从 #020408 抬到 #080A0D;所有使用
+ token 的页面、侧栏、输入与选中面同步生效。 */
:root{
--ground:#FFFFFF; --surface:#F7F8FA; --sunk:#ECEEF2; --hover:#EEF1F5;
--line:#D9DDE4; --line-soft:#E8EBF0;
@@ -31,7 +29,7 @@
--sb:#3A3A40; --sb-hover:#55555E; /* 336 = 168×2,与目标站的模块单位一致 */
}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
- --ground:#020408; --surface:#0C0F14; --sunk:#0B0D11; --hover:rgba(255,255,255,.07);
+ --ground:#080A0D; --surface:#0C0F14; --sunk:#0B0D11; --hover:rgba(255,255,255,.07);
--line:#3A3A3D; --line-soft:#2C2C30;
--ink:#FFFFFF; --ink-2:#C9CDD4; --muted:#9AA0A8;
--tungsten:#0095F6; --tungsten-soft:#0A2B45;
@@ -39,7 +37,7 @@
--overlay-5:rgba(245,250,255,.05);--border-10:rgba(245,250,255,.10);--border-15:rgba(245,250,255,.15);
--loupe:#6FD0C8; --keep:#5FB95F; --meter:#E0912F; --drop:#FF5252; --success:#5FB95F; --ambient-opacity:1;}}
:root[data-theme="dark"]{
- --ground:#020408; --surface:#0C0F14; --sunk:#0B0D11; --hover:rgba(255,255,255,.07);
+ --ground:#080A0D; --surface:#0C0F14; --sunk:#0B0D11; --hover:rgba(255,255,255,.07);
--line:#3A3A3D; --line-soft:#2C2C30;
--ink:#FFFFFF; --ink-2:#C9CDD4; --muted:#9AA0A8;
--tungsten:#0095F6; --tungsten-soft:#0A2B45;
@@ -253,7 +251,9 @@ button,a,input,textarea,select,summary{touch-action:manipulation}
.insightbarrow,.tastebar{padding:8px 0 12px;border-bottom:1px solid var(--line-soft)}.insightbarrow:last-child,.tastebar:last-child{border-bottom:0}.insightbarrow>div:first-child,.tastebar>div:first-child{display:flex;justify-content:space-between;gap:12px;font-size:var(--fs-sm)}.insightbarrow small{display:block;margin-top:5px;color:var(--muted);font-size:var(--fs-xs)}
.insightpanel{overflow:hidden;border:1px solid var(--line-soft);border-radius:12px;background:var(--surface)}.insightpanel>header{min-height:52px;display:flex;align-items:center;padding:0 16px;border-bottom:1px solid var(--line-soft)}.insightpanel>header h3{margin:0;font-size:var(--fs-md)}.insightpanel>header p{margin:2px 0 0;color:var(--muted);font-size:var(--fs-xs)}.insightpanelbody{min-width:0;padding:14px 16px 16px}
.insighttabs{min-width:0;display:flex;align-self:stretch;align-items:stretch;gap:24px;overflow-x:auto;overscroll-behavior-x:contain}.insighttabs button{position:relative;flex:none;border:0;background:transparent;color:var(--muted);font:inherit;font-size:var(--fs-sm);cursor:pointer}.insighttabs button:hover,.insighttabs button[aria-selected="true"]{color:var(--ink)}.insighttabs button[aria-selected="true"]:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--ink)}
-.insighttable{border-top:1px solid var(--line-soft)}.insighttablehead,.insighttablerow{box-sizing:border-box;min-height:42px;display:grid;grid-template-columns:minmax(0,1fr) minmax(140px,auto);align-items:center;gap:16px;padding:8px 12px;border:0;border-bottom:1px solid var(--line-soft);background:transparent;color:var(--ink);font-size:var(--fs-sm)}.insighttablehead{min-height:34px;color:var(--muted);font-size:var(--fs-xs)}.insighttablehead span:last-child,.insighttablerow b{text-align:right}.insighttablerow:is(button){width:100%;cursor:pointer}.insighttablerow:is(button):hover{background:var(--overlay-5)}.insighttablerow span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.insighttablerow b{font-weight:500;color:var(--ink-2)}.insightempty{padding:16px}
+.insighttable{border-top:0}.insighttablehead,.insighttablerow{box-sizing:border-box;min-height:42px;display:grid;grid-template-columns:minmax(0,1fr) minmax(140px,auto);align-items:center;gap:16px;padding:8px 12px;border:0;border-bottom:1px solid var(--line-soft);background:transparent;color:var(--ink);font-size:var(--fs-sm)}.insighttablehead{min-height:34px;color:var(--muted);font-size:var(--fs-xs)}.insighttablehead span:last-child,.insighttablerow b{text-align:right}.insighttablerow:is(button){width:100%;cursor:pointer}.insighttablerow:is(button):hover{background:var(--overlay-5)}.insighttablerow span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.insighttablerow b{font-weight:500;color:var(--ink-2)}.insightempty{padding:16px}
+.insightranking{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));margin:0;padding:0;border-top:1px solid var(--line-soft);border-left:1px solid var(--line-soft);list-style:none}.insightranking>li{min-width:0}.insightrankrow{width:100%;min-width:0;min-height:44px;display:grid;grid-template-columns:30px minmax(0,1fr) auto;align-items:center;gap:9px;padding:8px 12px;border:0;border-right:1px solid var(--line-soft);border-bottom:1px solid var(--line-soft);background:transparent;color:var(--ink);text-align:left;cursor:pointer}.insightrankrow:hover{background:var(--overlay-5)}.insightrankrow>span:nth-child(2){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.insightrankrow b{color:var(--ink-2);font-weight:500;font-variant-numeric:tabular-nums}.insightrankpos{color:var(--muted);font-size:var(--fs-xs);font-variant-numeric:tabular-nums}
+.insightstorage{align-self:stretch;overflow-x:auto;overscroll-behavior-x:contain}.insightdatatable{width:100%;min-width:520px;border-collapse:collapse;font-size:var(--fs-sm)}.insightdatatable th,.insightdatatable td{height:52px;padding:8px 12px;border-bottom:1px solid var(--line-soft);text-align:right;font-weight:400;white-space:nowrap}.insightdatatable thead th{height:36px;color:var(--muted);font-size:var(--fs-xs)}.insightdatatable th:first-child{text-align:left}.insightdatatable tbody th{font-weight:600}.insightdatatable tbody th span,.insightdatatable tbody th small{display:block}.insightdatatable tbody th small{margin-top:2px;color:var(--muted);font-size:var(--fs-xs);font-weight:400}.insightdatatable tbody tr:last-child>*{border-bottom:0}
.kv{display:flex;justify-content:space-between;align-items:baseline;padding:6px 0;font-size:var(--fs-sm)}
.kv>span:first-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-right:10px}
.kv b{font-variant-numeric:tabular-nums;font-weight:600;min-width:0;max-width:62%;text-align:right;overflow-wrap:anywhere}
@@ -261,9 +261,11 @@ button,a,input,textarea,select,summary{touch-action:manipulation}
.statmetric{padding:3px 0 12px;border-bottom:1px solid var(--line-soft)}.statmetric:last-child{padding-bottom:0;border-bottom:0}.geist-progress{height:8px;margin-top:7px;overflow:hidden;border-radius:var(--pill-radius);background:var(--line-soft)}.geist-progress i{display:block;width:var(--progress-value);height:100%;border-radius:inherit;background:var(--tungsten)}
.tastecovermetric{display:grid;gap:7px;padding:14px 0}.tastecovermetric+.tastecovermetric{border-top:1px solid var(--line-soft)}.tastecovermetric>span,.tastecovermetric>small{color:var(--muted);font-size:var(--fs-xs)}.tastecovermetric>b{font-size:var(--fs-2xl);font-variant-numeric:tabular-nums}
.tastehero{margin-bottom:16px}.tasteanalysis{margin-bottom:16px}.tasteranks{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-top:1px solid var(--line-soft);border-left:1px solid var(--line-soft)}.tasteranks-tags{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;border:0}.tasterank{width:100%;min-width:0;min-height:58px;box-sizing:border-box;display:grid;grid-template-columns:32px minmax(0,1fr) 18px;align-items:center;gap:10px;padding:9px 12px;border:0;border-right:1px solid var(--line-soft);border-bottom:1px solid var(--line-soft);border-radius:0;background:transparent;color:var(--ink);text-align:left}.tasterank-tag{min-height:54px;padding:8px 10px;border:1px solid var(--line-soft);border-radius:var(--control-radius);background:var(--overlay-5)}.tasterank-visual{grid-template-columns:32px 30px minmax(0,1fr) 18px}.tasterank:is(button){cursor:pointer}.tasterank:is(button):hover{background:var(--overlay-5)}.tasterank:is(button):focus-visible{position:relative;z-index:1;outline:2px solid var(--tungsten);outline-offset:-2px}.tasterank-tag:is(button):hover{border-color:var(--border-15);background:var(--hover)}.tasterank>span:nth-last-child(2){min-width:0}.tasterank b,.tasterank small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tasterank small{margin-top:2px;color:var(--muted);font-size:var(--fs-xs);font-weight:400}.tasterank>svg{justify-self:end;width:16px;height:16px;stroke:currentColor;fill:none}.tastepos{width:100%;text-align:center;color:var(--muted);font-size:var(--fs-xs);font-variant-numeric:tabular-nums}.tasteavatar{position:relative;width:30px;height:30px;overflow:hidden;border-radius:50%;background:var(--overlay-5);display:grid;place-items:center;color:var(--muted);font-size:var(--fs-xs);font-weight:650}.tasteavatar .ini{position:absolute;inset:0;display:grid;place-items:center}.tasteavatar img{position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:cover}.tasteavatar.tastesite{border-radius:8px}.tasteavatar.tastesite img{inset:5px;width:20px;height:20px;object-fit:contain}.tastenegative{margin:-4px 2px 16px;color:var(--muted);font-size:var(--fs-xs)}
-.tastesources{margin-top:16px}.tastesources .insightpanelbody>div{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-top:1px solid var(--line-soft);border-left:1px solid var(--line-soft)}.tastesource{display:grid;grid-template-columns:34px minmax(0,1fr) 34px;align-items:center;gap:10px;padding:10px 12px;border-right:1px solid var(--line-soft);border-bottom:1px solid var(--line-soft)}.tastebrowser{width:32px;height:32px;border-radius:9px;background:var(--overlay-5);display:grid;place-items:center;color:var(--tungsten)}.tastebrowser svg,.tastesource>button svg{width:17px;height:17px;stroke:currentColor;fill:none}.tastesource b,.tastesource small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tastesource small{color:var(--muted);font-size:var(--fs-xs);margin-top:2px}.tastesource>button{width:32px;height:32px;border:0;border-radius:var(--control-radius);background:transparent;color:var(--muted);display:grid;place-items:center;cursor:pointer}.tastesource>button:hover{background:var(--hover);color:var(--drop)}.tasteprivacy{margin:12px 2px 0;color:var(--muted);font-size:var(--fs-xs)}
+.tastesources{margin-top:16px}.tastesources .insightpanelbody>div{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-top:1px solid var(--line-soft);border-left:1px solid var(--line-soft)}.tastesource{display:grid;grid-template-columns:34px minmax(0,1fr) 34px;align-items:center;gap:10px;padding:10px 12px;border-right:1px solid var(--line-soft);border-bottom:1px solid var(--line-soft)}.tastebrowser{width:32px;height:32px;border-radius:9px;background:var(--overlay-5);display:grid;place-items:center;color:var(--tungsten)}.tastebrowser svg,.tastesource>button svg{width:17px;height:17px;stroke:currentColor;fill:none}.tastesource b,.tastesource small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tastesource small{color:var(--muted);font-size:var(--fs-xs);margin-top:2px}.tastesource>button{width:32px;height:32px;border:0;border-radius:var(--control-radius);background:transparent;color:var(--muted);display:grid;place-items:center;cursor:pointer}.tastesource>button:hover{background:var(--hover);color:var(--drop)}.tasteprivacy{margin:12px 16px 0;color:var(--muted);font-size:var(--fs-xs)}
+.tastenegative{margin-inline:16px}
@media(max-width:900px){.insightdetailbody,.tastehero{grid-template-columns:minmax(220px,40%) minmax(0,1fr)}.tasteranks{grid-template-columns:repeat(2,minmax(0,1fr))}.tasteranks-tags{grid-template-columns:repeat(3,minmax(0,1fr))}.tastesources .insightpanelbody>div{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:640px){.insighttoolbar,.tastehead{align-items:stretch}.tasteactions{display:grid;grid-template-columns:1fr 1fr;width:100%;margin-left:0}.tasteactions select{grid-column:1/-1}.tasteactions button{justify-content:center}.insightswitch{align-self:flex-start}.metricstrip,.tastesummaries{grid-auto-columns:minmax(168px,82%)}.insightdetailbody,.tastehero{min-height:0;grid-template-columns:minmax(0,1fr)}.insightcopy{border-right:0;border-bottom:1px solid var(--line-soft);padding:22px 18px}.insightcopy h2{font-size:var(--fs-3xl)}.insightcopy p{max-width:none;margin-top:18px}.insightvisual,.insightfacts,.tastebars{padding:18px}.insightpanel>header{padding:0 14px}.insightpanelbody{padding:12px}.insighttablehead,.insighttablerow{grid-template-columns:minmax(0,1fr);gap:3px}.insighttablehead span:last-child{display:none}.insighttablerow b{text-align:left;font-size:var(--fs-xs)}.tasteranks,.tasteranks-tags,.tastesources .insightpanelbody>div{grid-template-columns:minmax(0,1fr)}.tastesummary>b{font-size:var(--fs-xl)}.tastesource{grid-template-columns:32px minmax(0,1fr) 32px}}
+@media(max-width:640px){.insightranking{grid-template-columns:minmax(0,1fr)}.insightstorage{padding:0}}
/* 索引页:全部创作者 / 全部标签 */
.index{padding:4px 0 20px;min-width:0;max-width:100%;overflow-x:clip}
.index .ihead{display:flex;align-items:center;gap:12px;margin-bottom:14px}
@@ -624,6 +626,8 @@ main{position:relative;z-index:1;padding:14px 16px 90px}
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}
+.insight-layout .managebar{margin-left:auto;margin-right:auto}
+.insight-layout .managetitle,.insight-layout .pagelede{width:min(1100px,100%);margin-left:auto;margin-right:auto}
.count{position:sticky;top:calc(var(--topH) + var(--filterH));z-index:60;
min-height:var(--sortH);color:var(--ink-2);margin:0 -16px 16px;padding:8px 16px;
display:flex;align-items:center;gap:10px;flex-wrap:nowrap;
@@ -637,7 +641,7 @@ main{position:relative;z-index:1;padding:14px 16px 90px}
.resourcesync{scroll-margin-top:calc(var(--topH) + 18px);display:grid;gap:16px}.resourcesync>h2{margin:0;font-size:var(--fs-xl)}
.resourcesyncbox,.resourcepanel{overflow:clip;border:1px solid var(--line-soft);border-radius:12px;background:var(--surface)}.resourcesyncbody{padding:24px}.resourcesyncbody h3{margin:0 0 8px;font-size:var(--fs-lg)}.resourcesyncbody p{max-width:760px;margin:0;color:var(--muted);font-size:var(--fs-sm);line-height:1.55}.resourcesyncfooter,.resourceapplyrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 16px;border-top:1px solid var(--line-soft);background:var(--overlay-5)}.resourcesyncfooter p,.resourceapplyrow>p{margin:0;color:var(--muted);font-size:var(--fs-xs);line-height:1.5}.resourceaction{box-sizing:border-box;height:36px;padding:0 12px;border:1px solid var(--border-15);border-radius:var(--control-radius);background:var(--surface);color:var(--ink-2);display:inline-flex;align-items:center;justify-content:center;gap:8px;flex:none;font:inherit;font-size:var(--fs-sm);font-weight:550;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s}.resourceaction:hover:not(:disabled){background:var(--hover);border-color:color-mix(in srgb,var(--ink) 28%,transparent);color:var(--ink)}.resourceaction:focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}.resourceaction:disabled{cursor:default;opacity:.68}.resourceaction svg{width:16px;height:16px;stroke:currentColor;fill:none}#resourceSyncResult:empty{display:none}.resourcescanning,.resourceerror{margin:0;padding:14px 16px;border:1px solid var(--line-soft);border-radius:var(--control-radius);color:var(--muted)}.resourceerror{color:var(--drop)}.resourcesources{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}.resourcesources article{display:grid;gap:4px;min-width:0;padding:16px}.resourcesources article+article{border-left:1px solid var(--line-soft)}.resourcesourcetitle{display:flex;align-items:center;justify-content:space-between;gap:12px}.resourcesourcetitle span{font-size:var(--fs-xs)}.resourcesources .online{color:var(--success)}.resourcesources .offline{color:var(--drop)}.resourcesources strong{margin-top:10px;font-size:var(--fs-2xl);font-variant-numeric:tabular-nums}.resourcesources small,.resourcecache small{color:var(--muted)}.resourcecache{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border-top:1px solid var(--line-soft);background:var(--overlay-5)}.resourcecache>div{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:baseline;gap:4px 16px;padding:16px}.resourcecache>div+div{border-left:1px solid var(--line-soft)}.resourcecache b{font-size:var(--fs-2xl);font-variant-numeric:tabular-nums}.resourcecache span{font-weight:650}.resourcecache small{grid-column:1/-1}.resourceapplyrow .resourcesyncok{color:var(--success)}.resourcedanger{color:var(--drop)}.resourcedanger:hover:not(:disabled){border-color:color-mix(in srgb,var(--drop) 42%,transparent);background:color-mix(in srgb,var(--drop) 8%,transparent);color:var(--drop)}.resourcesyncok{margin:0;color:var(--success)}
.tagbar,.count,.entitycollectionhead{transition:background-color .16s ease,border-color .16s ease}
-.tagbar.is-stuck,.count.is-stuck,.entitycollectionhead.is-stuck{background:color-mix(in srgb,#020408 84%,transparent);
+.tagbar.is-stuck,.count.is-stuck,.entitycollectionhead.is-stuck{background:color-mix(in srgb,#080A0D 84%,transparent);
border-bottom-color:var(--line-soft);backdrop-filter:saturate(1.35) blur(16px);
-webkit-backdrop-filter:saturate(1.35) blur(16px)}
.count:empty{display:none}
@@ -802,7 +806,7 @@ body[data-density="dense"] .junkcard .junkactions button span{display:none}
/* 线条类来源图标(本地盘 / 在线)没有品牌底色,亮封面上会看不见:
垫一层深色方角底(--badge-radius,与圆形实体头像划清界限)。
115 / PikPak 的官方位图 logo 自带完整底色,保持裸图不再叠底。 */
-.src:has(svg){width:auto;height:auto;padding:3px;border-radius:var(--badge-radius);background:color-mix(in srgb,#020408 62%,transparent)}
+.src:has(svg){width:auto;height:auto;padding:3px;border-radius:var(--badge-radius);background:color-mix(in srgb,#080A0D 62%,transparent)}
.src.free{color:#CFE8CF}.src.metered{color:#FFD9AE}
.src svg{stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
/* 详情面板里的来源 */
diff --git a/web/app.js b/web/app.js
index 3605ba8cd..acad5e29d 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1368,27 +1368,30 @@ async function openStats(push=true,focusResource=false){
const totalVideos=d.by_loc.reduce((sum,row)=>sum+row.videos,0);
const totalBytes=d.by_loc.reduce((sum,row)=>sum+row.bytes,0);
const coverage=pct(d.tag_cov,a.videos);
- const disk=d.system_disk, diskPct=disk?pct(disk.free,disk.total):0;
+ const storage=d.storage_summary||{volumes:0,online:0,measured:0,free:0,used:0,total:0};
const kv=(k,v,u)=>`<div class="kv"><span>${k}</span><b>${v}${u?`<span class="u">${u}</span>`:''}</b></div>`;
const metric=(k,v,max)=>`<div class="statmetric">${kv(k,v.toLocaleString(),pct(v,max)+'%')}${progressHtml(`${k}:${v.toLocaleString()} / ${max.toLocaleString()}`,v,max)}</div>`;
const metricTab=(key,label,value,detail,selected=false)=>`<button type="button" role="tab" data-stats-metric="${key}"
aria-selected="${selected}" aria-controls="stats-detail-${key}" tabindex="${selected?'0':'-1'}">
<span>${label}</span><b>${value}</b><small>${detail}</small></button>`;
- const locationRows=d.by_loc.map(row=>`<div class="insightbarrow"><div><span>${LOC[row.k]||row.k}</span><b>${row.videos.toLocaleString()}</b></div>
- ${progressHtml(`${LOC[row.k]||row.k}:${row.videos.toLocaleString()} / ${totalVideos.toLocaleString()}`,row.videos,totalVideos)}
- <small>${gb(row.bytes)} · ${pct(row.videos,totalVideos)}%</small></div>`).join('');
+ const locationRows=d.by_loc.map(row=>{const label=row.k==='online'?'已保存在线':(LOC[row.k]||row.k);return `<div class="insightbarrow"><div><span>${label}</span><b>${row.videos.toLocaleString()}</b></div>
+ ${progressHtml(`${label}:${row.videos.toLocaleString()} / ${totalVideos.toLocaleString()}`,row.videos,totalVideos)}
+ <small>${gb(row.bytes)} · ${pct(row.videos,totalVideos)}%</small></div>`}).join('');
const table=(head,rows)=>`<div class="insighttable"><div class="insighttablehead">${head.map(value=>`<span>${value}</span>`).join('')}</div>${rows}</div>`;
- const tagsTable=table(['内容标签','视频'],d.top_tags.map(t=>`<button type="button" class="insighttablerow" data-k="${esc(t.k)}">
- <span>${esc(tagLabel(t.k))}</span><b>${t.n.toLocaleString()}</b></button>`).join(''));
+ const tagsTable=`<ol class="insightranking">${d.top_tags.map((t,index)=>`<li><button type="button" class="insightrankrow" data-k="${esc(t.k)}">
+ <span class="insightrankpos">${index+1}</span><span>${esc(tagLabel(t.k))}</span><b>${t.n.toLocaleString()}</b></button></li>`).join('')}</ol>`;
const recentTable=table(['作品','观看证据'],d.recent.length?d.recent.map(row=>{
const real=row.duration?Math.min(row.play_seconds/row.duration,1)*100:0;
const reached=(row.max_reached||0)*100;
- const note=real<reached-25?'快进扫过':(row.o_count?`高潮 ${row.o_count}`:'正常观看');
+ const note=row.kind==='online'?'在线直接观看':(real<reached-25?'快进扫过':(row.o_count?`高潮 ${row.o_count}`:'正常观看'));
return `<div class="insighttablerow"><span>${esc((row.creator?row.creator+' · ':'')+row.name)}</span>
<b>真实 ${real.toFixed(0)}% · 到达 ${reached.toFixed(0)}% · ${note}</b></div>`}).join(''):
`<div class="insightempty">${emptyStateHtml('history','还没有观看记录','开始播放后,这里会显示最近的真实观看证据。')}</div>`);
const sourceTable=table(['标签来源','覆盖视频'],d.tag_source.map(row=>`<div class="insighttablerow"><span>${esc(row.k)}</span>
<b>${row.n.toLocaleString()} 条 · ${row.assets.toLocaleString()} 个视频</b></div>`).join(''));
+ const storageTable=`<table class="insightdatatable"><thead><tr><th>位置</th><th>已用</th><th>可用</th><th>使用率</th></tr></thead><tbody>${(d.storage_volumes||[]).map(row=>{
+ const measured=row.total!=null, usedPct=measured?pct(row.used,row.total):0;
+ return `<tr><th scope="row"><span>${esc(row.label)}</span><small>${row.root?esc(row.root):'未映射'}</small></th><td>${measured?gb(row.used):'—'}</td><td>${measured?gb(row.free):'—'}</td><td>${measured?usedPct+'%':(row.online?'容量未取得':'离线')}</td></tr>`}).join('')}</tbody></table>`;
$('#stats').innerHTML=`
<div class="insightpage statsdashboard" data-stats-dashboard>
<header class="insighttoolbar"><p>账本当前快照 · ${totalVideos.toLocaleString()} 个视频 · ${gb(totalBytes)}</p></header>
@@ -1396,7 +1399,7 @@ async function openStats(push=true,focusResource=false){
${metricTab('inventory','馆藏视频',totalVideos.toLocaleString(),gb(totalBytes),true)}
${metricTab('viewing','看过',cs.played.toLocaleString(),hrs(cs.play_seconds))}
${metricTab('coverage','内容标签',coverage+'%',`${d.tag_cov.toLocaleString()} / ${a.videos.toLocaleString()}`)}
- ${metricTab('disk','系统盘可用',disk?gb(disk.free):'—',disk?diskPct+'%':'未取得')}
+ ${metricTab('storage','使用空间',`${storage.online} 个卷`,storage.measured?`已用 ${gb(storage.used)}`:'容量未取得')}
</div>
<section class="insightdetail">
<div id="stats-detail-inventory" role="tabpanel" data-stats-detail="inventory" class="insightdetailbody">
@@ -1405,19 +1408,19 @@ async function openStats(push=true,focusResource=false){
<div class="insightvisual">${locationRows}</div></div>
<div id="stats-detail-viewing" role="tabpanel" data-stats-detail="viewing" class="insightdetailbody" hidden>
<div class="insightcopy"><span>观看</span><h2>${cs.played.toLocaleString()}</h2><b>个作品有播放记录</b>
- <p>累计 ${hrs(cs.play_seconds)};真实观看时长与最远到达位置分开统计。</p></div>
- <div class="insightfacts">${kv('高潮计数',cs.o_total.toLocaleString())}${kv('快进扫过',cs.skimmed.toLocaleString())}
+ <p>累计 ${hrs(cs.play_seconds)};馆藏播放与关注页直接在线播放都计入,不要求先保存。</p></div>
+ <div class="insightfacts">${kv('馆藏观看',cs.library_played.toLocaleString())}${kv('在线直接观看',cs.online_played.toLocaleString())}
+ ${kv('高潮计数',cs.o_total.toLocaleString())}${kv('快进扫过',cs.skimmed.toLocaleString())}
${kv('明确不喜欢',cs.dislike.toLocaleString())}${kv('看过了',cs.seen.toLocaleString())}${kv('回收站',cs.trash.toLocaleString())}</div></div>
<div id="stats-detail-coverage" role="tabpanel" data-stats-detail="coverage" class="insightdetailbody" hidden>
<div class="insightcopy"><span>内容标签覆盖</span><h2>${coverage}%</h2><b>${d.tag_cov.toLocaleString()} / ${a.videos.toLocaleString()}</b>
<p>归属与加工分别保留真实分母,不用装饰性进度替代缺失数据。</p></div>
<div class="insightvisual">${metric('有创作者',a.creator,a.videos)}${metric('有番号',a.code,a.videos)}
${metric('有厂牌',a.studio,a.videos)}${metric('已抽帧',a.thumb,a.videos)}${metric('已探测时长',a.duration,a.videos)}</div></div>
- <div id="stats-detail-disk" role="tabpanel" data-stats-detail="disk" class="insightdetailbody" hidden>
- <div class="insightcopy"><span>系统盘</span><h2>${disk?gb(disk.free):'—'}</h2><b>${disk?`共 ${gb(disk.total)}`:'容量未取得'}</b>
- <p>CloudDrive 块缓存位于系统盘;低于 40 GB 时抽帧任务会拒绝启动。</p></div>
- <div class="insightvisual">${disk?progressHtml(`系统盘可用:${gb(disk.free)} / ${gb(disk.total)}`,disk.free,disk.total):
- noteHtml('系统盘容量未取得。',{variant:'warning',label:'容量未取得'})}</div></div>
+ <div id="stats-detail-storage" role="tabpanel" data-stats-detail="storage" class="insightdetailbody" hidden>
+ <div class="insightcopy"><span>使用空间</span><h2>${storage.measured}</h2><b>个卷已取得容量</b>
+ <p>同时统计系统盘、资源盘、115 与 PikPak;离线或未映射的来源明确保留,不伪造为 0。</p></div>
+ <div class="insightvisual insightstorage">${storageTable}</div></div>
</section>
<section class="insightpanel">
<header><div class="insighttabs" role="tablist" aria-label="统计维度">
@@ -1625,7 +1628,7 @@ function renderTaste(d){
${coverageMetric('有身份',Number(coverage.identified||0).toLocaleString(),`${coverage.unidentified||0} 项待补`,coverage.identified||0,(coverage.identified||0)+(coverage.unidentified||0))}
</div></section>
<section class="insightpanel tasteanalysis" data-taste-evidence-panel="browser"${tasteEvidence==='browser'?'':' hidden'}>
- <header>${sourceTabs('browser',[['tags','Tag'],['creators','创作者'],['domains','常访问网站'],['gaps','浏览候选']])}</header>
+ <header>${sourceTabs('browser',[['tags','标签'],['creators','创作者'],['domains','常访问网站'],['gaps','浏览候选']])}</header>
<div class="insightpanelbody">
${rankPanel('browser','tags',rank.browser_tags||[],'tag')}
${rankPanel('browser','creators',rank.browser_creators||[],'creator','暂无创作者证据','creator')}
@@ -1633,13 +1636,13 @@ function renderTaste(d){
${rankPanel('browser','gaps',gapRows,'','这些词在浏览记录中出现,但 Peach 观看记录还没有对应证据')}
</div></section>
<section class="insightpanel tasteanalysis" data-taste-evidence-panel="peach"${tasteEvidence==='peach'?'':' hidden'}>
- <header>${sourceTabs('peach',[['tags','Tag'],['creators','创作者'],['performers','女优']])}</header>
+ <header>${sourceTabs('peach',[['tags','标签'],['creators','创作者'],['performers','女优']])}</header>
<div class="insightpanelbody">
${rankPanel('peach','tags',rank.peach_tags||[],'tag')}
${rankPanel('peach','creators',rank.peach_creators||[],'creator','暂无创作者证据','creator')}
${rankPanel('peach','performers',rank.peach_performers||rank.performers||[],'performer','暂无女优证据','performer')}
</div></section>
- <p class="tastenegative" data-taste-evidence-panel="peach"${tasteEvidence==='peach'?'':' hidden'}>“不合口味”只记录到具体项目与理由,不自动给 Tag 降权。</p>
+ <p class="tastenegative" data-taste-evidence-panel="peach"${tasteEvidence==='peach'?'':' hidden'}>“不合口味”只记录到具体项目与理由,不自动给标签降权。</p>
<section class="insightpanel tastesources"><header><div><h3>数据源</h3><p>支持 macOS / Windows 的 Zen、Safari、Firefox、Chrome;这里列出已经采集的设备。</p></div></header>
<div class="insightpanelbody"><div>${sourceRows||emptyStateHtml('database','还没有数据源','导入或读取浏览记录后,这里会列出已采集设备。')}</div></div></section>
<p class="tasteprivacy">原始 URL、标题与搜索内容不会显示在页面,也不会写入 ledger;所有画像均为候选。</p>
@@ -2323,10 +2326,16 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals
switchImage(imageMedia[next].index);
});
const followVideo=$('#stage').querySelector('.followdetailmedia>video');
- if(followVideo){const followPlayer=mountDetailPlayer(item,followVideo,false,{
- source:{src,type:selectedMedia?.media_type||item.media_type||'video/mp4'},
- checkSourceStatus:false
- });const stopFollowAmbient=mountPlayerAmbient(followVideo);followPlayer?.one?.('dispose',stopFollowAmbient);followVideo.addEventListener('emptied',stopFollowAmbient,{once:true})}
+ if(followVideo){
+ const followPlayer=mountDetailPlayer(item,followVideo,false,{
+ source:{src,type:selectedMedia?.media_type||item.media_type||'video/mp4'},
+ checkSourceStatus:false
+ });
+ const stopFollowAmbient=mountPlayerAmbient(followVideo);
+ followPlayer?.one?.('dispose',stopFollowAmbient);
+ followVideo.addEventListener('emptied',stopFollowAmbient,{once:true});
+ wireFollowTelemetry(item,followVideo);
+ }
wireDrag($('#stage').querySelector('.mixlist'));
$('#stage').querySelectorAll('.followdetailtags [data-follow-tag]').forEach(button=>button.onclick=async()=>{
const tag=button.dataset.followTag;
@@ -4178,6 +4187,7 @@ function buildManageBar(){
function paintManageTitle(){
const current=manageSection(),el=$('#manageTitle');
if(!el)return;
+ document.body.classList.toggle('insight-layout',current==='stats'||current==='taste');
const entry=MANAGE_SECTIONS.find(([k])=>k===current);
el.hidden=!entry;
if(entry)el.textContent=entry[1];
@@ -4920,6 +4930,29 @@ function wireTelemetry(it,v,sel){
paint();
}
+function wireFollowTelemetry(item,video){
+ let last=0,acc=0,timer=null,started=false;
+ const flush=ended=>{const duration=Number(item.duration)||video.duration||0;
+ if(!acc&&!ended)return;
+ api('/api/follow/activity',{method:'POST',body:JSON.stringify({
+ item:item.id,position:video.currentTime,duration,delta:acc,ended:!!ended
+ })}).catch(()=>{});
+ acc=0;
+ };
+ video.addEventListener('play',()=>{
+ if(!started){started=true;api('/api/follow/play',{method:'POST',body:JSON.stringify({item:item.id})})
+ .then(result=>{item.status=result.status||item.status}).catch(()=>{})}
+ last=video.currentTime;
+ if(timer)clearInterval(timer);timer=setInterval(()=>flush(false),10000);
+ });
+ video.addEventListener('timeupdate',()=>{
+ const delta=video.currentTime-last;if(delta>0&&delta<2)acc+=delta;last=video.currentTime;
+ });
+ video.addEventListener('pause',()=>{if(timer)clearInterval(timer);timer=null;flush(false)});
+ video.addEventListener('ended',()=>{if(timer)clearInterval(timer);timer=null;flush(true)});
+ video.addEventListener('emptied',()=>{if(timer)clearInterval(timer);timer=null;flush(false)},{once:true});
+}
+
/* ── 短片全屏 ── */
let tokList=[],tokIdx=0,tokSwitching=false,tokNetTimer=null,tokLoadHideTimer=null,tokLoadingLabel='加载中…';
function tokStreamUrl(video,id){
diff --git a/web/index.html b/web/index.html
index 0e06654c9..82ef7f3fe 100644
--- a/web/index.html
+++ b/web/index.html
@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#FFFFFF" media="(prefers-color-scheme: light)">
-<meta name="theme-color" content="#020408" media="(prefers-color-scheme: dark)">
+<meta name="theme-color" content="#080A0D" media="(prefers-color-scheme: dark)">
<link rel="icon" href="/peach-logo.png" type="image/png">
<link rel="stylesheet" href="/vendor/videojs/8.24.0/video-js.min.css">
<title>Peach · 蜜桃</title>