You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
16 KiB

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统配置 - AlphaFutures</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#165DFF',
secondary: '#36CFC9',
success: '#52C41A',
warning: '#FAAD14',
error: '#F5222D',
dark: '#1D2129',
light: '#F2F3F5'
},
fontFamily: {
inter: ['Inter', 'system-ui', 'sans-serif'],
},
}
}
}
</script>
<style type="text/tailwindcss">
@layer utilities {
.content-auto {
content-visibility: auto;
}
.bg-gradient-blue {
background: linear-gradient(135deg, #165DFF 0%, #36CFC9 100%);
}
.card-shadow {
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
.transition-all-300 {
transition: all 300ms ease-in-out;
}
}
</style>
</head>
<body class="bg-light font-inter min-h-screen">
<!-- 顶部导航栏 -->
<header class="bg-white shadow-md sticky top-0 z-50">
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fa fa-line-chart text-primary text-2xl"></i>
<h1 class="text-xl font-bold text-dark">AlphaFutures</h1>
</div>
<nav class="flex items-center space-x-6">
<a href="/" class="text-gray-600 hover:text-primary transition-all-300">
<i class="fa fa-home mr-1"></i> 首页
</a>
<a href="/config" class="text-primary font-medium border-b-2 border-primary pb-1">
<i class="fa fa-cog mr-1"></i> 配置
</a>
{% if current_user.is_authenticated %}
<a href="/logout" class="text-gray-600 hover:text-primary transition-all-300">
<i class="fa fa-sign-out mr-1"></i> 登出
</a>
{% else %}
<a href="/login" class="text-gray-600 hover:text-primary transition-all-300">
<i class="fa fa-sign-in mr-1"></i> 登录
</a>
{% endif %}
</nav>
</div>
</header>
<!-- 主内容区 -->
<main class="container mx-auto px-4 py-8">
<div class="max-w-4xl mx-auto">
<!-- 页面标题 -->
<div class="mb-8 text-center">
<h2 class="text-2xl font-bold text-dark mb-2">系统配置</h2>
<p class="text-gray-600">配置数据源、AI模型等系统参数</p>
</div>
<!-- 配置表单 -->
<div class="bg-white rounded-lg card-shadow p-6 mb-8">
<form method="POST" action="/config" class="space-y-6">
<!-- 数据源配置 -->
<div class="border-b border-gray-200 pb-6">
<h3 class="text-lg font-semibold text-dark mb-4 flex items-center">
<i class="fa fa-database text-primary mr-2"></i> 数据源配置
</h3>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
数据源类型
</label>
<select name="data_adapter_type" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
<option value="tqsdk" {% if data_adapter_type == 'tqsdk' %}selected{% endif %}>
TQSDK
</option>
<option value="rqdata" {% if data_adapter_type == 'rqdata' %}selected{% endif %}>
RQData
</option>
</select>
<p class="text-xs text-gray-500 mt-1">选择要使用的数据源</p>
</div>
<!-- TQSDK账号配置 -->
<div class="space-y-2">
<label class="block text-sm font-medium text-gray-700 mb-1">
TQSDK账号配置
</label>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<input type="text" name="tqsdk_username" value="{{ tqsdk_username }}"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
placeholder="TQSDK用户名">
</div>
<div>
<input type="password" name="tqsdk_password" value="{{ tqsdk_password }}"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
placeholder="TQSDK密码">
</div>
</div>
<p class="text-xs text-gray-500">未配置时将使用模拟数据</p>
</div>
<!-- RQData账号配置 -->
<div class="space-y-2">
<label class="block text-sm font-medium text-gray-700 mb-1">
RQData账号配置
</label>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<input type="text" name="rqdata_username" value="{{ rqdata_username }}"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
placeholder="RQData用户名">
</div>
<div>
<input type="password" name="rqdata_password" value="{{ rqdata_password }}"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
placeholder="RQData密码">
</div>
</div>
<p class="text-xs text-gray-500">未配置时将使用模拟数据</p>
</div>
</div>
</div>
<!-- AI模型配置 -->
<div class="border-b border-gray-200 pb-6">
<h3 class="text-lg font-semibold text-dark mb-4 flex items-center">
<i class="fa fa-robot text-primary mr-2"></i> AI模型配置
</h3>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
默认AI模型
</label>
<select name="default_ai_model" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
<option value="deepseek" {% if default_ai_model == 'deepseek' %}selected{% endif %}>
DeepSeek
</option>
<option value="gpt" {% if default_ai_model == 'gpt' %}selected{% endif %}>
GPT
</option>
<option value="gemini" {% if default_ai_model == 'gemini' %}selected{% endif %}>
Gemini
</option>
</select>
<p class="text-xs text-gray-500 mt-1">选择默认使用的AI模型</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
AI API Key
</label>
<input type="password" name="ai_api_key" value="{{ ai_api_key }}"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
placeholder="AI模型API Key">
<p class="text-xs text-gray-500 mt-1">某些AI模型需要API Key才能使用</p>
</div>
</div>
</div>
<!-- 系统配置 -->
<div>
<h3 class="text-lg font-semibold text-dark mb-4 flex items-center">
<i class="fa fa-sliders text-primary mr-2"></i> 系统配置
</h3>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
调试模式
</label>
<div class="flex items-center">
<input type="checkbox" name="debug" {% if debug %}checked{% endif %}
class="w-4 h-4 text-primary focus:ring-primary border-gray-300 rounded">
<span class="ml-2 text-sm text-gray-600">启用详细日志输出</span>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
数据缓存
</label>
<div class="flex items-center">
<input type="checkbox" name="enable_cache" {% if enable_cache %}checked{% endif %}
class="w-4 h-4 text-primary focus:ring-primary border-gray-300 rounded">
<span class="ml-2 text-sm text-gray-600">启用数据缓存以提高性能</span>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
缓存过期时间 (秒)
</label>
<input type="number" name="cache_expiry" value="{{ cache_expiry }}" min="60" max="86400"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
<p class="text-xs text-gray-500 mt-1">数据缓存的过期时间</p>
</div>
</div>
</div>
<!-- 提交按钮 -->
<div class="pt-4">
<button type="submit" class="w-full bg-primary hover:bg-primary/90 text-white font-medium py-2 px-4 rounded-md transition-all-300 flex items-center justify-center">
<i class="fa fa-save mr-2"></i> 保存配置
</button>
</div>
</form>
</div>
<!-- 配置说明 -->
<div class="bg-blue-50 rounded-lg p-6">
<h3 class="text-lg font-semibold text-primary mb-3 flex items-center">
<i class="fa fa-info-circle mr-2"></i> 配置说明
</h3>
<ul class="space-y-2 text-gray-700">
<li class="flex items-start">
<i class="fa fa-check-circle text-success mt-1 mr-2"></i>
<span>数据源配置用于选择获取期货数据的API未配置账号时会自动使用模拟数据</span>
</li>
<li class="flex items-start">
<i class="fa fa-check-circle text-success mt-1 mr-2"></i>
<span>AI模型配置用于选择分析市场时使用的AI模型不同模型可能需要不同的API Key</span>
</li>
<li class="flex items-start">
<i class="fa fa-check-circle text-success mt-1 mr-2"></i>
<span>系统配置用于调整系统行为,如调试模式和缓存设置</span>
</li>
<li class="flex items-start">
<i class="fa fa-check-circle text-success mt-1 mr-2"></i>
<span>配置保存后会立即生效,无需重启系统</span>
</li>
</ul>
</div>
</div>
</main>
<!-- 页脚 -->
<footer class="bg-dark text-white py-6 mt-12">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<div class="flex items-center space-x-2">
<i class="fa fa-line-chart text-primary text-xl"></i>
<h2 class="text-xl font-bold">AlphaFutures</h2>
</div>
<p class="text-gray-400 mt-2">智能期货分析系统</p>
</div>
<div class="text-gray-400 text-sm">
© 2026 AlphaFutures. All rights reserved.
</div>
</div>
</div>
</footer>
<!-- 消息提示 -->
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="fixed bottom-4 right-4 z-50">
{% for message in messages %}
<div class="bg-primary text-white px-4 py-3 rounded-md shadow-lg mb-2 flex items-center">
<i class="fa fa-check-circle mr-2"></i>
<span>{{ message }}</span>
</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<script>
// 自动隐藏消息提示
setTimeout(() => {
const messages = document.querySelectorAll('.fixed.bottom-4.right-4 z-50 div');
messages.forEach(msg => {
msg.style.opacity = '0';
msg.style.transition = 'opacity 0.5s ease-out';
setTimeout(() => msg.remove(), 500);
});
}, 3000);
</script>
</body>
</html>