feat: 文章属性前端完成 — Phase 3
- 写文章页:可见性/类型/转载来源/创作声明/禁止转载 属性表单 - 类型切换联动(转载显示来源,原创显示禁止转载复选框) - 文章详情页:私密角标、置顶标记、创作声明横幅、转载来源 - 管理后台:置顶/取消置顶操作按钮 - PostService Create/Update 签名扩展接受文章属性 - DTO/接口同步更新
This commit is contained in:
@ -42,7 +42,7 @@
|
||||
<td>{{.ID}}</td>
|
||||
<td><a href="/posts/{{.ID}}" target="_blank" class="post-link">{{.Title}}</a>{{if .PendingBody}} <span class="revision-badge">修订中</span>{{end}}</td>
|
||||
<td>{{if .AuthorName}}{{.AuthorName}}({{.UserID}}){{else}}UID{{.UserID}}{{end}}</td>
|
||||
<td><span class="status-badge status-{{.Status}}">{{index $.StatusNames .Status}}</span>{{if .IsLocked}} <span class="status-badge status-locked">已锁定</span>{{end}}</td>
|
||||
<td><span class="status-badge status-{{.Status}}">{{index $.StatusNames .Status}}</span>{{if .IsLocked}} <span class="status-badge status-locked">已锁定</span>{{end}}{{if .PinType}} <span class="status-badge status-pinned">📌</span>{{end}}</td>
|
||||
<td>{{.CreatedAt.Format "2006-01-02 15:04"}}</td>
|
||||
<td class="actions-cell">
|
||||
<div class="action-btns">
|
||||
@ -63,6 +63,14 @@
|
||||
{{if .IsLocked}}
|
||||
<button class="btn btn-sm btn-success post-unlock" data-id="{{.ID}}">解锁</button>
|
||||
{{end}}
|
||||
{{if eq .Status "approved"}}
|
||||
{{if not .PinType}}
|
||||
<button class="btn btn-sm btn-info post-pin" data-id="{{.ID}}" data-pin-type="global">全局置顶</button>
|
||||
<button class="btn btn-sm btn-info post-pin" data-id="{{.ID}}" data-pin-type="category">分类置顶</button>
|
||||
{{else}}
|
||||
<button class="btn btn-sm btn-secondary post-unpin" data-id="{{.ID}}">取消置顶</button>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -80,6 +80,7 @@
|
||||
.status-approved { background: #d1fae5; color: #059669; }
|
||||
.status-rejected { background: #fee2e2; color: #dc2626; }
|
||||
.status-locked { background: #fee2e2; color: #b91c1c; }
|
||||
.status-pinned { background: #dbeafe; color: #1d4ed8; }
|
||||
|
||||
.revision-section { margin-bottom: 24px; }
|
||||
.revision-section h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: #4338ca; }
|
||||
@ -111,6 +112,7 @@
|
||||
.btn-success { background: #10b981; color: #fff; }
|
||||
.btn-warning { background: #f59e0b; color: #fff; }
|
||||
.btn-danger { background: #ef4444; color: #fff; }
|
||||
.btn-info { background: #3b82f6; color: #fff; }
|
||||
|
||||
/* 分页 */
|
||||
.pagination {
|
||||
|
||||
@ -52,4 +52,22 @@
|
||||
.then(function(d) { if (d.success) refreshPage(); else showToast(d.message || '操作失败', 'error'); })
|
||||
.catch(function() { showToast('操作失败', 'error'); });
|
||||
});
|
||||
|
||||
// 置顶
|
||||
document.querySelectorAll('.post-pin').forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
var id = btn.getAttribute('data-id');
|
||||
var pinType = btn.getAttribute('data-pin-type');
|
||||
api.post('/api/admin/posts/' + id + '/pin', { pin_type: pinType })
|
||||
.then(function(d) { if (d.success) refreshPage(); else showToast(d.message || '操作失败', 'error'); })
|
||||
.catch(function() { showToast('操作失败', 'error'); });
|
||||
});
|
||||
});
|
||||
|
||||
// 取消置顶
|
||||
handleClick('.post-unpin', '确定取消置顶吗?', function(id) {
|
||||
api.post('/api/admin/posts/' + id + '/unpin')
|
||||
.then(function(d) { if (d.success) refreshPage(); else showToast(d.message || '操作失败', 'error'); })
|
||||
.catch(function() { showToast('操作失败', 'error'); });
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user