优化帖子详情与列表展示,并新增问答帖类型与已解决状态。
统一标题锚点定位、编辑底栏固定与操作栏分层,列表徽章前置并区分置顶/问答配色。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -271,15 +271,16 @@ export const api = {
|
||||
fd.append('image', file);
|
||||
return request<{ url: string }>('/api/uploads/image', { method: 'POST', body: fd, headers: {} });
|
||||
},
|
||||
createPost: (data: { board_id: string; title: string; content: string; tags?: string }) => {
|
||||
createPost: (data: { board_id: string; title: string; content: string; tags?: string; post_type?: string }) => {
|
||||
const fd = new FormData();
|
||||
fd.append('board_id', data.board_id);
|
||||
fd.append('title', data.title);
|
||||
fd.append('content', data.content);
|
||||
fd.append('tags', data.tags || '');
|
||||
fd.append('post_type', data.post_type || 'normal');
|
||||
return request<{ post_id: number; message?: string; status?: string }>('/api/posts', { method: 'POST', body: fd, headers: {} });
|
||||
},
|
||||
updatePost: (id: number, data: { title: string; content: string; tags?: string; board_id?: string | number }) => {
|
||||
updatePost: (id: number, data: { title: string; content: string; tags?: string; board_id?: string | number; post_type?: string }) => {
|
||||
const fd = new FormData();
|
||||
fd.append('title', data.title);
|
||||
fd.append('content', data.content);
|
||||
@@ -287,8 +288,20 @@ export const api = {
|
||||
if (data.board_id != null && data.board_id !== '') {
|
||||
fd.append('board_id', String(data.board_id));
|
||||
}
|
||||
if (data.post_type) {
|
||||
fd.append('post_type', data.post_type);
|
||||
}
|
||||
return request<{ message: string }>(`/api/posts/${id}`, { method: 'PUT', body: fd, headers: {} });
|
||||
},
|
||||
setQuestionResolved: (id: number, resolved: boolean) => {
|
||||
const fd = new FormData();
|
||||
fd.append('resolved', resolved ? '1' : '0');
|
||||
return request<{ message: string; question_resolved: boolean }>(`/api/posts/${id}/resolve`, {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
headers: {},
|
||||
});
|
||||
},
|
||||
deletePost: (id: number) => request<{ message: string }>(`/api/posts/${id}`, { method: 'DELETE' }),
|
||||
login: (username: string, password: string) => {
|
||||
const fd = new FormData();
|
||||
|
||||
Reference in New Issue
Block a user