Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47729a52da | ||
|
|
8ad0246567 |
+302
@@ -0,0 +1,302 @@
|
||||
# Param Auto Manager 部署文档
|
||||
|
||||
## 📦 系统概览
|
||||
|
||||
**参数数据自动化管理系统** - 自动管理参数数据网站的系统,支持从内容库和互联网搜索数据,自动处理产品并提交到后台管理待审核区。
|
||||
|
||||
---
|
||||
|
||||
## 🚀 快速部署
|
||||
|
||||
### 1. 系统要求
|
||||
- Python 3.10+
|
||||
- Flask
|
||||
- SQLite3
|
||||
- Git
|
||||
|
||||
### 2. 安装依赖
|
||||
|
||||
```bash
|
||||
cd works/param-auto-manager
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 3. 启动服务
|
||||
|
||||
```bash
|
||||
# 方式1: 使用启动脚本
|
||||
./start.sh
|
||||
|
||||
# 方式2: 直接运行
|
||||
export PYTHONPATH="$HOME/.local/lib/python3.12/site-packages:$PYTHONPATH"
|
||||
python3 app.py
|
||||
```
|
||||
|
||||
### 4. 访问系统
|
||||
|
||||
- **前端界面**: http://localhost:16043 或 http://192.168.0.101:16043
|
||||
- **API接口**: http://localhost:16043/api
|
||||
|
||||
---
|
||||
|
||||
## 🌐 前端界面功能
|
||||
|
||||
### 主要功能模块
|
||||
|
||||
1. **统计面板**
|
||||
- 内容库文章数量
|
||||
- 待处理产品数量
|
||||
- 处理中产品数量
|
||||
- 最近成功/失败数量
|
||||
|
||||
2. **待处理产品列表**
|
||||
- 查看所有待处理产品
|
||||
- 添加单个/批量产品
|
||||
- 手动触发处理
|
||||
- 移除产品
|
||||
- 批量处理按钮
|
||||
|
||||
3. **内容库文章**
|
||||
- 查看所有文章
|
||||
- 搜索文章(关键词)
|
||||
- 添加新文章
|
||||
- 查看文章详情
|
||||
- 删除文章
|
||||
|
||||
4. **处理历史**
|
||||
- 查看处理历史记录
|
||||
- 状态显示(已提交/失败/错误)
|
||||
- 查看处理详情
|
||||
|
||||
5. **系统配置**
|
||||
- 自动处理开关
|
||||
- 处理间隔设置
|
||||
- 批量处理数量
|
||||
|
||||
---
|
||||
|
||||
## 🔌 API接口
|
||||
|
||||
### 文章内容库 API
|
||||
```bash
|
||||
# 获取文章列表
|
||||
GET /api/articles
|
||||
|
||||
# 搜索文章
|
||||
GET /api/articles/search?q=关键词
|
||||
|
||||
# 创建文章
|
||||
POST /api/articles
|
||||
{
|
||||
"product_names": ["产品1", "产品2"],
|
||||
"category": "分类",
|
||||
"keywords": ["关键词"],
|
||||
"summary": "摘要",
|
||||
"content": "内容",
|
||||
"source": "来源"
|
||||
}
|
||||
|
||||
# 删除文章
|
||||
DELETE /api/articles/{id}
|
||||
```
|
||||
|
||||
### 产品处理 API
|
||||
```bash
|
||||
# 待处理产品列表
|
||||
GET /api/products/pending
|
||||
|
||||
# 添加产品
|
||||
POST /api/products/pending
|
||||
{
|
||||
"product_name": "产品名称",
|
||||
"category": "分类",
|
||||
"priority": 10
|
||||
}
|
||||
|
||||
# 处理单个产品
|
||||
POST /api/products/process
|
||||
{
|
||||
"product_name": "产品名称"
|
||||
}
|
||||
|
||||
# 批量处理
|
||||
POST /api/products/process/batch
|
||||
{
|
||||
"limit": 5
|
||||
}
|
||||
|
||||
# 处理历史
|
||||
GET /api/products/history
|
||||
```
|
||||
|
||||
### 系统管理 API
|
||||
```bash
|
||||
# 系统统计
|
||||
GET /api/system/stats
|
||||
|
||||
# 系统配置
|
||||
GET /api/system/config
|
||||
PUT /api/system/config
|
||||
|
||||
# 健康检查
|
||||
GET /api/system/health
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ Git仓库推送
|
||||
|
||||
### ⚠️ 注意事项
|
||||
|
||||
当前Git服务器不允许用户直接推送创建仓库(Push to create),需要管理员预先创建仓库。
|
||||
|
||||
### 推送步骤
|
||||
|
||||
**方式1: 管理员预先创建仓库**
|
||||
|
||||
1. 在Git服务器创建仓库:
|
||||
- 地址: `http://121.40.164.32:12007/hz4th_coder/param-auto-manager.git`
|
||||
- 账号: `hz4th_coder`
|
||||
|
||||
2. 推送代码:
|
||||
```bash
|
||||
cd works/param-auto-manager
|
||||
git remote add origin http://hz4th_coder:262e7dbfce09c8cc21fbacff2b450cc3f1c3e265@121.40.164.32:12007/hz4th_coder/param-auto-manager.git
|
||||
git push -u origin master
|
||||
git push origin v1.1.0
|
||||
```
|
||||
|
||||
**方式2: 请求管理员推送权限**
|
||||
|
||||
联系Git服务器管理员,开通用户的"Push to create"权限。
|
||||
|
||||
---
|
||||
|
||||
## 📊 使用示例
|
||||
|
||||
### 1. 通过前端界面操作
|
||||
|
||||
1. **添加待处理产品**
|
||||
- 点击"添加产品"按钮
|
||||
- 输入产品名称(如: GPT-4o)
|
||||
- 设置分类和优先级
|
||||
- 点击"添加"
|
||||
|
||||
2. **添加文章到内容库**
|
||||
- 点击"添加文章"按钮
|
||||
- 填写产品名称、摘要、内容等
|
||||
- 点击"添加"
|
||||
|
||||
3. **手动触发处理**
|
||||
- 在待处理产品列表找到产品
|
||||
- 点击"处理"按钮
|
||||
- 查看处理结果
|
||||
|
||||
### 2. 通过API操作
|
||||
|
||||
```bash
|
||||
# 添加产品
|
||||
curl -X POST http://localhost:16043/api/products/pending \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"product_name":"GPT-4o","category":"AI模型","priority":10}'
|
||||
|
||||
# 添加文章
|
||||
curl -X POST http://localhost:16043/api/articles \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"product_names": ["GPT-4o"],
|
||||
"category": "AI模型",
|
||||
"keywords": ["大模型","多模态"],
|
||||
"summary": "OpenAI多模态大模型",
|
||||
"content": "详细内容...",
|
||||
"source": "官方网站"
|
||||
}'
|
||||
|
||||
# 触发处理
|
||||
curl -X POST http://localhost:16043/api/products/process \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"product_name":"GPT-4o"}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 系统配置
|
||||
|
||||
配置文件: `config.py`
|
||||
|
||||
```python
|
||||
PORT = 16043 # 服务端口
|
||||
PARAMHUB_BASE_URL = 'http://localhost:16041' # ParamHub API地址
|
||||
PROCESS_INTERVAL = 300 # 自动处理间隔(秒)
|
||||
BATCH_SIZE = 5 # 批量处理数量
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 项目结构
|
||||
|
||||
```
|
||||
param-auto-manager/
|
||||
├── app.py # 主应用
|
||||
├── config.py # 配置文件
|
||||
├── models/
|
||||
│ └── database.py # 数据库模型
|
||||
├── routes/
|
||||
│ ├── articles.py # 文章API
|
||||
│ ├── products.py # 产品API
|
||||
│ └── system.py # 系统API
|
||||
├── services/
|
||||
│ ├── search_service.py # 搜索服务
|
||||
│ ├── process_service.py # 处理服务
|
||||
│ └── paramhub_client.py # ParamHub客户端
|
||||
├── templates/
|
||||
│ └── index.html # 前端页面
|
||||
├── static/
|
||||
│ ├── css/style.css # 样式文件
|
||||
│ └── js/app.js # JavaScript文件
|
||||
├── utils/
|
||||
│ └── scheduler.py # 定时任务
|
||||
├── data/ # 数据库文件
|
||||
└── logs/ # 日志文件
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ 当前部署状态
|
||||
|
||||
- **端口**: 16043 ✅
|
||||
- **状态**: 运行中
|
||||
- **PID**: 2710498
|
||||
- **前端**: http://192.168.0.101:16043 ✅
|
||||
- **API**: http://192.168.0.101:16043/api ✅
|
||||
- **数据库**: SQLite (param_auto.db) ✅
|
||||
- **定时任务**: 每5分钟自动处理 ✅
|
||||
|
||||
---
|
||||
|
||||
## 📝 版本历史
|
||||
|
||||
- **v1.1.0** (2026-07-12): 添加前端界面和操作页面
|
||||
- **v1.0.0** (2026-07-12): 初始版本,核心功能实现
|
||||
|
||||
---
|
||||
|
||||
## 🆘 常见问题
|
||||
|
||||
### Q: Git推送失败怎么办?
|
||||
A: 需要在Git服务器上预先创建仓库,或联系管理员开通推送权限。
|
||||
|
||||
### Q: 如何查看日志?
|
||||
A: 日志文件位于 `logs/app.log`
|
||||
|
||||
### Q: 如何停止服务?
|
||||
A: 运行 `./stop.sh` 或手动杀掉进程
|
||||
|
||||
### Q: 前端页面打不开?
|
||||
A: 检查服务是否启动,查看日志是否有错误
|
||||
|
||||
---
|
||||
|
||||
## 📞 支持
|
||||
|
||||
如有问题,请查看日志文件或联系系统管理员。
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
参数数据自动化管理系统
|
||||
"""
|
||||
from flask import Flask, jsonify
|
||||
from flask import Flask, jsonify, render_template, send_from_directory
|
||||
from flask_cors import CORS
|
||||
from config import Config
|
||||
from models.database import db
|
||||
@@ -36,6 +36,11 @@ app.register_blueprint(system_bp)
|
||||
# 首页
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
# API首页
|
||||
@app.route('/api')
|
||||
def api_index():
|
||||
return jsonify({
|
||||
'name': 'Param Auto Manager',
|
||||
'version': '1.0.0',
|
||||
@@ -47,6 +52,11 @@ def index():
|
||||
}
|
||||
})
|
||||
|
||||
# 静态文件
|
||||
@app.route('/static/<path:filename>')
|
||||
def static_files(filename):
|
||||
return send_from_directory('static', filename)
|
||||
|
||||
# 错误处理
|
||||
@app.errorhandler(404)
|
||||
def not_found(error):
|
||||
|
||||
@@ -0,0 +1,645 @@
|
||||
/* 全局样式 */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 头部 */
|
||||
.header {
|
||||
background: white;
|
||||
padding: 20px 30px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
color: #667eea;
|
||||
font-size: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
background: #f0f0f0;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: #10b981;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
.status-dot.error {
|
||||
background: #ef4444;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
}
|
||||
|
||||
/* 统计卡片 */
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
background: #667eea;
|
||||
color: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.stat-icon.processing {
|
||||
background: #f59e0b;
|
||||
}
|
||||
|
||||
.stat-icon.success {
|
||||
background: #10b981;
|
||||
}
|
||||
|
||||
.stat-icon.error {
|
||||
background: #ef4444;
|
||||
}
|
||||
|
||||
.stat-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 面板 */
|
||||
.main-content {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.panel.full-width {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
padding: 20px;
|
||||
background: #f8f9fa;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.panel-header h2 {
|
||||
color: #667eea;
|
||||
font-size: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.panel-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
padding: 20px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* 按钮 */
|
||||
.btn {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #5568d3;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #6b7280;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #5a6270;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: #10b981;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-success:hover {
|
||||
background: #059669;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #ef4444;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #dc2626;
|
||||
}
|
||||
|
||||
.btn-warning {
|
||||
background: #f59e0b;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-warning:hover {
|
||||
background: #d97706;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
padding: 6px;
|
||||
background: transparent;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.btn-icon:hover {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
/* 输入框 */
|
||||
.search-input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
/* 数据表格 */
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
background: #f8f9fa;
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
border-bottom: 2px solid #e9ecef;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.data-table tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
/* 状态标签 */
|
||||
.status-badge-inline {
|
||||
padding: 4px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.status-badge-inline.submitted {
|
||||
background: #d1fae5;
|
||||
color: #065f46;
|
||||
}
|
||||
|
||||
.status-badge-inline.failed {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.status-badge-inline.error {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.status-badge-inline.processing {
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
/* 文章列表 */
|
||||
.articles-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.article-item {
|
||||
padding: 15px;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.article-item:hover {
|
||||
border-color: #667eea;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.article-title {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.article-meta span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
/* 配置表单 */
|
||||
.config-form {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.config-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.config-item label {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.config-item input,
|
||||
.config-item select {
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.config-item input:focus,
|
||||
.config-item select:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
/* 模态框 */
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 1000;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal.active {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-content.large {
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
padding: 20px;
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-radius: 12px 12px 0 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 20px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 0 0 12px 12px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* 表单 */
|
||||
.form-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group textarea,
|
||||
.form-group select {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group textarea:focus,
|
||||
.form-group select:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.hint {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* 提示消息 */
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
padding: 15px 20px;
|
||||
background: #333;
|
||||
color: white;
|
||||
border-radius: 8px;
|
||||
display: none;
|
||||
z-index: 1001;
|
||||
animation: slideIn 0.3s ease;
|
||||
}
|
||||
|
||||
.toast.success {
|
||||
background: #10b981;
|
||||
}
|
||||
|
||||
.toast.error {
|
||||
background: #ef4444;
|
||||
}
|
||||
|
||||
.toast.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 详情内容 */
|
||||
.detail-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.detail-section h4 {
|
||||
color: #667eea;
|
||||
margin-bottom: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.detail-section p {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.detail-meta {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 10px;
|
||||
background: #f8f9fa;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.detail-meta-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.detail-meta-item label {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.detail-meta-item span {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 768px) {
|
||||
.main-content {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.panel-actions {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
/* 加载动画 */
|
||||
.loading {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 2px solid #f3f3f3;
|
||||
border-top: 2px solid #667eea;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* 优先级指示 */
|
||||
.priority-high {
|
||||
color: #ef4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.priority-medium {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.priority-low {
|
||||
color: #10b981;
|
||||
}
|
||||
@@ -0,0 +1,615 @@
|
||||
// API基础地址
|
||||
const API_BASE = '';
|
||||
|
||||
// 当前选中的文章ID
|
||||
let currentArticleId = null;
|
||||
|
||||
// 页面加载时初始化
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
refreshData();
|
||||
loadConfig();
|
||||
|
||||
// 搜索框事件
|
||||
document.getElementById('article-search').addEventListener('input', (e) => {
|
||||
searchArticles(e.target.value);
|
||||
});
|
||||
|
||||
// 自动刷新(每30秒)
|
||||
setInterval(refreshData, 30000);
|
||||
});
|
||||
|
||||
// 刷新所有数据
|
||||
async function refreshData() {
|
||||
try {
|
||||
await Promise.all([
|
||||
loadStats(),
|
||||
loadPendingProducts(),
|
||||
loadArticles(),
|
||||
loadHistory()
|
||||
]);
|
||||
updateSystemStatus(true);
|
||||
} catch (error) {
|
||||
console.error('刷新数据失败:', error);
|
||||
updateSystemStatus(false);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新系统状态显示
|
||||
function updateSystemStatus(isHealthy) {
|
||||
const statusDot = document.getElementById('system-status');
|
||||
const statusText = document.getElementById('status-text');
|
||||
|
||||
if (isHealthy) {
|
||||
statusDot.classList.remove('error');
|
||||
statusText.textContent = '系统正常';
|
||||
} else {
|
||||
statusDot.classList.add('error');
|
||||
statusText.textContent = '系统异常';
|
||||
}
|
||||
}
|
||||
|
||||
// 加载统计数据
|
||||
async function loadStats() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/system/stats`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
document.getElementById('articles-count').textContent = data.stats.total_articles;
|
||||
document.getElementById('pending-count').textContent = data.stats.pending_products;
|
||||
document.getElementById('processing-count').textContent = data.stats.processing_products;
|
||||
document.getElementById('success-count').textContent = data.stats.recent_success;
|
||||
document.getElementById('failed-count').textContent = data.stats.recent_failed;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载统计失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载待处理产品
|
||||
async function loadPendingProducts() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/products/pending`);
|
||||
const data = await response.json();
|
||||
|
||||
const tbody = document.getElementById('pending-table');
|
||||
|
||||
if (data.success && data.products.length > 0) {
|
||||
tbody.innerHTML = data.products.map(product => `
|
||||
<tr>
|
||||
<td><strong>${escapeHtml(product.product_name)}</strong></td>
|
||||
<td>${escapeHtml(product.category || '-')}</td>
|
||||
<td>${escapeHtml(product.subcategory || '-')}</td>
|
||||
<td><span class="${getPriorityClass(product.priority)}">${product.priority}</span></td>
|
||||
<td>${escapeHtml(product.source)}</td>
|
||||
<td>${formatDate(product.created_at)}</td>
|
||||
<td>
|
||||
<button onclick="processProduct('${escapeHtml(product.product_name)}', '${escapeHtml(product.category || '')}', '${escapeHtml(product.subcategory || '')}')"
|
||||
class="btn btn-success btn-sm">
|
||||
<i class="ri-play-line"></i> 处理
|
||||
</button>
|
||||
<button onclick="removeProduct('${escapeHtml(product.product_name)}')"
|
||||
class="btn btn-danger btn-sm">
|
||||
<i class="ri-delete-bin-line"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} else {
|
||||
tbody.innerHTML = '<tr><td colspan="7" class="empty-text">暂无待处理产品</td></tr>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载待处理产品失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载文章列表
|
||||
async function loadArticles() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/articles?limit=50`);
|
||||
const data = await response.json();
|
||||
|
||||
const container = document.getElementById('articles-list');
|
||||
|
||||
if (data.success && data.articles.length > 0) {
|
||||
container.innerHTML = data.articles.map(article => `
|
||||
<div class="article-item" onclick="showArticleDetail(${article.id})">
|
||||
<div class="article-title">
|
||||
<i class="ri-file-text-line"></i>
|
||||
${escapeHtml(article.product_names.join(', '))}
|
||||
</div>
|
||||
<div class="article-meta">
|
||||
<span><i class="ri-folder-line"></i> ${escapeHtml(article.category || '未分类')}</span>
|
||||
<span><i class="ri-calendar-line"></i> ${formatDate(article.fetch_date)}</span>
|
||||
<span><i class="ri-link"></i> ${escapeHtml(article.source)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
} else {
|
||||
container.innerHTML = '<div class="empty-text">暂无文章</div>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载文章失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索文章
|
||||
async function searchArticles(keyword) {
|
||||
if (!keyword.trim()) {
|
||||
loadArticles();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/articles/search?q=${encodeURIComponent(keyword)}`);
|
||||
const data = await response.json();
|
||||
|
||||
const container = document.getElementById('articles-list');
|
||||
|
||||
if (data.success && data.articles.length > 0) {
|
||||
container.innerHTML = data.articles.map(article => `
|
||||
<div class="article-item" onclick="showArticleDetail(${article.id})">
|
||||
<div class="article-title">
|
||||
<i class="ri-file-text-line"></i>
|
||||
${escapeHtml(article.product_names.join(', '))}
|
||||
</div>
|
||||
<div class="article-meta">
|
||||
<span><i class="ri-folder-line"></i> ${escapeHtml(article.category || '未分类')}</span>
|
||||
<span><i class="ri-calendar-line"></i> ${formatDate(article.fetch_date)}</span>
|
||||
<span><i class="ri-link"></i> ${escapeHtml(article.source)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
} else {
|
||||
container.innerHTML = '<div class="empty-text">未找到相关文章</div>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索文章失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载处理历史
|
||||
async function loadHistory() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/products/history?limit=20`);
|
||||
const data = await response.json();
|
||||
|
||||
const tbody = document.getElementById('history-table');
|
||||
|
||||
if (data.success && data.history.length > 0) {
|
||||
tbody.innerHTML = data.history.map(item => `
|
||||
<tr>
|
||||
<td><strong>${escapeHtml(item.product_name)}</strong></td>
|
||||
<td>${escapeHtml(item.category || '-')}</td>
|
||||
<td>${escapeHtml(item.subcategory || '-')}</td>
|
||||
<td><span class="status-badge-inline ${item.status}">${getStatusText(item.status)}</span></td>
|
||||
<td>${escapeHtml(item.review_id || '-')}</td>
|
||||
<td>${formatDate(item.submitted_at)}</td>
|
||||
<td>
|
||||
<button onclick="showProcessDetail(${JSON.stringify(item.details).replace(/"/g, '"')})"
|
||||
class="btn btn-icon btn-sm">
|
||||
<i class="ri-information-line"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} else {
|
||||
tbody.innerHTML = '<tr><td colspan="7" class="empty-text">暂无处理历史</td></tr>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载处理历史失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载系统配置
|
||||
async function loadConfig() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/system/config`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
document.getElementById('auto-process-enabled').value = data.config.auto_process_enabled;
|
||||
document.getElementById('process-interval').value = data.config.process_interval;
|
||||
document.getElementById('batch-size').value = data.config.batch_size;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载配置失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存配置
|
||||
async function saveConfig() {
|
||||
const config = {
|
||||
auto_process_enabled: document.getElementById('auto-process-enabled').value,
|
||||
process_interval: document.getElementById('process-interval').value,
|
||||
batch_size: document.getElementById('batch-size').value
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/system/config`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(config)
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('配置已保存', 'success');
|
||||
} else {
|
||||
showToast('保存失败: ' + data.error, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('保存配置失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 显示添加产品模态框
|
||||
function showAddProductModal() {
|
||||
document.getElementById('add-product-modal').classList.add('active');
|
||||
document.getElementById('add-product-form').reset();
|
||||
}
|
||||
|
||||
// 显示添加文章模态框
|
||||
function showAddArticleModal() {
|
||||
document.getElementById('add-article-modal').classList.add('active');
|
||||
document.getElementById('add-article-form').reset();
|
||||
}
|
||||
|
||||
// 关闭模态框
|
||||
function closeModal(modalId) {
|
||||
document.getElementById(modalId).classList.remove('active');
|
||||
}
|
||||
|
||||
// 添加产品
|
||||
async function addProduct() {
|
||||
const batchProducts = document.getElementById('batch-products').value.trim();
|
||||
|
||||
let productsData;
|
||||
|
||||
if (batchProducts) {
|
||||
// 批量添加
|
||||
try {
|
||||
productsData = JSON.parse(batchProducts);
|
||||
} catch (e) {
|
||||
showToast('JSON格式错误', 'error');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 单个添加
|
||||
const productName = document.getElementById('product-name').value.trim();
|
||||
if (!productName) {
|
||||
showToast('请输入产品名称', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
productsData = {
|
||||
product_name: productName,
|
||||
category: document.getElementById('product-category').value.trim(),
|
||||
subcategory: document.getElementById('product-subcategory').value.trim(),
|
||||
priority: parseInt(document.getElementById('product-priority').value),
|
||||
source: 'manual'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/products/pending`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(productsData)
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast(`成功添加 ${data.added_count || 1} 个产品`, 'success');
|
||||
closeModal('add-product-modal');
|
||||
loadPendingProducts();
|
||||
loadStats();
|
||||
} else {
|
||||
showToast('添加失败: ' + data.error, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('添加产品失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 添加文章
|
||||
async function addArticle() {
|
||||
const products = document.getElementById('article-products').value.trim();
|
||||
const summary = document.getElementById('article-summary').value.trim();
|
||||
const content = document.getElementById('article-content').value.trim();
|
||||
const source = document.getElementById('article-source').value.trim();
|
||||
|
||||
if (!products || !summary || !content || !source) {
|
||||
showToast('请填写必填字段', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const articleData = {
|
||||
product_names: products.split(',').map(p => p.trim()),
|
||||
category: document.getElementById('article-category').value.trim(),
|
||||
keywords: document.getElementById('article-keywords').value.split(',').map(k => k.trim()),
|
||||
summary: summary,
|
||||
content: content,
|
||||
source: source,
|
||||
url: document.getElementById('article-url').value.trim()
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/articles`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(articleData)
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('文章添加成功', 'success');
|
||||
closeModal('add-article-modal');
|
||||
loadArticles();
|
||||
loadStats();
|
||||
} else {
|
||||
showToast('添加失败: ' + data.error, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('添加文章失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 处理单个产品
|
||||
async function processProduct(productName, category, subcategory) {
|
||||
if (!confirm(`确定要处理产品 "${productName}" 吗?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/products/process`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
product_name: productName,
|
||||
category: category,
|
||||
subcategory: subcategory
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast(data.message, 'success');
|
||||
if (data.new_products && data.new_products.length > 0) {
|
||||
showToast(`发现 ${data.new_products.length} 个新产品`, 'success');
|
||||
}
|
||||
} else {
|
||||
showToast('处理失败: ' + data.error || data.message, 'error');
|
||||
}
|
||||
|
||||
refreshData();
|
||||
} catch (error) {
|
||||
showToast('处理产品失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 批量处理
|
||||
async function processBatch() {
|
||||
if (!confirm('确定要批量处理待处理产品吗?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/products/process/batch`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ limit: 5 })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast(`已处理 ${data.processed} 个产品`, 'success');
|
||||
} else {
|
||||
showToast('批量处理失败', 'error');
|
||||
}
|
||||
|
||||
refreshData();
|
||||
} catch (error) {
|
||||
showToast('批量处理失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 移除待处理产品
|
||||
async function removeProduct(productName) {
|
||||
if (!confirm(`确定要从待处理列表移除 "${productName}" 吗?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/products/pending/${encodeURIComponent(productName)}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('产品已移除', 'success');
|
||||
loadPendingProducts();
|
||||
loadStats();
|
||||
} else {
|
||||
showToast('移除失败: ' + data.error, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('移除产品失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 显示文章详情
|
||||
async function showArticleDetail(articleId) {
|
||||
currentArticleId = articleId;
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/articles/${articleId}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
const article = data.article;
|
||||
const body = document.getElementById('article-detail-body');
|
||||
|
||||
body.innerHTML = `
|
||||
<div class="detail-meta">
|
||||
<div class="detail-meta-item">
|
||||
<label>产品名称</label>
|
||||
<span>${escapeHtml(article.product_names.join(', '))}</span>
|
||||
</div>
|
||||
<div class="detail-meta-item">
|
||||
<label>分类</label>
|
||||
<span>${escapeHtml(article.category || '未分类')}</span>
|
||||
</div>
|
||||
<div class="detail-meta-item">
|
||||
<label>关键词</label>
|
||||
<span>${escapeHtml(article.keywords.join(', ') || '无')}</span>
|
||||
</div>
|
||||
<div class="detail-meta-item">
|
||||
<label>来源</label>
|
||||
<span>${escapeHtml(article.source)}</span>
|
||||
</div>
|
||||
<div class="detail-meta-item">
|
||||
<label>获取日期</label>
|
||||
<span>${formatDate(article.fetch_date)}</span>
|
||||
</div>
|
||||
<div class="detail-meta-item">
|
||||
<label>URL</label>
|
||||
<span>${escapeHtml(article.url || '无')}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<h4><i class="ri-file-text-line"></i> 摘要总结</h4>
|
||||
<p>${escapeHtml(article.summary)}</p>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<h4><i class="ri-align-left"></i> 具体内容</h4>
|
||||
<p style="white-space: pre-wrap;">${escapeHtml(article.content)}</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.getElementById('article-detail-modal').classList.add('active');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('加载文章详情失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
async function deleteArticle() {
|
||||
if (!currentArticleId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm('确定要删除这篇文章吗?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api/articles/${currentArticleId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('文章已删除', 'success');
|
||||
closeModal('article-detail-modal');
|
||||
loadArticles();
|
||||
loadStats();
|
||||
} else {
|
||||
showToast('删除失败: ' + data.error, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('删除文章失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 显示处理详情
|
||||
function showProcessDetail(details) {
|
||||
const body = document.getElementById('process-detail-body');
|
||||
|
||||
if (details) {
|
||||
if (details.error) {
|
||||
body.innerHTML = `
|
||||
<div class="detail-section">
|
||||
<h4><i class="ri-error-warning-line"></i> 错误信息</h4>
|
||||
<p style="color: #ef4444;">${escapeHtml(details.error)}</p>
|
||||
</div>
|
||||
`;
|
||||
} else if (details.data) {
|
||||
body.innerHTML = `
|
||||
<div class="detail-section">
|
||||
<h4><i class="ri-check-line"></i> 提交数据</h4>
|
||||
<pre style="background: #f8f9fa; padding: 15px; border-radius: 8px; overflow-x: auto;">
|
||||
${JSON.stringify(details.data, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
body.innerHTML = '<p class="empty-text">无详细信息</p>';
|
||||
}
|
||||
} else {
|
||||
body.innerHTML = '<p class="empty-text">无详细信息</p>';
|
||||
}
|
||||
|
||||
document.getElementById('process-detail-modal').classList.add('active');
|
||||
}
|
||||
|
||||
// 显示提示消息
|
||||
function showToast(message, type = '') {
|
||||
const toast = document.getElementById('toast');
|
||||
toast.textContent = message;
|
||||
toast.className = `toast active ${type}`;
|
||||
|
||||
setTimeout(() => {
|
||||
toast.classList.remove('active');
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 辅助函数:HTML转义
|
||||
function escapeHtml(text) {
|
||||
if (!text) return '';
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
// 辅助函数:日期格式化
|
||||
function formatDate(dateString) {
|
||||
if (!dateString) return '-';
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
|
||||
// 辅助函数:获取优先级样式类
|
||||
function getPriorityClass(priority) {
|
||||
if (priority >= 8) return 'priority-high';
|
||||
if (priority >= 5) return 'priority-medium';
|
||||
return 'priority-low';
|
||||
}
|
||||
|
||||
// 辅助函数:获取状态文本
|
||||
function getStatusText(status) {
|
||||
const statusMap = {
|
||||
'submitted': '已提交',
|
||||
'processing': '处理中',
|
||||
'failed': '失败',
|
||||
'error': '错误',
|
||||
'completed': '已完成'
|
||||
};
|
||||
return statusMap[status] || status;
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>参数数据自动化管理系统</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- 头部 -->
|
||||
<header class="header">
|
||||
<h1><i class="ri-robot-line"></i> 参数数据自动化管理系统</h1>
|
||||
<div class="header-actions">
|
||||
<button onclick="refreshData()" class="btn btn-secondary">
|
||||
<i class="ri-refresh-line"></i> 刷新数据
|
||||
</button>
|
||||
<div class="status-badge">
|
||||
<span id="system-status" class="status-dot"></span>
|
||||
<span id="status-text">系统正常</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 统计卡片 -->
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon"><i class="ri-file-list-3-line"></i></div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-label">内容库文章</div>
|
||||
<div class="stat-value" id="articles-count">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon"><i class="ri-time-line"></i></div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-label">待处理产品</div>
|
||||
<div class="stat-value" id="pending-count">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon processing"><i class="ri-loader-4-line"></i></div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-label">处理中</div>
|
||||
<div class="stat-value" id="processing-count">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon success"><i class="ri-check-line"></i></div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-label">最近成功</div>
|
||||
<div class="stat-value" id="success-count">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon error"><i class="ri-close-circle-line"></i></div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-label">最近失败</div>
|
||||
<div class="stat-value" id="failed-count">0</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主内容区域 -->
|
||||
<div class="main-content">
|
||||
<!-- 左侧:待处理产品 -->
|
||||
<div class="panel">
|
||||
<div class="panel-header">
|
||||
<h2><i class="ri-list-check-2"></i> 待处理产品列表</h2>
|
||||
<div class="panel-actions">
|
||||
<button onclick="showAddProductModal()" class="btn btn-primary">
|
||||
<i class="ri-add-line"></i> 添加产品
|
||||
</button>
|
||||
<button onclick="processBatch()" class="btn btn-success">
|
||||
<i class="ri-play-line"></i> 批量处理
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>产品名称</th>
|
||||
<th>分类</th>
|
||||
<th>子分类</th>
|
||||
<th>优先级</th>
|
||||
<th>来源</th>
|
||||
<th>添加时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="pending-table">
|
||||
<tr><td colspan="7" class="empty-text">暂无待处理产品</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:内容库 -->
|
||||
<div class="panel">
|
||||
<div class="panel-header">
|
||||
<h2><i class="ri-folder-line"></i> 内容库文章</h2>
|
||||
<div class="panel-actions">
|
||||
<input type="text" id="article-search" placeholder="搜索文章..." class="search-input">
|
||||
<button onclick="showAddArticleModal()" class="btn btn-primary">
|
||||
<i class="ri-add-line"></i> 添加文章
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="articles-list" id="articles-list">
|
||||
<div class="empty-text">暂无文章</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 处理历史 -->
|
||||
<div class="panel full-width">
|
||||
<div class="panel-header">
|
||||
<h2><i class="ri-history-line"></i> 处理历史</h2>
|
||||
<button onclick="loadHistory()" class="btn btn-secondary btn-sm">
|
||||
<i class="ri-refresh-line"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>产品名称</th>
|
||||
<th>分类</th>
|
||||
<th>子分类</th>
|
||||
<th>状态</th>
|
||||
<th>审核ID</th>
|
||||
<th>提交时间</th>
|
||||
<th>详情</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="history-table">
|
||||
<tr><td colspan="7" class="empty-text">暂无处理历史</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 系统配置 -->
|
||||
<div class="panel full-width">
|
||||
<div class="panel-header">
|
||||
<h2><i class="ri-settings-3-line"></i> 系统配置</h2>
|
||||
<button onclick="saveConfig()" class="btn btn-primary btn-sm">
|
||||
<i class="ri-save-line"></i> 保存配置
|
||||
</button>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="config-form">
|
||||
<div class="config-item">
|
||||
<label>自动处理</label>
|
||||
<select id="auto-process-enabled">
|
||||
<option value="true">启用</option>
|
||||
<option value="false">禁用</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<label>处理间隔(秒)</label>
|
||||
<input type="number" id="process-interval" value="300" min="60" max="3600">
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<label>批量处理数量</label>
|
||||
<input type="number" id="batch-size" value="5" min="1" max="20">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 添加产品模态框 -->
|
||||
<div id="add-product-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3><i class="ri-add-circle-line"></i> 添加待处理产品</h3>
|
||||
<button onclick="closeModal('add-product-modal')" class="close-btn">
|
||||
<i class="ri-close-line"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="add-product-form">
|
||||
<div class="form-group">
|
||||
<label>产品名称 *</label>
|
||||
<input type="text" id="product-name" required placeholder="例如:GPT-4o">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分类</label>
|
||||
<input type="text" id="product-category" placeholder="例如:AI模型">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>子分类</label>
|
||||
<input type="text" id="product-subcategory" placeholder="例如:model">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>优先级</label>
|
||||
<input type="number" id="product-priority" value="5" min="0" max="100">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>批量添加(JSON格式)</label>
|
||||
<textarea id="batch-products" rows="5" placeholder='[{"product_name":"产品1"},{"product_name":"产品2"}]'></textarea>
|
||||
<small class="hint">批量添加时,单产品字段将被忽略</small>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button onclick="closeModal('add-product-modal')" class="btn btn-secondary">取消</button>
|
||||
<button onclick="addProduct()" class="btn btn-primary">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 添加文章模态框 -->
|
||||
<div id="add-article-modal" class="modal">
|
||||
<div class="modal-content large">
|
||||
<div class="modal-header">
|
||||
<h3><i class="ri-file-add-line"></i> 添加文章到内容库</h3>
|
||||
<button onclick="closeModal('add-article-modal')" class="close-btn">
|
||||
<i class="ri-close-line"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="add-article-form">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>产品名称 *(多个用逗号分隔)</label>
|
||||
<input type="text" id="article-products" required placeholder="GPT-4o, Claude 3">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分类</label>
|
||||
<input type="text" id="article-category" placeholder="AI模型">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>关键词(多个用逗号分隔)</label>
|
||||
<input type="text" id="article-keywords" placeholder="大模型, 多模态, 推理">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>摘要总结 *</label>
|
||||
<textarea id="article-summary" rows="3" required placeholder="文章简要总结..."></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>具体内容 *</label>
|
||||
<textarea id="article-content" rows="10" required placeholder="文章详细内容..."></textarea>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>来源 *</label>
|
||||
<input type="text" id="article-source" required placeholder="官方网站/新闻">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>URL</label>
|
||||
<input type="url" id="article-url" placeholder="https://...">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button onclick="closeModal('add-article-modal')" class="btn btn-secondary">取消</button>
|
||||
<button onclick="addArticle()" class="btn btn-primary">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 文章详情模态框 -->
|
||||
<div id="article-detail-modal" class="modal">
|
||||
<div class="modal-content large">
|
||||
<div class="modal-header">
|
||||
<h3><i class="ri-file-text-line"></i> 文章详情</h3>
|
||||
<button onclick="closeModal('article-detail-modal')" class="close-btn">
|
||||
<i class="ri-close-line"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="article-detail-body">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button onclick="closeModal('article-detail-modal')" class="btn btn-secondary">关闭</button>
|
||||
<button onclick="deleteArticle()" class="btn btn-danger">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 处理详情模态框 -->
|
||||
<div id="process-detail-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3><i class="ri-information-line"></i> 处理详情</h3>
|
||||
<button onclick="closeModal('process-detail-modal')" class="close-btn">
|
||||
<i class="ri-close-line"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="process-detail-body">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button onclick="closeModal('process-detail-modal')" class="btn btn-secondary">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 提示消息 -->
|
||||
<div id="toast" class="toast"></div>
|
||||
|
||||
<script src="/static/js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user