feat(评论/账号): 自动评论导入 + 账号导出 + 切号参数全局化

- 新表 comment_item(schema v25):视频链接/账号/评论内容/状态
- 新步骤 foreach_comment / mark_comment;clipboard 支持评论变量;input_text 支持当前评论内容
- 计划调度页导入评论、查看/重置/裁决评论数据
- 资产管理导出账号列表 + 自动/人工/有效状态 CSV
- 切号参数全局化:fleet.switch 统一选择器,计划默认 use_global=true,老计划也按全局
- 测试 19/19;API/DATA_MODEL/TASK_DEV/ACCOUNT_FOLDER/CHANGES 同步
This commit is contained in:
2026-10-31 09:18:15 +08:00
parent 0673fa678b
commit 7edb9f6a94
24 changed files with 1542 additions and 82 deletions
+291 -32
View File
@@ -367,6 +367,7 @@ function afHtmlAsset() {
'<button class="btn btn-primary" onclick="afOpenAssetImport()" data-perm="devices">⬆ 批量上传素材(配模板)</button>' +
'<button class="btn" onclick="afOpenRoster()" data-perm="devices">导入/维护账号库</button>' +
'<button class="btn" onclick="afShowPoolApi()" data-perm="devices">🔑 账号池 API</button>' +
'<a class="btn" href="/api/af/accounts/export" data-perm="devices" title="导出账号列表 + 自动状态/人工标记/有效状态">⬇ 导出账号列表</a>' +
'<button class="btn" onclick="afRefreshAll(true)">刷新</button>' +
'<span class="text-muted" style="font-size:12px">账号表里点「入库 N」进素材库;' +
'「所属手机」改了就**重新登记**(下次按新设备激活)。' +
@@ -1815,7 +1816,7 @@ function afPlanSwitchBar() {
const s = sw.switch || {};
return '<div style="border:1px solid var(--border);border-radius:6px;padding:8px 10px;margin-bottom:10px">' +
'<b>切号 / 发布前准备参数</b> <span class="text-muted" style="font-size:12px">' +
'(所有计划共用;切号本身用的是「发布前准备」里的内置「切账号」)</span>' +
'(所有计划共用;选择器点「编辑切号选择器」,改一次全部生效)</span>' +
'<div style="display:flex;gap:10px;flex-wrap:wrap;margin-top:6px;align-items:center;font-size:12px">' +
'<span>切完等 <input class="form-control" style="width:60px;display:inline-block" type="number" min="5" id="af-sw-wait" value="' +
(s.wait_after === undefined ? 15 : s.wait_after) + '"> 秒</span>' +
@@ -1826,6 +1827,7 @@ function afPlanSwitchBar() {
'<option value="continue"' + (s.on_login === 'continue' ? ' selected' : '') + '>继续(只记一句)</option>' +
'</select></span>' +
'<button class="btn btn-xs btn-primary" onclick="afSaveSwitchParams()">保存</button>' +
'<button class="btn btn-xs" onclick="afOpenReadyEditor(\'global\')">编辑切号选择器</button>' +
'<button class="btn btn-xs" onclick="afOpenQuickRun()" data-perm="devices">⚡ 临时跑一轮(不建计划)</button>' +
'</div></div>';
}
@@ -1841,6 +1843,7 @@ async function afSaveSwitchParams() {
const r = await apiPost('/api/af/profile', {name: _af.profile.name, params: p});
if (!r || !r.ok) { showToast((r && r.error) || '保存失败', 'error'); return; }
showToast('已保存(下次跑生效)', 'success');
await afReloadReadyDefaults();
}
// 临时跑一轮:选账号 + 动作组 → 立刻跑(不走计划、不建记录之外的任何东西)
@@ -1976,6 +1979,8 @@ function afHtmlPlan() {
return afPlanSwitchBar() + '' +
'<div class="toolbar" style="flex-wrap:wrap;align-items:center">' +
'<button class="btn btn-primary" onclick="afOpenPlan(\'\')" data-perm="devices">+ 新建计划</button>' +
'<button class="btn" onclick="afOpenCommentImport()" data-perm="devices">📥 导入评论</button>' +
'<button class="btn" onclick="afShowComments()" data-perm="devices">评论数据</button>' +
'<button class="btn" onclick="afRefreshAll(true)">刷新</button>' +
'<span class="text-muted">一条计划 = <b>干什么</b>(App + 动作组)· <b>给谁干</b>(账号库里勾号)· ' +
'<b>发什么</b>(每人几条)· <b>什么时候</b>(固定点 + 抖动)· <b>怎么跑</b>(并发/重试/失败处置);' +
@@ -1999,6 +2004,180 @@ function afHtmlPlan() {
'</div>';
}
// ================== 评论数据:导入 / 列表 ==================
function afOpenCommentImport() {
if (document.getElementById('af-cm-imp')) return;
const ov = document.createElement('div');
ov.id = 'af-cm-imp';
ov.className = 'modal-overlay show';
ov.onclick = function (e) { if (e.target === ov) ov.remove(); };
ov.innerHTML = '<div class="modal" style="max-width:860px">' +
'<div class="modal-header"><h3>导入评论数据</h3>' +
'<button class="close" onclick="document.getElementById(\'af-cm-imp\').remove()">&times;</button></div>' +
'<div class="modal-body">' +
'<div class="help" style="margin-bottom:8px">每行一条:<b>视频链接 &nbsp;账号 &nbsp;评论内容</b>(制表符/逗号都行)。' +
'账号写账号库里的昵称或抖音号;同一个账号可以对多条视频各有一行。' +
'重复导入按「视频链接 + 账号」去重:未执行的更新,已评论/结果未知的跳过。<br>' +
'CSV 里评论内容带逗号/换行时要用引号包起来。</div>' +
'<div class="toolbar" style="margin-bottom:6px">' +
'<a class="btn btn-xs" href="/api/af/comments/template" target="_blank">⬇ 下载模板(CSV)</a>' +
'<span class="text-muted" style="font-size:12px">可以从 Excel 直接复制三列粘贴到下面</span></div>' +
'<div class="form-group"><label>粘贴表格(优先使用;有文件时以文件为准)</label>' +
'<textarea id="af-cm-text" class="form-control" rows="8" style="font-family:monospace" ' +
'placeholder="视频链接\t账号\t评论内容&#10;https://v.douyin.com/xxxxxx/\t周周苏州寻宝藏小店\t这家店我去过"></textarea></div>' +
'<div class="form-group"><label>或上传 CSV</label>' +
'<input type="file" class="form-control" id="af-cm-file" accept=".csv,text/csv"></div>' +
'<div id="af-cm-log" class="text-muted" style="font-size:12px;max-height:260px;overflow:auto"></div>' +
'</div>' +
'<div class="modal-footer">' +
'<button class="btn" onclick="document.getElementById(\'af-cm-imp\').remove()">关闭</button>' +
'<button class="btn" onclick="afDoCommentImport(1)">试导(只校验)</button>' +
'<button class="btn btn-primary" onclick="afDoCommentImport(0)">导入</button>' +
'</div></div>';
document.body.appendChild(ov);
}
async function afDoCommentImport(dry) {
const textEl = document.getElementById('af-cm-text');
const fileEl = document.getElementById('af-cm-file');
const log = document.getElementById('af-cm-log');
if (!textEl || !log) return;
const text = (textEl.value || '').trim();
const file = fileEl && fileEl.files ? fileEl.files[0] : null;
if (!text && !file) { showToast('先粘贴表格或选一个 CSV', 'error'); return; }
log.innerHTML = '⏳ ' + (dry ? '正在校验(不写库)…' : '正在导入…');
let res = null;
try {
if (file) {
const fd = new FormData();
fd.append('file', file);
if (dry) fd.append('dry_run', '1');
const r = await fetch('/api/af/comments/import', {
method: 'POST',
headers: {'X-CSRF-Token': (typeof _csrfToken !== 'undefined' ? _csrfToken : '')},
body: fd
});
res = await r.json();
} else {
res = await apiPost('/api/af/comments/import', {text: text, dry_run: !!dry});
}
} catch (e) {
log.innerHTML = '<span style="color:#c0392b">❌ 请求失败:' + esc(String(e)) + '</span>';
return;
}
if (!res || !res.ok) {
log.innerHTML = '<span style="color:#c0392b">❌ ' + esc((res && (res.error || res.msg)) || '导入失败') + '</span>';
return;
}
const rows = res.rows || [];
const head = (dry ? '试导' : '导入') + '完成:新增 ' + (res.added || 0) +
' / 更新 ' + (res.updated || 0) + ' / 跳过 ' + (res.skipped || 0) +
' / 错误 ' + (res.errors || 0) + (dry ? '(没有写库)' : '');
log.innerHTML = '<div style="color:' + ((res.errors || 0) ? '#b45309' : '#16a34a') +
';margin-bottom:4px"><b>' + esc(head) + '</b></div>' +
'<table class="table" style="font-size:12px"><thead><tr>' +
'<th style="width:45px">行</th><th style="width:110px">账号</th><th>视频链接</th>' +
'<th style="width:75px">结果</th><th>说明</th></tr></thead><tbody>' +
rows.map(function (x) {
const bad = x.action === 'error';
return '<tr><td>' + (x.line || '') + '</td><td>' + esc(x.account || '') + '</td>' +
'<td style="max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">' +
esc(x.url || x.video_url || '') + '</td>' +
'<td style="' + (bad ? 'color:#c0392b' : '') + '">' + esc(x.action || '') + '</td>' +
'<td style="' + (bad ? 'color:#c0392b' : '') + '">' + esc(x.msg || x.error || '') + '</td></tr>';
}).join('') + '</tbody></table>';
if (!dry) showToast('评论数据已导入', 'success');
}
function _afCommentStatusLabel(st) {
const m = {pending: ['待评论', 'label-default'], running: ['执行中', 'label-warning'],
done: ['已评论', 'label-success'], failed: ['失败可重试', 'label-danger'],
unknown: ['结果未知', 'label-warning']};
const x = m[st] || [st || '—', 'label-default'];
return '<span class="label ' + x[1] + '">' + esc(x[0]) + '</span>';
}
async function afShowComments(account, status) {
account = account || '';
status = status || '';
const qs = '/api/af/comments?limit=500' +
(account ? ('&account=' + encodeURIComponent(account)) : '') +
(status ? ('&status=' + encodeURIComponent(status)) : '');
const r = await apiGet(qs);
if (!r || !r.ok) { showToast((r && r.error) || '读取评论数据失败', 'error'); return; }
const rows = r.rows || [];
const st = r.stats || {};
const counts = st.counts || {};
const old = document.getElementById('af-cm-list');
if (old) old.remove();
const ov = document.createElement('div');
ov.id = 'af-cm-list';
ov.className = 'modal-overlay show';
ov.onclick = function (e) { if (e.target === ov) ov.remove(); };
const opts = [['', '全部账号']].concat((r.accounts || []).map(function (a) {
return [a.account_name, a.account_name + '(' + a.pending + ' 条待评论)'];
}));
ov.innerHTML = '<div class="modal" style="max-width:1050px">' +
'<div class="modal-header"><h3>评论数据</h3>' +
'<button class="close" onclick="document.getElementById(\'af-cm-list\').remove()">&times;</button></div>' +
'<div class="modal-body">' +
'<div class="toolbar" style="flex-wrap:wrap;align-items:center;gap:8px">' +
'<span class="text-muted" style="font-size:12px">待评论 <b>' + (st.pending || 0) + '</b> 条 · ' +
'涉及 <b>' + (st.accounts || 0) + '</b> 个账号 · 已评论 ' + (counts.done || 0) +
' · 结果未知 ' + (counts.unknown || 0) + ' · 失败 ' + (counts.failed || 0) + '</span>' +
'<select class="form-control" style="width:210px" data-status="' + esc(status) + '" onchange="afShowComments(this.value, this.dataset.status||\'\')">' +
opts.map(function (o) {
return '<option value="' + esc(o[0]) + '"' + (o[0] === account ? ' selected' : '') + '>' + esc(o[1]) + '</option>';
}).join('') + '</select>' +
'<select class="form-control" style="width:130px" data-account="' + esc(account) + '" onchange="afShowComments(this.dataset.account||\'\', this.value)">' +
[['', '全部状态'], ['pending', '待评论'], ['failed', '失败可重试'],
['unknown', '结果未知'], ['done', '已评论'], ['running', '执行中']].map(function (o) {
return '<option value="' + o[0] + '"' + (o[0] === status ? ' selected' : '') + '>' + o[1] + '</option>';
}).join('') + '</select>' +
'<button class="btn btn-xs" onclick="afOpenCommentImport()">📥 导入评论</button>' +
'</div>' +
'<table class="table" style="font-size:12px;margin-top:8px"><thead><tr>' +
'<th style="width:120px">账号</th><th style="width:150px">视频链接</th><th>评论内容</th>' +
'<th style="width:90px">状态</th><th style="width:70px">尝试</th><th style="width:190px">操作</th>' +
'</tr></thead><tbody>' +
(rows.map(function (x) {
const url = x.video_url || '';
return '<tr><td>' + esc(x.account_name || '') + '</td>' +
'<td style="max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="' + esc(url) + '">' +
(url ? '<a href="' + esc(url) + '" target="_blank" rel="noopener">' + esc(url) + '</a>' : '—') + '</td>' +
'<td title="' + esc(x.comment_text || '') + '">' + esc((x.comment_text || '').slice(0, 80)) +
((x.comment_text || '').length > 80 ? '…' : '') + '</td>' +
'<td>' + _afCommentStatusLabel(x.status) + '</td>' +
'<td>' + (x.attempts || 0) + '</td>' +
'<td style="white-space:nowrap">' +
(x.status !== 'pending' ? '<button class="btn btn-xs" onclick="afCommentAction(\'' + esc(x.id) + '\',\'reset\')">重置</button>' : '') +
(x.status !== 'done' ? '<button class="btn btn-xs" onclick="afCommentAction(\'' + esc(x.id) + '\',\'done\')">标已发</button>' : '') +
'<button class="btn btn-xs" onclick="afCommentAction(\'' + esc(x.id) + '\',\'unknown\')">标未知</button>' +
'<button class="btn btn-xs btn-danger" onclick="afCommentDelete(\'' + esc(x.id) + '\')">删除</button>' +
'</td></tr>';
}).join('') || '<tr><td colspan="6" class="empty">还没有评论数据 —— 点「导入评论」粘贴表格</td></tr>') +
'</tbody></table></div>' +
'<div class="modal-footer"><button class="btn" onclick="document.getElementById(\'af-cm-list\').remove()">关闭</button></div></div>';
document.body.appendChild(ov);
}
async function afCommentAction(id, action) {
let r = null;
if (action === 'reset') r = await apiPost('/api/af/comments/' + encodeURIComponent(id) + '/reset', {});
else r = await apiPost('/api/af/comments/' + encodeURIComponent(id) + '/resolve', {result: action});
if (!r || !r.ok) { showToast((r && r.error) || '操作失败', 'error'); return; }
showToast(r.msg || '已更新', 'success');
afShowComments();
}
async function afCommentDelete(id) {
if (!confirm('删除这条评论数据?')) return;
const r = await apiDelete('/api/af/comments/' + encodeURIComponent(id));
if (!r || !r.ok) { showToast((r && r.error) || '删除失败', 'error'); return; }
showToast('已删除', 'success');
afShowComments();
}
function _afPlanStatus(s) {
const m = {done: '<span class="label label-success">全部完成</span>',
partial: '<span class="label label-warning">部分完成</span>',
@@ -2028,21 +2207,28 @@ function _afPlanSegDefault() {
// 它不是动作库里的条目,而是计划执行每个账号前的内置步骤;页面把它显示在编排列表上方,
// 参数存在 plan.ready(空 = 用 /api/af/ready_defaults 的全局默认)。
function afPlanReadyInit(saved) {
const d = _af.readyDefaults || {};
const s = saved || {};
_afPlanReady = Object.assign({}, d, s);
_afPlanReady.enabled = (s.enabled === undefined) ? true : !!s.enabled;
// 只保留可编辑字段,避免把 probability/target 等内部字段带进保存体
['switch_selector_type', 'switch_selector_value', 'me_selector_type', 'me_selector_value',
'name_selector_type', 'name_selector_value', 'timeout', 'wait_after', 'max_attempts',
'on_login_page', 'on_fail'].forEach(function (k) {
if (_afPlanReady[k] === undefined && d[k] !== undefined) _afPlanReady[k] = d[k];
});
// 2026-10-31:默认用**全局切号参数**。老计划没有 use_global 字段也按全局走
// (否则元素一变就要一个个计划改)。要单独覆盖才显式存 use_global=false。
const useGlobal = s.use_global !== false;
_afPlanReady = {enabled: s.enabled === undefined ? true : !!s.enabled,
use_global: useGlobal};
if (!useGlobal) Object.assign(_afPlanReady, s, {use_global: false});
}
function afPlanReadySet(k, v) {
if (!_afPlanReady) _afPlanReady = {};
_afPlanReady[k] = v;
if (!_afPlanReady) _afPlanReady = {enabled: true, use_global: true};
if (k === 'use_global') {
if (v) {
_afPlanReady = {enabled: _afPlanReady.enabled !== false, use_global: true};
} else {
const d = _af.readyDefaults || {};
_afPlanReady = Object.assign({}, d, {enabled: _afPlanReady.enabled !== false,
use_global: false});
}
} else {
_afPlanReady[k] = v;
}
afPlanReadyRender();
}
@@ -2051,25 +2237,33 @@ function afPlanReadyRender() {
if (!box) return;
const r = _afPlanReady || {};
const en = r.enabled !== false;
const short = function (v) {
v = v || '';
return v.length > 44 ? (v.slice(0, 44) + '…') : (v || '(默认)');
const useGlobal = r.use_global !== false;
const d = _af.readyDefaults || {};
const v = useGlobal ? Object.assign({}, d, {enabled: en}) : r;
const short = function (val) {
val = val || '';
return val.length > 44 ? (val.slice(0, 44) + '…') : (val || '(默认)');
};
box.innerHTML = '<div style="border:1px solid var(--border);border-radius:6px;padding:8px;margin-bottom:8px;background:#fafafa">' +
'<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap">' +
'<b>🔒 内置 · 账号就绪(切号)</b>' +
'<label style="font-weight:400;font-size:12px"><input type="checkbox" ' + (en ? 'checked' : '') +
' onchange="afPlanReadySet(\'enabled\', this.checked)"> 启用</label>' +
'<button class="btn btn-xs" onclick="afOpenReadyEditor()">编辑参数</button>' +
'<span class="text-muted" style="font-size:11px">每个账号在编排之前自动执行;切不过来默认跳过这个号</span>' +
'<label style="font-weight:400;font-size:12px"><input type="checkbox" ' + (useGlobal ? 'checked' : '') +
' onchange="afPlanReadySet(\'use_global\', this.checked)"> 使用全局切号参数</label>' +
(useGlobal
? '<button class="btn btn-xs" onclick="afOpenReadyEditor(\'global\')">编辑全局参数</button>'
: '<button class="btn btn-xs" onclick="afOpenReadyEditor(\'plan\')">编辑本计划参数</button>') +
'<span class="text-muted" style="font-size:11px">' +
(useGlobal ? '全局改了所有计划一起生效' : '本计划单独覆盖,不受全局改动影响') + '</span>' +
'</div>' +
(en
? ('<div class="text-muted" style="font-size:11px;margin-top:4px">' +
'点「我」(' + esc(r.me_selector_type || 'xpath') + ': ' + esc(short(r.me_selector_value)) + ')' +
'点「我」(' + esc(v.me_selector_type || 'xpath') + ': ' + esc(short(v.me_selector_value)) + ')' +
' → 读名字 → 一样跳过 / 不一样才切;切后等 ' +
(r.wait_after === undefined ? 15 : r.wait_after) + ' 秒,重试 ' +
(r.max_attempts || 2) + ' 次;切不过去:' +
(r.on_fail === 'stop' ? '停本设备' : '跳过这个号') +
(v.wait_after === undefined ? 15 : v.wait_after) + ' 秒,重试 ' +
(v.max_attempts || 2) + ' 次;切不过去:' +
(v.on_fail === 'stop' ? '停本设备' : '跳过这个号') +
'</div>')
: '<div style="color:#c0392b;font-size:11px;margin-top:4px">' +
'已关闭内置切号 —— 请在下面的编排里放一个切号动作组,否则可能发到错误的号</div>') +
@@ -2090,8 +2284,33 @@ function _afReadySelOpts(cur, withAll) {
}).join('');
}
function afOpenReadyEditor() {
const r = _afPlanReady || {};
var _afReadyEditMode = 'plan';
async function afReloadReadyDefaults() {
const rd = await apiGet('/api/af/ready_defaults');
if (rd && rd.ok) _af.readyDefaults = rd.params || {};
if (document.getElementById('afp-ready')) afPlanReadyRender();
afRender();
}
function afOpenReadyEditor(mode) {
_afReadyEditMode = mode || 'plan';
const globalMode = _afReadyEditMode === 'global';
const gsw = ((((_af.profile || {}).params || {}).fleet || {}).switch) || {};
const d = _af.readyDefaults || {};
const r = globalMode ? {
switch_selector_type: gsw.entry_selector_type || gsw.switch_selector_type || d.switch_selector_type || '',
switch_selector_value: gsw.entry_selector_value || gsw.switch_selector_value || d.switch_selector_value || '',
name_selector_type: gsw.name_selector_type || d.name_selector_type || '',
name_selector_value: gsw.name_selector_value || d.name_selector_value || '',
me_selector_type: gsw.me_selector_type || d.me_selector_type || '',
me_selector_value: gsw.me_selector_value || d.me_selector_value || '',
timeout: gsw.timeout === undefined ? (d.timeout === undefined ? 8 : d.timeout) : gsw.timeout,
wait_after: gsw.wait_after === undefined ? (d.wait_after === undefined ? 15 : d.wait_after) : gsw.wait_after,
max_attempts: gsw.retries || d.max_attempts || 2,
on_login_page: gsw.on_login || d.on_login_page || 'stop',
on_fail: gsw.on_fail || d.on_fail || 'skip_account'
} : Object.assign({}, d, _afPlanReady || {}, {use_global: false});
const old = document.getElementById('af-ready-overlay');
if (old) old.remove();
const ov = document.createElement('div');
@@ -2100,13 +2319,18 @@ function afOpenReadyEditor() {
ov.style.zIndex = 1200;
ov.onclick = function (e) { if (e.target === ov) ov.remove(); };
ov.innerHTML = '<div class="modal" style="max-width:760px">' +
'<div class="modal-header"><h3>内置步骤参数 · 账号就绪(切号)</h3>' +
'<div class="modal-header"><h3>' +
(globalMode ? '全局切号参数(所有计划共用)' : '内置步骤参数 · 账号就绪(切号)') + '</h3>' +
'<button class="close" onclick="document.getElementById(\'af-ready-overlay\').remove()">&times;</button></div>' +
'<div class="modal-body">' +
'<div class="help" style="margin-bottom:8px">这里是**计划内置**的切号步骤:每个账号执行编排前先跑它。' +
'空选择器 = 用全局默认(config/.env)。关闭后请自己在编排里放一个切号动作组。</div>' +
'<div class="form-check" style="margin-bottom:8px"><input type="checkbox" id="afr-enabled" ' +
(r.enabled !== false ? 'checked' : '') + '><label for="afr-enabled">启用内置切号</label></div>' +
'<div class="help" style="margin-bottom:8px">' +
(globalMode
? '这里是<b>全局</b>切号选择器:所有「使用全局切号参数」的计划都读这一份,元素变了只改这里一次。'
: '这里是<b>本计划</b>的切号覆盖:只影响这个计划。一般保持「使用全局切号参数」,除非本计划确实要不同选择器。') +
'</div>' +
(globalMode ? '' :
'<div class="form-check" style="margin-bottom:8px"><input type="checkbox" id="afr-enabled" ' +
(r.enabled !== false ? 'checked' : '') + '><label for="afr-enabled">启用内置切号</label></div>') +
'<div class="form-group"><label>进「切换账号」列表的入口</label>' +
'<div style="display:flex;gap:6px">' +
'<select class="form-control" id="afr-sw-type" style="width:170px">' + _afReadySelOpts(r.switch_selector_type) + '</select>' +
@@ -2153,8 +2377,7 @@ function afOpenReadyEditor() {
function afSaveReadyEditor() {
const g = function (id) { const e = document.getElementById(id); return e ? e.value : ''; };
const c = function (id) { const e = document.getElementById(id); return !!(e && e.checked); };
_afPlanReady = {
enabled: c('afr-enabled'),
const r = {
switch_selector_type: g('afr-sw-type'), switch_selector_value: g('afr-sw-val'),
me_selector_type: g('afr-me-type'), me_selector_value: g('afr-me-val'),
name_selector_type: g('afr-name-type'), name_selector_value: g('afr-name-val'),
@@ -2164,6 +2387,30 @@ function afSaveReadyEditor() {
on_login_page: g('afr-login') || 'stop',
on_fail: g('afr-fail') || 'skip_account'
};
if (_afReadyEditMode === 'global') {
const p = _af.profile && _af.profile.params;
if (!p) { showToast('配置还没加载', 'error'); return; }
p.fleet = p.fleet || {};
p.fleet.switch = Object.assign({}, p.fleet.switch || {}, {
entry_selector_type: r.switch_selector_type,
entry_selector_value: r.switch_selector_value,
name_selector_type: r.name_selector_type,
name_selector_value: r.name_selector_value,
me_selector_type: r.me_selector_type,
me_selector_value: r.me_selector_value,
timeout: r.timeout, wait_after: r.wait_after, retries: r.max_attempts,
on_login: r.on_login_page, on_fail: r.on_fail
});
apiPost('/api/af/profile', {name: _af.profile.name, params: p}).then(async function (res) {
const ov = document.getElementById('af-ready-overlay');
if (ov) ov.remove();
if (!res || !res.ok) { showToast((res && res.error) || '保存失败', 'error'); return; }
showToast('全局切号参数已保存(所有使用全局的计划生效)', 'success');
await afReloadReadyDefaults();
});
return;
}
_afPlanReady = Object.assign({}, r, {enabled: c('afr-enabled'), use_global: false});
const ov = document.getElementById('af-ready-overlay');
if (ov) ov.remove();
afPlanReadyRender();
@@ -2255,7 +2502,13 @@ function afPlanSegRow(s, i) {
'type="number" min="0" value="' + (s.per_account === undefined ? 1 : s.per_account) +
'" onchange="afPlanSegSet(' + i + ',\'per_account\',this.value)"> 条(0=全部)</span>') : '') +
(s.source === 'task'
? '<span class="text-muted" style="font-size:11px">任务只做发布动作;推送/标记由计划补(任务里已有就不重复)</span>'
? (function () {
const tj = (_af.jobs || []).find(function (x) { return x.id === s.task_id; }) || {};
const isComment = (tj.name || '').indexOf('评论') >= 0;
return isComment
? '<span style="color:#b45309;font-size:11px">评论任务:<b>不要勾「发布素材」</b>,评论数据由任务里的「循环评论」取</span>'
: '<span class="text-muted" style="font-size:11px">任务只做发布动作;推送/标记由计划补(任务里已有就不重复)</span>';
})()
: '') +
'<label style="font-weight:400;font-size:12px">循环 ' +
'<select class="form-control" style="width:86px;display:inline-block" onchange="afPlanSegSet(' + i + ',\'loop.mode\',this.value)">' +
@@ -2585,7 +2838,13 @@ async function afSavePlan(planId) {
app_id: first.app_id || '',
action_id: first.action_id,
segments: segs,
ready: _afPlanReady || {},
ready: (function () {
const r = _afPlanReady || {};
if (r.use_global !== false) {
return {enabled: r.enabled !== false, use_global: true};
}
return Object.assign({}, r, {use_global: false});
})(),
account_ids: ids, accounts: names,
material: (function () {
const mode = (document.querySelector('input[name="afp-matmode"]:checked') || {}).value || 'pool';