newpage
This commit is contained in:
1 parent
ce24352cf6
commit
41cba06648
22 files changed
+1101
-358
No files matched your search
@@ -312,6 +312,10 @@ def manage_raw_files(subpath=None):
|
||||
if subpath is None:
|
||||
storage_root = current_app.config['RAW_DATA_STORAGE_FOLDER']
|
||||
|
||||
# 确保根目录存在,防止 404 错误
|
||||
if not os.path.exists(storage_root):
|
||||
os.makedirs(storage_root)
|
||||
|
||||
# 1. 从数据库获取记录
|
||||
db_folders_query = RawDataFolder.query.all()
|
||||
db_folder_map = {f.folder_name: f for f in db_folders_query}
|
||||
|
||||
+115
-2
@@ -6,7 +6,7 @@ from . import main
|
||||
from ..models import DataEntry, Notification # 确保 Notification 已导入
|
||||
from .forms import SearchForm # 1. 导入 SearchForm
|
||||
from sqlalchemy import or_, and_
|
||||
from flask import render_template, redirect, url_for
|
||||
from flask import render_template, redirect, url_for, jsonify, request
|
||||
@main.route('/search', methods=['POST'])
|
||||
@login_required
|
||||
def search():
|
||||
@@ -20,6 +20,7 @@ def search():
|
||||
|
||||
data_entry_results = []
|
||||
notification_results = []
|
||||
raw_file_results = []
|
||||
|
||||
# 根据用户角色执行不同的查询
|
||||
if current_user.is_admin():
|
||||
@@ -31,6 +32,13 @@ def search():
|
||||
notification_results = Notification.query.filter(
|
||||
or_(Notification.title.ilike(search_term), Notification.content.ilike(search_term))
|
||||
).order_by(Notification.timestamp.desc()).all()
|
||||
|
||||
# 管理员:搜索 RawDataFolder
|
||||
# 注意:这里需要从 ..models 导入 RawDataFolder,如果上面没有导入,需要添加
|
||||
from ..models import RawDataFolder
|
||||
raw_file_results = RawDataFolder.query.filter(
|
||||
RawDataFolder.folder_name.ilike(search_term)
|
||||
).order_by(RawDataFolder.folder_name).all()
|
||||
|
||||
else:
|
||||
# 普通用户:只搜索他们有权查看的数据
|
||||
@@ -53,7 +61,112 @@ def search():
|
||||
return render_template('search_results.html',
|
||||
query=query,
|
||||
data_entries=data_entry_results,
|
||||
notifications=notification_results)
|
||||
notifications=notification_results,
|
||||
raw_files=raw_file_results)
|
||||
|
||||
@main.route('/search/suggestions')
|
||||
@login_required
|
||||
def search_suggestions():
|
||||
query = request.args.get('q', '')
|
||||
if len(query) < 1:
|
||||
return jsonify([])
|
||||
|
||||
search_term = f"%{query}%"
|
||||
suggestions = []
|
||||
|
||||
# 1. 功能导航 (Hardcoded)
|
||||
features = [
|
||||
{'name': '仪表盘', 'url': url_for('main.dashboard'), 'keywords': ['dashboard', 'home', '主页', '仪表盘']},
|
||||
{'name': '个人数据', 'url': url_for('main.dashboard'), 'keywords': ['data', 'my data', '数据']},
|
||||
{'name': '系统通知', 'url': url_for('main.notifications'), 'keywords': ['notification', 'notice', '通知', '公告']}
|
||||
]
|
||||
if current_user.is_admin():
|
||||
features.extend([
|
||||
{'name': '管理面板', 'url': url_for('admin.dashboard'), 'keywords': ['admin', 'manage', '管理']},
|
||||
{'name': '用户管理', 'url': url_for('admin.manage_users'), 'keywords': ['user', 'account', '用户', '账号']},
|
||||
{'name': '数据上传', 'url': url_for('admin.upload_data'), 'keywords': ['upload', '上传', 'import']},
|
||||
{'name': '原始文件管理', 'url': url_for('admin.manage_raw_files'), 'keywords': ['raw', 'file', '原始', '文件']},
|
||||
{'name': '数据整合', 'url': url_for('admin.integration_manager'), 'keywords': ['integration', 'process', '整合', '处理']},
|
||||
{'name': 'AI推理', 'url': url_for('admin.inference_manager'), 'keywords': ['ai', 'inference', 'model', '推理', '诊断']}
|
||||
])
|
||||
|
||||
for feature in features:
|
||||
for kw in feature.keywords:
|
||||
if kw in query.lower() or query.lower() in kw:
|
||||
suggestions.append({
|
||||
'type': '功能',
|
||||
'title': feature['name'],
|
||||
'url': feature['url'],
|
||||
'icon': 'fa-solid fa-compass'
|
||||
})
|
||||
break
|
||||
|
||||
# 2. 数据库查询
|
||||
if current_user.is_admin():
|
||||
# DataEntries
|
||||
entries = DataEntry.query.filter(DataEntry.title.ilike(search_term)).limit(5).all()
|
||||
for e in entries:
|
||||
suggestions.append({
|
||||
'type': '数据',
|
||||
'title': e.title,
|
||||
'url': url_for('admin.view_csv', entry_id=e.id),
|
||||
'icon': 'fa-solid fa-database'
|
||||
})
|
||||
|
||||
# Notifications
|
||||
notifs = Notification.query.filter(Notification.title.ilike(search_term)).limit(3).all()
|
||||
for n in notifs:
|
||||
suggestions.append({
|
||||
'type': '通知',
|
||||
'title': n.title,
|
||||
'url': url_for('main.notifications'), # 暂时跳转到列表页
|
||||
'icon': 'fa-solid fa-bullhorn'
|
||||
})
|
||||
|
||||
# Raw Files
|
||||
from ..models import RawDataFolder
|
||||
folders = RawDataFolder.query.filter(RawDataFolder.folder_name.ilike(search_term)).limit(3).all()
|
||||
for f in folders:
|
||||
suggestions.append({
|
||||
'type': '原始文件',
|
||||
'title': f.folder_name,
|
||||
'url': url_for('admin.manage_raw_files', subpath=f.folder_name),
|
||||
'icon': 'fa-regular fa-folder'
|
||||
})
|
||||
|
||||
else:
|
||||
# User DataEntries
|
||||
entries = DataEntry.query.with_parent(current_user).filter(
|
||||
and_(
|
||||
or_(DataEntry.expiration_date == None, DataEntry.expiration_date > datetime.utcnow()),
|
||||
DataEntry.title.ilike(search_term)
|
||||
)
|
||||
).limit(5).all()
|
||||
for e in entries:
|
||||
suggestions.append({
|
||||
'type': '数据',
|
||||
'title': e.title,
|
||||
'url': url_for('main.dashboard'), # 用户只能去仪表盘查看
|
||||
'icon': 'fa-solid fa-database'
|
||||
})
|
||||
|
||||
# User Notifications
|
||||
notifs = Notification.query.filter(
|
||||
and_(
|
||||
Notification.is_published == True,
|
||||
Notification.title.ilike(search_term)
|
||||
)
|
||||
).limit(3).all()
|
||||
for n in notifs:
|
||||
suggestions.append({
|
||||
'type': '通知',
|
||||
'title': n.title,
|
||||
'url': url_for('main.notifications'),
|
||||
'icon': 'fa-solid fa-bullhorn'
|
||||
})
|
||||
|
||||
# 限制返回数量,防止下拉框过长
|
||||
return jsonify(suggestions[:10])
|
||||
# 2. 添加上下文处理器
|
||||
@main.app_context_processor
|
||||
def inject_search_form():
|
||||
|
||||
@@ -8,9 +8,6 @@ import padasip as pa
|
||||
from tqdm import tqdm
|
||||
import shutil
|
||||
|
||||
# 从您的脚本中提取的所有核心函数都放在这里
|
||||
# ... (我们将在这里填充下面的函数) ...
|
||||
|
||||
# 总调度函数
|
||||
def run_full_pipeline(source_id, original_txt_path):
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
:root {
|
||||
--primary-color: #4f46e5; /* Indigo 600 */
|
||||
--primary-hover: #4338ca; /* Indigo 700 */
|
||||
--secondary-color: #64748b; /* Slate 500 */
|
||||
--bg-color: #f8fafc; /* Slate 50 */
|
||||
--card-bg: #ffffff;
|
||||
--text-main: #1e293b; /* Slate 800 */
|
||||
--text-muted: #64748b;
|
||||
--border-color: #e2e8f0; /* Slate 200 */
|
||||
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
|
||||
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
||||
--radius-md: 0.5rem;
|
||||
--radius-lg: 0.75rem;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-main);
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-weight: 600;
|
||||
color: #0f172a; /* Slate 900 */
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: var(--primary-hover);
|
||||
}
|
||||
|
||||
/* Navbar */
|
||||
.navbar {
|
||||
background-color: #fff !important;
|
||||
box-shadow: var(--shadow-sm);
|
||||
padding: 0.75rem 0;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-weight: 700;
|
||||
color: var(--primary-color) !important;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
color: var(--text-main) !important;
|
||||
font-weight: 500;
|
||||
padding: 0.5rem 1rem !important;
|
||||
border-radius: var(--radius-md);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.nav-link:hover, .nav-link.active {
|
||||
background-color: #eff6ff; /* Blue 50 */
|
||||
color: var(--primary-color) !important;
|
||||
}
|
||||
|
||||
/* Cards */
|
||||
.card {
|
||||
background-color: var(--card-bg);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
background-color: transparent;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding: 1rem 1.25rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
border-radius: var(--radius-md);
|
||||
padding: 0.5rem 1rem;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: var(--primary-hover);
|
||||
border-color: var(--primary-hover);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
.list-group-item {
|
||||
border: none;
|
||||
padding: 0.75rem 1rem;
|
||||
color: var(--text-main);
|
||||
border-radius: var(--radius-md) !important;
|
||||
margin-bottom: 0.25rem;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.list-group-item:hover {
|
||||
background-color: #f1f5f9; /* Slate 100 */
|
||||
}
|
||||
|
||||
.list-group-item.active {
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.list-group-item-secondary {
|
||||
background-color: transparent;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.05em;
|
||||
margin-top: 1rem;
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
|
||||
/* Tables */
|
||||
.table {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.table th {
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
background-color: #f8fafc;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
border-radius: var(--radius-lg);
|
||||
border: 1px solid var(--border-color);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
footer {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
/* Hero Section (for Index) */
|
||||
.hero-section {
|
||||
padding: 5rem 0;
|
||||
background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
|
||||
border-radius: 0 0 2rem 2rem;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 3rem;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
background: -webkit-linear-gradient(45deg, #4f46e5, #0ea5e9);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.feature-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border-radius: 0.75rem;
|
||||
background-color: #e0e7ff;
|
||||
color: var(--primary-color);
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
/* Utilities */
|
||||
.text-muted-sm {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.shadow-soft {
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.badge-soft-success {
|
||||
background-color: #dcfce7;
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
.badge-soft-warning {
|
||||
background-color: #fef9c3;
|
||||
color: #854d0e;
|
||||
}
|
||||
|
||||
.badge-soft-danger {
|
||||
background-color: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
/* Data Block (Dashboard) */
|
||||
.data-block {
|
||||
background: #fff;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.data-block:hover {
|
||||
box-shadow: var(--shadow-md);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.data-block.private {
|
||||
border-left: 4px solid var(--secondary-color);
|
||||
}
|
||||
|
||||
/* Search Suggestions */
|
||||
#searchSuggestions .list-group-item {
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
#searchSuggestions .list-group-item:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
#searchSuggestions .list-group-item:hover {
|
||||
background-color: #f8fafc;
|
||||
}
|
||||
@@ -2,47 +2,86 @@
|
||||
{% extends "dashboard_base.html" %}
|
||||
|
||||
{% block dashboard_content %}
|
||||
<h1>管理员仪表盘</h1>
|
||||
<p>欢迎, 管理员! 你可以看到所有数据(包括对用户已过期的条目)。</p>
|
||||
<hr>
|
||||
{% for entry in data_entries %}
|
||||
{# 使用 is_expired() 方法来检查状态 #}
|
||||
<div class="data-block {% if entry.is_expired() %}private{% endif %}">
|
||||
<h3>
|
||||
{{ entry.title }}
|
||||
{# 如果已过期,则添加一个清晰的红色标签 #}
|
||||
{% if entry.is_expired() %}
|
||||
<span style="font-size: 0.8em; color: red; font-weight: bold;">(已过期)</span>
|
||||
{% endif %}
|
||||
</h3>
|
||||
<p>{{ entry.content }}</p>
|
||||
<p>
|
||||
<strong>可见用户:</strong>
|
||||
{% for user in entry.visible_to_users %}
|
||||
<span style="background-color: #eee; padding: 2px 5px; border-radius: 3px;">{{ user.username }}</span>
|
||||
{% else %}
|
||||
<em>无</em>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<div class="mb-2">
|
||||
{% for attachment in entry.attachments %}
|
||||
<a href="{{ url_for('admin.download_attachment', attachment_id=attachment.id) }}" class="btn btn-sm btn-outline-primary me-1 mb-1">
|
||||
<i class="fa-solid fa-paperclip me-1"></i>{{ attachment.original_name }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<small>创建于: {{ entry.timestamp.strftime('%Y-%m-%d %H:%M') }}</small>
|
||||
<br>
|
||||
<small>
|
||||
<strong>过期时间:</strong>
|
||||
{% if entry.expiration_date %}
|
||||
{{ entry.expiration_date.strftime('%Y-%m-%d %H:%M') }}
|
||||
{% else %}
|
||||
永不过期
|
||||
{% endif %}
|
||||
</small>
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h2 class="fw-bold mb-0">管理员仪表盘</h2>
|
||||
<p class="text-muted mb-0">概览系统中的所有数据条目与状态</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>数据库中没有任何数据。请前往 <a href="{{ url_for('admin.manage_data') }}">管理数据</a> 页面添加。</p>
|
||||
{% endfor %}
|
||||
<a href="{{ url_for('admin.manage_data') }}" class="btn btn-primary shadow-sm">
|
||||
<i class="fa-solid fa-plus me-2"></i>新增数据
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
{% for entry in data_entries %}
|
||||
<div class="col-md-6 col-xl-4">
|
||||
<div class="card h-100 border-0 shadow-sm {% if entry.is_expired() %}opacity-75{% endif %}">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||||
<h5 class="card-title fw-bold text-truncate" title="{{ entry.title }}">{{ entry.title }}</h5>
|
||||
{% if entry.is_expired() %}
|
||||
<span class="badge bg-danger rounded-pill">已过期</span>
|
||||
{% else %}
|
||||
<span class="badge bg-success rounded-pill">有效</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<p class="card-text text-muted small mb-3" style="min-height: 3rem;">
|
||||
{{ entry.content | truncate(80) }}
|
||||
</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<small class="fw-bold text-uppercase text-muted" style="font-size: 0.7rem;">可见用户</small>
|
||||
<div class="mt-1 d-flex flex-wrap gap-1">
|
||||
{% for user in entry.visible_to_users[:3] %}
|
||||
<span class="badge bg-light text-dark border">{{ user.username }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted small fst-italic">无特定用户</span>
|
||||
{% endfor %}
|
||||
{% if entry.visible_to_users|length > 3 %}
|
||||
<span class="badge bg-light text-dark border">+{{ entry.visible_to_users|length - 3 }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if entry.attachments %}
|
||||
<div class="mb-3">
|
||||
<small class="fw-bold text-uppercase text-muted" style="font-size: 0.7rem;">附件</small>
|
||||
<div class="mt-1">
|
||||
{% for attachment in entry.attachments[:2] %}
|
||||
<a href="{{ url_for('admin.download_attachment', attachment_id=attachment.id) }}" class="badge bg-indigo-50 text-primary text-decoration-none border border-primary-subtle mb-1">
|
||||
<i class="fa-solid fa-paperclip me-1"></i>{{ attachment.original_name | truncate(15) }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% if entry.attachments|length > 2 %}
|
||||
<small class="text-muted ms-1">+{{ entry.attachments|length - 2 }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-footer bg-white border-top-0 pt-0">
|
||||
<div class="d-flex justify-content-between align-items-center small text-muted">
|
||||
<span><i class="fa-regular fa-clock me-1"></i>{{ entry.timestamp.strftime('%Y-%m-%d') }}</span>
|
||||
{% if entry.expiration_date %}
|
||||
<span title="过期时间: {{ entry.expiration_date.strftime('%Y-%m-%d') }}">
|
||||
<i class="fa-solid fa-hourglass-end me-1"></i>{{ entry.expiration_date.strftime('%m-%d') }}
|
||||
</span>
|
||||
{% else %}
|
||||
<span><i class="fa-solid fa-infinity me-1"></i>永久</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-12">
|
||||
<div class="text-center py-5 bg-light rounded-3 border border-dashed">
|
||||
<i class="fa-regular fa-folder-open fa-3x text-muted mb-3 opacity-50"></i>
|
||||
<p class="text-muted mb-3">暂无数据条目</p>
|
||||
<a href="{{ url_for('admin.manage_data') }}" class="btn btn-sm btn-outline-primary">立即添加</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,113 +1,164 @@
|
||||
{# app/templates/admin/manage_data.html (修改此文件) #}
|
||||
{% extends "dashboard_base.html" %} {# <-- 继承 dashboard_base 以获得侧边栏 #}
|
||||
{% extends "dashboard_base.html" %}
|
||||
|
||||
{% block dashboard_content %} {# <-- 填充 dashboard_content 块 #}
|
||||
<div class="row">
|
||||
<!-- 左侧:表单 -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header"><h5 class="mb-0">添加/编辑数据</h5></div>
|
||||
<div class="card-body">
|
||||
<form method="POST" enctype="multipart/form-data"> {# <-- 添加 enctype #}
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="mb-3">
|
||||
{{ form.title.label(class="form-label") }}
|
||||
{{ form.title(class="form-control") }}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.content.label(class="form-label") }}
|
||||
{{ form.content(class="form-control", rows=4) }}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.visible_for_days.label(class="form-label") }}
|
||||
{{ form.visible_for_days(class="form-control") }}
|
||||
</div>
|
||||
|
||||
{# --- 新增:文件上传字段 --- #}
|
||||
<div class="mb-3">
|
||||
{{ form.csv_file.label(class="form-label") }}
|
||||
{{ form.csv_file(class="form-control") }}
|
||||
{% for error in form.csv_file.errors %}
|
||||
<div class="text-danger mt-1"><small>{{ error }}</small></div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% block dashboard_content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h2 class="fw-bold mb-0">数据管理</h2>
|
||||
<p class="text-muted mb-0">上传新数据或管理现有条目</p>
|
||||
</div>
|
||||
<button class="btn btn-primary shadow-sm" type="button" data-bs-toggle="collapse" data-bs-target="#createDataForm" aria-expanded="false" aria-controls="createDataForm">
|
||||
<i class="fa-solid fa-plus me-2"></i>添加数据
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.attachments.label(class="form-label") }}
|
||||
{{ form.attachments(class="form-control", multiple=True) }}
|
||||
<div class="form-text">可以同时选择多个文件作为附件。</div>
|
||||
{% for error in form.attachments.errors %}
|
||||
<div class="text-danger mt-1"><small>{{ error }}</small></div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{# --- 新增结束 --- #}
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.users.label(class="form-label") }}
|
||||
<div class="border rounded p-2" style="height: 150px; overflow-y: auto;">
|
||||
{{ form.users(class="form-check-input") }}
|
||||
<!-- 可折叠的创建表单 -->
|
||||
<div class="collapse mb-4" id="createDataForm">
|
||||
<div class="card shadow-sm border-0 bg-light">
|
||||
<div class="card-body p-4">
|
||||
<h5 class="card-title fw-bold mb-3">创建新数据条目</h5>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.title.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
{{ form.title(class="form-control", placeholder="输入数据标题") }}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.visible_for_days.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
<div class="input-group">
|
||||
{{ form.visible_for_days(class="form-control", placeholder="例如: 30") }}
|
||||
<span class="input-group-text text-muted">天</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.csv_file.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
{{ form.csv_file(class="form-control") }}
|
||||
{% for error in form.csv_file.errors %}
|
||||
<div class="text-danger small mt-1">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.attachments.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
{{ form.attachments(class="form-control", multiple=True) }}
|
||||
<div class="form-text small">支持多文件上传</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-grid">
|
||||
{{ form.submit(class="btn btn-primary") }}
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.content.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
{{ form.content(class="form-control", rows=4, placeholder="输入详细描述...") }}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.users.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
<div class="card p-2" style="height: 185px; overflow-y: auto;">
|
||||
{% for subfield in form.users %}
|
||||
<div class="form-check">
|
||||
{{ subfield(class="form-check-input") }}
|
||||
{{ subfield.label(class="form-check-label") }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2 mt-3">
|
||||
<button type="button" class="btn btn-light border" data-bs-toggle="collapse" data-bs-target="#createDataForm">取消</button>
|
||||
{{ form.submit(class="btn btn-primary px-4") }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:数据列表 -->
|
||||
<div class="col-lg-8">
|
||||
<h3 class="mb-3">现有数据</h3>
|
||||
{% for entry in data_entries %}
|
||||
<div class="card shadow-sm mb-3">
|
||||
<!-- 数据列表 -->
|
||||
<div class="row g-4">
|
||||
{% for entry in data_entries %}
|
||||
<div class="col-md-6 col-xl-4">
|
||||
<div class="card h-100 shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ entry.title }}</h5>
|
||||
<p class="card-text">{{ entry.content }}</p>
|
||||
<p class="card-text">
|
||||
<strong>可见用户:</strong>
|
||||
{% for user in entry.visible_to_users %}
|
||||
<span class="badge bg-secondary">{{ user.username }}</span>
|
||||
{% else %}
|
||||
<em>无</em>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<hr>
|
||||
<div class="mb-3">
|
||||
<strong>附件:</strong>
|
||||
{% for attachment in entry.attachments %}
|
||||
<a href="{{ url_for('admin.download_attachment', attachment_id=attachment.id) }}" class="btn btn-sm btn-link">
|
||||
<i class="fa-solid fa-paperclip me-1"></i>{{ attachment.original_name }}
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="text-muted"><small>无附件</small></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<hr>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
{# --- 新增:查看CSV链接 --- #}
|
||||
{% if entry.associated_filename %}
|
||||
<a href="{{ url_for('admin.view_csv', entry_id=entry.id) }}" class="btn btn-sm btn-outline-info">
|
||||
<i class="fa-solid fa-table fa-fw me-1"></i>查看CSV
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="text-muted"><small>无关联CSV</small></span>
|
||||
{% endif %}
|
||||
{# --- 新增结束 --- #}
|
||||
</div>
|
||||
<form action="{{ url_for('admin.delete_data', entry_id=entry.id) }}" method="post" class="d-inline" enctype="multipart/form-data">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('确定要删除这条数据吗?');">
|
||||
<i class="fa-solid fa-trash fa-fw me-1"></i>删除
|
||||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||||
<h5 class="card-title fw-bold text-truncate" title="{{ entry.title }}">{{ entry.title }}</h5>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-link text-muted p-0" type="button" data-bs-toggle="dropdown">
|
||||
<i class="fa-solid fa-ellipsis-vertical"></i>
|
||||
</button>
|
||||
</form>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow-sm border-0">
|
||||
{% if entry.associated_filename %}
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ url_for('admin.view_csv', entry_id=entry.id) }}">
|
||||
<i class="fa-solid fa-table me-2 text-info"></i>查看CSV
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<form action="{{ url_for('admin.delete_data', entry_id=entry.id) }}" method="post" class="d-inline">
|
||||
<button type="submit" class="dropdown-item text-danger" onclick="return confirm('确定要删除这条数据吗?');">
|
||||
<i class="fa-solid fa-trash me-2"></i>删除
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="card-text text-muted small mb-3" style="min-height: 3rem;">
|
||||
{{ entry.content | truncate(80) }}
|
||||
</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<small class="fw-bold text-uppercase text-muted" style="font-size: 0.7rem;">可见用户</small>
|
||||
<div class="mt-1 d-flex flex-wrap gap-1">
|
||||
{% for user in entry.visible_to_users[:3] %}
|
||||
<span class="badge bg-light text-dark border">{{ user.username }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted small fst-italic">无特定用户</span>
|
||||
{% endfor %}
|
||||
{% if entry.visible_to_users|length > 3 %}
|
||||
<span class="badge bg-light text-dark border">+{{ entry.visible_to_users|length - 3 }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if entry.attachments %}
|
||||
<div class="mb-3">
|
||||
<small class="fw-bold text-uppercase text-muted" style="font-size: 0.7rem;">附件</small>
|
||||
<div class="mt-1">
|
||||
{% for attachment in entry.attachments[:2] %}
|
||||
<a href="{{ url_for('admin.download_attachment', attachment_id=attachment.id) }}" class="badge bg-indigo-50 text-primary text-decoration-none border border-primary-subtle mb-1">
|
||||
<i class="fa-solid fa-paperclip me-1"></i>{{ attachment.original_name | truncate(15) }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% if entry.attachments|length > 2 %}
|
||||
<small class="text-muted ms-1">+{{ entry.attachments|length - 2 }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-footer bg-white border-top-0 pt-0">
|
||||
<div class="d-flex justify-content-between align-items-center small text-muted">
|
||||
<span><i class="fa-regular fa-clock me-1"></i>{{ entry.timestamp.strftime('%Y-%m-%d') }}</span>
|
||||
{% if entry.expiration_date %}
|
||||
<span title="过期时间: {{ entry.expiration_date.strftime('%Y-%m-%d') }}">
|
||||
<i class="fa-solid fa-hourglass-end me-1"></i>{{ entry.expiration_date.strftime('%m-%d') }}
|
||||
</span>
|
||||
{% else %}
|
||||
<span><i class="fa-solid fa-infinity me-1"></i>永久</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>还没有任何数据。</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-12">
|
||||
<div class="text-center py-5 bg-light rounded-3 border border-dashed">
|
||||
<i class="fa-regular fa-folder-open fa-3x text-muted mb-3 opacity-50"></i>
|
||||
<p class="text-muted mb-3">暂无数据条目</p>
|
||||
<button class="btn btn-sm btn-outline-primary" type="button" data-bs-toggle="collapse" data-bs-target="#createDataForm">立即添加</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -2,73 +2,92 @@
|
||||
{% extends "dashboard_base.html" %}
|
||||
|
||||
{% block dashboard_content %}
|
||||
<div class="row">
|
||||
<!-- 左侧:创建新通知 -->
|
||||
<div class="col-lg-4">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0"><i class="fa-solid fa-plus fa-fw me-2"></i>创建新通知</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="mb-3">
|
||||
{{ form.title.label(class="form-label") }}
|
||||
{{ form.title(class="form-control") }}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.content.label(class="form-label") }}
|
||||
{{ form.content(class="form-control") }}
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
{{ form.submit(class="btn btn-primary") }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h2 class="fw-bold mb-0">通知管理</h2>
|
||||
<p class="text-muted mb-0">发布新公告或管理现有通知</p>
|
||||
</div>
|
||||
<button class="btn btn-primary shadow-sm" type="button" data-bs-toggle="collapse" data-bs-target="#createNotificationForm" aria-expanded="false" aria-controls="createNotificationForm">
|
||||
<i class="fa-solid fa-plus me-2"></i>发布通知
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:通知列表 -->
|
||||
<div class="col-lg-8">
|
||||
<h3 class="mb-3">通知列表</h3>
|
||||
{% for notification in notifications %}
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h5 class="card-title">{{ notification.title }}</h5>
|
||||
<p class="card-text text-muted">{{ notification.content|truncate(100) }}</p>
|
||||
<small class="text-muted">
|
||||
由 {{ notification.author.username }} 创建于 {{ notification.timestamp.strftime('%Y-%m-%d') }}
|
||||
</small>
|
||||
<!-- 可折叠的创建表单 -->
|
||||
<div class="collapse mb-4" id="createNotificationForm">
|
||||
<div class="card shadow-sm border-0 bg-light">
|
||||
<div class="card-body p-4">
|
||||
<h5 class="card-title fw-bold mb-3">创建新通知</h5>
|
||||
<form method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12">
|
||||
<div class="mb-3">
|
||||
{{ form.title.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
{{ form.title(class="form-control", placeholder="输入通知标题") }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{% if notification.is_published %}
|
||||
<span class="badge bg-success">已发布</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">草稿</span>
|
||||
{% endif %}
|
||||
<div class="col-md-12">
|
||||
<div class="mb-3">
|
||||
{{ form.content.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
{{ form.content(class="form-control", rows=3, placeholder="输入通知内容...") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="text-end">
|
||||
<a href="{{ url_for('admin.toggle_publish', notification_id=notification.id) }}" class="btn btn-sm btn-outline-secondary">
|
||||
{% if notification.is_published %}
|
||||
<i class="fa-solid fa-eye-slash fa-fw me-1"></i>撤回
|
||||
{% else %}
|
||||
<i class="fa-solid fa-eye fa-fw me-1"></i>发布
|
||||
{% endif %}
|
||||
</a>
|
||||
<form action="{{ url_for('admin.delete_notification', notification_id=notification.id) }}" method="POST" class="d-inline">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('确定要删除这条通知吗?');">
|
||||
<i class="fa-solid fa-trash fa-fw me-1"></i>删除
|
||||
</button>
|
||||
</form>
|
||||
<div class="d-flex justify-content-end gap-2 mt-3">
|
||||
<button type="button" class="btn btn-light border" data-bs-toggle="collapse" data-bs-target="#createNotificationForm">取消</button>
|
||||
{{ form.submit(class="btn btn-primary px-4") }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 通知列表 -->
|
||||
<div class="row g-4">
|
||||
<div class="col-12">
|
||||
{% for notification in notifications %}
|
||||
<div class="card shadow-sm border-0 mb-3">
|
||||
<div class="card-body p-4">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div class="flex-grow-1">
|
||||
<div class="d-flex align-items-center gap-2 mb-2">
|
||||
<h5 class="card-title fw-bold mb-0">{{ notification.title }}</h5>
|
||||
{% if notification.is_published %}
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle">已发布</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">草稿</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<p class="card-text text-secondary mb-2">{{ notification.content }}</p>
|
||||
<small class="text-muted">
|
||||
<i class="fa-solid fa-user-pen me-1"></i>{{ notification.author.username }}
|
||||
<span class="mx-2">•</span>
|
||||
<i class="fa-regular fa-clock me-1"></i>{{ notification.timestamp.strftime('%Y-%m-%d %H:%M') }}
|
||||
</small>
|
||||
</div>
|
||||
<div class="d-flex gap-2 ms-3">
|
||||
<a href="{{ url_for('admin.toggle_publish', notification_id=notification.id) }}" class="btn btn-sm btn-outline-secondary d-flex align-items-center">
|
||||
{% if notification.is_published %}
|
||||
<i class="fa-solid fa-eye-slash me-1"></i>撤回
|
||||
{% else %}
|
||||
<i class="fa-solid fa-eye me-1"></i>发布
|
||||
{% endif %}
|
||||
</a>
|
||||
<form action="{{ url_for('admin.delete_notification', notification_id=notification.id) }}" method="POST" class="d-inline">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger d-flex align-items-center" onclick="return confirm('确定要删除这条通知吗?');">
|
||||
<i class="fa-solid fa-trash me-1"></i>删除
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>还没有任何通知。</p>
|
||||
<div class="text-center py-5 bg-light rounded-3 border border-dashed">
|
||||
<i class="fa-regular fa-bell-slash fa-3x text-muted mb-3 opacity-50"></i>
|
||||
<p class="text-muted mb-3">暂无通知</p>
|
||||
<button class="btn btn-sm btn-outline-primary" type="button" data-bs-toggle="collapse" data-bs-target="#createNotificationForm">立即发布</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,32 +2,51 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title text-center mb-4">用户登录</h3>
|
||||
<div class="row justify-content-center mt-5">
|
||||
<div class="col-md-5 col-lg-4">
|
||||
<div class="text-center mb-4">
|
||||
<div class="d-inline-flex align-items-center justify-content-center bg-primary text-white rounded-circle mb-3" style="width: 64px; height: 64px; font-size: 1.75rem;">
|
||||
<i class="fa-solid fa-user-lock"></i>
|
||||
</div>
|
||||
<h2 class="fw-bold">欢迎回来</h2>
|
||||
<p class="text-muted">请登录您的账户以继续</p>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-lg">
|
||||
<div class="card-body p-4 p-sm-5">
|
||||
<form action="" method="post" novalidate>
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="mb-3">
|
||||
{{ form.username.label(class="form-label") }}
|
||||
{{ form.username(class="form-control", size=32) }}
|
||||
<div class="mb-4">
|
||||
{{ form.username.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-light border-end-0"><i class="fa-solid fa-user text-muted"></i></span>
|
||||
{{ form.username(class="form-control bg-light border-start-0 ps-0", placeholder="请输入用户名") }}
|
||||
</div>
|
||||
{% for error in form.username.errors %}
|
||||
<div class="text-danger small mt-1">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
{{ form.password.label(class="form-label") }}
|
||||
{{ form.password(class="form-control", size=32) }}
|
||||
<div class="mb-4">
|
||||
{{ form.password.label(class="form-label fw-bold small text-uppercase text-muted") }}
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-light border-end-0"><i class="fa-solid fa-key text-muted"></i></span>
|
||||
{{ form.password(class="form-control bg-light border-start-0 ps-0", placeholder="请输入密码") }}
|
||||
</div>
|
||||
{% for error in form.password.errors %}
|
||||
<div class="text-danger small mt-1">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<div class="mb-4 form-check">
|
||||
{{ form.remember_me(class="form-check-input") }}
|
||||
{{ form.remember_me.label(class="form-check-label") }}
|
||||
{{ form.remember_me.label(class="form-check-label text-muted") }}
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
{{ form.submit(class="btn btn-primary") }}
|
||||
{{ form.submit(class="btn btn-primary btn-lg") }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-footer text-center py-3">
|
||||
<small class="text-muted">还没有账户? <a href="{{ url_for('auth.register') }}" class="text-decoration-none">立即申请</a></small>
|
||||
<div class="card-footer text-center py-3 bg-light border-top-0 rounded-bottom">
|
||||
<small class="text-muted">还没有账户? <a href="{{ url_for('auth.register') }}" class="fw-bold text-primary text-decoration-none">立即申请</a></small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+128
-24
@@ -11,22 +11,19 @@
|
||||
<!-- Font Awesome Icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
</style>
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{# --- 导航栏块 --- #}
|
||||
{% block navbar %}
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark shadow-sm">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="{{ url_for('main.index') }}">
|
||||
<i class="fa-solid fa-chart-line"></i> 数据平台
|
||||
<i class="fa-solid fa-chart-line me-2"></i>数据平台
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<button class="navbar-toggler border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
@@ -34,41 +31,48 @@
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
{% if current_user.is_authenticated %}
|
||||
<form method="POST" action="{{ url_for('main.search') }}" class="d-flex me-2">
|
||||
<form method="POST" action="{{ url_for('main.search') }}" class="d-flex me-3 position-relative" id="searchForm">
|
||||
{{ search_form.hidden_tag() }}
|
||||
<div class="input-group">
|
||||
{{ search_form.q(class="form-control form-control-sm", placeholder="搜索...") }}
|
||||
<button class="btn btn-outline-light btn-sm" type="submit">
|
||||
<i class="fa-solid fa-search"></i>
|
||||
<div class="input-group input-group-sm">
|
||||
{{ search_form.q(class="form-control border-end-0 bg-light", placeholder="搜索...", id="searchInput", autocomplete="off") }}
|
||||
<button class="btn btn-outline-secondary border-start-0 bg-light" type="submit">
|
||||
<i class="fa-solid fa-search text-muted"></i>
|
||||
</button>
|
||||
</div>
|
||||
<!-- 搜索建议下拉框 -->
|
||||
<div id="searchSuggestions" class="position-absolute w-100 bg-white shadow-lg rounded-bottom start-0" style="top: 100%; z-index: 1050; display: none; border: 1px solid rgba(0,0,0,.15); border-top: none;">
|
||||
<!-- 建议内容将通过JS动态插入 -->
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<!-- 用户菜单 -->
|
||||
<ul class="navbar-nav">
|
||||
<ul class="navbar-nav align-items-center">
|
||||
{% if current_user.is_anonymous %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('auth.login') }}"><i class="fa-solid fa-right-to-bracket"></i> 登录</a>
|
||||
<a class="nav-link" href="{{ url_for('auth.login') }}">登录</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('auth.register') }}"><i class="fa-solid fa-user-plus"></i> 注册</a>
|
||||
<a class="btn btn-primary btn-sm ms-2 text-white" href="{{ url_for('auth.register') }}">注册</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('main.dashboard') }}"><i class="fa-solid fa-table-columns"></i> 仪表盘</a>
|
||||
<a class="nav-link" href="{{ url_for('main.dashboard') }}">仪表盘</a>
|
||||
</li>
|
||||
{% if current_user.is_admin() %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('admin.dashboard') }}"><i class="fa-solid fa-shield-halved"></i> 管理面板</a>
|
||||
<a class="nav-link" href="{{ url_for('admin.dashboard') }}">管理面板</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="fa-solid fa-user-circle"></i> {{ current_user.username }}
|
||||
<li class="nav-item dropdown ms-2">
|
||||
<a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<div class="rounded-circle bg-primary text-white d-flex justify-content-center align-items-center me-2" style="width: 32px; height: 32px;">
|
||||
{{ current_user.username[0] | upper }}
|
||||
</div>
|
||||
{{ current_user.username }}
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" href="{{ url_for('auth.logout') }}"><i class="fa-solid fa-right-from-bracket"></i> 登出</a></li>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow-sm border-0">
|
||||
<li><a class="dropdown-item" href="{{ url_for('auth.logout') }}"><i class="fa-solid fa-right-from-bracket me-2 text-muted"></i> 登出</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -106,5 +110,105 @@
|
||||
|
||||
<!-- Bootstrap JavaScript Bundle -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Search Suggestions JS -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
const suggestionsBox = document.getElementById('searchSuggestions');
|
||||
let debounceTimer;
|
||||
|
||||
if (searchInput && suggestionsBox) {
|
||||
// 监听输入事件
|
||||
searchInput.addEventListener('input', function() {
|
||||
const query = this.value.trim();
|
||||
|
||||
clearTimeout(debounceTimer);
|
||||
|
||||
if (query.length < 1) {
|
||||
suggestionsBox.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
// 防抖处理,300ms 后发送请求
|
||||
debounceTimer = setTimeout(() => {
|
||||
fetch(`{{ url_for('main.search_suggestions') }}?q=${encodeURIComponent(query)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.length > 0) {
|
||||
suggestionsBox.innerHTML = '';
|
||||
const listGroup = document.createElement('div');
|
||||
listGroup.className = 'list-group list-group-flush';
|
||||
|
||||
data.forEach(item => {
|
||||
const a = document.createElement('a');
|
||||
a.href = item.url;
|
||||
a.className = 'list-group-item list-group-item-action d-flex align-items-center px-3 py-2 small';
|
||||
|
||||
// 图标
|
||||
const icon = document.createElement('i');
|
||||
icon.className = `${item.icon} text-muted me-2`;
|
||||
icon.style.width = '16px';
|
||||
|
||||
// 内容容器
|
||||
const content = document.createElement('div');
|
||||
content.className = 'text-truncate';
|
||||
|
||||
// 标题
|
||||
const title = document.createElement('span');
|
||||
title.className = 'fw-medium text-dark';
|
||||
title.textContent = item.title;
|
||||
|
||||
// 类型标签
|
||||
const badge = document.createElement('span');
|
||||
badge.className = 'badge bg-light text-secondary border ms-2';
|
||||
badge.style.fontSize = '0.65rem';
|
||||
badge.textContent = item.type;
|
||||
|
||||
content.appendChild(title);
|
||||
content.appendChild(badge);
|
||||
|
||||
a.appendChild(icon);
|
||||
a.appendChild(content);
|
||||
listGroup.appendChild(a);
|
||||
});
|
||||
|
||||
// 添加"查看所有结果"链接
|
||||
const viewAll = document.createElement('button');
|
||||
viewAll.className = 'list-group-item list-group-item-action text-center text-primary bg-light small fw-bold py-2 border-top';
|
||||
viewAll.textContent = `查看所有 "${query}" 的结果`;
|
||||
viewAll.onclick = function(e) {
|
||||
e.preventDefault();
|
||||
document.getElementById('searchForm').submit();
|
||||
};
|
||||
listGroup.appendChild(viewAll);
|
||||
|
||||
suggestionsBox.innerHTML = '';
|
||||
suggestionsBox.appendChild(listGroup);
|
||||
suggestionsBox.style.display = 'block';
|
||||
} else {
|
||||
suggestionsBox.style.display = 'none';
|
||||
}
|
||||
})
|
||||
.catch(err => console.error('Search error:', err));
|
||||
}, 300);
|
||||
});
|
||||
|
||||
// 点击外部关闭下拉框
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!searchInput.contains(e.target) && !suggestionsBox.contains(e.target)) {
|
||||
suggestionsBox.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// 获得焦点时如果已有内容则显示建议
|
||||
searchInput.addEventListener('focus', function() {
|
||||
if (this.value.trim().length > 0 && suggestionsBox.innerHTML !== '') {
|
||||
suggestionsBox.style.display = 'block';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,66 +2,73 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="row g-4">
|
||||
{# 侧边栏 #}
|
||||
<aside class="col-md-3">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header">
|
||||
<i class="fa-solid fa-bars fa-fw me-2"></i> 导航
|
||||
</div>
|
||||
<div class="list-group list-group-flush">
|
||||
<a href="{{ url_for('main.dashboard') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'main.dashboard' }}">
|
||||
<i class="fa-solid fa-chart-pie fa-fw me-2"></i>我的数据
|
||||
</a>
|
||||
<a href="{{ url_for('main.notifications') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'main.notifications' }}">
|
||||
<i class="fa-solid fa-bullhorn fa-fw me-2"></i>系统通知
|
||||
</a>
|
||||
<aside class="col-lg-3 col-md-4">
|
||||
<div class="sticky-top" style="top: 80px; z-index: 100;">
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-body p-2">
|
||||
<div class="list-group list-group-flush">
|
||||
<div class="px-3 py-2 text-uppercase text-muted fw-bold" style="font-size: 0.75rem;">个人中心</div>
|
||||
<a href="{{ url_for('main.dashboard') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'main.dashboard' }}">
|
||||
<i class="fa-solid fa-chart-pie fa-fw me-2"></i>我的数据
|
||||
</a>
|
||||
<a href="{{ url_for('main.notifications') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'main.notifications' }}">
|
||||
<i class="fa-solid fa-bullhorn fa-fw me-2"></i>系统通知
|
||||
</a>
|
||||
|
||||
{% if current_user.is_admin() %}
|
||||
<div class="list-group-item list-group-item-secondary small fw-bold text-uppercase">
|
||||
管理功能
|
||||
{% if current_user.is_admin() %}
|
||||
<div class="mt-3 px-3 py-2 text-uppercase text-muted fw-bold" style="font-size: 0.75rem;">管理控制台</div>
|
||||
|
||||
<a href="{{ url_for('admin.dashboard') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'admin.dashboard' }}">
|
||||
<i class="fa-solid fa-gauge-high fa-fw me-2"></i>概览
|
||||
</a>
|
||||
<a href="{{ url_for('admin.manage_data') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'admin.manage_data' }}">
|
||||
<i class="fa-solid fa-database fa-fw me-2"></i>数据管理
|
||||
</a>
|
||||
<a href="{{ url_for('admin.upload_data') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'admin.upload_data' }}">
|
||||
<i class="fa-solid fa-upload fa-fw me-2"></i>上传原始数据
|
||||
</a>
|
||||
<a href="{{ url_for('admin.integration_manager') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'admin.integration_manager' }}">
|
||||
<i class="fa-solid fa-gears fa-fw me-2"></i>数据整合处理
|
||||
</a>
|
||||
<a href="{{ url_for('admin.manage_raw_files') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'admin.manage_raw_files' }}">
|
||||
<i class="fa-solid fa-folder-tree fa-fw me-2"></i>原始文件管理
|
||||
</a>
|
||||
<a href="{{ url_for('admin.inference_manager') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'admin.inference_manager' }}">
|
||||
<i class="fa-solid fa-brain fa-fw me-2"></i>AI 推理与诊断
|
||||
</a>
|
||||
<a href="{{ url_for('admin.manage_notifications') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint == 'admin.manage_notifications' }}">
|
||||
<i class="fa-solid fa-bell fa-fw me-2"></i>通知发布
|
||||
</a>
|
||||
<a href="{{ url_for('admin.manage_users') }}"
|
||||
class="list-group-item list-group-item-action border-0 rounded {{ 'active' if request.endpoint in ['admin.manage_users', 'admin.add_user', 'admin.edit_user'] }}">
|
||||
<i class="fa-solid fa-users-gear fa-fw me-2"></i>用户管理
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<a href="{{ url_for('admin.manage_data') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'admin.manage_data' }}">
|
||||
<i class="fa-solid fa-database fa-fw me-2"></i>管理数据
|
||||
</a>
|
||||
<a href="{{ url_for('admin.upload_data') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'admin.upload_data' }}">
|
||||
<i class="fa-solid fa-upload fa-fw me-2"></i>上传原始数据
|
||||
</a>
|
||||
<a href="{{ url_for('admin.integration_manager') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'admin.integration_manager' }}">
|
||||
<i class="fa-solid fa-cogs fa-fw me-2"></i>数据整合处理
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('admin.manage_raw_files') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'admin.manage_raw_files' }}">
|
||||
<i class="fa-solid fa-folder-open fa-fw me-2"></i>管理原始文件
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('admin.inference_manager') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'admin.inference_manager' }}">
|
||||
<i class="fa-solid fa-brain fa-fw me-2"></i>推理与诊断
|
||||
</a>
|
||||
<a href="{{ url_for('admin.manage_notifications') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint == 'admin.manage_notifications' }}">
|
||||
<i class="fa-solid fa-bell fa-fw me-2"></i>管理通知
|
||||
</a>
|
||||
<a href="{{ url_for('admin.manage_users') }}"
|
||||
class="list-group-item list-group-item-action {{ 'active' if request.endpoint in ['admin.manage_users', 'admin.add_user', 'admin.edit_user'] }}">
|
||||
<i class="fa-solid fa-users fa-fw me-2"></i>用户管理
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{# 主内容区 #}
|
||||
<main class="col-md-9">
|
||||
{% block dashboard_content %}
|
||||
{% endblock %}
|
||||
<main class="col-lg-9 col-md-8">
|
||||
<div class="card border-0 shadow-sm" style="min-height: 80vh;">
|
||||
<div class="card-body p-4">
|
||||
{% block dashboard_content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
{% endblock %}
|
||||
+95
-27
@@ -1,40 +1,108 @@
|
||||
{# app/templates/index.html (修改此文件) #}
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="p-5 mb-4 bg-light rounded-3 shadow-sm">
|
||||
<div class="container-fluid py-5">
|
||||
<h1 class="display-5 fw-bold">欢迎来到数据处理平台</h1>
|
||||
<p class="col-md-8 fs-4">一个集数据上传、处理、分析与展示于一体的现代化 Web 应用。</p>
|
||||
|
||||
{# --- Hero Section --- #}
|
||||
<div class="hero-section text-center mb-5">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
<h1 class="hero-title display-4 fw-bold mb-4">智能生理信号分析平台</h1>
|
||||
<p class="lead text-muted mb-5">
|
||||
基于深度学习的一站式数据管理与分析解决方案。从原始数据采集到AI辅助诊断,为您提供全流程的智能化支持。
|
||||
</p>
|
||||
{% if current_user.is_anonymous %}
|
||||
<div class="d-flex justify-content-center gap-3">
|
||||
<a href="{{ url_for('auth.login') }}" class="btn btn-primary btn-lg px-4 shadow-sm">
|
||||
<i class="fa-solid fa-right-to-bracket me-2"></i>立即登录
|
||||
</a>
|
||||
<a href="{{ url_for('auth.register') }}" class="btn btn-outline-primary btn-lg px-4">
|
||||
注册账号
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<a href="{{ url_for('main.dashboard') }}" class="btn btn-primary btn-lg px-5 shadow-sm rounded-pill">
|
||||
<i class="fa-solid fa-gauge-high me-2"></i>进入工作台
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h2><i class="fa-solid fa-bullhorn fa-fw me-2"></i>最新通知</h2>
|
||||
<hr>
|
||||
{% if notifications %}
|
||||
<div class="accordion" id="notificationsAccordion">
|
||||
{% for notification in notifications %}
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="heading-{{ notification.id }}">
|
||||
<button class="accordion-button {% if not loop.first %}collapsed{% endif %}" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-{{ notification.id }}" aria-expanded="{% if loop.first %}true{% else %}false{% endif %}" aria-controls="collapse-{{ notification.id }}">
|
||||
<strong>{{ notification.title }}</strong> - <small class="text-muted">{{ notification.timestamp.strftime('%Y年%m月%d日') }}</small>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapse-{{ notification.id }}" class="accordion-collapse collapse {% if loop.first %}show{% endif %}" aria-labelledby="heading-{{ notification.id }}" data-bs-parent="#notificationsAccordion">
|
||||
<div class="accordion-body">
|
||||
{{ notification.content | safe }}
|
||||
</div>
|
||||
{# --- Features Grid --- #}
|
||||
<div class="container mb-5">
|
||||
<div class="row g-4 text-center">
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm p-4">
|
||||
<div class="card-body">
|
||||
<div class="feature-icon mb-3">
|
||||
<i class="fa-solid fa-database"></i>
|
||||
</div>
|
||||
<h4 class="card-title h5 fw-bold">数据全生命周期管理</h4>
|
||||
<p class="card-text text-muted">支持海量生理信号数据的上传、存储、清洗与归档,确保数据安全可追溯。</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-info">
|
||||
目前没有新的通知。
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm p-4">
|
||||
<div class="card-body">
|
||||
<div class="feature-icon mb-3">
|
||||
<i class="fa-solid fa-wand-magic-sparkles"></i>
|
||||
</div>
|
||||
<h4 class="card-title h5 fw-bold">自动化处理流水线</h4>
|
||||
<p class="card-text text-muted">内置高效的预处理引擎,自动完成解压、格式转换与信号质量评估(SQA)。</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 border-0 shadow-sm p-4">
|
||||
<div class="card-body">
|
||||
<div class="feature-icon mb-3">
|
||||
<i class="fa-solid fa-brain"></i>
|
||||
</div>
|
||||
<h4 class="card-title h5 fw-bold">AI 辅助诊断</h4>
|
||||
<p class="card-text text-muted">集成 Transformer 深度学习模型,提供高精度的疾病筛查与辅助诊断建议。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# --- Notifications Section --- #}
|
||||
<div class="container py-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-10">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h3 class="fw-bold m-0"><i class="fa-solid fa-bullhorn text-primary me-2"></i>最新公告</h3>
|
||||
<a href="{{ url_for('main.notifications') }}" class="btn btn-sm btn-outline-secondary">查看全部</a>
|
||||
</div>
|
||||
|
||||
{% if notifications %}
|
||||
<div class="list-group shadow-sm rounded-3 overflow-hidden">
|
||||
{% for notification in notifications[:5] %}
|
||||
<div class="list-group-item p-4 border-start-0 border-end-0">
|
||||
<div class="d-flex w-100 justify-content-between align-items-center mb-2">
|
||||
<h5 class="mb-1 fw-bold text-dark">{{ notification.title }}</h5>
|
||||
<small class="text-muted bg-light px-2 py-1 rounded">
|
||||
<i class="fa-regular fa-clock me-1"></i>{{ notification.timestamp.strftime('%Y-%m-%d') }}
|
||||
</small>
|
||||
</div>
|
||||
<p class="mb-1 text-secondary">{{ notification.content | truncate(100) }}</p>
|
||||
<small class="text-muted">
|
||||
<i class="fa-solid fa-user-pen me-1"></i>发布者: {{ notification.author.username }}
|
||||
</small>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-5 text-muted bg-light rounded-3 border border-dashed">
|
||||
<i class="fa-regular fa-bell-slash fa-2x mb-3 d-block opacity-50"></i>
|
||||
暂无发布的公告
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -2,59 +2,133 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1 class="mb-4">搜索结果 for "<em class="text-primary">{{ query }}</em>"</h1>
|
||||
<div class="container py-4">
|
||||
<div class="mb-5">
|
||||
<h2 class="fw-bold mb-3">搜索结果</h2>
|
||||
<p class="text-muted">关键词: <span class="badge bg-primary fs-6">{{ query }}</span></p>
|
||||
</div>
|
||||
|
||||
<!-- 功能导航 (伪搜索结果) -->
|
||||
<div class="mb-5">
|
||||
<h4 class="fw-bold mb-3 text-secondary"><i class="fa-solid fa-compass me-2"></i>系统功能</h4>
|
||||
<div class="list-group shadow-sm">
|
||||
{% set features = [
|
||||
{'name': '仪表盘', 'url': url_for('main.dashboard'), 'keywords': ['dashboard', 'home', '主页', '仪表盘']},
|
||||
{'name': '个人数据', 'url': url_for('main.dashboard'), 'keywords': ['data', 'my data', '数据']},
|
||||
{'name': '系统通知', 'url': url_for('main.notifications'), 'keywords': ['notification', 'notice', '通知', '公告']}
|
||||
] %}
|
||||
|
||||
{% if current_user.is_admin() %}
|
||||
{% set _ = features.extend([
|
||||
{'name': '管理面板', 'url': url_for('admin.dashboard'), 'keywords': ['admin', 'manage', '管理']},
|
||||
{'name': '用户管理', 'url': url_for('admin.manage_users'), 'keywords': ['user', 'account', '用户', '账号']},
|
||||
{'name': '数据上传', 'url': url_for('admin.upload_data'), 'keywords': ['upload', '上传', 'import']},
|
||||
{'name': '原始文件管理', 'url': url_for('admin.manage_raw_files'), 'keywords': ['raw', 'file', '原始', '文件']},
|
||||
{'name': '数据整合', 'url': url_for('admin.integration_manager'), 'keywords': ['integration', 'process', '整合', '处理']},
|
||||
{'name': 'AI推理', 'url': url_for('admin.inference_manager'), 'keywords': ['ai', 'inference', 'model', '推理', '诊断']}
|
||||
]) %}
|
||||
{% endif %}
|
||||
|
||||
{% set found_features = [] %}
|
||||
{% for feature in features %}
|
||||
{% for kw in feature.keywords %}
|
||||
{% if kw in query.lower() or query.lower() in kw %}
|
||||
{% if feature not in found_features %}
|
||||
{% set _ = found_features.append(feature) %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% for feature in found_features %}
|
||||
<a href="{{ feature.url }}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center p-3">
|
||||
<div>
|
||||
<span class="fw-bold text-dark">{{ feature.name }}</span>
|
||||
<small class="d-block text-muted">跳转到 {{ feature.name }} 页面</small>
|
||||
</div>
|
||||
<i class="fa-solid fa-chevron-right text-muted"></i>
|
||||
</a>
|
||||
{% else %}
|
||||
<div class="list-group-item text-muted fst-italic p-3">未找到匹配的系统功能入口</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Data Entries Results -->
|
||||
<div class="mb-5">
|
||||
<h3><i class="fa-solid fa-database fa-fw me-2"></i>仪表盘数据</h3>
|
||||
<hr>
|
||||
<h4 class="fw-bold mb-3 text-secondary"><i class="fa-solid fa-database me-2"></i>数据条目</h4>
|
||||
{% if data_entries %}
|
||||
{% for entry in data_entries %}
|
||||
<div class="card mb-3 shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ entry.title }}</h5>
|
||||
<p class="card-text">{{ entry.content | truncate(200) }}</p>
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
创建于: {{ entry.timestamp.strftime('%Y-%m-%d') }}
|
||||
{% if current_user.is_admin() and entry.is_expired() %}
|
||||
<span class="badge bg-danger ms-2">已过期</span>
|
||||
{% endif %}
|
||||
</small>
|
||||
</p>
|
||||
<div class="row g-3">
|
||||
{% for entry in data_entries %}
|
||||
<div class="col-md-6">
|
||||
<div class="card h-100 shadow-sm border-0">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title fw-bold">
|
||||
<a href="{{ url_for('admin.view_csv', entry_id=entry.id) if current_user.is_admin() else '#' }}" class="text-decoration-none text-dark stretched-link">
|
||||
{{ entry.title }}
|
||||
</a>
|
||||
</h5>
|
||||
<p class="card-text text-muted small">{{ entry.content | truncate(100) }}</p>
|
||||
<div class="d-flex justify-content-between align-items-center mt-3">
|
||||
<small class="text-muted"><i class="fa-regular fa-calendar me-1"></i>{{ entry.timestamp.strftime('%Y-%m-%d') }}</small>
|
||||
{% if current_user.is_admin() and entry.is_expired() %}
|
||||
<span class="badge bg-danger-subtle text-danger border border-danger-subtle">已过期</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="alert alert-info">没有找到相关的仪表盘数据。</div>
|
||||
<div class="alert alert-light border border-dashed text-center text-muted">没有找到相关的数据条目。</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Notifications Results -->
|
||||
<div>
|
||||
<h3><i class="fa-solid fa-bullhorn fa-fw me-2"></i>通知</h3>
|
||||
<hr>
|
||||
<div class="mb-5">
|
||||
<h4 class="fw-bold mb-3 text-secondary"><i class="fa-solid fa-bullhorn me-2"></i>通知公告</h4>
|
||||
{% if notifications %}
|
||||
{% for notification in notifications %}
|
||||
<div class="card mb-3 shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ notification.title }}</h5>
|
||||
<p class="card-text">{{ notification.content | truncate(200) }}</p>
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
发布于: {{ notification.timestamp.strftime('%Y-%m-%d') }}
|
||||
{% if current_user.is_admin() and not notification.is_published %}
|
||||
<span class="badge bg-secondary ms-2">草稿</span>
|
||||
{% endif %}
|
||||
</small>
|
||||
</p>
|
||||
<div class="list-group shadow-sm">
|
||||
{% for notification in notifications %}
|
||||
<div class="list-group-item p-3 border-start-0 border-end-0">
|
||||
<div class="d-flex w-100 justify-content-between align-items-center mb-1">
|
||||
<h6 class="mb-0 fw-bold">{{ notification.title }}</h6>
|
||||
<small class="text-muted">{{ notification.timestamp.strftime('%Y-%m-%d') }}</small>
|
||||
</div>
|
||||
<p class="mb-1 text-muted small">{{ notification.content | truncate(150) }}</p>
|
||||
{% if current_user.is_admin() and not notification.is_published %}
|
||||
<span class="badge bg-secondary">草稿</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="alert alert-info">没有找到相关的通知。</div>
|
||||
<div class="alert alert-light border border-dashed text-center text-muted">没有找到相关的通知。</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if current_user.is_admin() %}
|
||||
<!-- Raw Files Results -->
|
||||
<div class="mb-5">
|
||||
<h4 class="fw-bold mb-3 text-secondary"><i class="fa-solid fa-folder-tree me-2"></i>原始数据文件夹</h4>
|
||||
{% if raw_files %}
|
||||
<div class="list-group shadow-sm">
|
||||
{% for folder in raw_files %}
|
||||
<a href="{{ url_for('admin.manage_raw_files', subpath=folder.folder_name) }}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center p-3">
|
||||
<div>
|
||||
<i class="fa-regular fa-folder me-2 text-warning"></i>
|
||||
<span class="fw-medium">{{ folder.folder_name }}</span>
|
||||
</div>
|
||||
<span class="badge bg-light text-dark border">{{ folder.status }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-light border border-dashed text-center text-muted">没有找到相关的原始数据文件夹。</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in new issue
Block a user