refactor: 完成v6.5.28版本迭代,修复多项体验问题
主要变更: 1. 重构多处Provider初始化逻辑,使用Future.microtask避免build阶段修改state 2. 重命名"灵感"模块为"工作流","天气诗词"改为"情景诗词" 3. 新增插件系统页面与路由,添加speech_to_text_windows插件支持 4. 优化玻璃容器性能,添加性能节流与模糊值适配 5. 新增离线横幅、阅读体验控制器、手势控制器等组件 6. 完善头像审核状态展示与缓存管理 7. 修复键盘弹出与页面路由问题 8. 更新依赖与项目配置,优化widget默认数据
This commit is contained in:
122
scripts/verify_wallpaper_api.py
Normal file
122
scripts/verify_wallpaper_api.py
Normal file
@@ -0,0 +1,122 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 创建时间: 2026-05-25
|
||||
# 更新时间: 2026-05-25
|
||||
# 名称: verify_wallpaper_api.py
|
||||
# 作用: 验证壁纸API接口的可用性,测试12个端点的响应状态、耗时和数据
|
||||
# 上次更新内容: 初始创建,支持12个壁纸API端点验证
|
||||
|
||||
import requests
|
||||
import time
|
||||
import json
|
||||
|
||||
BASE_URL = "http://bz.wktyl.com"
|
||||
TIMEOUT = 5
|
||||
LIMIT = 2
|
||||
PAGE = 1
|
||||
|
||||
ENDPOINTS = [
|
||||
"/api_unsplash.php",
|
||||
"/api_wallstreet.php",
|
||||
"/api_pexels.php",
|
||||
"/api_pixabay.php",
|
||||
"/api_360_bing.php?source=360",
|
||||
"/api_360_bing.php?source=bing",
|
||||
"/api_nasa.php",
|
||||
"/api_hao_wallpaper.php",
|
||||
"/api_bizhiduoduo.php?action=random",
|
||||
"/api_bing_enhanced.php",
|
||||
"/api_anime_pictures.php",
|
||||
"/api_dmoe.php",
|
||||
]
|
||||
|
||||
|
||||
def test_endpoint(endpoint):
|
||||
url = f"{BASE_URL}{endpoint}"
|
||||
params = {"limit": LIMIT, "page": PAGE}
|
||||
result = {
|
||||
"endpoint": endpoint,
|
||||
"status_code": None,
|
||||
"response_time": None,
|
||||
"data_count": None,
|
||||
"success": None,
|
||||
"error": None,
|
||||
}
|
||||
try:
|
||||
start = time.time()
|
||||
resp = requests.get(url, params=params, timeout=TIMEOUT)
|
||||
elapsed = round((time.time() - start) * 1000, 1)
|
||||
result["status_code"] = resp.status_code
|
||||
result["response_time"] = elapsed
|
||||
try:
|
||||
data = resp.json()
|
||||
result["success"] = data.get("success", data.get("code", None))
|
||||
items = data.get("data", data.get("result", data.get("images", data.get("wallpapers", data.get("list", [])))))
|
||||
if isinstance(items, list):
|
||||
result["data_count"] = len(items)
|
||||
elif isinstance(items, dict):
|
||||
result["data_count"] = 1
|
||||
else:
|
||||
result["data_count"] = 0
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
result["data_count"] = 0
|
||||
result["success"] = None
|
||||
except requests.exceptions.Timeout:
|
||||
result["error"] = "超时(>{0}s)".format(TIMEOUT)
|
||||
except requests.exceptions.ConnectionError:
|
||||
result["error"] = "连接失败"
|
||||
except requests.exceptions.RequestException as e:
|
||||
result["error"] = str(e)[:40]
|
||||
return result
|
||||
|
||||
|
||||
def print_table(results):
|
||||
header = f"{'序号':<4} {'接口端点':<38} {'状态码':<8} {'耗时(ms)':<10} {'数据条数':<10} {'success':<10} {'错误':<12}"
|
||||
sep = "-" * len(header)
|
||||
print(sep)
|
||||
print(header)
|
||||
print(sep)
|
||||
for i, r in enumerate(results, 1):
|
||||
status = str(r["status_code"]) if r["status_code"] is not None else "-"
|
||||
rt = str(r["response_time"]) if r["response_time"] is not None else "-"
|
||||
dc = str(r["data_count"]) if r["data_count"] is not None else "-"
|
||||
sc = str(r["success"]) if r["success"] is not None else "-"
|
||||
err = r["error"] or "-"
|
||||
print(f"{i:<4} {r['endpoint']:<38} {status:<8} {rt:<10} {dc:<10} {sc:<10} {err:<12}")
|
||||
print(sep)
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 96)
|
||||
print(" 壁纸API接口验证脚本")
|
||||
print(f" Base URL: {BASE_URL} | limit={LIMIT} page={PAGE} timeout={TIMEOUT}s")
|
||||
print("=" * 96)
|
||||
print()
|
||||
|
||||
results = []
|
||||
for ep in ENDPOINTS:
|
||||
print(f" 正在测试: {ep} ...", end="", flush=True)
|
||||
r = test_endpoint(ep)
|
||||
results.append(r)
|
||||
tag = "✓" if r["status_code"] == 200 and r["error"] is None else "✗"
|
||||
rt = f"{r['response_time']}ms" if r["response_time"] else r["error"]
|
||||
print(f" {tag} {rt}")
|
||||
|
||||
print()
|
||||
print_table(results)
|
||||
|
||||
success = sum(1 for r in results if r["status_code"] == 200 and r["error"] is None)
|
||||
fail = len(results) - success
|
||||
print()
|
||||
print(f" 汇总: 共 {len(results)} 个接口 | 成功: {success} | 失败: {fail}")
|
||||
print()
|
||||
|
||||
if fail > 0:
|
||||
print(" 失败接口详情:")
|
||||
for r in results:
|
||||
if r["status_code"] != 200 or r["error"] is not None:
|
||||
print(f" - {r['endpoint']} => 状态码={r['status_code']} 错误={r['error']}")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user