Improve Comment model to support multiple comment type.

This commit is contained in:
2025-06-26 20:54:35 +08:00
parent f18465bba3
commit 5d0b201fde
7 changed files with 112 additions and 37 deletions

View File

@@ -571,13 +571,13 @@ class Network {
return `${this.apiBaseUrl}/files/download/${fileId}?cf_token=${cfToken}`;
}
async createComment(
async createResourceComment(
resourceID: number,
content: string,
images: number[],
): Promise<Response<any>> {
return this._callApi(() =>
axios.post(`${this.apiBaseUrl}/comments/${resourceID}`, {
axios.post(`${this.apiBaseUrl}/comments/resource/${resourceID}`, {
content,
images,
}),
@@ -597,12 +597,12 @@ class Network {
);
}
async listComments(
async listResourceComments(
resourceID: number,
page: number = 1,
): Promise<PageResponse<Comment>> {
return this._callApi(() =>
axios.get(`${this.apiBaseUrl}/comments/${resourceID}`, {
axios.get(`${this.apiBaseUrl}/comments/resource/${resourceID}`, {
params: { page },
}),
);

View File

@@ -1221,7 +1221,7 @@ function CommentInput({
return;
}
}
const res = await network.createComment(
const res = await network.createResourceComment(
resourceId,
commentContent,
imageIds,
@@ -1339,7 +1339,7 @@ function CommentsList({
const [comments, setComments] = useState<Comment[] | null>(null);
useEffect(() => {
network.listComments(resourceId, page).then((res) => {
network.listResourceComments(resourceId, page).then((res) => {
if (res.success) {
setComments(res.data!);
maxPageCallback(res.totalPages || 1);