This repository has been archived on 2026-06-21. You can view files and clone it, but cannot push or open issues or pull requests.
Files
MetaLab/templates/MetaLab-2026/html/studio/drafts.html
Victor_Jay c73b131b83 feat: prompt/confirm 替换为自定义弹窗
- shared/utils.js 新增 showConfirm()/showPrompt() 通用函数(inline CSS,无需额外样式)
- admin/common.js 移除重复 showConfirm(),统一使用 utils.js
- admin/posts.js: 3 处 confirm/prompt 替换(审核/退回/锁定)
- admin/comments.js: 1 处 confirm 替换
- settings/index.html: 4 处 confirm + 1 处 prompt 替换
- studio/posts.html + drafts.html: 3 处 confirm 替换
- post-view.js + login.js + post-favorite.js: 3 处 confirm 替换
2026-06-02 20:11:48 +08:00

121 lines
3.8 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.

{{template "layout/header.html" .}}
<body>
{{template "layout/nav.html" .}}
<div class="studio-wrapper">
{{template "studio/sidebar.html" .}}
<main class="studio-main">
<div class="studio-header">
<h1>草稿箱</h1>
<span class="studio-subtitle">共 {{.Total}} 篇草稿</span>
</div>
{{if .Error}}
<div class="studio-error">{{.Error}}</div>
{{else}}
{{if .Posts}}
<div class="post-list">
{{range .Posts}}
<div class="post-item">
<div class="post-item-main">
<span class="post-item-title draft-title">{{if .Title}}{{.Title}}{{else}}无标题{{end}}</span>
<div class="post-item-meta">
<span class="post-status-badge status-draft">草稿</span>
<span>{{.CreatedAt.Format "2006-01-02 15:04"}}</span>
</div>
</div>
<div class="post-item-actions">
<a href="/studio/write?id={{.ID}}" class="action-btn primary">继续编辑</a>
<button class="action-btn" data-post-id="{{.ID}}" data-action="submit" title="提交发布">提交</button>
<button class="action-btn danger" data-post-id="{{.ID}}" data-action="delete" title="删除">删除</button>
</div>
</div>
{{end}}
</div>
{{if gt .TotalPages 1}}
<div class="pagination">
{{if gt .Page 1}}
<a href="/studio/drafts?page={{subtract .Page 1}}" class="page-btn">上一页</a>
{{end}}
<span class="page-info">第 {{.Page}} / {{.TotalPages}} 页</span>
{{if lt .Page .TotalPages}}
<a href="/studio/drafts?page={{add .Page 1}}" class="page-btn">下一页</a>
{{end}}
</div>
{{end}}
{{else}}
<div class="studio-empty">
<p>✨ 草稿箱是空的</p>
<a href="/studio/write" class="btn-primary">开始写作</a>
</div>
{{end}}
{{end}}
</main>
</div>
<script nonce="{{.CSPNonce}}">
function submitPost(id) {
showConfirm('确认', '确定要提交这篇草稿进行审核吗?').then(function(ok) {
if (!ok) return;
fetch('/api/studio/posts/' + id + '/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCSRFToken()
}
})
.then(r => r.json())
.then(data => {
if (data.success) {
location.reload();
} else {
alert(data.message || '提交失败');
}
});
});
}
function deletePost(id) {
showConfirm('确认', '确定要删除这篇草稿吗?此操作不可恢复。').then(function(ok) {
if (!ok) return;
fetch('/api/studio/posts/' + id, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCSRFToken()
}
})
.then(r => r.json())
.then(data => {
if (data.success) {
location.reload();
} else {
alert(data.message || '删除失败');
}
});
});
}
// 事件委托代替内联 onclick满足 CSP 无 unsafe-inline
document.addEventListener('click', function(e) {
var btn = e.target.closest('[data-action]');
if (!btn) return;
var id = btn.getAttribute('data-post-id');
var action = btn.getAttribute('data-action');
if (action === 'delete') {
deletePost(id);
} else if (action === 'submit') {
submitPost(id);
}
});
</script>
{{template "layout/footer.html" .}}
</body>
</html>