## 修复清单
### 后端路由修复
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= ✅
104 lines
4.6 KiB
HTML
104 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=0" />
|
|
<title>GoChat Widget</title>
|
|
<script>
|
|
(function () {
|
|
var cfg = window.__GOCHAT_CONFIG__ || {};
|
|
window.chatwootConfig = Object.assign(
|
|
{
|
|
hostURL: '',
|
|
helpCenterURL: '',
|
|
fbAppId: '',
|
|
instagramAppId: '',
|
|
tiktokAppId: '',
|
|
googleOAuthClientId: '',
|
|
googleOAuthCallbackUrl: '',
|
|
allowedLoginMethods: ['email'],
|
|
fbApiVersion: '',
|
|
whatsappAppId: '',
|
|
whatsappConfigurationId: '',
|
|
whatsappApiVersion: '',
|
|
signupEnabled: 'false',
|
|
isMfaEnabled: 'false',
|
|
inboxEventsEnabled: 'false',
|
|
selectedLocale: 'zh_CN',
|
|
enabledLanguages: [
|
|
{ name: '中文', iso_639_1_code: 'zh_CN' },
|
|
{ name: 'English', iso_639_1_code: 'en' },
|
|
],
|
|
helpUrls: {},
|
|
},
|
|
cfg
|
|
);
|
|
window.globalConfig = Object.assign(
|
|
{
|
|
INSTALLATION_NAME: 'GoChat',
|
|
CREATE_NEW_ACCOUNT_FROM_DASHBOARD: false,
|
|
DISPLAY_MANIFEST: false,
|
|
LOGO_THUMBNAIL: '/favicon-32x32.png',
|
|
},
|
|
cfg.globalConfig || {}
|
|
);
|
|
window.errorLoggingConfig = '';
|
|
window.browserConfig = { browser_name: navigator.userAgent };
|
|
|
|
// Initialize widget channel config from URL params
|
|
(function() {
|
|
var params = new URLSearchParams(window.location.search);
|
|
var websiteToken = params.get('website_token');
|
|
if (!websiteToken) return;
|
|
window.chatwootWebChannel = {
|
|
websiteToken: websiteToken,
|
|
locale: params.get('locale') || 'zh_CN',
|
|
widgetColor: '#1f93ff',
|
|
enabledLanguages: window.chatwootConfig.enabledLanguages || [],
|
|
workingHours: [],
|
|
workingHoursEnabled: false,
|
|
utcOffset: '+08:00',
|
|
replyTime: 'in_a_few_minutes',
|
|
enabledFeatures: ['attachments', 'emoji', 'end_conversation'],
|
|
allowMessageAfterResolved: true,
|
|
preChatFormEnabled: false,
|
|
preChatFormOptions: {},
|
|
businessHoursEnabled: false,
|
|
offlineMessageEnabled: true,
|
|
hmacEnabled: false,
|
|
portal: null,
|
|
};
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/api/v1/widget/config', true);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.onload = function() {
|
|
if (xhr.status === 200) {
|
|
try {
|
|
var config = JSON.parse(xhr.responseText);
|
|
if (config.widgetColor) window.chatwootWebChannel.widgetColor = config.widgetColor;
|
|
if (config.enabledLanguages) window.chatwootWebChannel.enabledLanguages = config.enabledLanguages;
|
|
if (config.workingHours) window.chatwootWebChannel.workingHours = config.workingHours;
|
|
if (config.workingHoursEnabled !== undefined) window.chatwootWebChannel.workingHoursEnabled = config.workingHoursEnabled;
|
|
if (config.replyTime) window.chatwootWebChannel.replyTime = config.replyTime;
|
|
if (config.preChatFormEnabled !== undefined) window.chatwootWebChannel.preChatFormEnabled = config.preChatFormEnabled;
|
|
if (config.businessHoursEnabled !== undefined) window.chatwootWebChannel.businessHoursEnabled = config.businessHoursEnabled;
|
|
if (config.offlineMessageEnabled !== undefined) window.chatwootWebChannel.offlineMessageEnabled = config.offlineMessageEnabled;
|
|
if (config.portal) window.chatwootWebChannel.portal = config.portal;
|
|
if (config.enabledFeatures) window.chatwootWebChannel.enabledFeatures = config.enabledFeatures;
|
|
if (config.allowMessageAfterResolved !== undefined) window.chatwootWebChannel.allowMessageAfterResolved = config.allowMessageAfterResolved;
|
|
if (config.hmacEnabled !== undefined) window.chatwootWebChannel.hmacEnabled = config.hmacEnabled;
|
|
} catch(e) {}
|
|
}
|
|
};
|
|
xhr.send('{"website_token":"' + websiteToken + '"}');
|
|
})();
|
|
})();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="app"></div>
|
|
<noscript id="noscript">This app works best with JavaScript enabled.</noscript>
|
|
<script type="module" src="/app/javascript/entrypoints/widget.js"></script>
|
|
</body>
|
|
</html>
|