Compare commits

...

7 Commits

3 changed files with 72 additions and 9 deletions

View File

@@ -276,6 +276,20 @@ def init_db():
]
for key, value, desc in default_configs:
cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc))
else:
# 检查并添加缺失的配置项(兼容旧数据库)
default_configs = [
('app_developer', 'OpenClaw Team', '开发者'),
('app_update_date', '2026-04-27', '更新日期'),
('app_technology', '智谱 GLM-4.5-Air 大模型', '技术基础'),
('app_description', '提供智能对话、多种智能体服务', '应用简介'),
('privacy_policy_url', '', '隐私政策链接'),
('user_agreement_url', '', '用户协议链接'),
]
for key, value, desc in default_configs:
cursor.execute('SELECT COUNT(*) FROM system_configs WHERE key=?', (key,))
if cursor.fetchone()[0] == 0:
cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc))
# 初始化管理员账户
cursor.execute('SELECT COUNT(*) FROM admin_users')

View File

@@ -124,6 +124,19 @@ async function loadBackendConfig() {
// 不加载默认启用的工具,所有工具默认未启用
// 将后台系统配置赋值到 CONFIG
if (backendConfig.system) {
CONFIG.system = backendConfig.system;
}
// 将后台 LLM 配置赋值到 CONFIG
if (backendConfig.llm) {
CONFIG.apiUrl = backendConfig.llm.api_url;
CONFIG.apiKey = backendConfig.llm.api_key;
CONFIG.model = backendConfig.llm.model;
CONFIG.maxTokens = backendConfig.llm.max_tokens || 2048;
}
updateAgentsDisplay();
console.log('后台配置已加载', backendConfig);
} catch (e) {
@@ -789,7 +802,7 @@ function renderAgentsPage() {
<div class="recent-agent-item" data-conv-id="${conv.id}">
<div class="recent-agent-left">
<span class="recent-agent-avatar">${conv.agent ? conv.agent.avatar : '🤖'}</span>
<span class="recent-agent-name">${conv.title}</span>
<span class="recent-agent-title">${conv.title}</span>
</div>
<div class="recent-agent-right">
<span class="recent-agent-agent-name">${conv.agent ? conv.agent.name : '未知智能体'}</span>
@@ -1324,6 +1337,7 @@ function filterDiscoverAgents(keyword) {
if (!keyword) {
// 显示所有
showDiscoverSection('hot', systemAgents.filter(a => a.category === 'hot'));
showDiscoverSection('basic', systemAgents.filter(a => a.category === 'basic'));
showDiscoverSection('work', systemAgents.filter(a => a.category === 'work'));
showDiscoverSection('study', systemAgents.filter(a => a.category === 'study'));
showDiscoverSection('life', systemAgents.filter(a => a.category === 'life'));
@@ -1338,6 +1352,7 @@ function filterDiscoverAgents(keyword) {
// 显示搜索结果
showDiscoverSection('hot', filtered.filter(a => a.category === 'hot'));
showDiscoverSection('basic', filtered.filter(a => a.category === 'basic'));
showDiscoverSection('work', filtered.filter(a => a.category === 'work'));
showDiscoverSection('study', filtered.filter(a => a.category === 'study'));
showDiscoverSection('life', filtered.filter(a => a.category === 'life'));
@@ -2611,7 +2626,12 @@ function showAboutPage() {
const privacyPolicyBtn = document.getElementById('privacyPolicyBtn');
if (privacyPolicyBtn) {
privacyPolicyBtn.addEventListener('click', () => {
showToast('隐私政策页面待完善');
const privacyUrl = CONFIG?.system?.privacyPolicyUrl;
if (privacyUrl) {
window.open(privacyUrl, '_blank');
} else {
showToast('隐私政策链接未配置');
}
});
}
@@ -2619,7 +2639,12 @@ function showAboutPage() {
const userAgreementBtn = document.getElementById('userAgreementBtn');
if (userAgreementBtn) {
userAgreementBtn.addEventListener('click', () => {
showToast('用户协议页面待完善');
const agreementUrl = CONFIG?.system?.userAgreementUrl;
if (agreementUrl) {
window.open(agreementUrl, '_blank');
} else {
showToast('用户协议链接未配置');
}
});
}
}
@@ -3003,10 +3028,10 @@ function showAgentHistoryPage() {
<div class="agent-history-item" data-conv-id="${conv.id}">
<div class="agent-history-left">
<span class="agent-history-avatar">${conv.agent ? conv.agent.avatar : '🤖'}</span>
<span class="agent-history-name">${conv.title}</span>
<span class="agent-history-title">${conv.title}</span>
</div>
<div class="agent-history-right">
<span class="agent-history-agent">${conv.agent ? conv.agent.name : '未知智能体'}</span>
<span class="agent-history-agent-name">${conv.agent ? conv.agent.name : '未知智能体'}</span>
<span class="agent-history-time">${formatTime(conv.updatedAt)}</span>
</div>
</div>
@@ -3087,7 +3112,7 @@ async function openAgent(agentId) {
// 创建新对话并设置智能体
const newConv = {
id: backendId || Date.now().toString(),
title: currentAgent.name,
title: '新对话', // 和普通对话一样,初始标题为"新对话",后续自动生成
messages: [],
agentId: agentId,
createdAt: Date.now(),
@@ -4541,7 +4566,11 @@ function renderMessages() {
messagesDiv.innerHTML = currentConversation.messages.map((msg, index) => {
const isUser = msg.role === 'user';
const avatar = isUser ? '👤' : '🤖';
// 用户头像使用实际头像AI头像使用智能体头像或默认
const avatar = isUser
? (currentUser?.avatar || '👤')
: (currentAgent?.avatar || '🤖');
const avatarHtml = isUser ? renderAvatar(avatar) : avatar;
// 处理消息内容(支持图片)
let contentHtml = '';
@@ -4616,7 +4645,7 @@ function renderMessages() {
return `
<div class="message ${msg.role}" data-index="${index}">
<div class="message-avatar">${avatar}</div>
<div class="message-avatar">${avatarHtml}</div>
<div class="message-body">
${searchHtml}
${thinkingHtml}

View File

@@ -1730,6 +1730,16 @@ body {
color: var(--primary);
}
.recent-agent-title {
font-size: 14px;
color: #333;
font-weight: 500;
max-width: 120px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.recent-agent-agent-name {
font-size: 12px;
color: var(--primary);
@@ -1807,7 +1817,17 @@ body {
color: var(--primary);
}
.agent-history-agent {
.agent-history-title {
font-size: 14px;
color: #333;
font-weight: 500;
max-width: 150px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.agent-history-agent-name {
font-size: 12px;
color: var(--primary);
background: rgba(102, 126, 234, 0.1);