Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a56bad11f1 | |||
| 92c187d576 | |||
| 9eeeace88c | |||
| ba5d49005b | |||
| c71f27072a | |||
| 22a109d6c0 | |||
| 0244715a8a | |||
| 1c3f7604c9 | |||
| 0086eaa1d6 | |||
| 8e17ef5e15 | |||
| 773fb89b01 | |||
| 8199773ef6 |
402
backend/app.py
402
backend/app.py
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
AI Chat App - 后台管理服务
|
AI Chat App - 后台管理服务
|
||||||
端口: 19020 (与前端同一端口)
|
端口: 19021 (与前端同一端口)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask import Flask, jsonify, request, send_from_directory
|
from flask import Flask, jsonify, request, send_from_directory
|
||||||
@@ -11,6 +11,7 @@ import json
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import base64
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='../www')
|
app = Flask(__name__, static_folder='../www')
|
||||||
CORS(app)
|
CORS(app)
|
||||||
@@ -18,6 +19,11 @@ CORS(app)
|
|||||||
# 数据库路径
|
# 数据库路径
|
||||||
DB_PATH = os.path.join(os.path.dirname(__file__), 'data.db')
|
DB_PATH = os.path.join(os.path.dirname(__file__), 'data.db')
|
||||||
|
|
||||||
|
# 头像存储目录
|
||||||
|
AVATAR_DIR = os.path.join(os.path.dirname(__file__), 'avatars')
|
||||||
|
if not os.path.exists(AVATAR_DIR):
|
||||||
|
os.makedirs(AVATAR_DIR)
|
||||||
|
|
||||||
# 管理员账户(默认)
|
# 管理员账户(默认)
|
||||||
ADMIN_USERNAME = 'admin'
|
ADMIN_USERNAME = 'admin'
|
||||||
ADMIN_PASSWORD_HASH = hashlib.sha256('admin123'.encode()).hexdigest()
|
ADMIN_PASSWORD_HASH = hashlib.sha256('admin123'.encode()).hexdigest()
|
||||||
@@ -166,6 +172,35 @@ def init_db():
|
|||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
# 用户智能体配置表(我的智能体)
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS user_agents (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
agent_id TEXT NOT NULL,
|
||||||
|
category TEXT NOT NULL,
|
||||||
|
is_pinned INTEGER DEFAULT 0,
|
||||||
|
is_favorite INTEGER DEFAULT 0,
|
||||||
|
added_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id),
|
||||||
|
UNIQUE(user_id, agent_id)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
|
# 对话表(用户对话数据)
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE IF NOT EXISTS conversations (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
title TEXT NOT NULL,
|
||||||
|
agent_id TEXT,
|
||||||
|
messages TEXT NOT NULL DEFAULT '[]',
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
# 初始化默认大模型配置
|
# 初始化默认大模型配置
|
||||||
cursor.execute('SELECT COUNT(*) FROM llm_configs')
|
cursor.execute('SELECT COUNT(*) FROM llm_configs')
|
||||||
if cursor.fetchone()[0] == 0:
|
if cursor.fetchone()[0] == 0:
|
||||||
@@ -225,13 +260,19 @@ def init_db():
|
|||||||
if cursor.fetchone()[0] == 0:
|
if cursor.fetchone()[0] == 0:
|
||||||
default_configs = [
|
default_configs = [
|
||||||
('app_name', 'AI助手', '应用名称'),
|
('app_name', 'AI助手', '应用名称'),
|
||||||
('app_version', '3.5.1', '应用版本'),
|
('app_version', '3.10.0', '应用版本'),
|
||||||
('llm_provider', 'zhipu', '默认大模型提供商'),
|
('llm_provider', 'zhipu', '默认大模型提供商'),
|
||||||
('enable_search', 'true', '是否启用联网搜索'),
|
('enable_search', 'true', '是否启用联网搜索'),
|
||||||
('guest_chat_sessions', '1', '游客每日对话会话限制'),
|
('guest_chat_sessions', '1', '游客每日对话会话限制'),
|
||||||
('guest_chat_messages', '20', '游客每日对话消息限制'),
|
('guest_chat_messages', '20', '游客每日对话消息限制'),
|
||||||
('guest_agent_messages', '20', '游客每日智能体消息限制'),
|
('guest_agent_messages', '20', '游客每日智能体消息限制'),
|
||||||
('admin_password', 'admin123', '管理员密码'),
|
('admin_password', 'admin123', '管理员密码'),
|
||||||
|
('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:
|
for key, value, desc in default_configs:
|
||||||
cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc))
|
cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc))
|
||||||
@@ -581,6 +622,348 @@ def change_user_password(id):
|
|||||||
return jsonify({'success': True})
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== 用户头像上传 ====================
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/avatar', methods=['POST'])
|
||||||
|
def upload_user_avatar(user_id):
|
||||||
|
"""上传用户头像"""
|
||||||
|
data = request.json
|
||||||
|
avatar_data = data.get('avatar') # base64 格式图片
|
||||||
|
|
||||||
|
if not avatar_data:
|
||||||
|
return jsonify({'error': '头像数据不能为空'}), 400
|
||||||
|
|
||||||
|
# 解析 base64 数据
|
||||||
|
try:
|
||||||
|
# 支持两种格式:
|
||||||
|
# 1. data:image/png;base64,xxxxx
|
||||||
|
# 2. 纯 base64 字符串
|
||||||
|
|
||||||
|
if avatar_data.startswith('data:'):
|
||||||
|
# 提取格式和内容
|
||||||
|
header, content = avatar_data.split(',', 1)
|
||||||
|
# 提取图片格式
|
||||||
|
mime_type = header.split(':')[1].split(';')[0]
|
||||||
|
ext = mime_type.split('/')[1] if '/' in mime_type else 'png'
|
||||||
|
else:
|
||||||
|
content = avatar_data
|
||||||
|
ext = 'png'
|
||||||
|
|
||||||
|
# 解码 base64
|
||||||
|
image_bytes = base64.b64decode(content)
|
||||||
|
|
||||||
|
# 验证图片大小(最大 2MB)
|
||||||
|
if len(image_bytes) > 2 * 1024 * 1024:
|
||||||
|
return jsonify({'error': '头像大小不能超过2MB'}), 400
|
||||||
|
|
||||||
|
# 生成文件名
|
||||||
|
filename = f'user_{user_id}_{int(datetime.now().timestamp())}.{ext}'
|
||||||
|
filepath = os.path.join(AVATAR_DIR, filename)
|
||||||
|
|
||||||
|
# 保存文件
|
||||||
|
with open(filepath, 'wb') as f:
|
||||||
|
f.write(image_bytes)
|
||||||
|
|
||||||
|
# 更新数据库(存储文件名)
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('UPDATE users SET avatar=?, updated_at=CURRENT_TIMESTAMP WHERE id=?',
|
||||||
|
(filename, user_id))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
return jsonify({'success': True, 'avatar': filename, 'avatar_url': f'/api/avatars/{filename}'})
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': f'头像上传失败: {str(e)}'}), 500
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/avatars/<filename>', methods=['GET'])
|
||||||
|
def get_avatar(filename):
|
||||||
|
"""获取头像图片"""
|
||||||
|
return send_from_directory(AVATAR_DIR, filename)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/admin/users/<int:user_id>/avatar', methods=['POST'])
|
||||||
|
def admin_upload_user_avatar(user_id):
|
||||||
|
"""管理员上传用户头像"""
|
||||||
|
return upload_user_avatar(user_id)
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== 用户对话数据同步 ====================
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/conversations', methods=['GET'])
|
||||||
|
def get_user_conversations(user_id):
|
||||||
|
"""获取用户所有对话"""
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('''
|
||||||
|
SELECT id, title, agent_id, messages, created_at, updated_at
|
||||||
|
FROM conversations WHERE user_id = ? ORDER BY updated_at DESC
|
||||||
|
''', (user_id,))
|
||||||
|
|
||||||
|
conversations = []
|
||||||
|
for row in cursor.fetchall():
|
||||||
|
conv = dict(row)
|
||||||
|
# 解析消息JSON
|
||||||
|
try:
|
||||||
|
conv['messages'] = json.loads(conv['messages']) if conv['messages'] else []
|
||||||
|
except:
|
||||||
|
conv['messages'] = []
|
||||||
|
# 转换为前端格式(使用字符串ID)
|
||||||
|
conv['id'] = str(conv['id'])
|
||||||
|
conv['createdAt'] = int(datetime.strptime(conv['created_at'], '%Y-%m-%d %H:%M:%S').timestamp() * 1000) if conv['created_at'] else 0
|
||||||
|
conv['updatedAt'] = int(datetime.strptime(conv['updated_at'], '%Y-%m-%d %H:%M:%S').timestamp() * 1000) if conv['updated_at'] else 0
|
||||||
|
conv['agentId'] = conv['agent_id']
|
||||||
|
conversations.append(conv)
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
return jsonify(conversations)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/conversations/<int:conv_id>', methods=['GET'])
|
||||||
|
def get_user_conversation_detail(user_id, conv_id):
|
||||||
|
"""获取单个对话详情"""
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('''
|
||||||
|
SELECT id, title, agent_id, messages, created_at, updated_at
|
||||||
|
FROM conversations WHERE id = ? AND user_id = ?
|
||||||
|
''', (conv_id, user_id))
|
||||||
|
|
||||||
|
row = cursor.fetchone()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
if not row:
|
||||||
|
return jsonify({'error': '对话不存在'}), 404
|
||||||
|
|
||||||
|
conv = dict(row)
|
||||||
|
try:
|
||||||
|
conv['messages'] = json.loads(conv['messages']) if conv['messages'] else []
|
||||||
|
except:
|
||||||
|
conv['messages'] = []
|
||||||
|
|
||||||
|
conv['id'] = str(conv['id'])
|
||||||
|
conv['createdAt'] = int(datetime.strptime(conv['created_at'], '%Y-%m-%d %H:%M:%S').timestamp() * 1000) if conv['created_at'] else 0
|
||||||
|
conv['updatedAt'] = int(datetime.strptime(conv['updated_at'], '%Y-%m-%d %H:%M:%S').timestamp() * 1000) if conv['updated_at'] else 0
|
||||||
|
conv['agentId'] = conv['agent_id']
|
||||||
|
|
||||||
|
return jsonify(conv)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/conversations', methods=['POST'])
|
||||||
|
def create_user_conversation(user_id):
|
||||||
|
"""创建新对话"""
|
||||||
|
data = request.json
|
||||||
|
title = data.get('title', '新对话')
|
||||||
|
agent_id = data.get('agentId') or data.get('agent_id')
|
||||||
|
messages = data.get('messages', [])
|
||||||
|
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('''
|
||||||
|
INSERT INTO conversations (user_id, title, agent_id, messages)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
''', (user_id, title, agent_id, json.dumps(messages)))
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
conv_id = cursor.lastrowid
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
return jsonify({'success': True, 'id': str(conv_id)})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/conversations/<int:conv_id>', methods=['PUT'])
|
||||||
|
def update_user_conversation(user_id, conv_id):
|
||||||
|
"""更新对话(添加消息、修改标题等)"""
|
||||||
|
data = request.json
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# 验证对话属于该用户
|
||||||
|
cursor.execute('SELECT id FROM conversations WHERE id = ? AND user_id = ?', (conv_id, user_id))
|
||||||
|
if not cursor.fetchone():
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'error': '对话不存在'}), 404
|
||||||
|
|
||||||
|
# 更新字段
|
||||||
|
updates = []
|
||||||
|
values = []
|
||||||
|
|
||||||
|
if 'title' in data:
|
||||||
|
updates.append('title = ?')
|
||||||
|
values.append(data['title'])
|
||||||
|
|
||||||
|
if 'messages' in data:
|
||||||
|
updates.append('messages = ?')
|
||||||
|
values.append(json.dumps(data['messages']))
|
||||||
|
|
||||||
|
if 'agentId' in data or 'agent_id' in data:
|
||||||
|
updates.append('agent_id = ?')
|
||||||
|
values.append(data.get('agentId') or data.get('agent_id'))
|
||||||
|
|
||||||
|
if updates:
|
||||||
|
updates.append('updated_at = CURRENT_TIMESTAMP')
|
||||||
|
sql = f'UPDATE conversations SET {", ".join(updates)} WHERE id = ?'
|
||||||
|
values.append(conv_id)
|
||||||
|
cursor.execute(sql, values)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/conversations/<int:conv_id>', methods=['DELETE'])
|
||||||
|
def delete_user_conversation(user_id, conv_id):
|
||||||
|
"""删除对话"""
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# 验证对话属于该用户
|
||||||
|
cursor.execute('SELECT id FROM conversations WHERE id = ? AND user_id = ?', (conv_id, user_id))
|
||||||
|
if not cursor.fetchone():
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'error': '对话不存在'}), 404
|
||||||
|
|
||||||
|
cursor.execute('DELETE FROM conversations WHERE id = ?', (conv_id,))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== 用户智能体数据同步 ====================
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/agents', methods=['GET'])
|
||||||
|
def get_user_agents(user_id):
|
||||||
|
"""获取用户智能体配置"""
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('''
|
||||||
|
SELECT agent_id, category, is_pinned, is_favorite, added_at
|
||||||
|
FROM user_agents WHERE user_id = ?
|
||||||
|
''', (user_id,))
|
||||||
|
|
||||||
|
agents_data = {
|
||||||
|
'myAgents': {}, # {category: [agent_ids]}
|
||||||
|
'favoriteAgents': [], # [agent_ids]
|
||||||
|
'pinnedAgents': {} # {category: [agent_ids]}
|
||||||
|
}
|
||||||
|
|
||||||
|
for row in cursor.fetchall():
|
||||||
|
agent_id = row['agent_id']
|
||||||
|
category = row['category']
|
||||||
|
is_pinned = row['is_pinned']
|
||||||
|
is_favorite = row['is_favorite']
|
||||||
|
|
||||||
|
# 添加到 myAgents
|
||||||
|
if category not in agents_data['myAgents']:
|
||||||
|
agents_data['myAgents'][category] = []
|
||||||
|
agents_data['myAgents'][category].append(agent_id)
|
||||||
|
|
||||||
|
# 添加到 pinnedAgents
|
||||||
|
if is_pinned:
|
||||||
|
if category not in agents_data['pinnedAgents']:
|
||||||
|
agents_data['pinnedAgents'][category] = []
|
||||||
|
agents_data['pinnedAgents'][category].append(agent_id)
|
||||||
|
|
||||||
|
# 添加到 favoriteAgents
|
||||||
|
if is_favorite:
|
||||||
|
agents_data['favoriteAgents'].append(agent_id)
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
return jsonify(agents_data)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/agents/<agent_id>', methods=['POST'])
|
||||||
|
def add_user_agent(user_id, agent_id):
|
||||||
|
"""添加智能体到用户列表"""
|
||||||
|
data = request.json
|
||||||
|
category = data.get('category', 'basic')
|
||||||
|
is_pinned = data.get('is_pinned', 0)
|
||||||
|
is_favorite = data.get('is_favorite', 0)
|
||||||
|
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
try:
|
||||||
|
cursor.execute('''
|
||||||
|
INSERT INTO user_agents (user_id, agent_id, category, is_pinned, is_favorite)
|
||||||
|
VALUES (?, ?, ?, ?, ?)
|
||||||
|
''', (user_id, agent_id, category, is_pinned, is_favorite))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'success': True})
|
||||||
|
except:
|
||||||
|
# 已存在,更新
|
||||||
|
cursor.execute('''
|
||||||
|
UPDATE user_agents SET category=?, is_pinned=?, is_favorite=?
|
||||||
|
WHERE user_id=? AND agent_id=?
|
||||||
|
''', (category, is_pinned, is_favorite, user_id, agent_id))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/agents/<agent_id>', methods=['DELETE'])
|
||||||
|
def remove_user_agent(user_id, agent_id):
|
||||||
|
"""从用户列表移除智能体"""
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('DELETE FROM user_agents WHERE user_id=? AND agent_id=?', (user_id, agent_id))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/agents/<agent_id>/pin', methods=['POST'])
|
||||||
|
def toggle_user_agent_pin(user_id, agent_id):
|
||||||
|
"""切换智能体置顶状态"""
|
||||||
|
data = request.json
|
||||||
|
is_pinned = data.get('is_pinned', 1)
|
||||||
|
category = data.get('category', 'basic')
|
||||||
|
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# 检查是否存在
|
||||||
|
cursor.execute('SELECT id FROM user_agents WHERE user_id=? AND agent_id=?', (user_id, agent_id))
|
||||||
|
if cursor.fetchone():
|
||||||
|
cursor.execute('UPDATE user_agents SET is_pinned=? WHERE user_id=? AND agent_id=?',
|
||||||
|
(is_pinned, user_id, agent_id))
|
||||||
|
else:
|
||||||
|
cursor.execute('INSERT INTO user_agents (user_id, agent_id, category, is_pinned) VALUES (?, ?, ?, ?)',
|
||||||
|
(user_id, agent_id, category, is_pinned))
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/user/<int:user_id>/agents/<agent_id>/favorite', methods=['POST'])
|
||||||
|
def toggle_user_agent_favorite(user_id, agent_id):
|
||||||
|
"""切换智能体收藏状态"""
|
||||||
|
data = request.json
|
||||||
|
is_favorite = data.get('is_favorite', 1)
|
||||||
|
category = data.get('category', 'basic')
|
||||||
|
|
||||||
|
conn = get_db()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# 检查是否存在
|
||||||
|
cursor.execute('SELECT id FROM user_agents WHERE user_id=? AND agent_id=?', (user_id, agent_id))
|
||||||
|
if cursor.fetchone():
|
||||||
|
cursor.execute('UPDATE user_agents SET is_favorite=? WHERE user_id=? AND agent_id=?',
|
||||||
|
(is_favorite, user_id, agent_id))
|
||||||
|
else:
|
||||||
|
cursor.execute('INSERT INTO user_agents (user_id, agent_id, category, is_favorite) VALUES (?, ?, ?, ?)',
|
||||||
|
(user_id, agent_id, category, is_favorite))
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return jsonify({'success': True})
|
||||||
|
|
||||||
|
|
||||||
# ==================== 大模型接口管理 ====================
|
# ==================== 大模型接口管理 ====================
|
||||||
|
|
||||||
@app.route('/api/admin/llm', methods=['GET'])
|
@app.route('/api/admin/llm', methods=['GET'])
|
||||||
@@ -949,6 +1332,10 @@ def get_frontend_config():
|
|||||||
cursor.execute('SELECT * FROM tool_configs WHERE is_default=1 AND is_active=1')
|
cursor.execute('SELECT * FROM tool_configs WHERE is_default=1 AND is_active=1')
|
||||||
tools = [dict(row) for row in cursor.fetchall()]
|
tools = [dict(row) for row in cursor.fetchall()]
|
||||||
|
|
||||||
|
# 获取所有活跃的工具配置(供前端选择)
|
||||||
|
cursor.execute('SELECT tool_id, name, type, provider, is_active FROM tool_configs WHERE is_active=1')
|
||||||
|
allTools = [dict(row) for row in cursor.fetchall()]
|
||||||
|
|
||||||
# 获取所有智能体(上线且活跃)
|
# 获取所有智能体(上线且活跃)
|
||||||
cursor.execute('SELECT agent_id, name, avatar, category, description, system_prompt, heat, tags, enable_tools FROM agents WHERE is_online=1 AND is_active=1')
|
cursor.execute('SELECT agent_id, name, avatar, category, description, system_prompt, heat, tags, enable_tools FROM agents WHERE is_online=1 AND is_active=1')
|
||||||
agents = [dict(row) for row in cursor.fetchall()]
|
agents = [dict(row) for row in cursor.fetchall()]
|
||||||
@@ -966,17 +1353,24 @@ def get_frontend_config():
|
|||||||
config = {
|
config = {
|
||||||
'llm': dict(llm) if llm else None,
|
'llm': dict(llm) if llm else None,
|
||||||
'tools': tools,
|
'tools': tools,
|
||||||
|
'allTools': allTools, # 所有活跃的工具(供前端选择)
|
||||||
'agents': agents,
|
'agents': agents,
|
||||||
'chat_config': dict(chat_config) if chat_config else None,
|
'chat_config': dict(chat_config) if chat_config else None,
|
||||||
'system': {
|
'system': {
|
||||||
'appName': system.get('app_name', 'AI助手'),
|
'appName': system.get('app_name', 'AI助手'),
|
||||||
'version': system.get('app_version', '3.6.0'),
|
'version': system.get('app_version', '3.10.0'),
|
||||||
'enableSearch': system.get('enable_search', 'true') == 'true',
|
'enableSearch': system.get('enable_search', 'true') == 'true',
|
||||||
'guestLimits': {
|
'guestLimits': {
|
||||||
'chatSessions': int(system.get('guest_chat_sessions', '1')),
|
'chatSessions': int(system.get('guest_chat_sessions', '1')),
|
||||||
'chatMessages': int(system.get('guest_chat_messages', '20')),
|
'chatMessages': int(system.get('guest_chat_messages', '20')),
|
||||||
'agentMessages': int(system.get('guest_agent_messages', '20')),
|
'agentMessages': int(system.get('guest_agent_messages', '20')),
|
||||||
}
|
},
|
||||||
|
'developer': system.get('app_developer', 'OpenClaw Team'),
|
||||||
|
'updateDate': system.get('app_update_date', '2026-04-27'),
|
||||||
|
'technology': system.get('app_technology', '智谱 GLM-4.5-Air 大模型'),
|
||||||
|
'description': system.get('app_description', '提供智能对话、多种智能体服务'),
|
||||||
|
'privacyPolicyUrl': system.get('privacy_policy_url', ''),
|
||||||
|
'userAgreementUrl': system.get('user_agreement_url', ''),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
185
www/admin.js
185
www/admin.js
@@ -250,6 +250,7 @@ async function loadUsersPage(content) {
|
|||||||
<td>
|
<td>
|
||||||
<div class="action-btns">
|
<div class="action-btns">
|
||||||
<button class="action-btn edit" onclick="showEditUserModal(${u.id})">编辑</button>
|
<button class="action-btn edit" onclick="showEditUserModal(${u.id})">编辑</button>
|
||||||
|
<button class="action-btn" style="background: #8b5cf6; color: white;" onclick="showUserConversations(${u.id}, '${u.username}')">查看对话</button>
|
||||||
<button class="action-btn" style="background: #f59e0b; color: white;" onclick="showResetPasswordModal(${u.id})">重置密码</button>
|
<button class="action-btn" style="background: #f59e0b; color: white;" onclick="showResetPasswordModal(${u.id})">重置密码</button>
|
||||||
<button class="action-btn delete" onclick="deleteUser(${u.id})">删除</button>
|
<button class="action-btn delete" onclick="deleteUser(${u.id})">删除</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -396,6 +397,150 @@ async function deleteUser(id) {
|
|||||||
loadPage('users');
|
loadPage('users');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 查看用户对话记录 ====================
|
||||||
|
|
||||||
|
async function showUserConversations(userId, username) {
|
||||||
|
// 加载用户对话列表
|
||||||
|
const conversations = await fetchAPI(`/api/user/${userId}/conversations`);
|
||||||
|
|
||||||
|
const content = document.getElementById('mainContent');
|
||||||
|
|
||||||
|
content.innerHTML = `
|
||||||
|
<div class="content-header">
|
||||||
|
<h1 class="content-title">用户对话记录 - ${username}</h1>
|
||||||
|
<button class="add-btn" style="background: #718096;" onclick="loadPage('users')">返回用户列表</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="stats-grid" style="grid-template-columns: repeat(3, 1fr);">
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-icon">💬</div>
|
||||||
|
<div class="stat-value">${conversations.length}</div>
|
||||||
|
<div class="stat-label">对话总数</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-icon">🤖</div>
|
||||||
|
<div class="stat-value">${conversations.filter(c => c.agentId).length}</div>
|
||||||
|
<div class="stat-label">智能体对话</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-icon">📝</div>
|
||||||
|
<div class="stat-value">${conversations.reduce((sum, c) => sum + (c.messages?.length || 0), 0)}</div>
|
||||||
|
<div class="stat-label">消息总数</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="data-table">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>标题</th>
|
||||||
|
<th>智能体</th>
|
||||||
|
<th>消息数</th>
|
||||||
|
<th>创建时间</th>
|
||||||
|
<th>更新时间</th>
|
||||||
|
<th>操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${conversations.length === 0 ? '<tr><td colspan="7" style="text-align: center; color: #999;">暂无对话记录</td></tr>' :
|
||||||
|
conversations.map(conv => `
|
||||||
|
<tr>
|
||||||
|
<td>${conv.id}</td>
|
||||||
|
<td>${conv.title || '新对话'}</td>
|
||||||
|
<td>${conv.agentId ? getAgentName(conv.agentId) : '普通对话'}</td>
|
||||||
|
<td>${conv.messages?.length || 0}</td>
|
||||||
|
<td>${formatDate(conv.createdAt || conv.created_at)}</td>
|
||||||
|
<td>${formatDate(conv.updatedAt || conv.updated_at)}</td>
|
||||||
|
<td>
|
||||||
|
<div class="action-btns">
|
||||||
|
<button class="action-btn edit" onclick="showConversationMessages(${userId}, ${conv.id}, '${conv.title || '新对话'}')">查看详情</button>
|
||||||
|
<button class="action-btn delete" onclick="deleteUserConversation(${userId}, ${conv.id})">删除</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`).join('')
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAgentName(agentId) {
|
||||||
|
const agent = agents.find(a => a.agent_id === agentId);
|
||||||
|
return agent ? `${agent.avatar} ${agent.name}` : agentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function showConversationMessages(userId, convId, title) {
|
||||||
|
// 获取对话详情
|
||||||
|
const conv = await fetchAPI(`/api/user/${userId}/conversations/${convId}`);
|
||||||
|
|
||||||
|
const content = document.getElementById('mainContent');
|
||||||
|
|
||||||
|
const messages = conv.messages || [];
|
||||||
|
|
||||||
|
content.innerHTML = `
|
||||||
|
<div class="content-header">
|
||||||
|
<h1 class="content-title">对话详情 - ${title}</h1>
|
||||||
|
<button class="add-btn" style="background: #718096;" onclick="showUserConversations(${userId}, '用户')">返回对话列表</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="background: white; padding: 16px; border-radius: 12px; margin-bottom: 16px;">
|
||||||
|
<div style="display: flex; gap: 16px; color: #718096;">
|
||||||
|
<span>💬 消息数: ${messages.length}</span>
|
||||||
|
<span>🤖 智能体: ${conv.agentId ? getAgentName(conv.agentId) : '普通对话'}</span>
|
||||||
|
<span>📅 创建: ${formatDate(conv.createdAt || conv.created_at)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="data-table">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 60px;">序号</th>
|
||||||
|
<th style="width: 80px;">角色</th>
|
||||||
|
<th>内容</th>
|
||||||
|
<th style="width: 150px;">时间</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${messages.length === 0 ? '<tr><td colspan="4" style="text-align: center; color: #999;">暂无消息</td></tr>' :
|
||||||
|
messages.map((msg, idx) => `
|
||||||
|
<tr>
|
||||||
|
<td>${idx + 1}</td>
|
||||||
|
<td style="color: ${msg.role === 'user' ? '#3b82f6' : '#10b981'};">
|
||||||
|
${msg.role === 'user' ? '👤 用户' : '🤖 AI'}
|
||||||
|
</td>
|
||||||
|
<td style="max-width: 500px; white-space: pre-wrap; word-break: break-all;">
|
||||||
|
${escapeHtml(msg.content?.slice(0, 500) || '')}${msg.content?.length > 500 ? '...' : ''}
|
||||||
|
${msg.thinking ? `<div style="color: #f59e0b; margin-top: 8px; font-size: 12px;">💭 思考: ${escapeHtml(msg.thinking?.slice(0, 200) || '')}...</div>` : ''}
|
||||||
|
</td>
|
||||||
|
<td>${formatDate(msg.timestamp || msg.createdAt)}</td>
|
||||||
|
</tr>
|
||||||
|
`).join('')
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteUserConversation(userId, convId) {
|
||||||
|
if (!confirm('确定删除此对话?此操作不可恢复!')) return;
|
||||||
|
|
||||||
|
await fetchAPI(`/api/user/${userId}/conversations/${convId}`, 'DELETE');
|
||||||
|
showToast('删除成功');
|
||||||
|
showUserConversations(userId, '用户');
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeHtml(text) {
|
||||||
|
if (!text) return '';
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.textContent = text;
|
||||||
|
return div.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 大模型配置页面 ====================
|
// ==================== 大模型配置页面 ====================
|
||||||
|
|
||||||
async function loadLLMPage(content) {
|
async function loadLLMPage(content) {
|
||||||
@@ -1210,6 +1355,26 @@ async function loadSystemPage(content) {
|
|||||||
<input type="text" class="form-input" id="appVersion" value="${systemConfigs.app_version?.value || ''}">
|
<input type="text" class="form-input" id="appVersion" value="${systemConfigs.app_version?.value || ''}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">应用简介</label>
|
||||||
|
<input type="text" class="form-input" id="appDescription" value="${systemConfigs.app_description?.value || ''}" placeholder="如:提供智能对话、多种智能体服务">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">技术基础</label>
|
||||||
|
<input type="text" class="form-input" id="appTechnology" value="${systemConfigs.app_technology?.value || ''}" placeholder="如:智谱 GLM-4.5-Air 大模型">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">开发者</label>
|
||||||
|
<input type="text" class="form-input" id="appDeveloper" value="${systemConfigs.app_developer?.value || ''}" placeholder="如:OpenClaw Team">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">更新日期</label>
|
||||||
|
<input type="text" class="form-input" id="appUpdateDate" value="${systemConfigs.app_update_date?.value || ''}" placeholder="如:2026-04-27">
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3 style="margin: 24px 0 16px; padding-top: 16px; border-top: 1px solid #e2e8f0;">游客使用限制</h3>
|
<h3 style="margin: 24px 0 16px; padding-top: 16px; border-top: 1px solid #e2e8f0;">游客使用限制</h3>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -1234,6 +1399,18 @@ async function loadSystemPage(content) {
|
|||||||
<input type="text" class="form-input" id="adminPassword" value="${systemConfigs.admin_password?.value || ''}" placeholder="修改管理员密码">
|
<input type="text" class="form-input" id="adminPassword" value="${systemConfigs.admin_password?.value || ''}" placeholder="修改管理员密码">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h3 style="margin: 24px 0 16px; padding-top: 16px; border-top: 1px solid #e2e8f0;">链接配置</h3>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">隐私政策链接</label>
|
||||||
|
<input type="text" class="form-input" id="privacyPolicyUrl" value="${systemConfigs.privacy_policy_url?.value || ''}" placeholder="隐私政策页面URL">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">用户协议链接</label>
|
||||||
|
<input type="text" class="form-input" id="userAgreementUrl" value="${systemConfigs.user_agreement_url?.value || ''}" placeholder="用户协议页面URL">
|
||||||
|
</div>
|
||||||
|
|
||||||
<button class="form-submit" onclick="saveSystemConfig()">保存设置</button>
|
<button class="form-submit" onclick="saveSystemConfig()">保存设置</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1249,10 +1426,16 @@ async function saveSystemConfig() {
|
|||||||
const data = {
|
const data = {
|
||||||
app_name: document.getElementById('appName').value,
|
app_name: document.getElementById('appName').value,
|
||||||
app_version: document.getElementById('appVersion').value,
|
app_version: document.getElementById('appVersion').value,
|
||||||
|
app_description: document.getElementById('appDescription').value,
|
||||||
|
app_technology: document.getElementById('appTechnology').value,
|
||||||
|
app_developer: document.getElementById('appDeveloper').value,
|
||||||
|
app_update_date: document.getElementById('appUpdateDate').value,
|
||||||
guest_chat_sessions: document.getElementById('guestChatSessions').value,
|
guest_chat_sessions: document.getElementById('guestChatSessions').value,
|
||||||
guest_chat_messages: document.getElementById('guestChatMessages').value,
|
guest_chat_messages: document.getElementById('guestChatMessages').value,
|
||||||
guest_agent_messages: document.getElementById('guestAgentMessages').value,
|
guest_agent_messages: document.getElementById('guestAgentMessages').value,
|
||||||
admin_password: document.getElementById('adminPassword').value
|
admin_password: document.getElementById('adminPassword').value,
|
||||||
|
privacy_policy_url: document.getElementById('privacyPolicyUrl').value,
|
||||||
|
user_agreement_url: document.getElementById('userAgreementUrl').value,
|
||||||
};
|
};
|
||||||
|
|
||||||
await fetchAPI('/api/admin/system', 'POST', data);
|
await fetchAPI('/api/admin/system', 'POST', data);
|
||||||
|
|||||||
760
www/app.js
760
www/app.js
File diff suppressed because it is too large
Load Diff
212
www/style.css
212
www/style.css
@@ -1049,6 +1049,31 @@ body {
|
|||||||
box-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
|
box-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.avatar-upload-section {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-upload-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px 24px;
|
||||||
|
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-upload-btn:hover {
|
||||||
|
transform: scale(1.02);
|
||||||
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
.edit-input-group {
|
.edit-input-group {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
@@ -2715,6 +2740,193 @@ body {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 更多工具按钮 */
|
||||||
|
.tools-btn {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-count {
|
||||||
|
position: absolute;
|
||||||
|
top: -4px;
|
||||||
|
right: -4px;
|
||||||
|
min-width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
padding: 0 4px;
|
||||||
|
background: #ef4444;
|
||||||
|
color: white;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: 8px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 工具选择弹窗 */
|
||||||
|
.tools-popup {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-content {
|
||||||
|
width: 90%;
|
||||||
|
max-width: 400px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 16px 20px;
|
||||||
|
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-header h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-close {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border: none;
|
||||||
|
border-radius: 14px;
|
||||||
|
color: white;
|
||||||
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-close:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-body {
|
||||||
|
padding: 16px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-tip {
|
||||||
|
color: #718096;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
max-height: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-option {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-radius: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-option:hover {
|
||||||
|
background: #e8ecf1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-option.selected {
|
||||||
|
background: rgba(102, 126, 234, 0.1);
|
||||||
|
border-color: var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-checkbox {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: #718096;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-option.selected .tool-checkbox {
|
||||||
|
color: var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-icon {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-info {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-name {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #2d3748;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-type {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #718096;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-footer {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 16px 20px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-btn {
|
||||||
|
flex: 1;
|
||||||
|
padding: 12px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-btn.cancel {
|
||||||
|
background: #e2e8f0;
|
||||||
|
color: #4a5568;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-btn.cancel:hover {
|
||||||
|
background: #cbd5e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-btn.confirm {
|
||||||
|
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-popup-btn.confirm:hover {
|
||||||
|
transform: scale(1.02);
|
||||||
|
}
|
||||||
|
|
||||||
/* 导航按钮样式 */
|
/* 导航按钮样式 */
|
||||||
.nav-btn {
|
.nav-btn {
|
||||||
padding: 6px 8px;
|
padding: 6px 8px;
|
||||||
|
|||||||
Reference in New Issue
Block a user