feat: align with upstream — pin posts, edit marker, custom CSS, UX fixes

- Pin/unpin posts (PUT /api/posts/:id/pin, admin) with notification to author
- is_pinned/pinned_at in schema; 📌 badge on feed + detail; admin pin button
- Edited marker (已编辑) on feed + detail; edit button + modal for authors
- Custom CSS: upload/delete API + admin tab + global loader (style.css override)
- Fix: duplicate post title on detail page (remove card title, keep header)
- Fix: forum name flicker on load (localStorage cache before fetch)
- Fix: dropdown menu closes on outside click (document listener)
- Fix: document.title + <title> sync on forum rename
This commit is contained in:
lezi-fun committed 2026-08-10 12:32:06 +08:00
1 parent 7ce81969ac
commit 4ee38f6486
14 files changed
+371 -10

No files matched your search

+19
View File
@@ -60,6 +60,9 @@ export const API = {
updatePost(postId, title, content) {
return apiFetch('/posts/' + postId, { method: 'PUT', body: JSON.stringify({ title, content }) });
},
togglePinPost(postId) {
return apiFetch('/posts/' + postId + '/pin', { method: 'PUT' });
},
deletePost(postId) { return apiFetch('/posts/' + postId, { method: 'DELETE' }); },
// 回复
@@ -142,6 +145,22 @@ export const API = {
return apiFetch('/admin/custom-pages/' + id, { method: 'DELETE' });
},
// 自定义 CSS
uploadCustomCss(file) {
const fd = new FormData();
fd.append('file', file);
const headers = {};
if (token) headers['Authorization'] = 'Bearer ' + token;
return fetch('/api/admin/custom-css', { method: 'POST', body: fd, headers }).then(async (res) => {
const data = await res.json().catch(() => ({}));
if (!res.ok || data.error) throw new Error(data.error || '上传失败');
return data;
});
},
deleteCustomCss() {
return apiFetch('/admin/custom-css', { method: 'DELETE' });
},
// 通知
getNotifications() { return apiFetch('/notifications'); },
markNotificationRead(id) { return apiFetch('/notifications/' + id + '/read', { method: 'PUT' }); },