blob: 7f8d900df68f43636e9faf5b452cdb544b8c5def [file] [log] [blame]
San3yuan292794c2025-06-08 20:02:46 +08001
2import React, { useState, useCallback, useEffect } from 'react';
阳菜,放晴!77743f42025-06-06 23:04:08 +08003import styles from './corner.module.css';
4import { useNavigate } from 'react-router';
San3yuan30e245f2025-06-07 20:04:23 +08005import { useSearchParams } from 'react-router-dom';
San3yuan292794c2025-06-08 20:02:46 +08006import { MainTag, MainPostTag } from '@/types/common';
7import { Button, Checkbox, Row, Col } from 'antd';
8import { getTagsByMainTag } from '@/utils/common';
9interface CornerProp {
10
11 setTagIds: (tagIds: number[]) => void;
12}
13
14const BottomRightUpload: React.FC<CornerProp> = (props:CornerProp) => {
San3yuan30e245f2025-06-07 20:04:23 +080015 const [searchParams] = useSearchParams();
San3yuan292794c2025-06-08 20:02:46 +080016 const [tags, setTags] = useState<Map<string, number>>(new Map);
17 const [selectdTags, setSelectedTags] = useState<number[]>([])
18 const setTagIds = props.setTagIds;
阳菜,放晴!77743f42025-06-06 23:04:08 +080019 const navigate = useNavigate();
San3yuan30e245f2025-06-07 20:04:23 +080020 const type = searchParams.get('type');
San3yuan292794c2025-06-08 20:02:46 +080021
阳菜,放晴!77743f42025-06-06 23:04:08 +080022 const handleUploadClick = () => {
San3yuan30e245f2025-06-07 20:04:23 +080023 navigate('/createPost', { state: { isNewPost: true, type} });
阳菜,放晴!77743f42025-06-06 23:04:08 +080024 };
San3yuan292794c2025-06-08 20:02:46 +080025 useEffect(()=>{
26 setTags(getTagsByMainTag(type as string))
27 },[])
阳菜,放晴!77743f42025-06-06 23:04:08 +080028
29 return (
30 <div className={styles.container}>
31 <button className={styles.uploadButton} onClick={handleUploadClick}>
32 发布种子
33 </button>
34
35 <div className={styles.filterItem}>
阳菜,放晴!77743f42025-06-06 23:04:08 +080036 <label htmlFor="rating">评分:</label>
37 <select id="rating">
38 <option value="all">全部</option>
39 <option value="high">高评分</option>
40 <option value="medium">中评分</option>
41 <option value="low">低评分</option>
42 </select>
43 </div>
44
45 <div className={styles.filterItem}>
46 <label htmlFor="tag">标签:</label>
San3yuan292794c2025-06-08 20:02:46 +080047 <Checkbox.Group
48 value={selectdTags}
49 onChange={(checkedValues) =>{
50 setSelectedTags([...checkedValues])
51 }}
52 >
53 <Row gutter={[12, 12]}>
54 {[...tags.entries()].map(([name, id]) => (
55 <Col key={id} xs={12} sm={12} md={8} lg={6}>
56 <Checkbox value={id}>{name}</Checkbox>
57 </Col>
58 ))}
59 </Row>
60 </Checkbox.Group>
阳菜,放晴!77743f42025-06-06 23:04:08 +080061 </div>
San3yuan292794c2025-06-08 20:02:46 +080062
63 <Button
64 color='primary'
65 variant='outlined'
66 onClick={()=>{
67 console.log(selectdTags)
68 setTagIds([...selectdTags])
69
70 }}
71 > 筛选 </Button>
72
73 <Button
74 color='danger'
75 variant='outlined'
76 onClick={()=>{
77 setTagIds([])
78 setSelectedTags([])
79 }}
80 >清空筛选
81 </Button>
阳菜,放晴!77743f42025-06-06 23:04:08 +080082 </div>
83 );
84};
85
86export default BottomRightUpload;