Commit 4ab1ada5 authored by 健杭 徐's avatar 健杭 徐
Browse files

111

parent 2be90194
......@@ -16,9 +16,9 @@ async function AddComment({ name, onSuccess }: { name: string; onSuccess: () =>
const response = await fetch(COMMENT_ADD, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, content, created_at: new Date().toISOString() })
body: JSON.stringify({ name, content })
});
const result = await response.json();
if (result.code !== 0) {
alert(`操作失败: ${result.msg}`);
......@@ -28,7 +28,6 @@ async function AddComment({ name, onSuccess }: { name: string; onSuccess: () =>
textInput.value = '';
(document.getElementById('nameInput') as HTMLInputElement).value = '';
onSuccess();
} catch (error) {
console.error('添加评论失败:', error);
}
......
export const COMMENT_ADD: string = 'http://localhost:8080/comment/add'
export const COMMENT_GET: string = 'http://localhost:8080/comment/get'
export const COMMENT_DEL: string = 'http://localhost:8080/comment/delete'
\ No newline at end of file
const IP: string = 'http://10.197.150.54:8080'
export const COMMENT_ADD: string = IP + '/comment/add'
export const COMMENT_GET: string = IP + '/comment/get'
export const COMMENT_DEL: string = IP + '/comment/delete'
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment