fix: API param localStorge useId
Change-Id: Ifd624462360111f08ca308ea07b6fcaac0747104
diff --git "a/src/app/community/community-detail/\133communityId\135/page.tsx" "b/src/app/community/community-detail/\133communityId\135/page.tsx"
index 962cc0f..6beb423 100644
--- "a/src/app/community/community-detail/\133communityId\135/page.tsx"
+++ "b/src/app/community/community-detail/\133communityId\135/page.tsx"
@@ -23,9 +23,13 @@
import axios from 'axios';
// 防抖函数
import { debounce } from 'lodash';
+import { useLocalStorage } from '../../../hook/useLocalStorage';
// 样式
import './resource-community.scss';
+interface User {
+ Id: number;
+}
// 帖子列表数据
interface Thread {
threadId: number;
@@ -53,6 +57,8 @@
// 社区详情页面
export default function CommunityDetailPage() {
+ const user = useLocalStorage<User>('user');
+ const userId: number = user?.Id ?? -1;
// 获取URL参数,页面跳转
const params = useParams<{ communityId: string }>()
const communityId = decodeURIComponent(params.communityId); // 防止中文路径乱码
@@ -111,7 +117,7 @@
const option = selectedOption.name // 添加排序参数
const response = await axios.get<ThreadList>(
process.env.PUBLIC_URL + `/community/threads`, {
- params: { userId: 22301145, communityId, pageNumber, rows, option, searchValue }
+ params: { userId, communityId, pageNumber, rows, option, searchValue }
}
);
console.log('获取帖子列表:', response.data.records);
@@ -139,7 +145,7 @@
try {
const currentDate = new Date().toISOString();
const postData = {
- userId: 22301145, // 记得用户登录状态获取
+ userId, // 记得用户登录状态获取
threadPicture: formData.threadPicture,
title: formData.title,
content: formData.content,