Merge "add reward manage" into main
diff --git "a/src/app/community/community-detail/\133communityId\135/page.tsx" "b/src/app/community/community-detail/\133communityId\135/page.tsx"
index 850c54e..962cc0f 100644
--- "a/src/app/community/community-detail/\133communityId\135/page.tsx"
+++ "b/src/app/community/community-detail/\133communityId\135/page.tsx"
@@ -111,7 +111,7 @@
const option = selectedOption.name // 添加排序参数
const response = await axios.get<ThreadList>(
process.env.PUBLIC_URL + `/community/threads`, {
- params: { communityId, pageNumber, rows, option, searchValue }
+ params: { userId: 22301145, communityId, pageNumber, rows, option, searchValue }
}
);
console.log('获取帖子列表:', response.data.records);
diff --git "a/src/app/community/thread-detail/\133threadId\135/page.tsx" "b/src/app/community/thread-detail/\133threadId\135/page.tsx"
index 89ae1e8..f998f64 100644
--- "a/src/app/community/thread-detail/\133threadId\135/page.tsx"
+++ "b/src/app/community/thread-detail/\133threadId\135/page.tsx"
@@ -101,7 +101,12 @@
const fetchThreadInfo = async () => {
try {
- const { data } = await axios.get(process.env.PUBLIC_URL + `/thread?threadId=${threadId}`);
+ const { data } = await axios.get(process.env.PUBLIC_URL + `/thread`, {
+ params: {
+ threadId,
+ userId: 22301145
+ }
+ });
setThreadInfo(data);
setTotalComments(data.commentNumber);
} catch (err) {
@@ -110,6 +115,7 @@
}
};
+
// 获取发帖人
useEffect(() => {
if (!threadInfo) return;
diff --git a/src/app/resource/hot-resource/page.tsx b/src/app/resource/hot-resource/page.tsx
index 3204d6a..4990638 100644
--- a/src/app/resource/hot-resource/page.tsx
+++ b/src/app/resource/hot-resource/page.tsx
@@ -41,18 +41,17 @@
resourceSummary: string;
lastUpdateTime: string;
hot: number;
- gamePlayList: { gameplayName: string }[];
+ gameplayList: string[];
}
interface HotEntry {
hot: number;
}
interface HotInfo {
- resourceId: number;
- resourceName: string;
- hotList: HotEntry[];
+ classify: string;
+ hotInfoList: HotEntry[];
}
interface HotInfoResponse {
- hotInfoList: HotInfo[];
+ records: HotInfo[];
}
interface HotResourceList {
total: number;
@@ -109,8 +108,9 @@
const fetchHotInfo = async () => {
try {
- const response = await axios.get<HotInfoResponse>(process.env.PUBLIC_URL + `/resource/hot-info`);
- const hotInfoList = response.data.hotInfoList;
+ const response = await axios.get<HotInfoResponse>(process.env.PUBLIC_URL + `/resource/hot-trend`);
+ console.log(response.data.records)
+ const records = response.data.records;
// 获取最近七天的日期标签(格式:MM-DD)
const labels = Array.from({ length: 7 }, (_, i) => {
@@ -119,9 +119,9 @@
return `${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
});
- const datasets = hotInfoList.map((info, idx) => ({
- label: info.resourceName,
- data: info.hotList.map(h => h.hot),
+ const datasets = records.map((info, idx) => ({
+ label: info.classify,
+ data: info.hotInfoList.map(h => h.hot),
fill: false,
tension: 0.4,
borderColor: generateColor(idx),
@@ -243,8 +243,8 @@
<div className="resource-content">
<h3>{hotResource.resourceName}</h3>
<div className="tags">
- {hotResource.gamePlayList.map((tag, index) => (
- <Tag key={index} value={tag.gameplayName} />
+ {hotResource.gameplayList.map((tag, index) => (
+ <Tag key={index} value={tag} />
))}
</div>
</div>
diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx
index c48b626..5f6642b 100644
--- a/src/app/search/page.tsx
+++ b/src/app/search/page.tsx
@@ -1,12 +1,120 @@
'use client';
-import React from 'react';
-const EmptyPage: React.FC = () => {
+import React, { useRef, useState } from 'react';
+import { InputText } from 'primereact/inputtext';
+import { Button } from 'primereact/button';
+import { Card } from 'primereact/card';
+import { Tag } from 'primereact/tag';
+import { Image } from 'primereact/image';
+import { Paginator, PaginatorPageChangeEvent } from 'primereact/paginator';
+// 页面跳转
+import { useRouter } from 'next/navigation';
+// 评分图标
+import { Fire } from '@icon-park/react';
+import { RobotOne } from '@icon-park/react';
+import axios from 'axios';
+
+import './search-page.scss';
+
+interface Resource {
+ resourceId: number;
+ resourceName: string;
+ resourcePicture: string;
+ resourceSummary: string;
+ lastUpdateTime: string;
+ hot: number;
+ gamePlayList: { gameplayName: string }[];
+}
+
+export default function SmartSearchPage() {
+ const [input, setInput] = useState('');
+ const [isSearched, setIsSearched] = useState(false);
+
+ const [resources, setResources] = useState<Resource[]>([]);
+ const [page, setPage] = useState(0);
+ const [rows, setRows] = useState(5);
+ const [totalRecords, setTotalRecords] = useState(0);
+ const scrollRef = useRef<HTMLDivElement>(null);
+ const router = useRouter();
+ const fetchSearch = async (query: string, page: number, size: number) => {
+ console.log(page, size,)
+ const res = await axios.get(process.env.PUBLIC_URL + '/ai', {
+ params: { input: query, pageNumber: page + 1, rows: size }
+ });
+ console.log(res.data.records)
+ setResources(res.data.records);
+ setTotalRecords(res.data.total);
+ scrollRef.current?.scrollTo({ top: 0, behavior: 'smooth' });
+ };
+
+ const handleSearch = () => {
+ if (input.trim()) {
+ setIsSearched(true); // ⬅️ 设置为 true,触发样式移动
+ setPage(0); // 重置到第一页
+ fetchSearch(input, 0, rows);
+ }
+ };
+
+ const onPageChange = (e: PaginatorPageChangeEvent) => {
+ setPage(e.page);
+ setRows(e.rows);
+ fetchSearch(input, e.page, e.rows);
+ };
+
return (
- <div className="p-d-flex p-jc-center p-ai-center" style={{ height: '100vh' }}>
- {"一个空页面"}
+ <div className={`smart-search-page ${!isSearched ? 'centered' : ''}`}>
+ <div className="search-header">AI 智能搜索助手</div>
+
+ <div className="search-input">
+ <InputText
+ value={input}
+ onChange={(e) => setInput(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && handleSearch()}
+ placeholder="请输入你的需求"
+ className="input-text"
+ />
+ <Button icon={<RobotOne theme="outline" size="24" fill="#ffffff" />} onClick={handleSearch} className="search-btn" />
+ </div>
+
+ <div className="all-resources-list" ref={scrollRef}>
+ {resources.map((item) => (
+ <Card key={item.resourceId} className="all-resources-card" onClick={() => router.push(`/resource/resource-detail/${item.resourceId}`)}>
+ {/* 左侧图片 */}
+ <Image
+ src={process.env.NEXT_PUBLIC_NGINX_URL + item.resourcePicture}
+ alt={item.resourceName}
+ width="250" height="140"
+ preview
+ />
+
+ {/* 中间内容 */}
+ <div className="resource-header">
+ <div className="resource-content">
+ <h3>{item.resourceName}</h3>
+ <div className="tags">
+ {item.gamePlayList.map((tag, i) => (
+ <Tag key={i} value={tag.gameplayName} />
+ ))}
+ </div>
+ </div>
+
+ {/* 右侧状态栏 */}
+ <div className="resources-states">
+ <div className="state-item">
+ <Fire theme="outline" size="16" fill="#FF8D1A" />
+ <span>热度:{item.hot}</span>
+ </div>
+ <div className="state-item">
+ <span>最新更新时间:{item.lastUpdateTime}</span>
+ </div>
+ </div>
+
+ </div>
+ </Card>
+ ))}
+ </div>
+
+ {totalRecords > 5 && (<Paginator className="Paginator" first={page * rows} rows={rows} totalRecords={totalRecords} rowsPerPageOptions={[5, 10]} onPageChange={onPageChange} />)}
</div>
);
-};
-
-export default EmptyPage;
+}
diff --git a/src/app/search/search-page.scss b/src/app/search/search-page.scss
new file mode 100644
index 0000000..13c701c
--- /dev/null
+++ b/src/app/search/search-page.scss
@@ -0,0 +1,35 @@
+.smart-search-page {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 2rem 1rem;
+ display: flex;
+ flex-direction: column;
+ transition: all 5s ease;
+
+ .search-header {
+ font-size: 1.8rem;
+ font-weight: bold;
+ text-align: center;
+ margin-bottom: 2rem;
+ }
+
+ .search-input {
+ display: flex;
+ margin-bottom: 1.5rem;
+
+ .input-text {
+ flex: 1;
+ border-radius: 10px 0 0 10px;
+ }
+
+ .search-btn {
+ min-width: 100px;
+ border-radius: 0 10px 10px 0;
+ }
+ }
+}
+
+.smart-search-page.centered {
+ justify-content: center; // 使其上下居中
+ height: 80vh; // 占满整页高度实现居中效果
+}
\ No newline at end of file