feat(frontend): 优化对话与管理页面展示体验

This commit is contained in:
2026-05-30 00:26:18 +08:00
parent df45a89eb1
commit 905067277a
10 changed files with 776 additions and 218 deletions

View File

@@ -1,50 +1,53 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>文件列表</title>
</head>
<body>
<h1>件列表</h1>
<nav>
<a href="/">返回首页</a>
<a href="{% url 'documents:upload' %}">上传文件</a>
</nav>
<table>
<thead>
<tr>
<th>文件名</th>
<th>场景</th>
<th>类型</th>
<th>大小</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for document in documents %}
{% extends "base.html" %}
{% block title %}文档中心{% endblock %}
{% block content %}
<header class="page-header">
<span class="eyebrow">知识库资料</span>
<h1 class="page-title">档中心</h1>
<p class="page-lead">上传题目材料后,可以在这里管理文件状态,并手动触发入库。</p>
<p style="margin-top: 14px;"><a class="button button-primary" href="{% url 'documents:upload' %}">上传新文件</a></p>
</header>
<article class="panel">
<table class="kv-table">
<thead>
<tr>
<td>{{ document.original_name }}</td>
<td>{{ document.scenario_id }}</td>
<td>{{ document.file_type }}</td>
<td>{{ document.size }}</td>
<td>{{ document.status }}</td>
<td>
{% if document.status != "indexed" %}
<form action="{% url 'documents:index' document.id %}" method="post">
{% csrf_token %}
<button type="submit">入库</button>
</form>
{% endif %}
{% if document.error_message %}
<pre>{{ document.error_message }}</pre>
{% endif %}
</td>
<th>文件名</th>
<th>场景</th>
<th>类型</th>
<th>大小</th>
<th>状态</th>
<th>操作</th>
</tr>
{% empty %}
<tr><td colspan="6">暂无文件。</td></tr>
{% endfor %}
</tbody>
</table>
</body>
</html>
</thead>
<tbody>
{% for document in documents %}
<tr>
<td>{{ document.original_name }}</td>
<td>{{ document.scenario_id }}</td>
<td>{{ document.file_type }}</td>
<td>{{ document.size }}</td>
<td>{{ document.status }}</td>
<td>
{% if document.status != "indexed" %}
<form action="{% url 'documents:index' document.id %}" method="post">
{% csrf_token %}
<button type="submit">执行入库</button>
</form>
{% else %}
<span class="status status-success">已可用于检索</span>
{% endif %}
{% if document.error_message %}
<pre class="code-block" style="margin-top: 10px;">{{ document.error_message }}</pre>
{% endif %}
</td>
</tr>
{% empty %}
<tr><td colspan="6">暂无文件,请先上传题目材料。</td></tr>
{% endfor %}
</tbody>
</table>
</article>
{% endblock %}

View File

@@ -1,26 +1,39 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>上传文件</title>
</head>
<body>
<h1>上传文件</h1>
<nav><a href="{% url 'documents:list' %}">返回文件列表</a></nav>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<p>
<label for="id_scenario_id">场景</label>
<select name="scenario_id" id="id_scenario_id">
{% for scenario in scenarios %}
<option value="{{ scenario.id }}">{{ scenario.name }}</option>
{% endfor %}
</select>
</p>
<p>{{ form.file.label_tag }} {{ form.file }}</p>
{{ form.errors }}
<p>支持 .txt、.md、.pdf 和 .docx 文件。</p>
<button type="submit">上传</button>
</form>
</body>
</html>
{% extends "base.html" %}
{% block title %}上传文件{% endblock %}
{% block content %}
<header class="page-header">
<span class="eyebrow">文件上传</span>
<h1 class="page-title">上传题目材料或知识库文档</h1>
<p class="page-lead">支持 `.txt`、`.md`、`.pdf` 和 `.docx`。上传后可以在文档中心手动执行入库。</p>
</header>
<article class="panel" style="max-width: 760px;">
<form method="post" enctype="multipart/form-data" class="stack">
{% csrf_token %}
<div>
<label for="id_scenario_id">关联场景</label>
<select name="scenario_id" id="id_scenario_id">
{% for scenario in scenarios %}
<option value="{{ scenario.id }}">{{ scenario.name }}</option>
{% endfor %}
</select>
</div>
<div>
{{ form.file.label_tag }}
{{ form.file }}
{% if form.file.errors %}
<p class="notice notice-error">{{ form.file.errors|join:" " }}</p>
{% endif %}
</div>
{% if form.errors %}
<div class="notice notice-error">{{ form.errors }}</div>
{% endif %}
<div style="display: flex; gap: 10px; flex-wrap: wrap;">
<button type="submit">上传文件</button>
<a class="button" href="{% url 'documents:list' %}">返回文件列表</a>
</div>
</form>
</article>
{% endblock %}