站点配置(百世密码/韵达账密/安能路径)从 config.yaml 移至 state.db
- state_store:加 site_settings(site,key,value) 表 + get_setting/set_setting/get_site_settings
- runtime:seed_legacy_config 启动一次性从 config.yaml 灌入(已存在不覆盖);安能 app_path 改读 state_store
- site_baishi:导出密码改读 get_setting("百世","password")
- site_yunda:登录账密改读 get_setting("韵达",...)
- server:/config PUT 接受 settings;新增 GET /config/{site}/settings(不进 5s 轮询)
debug 仍保留在 config.yaml;站点配置现由前端配置弹窗管理(state.db 为准)。
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import yaml
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
from paths import DOWNLOAD_DIR, CONFIG_PATH
|
||||
import state_store
|
||||
|
||||
|
||||
def with_retry(site_name, label, flow, reset, max_attempts=3):
|
||||
@@ -143,21 +144,11 @@ def baishi_download_undelivered_data_impl(page):
|
||||
# 验证模态框弹出
|
||||
page.locator(".ant-modal-title", has_text="导出设置").wait_for(state="visible")
|
||||
|
||||
# 4. 加载 YAML 配置并输入密码
|
||||
# 4. 读取百世导出密码(存 state.db,由前端站点配置)
|
||||
print(">> 正在读取配置并填写密码...")
|
||||
password = ""
|
||||
try:
|
||||
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
|
||||
config = yaml.safe_load(f)
|
||||
password = config.get("baishi", {}).get("password", "")
|
||||
|
||||
if not password:
|
||||
print(
|
||||
" ⚠️ 警告:在 config.yaml 中未找到百世的登录密码,可能导致导出失败。"
|
||||
)
|
||||
except Exception as e:
|
||||
print(f" ⚠️ 读取 config.yaml 失败,请确保文件存在且格式正确: {e}")
|
||||
return False
|
||||
password = state_store.get_setting("百世", "password")
|
||||
if not password:
|
||||
print(" ⚠️ 警告:未设置百世导出密码(前端站点配置),可能导致导出失败。")
|
||||
|
||||
page.get_by_placeholder("请输入登录密码").fill(password)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user