chore: 去掉脚本 BOM;登录校验复用统一客户端;login.bat 不再强依赖环境变量

This commit is contained in:
houhuan committed 2026-11-16 12:54:30 +08:00
1 parent 92bd4e1b59
commit 73462d94a0
4 files changed
+19 -34

No files matched your search

+14 -23
View File
@@ -70,29 +70,20 @@ def login_with_browser(login_url: str) -> dict[str, str] | None:
return cookies
def verify(cookies: dict[str, str]) -> bool:
def verify(cfg, cookies: dict[str, str]) -> bool:
"""本地先验一次,避免把坏 Cookie 推上去。"""
import requests as _rq
resp = _rq.post(
"https://fs.szfx.com/saasmerchant/pcweb/order/quickpayorder/list",
json={"shopId": "20434543575189", "page": 1, "pageSize": 1},
headers={
"Content-Type": "application/json",
"Referer": MMS_BASE,
"Origin": "https://fs.szfx.com",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
},
cookies=cookies,
timeout=20,
)
data = resp.json()
if data.get("errno") == 0:
orders = (data.get("data") or {}).get("list") or []
latest = orders[0].get("orderId") if orders else None
print(f" Cookie 校验通过(最新订单 {latest})")
return True
print(f" Cookie 校验失败:errno={data.get('errno')} {data.get('errmsg')}", file=sys.stderr)
return False
from fengxiang.client import FengxiangClient, FengxiangError
client = FengxiangClient(cfg)
client.set_cookies(cookies)
try:
orders = client.list_orders(page_size=1)
except FengxiangError as exc:
print(f" Cookie 校验失败:{exc}", file=sys.stderr)
return False
latest = orders[0].get("orderId") if orders else None
print(f" Cookie 校验通过(最新订单 {latest})")
return True
def upload(server: str, token: str, cookies: dict[str, str]) -> bool:
@@ -122,7 +113,7 @@ def main() -> int:
if not cookies:
return 1
if not verify(cookies):
if not verify(cfg, cookies):
print("Cookie 不可用,未保存。", file=sys.stderr)
return 2
+1 -1
View File
@@ -1,4 +1,4 @@
"""本地 TTS 语音播报(IndexTTS2),仅 Windows 本地模式使用。
"""本地 TTS 语音播报(IndexTTS2),仅 Windows 本地模式使用。
服务器/容器不会启用(无 torch、无声卡),由 fengxiang.tts.Speaker 在非 win32 平台直接跳过。
+3 -9
View File
@@ -20,20 +20,14 @@ if errorlevel 1 (
"%PYTHON%" -m playwright install chromium
)
:: 服务器地址与 token:优先用环境变量,也可直接改下面两行
:: 服务器地址:优先用环境变量,也可直接改这一行
if not defined FX_SERVER set "FX_SERVER=http://192.168.8.210:52100"
if not defined FX_ADMIN_TOKEN (
echo [错误] 请先设置管理接口 token,例如:
echo set FX_ADMIN_TOKEN=你的token
echo token 与服务器 config.yaml 里 admin.token 一致
pause
exit /b 1
)
:: 上传用的 token 自动从本地 config.yaml 的 admin.token 读取;也可用 FX_ADMIN_TOKEN 覆盖
echo [1/2] 打开浏览器登录丰享...
echo.
"%PYTHON%" fengxiang_scraper.py --upload --server "%FX_SERVER%"
echo.
echo [2/2] 完成。若提示上传失败,请检查服务器地址/token。
echo [2/2] 完成。若提示上传失败,请检查服务器地址 / config.yaml 里的 admin.token。
pause
+1 -1
View File
@@ -1,4 +1,4 @@
@echo off
@echo off
chcp 65001 >nul
title 丰享订单监控 v5
cd /d "%~dp0"