refactor(home-api): 统一首页API响应格式并迁移配套代码

完成首页数据模型的统一重构,具体变更如下:
1.  重构公共首页API接口,移除`playRecommendations`字段,将玩法推荐数据统一放入`experiences`字段
2.  更新前后端类型定义、序列化逻辑与前端页面组件,适配新的API响应结构
3.  为微信登录相关接口添加`trust_env=True`配置,支持企业代理环境并新增`socksio`依赖
4.  新增图片画廊上传组件,重构SingleImageUploader组件支持自定义宽高比
5.  重构Toast与Select组件的实现与样式,统一后台UI设计系统
6.  移除个人中心页面不必要的返回事件与顶部标题组件,优化详情卡片布局
7.  新增微信接口单元测试,更新官方文档与测试用例适配变更
8.  删除过期的文档图片资源
This commit is contained in:
duanshuwen committed 2026-08-20 21:18:27 +08:00
1 parent d3a246a873
commit 6296392e80
27 files changed
+1055 -218

No files matched your search

+5 -14
View File
@@ -381,7 +381,7 @@ def test_admin_home_wanfa_recommendation_create_links_existing_category():
assert fake_db.added[0].categoryId == "family-route"
def test_public_home_returns_active_wanfa_category_recommendations():
def test_public_home_places_active_wanfa_category_recommendations_in_experiences():
recommendation = make_wanfa_recommendation()
app = create_app()
fake_db = FakeDb(
@@ -399,7 +399,8 @@ def test_public_home_returns_active_wanfa_category_recommendations():
app.dependency_overrides.clear()
assert response.status_code == 200
assert response.json()["data"]["playRecommendations"] == [
payload = response.json()["data"]
assert payload["experiences"] == [
{
"id": "recommendation-1",
"categoryId": "family-route",
@@ -416,6 +417,7 @@ def test_public_home_returns_active_wanfa_category_recommendations():
],
}
]
assert "playRecommendations" not in payload
def test_public_home_returns_rendering_fields_for_all_sections():
@@ -438,17 +440,7 @@ def test_public_home_returns_rendering_fields_for_all_sections():
"code": 200,
"msg": "success",
"data": {
"experiences": [
{
"id": "waterfall-descent",
"badge": "玩过推荐",
"category": "瀑降体验",
"title": "悬崖瀑降",
"englishTitle": "WATERFALL DESCENT",
"image": "https://example.test/waterfall.jpg",
"demandKeyword": "悬崖瀑降",
}
],
"experiences": [],
"teamBuildings": [
{
"id": "wild-challenge",
@@ -468,7 +460,6 @@ def test_public_home_returns_rendering_fields_for_all_sections():
"photoCount": 2,
}
],
"playRecommendations": [],
},
}
+48
View File
@@ -0,0 +1,48 @@
from app import wechat
from app.config import Settings
class FakeResponse:
def __init__(self, payload: dict):
self.payload = payload
def json(self):
return self.payload
def test_get_access_token_uses_configured_process_proxy(monkeypatch):
call = {}
def fake_get(_url, *, params, timeout, **kwargs):
call.update(params=params, timeout=timeout, **kwargs)
return FakeResponse({"access_token": "test-access-token", "expires_in": 7200})
monkeypatch.setattr(wechat.httpx, "get", fake_get)
token = wechat.get_access_token(
Settings(_env_file=None, wechat_miniapp_appid="wx-proxy-test", wechat_miniapp_secret="test-secret")
)
assert token == "test-access-token"
assert call["trust_env"] is True
def test_exchange_phone_code_uses_configured_process_proxy(monkeypatch):
call = {}
def fake_post(_url, *, params, json, timeout, **kwargs):
call.update(params=params, json=json, timeout=timeout, **kwargs)
return FakeResponse(
{
"errcode": 0,
"phone_info": {"phoneNumber": "10000000000"},
}
)
monkeypatch.setattr(wechat, "get_access_token", lambda _settings=None: "test-access-token")
monkeypatch.setattr(wechat.httpx, "post", fake_post)
phone = wechat.exchange_phone_code("phone-code")
assert phone == "10000000000"
assert call["trust_env"] is True