Files
shijian/docs/ui-preview.html
T

851 lines
39 KiB
HTML
Raw Normal View History

2026-11-26 10:08:04 +08:00
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light">
<link rel="icon" href="../app/src/main/res/drawable-nodpi/launcher_artwork.jpg" type="image/jpeg">
2026-11-26 10:08:04 +08:00
<title>拾见 · 界面预览</title>
<style>
:root {
--ink: #25354e;
--muted: #50627c;
--screen: #edf5ff;
--paper: #fff;
--line: #ccddf5;
--blue: #31588f;
--blue-tint: #e7f0ff;
--coral: #b64154;
--coral-pressed: #9d354b;
--coral-tint: #ffe8ec;
--green: #267252;
--grass-tint: #e9f7eb;
--launcher-art: url('../app/src/main/res/drawable-nodpi/launcher_artwork.jpg');
2026-11-26 10:08:04 +08:00
font: 16px/1.55 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
color: var(--ink);
background: #f4f8ff;
2026-11-26 10:08:04 +08:00
}
* { box-sizing: border-box; }
body {
margin: 0;
background: radial-gradient(ellipse at 9% 0%, #e3eeff 0, transparent 480px),
radial-gradient(ellipse at 90% 0%, #ffedf1 0, transparent 430px);
}
2026-11-26 10:08:04 +08:00
a { color: inherit; }
a:focus-visible, [tabindex]:focus-visible {
outline: 2px solid var(--blue);
2026-11-26 10:08:04 +08:00
outline-offset: 3px;
}
.preview {
max-width: 1312px;
margin-inline: auto;
padding: 42px clamp(20px, 4vw, 56px) 48px;
}
.preview-header {
display: flex;
align-items: center;
gap: 16px;
margin-bottom: 32px;
}
.mark {
display: block;
2026-11-26 10:08:04 +08:00
flex: 0 0 52px;
width: 52px;
2026-11-26 10:08:04 +08:00
height: 52px;
border-radius: 14px;
object-fit: cover;
box-shadow: 0 2px 0 #b8cee8, 0 6px 14px #31588f1c;
2026-11-26 10:08:04 +08:00
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(26px, 4vw, 38px); font-weight: 740; line-height: 1.15; }
.preview-header p { margin-top: 7px; color: var(--muted); font-size: 14px; }
.screen-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: clamp(16px, 2.15vw, 30px);
align-items: start;
}
.screen-figure {
display: grid;
gap: 9px;
margin: 0;
min-width: 0;
scroll-margin-top: 18px;
}
.screen-figure figcaption { padding-inline: 8px; color: var(--blue); font-size: 15px; font-weight: 700; }
.screen-figure:target .phone { border-color: #96b4e0; }
2026-11-26 10:08:04 +08:00
.phone {
display: grid;
grid-template-rows: auto minmax(0, 1fr) auto;
min-width: 0;
height: 735px;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 28px;
2026-11-26 10:08:04 +08:00
background: var(--screen);
box-shadow: 0 3px 0 #dbe8fa, 0 14px 28px #31588f16;
2026-11-26 10:08:04 +08:00
}
.app-name {
position: relative;
display: flex;
align-items: center;
gap: 12px;
margin: 14px 14px 8px;
min-height: 76px;
padding: 11px 13px;
border: 1px solid #f5ced7;
border-radius: 20px;
background: linear-gradient(108deg, #fff3f5, var(--coral-tint));
color: var(--ink);
font-size: 27px;
2026-11-26 10:08:04 +08:00
font-weight: 740;
line-height: 1.2;
}
.app-name::before {
content: '';
flex: 0 0 48px;
height: 48px;
border-radius: 12px;
background: #7babf8 var(--launcher-art) center / cover;
box-shadow: 0 2px 0 #eac2d1;
}
.app-name::after {
content: '';
position: absolute;
inset: 29px 34px auto auto;
width: 5px;
height: 5px;
background: #e49aab;
box-shadow: -5px 5px #e49aab, 0 5px #e49aab, 5px 5px #e49aab, 0 10px #e49aab,
15px -6px #88aee0, 24px 14px #a7cda9;
pointer-events: none;
}
2026-11-26 10:08:04 +08:00
.phone-content {
overflow: auto;
padding: 4px 14px 12px;
scrollbar-color: #afc6e7 transparent;
2026-11-26 10:08:04 +08:00
scrollbar-width: thin;
}
.card {
margin-bottom: 12px;
padding: 14px 15px 15px;
border: 1px solid var(--line);
2026-11-26 10:08:04 +08:00
border-radius: 18px;
background: var(--paper);
box-shadow: 0 2px 0 #dce9fa;
2026-11-26 10:08:04 +08:00
}
.card h3 { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; font-size: 18px; line-height: 1.45; }
.card h3::before { content: ''; width: 7px; height: 7px; flex: 0 0 7px; background: #82ade6; box-shadow: 3px 3px #cedff7; }
.task-state { border-color: #cde7d3; background: #f6fcf7; box-shadow: 0 2px 0 #deeddf; }
.task-state h3 { color: var(--green); }
.task-state h3::before { background: #77af86; box-shadow: 3px 3px #c8e5ce; }
2026-11-26 10:08:04 +08:00
.card p { margin-top: 6px; font-size: 14px; }
.card .mode { font-size: 15px; font-weight: 650; }
2026-11-26 10:08:04 +08:00
.hint, .summary { color: var(--muted); }
.phone-content > details.card { margin-top: 12px; }
summary { color: var(--blue); font-weight: 650; cursor: pointer; }
2026-11-26 10:08:04 +08:00
progress {
display: block;
width: 100%;
height: 7px;
2026-11-26 10:08:04 +08:00
margin: 12px 0 8px;
appearance: none;
overflow: hidden;
border: 0;
border-radius: 4px;
background: #dcefe0;
2026-11-26 10:08:04 +08:00
}
progress::-webkit-progress-bar { background: #dcefe0; }
2026-11-26 10:08:04 +08:00
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
.action, .app-nav a {
display: grid;
place-items: center;
min-height: 46px;
padding: 6px 10px;
border-radius: 12px;
background: var(--blue-tint);
color: var(--blue);
2026-11-26 10:08:04 +08:00
font-size: 15px;
font-weight: 650;
text-align: center;
text-decoration: none;
}
.action {
width: 100%;
margin-top: 7px;
}
[hidden] { display: none !important; }
button.action { border: 0; cursor: pointer; font-family: inherit; }
.action:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button.action:disabled { color: #63758e; background: #edf2fa; cursor: default; }
#photo-items { display: grid; gap: 10px; margin-top: 8px; }
.photo-item { padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #f6f9ff; }
.photo-item img { display: block; width: 96px; height: 76px; margin-top: 5px; border-radius: 7px; object-fit: contain; }
.library-actions, .photo-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.library-level { margin-top: 14px; }
.library-level label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 700; }
#photo-binding { margin-top: 14px; }
dialog {
width: min(390px, calc(100% - 32px));
padding: 20px;
border: 1px solid #f1cad3;
border-radius: 22px;
background: var(--paper);
color: var(--ink);
box-shadow: 0 8px 32px #293b6560, inset 0 5px var(--coral-tint);
}
dialog::backdrop { background: #26355470; }
dialog h2 { margin-bottom: 12px; font-size: 20px; }
dialog .library-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 10px; }
#library-status { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
#library-error, #library-status.error { color: var(--coral-pressed); font-size: 14px; }
2026-11-26 10:08:04 +08:00
.action.primary {
2026-11-26 10:08:04 +08:00
color: #fff;
background: var(--coral);
2026-11-26 10:08:04 +08:00
}
button.action.primary:hover { background: var(--coral-pressed); }
2026-11-26 10:08:04 +08:00
.action.danger { color: var(--coral-pressed); background: var(--coral-tint); }
.action.primary.danger { color: #fff; background: var(--coral-pressed); }
2026-11-26 10:08:04 +08:00
.action[aria-disabled="true"] {
color: #63758e;
background: #e3ecf9;
2026-11-26 10:08:04 +08:00
}
.app-nav {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 6px;
padding: 8px 14px 11px;
border-top: 1px solid var(--line);
background: #f8fbff;
2026-11-26 10:08:04 +08:00
}
.app-nav a { color: var(--muted); background: transparent; }
.app-nav [aria-current="page"] { background: #dceaff; color: var(--blue); }
.app-nav a:hover { box-shadow: inset 0 0 0 1px var(--line); }
2026-11-26 10:08:04 +08:00
.fields {
display: grid;
gap: 10px;
margin: 7px 0 0;
}
.fields dt { margin-bottom: 3px; font-size: 14px; font-weight: 700; }
.fields dd { margin: 0; }
.control {
display: flex;
align-items: center;
min-height: 44px;
2026-11-26 10:08:04 +08:00
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 11px;
background: #f6f9ff;
2026-11-26 10:08:04 +08:00
font-size: 15px;
overflow-wrap: anywhere;
}
.select { justify-content: space-between; gap: 9px; }
.select::after {
content: "";
width: 7px;
height: 7px;
flex: 0 0 7px;
margin: -4px 2px 0 0;
transform: rotate(45deg);
border-right: 1.5px solid currentColor;
border-bottom: 1.5px solid currentColor;
}
.multiline { min-height: 60px; align-items: start; }
.settings-input {
display: block;
width: 100%;
color: inherit;
font: inherit;
font-size: 15px;
}
.settings-input:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.settings-input:disabled { color: #63758e; background: #edf2fa; }
select.settings-input {
appearance: none;
padding-right: 28px;
background-image: linear-gradient(45deg, transparent 50%, #6984a9 50%), linear-gradient(135deg, #6984a9 50%, transparent 50%);
background-position: right 15px center, right 10px center;
background-size: 5px 5px;
background-repeat: no-repeat;
}
2026-11-26 10:08:04 +08:00
textarea.settings-input { resize: vertical; }
.range {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
gap: 8px;
font-size: 14px;
}
code { font-size: .92em; overflow-wrap: anywhere; }
.entries {
display: grid;
gap: 7px;
margin: 8px 0 0;
padding: 0;
list-style: none;
font-size: 14px;
overflow-wrap: anywhere;
}
.entries li { padding: 7px 9px; border-left: 3px solid #b9d8c3; border-radius: 8px; background: var(--grass-tint); }
.entries time { display: block; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; white-space: nowrap; }
.entries .warning { border-color: #e8aebc; color: var(--coral-pressed); background: var(--coral-tint); }
2026-11-26 10:08:04 +08:00
@media (max-width: 970px) {
.screen-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 610px) {
.preview { max-width: 442px; padding-top: 25px; }
.preview-header { gap: 12px; margin-bottom: 22px; }
.mark { flex-basis: 44px; width: 44px; height: 44px; border-radius: 12px; }
2026-11-26 10:08:04 +08:00
.screen-grid { grid-template-columns: 1fr; gap: 26px; }
.phone { height: min(735px, max(530px, 80svh)); }
}
@media print {
:root { background: #fff; }
.preview { padding: 0; }
.screen-grid { display: block; }
.screen-figure { margin-bottom: 20px; }
.phone { height: auto; overflow: visible; box-shadow: none; }
.phone-content { overflow: visible; }
.card { break-inside: avoid; border: 1px solid var(--line); }
}
</style>
</head>
<body>
<main class="preview">
<header class="preview-header">
<img class="mark" src="../app/src/main/res/drawable-nodpi/launcher_artwork.jpg" width="52" height="52" alt="">
2026-11-26 10:08:04 +08:00
<div>
<h1>拾见 · 界面预览</h1>
<p>离线预览,可编辑内容库并试用图片绑定。修改仅在本页保留。</p>
2026-11-26 10:08:04 +08:00
</div>
</header>
<div class="screen-grid">
<figure class="screen-figure" id="task">
<figcaption>任务</figcaption>
<section class="phone" aria-label="拾见任务页">
<h2 class="app-name">拾见</h2>
<div class="phone-content">
<div class="card task-state">
2026-11-26 10:08:04 +08:00
<h3>准备运行</h3>
<p class="mode" id="task-mode">抖音 · 仅浏览</p>
<p id="task-scope">内容类型 1 个 · 单次 3 个视频</p>
<progress id="task-progress" value="0" max="3" aria-label="已处理 0 个视频,共 3 个"></progress>
<p class="summary" id="task-summary">已处理视频 0 / 3 · 已确认回复 0 条</p>
<p id="task-content-type">内容类型 · 模型服务</p>
2026-11-26 10:08:04 +08:00
</div>
<div class="card">
<h3>无障碍服务未连接</h3>
<p>在系统设置中开启「拾见任务服务」,然后返回这里。</p>
<span class="action primary">打开无障碍设置</span>
</div>
<span class="action primary" aria-disabled="true">开始任务</span>
<span class="action">启用通知栏暂停按钮</span>
<details class="card" id="pending-receipt-preview">
<summary>等待核对状态</summary>
<p>到抖音核对这条评论</p>
<span class="action primary">自动核对回复</span>
<span class="action primary">确认已发送</span>
<span class="action">跳过此回复</span>
</details>
2026-11-26 10:08:04 +08:00
</div>
<nav class="app-nav" aria-label="任务页导航">
<a href="#task" aria-current="page">任务</a>
<a href="#settings">配置</a>
<a href="#logs">日志</a>
</nav>
</section>
</figure>
<figure class="screen-figure" id="settings">
<figcaption>配置</figcaption>
<section class="phone" aria-label="拾见配置页">
<h2 class="app-name">拾见</h2>
<div class="phone-content" tabindex="0" role="region" aria-label="可滚动的配置预览">
<div class="card">
<h3>任务范围</h3>
<dl class="fields">
<div>
<dt><label for="target-platform">平台</label></dt>
<dd><select id="target-platform" class="control settings-input">
<option value="douyin" data-unit="视频">抖音</option>
<option value="xiaohongshu" data-unit="笔记">小红书</option>
<option value="bilibili" data-unit="视频">哔哩哔哩</option>
<option value="kuaishou" data-unit="作品">快手</option>
</select></dd>
</div>
<div><dt><label for="search-scope">搜索范围</label></dt><dd><select id="search-scope" class="control settings-input"></select></dd></div>
<div><dt><label id="content-limit-label" for="video-limit">单次任务视频上限</label></dt><dd><input id="video-limit" class="control settings-input" type="number" inputmode="numeric" min="1" max="100" value="3" required></dd></div>
2026-11-26 10:08:04 +08:00
</dl>
</div>
<div class="card">
<h3>动作节奏</h3>
<dl class="fields">
<div>
<dt>观看时长(秒)</dt>
<dd class="range"><span class="control">5</span><span>至</span><span class="control">12</span></dd>
</div>
<div>
<dt>动作间隔(毫秒)</dt>
<dd class="range"><span class="control">600</span><span>至</span><span class="control">1800</span></dd>
</div>
</dl>
</div>
<div class="card">
<h3>评论设置</h3>
2026-11-26 10:08:04 +08:00
<dl class="fields">
<div>
<dt><label for="reply-mode">处理方式</label></dt>
<dd><select id="reply-mode" class="control settings-input">
<option>仅浏览</option>
<option>匹配评论并回复</option>
2026-11-26 10:08:04 +08:00
</select></dd>
</div>
<div id="bilibili-comment-scope-field" hidden>
<dt><label for="bilibili-comment-scope">评论发布位置</label></dt>
<dd>
<select id="bilibili-comment-scope" class="control settings-input" aria-describedby="bilibili-comment-scope-hint">
<option value="REPLY_TO_ORIGINAL">回复原评论(仅文字)</option>
<option value="VIDEO_COMMENT">发布视频评论(可带图片)</option>
</select>
<p class="hint" id="bilibili-comment-scope-hint">将话术作为文字回复发到命中的原评论下。已绑定的图片会保留。</p>
</dd>
</div>
<div><dt><label id="reply-limit-label" for="replies-per-video">每条视频回复上限</label></dt><dd><input id="replies-per-video" class="control settings-input" type="number" inputmode="numeric" min="1" max="100" value="1" required></dd></div>
2026-11-28 22:24:06 +08:00
<div><dt><label for="like-on-success">确认回复后点赞</label></dt><dd><select id="like-on-success" class="control settings-input"><option>关闭</option><option>开启</option></select></dd></div>
<div><dt><label for="favorite-on-success">确认回复后收藏</label></dt><dd><select id="favorite-on-success" class="control settings-input"><option>关闭</option><option>开启</option></select></dd></div>
2026-11-26 10:08:04 +08:00
</dl>
<p class="hint" id="reply-scope-hint">达到回复上限或找不到更多匹配评论时,进入下一个视频。</p>
<p class="hint" id="engage-hint">回复确认发送后才会执行已开启的点赞或收藏。</p>
</div>
<div class="card" id="content-library">
<h3>内容库</h3>
<p class="hint" id="content-scope-hint">按内容类型搜索视频,按关键词匹配评论。每个关键词可配置多条话术。</p>
<div class="library-level" id="type-level">
<label for="content-type">内容类型</label>
<select id="content-type" class="control settings-input"></select>
<div class="library-actions">
<button type="button" class="action" data-level="type" data-action="add" aria-label="新增内容类型">新增</button>
<button type="button" class="action" data-level="type" data-action="edit" aria-label="编辑内容类型">编辑</button>
<button type="button" class="action" data-level="type" data-action="delete" aria-label="删除内容类型">删除</button>
2026-11-26 10:08:04 +08:00
</div>
</div>
<div class="library-level" id="rule-level">
<label for="keyword-rule">关键词</label>
<select id="keyword-rule" class="control settings-input"></select>
<div class="library-actions">
<button type="button" class="action" data-level="rule" data-action="add" aria-label="新增关键词">新增</button>
<button type="button" class="action" data-level="rule" data-action="edit" aria-label="编辑关键词">编辑</button>
<button type="button" class="action" data-level="rule" data-action="delete" aria-label="删除关键词">删除</button>
</div>
</div>
<div class="library-level" id="phrase-level">
<label for="reply-phrase">回复话术</label>
<select id="reply-phrase" class="control settings-input"></select>
<div class="library-actions">
<button type="button" class="action" data-level="phrase" data-action="add" aria-label="新增话术">新增</button>
<button type="button" class="action" data-level="phrase" data-action="edit" aria-label="编辑话术">编辑</button>
<button type="button" class="action" data-level="phrase" data-action="delete" aria-label="删除话术">删除</button>
</div>
</div>
<div id="photo-binding" hidden>
<p id="photo-count" class="hint"></p>
<div id="photo-items"></div>
<input id="template-photo" type="file" accept="image/jpeg,image/png" multiple hidden>
<button id="photo-choose" type="button" class="action">添加本机图片</button>
<p id="photo-status" class="hint" role="status" hidden></p>
<p class="hint">支持 JPEG 和 PNG。修改名称、关键词或话术时,保留已绑定图片。</p>
</div>
2026-11-26 10:08:04 +08:00
</div>
<button type="button" class="action primary" id="save-preview">保存配置</button>
<div class="card" style="margin-top: 12px">
<h3>本机数据</h3>
<button type="button" class="action danger" id="reset-preview">一键清除所有已保存数据</button>
</div>
<p id="library-status" role="status" hidden></p>
2026-11-26 10:08:04 +08:00
</div>
<nav class="app-nav" aria-label="配置页导航">
<a href="#task">任务</a>
<a href="#settings" aria-current="page">配置</a>
<a href="#logs">日志</a>
</nav>
</section>
</figure>
<figure class="screen-figure" id="logs">
<figcaption>日志</figcaption>
<section class="phone" aria-label="拾见日志页">
<h2 class="app-name">拾见</h2>
<div class="phone-content">
<div class="card">
<h3>运行日志</h3>
<p id="empty-log" hidden>启动任务后会在这里显示运行步骤。</p>
<ul class="entries" id="log-entries">
<li><time datetime="2026-11-26T12:56:05+08:00">11-26 12:56:05</time> 运行 任务完成 · 处理 1 条 · 确认发送 1 条</li>
<li><time datetime="2026-11-26T12:56:05+08:00">11-26 12:56:05</time> 运行 第 1 条视频已确认 1/1 条回复</li>
2026-11-26 10:08:04 +08:00
<li class="warning"><time datetime="2026-11-25T15:22:14+08:00">11-25 15:22:14</time> 异常 抖音评论未回读到完整内容或未看到唯一发送按钮</li>
<li><time datetime="2026-11-25T15:22:01+08:00">11-25 15:22:01</time> 运行 搜索内容类型 模型服务</li>
<li><time datetime="2026-11-25T15:22:00+08:00">11-25 15:22:00</time> 运行 开始任务 · 匹配评论并回复 · 上限 3 条</li>
2026-11-26 10:08:04 +08:00
<li><time datetime="2026-11-25T15:19:09+08:00">11-25 15:19:09</time> 运行 任务完成 · 处理 3 条 · 确认发送 0 条</li>
<li><time datetime="2026-11-25T15:19:02+08:00">11-25 15:19:02</time> 运行 观看第 3 条 · 7 秒</li>
<li><time datetime="2026-11-25T15:18:47+08:00">11-25 15:18:47</time> 运行 观看第 2 条 · 11 秒</li>
<li><time datetime="2026-11-25T15:18:37+08:00">11-25 15:18:37</time> 运行 观看第 1 条 · 8 秒</li>
</ul>
</div>
</div>
<nav class="app-nav" aria-label="日志页导航">
<a href="#task">任务</a>
<a href="#settings">配置</a>
<a href="#logs" aria-current="page">日志</a>
</nav>
</section>
</figure>
</div>
</main>
<dialog id="library-editor" aria-labelledby="editor-title">
<form id="library-form">
<h2 id="editor-title"></h2>
<input id="library-value" class="control settings-input" autocomplete="off">
<textarea id="library-phrase-text" class="control multiline settings-input" rows="3" autocomplete="off" hidden></textarea>
<p id="library-error" role="alert" hidden></p>
<div class="library-actions">
<button type="button" class="action" id="edit-cancel">取消</button>
<button type="submit" class="action primary">完成</button>
</div>
</form>
</dialog>
<dialog id="library-delete" aria-labelledby="delete-message">
<p id="delete-message"></p>
<div class="library-actions">
<button type="button" class="action" id="delete-cancel">取消</button>
<button type="button" class="action primary" id="delete-confirm">删除</button>
</div>
</dialog>
<dialog id="reset-dialog" aria-labelledby="reset-title" aria-describedby="reset-message">
<h2 id="reset-title">清除所有已保存数据?</h2>
<p id="reset-message">将清除拾见本机保存的配置、内容库、绑定图片、任务检查点和运行日志。DeepSeek 密钥会保留。清除后恢复默认设置,此操作无法撤销。</p>
<div class="library-actions">
<button type="button" class="action" id="reset-cancel" autofocus>取消</button>
<button type="button" class="action primary danger" id="reset-confirm">清除数据</button>
</div>
</dialog>
2026-11-26 10:08:04 +08:00
<script>
const byId = id => document.getElementById(id);
const scope = byId("search-scope");
const platformPicker = byId("target-platform");
const replyMode = byId("reply-mode");
const bilibiliScopeField = byId("bilibili-comment-scope-field");
const bilibiliScope = byId("bilibili-comment-scope");
const typePicker = byId("content-type");
const rulePicker = byId("keyword-rule");
const phrasePicker = byId("reply-phrase");
const editDialog = byId("library-editor");
const deleteDialog = byId("library-delete");
const resetDialog = byId("reset-dialog");
const singleLine = byId("library-value");
const multiLine = byId("library-phrase-text");
const editError = byId("library-error");
2026-11-26 10:08:04 +08:00
const photoBinding = document.getElementById("photo-binding");
const photoCount = document.getElementById("photo-count");
const photoItems = document.getElementById("photo-items");
2026-11-26 10:08:04 +08:00
const fileInput = document.getElementById("template-photo");
const choosePhoto = document.getElementById("photo-choose");
const photoStatus = document.getElementById("photo-status");
const maxPhotos = 9;
const types = [{ id: "model-services", name: "模型服务", rules: [
{ id: "model-recharge", keyword: "国外大模型充值", phrases: [
{ id: "recharge-regions", text: "这条视频里提到的方式适用于哪些地区?", photos: [] },
] },
] }];
const pick = (list, picker) => list.find(item => item.id === picker.value);
const activeType = () => pick(types, typePicker);
const activeRule = () => pick(activeType()?.rules ?? [], rulePicker);
const activePhrase = () => pick(activeRule()?.phrases ?? [], phrasePicker);
const normalizeKeyword = keyword => keyword.normalize("NFKC").toLowerCase().trim().replace(/\s+/gu, " ");
const levels = {
type: { picker: typePicker, name: "内容类型", key: "name", entries: () => types, extra: () => ({ rules: [] }) },
rule: { picker: rulePicker, name: "关键词", key: "keyword", entries: () => activeType()?.rules ?? [], extra: () => ({ phrases: [] }) },
phrase: { picker: phrasePicker, name: "话术", key: "text", entries: () => activeRule()?.phrases ?? [], extra: () => ({ photos: [] }) },
};
let nextId = 0;
let editing;
let deleting;
2026-11-26 10:08:04 +08:00
let photoTarget;
const fillPicker = (picker, options, selected, placeholder) => {
picker.replaceChildren(...(options.length ? options.map(([id, title]) => new Option(title, id)) : [new Option(placeholder, "")]));
if (options.some(([id]) => id === selected)) picker.value = selected;
picker.disabled = !options.length;
2026-11-26 10:08:04 +08:00
};
const setStatus = (message = "") => {
photoStatus.textContent = message;
photoStatus.hidden = !message;
};
const photoItem = (phrase, entry, index) => {
const item = document.createElement("div");
item.className = "photo-item";
const name = document.createElement("p");
name.textContent = `图片 ${index + 1} · ${entry.name}`;
const thumbnail = document.createElement("img");
thumbnail.alt = `第 ${index + 1} 张图片预览`;
thumbnail.src = entry.url;
const actions = document.createElement("div");
actions.className = "photo-actions";
for (const [title, position, disabled] of [["上移", index - 1, index === 0], ["下移", index + 1, index === phrase.photos.length - 1], ["移除图片", null, false]]) {
const button = document.createElement("button");
button.type = "button";
button.className = "action";
button.textContent = title;
button.setAttribute("aria-label", `${title === "移除图片" ? "移除" : title}第 ${index + 1} 张图片`);
button.disabled = disabled;
button.addEventListener("click", () => {
const [selected] = phrase.photos.splice(index, 1);
if (position === null) URL.revokeObjectURL(selected.url);
else phrase.photos.splice(position, 0, selected);
setStatus();
redrawPhoto();
});
actions.append(button);
}
item.append(name, thumbnail, actions);
return item;
};
const redrawPhoto = () => {
const phrase = activePhrase();
const entries = phrase?.photos ?? [];
photoBinding.hidden = !phrase;
photoCount.textContent = `已绑定 ${entries.length} / ${maxPhotos} 张图片`;
photoItems.replaceChildren(...entries.map((entry, index) => photoItem(phrase, entry, index)));
choosePhoto.disabled = entries.length >= maxPhotos;
};
const redrawLibrary = (typeId = typePicker.value, ruleId = rulePicker.value, phraseId = phrasePicker.value) => {
const typeOptions = types.map(type => [type.id, type.name]);
fillPicker(scope, [["", "全部内容类型"], ...typeOptions], scope.value, "");
fillPicker(typePicker, typeOptions, typeId, "请先新增内容类型");
fillPicker(rulePicker, (activeType()?.rules ?? []).map(rule => [rule.id, rule.keyword]), ruleId, "请先新增关键词");
fillPicker(phrasePicker, (activeRule()?.phrases ?? []).map((phrase, index) => [phrase.id, `${index + 1}. ${phrase.text.replace(/\s+/gu, " ")}`]), phraseId, "请先新增话术");
byId("rule-level").hidden = !activeType();
byId("phrase-level").hidden = !activeRule();
for (const button of document.querySelectorAll("[data-level][data-action]")) {
button.disabled = button.dataset.action !== "add" && levels[button.dataset.level].picker.disabled;
}
2026-11-26 10:08:04 +08:00
redrawPhoto();
};
for (const button of document.querySelectorAll("[data-level][data-action]")) {
button.addEventListener("click", () => {
const level = button.dataset.level;
const config = levels[level];
const entries = config.entries();
const existing = pick(entries, config.picker);
if (button.dataset.action === "delete") {
if (!existing) return;
const messages = {
type: () => `删除「${existing.name}」及其中的关键词、话术和图片绑定?`,
rule: () => `删除关键词「${existing.keyword}」及其话术和图片绑定?`,
phrase: () => "删除这条话术及其图片绑定?",
};
deleting = { entries, existing };
byId("delete-message").textContent = messages[level]();
deleteDialog.showModal();
return;
}
const edit = button.dataset.action === "edit";
editing = { level, config, entries, item: edit ? existing : undefined };
byId("editor-title").textContent = `${edit ? "编辑" : "新增"}${config.name}`;
const isPhrase = level === "phrase";
singleLine.hidden = isPhrase;
multiLine.hidden = !isPhrase;
editError.hidden = true;
const field = isPhrase ? multiLine : singleLine;
field.value = editing.item?.[config.key] ?? "";
field.placeholder = isPhrase ? "输入回复文字" : level === "type" ? "内容类型名称" : "一个关键词";
field.setAttribute("aria-label", field.placeholder);
editDialog.showModal();
field.focus();
});
}
byId("edit-cancel").addEventListener("click", () => editDialog.close());
byId("delete-cancel").addEventListener("click", () => deleteDialog.close());
byId("library-form").addEventListener("submit", event => {
event.preventDefault();
const { level, config, entries, item } = editing;
const field = level === "phrase" ? multiLine : singleLine;
const value = field.value.trim();
const error = !value ? `请填写${field.placeholder}。`
: level === "type" && value.length > 120 ? "内容类型名称最多 120 个字符。"
: level === "rule" && (value.length > 120 || /[\r\n]/u.test(value)) ? "每个关键词最多 120 个字符,请填一行。"
: level === "rule" && entries.some(entry => entry !== item && normalizeKeyword(entry.keyword) === normalizeKeyword(value)) ? "这个内容类型已有相同的关键词。"
: level === "phrase" && [...value].length > 120 ? "每条话术最多 120 个字符。"
: level === "phrase" && !item && entries.length >= 100 ? "每个关键词最多 100 条话术。" : "";
if (error) {
editError.textContent = error;
editError.hidden = false;
return;
}
const updated = item ?? { id: `preview-${++nextId}`, ...config.extra() };
updated[config.key] = value;
if (!item) entries.push(updated);
editDialog.close();
setStatus();
redrawLibrary(level === "type" ? updated.id : typePicker.value,
level === "rule" ? updated.id : rulePicker.value, level === "phrase" ? updated.id : phrasePicker.value);
});
byId("delete-confirm").addEventListener("click", () => {
const { entries, existing } = deleting;
const affected = existing.rules ? existing.rules.flatMap(rule => rule.phrases) : existing.phrases ?? [existing];
for (const phrase of affected) phrase.photos.forEach(photo => URL.revokeObjectURL(photo.url));
entries.splice(entries.indexOf(existing), 1);
deleteDialog.close();
setStatus();
redrawLibrary();
});
2026-11-26 10:08:04 +08:00
choosePhoto.addEventListener("click", () => {
photoTarget = activePhrase();
2026-11-26 10:08:04 +08:00
fileInput.click();
});
fileInput.addEventListener("change", () => {
const stillPresent = types.some(type => type.rules.some(rule => rule.phrases.includes(photoTarget)));
if (stillPresent && fileInput.files.length) {
const current = photoTarget.photos;
const available = maxPhotos - current.length;
const selected = [...fileInput.files].slice(0, available);
const imported = selected.filter(file => ["image/jpeg", "image/png"].includes(file.type));
current.push(...imported.map(file => ({ name: file.name, url: URL.createObjectURL(file) })));
const issues = [];
if (selected.length > imported.length) issues.push(`${selected.length - imported.length} 张图片无法导入。`);
if (fileInput.files.length > available) issues.push(`超出数量上限的 ${fileInput.files.length - available} 张图片未导入。`);
setStatus(issues.join(" "));
2026-11-26 10:08:04 +08:00
}
photoTarget = undefined;
fileInput.value = "";
redrawPhoto();
});
for (const picker of [typePicker, rulePicker, phrasePicker]) {
picker.addEventListener("change", () => {
setStatus();
redrawLibrary();
});
}
function updateCommentSettings() {
const unit = platformPicker.selectedOptions[0].dataset.unit;
const showBilibiliScope = platformPicker.value === "bilibili" && replyMode.selectedIndex === 1;
const videoComment = showBilibiliScope && bilibiliScope.value === "VIDEO_COMMENT";
const operation = videoComment ? "发布" : "回复";
bilibiliScopeField.hidden = !showBilibiliScope;
byId("bilibili-comment-scope-hint").textContent = videoComment
? "根据匹配结果在当前视频发布评论,话术绑定的图片会随正文发送。"
: "将话术作为文字回复发到命中的原评论下。已绑定的图片会保留。";
byId("content-limit-label").textContent = `单次任务${unit}上限`;
byId("reply-limit-label").textContent = `每条${unit}${videoComment ? "评论发布" : "回复"}上限`;
byId("reply-scope-hint").textContent = `达到${operation}上限或找不到更多匹配评论时,进入下一个${unit}。`;
byId("engage-hint").textContent = ["bilibili", "kuaishou"].includes(platformPicker.value)
? `人工确认后,继续任务时会先核对原${unit},再补做已开启的互动。`
: "回复确认发送后才会执行已开启的点赞或收藏。";
byId("content-scope-hint").textContent = platformPicker.value === "kuaishou"
? "按内容类型搜索,轮流处理「图片」和「视频」中的作品。每个关键词可配置多条话术。"
: `按内容类型搜索${unit},按关键词匹配评论。每个关键词可配置多条话术。`;
}
for (const picker of [platformPicker, replyMode, bilibiliScope]) {
picker.addEventListener("change", updateCommentSettings);
}
function updateTaskPreview() {
const platform = platformPicker.selectedOptions[0];
const unit = platform.dataset.unit;
const limit = byId("video-limit").valueAsNumber;
const selectedType = pick(types, scope);
const searchTypes = selectedType ? [selectedType] : types;
const type = byId("task-content-type");
const progress = byId("task-progress");
const modeLabel = bilibiliScopeField.hidden ? replyMode.value : bilibiliScope.selectedOptions[0].text;
const confirmedLabel = !bilibiliScopeField.hidden && bilibiliScope.value === "VIDEO_COMMENT" ? "已确认发布评论" : "已确认回复";
byId("task-mode").textContent = `${platform.text} · ${modeLabel}`;
byId("task-scope").textContent = `内容类型 ${searchTypes.length} 个 · 单次 ${limit} 个${unit}`;
byId("task-summary").textContent = `已处理${unit} 0 / ${limit} · ${confirmedLabel} 0 条`;
progress.max = limit;
progress.value = 0;
progress.setAttribute("aria-label", `已处理 0 个${unit},共 ${limit} 个`);
type.hidden = searchTypes.length === 0;
type.textContent = searchTypes.length ? `内容类型 · ${searchTypes[0].name}` : "";
}
function showConfigStatus(message, invalid) {
const status = byId("library-status");
status.textContent = message;
status.classList.toggle("error", Boolean(invalid));
status.hidden = false;
invalid?.focus({ preventScroll: true });
status.scrollIntoView({ block: "nearest", inline: "nearest" });
}
byId("save-preview").addEventListener("click", () => {
const invalid = [byId("video-limit"), byId("replies-per-video")].find(input => !input.validity.valid);
if (!invalid) updateTaskPreview();
showConfigStatus(invalid ? `${invalid.labels[0].textContent}须为 1–100 的整数。` : "预览配置已更新。", invalid);
});
byId("reset-preview").addEventListener("click", () => resetDialog.showModal());
byId("reset-cancel").addEventListener("click", () => resetDialog.close());
byId("reset-confirm").addEventListener("click", () => {
for (const type of types) {
for (const rule of type.rules) {
for (const phrase of rule.phrases) phrase.photos.forEach(photo => URL.revokeObjectURL(photo.url));
}
}
types.length = 0;
nextId = 0;
editing = deleting = photoTarget = undefined;
singleLine.value = multiLine.value = fileInput.value = "";
2026-11-28 22:24:06 +08:00
for (const picker of [platformPicker, replyMode, bilibiliScope, scope, byId("like-on-success"), byId("favorite-on-success")]) picker.selectedIndex = 0;
for (const input of [byId("video-limit"), byId("replies-per-video")]) input.value = input.defaultValue;
const pending = byId("pending-receipt-preview");
pending.open = false;
pending.hidden = true;
byId("log-entries").replaceChildren();
byId("log-entries").hidden = true;
byId("empty-log").hidden = false;
resetDialog.close();
setStatus();
updateCommentSettings();
redrawLibrary();
updateTaskPreview();
showConfigStatus("已清除所有已保存数据。");
2026-11-26 10:08:04 +08:00
});
updateCommentSettings();
redrawLibrary();
2026-11-26 10:08:04 +08:00
</script>
</body>
</html>