chore(addon/aikefu): 只允许info及error的日志输出

This commit is contained in:
2025-12-10 11:46:20 +08:00
parent 99628f1d18
commit 7b6a8500b0
2 changed files with 45 additions and 16 deletions

View File

@@ -358,6 +358,10 @@ class Kefu extends BaseApi
*/
private function log($message, $level = 'info')
{
// 只允许info、error级别
if (!in_array($level, ['info', 'error'])) {
return;
}
log_write($message, $level, '', 2);
}

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -12,20 +13,24 @@
padding: 20px;
background-color: #f5f5f5;
}
.container {
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 20px;
}
h1 {
text-align: center;
color: #333;
}
.method-selector {
margin-bottom: 20px;
text-align: center;
}
.method-btn {
padding: 10px 20px;
margin: 0 10px;
@@ -36,9 +41,11 @@
cursor: pointer;
font-size: 14px;
}
.method-btn.active {
background-color: #0056b3;
}
#chat-container {
border: 1px solid #ddd;
border-radius: 4px;
@@ -48,27 +55,32 @@
padding: 10px;
background-color: #fafafa;
}
.message {
margin-bottom: 15px;
padding: 10px;
border-radius: 8px;
max-width: 80%;
}
.user-message {
background-color: #007bff;
color: white;
margin-left: auto;
}
.ai-message {
background-color: #e9ecef;
color: #333;
margin-right: auto;
white-space: pre-wrap;
}
.input-area {
display: flex;
gap: 10px;
}
#message-input {
flex: 1;
padding: 12px;
@@ -76,6 +88,7 @@
border-radius: 4px;
font-size: 14px;
}
#send-btn {
padding: 12px 20px;
background-color: #28a745;
@@ -85,10 +98,12 @@
cursor: pointer;
font-size: 14px;
}
#send-btn:disabled {
background-color: #6c757d;
cursor: not-allowed;
}
.status {
margin-top: 10px;
font-size: 12px;
@@ -97,6 +112,7 @@
}
</style>
</head>
<body>
<div class="container">
<h1>流式聊天测试 Demo</h1>
@@ -244,10 +260,18 @@
// 监听错误事件
es.addEventListener('error', (error) => {
console.error('EventSource 错误:', error);
// 添加更详细的错误信息
if (es.readyState === EventSource.CLOSED) {
console.error('EventSource 连接已关闭');
} else if (es.readyState === EventSource.CONNECTING) {
console.error('EventSource 连接中出现错误');
}
statusText.textContent = '连接错误';
sendBtn.disabled = false;
if (es) {
es.close();
es = null;
}
});
// 监听关闭事件
@@ -433,4 +457,5 @@
statusText.textContent = '就绪,使用 EventSource 方式';
</script>
</body>
</html>