feat(账号): 人工标记优先于自动状态
- device_account 新增 manual_status(schema v24) - 资产总表新增「人工标记」下拉(账号异常/作品异常/账号限流/账号正常) - 有效状态 effective_status = 人工标记 or 自动状态;筛选/通知/账号池 API 都按它 - 任务自动检测只写 account_status,不覆盖人工标记 - 账号池 API 增加 manual_status/effective_status 与 ?manual= 过滤 - 测试 test_roster ⑩;文档同步
This commit is contained in:
@@ -142,6 +142,11 @@ function afAccFilterSet(k, v, debounce) {
|
||||
} else redraw();
|
||||
}
|
||||
|
||||
// 有效状态:人工标记优先,否则自动检测值(与后端 DeviceAccount.effective_status 一致)
|
||||
function afEffStatus(a) {
|
||||
return ((a && (a.effective_status || a.manual_status || a.account_status)) || '').trim();
|
||||
}
|
||||
|
||||
// ---------- 单条素材上传:选一个文件 → 弹窗手填明细 → 入库 ----------
|
||||
function afAssetPickFile(account) {
|
||||
const inp = document.createElement('input');
|
||||
@@ -294,9 +299,10 @@ function afHtmlAsset() {
|
||||
let shown = all;
|
||||
if (F.device === '__none') shown = shown.filter(function (a) { return !a.device_name; });
|
||||
else if (F.device) shown = shown.filter(function (a) { return a.device_name === F.device; });
|
||||
if (F.status === '__none') shown = shown.filter(function (a) { return !(a.account_status || '').trim(); });
|
||||
else if (F.status === '__abnormal') shown = shown.filter(function (a) { return (a.account_status || '').indexOf('异常') >= 0; });
|
||||
else if (F.status) shown = shown.filter(function (a) { return (a.account_status || '') === F.status; });
|
||||
// 状态筛选按**有效状态**:人工标记优先于任务自动检测值
|
||||
if (F.status === '__none') shown = shown.filter(function (a) { return !afEffStatus(a); });
|
||||
else if (F.status === '__abnormal') shown = shown.filter(function (a) { return afEffStatus(a).indexOf('异常') >= 0; });
|
||||
else if (F.status) shown = shown.filter(function (a) { return afEffStatus(a) === F.status; });
|
||||
if (F.q) {
|
||||
const kw = F.q.toLowerCase();
|
||||
shown = shown.filter(function (a) {
|
||||
@@ -306,7 +312,7 @@ function afHtmlAsset() {
|
||||
const devNames = Array.from(new Set(all.map(function (a) { return a.device_name; })
|
||||
.filter(Boolean))).sort();
|
||||
const statusNames = Array.from(new Set(all.map(function (a) {
|
||||
return (a.account_status || '').trim();
|
||||
return afEffStatus(a);
|
||||
}).filter(Boolean)));
|
||||
// 排序:正常 → 带「异常」的 → 其它(中文排序)
|
||||
statusNames.sort(function (a, b) {
|
||||
@@ -326,7 +332,7 @@ function afHtmlAsset() {
|
||||
'<td>' + devSel + '</td>' +
|
||||
'<td style="white-space:nowrap">' +
|
||||
(a.account_status
|
||||
? '<span class="label ' + (a.account_status === '正常' ? 'label-success' : 'label-warning') + '">' +
|
||||
? '<span class="label ' + ((a.account_status === '正常' || a.account_status === '账号正常') ? 'label-success' : 'label-warning') + '">' +
|
||||
esc(a.account_status) + '</span> '
|
||||
: '<span class="text-muted" style="font-size:11px">—</span> ') +
|
||||
(a.in_roster
|
||||
@@ -339,6 +345,7 @@ function afHtmlAsset() {
|
||||
? '<div class="text-muted" style="font-size:11px;margin-top:2px">检测 ' +
|
||||
esc(a.status_checked_at) + '</div>' : '') +
|
||||
'</td>' +
|
||||
'<td>' + afManualStatusHtml(a) + '</td>' +
|
||||
'<td><button class="btn btn-xs btn-primary" onclick="afAssetOpenAccount(\'' + esc(a.name) + '\')">' +
|
||||
'入库 <b>' + (a.total || 0) + '</b> · 未发布 <b style="color:#b45309">' + (a.pending || 0) + '</b>' +
|
||||
' · 已发布 <b style="color:#16a34a">' + (a.done || 0) + '</b>' +
|
||||
@@ -362,7 +369,8 @@ function afHtmlAsset() {
|
||||
'<button class="btn" onclick="afShowPoolApi()" data-perm="devices">🔑 账号池 API</button>' +
|
||||
'<button class="btn" onclick="afRefreshAll(true)">刷新</button>' +
|
||||
'<span class="text-muted" style="font-size:12px">账号表里点「入库 N」进素材库;' +
|
||||
'「所属手机」改了就**重新登记**(下次按新设备激活)。素材放进去 = 归这个账号。</span>' +
|
||||
'「所属手机」改了就**重新登记**(下次按新设备激活)。' +
|
||||
'「人工标记」优先于自动状态(筛选/通知/账号池 API 都按它)。</span>' +
|
||||
'</div>' +
|
||||
'<div class="toolbar" style="flex-wrap:wrap;align-items:center;gap:8px">' +
|
||||
'<span style="font-size:12px">所属手机</span>' +
|
||||
@@ -394,10 +402,10 @@ function afHtmlAsset() {
|
||||
'</div>' +
|
||||
'<table class="table"><thead><tr>' +
|
||||
'<th style="width:230px">账号</th><th style="width:210px">所属手机</th>' +
|
||||
'<th style="width:190px">账号状态</th>' +
|
||||
'<th style="width:400px">素材库</th><th style="width:140px">最近发布</th><th style="width:190px">操作</th>' +
|
||||
'<th style="width:190px">账号状态(自动)</th><th style="width:140px">人工标记</th>' +
|
||||
'<th style="width:360px">素材库</th><th style="width:140px">最近发布</th><th style="width:190px">操作</th>' +
|
||||
'</tr></thead><tbody>' +
|
||||
(rows || '<tr><td colspan="6" class="empty">' +
|
||||
(rows || '<tr><td colspan="7" class="empty">' +
|
||||
((F.device || F.q || F.status) ? '没有符合筛选条件的账号 —— 点「清除筛选」看全部'
|
||||
: '还没有账号 —— 先「导入/维护账号库」,再「批量上传素材」') +
|
||||
'</td></tr>') +
|
||||
@@ -433,6 +441,40 @@ async function afAssetSetDevice(rosterId, deviceName) {
|
||||
await afRefreshAll();
|
||||
}
|
||||
|
||||
// 人工标记:人工判断优先于任务自动检测的 account_status;自动检测只改自动列。
|
||||
var AF_MANUAL_OPTS = [
|
||||
['', '未标记'],
|
||||
['账号异常', '账号异常'],
|
||||
['作品异常', '作品异常'],
|
||||
['账号限流', '账号限流'],
|
||||
['账号正常', '账号正常']
|
||||
];
|
||||
function afManualStatusHtml(a) {
|
||||
if (!a.in_roster) return '<span class="text-muted">—</span>';
|
||||
var cur = a.manual_status || '';
|
||||
var opts = AF_MANUAL_OPTS.slice();
|
||||
if (cur && !opts.some(function (o) { return o[0] === cur; })) opts.unshift([cur, cur]);
|
||||
var bad = cur.indexOf('异常') >= 0;
|
||||
var style = 'width:120px' + (bad ? ';border-color:#c0392b;color:#c0392b;font-weight:600' : '');
|
||||
return '<select class="form-control" style="' + style + '" title="人工标记优先于自动状态" ' +
|
||||
'onchange="afSaveManualStatus(\'' + esc(a.roster_id) + '\', this.value)">' +
|
||||
opts.map(function (o) {
|
||||
return '<option value="' + esc(o[0]) + '"' + (o[0] === cur ? ' selected' : '') + '>' +
|
||||
esc(o[1]) + '</option>';
|
||||
}).join('') + '</select>';
|
||||
}
|
||||
async function afSaveManualStatus(rosterId, status) {
|
||||
const r = await apiPut('/api/af/roster/' + encodeURIComponent(rosterId),
|
||||
{manual_status: status});
|
||||
if (!r || !r.ok) {
|
||||
showToast((r && r.error) || '保存人工标记失败', 'error');
|
||||
await afRefreshAll();
|
||||
return;
|
||||
}
|
||||
showToast(status ? ('人工标记:' + status) : '已清除人工标记', 'success');
|
||||
await afRefreshAll();
|
||||
}
|
||||
|
||||
// 账号状态:手动编辑(任务里「读取文字」写变量 account_status 时也会自动回写这列)
|
||||
function afAssetEditStatus(rosterId, name, cur) {
|
||||
const v = prompt('『' + name + '』的账号状态(正常 / 账号异常 / 限流…;留空=清空)', cur || '');
|
||||
|
||||
Reference in New Issue
Block a user