Files
liteadmin/templates/knowledge_new.html
T

68 lines
2.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "base.html" %}
{% block title %}发布知识库 - {{ site_name }}{% endblock %}
{% block content %}
<div class="page-title">
<h1>发布知识库文章</h1>
<p>分享规范文档与知识沉淀</p>
</div>
<div class="card">
<div class="card-body">
<div id="error-box" style="display:none;" class="alert alert-danger"></div>
<form id="article-form">
<div class="form-group">
<label for="title">标题</label>
<input type="text" id="title" name="title" class="form-control" required placeholder="请输入文章标题">
</div>
<div class="form-group">
<label for="category">分类</label>
<select id="category" name="category" class="form-control">
{% for cat in knowledge_categories %}
<option value="{{ cat.name }}">{{ cat.name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="content">内容(支持 Markdown)</label>
<textarea id="content" name="content" class="form-control" rows="12" required placeholder="支持 Markdown 语法..."></textarea>
</div>
<div class="form-group">
<label for="file_upload">上传文件(可选,支持 .docx / .xlsx)</label>
<input type="file" id="file_upload" name="file_upload" class="form-control" accept=".docx,.xlsx">
<div style="font-size:12px;color:var(--text-light);margin-top:4px;">
上传后自动解析文字、图片和表格到内容中
</div>
</div>
<button type="submit" class="btn btn-primary">发布文章</button>
<a href="/knowledge/" class="btn">取消</a>
</form>
</div>
</div>
<script>
document.getElementById('article-form').addEventListener('submit', async function(e) {
e.preventDefault();
var fd = new FormData(this);
fd.append('csrf_token', CSRF_TOKEN);
var res = await fetch('/knowledge/new/', { method: 'POST', body: fd });
var data = await res.json();
if (data.success) {
window.location.href = '/knowledge/' + data.id + '/';
} else {
var box = document.getElementById('error-box');
box.textContent = data.error || '发布失败';
box.style.display = 'block';
}
});
document.getElementById('file_upload').addEventListener('change', function(e) {
var file = e.target.files[0];
if (!file) return;
parseUploadedFile(file, function(markdown) {
var ta = document.getElementById('content');
ta.value = ta.value + '\n\n' + markdown;
});
});
</script>
{% endblock %}