Files
jiang13-forum/embed_static/templates/post_edit.html
freefire e1c1708715 初始提交:姜十三论坛 Jiang13 Forum
轻量自用论坛,Go 单二进制 + React SPA 内嵌 + SQLite。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 21:08:52 +08:00

32 lines
1.1 KiB
HTML

{{define "post_edit.html"}}{{template "layout" .}}{{end}}
{{define "content"}}
<h3>编辑帖子</h3>
<form id="editForm">
<div class="mb-3">
<label class="form-label">标题</label>
<input type="text" name="title" class="form-control" value="{{.Post.Title}}" required>
</div>
<div class="mb-3">
<label class="form-label">标签</label>
<input type="text" name="tags" class="form-control" value="{{.Post.Tags}}">
</div>
<div class="mb-3">
<label class="form-label">内容</label>
<textarea name="content" class="form-control" rows="12" required>{{.Post.Content}}</textarea>
</div>
<button type="submit" class="btn btn-success">保存</button>
<a href="/post/{{.Post.ID}}" class="btn btn-secondary">取消</a>
</form>
{{end}}
{{define "scripts"}}
<script>
document.getElementById('editForm').addEventListener('submit',function(e){
e.preventDefault();
fetch('/api/posts/{{.Post.ID}}',{method:'PUT',credentials:'same-origin',body:new FormData(this)}).then(r=>r.json()).then(d=>{
if(d.error){showToast(d.error,'danger');return;}
location.href='/post/{{.Post.ID}}';
});
});
</script>
{{end}}