feat: 完成T-501c Shopee更新安全开关

新增 shopee_update 配置段,默认关闭真实提交和封面更新,限制测试商品ID、单次最大更新条数,并支持成功后关闭本轮自动新开编辑页。

Tab⑤ 设置页新增 Shopee 更新安全表单;Tab③ 开始更新前先读取安全配置并阻断未授权真实提交、超量、非测试商品和未允许的封面更新。

ApplyWorker 将 close_success_tab 传入 editor.apply_task;editor 仅在提交成功且页面为本轮自动新开时关闭 tab,失败和复用页面保留。

同步架构、API、路由、任务看板、当前状态与 progress 文档;补充 GUI 与 editor 单测覆盖安全设置保存、共享配置读取、安全拦截和 tab 关闭策略。
This commit is contained in:
chengma
2026-06-29 09:18:03 +08:00
parent 91683abe7d
commit b05a856796
11 changed files with 453 additions and 42 deletions
+18 -2
View File
@@ -472,7 +472,7 @@ def click_update(cdp) -> dict:
}
def apply_task(account, task) -> dict:
def apply_task(account, task, close_success_tab=False) -> dict:
"""Apply generated title/cover to Shopee.
The caller must perform the batch confirmation before calling this function.
@@ -480,6 +480,7 @@ def apply_task(account, task) -> dict:
item_id = _item_id(task)
cdp = open_product(account, item_id)
committed = False
try:
title_result = None
cover_result = None
@@ -494,8 +495,9 @@ def apply_task(account, task) -> dict:
if not cover_result.get("ok"):
return {"committed": False, "error": cover_result.get("reason"), "cover": cover_result}
update_result = click_update(cdp)
committed = bool(update_result.get("clicked", False))
return {
"committed": update_result.get("clicked", False),
"committed": committed,
"error": update_result.get("reason"),
"title": title_result,
"cover": cover_result,
@@ -504,4 +506,18 @@ def apply_task(account, task) -> dict:
except Exception as exc:
return {"committed": False, "error": str(exc)}
finally:
_close_applied_product(cdp, close_success_tab=close_success_tab and committed)
def _close_applied_product(cdp, close_success_tab=False):
target_id = getattr(cdp, "target_id", None)
created_by_app = bool(getattr(cdp, "created_by_app", False))
host = getattr(cdp, "cdp_host", None)
try:
cdp.close()
finally:
if close_success_tab and created_by_app and target_id:
try:
close_tab(target_id, host=host)
except Exception:
pass