add mainView, reward, community pages
Change-Id: I70da6ed3e91ebf4124c2074b6508192a19ed9909
diff --git "a/src/app/community/thread-detail/\133threadId\135/page.tsx" "b/src/app/community/thread-detail/\133threadId\135/page.tsx"
index 2189402..89ae1e8 100644
--- "a/src/app/community/thread-detail/\133threadId\135/page.tsx"
+++ "b/src/app/community/thread-detail/\133threadId\135/page.tsx"
@@ -7,7 +7,6 @@
import { InputText } from "primereact/inputtext";
// 页面跳转
import { useParams } from 'next/navigation'
-import { useRouter } from 'next/navigation';
// 接口传输
import axios from 'axios';
// 回复评论
@@ -69,7 +68,6 @@
// 获取URL参数,页面跳转
const params = useParams<{ threadId: string }>()
const threadId = decodeURIComponent(params.threadId); // 防止中文路径乱码
- const router = useRouter();
// 消息提醒
const toast = useRef<Toast>(null);
// 帖子信息
@@ -103,7 +101,7 @@
const fetchThreadInfo = async () => {
try {
- const { data } = await axios.get(`http://127.0.0.1:4523/m1/6387307-6083949-default/thread?threadId=${threadId}`);
+ const { data } = await axios.get(process.env.PUBLIC_URL + `/thread?threadId=${threadId}`);
setThreadInfo(data);
setTotalComments(data.commentNumber);
} catch (err) {
@@ -116,7 +114,7 @@
useEffect(() => {
if (!threadInfo) return;
// 发帖人
- axios.get(`http://127.0.0.1:4523/m1/6387307-6083949-default/user/info?userId=${threadInfo.userId}`)
+ axios.get(process.env.PUBLIC_URL + `/user/info?userId=${threadInfo.userId}`)
.then(res => setUserInfo(res.data))
.catch(console.error);
}, [threadInfo]);
@@ -127,7 +125,7 @@
if (!threadInfo.isLike) {
try {
const response = await axios.post(
- `http://127.0.0.1:4523/m1/6387307-6083949-default/thread/like`, {
+ process.env.PUBLIC_URL + `/thread/like`, {
params: { threadId, userId: 22301145 }
}
);
@@ -143,7 +141,7 @@
} else {
try {
const response = await axios.delete(
- `http://127.0.0.1:4523/m1/6387307-6083949-default/thread/like`, {
+ process.env.PUBLIC_URL + `/thread/like`, {
params: { threadId, userId: 22301145 }
}
);
@@ -180,11 +178,11 @@
// 获取评论列表
const fetchComments = async () => {
try {
- const page = first / rows + 1;
- console.log("当前页" + page + "size" + rows);
+ const pageNumber = first / rows + 1;
+ console.log("当前页" + pageNumber + "size" + rows);
const response = await axios.get<CommentList>(
- `http://127.0.0.1:4523/m1/6387307-6083949-default/comments`, {
- params: { threadId, page, rows }
+ process.env.PUBLIC_URL + `/comments`, {
+ params: { threadId, pageNumber, rows }
}
);
console.log('获取评论列表:', response.data.records);
@@ -193,7 +191,7 @@
response.data.records.forEach(comment => {
if (comment.userId != null && !commentUserInfos.has(comment.userId)) {
axios.get<UserInfo>(
- `http://127.0.0.1:4523/m1/6387307-6083949-default/user/info`,
+ process.env.PUBLIC_URL + `/user/info`,
{ params: { userId: comment.userId } }
).then(res => {
setCommentUserInfos(prev => new Map(prev).set(comment.userId!, res.data));
@@ -220,7 +218,7 @@
createdAt: new Date().toISOString().slice(0, 19).replace('T', ' ')
};
- const response = await axios.post('http://127.0.0.1:4523/m1/6387307-6083949-default/comment', newComment);
+ const response = await axios.post(process.env.PUBLIC_URL + '/comment', newComment);
if (response.status === 200) {
toast.current?.show({ severity: 'success', summary: 'Success', detail: '回复成功' });
@@ -250,7 +248,7 @@
createdAt: new Date().toISOString().slice(0, 19).replace('T', ' ')
};
- const response = await axios.post('http://127.0.0.1:4523/m1/6387307-6083949-default/comment', newComment);
+ const response = await axios.post(process.env.PUBLIC_URL + '/comment', newComment);
if (response.status === 200) {
toast.current?.show({ severity: 'success', summary: 'Success', detail: '评论成功' });
@@ -272,7 +270,7 @@
try {
// 调用 DELETE 接口,URL 中最后一段是要删除的 commentId
const response = await axios.delete(
- `http://127.0.0.1:4523/m1/6387307-6083949-default/comment?commentId=${commentId}`
+ process.env.PUBLIC_URL + `/comment?commentId=${commentId}`
);
if (response.status === 200) {
@@ -334,7 +332,6 @@
<div className="comments-section">
<div className="comments-header">
<h2>评论 ({totalComments})</h2>
- <Button label="返回社区" link onClick={() => router.push(`/community/community-detail/${threadInfo.communityId}`)} />
</div>
<div className="comments-input">
<Avatar image={process.env.NEXT_PUBLIC_NGINX_URL + "users/" + userInfo.avatar} size="large" shape="circle" />