Files
article-workflow/admin/templates/settings.html
hubian 45b8c70cb9 新增后台管理系统
功能模块:
- 仪表盘: 统计数据概览、快速操作入口
- 资料池管理: 查看、搜索、删除资料
- 文章历史: 查看历史文章列表和主题标签
- 工作流控制: 新建工作流、配置参数、启动流程
- 系统设置: LLM配置、文章类型、数据管理

技术栈:
- Flask Web框架
- Tailwind CSS
- RESTful API
- 实时LLM连接测试
2026-04-08 11:48:39 +08:00

234 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统设置 - 文章工作流</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
</head>
<body class="bg-gray-50 min-h-screen">
<div class="flex">
<aside class="w-64 bg-slate-800 min-h-screen fixed left-0 top-0">
<div class="p-6">
<h1 class="text-white text-xl font-bold flex items-center gap-2">
<i class="ri-article-line text-2xl text-blue-400"></i>
文章工作流
</h1>
</div>
<nav class="mt-6">
<a href="/" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-dashboard-line"></i><span>仪表盘</span>
</a>
<a href="/resources" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-database-2-line"></i><span>资料池</span>
</a>
<a href="/articles" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-file-list-3-line"></i><span>文章历史</span>
</a>
<a href="/workflow" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-flow-chart"></i><span>工作流</span>
</a>
<a href="/settings" class="flex items-center gap-3 px-6 py-3 bg-slate-700 text-white">
<i class="ri-settings-3-line"></i><span>系统设置</span>
</a>
</nav>
</aside>
<main class="ml-64 flex-1 p-8">
<h1 class="text-2xl font-bold text-gray-800 mb-6">系统设置</h1>
<!-- LLM配置 -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 mb-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-robot-line text-blue-500"></i>
大模型配置
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">API地址</label>
<input type="text" id="apiUrl"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500"
placeholder="http://localhost:1234/v1">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">API Key</label>
<input type="password" id="apiKey"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500"
placeholder="sk-...">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">模型名称</label>
<input type="text" id="modelName"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500"
placeholder="qwen3.5-4b">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">最大Token数</label>
<input type="number" id="maxTokens"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500"
placeholder="4096">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Temperature</label>
<input type="number" id="temperature" step="0.1" min="0" max="1"
class="w-full px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500"
placeholder="0.7">
</div>
</div>
<div class="flex gap-3 mt-6">
<button onclick="saveConfig()"
class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 flex items-center gap-2">
<i class="ri-save-line"></i> 保存配置
</button>
<button onclick="testConnection()"
class="px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 flex items-center gap-2">
<i class="ri-link"></i> 测试连接
</button>
</div>
</div>
<!-- 文章类型配置 -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 mb-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-file-list-3-line text-purple-500"></i>
文章类型
</h2>
<div id="articleTypes" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<p class="text-gray-500">加载中...</p>
</div>
</div>
<!-- 数据管理 -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
<i class="ri-database-2-line text-orange-500"></i>
数据管理
</h2>
<div class="space-y-4">
<div class="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
<div>
<p class="font-medium text-gray-800">导出资料池</p>
<p class="text-sm text-gray-500">导出所有资料数据为JSON格式</p>
</div>
<button onclick="exportData('resources')"
class="px-4 py-2 bg-blue-100 text-blue-700 rounded-lg hover:bg-blue-200">
导出
</button>
</div>
<div class="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
<div>
<p class="font-medium text-gray-800">导出文章历史</p>
<p class="text-sm text-gray-500">导出所有文章记录</p>
</div>
<button onclick="exportData('articles')"
class="px-4 py-2 bg-blue-100 text-blue-700 rounded-lg hover:bg-blue-200">
导出
</button>
</div>
<div class="flex items-center justify-between p-4 bg-red-50 rounded-lg">
<div>
<p class="font-medium text-red-800">清空资料池</p>
<p class="text-sm text-red-500">删除所有资料和分析数据(不可恢复)</p>
</div>
<button onclick="clearData()"
class="px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600">
清空
</button>
</div>
</div>
</div>
</main>
</div>
<script>
async function loadConfig() {
const response = await fetch('/api/config');
const data = await response.json();
document.getElementById('apiUrl').value = data.base_url || '';
document.getElementById('modelName').value = data.model || '';
document.getElementById('maxTokens').value = data.max_tokens || 4096;
document.getElementById('temperature').value = data.temperature || 0.7;
}
async function loadArticleTypes() {
const response = await fetch('/api/article-types');
const types = await response.json();
const container = document.getElementById('articleTypes');
container.innerHTML = Object.entries(types).map(([key, value]) => `
<div class="p-4 bg-gray-50 rounded-lg">
<h3 class="font-medium text-gray-800">${key}</h3>
<p class="text-sm text-gray-500 mt-1">${value.description}</p>
<p class="text-xs text-gray-400 mt-2">字数: ${value.word_count}</p>
</div>
`).join('');
}
async function saveConfig() {
const config = {
base_url: document.getElementById('apiUrl').value,
model: document.getElementById('modelName').value,
max_tokens: parseInt(document.getElementById('maxTokens').value),
temperature: parseFloat(document.getElementById('temperature').value),
};
const response = await fetch('/api/config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(config)
});
const data = await response.json();
if (data.success) {
alert('配置已保存');
} else {
alert('保存失败');
}
}
async function testConnection() {
const btn = event.target;
btn.disabled = true;
btn.innerHTML = '<i class="ri-loader-4-line animate-spin"></i> 测试中...';
try {
const response = await fetch('/api/test-llm', { method: 'POST' });
const data = await response.json();
if (data.success) {
alert('连接成功!模型响应: ' + data.response);
} else {
alert('连接失败: ' + data.error);
}
} catch (e) {
alert('测试失败: ' + e.message);
}
btn.disabled = false;
btn.innerHTML = '<i class="ri-link"></i> 测试连接';
}
async function exportData(type) {
if (type === 'resources') {
window.location.href = '/api/export/resources';
}
}
async function clearData() {
if (!confirm('确定要清空所有资料吗?此操作不可恢复!')) return;
alert('功能开发中');
}
// 初始化
loadConfig();
loadArticleTypes();
</script>
</body>
</html>