整体链接
Change-Id: Id3379c6188613acdc95548964f19e317eda8dc4f
diff --git a/src/components/corner/corner.tsx b/src/components/corner/corner.tsx
index ad80476..7f8d900 100644
--- a/src/components/corner/corner.tsx
+++ b/src/components/corner/corner.tsx
@@ -1,15 +1,30 @@
-// src/components/BottomRightUpload.tsx
-import React, { use } from 'react';
+
+import React, { useState, useCallback, useEffect } from 'react';
import styles from './corner.module.css';
import { useNavigate } from 'react-router';
import { useSearchParams } from 'react-router-dom';
-const BottomRightUpload: React.FC = () => {
+import { MainTag, MainPostTag } from '@/types/common';
+import { Button, Checkbox, Row, Col } from 'antd';
+import { getTagsByMainTag } from '@/utils/common';
+interface CornerProp {
+
+ setTagIds: (tagIds: number[]) => void;
+}
+
+const BottomRightUpload: React.FC<CornerProp> = (props:CornerProp) => {
const [searchParams] = useSearchParams();
+ const [tags, setTags] = useState<Map<string, number>>(new Map);
+ const [selectdTags, setSelectedTags] = useState<number[]>([])
+ const setTagIds = props.setTagIds;
const navigate = useNavigate();
const type = searchParams.get('type');
+
const handleUploadClick = () => {
navigate('/createPost', { state: { isNewPost: true, type} });
};
+ useEffect(()=>{
+ setTags(getTagsByMainTag(type as string))
+ },[])
return (
<div className={styles.container}>
@@ -18,17 +33,6 @@
</button>
<div className={styles.filterItem}>
- <label htmlFor="category">分区:</label>
- <select id="category">
- <option value="all">全部</option>
- <option value="video">视频</option>
- <option value="music">音乐</option>
- <option value="game">游戏</option>
- <option value="software">软件</option>
- </select>
- </div>
-
- <div className={styles.filterItem}>
<label htmlFor="rating">评分:</label>
<select id="rating">
<option value="all">全部</option>
@@ -40,8 +44,41 @@
<div className={styles.filterItem}>
<label htmlFor="tag">标签:</label>
- <input type="text" id="tag" placeholder="输入标签关键词" />
+ <Checkbox.Group
+ value={selectdTags}
+ onChange={(checkedValues) =>{
+ setSelectedTags([...checkedValues])
+ }}
+ >
+ <Row gutter={[12, 12]}>
+ {[...tags.entries()].map(([name, id]) => (
+ <Col key={id} xs={12} sm={12} md={8} lg={6}>
+ <Checkbox value={id}>{name}</Checkbox>
+ </Col>
+ ))}
+ </Row>
+ </Checkbox.Group>
</div>
+
+ <Button
+ color='primary'
+ variant='outlined'
+ onClick={()=>{
+ console.log(selectdTags)
+ setTagIds([...selectdTags])
+
+ }}
+ > 筛选 </Button>
+
+ <Button
+ color='danger'
+ variant='outlined'
+ onClick={()=>{
+ setTagIds([])
+ setSelectedTags([])
+ }}
+ >清空筛选
+ </Button>
</div>
);
};
diff --git a/src/components/navbar/navbar.tsx b/src/components/navbar/navbar.tsx
index e246ed6..3f26b6b 100644
--- a/src/components/navbar/navbar.tsx
+++ b/src/components/navbar/navbar.tsx
@@ -95,7 +95,7 @@
key: 'game',
icon: <GameIcon />,
label: (
- <a href={'/posts?type=game'}>
+ <a href={'/posts?type=Game'}>
游戏
</a>
),
diff --git a/src/components/postsPanel/postsPanel.module.css b/src/components/postsPanel/postsPanel.module.css
index b4b75ce..f639c77 100644
--- a/src/components/postsPanel/postsPanel.module.css
+++ b/src/components/postsPanel/postsPanel.module.css
@@ -4,7 +4,9 @@
width:100%;
padding:0px 5px;
}
-
+span {
+ color:var(--text-color)
+}
.header{
border-bottom:1px solid var(--border-color);
box-shadow: 1px;
diff --git a/src/components/postsPanel/postsPanel.tsx b/src/components/postsPanel/postsPanel.tsx
index 2916753..c99e40e 100644
--- a/src/components/postsPanel/postsPanel.tsx
+++ b/src/components/postsPanel/postsPanel.tsx
@@ -1,5 +1,5 @@
import { useApi } from '@/hooks/request';
-import React, { useCallback } from 'react';
+import React, { useCallback, useEffect, useState } from 'react';
import request from '@/utils/request'
import style from './postsPanel.module.css'
import { useNavigate } from 'react-router';
@@ -18,6 +18,14 @@
const handlePostCheck =(postId:string) =>{
nav('/postDetail?postId=' + postId);
}
+
+ useEffect(()=>{
+ if(data){
+ console.log("data!!!")
+ console.log(data)
+ }
+ }, [data])
+
return (
<div className={style.panel}>
<div className={style.header}>
@@ -25,11 +33,11 @@
<span className={style.more}>更多</span>
</div>
<div className={style.content} >
- {data && data.length > 0 ?
- data?.map((item: {postId:string, postTitle: string; createdAt: string }, index: number) => (
+ {data && data.records && data.records.length > 0 ?
+ data.records.map((item: {postId:string, postTitle: string; createdAt: string }, index: number) => (
<div key={index} className={style.item} onClick={()=> handlePostCheck(item.postId)} >
<span className={style.text}>{item.postTitle}</span>
- <span>{item.createdAt}</span>
+ <span>{new Date(item.createdAt).toLocaleString()}</span>
</div>
)) :(
<div>未查询到相关记录</div>
diff --git a/src/components/selfStatus/selfStatus.tsx b/src/components/selfStatus/selfStatus.tsx
index 24028ad..1fa812a 100644
--- a/src/components/selfStatus/selfStatus.tsx
+++ b/src/components/selfStatus/selfStatus.tsx
@@ -5,8 +5,9 @@
import request from "@/utils/request";
import { getUserInfo } from "@/api/user";
import { useAppDispatch } from "@/hooks/store";
-
+import type { MenuProps } from 'antd';
import { useNavigate } from "react-router";
+import { Dropdown } from "antd";
interface SelfStatusProps {
@@ -32,29 +33,37 @@
dispatch({ type: "user/getUserInfo", payload: data.userInfo });
}
}
+
+ const logOut = () =>{
+ dispatch({type:"user/logout"})
+ nav('/')
+ }
+
+ const menu: MenuProps['items'] =[
+ {
+ key:'1',
+ label:(<span onClick={logOut}>登出</span>)
+ }
+]
useEffect(() => {
fenchData();
}, [ dispatch]);
- function handleAvatarClick(){
- nav('/homepage')
- }
-
return (
<div className={style.container}>
- <div className={style.left}>
+ <div className={style.left}
+
+ >
{avatar && avatar.length > 0 ? (
- <img className={style.avatar} src={avatar} alt="User Avatar" />):null}
+ <img className={style.avatar} onClick={() => nav('/homepage')} style={{ cursor: 'pointer'}} src={avatar} alt="User Avatar" />):null}
</div>
<div className={style.right}>
<div className={style.info}>
- <p className={style.userName}>{userName}</p>
- <p
- className={style.role}
- onClick={() => nav('/homepage')}
- style={{ cursor: 'pointer', textDecoration: 'underline' }}>
- 用户组: {role && role.trim().length? role:'N/A'}</p>
+ <Dropdown menu={{ items: menu }}>
+ <p className={style.userName}>{userName}</p>
+ </Dropdown>
+ <p className={style.role}>用户组: {role && role.trim().length? role:'N/A'}</p>
<p className={style.uploadTraffic}>上传量: {uploadTraffic ? uploadTraffic : 0}</p>
<p className={style.downloadTraffic}>下载量: {downloadTraffic ? downloadTraffic : 0}</p>
diff --git a/src/components/selfStatus/style.module.css b/src/components/selfStatus/style.module.css
index 858e88a..da68ee3 100644
--- a/src/components/selfStatus/style.module.css
+++ b/src/components/selfStatus/style.module.css
@@ -13,7 +13,6 @@
}
.left {
- border:1px solid #ccc;
display: flex;
flex-direction: column;
align-items: center;
@@ -29,7 +28,6 @@
margin-bottom: 10px;
}
.right {
- border:1px solid #aaa;
display: flex;
flex-direction: column;
justify-content: flex-start;