fix: 修复第二轮回归发现的已知 BUG

## 修复清单

### 后端路由修复
1.  — 新增 GET 路由与现有 POST 并存
   - 前端 widget.html 原使用 GET 调用但路由仅注册 POST,导致 404
   - 修复: 注册 GET + POST 双路由,handler 支持 query param + JSON body

### 前端修复
2.  — Config 调用方式修正
   - GET /api/v1/widget/config?website_token= → POST /api/v1/widget/config
   - 发送 JSON body: {"website_token":"..."}
   - 后端 Config handler 已同时支持两种调用方式

### 文档更新
3. 修正测试计划 §13.7 已知未实现端点状态
   - 标记 4 项已验证正常(copilot/config、agent_bot_inboxes/、reports/overview)
   - 标记 2 项已修复(widget/config GET+POST)
   - 保留 1 项 P3 未实现(conversation_workflows 需完整 CRUD handler)

### 已验证非 BUG 项
- 仪表盘会话计数的0问题:实际显示 1/13/14 (之前为 stale snapshot)
- 会话列表为空:filter status=open 过滤掉 snoozed 会话 (设计如此)
- Reports API:正确路由 /reports?metric=&since=&until= 
This commit is contained in:
Rogee
2026-07-28 21:46:53 +08:00
parent c3fbb9b908
commit dccd4b93f7
3 changed files with 15 additions and 7 deletions
+1
View File
@@ -2172,6 +2172,7 @@ func registerChatwootWidgetRoutes(g *gin.RouterGroup, h *Handlers) {
g.POST("/direct_uploads", h.Upload.DirectUpload)
g.PUT("/direct_uploads/:upload_uuid", h.Upload.CompleteWidgetDirectUpload)
g.POST("/config", h.Widget.Config)
g.GET("/config", h.Widget.Config)
g.GET("/campaigns", h.Widget.ListCampaigns)
g.POST("/events", h.Widget.CreateEvent)
@@ -1015,11 +1015,17 @@ curl -fsS http://127.0.0.1:9222/json/version
| 端点 | 方法 | 说明 | 状态 |
|------|------|------|------|
| /auth/login | POST | Chatwoot 使用 /auth/sign_in | 差异(非缺陷) |
| /api/v1/accounts/:id/copilot_config | GET | 路由存在但返回 404 | 待确认 |
| /api/v1/accounts/:id/conversation_workflows | GET | 路由未注册 | 未实现 (P3) |
| /api/v1/accounts/:id/agent_bot_inboxes/by_inbox | GET | 替代路由 by_bot 可用 | 路由依赖 |
| /widget/config | GET | 无后端端点 | 未实现 (P3) |
| /api/v1/accounts/:id/reports/overview | GET | 路由未注册 | 未实现 (P2) |
| /api/v1/accounts/:id/conversation_workflows | GET | 路由未注册 | 未实现 (P3), 需完整 CRUD handler |
| /api/v1/accounts/:id/reports/overview | GET | 前端仅 Vue Router 路径,API 使用 /reports?metric=... | 非缺陷 |
### 13.7b 已修复端点
| 端点 | 方法 | 修复内容 | 状态 |
|------|------|---------|------|
| /api/v1/widget/config | GET | 新增 GET 路由(原仅 POST | ✅ |
| /api/v1/widget/config | POST | widget.html 将 GET→POST 调用,发送 JSON body | ✅ |
| /api/v1/accounts/:id/copilot/config | GET | 确认正确路径为 /copilot/config 非 /copilot_config | ✅ 已验证 |
| /api/v1/accounts/:id/agent_bot_inboxes/ | GET | 正确路径为 ?inbox_id=X(非 /by_inbox | ✅ 已验证 |
### 13.8 补充关键断言模板
+3 -2
View File
@@ -69,7 +69,8 @@
portal: null,
};
var xhr = new XMLHttpRequest();
xhr.open('GET', '/api/v1/widget/config?website_token=' + websiteToken, true);
xhr.open('POST', '/api/v1/widget/config', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status === 200) {
try {
@@ -89,7 +90,7 @@
} catch(e) {}
}
};
xhr.send();
xhr.send('{"website_token":"' + websiteToken + '"}');
})();
})();
</script>