feat: 增强 Agent 系统和完善项目结构
主要改进: - Agent 增强: 订单查询、售后支持、客服路由等功能优化 - 新增语言检测和 Token 管理模块 - 改进 Chatwoot webhook 处理和用户标识 - MCP 服务器增强: 订单 MCP 和 Strapi MCP 功能扩展 - 新增商城客户端、知识库、缓存和同步模块 - 添加多语言提示词系统 (YAML) - 完善项目结构: 整理文档、脚本和测试文件 - 新增调试和测试工具脚本 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -111,6 +111,10 @@
|
||||
✅ 系统状态:所有服务运行正常
|
||||
</div>
|
||||
|
||||
<div id="tokenStatus" class="status testing" style="display: none;">
|
||||
🍪 Token 状态:检测中...
|
||||
</div>
|
||||
|
||||
<div class="info-box">
|
||||
<h3>📝 如何测试</h3>
|
||||
<ol>
|
||||
@@ -126,11 +130,11 @@
|
||||
<p style="color: #666; margin-bottom: 15px;">点击以下问题直接复制到聊天窗口:</p>
|
||||
<ul class="question-list">
|
||||
<li onclick="copyQuestion(this.textContent)">🕐 你们的营业时间是什么?</li>
|
||||
<li onclick="copyQuestion(this.textContent)">📦 我想查询订单状态</li>
|
||||
<li onclick="copyQuestion(this.textContent)">🔍 你们有哪些产品?</li>
|
||||
<li onclick="copyQuestion(this.textContent)">📦 我的订单 202071324 怎么样了?</li>
|
||||
<li onclick="copyQuestion(this.textContent)">🔍 查询订单 202071324</li>
|
||||
<li onclick="copyQuestion(this.textContent)">📞 如何联系客服?</li>
|
||||
<li onclick="copyQuestion(this.textContent)">🛍️ 我想退换货</li>
|
||||
<li onclick="copyQuestion(this.textContent)">💰 支付方式有哪些?</li>
|
||||
<li onclick="copyQuestion(this.textContent)">📦 订单 202071324 的物流信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -174,25 +178,85 @@
|
||||
alert('问题已复制!请粘贴到聊天窗口中发送。');
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== Cookie Token 读取 ====================
|
||||
|
||||
function getCookie(name) {
|
||||
const value = `; ${document.cookie}`;
|
||||
const parts = value.split(`; ${name}=`);
|
||||
if (parts.length === 2) return parts.pop().split(";").shift();
|
||||
return null;
|
||||
}
|
||||
|
||||
function checkToken() {
|
||||
const token = getCookie('token');
|
||||
const statusDiv = document.getElementById('tokenStatus');
|
||||
|
||||
if (token) {
|
||||
statusDiv.style.display = 'block';
|
||||
statusDiv.className = 'status online';
|
||||
statusDiv.innerHTML = `✅ Token 已找到 | 长度: ${token.length} 字符 | 前缀: ${token.substring(0, 20)}...`;
|
||||
// 存储到 window 供后续使用
|
||||
window._chatwootUserToken = token;
|
||||
console.log('✅ Token 已从 Cookie 读取');
|
||||
} else {
|
||||
statusDiv.style.display = 'block';
|
||||
statusDiv.className = 'status testing';
|
||||
statusDiv.innerHTML = '⚠️ 未找到 Token | 请确保已登录商城 | Cookie 名称: token';
|
||||
console.warn('⚠️ 未找到 Token,订单查询功能可能无法使用');
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载时检查 Token
|
||||
window.addEventListener('load', function() {
|
||||
setTimeout(checkToken, 1000);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Chatwoot Widget -->
|
||||
<!-- Chatwoot Widget - 官方集成方式 -->
|
||||
<script>
|
||||
window.chatwootSettings = {"position":"right","type":"expanded_bubble","launcherTitle":"Chat with us"};
|
||||
(function(d,t) {
|
||||
var BASE_URL="http://localhost:3000";
|
||||
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||||
g.src=BASE_URL+"/packs/js/sdk.js";
|
||||
g.defer = true;
|
||||
g.async = true;
|
||||
s.parentNode.insertBefore(g,s);
|
||||
g.onload=function(){
|
||||
window.chatwootSDK.run({
|
||||
websiteToken: '39PNCMvbMk3NvB7uaDNucc6o',
|
||||
baseUrl: BASE_URL
|
||||
})
|
||||
(function(d,t) {
|
||||
var BASE_URL="http://localhost:3000";
|
||||
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||||
g.src=BASE_URL+"/packs/js/sdk.js";
|
||||
g.async = true;
|
||||
s.parentNode.insertBefore(g,s);
|
||||
g.onload=function(){
|
||||
window.chatwootSDK.run({
|
||||
websiteToken: '39PNCMvbMk3NvB7uaDNucc6o',
|
||||
baseUrl: BASE_URL,
|
||||
locale: 'zh_CN',
|
||||
userIdentifier: getCookie('token') || 'web_user_' + Date.now()
|
||||
});
|
||||
|
||||
const userToken = getCookie('token');
|
||||
console.log('✅ Chatwoot Widget 已加载 (官方集成方式)');
|
||||
console.log('Base URL:', BASE_URL);
|
||||
console.log('Website Token: 39PNCMvbMk3NvB7uaDNucc6o');
|
||||
console.log('Locale: zh_CN');
|
||||
console.log('User Identifier:', userToken || 'web_user_' + Date.now());
|
||||
|
||||
// 设置用户信息(可选)
|
||||
setTimeout(function() {
|
||||
const token = getCookie('token');
|
||||
if (token && window.$chatwoot) {
|
||||
window.$chatwoot.setUser('user_' + Date.now(), {
|
||||
email: 'user@example.com',
|
||||
name: 'Website User',
|
||||
phone_number: ''
|
||||
});
|
||||
|
||||
console.log('✅ 用户信息已设置');
|
||||
} else if (!token) {
|
||||
console.warn('⚠️ 未找到 Token');
|
||||
}
|
||||
})(document,"script");
|
||||
}, 2000);
|
||||
}
|
||||
g.onerror=function(){
|
||||
console.error('❌ Chatwoot SDK 加载失败');
|
||||
console.error('请确保 Chatwoot 运行在: ' + BASE_URL);
|
||||
}
|
||||
})(document,"script");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user