Release Shijian 0.1.19 with automatic Douyin reply receipts

Add content type rules, reply quotas, and multi-image templates. Verify published replies in the original comment thread and record automatic receipts. Document uninterrupted physical-device acceptance.
This commit is contained in:
2026-11-26 14:00:16 +08:00
parent af6aa07c3a
commit fed659dab9
23 changed files with 3611 additions and 770 deletions
+284 -118
View File
@@ -150,8 +150,27 @@
margin-top: 7px;
}
#photo-binding [hidden] { display: none; }
#photo-binding button { border: 0; cursor: pointer; }
[hidden] { display: none !important; }
button.action { border: 0; cursor: pointer; }
button.action:disabled { opacity: .48; cursor: default; }
#photo-items { display: grid; gap: 10px; margin-top: 8px; }
.photo-item img { display: block; width: 96px; height: 76px; 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 var(--line);
border-radius: 18px;
color: var(--ink);
}
dialog::backdrop { background: #172a2460; }
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(--alert); font-size: 14px; }
.action.primary, .app-nav [aria-current="page"] {
color: #fff;
@@ -222,22 +241,6 @@
font-size: 14px;
}
.checkbox {
display: flex;
gap: 8px;
align-items: center;
min-height: 32px;
font-size: 14px;
}
.checkbox::before {
content: "";
width: 15px;
height: 15px;
flex: 0 0 15px;
border: 1.5px solid var(--muted);
border-radius: 3px;
}
code { font-size: .92em; overflow-wrap: anywhere; }
.entries {
@@ -283,7 +286,7 @@
<span class="mark" aria-hidden="true"><i></i><i></i><i></i></span>
<div>
<h1>拾见 · 界面预览</h1>
<p>离线预览,可编辑话术并试用本机图片绑定。日志为演示数据。</p>
<p>离线预览,可编辑内容库并试用图片绑定。修改仅在本页保留。</p>
</div>
</header>
@@ -296,10 +299,10 @@
<div class="card">
<h3>准备运行</h3>
<p class="mode">抖音 · 仅浏览</p>
<p>关键词 1 个 · 单次 3 条</p>
<progress value="0" max="3" aria-label="已处理 0 条,共 3 条"></progress>
<p class="summary">已处理 0 / 3 · 已确认发送 0</p>
<p>关键词 国外大模型充值</p>
<p>内容类型 1 个 · 单次 3 个视频</p>
<progress value="0" max="3" aria-label="已处理 0 个视频,共 3 个"></progress>
<p class="summary">已处理视频 0 / 3 · 已确认回复 0 条</p>
<p>内容类型 · 模型服务</p>
</div>
<div class="card">
<h3>无障碍服务未连接</h3>
@@ -308,6 +311,13 @@
</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>
</div>
<nav class="app-nav" aria-label="任务页导航">
<a href="#task" aria-current="page">任务</a>
@@ -326,8 +336,8 @@
<h3>任务范围</h3>
<dl class="fields">
<div><dt>平台</dt><dd class="control select">抖音</dd></div>
<div><dt>搜索关键词</dt><dd class="control multiline">国外大模型充值</dd></div>
<div><dt>单次任务总数</dt><dd class="control">3</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 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>
</dl>
</div>
<div class="card">
@@ -344,57 +354,60 @@
</dl>
</div>
<div class="card">
<h3>评论</h3>
<h3>评论设置</h3>
<dl class="fields">
<div>
<dt><label for="reply-mode">处理方式</label></dt>
<dd><select id="reply-mode" class="control settings-input">
<option>仅浏览</option>
<option>随机使用话术并发送</option>
<option>话术优先,DeepSeek 兜底</option>
<option>匹配评论并回复</option>
</select></dd>
</div>
<div>
<dt><label for="template-group">话术分组</label></dt>
<dd><select id="template-group" class="control settings-input">
<option value="common">通用</option>
<option value="keyword-0">关键词 · 国外大模型充值</option>
</select></dd>
</div>
<div>
<dt><label for="template-editor">话术库</label></dt>
<dd><textarea id="template-editor" class="control multiline settings-input" rows="2" placeholder="每行一条话术" autocomplete="off"></textarea></dd>
</div>
<div><dt><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>
</dl>
<p class="hint">先从当前关键词分组随机选一条。该分组为空时使用通用分组。支持 <code>{keyword}</code> 和 <code>{title}</code>。</p>
<dl class="fields">
<div>
<dt><label for="photo-phrase">绑定到话术</label></dt>
<dd><select id="photo-phrase" class="control settings-input" disabled></select></dd>
<p class="hint">达到回复上限或找不到更多匹配评论时,进入下一个视频。</p>
</div>
<div class="card" id="content-library">
<h3>内容库</h3>
<p class="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>
</div>
</dl>
<div id="photo-binding" hidden>
<p id="photo-name" class="hint" hidden></p>
<img id="photo-thumbnail" alt="已绑定图片预览" width="96" height="76" style="object-fit: contain" hidden>
<input id="template-photo" type="file" accept="image/jpeg,image/png" hidden>
<button id="photo-choose" type="button" class="action">选择本机图片</button>
<button id="photo-remove" type="button" class="action" hidden>移除图片</button>
</div>
<p class="hint">每条话术可绑定一张本机照片。改写话术后需重新绑定。</p>
<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>
</div>
<div class="card">
<h3>DeepSeek</h3>
<p class="hint">启用兜底后,没有可用话术时才调用 DeepSeek。请求包含关键词、视频标题和可见评论样本。缺少话术且未设置 API Key 时跳过该视频。</p>
<dl class="fields">
<div><dt>API Key</dt><dd class="control hint">粘贴 API Key</dd></div>
</dl>
<div class="checkbox">清除已保存的 API Key</div>
<dl class="fields">
<div><dt>模型</dt><dd class="control">deepseek-flash</dd></div>
<div><dt>生成说明</dt><dd class="control multiline">根据视频内容提供一句具体、有帮助的中文评论。</dd></div>
</dl>
</div>
<span class="action primary">保存配置</span>
<button type="button" class="action primary" id="save-preview">保存配置</button>
<p id="library-status" role="status" hidden></p>
</div>
<nav class="app-nav" aria-label="配置页导航">
<a href="#task">任务</a>
@@ -412,9 +425,11 @@
<div class="card">
<h3>运行日志</h3>
<ul class="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>
<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> 运行 开始任务 · 话术优先,DeepSeek 兜底 · 上限 3 条</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>
<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>
@@ -431,77 +446,228 @@
</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>
<script>
const groups = document.getElementById("template-group");
const editor = document.getElementById("template-editor");
const photoPhrase = document.getElementById("photo-phrase");
const byId = id => document.getElementById(id);
const scope = byId("search-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 singleLine = byId("library-value");
const multiLine = byId("library-phrase-text");
const editError = byId("library-error");
const photoBinding = document.getElementById("photo-binding");
const photoName = document.getElementById("photo-name");
const thumbnail = document.getElementById("photo-thumbnail");
const photoCount = document.getElementById("photo-count");
const photoItems = document.getElementById("photo-items");
const fileInput = document.getElementById("template-photo");
const choosePhoto = document.getElementById("photo-choose");
const removePhoto = document.getElementById("photo-remove");
const drafts = new Map([["keyword-0", "这条视频里提到的方式适用于哪些地区?"]]);
const photos = new Map();
let activeGroup = groups.value;
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;
let photoTarget;
const photoKey = () => JSON.stringify([activeGroup, photoPhrase.value]);
const redrawPhoto = () => {
const attachment = photos.get(photoKey());
photoBinding.hidden = photoPhrase.disabled;
photoName.hidden = thumbnail.hidden = removePhoto.hidden = !attachment;
if (attachment) {
photoName.textContent = "图片 · " + attachment.name;
thumbnail.src = attachment.url;
} else {
thumbnail.removeAttribute("src");
}
choosePhoto.textContent = attachment ? "更换图片" : "选择本机图片";
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;
};
const redrawPhrases = () => {
const previous = photoPhrase.value;
const phrases = [...new Set(editor.value.split(/\r?\n/).map(line => line.trim()).filter(Boolean))];
photoPhrase.replaceChildren(...(phrases.length ? phrases.map(phrase => new Option(phrase, phrase)) :
[new Option("先填写一条话术", "")]));
if (phrases.includes(previous)) photoPhrase.value = previous;
photoPhrase.disabled = !phrases.length;
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;
}
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();
});
choosePhoto.addEventListener("click", () => {
photoTarget = photoKey();
photoTarget = activePhrase();
fileInput.click();
});
fileInput.addEventListener("change", () => {
const file = fileInput.files[0];
if (photoTarget && file && ["image/jpeg", "image/png"].includes(file.type)) {
const previous = photos.get(photoTarget);
if (previous) URL.revokeObjectURL(previous.url);
photos.set(photoTarget, { name: file.name, url: URL.createObjectURL(file) });
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(" "));
}
photoTarget = undefined;
fileInput.value = "";
redrawPhoto();
});
removePhoto.addEventListener("click", () => {
const key = photoKey();
const attachment = photos.get(key);
if (attachment) URL.revokeObjectURL(attachment.url);
photos.delete(key);
redrawPhoto();
});
photoPhrase.addEventListener("change", redrawPhoto);
editor.addEventListener("input", redrawPhrases);
editor.value = drafts.get(activeGroup) ?? "";
redrawPhrases();
groups.addEventListener("change", () => {
drafts.set(activeGroup, editor.value);
activeGroup = groups.value;
editor.value = drafts.get(activeGroup) ?? "";
redrawPhrases();
for (const picker of [typePicker, rulePicker, phrasePicker]) {
picker.addEventListener("change", () => {
setStatus();
redrawLibrary();
});
}
byId("save-preview").addEventListener("click", () => {
const status = byId("library-status");
const invalid = [byId("video-limit"), byId("replies-per-video")].find(input => !input.validity.valid);
status.textContent = invalid ? `${invalid.labels[0].textContent}须为 1–100 的整数。` : "预览配置已更新。";
status.classList.toggle("error", Boolean(invalid));
status.hidden = false;
invalid?.focus();
});
redrawLibrary();
</script>
</body>
</html>