Files
WebhockTransfer/templates/admin/templates.html
T
houhuan 2bc7460f1f feat: 初始化Webhook中继系统项目
- 添加FastAPI应用基础结构,包括主入口、路由和模型定义
- 实现Webhook接收端点(/webhook/{namespace})和健康检查(/health)
- 添加管理后台路由和模板,支持端点、目标、渠道和模板管理
- 包含SQLite数据库模型定义和初始化逻辑
- 添加日志记录和统计服务
- 包含Dockerfile和配置示例文件
- 添加项目文档,包括设计、流程图和验收标准
2025-12-21 18:43:12 +08:00

104 lines
4.3 KiB
HTML

{% extends "admin/base.html" %}
{% block title %}消息模板 - Webhook{% endblock %}
{% block content %}
<div class="row mb-3">
<div class="col">
<h3>消息模板资源</h3>
</div>
<div class="col-auto">
<button type="button" class="btn btn-primary" onclick="openAddModal()">添加模板</button>
</div>
</div>
<div class="alert alert-info alert-dismissible fade show" role="alert">
<strong>什么是“消息模板”?</strong>
<p class="mb-0">
消息模板(Message Templates)是<strong>纯文本资源</strong>,供“通知动作”调用。<br>
<strong>变量替换</strong>:使用 <code>{variable}</code> 语法插入 JSON 中的数据。<br>
例如:<code>{trans_order_info_remark}</code><code>{body_status}</code>(引擎会将嵌套JSON展平为下划线连接的键)。
</p>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>模板名称</th>
<th>内容预览</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for t in templates %}
<tr>
<td>{{ t.id }}</td>
<td>{{ t.name }}</td>
<td>{{ t.template_content }}</td>
<td>
<button class="btn btn-sm btn-outline-primary"
onclick="openEditModal('{{ t.id }}', '{{ t.name }}', `{{ t.template_content }}`)">修改</button>
<form action="/admin/templates/delete" method="post" style="display:inline" onsubmit="return confirm('确定删除?')">
<input type="hidden" name="id" value="{{ t.id }}">
<button type="submit" class="btn btn-sm btn-danger">删除</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- Modal -->
<div class="modal fade" id="templateModal" tabindex="-1">
<div class="modal-dialog">
<form id="templateForm" action="/admin/templates" method="post">
<input type="hidden" name="id" id="templateId">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalTitle">添加消息模板</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">模板名称</label>
<input type="text" class="form-control" name="name" id="templateName" required placeholder="收款成功通知">
</div>
<div class="mb-3">
<label class="form-label">模板内容</label>
<textarea class="form-control" name="template_content" id="templateContent" rows="3" required placeholder="收到{trans_amt}元"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
<button type="submit" class="btn btn-primary">保存</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
var modal = new bootstrap.Modal(document.getElementById('templateModal'));
function openAddModal() {
document.getElementById('modalTitle').innerText = "添加消息模板";
document.getElementById('templateForm').action = "/admin/templates";
document.getElementById('templateId').value = "";
document.getElementById('templateName').value = "";
document.getElementById('templateContent').value = "";
modal.show();
}
function openEditModal(id, name, content) {
document.getElementById('modalTitle').innerText = "修改消息模板";
document.getElementById('templateForm').action = "/admin/templates/update";
document.getElementById('templateId').value = id;
document.getElementById('templateName').value = name;
document.getElementById('templateContent').value = content;
modal.show();
}
</script>
{% endblock %}