feat(资产管理): 账号状态列 + 任务变量回写;通用任务 App 回退
- device_account 新增 account_status(schema v21),资产表可手改 - 任务「读取文字」var=account_status 自动回写当前账号;元素不存在=正常 - 计划:任务段没有 open_app 时回退到唯一 App(创作者中心这类通用任务) - 测试/文档同步
This commit is contained in:
@@ -171,6 +171,7 @@ def list_accounts(prof=None):
|
||||
"unscanned": max(0, media - total),
|
||||
"has_dir": has_dir,
|
||||
"device_name": rr.get("device_name") or "",
|
||||
"account_status": rr.get("account_status") or "",
|
||||
"serial": rr.get("serial") or "",
|
||||
"pooled": bool(rr.get("pooled")),
|
||||
"online": bool(rr.get("online")),
|
||||
@@ -1142,6 +1143,28 @@ def roster_rows():
|
||||
return out
|
||||
|
||||
|
||||
def set_account_status(name, status=""):
|
||||
"""按账号名写账号库的「账号状态」(任务变量回写用)。
|
||||
|
||||
名字先精确匹配昵称,再按抖音号兜底;账号库里没有这个号 → 返回 False(**不新建行**)。
|
||||
供任务里的「读取文字」在变量名是 `account_status` 时调用:读到什么写什么,
|
||||
读不到(元素不存在)写「正常」。
|
||||
"""
|
||||
from core.models import db, DeviceAccount
|
||||
key = (name or "").strip()
|
||||
if not key:
|
||||
return False
|
||||
with _ctx():
|
||||
row = (DeviceAccount.query.filter_by(nickname=key).first()
|
||||
or DeviceAccount.query.filter_by(douyin_id=key).first())
|
||||
if row is None:
|
||||
return False
|
||||
row.account_status = (status or "").strip()[:80]
|
||||
row.updated_at = _now()
|
||||
db.session.commit()
|
||||
return True
|
||||
|
||||
|
||||
def device_of_name(name, rows=None):
|
||||
"""账号名 → 设备信息。**精确匹配名字**;名字对不上时再拿抖音号试一次。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user