整理router
This commit is contained in:
+3
-8
@@ -746,15 +746,10 @@ async function loadPages() {
|
||||
}
|
||||
}
|
||||
|
||||
// 评论管理 API 基础路径(管理员走 admin 组,普通用户走 my 组)
|
||||
function commentsAPIBase() {
|
||||
return (currentUser && currentUser.role === 'admin') ? `${API_BASE}/admin` : `${API_BASE}/my`;
|
||||
}
|
||||
|
||||
// 加载评论(postId 为空时加载全部)
|
||||
async function loadComments(postId = '') {
|
||||
try {
|
||||
const url = postId ? `${commentsAPIBase()}/comments?post_id=${postId}` : `${commentsAPIBase()}/comments`;
|
||||
const url = postId ? `${API_BASE}/comments?post_id=${postId}` : `${API_BASE}/comments`;
|
||||
const res = await fetch(url, { headers: getHeaders() });
|
||||
const data = await res.json();
|
||||
|
||||
@@ -958,7 +953,7 @@ async function deletePage(id) {
|
||||
|
||||
// 通过评论
|
||||
async function approveComment(id) {
|
||||
await fetch(`${commentsAPIBase()}/comments/${id}/approve`, {
|
||||
await fetch(`${API_BASE}/comments/${id}/approve`, {
|
||||
method: 'PUT',
|
||||
headers: getHeaders()
|
||||
});
|
||||
@@ -968,7 +963,7 @@ async function approveComment(id) {
|
||||
// 删除评论
|
||||
async function deleteComment(id) {
|
||||
if (!confirm('确定要删除这条评论吗?')) return;
|
||||
await fetch(`${commentsAPIBase()}/comments/${id}`, {
|
||||
await fetch(`${API_BASE}/comments/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: getHeaders()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user