parent
0b141c938b
commit
ebc02c9667
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
|
|
@ -81,12 +81,12 @@ function List(props){
|
|||
|
||||
useEffect(()=>{
|
||||
let v = allValue && allValue > 0;
|
||||
if((updateIds && !v && (updateIds.author_id || updateIds.issue_priorities_id || updateIds.issue_tag_ids || updateIds.milestone_id || updateIds.sort_by || updateIds.status_id ||updateIds.assigner_id)) || value || end_date || begin_date){
|
||||
if((updateIds && !v && (updateIds.author_id || updateIds.issue_priorities_id || updateIds.issue_tag_ids || updateIds.milestone_id || updateIds.sort_by || updateIds.status_id ||updateIds.assigner_id)) || value || end_date || begin_date || aboutMe !=="all"){
|
||||
setClearFlag(true);
|
||||
}else{
|
||||
setClearFlag(false);
|
||||
}
|
||||
},[updateIds,value,allValue,begin_date,end_date])
|
||||
},[updateIds,value,allValue,begin_date,end_date,aboutMe])
|
||||
// 自定义一个初始不更新的hook
|
||||
const useUpdateEffect = (fn, inputs) => {
|
||||
const didMountRef = useRef(false);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { Input, Row, Col, Tabs, Pagination } from 'antd';
|
||||
import { Input, Row, Col, Tabs, Pagination , Icon } from 'antd';
|
||||
import axios from 'axios';
|
||||
import { TPMIndexHOC } from '../tpm/TPMIndexHOC';
|
||||
import { SnackbarHOC } from 'educoder';
|
||||
import ItemList from './ItemList';
|
||||
import Nodata from '../../forge/Nodata';
|
||||
import './index.scss';
|
||||
import emp from '../../forge/Images/emp.png';
|
||||
|
||||
const { Search } = Input;
|
||||
const { TabPane } = Tabs;
|
||||
|
|
@ -23,7 +24,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
const [total, setTotal] = useState(0);
|
||||
const [dataList, setDataList] = useState([]);
|
||||
|
||||
const [ orderBy , setOrderBy ] = useState(undefined);
|
||||
const [ orderBy , setOrderBy ] = useState("scoreDesc");
|
||||
|
||||
const [forcesearch, setForcesearch] = useState(false);
|
||||
|
||||
|
|
@ -46,7 +47,11 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
|
||||
useEffect(() => {
|
||||
searchDataList();
|
||||
}, [type, page, term, forcesearch,orderBy]);
|
||||
}, [type, term, forcesearch,orderBy,page]);
|
||||
|
||||
useEffect(()=>{
|
||||
setPage(1);
|
||||
},[orderBy])
|
||||
|
||||
useEffect(() => {
|
||||
if (ref) {
|
||||
|
|
@ -119,6 +124,8 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
setPage(1);
|
||||
if(type !== "1"){
|
||||
setOrderBy(undefined);
|
||||
}else{
|
||||
setOrderBy("scoreDesc");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +136,34 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
})
|
||||
}, [history]);
|
||||
|
||||
const svg = ()=>(
|
||||
<svg t="1679452192759" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="27711" width="14" height="16">
|
||||
<path d="M709.060096 692.0192H315.024896c-11.8784 0-18.432 12.4928-11.1616 20.992l197.12 228.4544a15.0528 15.0528 0 0 0 22.1184 0l197.12-228.4544c7.2704-8.4992 0.7168-20.992-11.1616-20.992z" fill="#bfbfbf" p-id="27712" data-spm-anchor-id="a313x.7781069.0.i11" class="selected"></path><path d="M709.060096 331.9808H315.024896c-11.8784 0-18.432-12.4928-11.1616-20.992L500.983296 82.5344a15.0528 15.0528 0 0 1 22.1184 0l197.12 228.4544c7.2704 8.4992 0.7168 20.992-11.1616 20.992z" fill="#bfbfbf" p-id="27713" data-spm-anchor-id="a313x.7781069.0.i7" class="selected"></path>
|
||||
</svg>
|
||||
)
|
||||
|
||||
const descSvg = ()=>(
|
||||
<svg t="1679451960146" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="27475" width="14" height="16">
|
||||
<path d="M709.060096 331.9808H315.024896c-11.8784 0-18.432-12.4928-11.1616-20.992L500.983296 82.5344a15.0528 15.0528 0 0 1 22.1184 0l197.12 228.4544c7.2704 8.4992 0.7168 20.992-11.1616 20.992z" fill="#999999" p-id="27476"></path><path d="M709.060096 692.0192H315.024896c-11.8784 0-18.432 12.4928-11.1616 20.992l197.12 228.4544a15.0528 15.0528 0 0 0 22.1184 0l197.12-228.4544c7.2704-8.4992 0.7168-20.992-11.1616-20.992z" fill="#466aff" p-id="27477" data-spm-anchor-id="a313x.7781069.0.i0" class="selected"></path>
|
||||
</svg>
|
||||
)
|
||||
|
||||
const ascSvg = ()=>(
|
||||
<svg t="1679452192759" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="27711" width="14" height="16">
|
||||
<path d="M709.060096 692.0192H315.024896c-11.8784 0-18.432 12.4928-11.1616 20.992l197.12 228.4544a15.0528 15.0528 0 0 0 22.1184 0l197.12-228.4544c7.2704-8.4992 0.7168-20.992-11.1616-20.992z" fill="#999999" p-id="27712"></path><path d="M709.060096 331.9808H315.024896c-11.8784 0-18.432-12.4928-11.1616-20.992L500.983296 82.5344a15.0528 15.0528 0 0 1 22.1184 0l197.12 228.4544c7.2704 8.4992 0.7168 20.992-11.1616 20.992z" fill="#466aff" p-id="27713" data-spm-anchor-id="a313x.7781069.0.i7" class="selected"></path>
|
||||
</svg>
|
||||
)
|
||||
|
||||
function iconSwitch(array){
|
||||
if(array === "desc"){
|
||||
return <Icon component={descSvg} />
|
||||
}else if(array === "asc"){
|
||||
return <Icon component={ascSvg} />
|
||||
}else{
|
||||
return <Icon component={svg} />
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
|
|
@ -156,12 +191,22 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
<TabPane tab={`项目(${totalType1})`} key={1}>
|
||||
<div className="search-content">
|
||||
<ul className="search-condition">
|
||||
<li className={orderBy === "scoreDesc" || orderBy === "scoreAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "scoreDesc" ? "scoreAsc" :"scoreDesc")}>匹配度</li>
|
||||
<li className={orderBy === "watchDesc" || orderBy === "watchAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "watchDesc" ? "watchAsc" :"watchDesc")}>关注数</li>
|
||||
<li className={orderBy === "forkDesc" || orderBy === "forkAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "forkDesc" ? "forkAsc" :"forkDesc")}>Fork数</li>
|
||||
<li className={orderBy === "starDesc" || orderBy === "starAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "starDesc" ? "starAsc" :"starDesc")}>点赞数</li>
|
||||
<li className={orderBy === "updateTimeDesc" || orderBy === "updateTimeAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "updateTimeDesc" ? "updateTimeAsc" :"updateTimeDesc")}>更新时间</li>
|
||||
<li className={orderBy === "createTimeDesc" || orderBy === "createTimeAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "createTimeDesc" ? "createTimeAsc" :"createTimeDesc")}>创建时间</li>
|
||||
<li className={orderBy === "scoreDesc" ? "active":""} onClick={()=>setOrderBy("scoreDesc")}>匹配度</li>
|
||||
<li className={orderBy === "watchDesc" || orderBy === "watchAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "watchDesc" ? "watchAsc" :"watchDesc")}>
|
||||
关注数{iconSwitch(orderBy === "watchDesc" ? "desc" : orderBy === "watchAsc" ? "asc" :"")}
|
||||
</li>
|
||||
<li className={orderBy === "forkDesc" || orderBy === "forkAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "forkDesc" ? "forkAsc" :"forkDesc")}>
|
||||
Fork数{iconSwitch(orderBy === "forkDesc" ? "desc" : orderBy === "forkAsc" ? "asc" :"")}
|
||||
</li>
|
||||
<li className={orderBy === "starDesc" || orderBy === "starAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "starDesc" ? "starAsc" :"starDesc")}>
|
||||
点赞数{iconSwitch(orderBy === "starDesc" ? "desc" : orderBy === "starAsc" ? "asc" :"")}
|
||||
</li>
|
||||
<li className={orderBy === "updateTimeDesc" || orderBy === "updateTimeAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "updateTimeDesc" ? "updateTimeAsc" :"updateTimeDesc")}>
|
||||
更新时间{iconSwitch(orderBy === "updateTimeDesc" ? "desc" : orderBy === "updateTimeAsc" ? "asc" :"")}
|
||||
</li>
|
||||
<li className={orderBy === "createTimeDesc" || orderBy === "createTimeAsc" ?"active":""} onClick={()=>setOrderBy(orderBy === "createTimeDesc" ? "createTimeAsc" :"createTimeDesc")}>
|
||||
创建时间{iconSwitch(orderBy === "createTimeDesc" ? "desc" : orderBy === "createTimeAsc" ? "asc" :"")}
|
||||
</li>
|
||||
</ul>
|
||||
<p>{`找到${totalType1}条结果`}</p>
|
||||
<ItemList
|
||||
|
|
@ -177,7 +222,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
total={total}
|
||||
showTotal={total => `共 ${total} 条`}
|
||||
/></div>
|
||||
: <Nodata _html="暂无数据" className="no-data-box" />
|
||||
: <div className="none_panels"><div><img src={emp} alt="" /></div></div>
|
||||
}
|
||||
</TabPane>
|
||||
|
||||
|
|
@ -192,7 +237,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
dataList.length ?
|
||||
<div className="pb20"><Pagination
|
||||
showQuickJumper={dataList.length > size}
|
||||
onChange={(page) => { setPage(page) }}
|
||||
onChange={(page) => { setPage(page); }}
|
||||
current={page}
|
||||
total={total}
|
||||
showTotal={total => `共 ${total} 条`}
|
||||
|
|
@ -249,7 +294,7 @@ const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) =
|
|||
dataList.length ?
|
||||
<div className="pb20"><Pagination
|
||||
showQuickJumper={dataList.length > size}
|
||||
onChange={(page) => { setPage(page) }}
|
||||
onChange={(page) => { setPage(page);}}
|
||||
current={page}
|
||||
total={total}
|
||||
showTotal={total => `共 ${total} 条`}
|
||||
|
|
|
|||
Loading…
Reference in New Issue