From 5fa0d547afd6f56f604c2809d40e351f877dbba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Fri, 11 Nov 2022 14:52:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.css | 3 +- src/forge/Component/SiderBar.js | 3 +- src/forge/Main/Index.js | 95 +++++++++++++--------------- src/forge/Main/IndexItem.js | 2 +- src/forge/Main/projecthome/Index.jsx | 25 +++----- src/forge/css/index.scss | 1 + 6 files changed, 59 insertions(+), 70 deletions(-) diff --git a/src/App.css b/src/App.css index fcf5cb956..090ef43dc 100644 --- a/src/App.css +++ b/src/App.css @@ -72,7 +72,8 @@ body { .markdown-body p { margin:10px 0px!important; font-size: 16px !important; - white-space: pre-wrap; + /* 用户提出多个徽章换行显示,p标签会换行显示 */ + /* white-space: pre-wrap; */ } .markdown-body>p { diff --git a/src/forge/Component/SiderBar.js b/src/forge/Component/SiderBar.js index c0cae2ce2..61e6f85e3 100644 --- a/src/forge/Component/SiderBar.js +++ b/src/forge/Component/SiderBar.js @@ -36,7 +36,8 @@ function SiderBar(props) { //页面加载完成之后隐藏回到顶点 $(".-task-sidebar .gotop").hide(); // 意见反馈弹窗 - if(search && search.indexOf('feedback') !== -1){ + if(search && search.indexOf('feedback') !== -1 && search.indexOf('type=feedback') === -1){ + // 用户已经在issue中反馈,刷新页面不弹出意见反馈 setFeedBackModal(true) } },[]) diff --git a/src/forge/Main/Index.js b/src/forge/Main/Index.js index c76f3858a..4ac20e426 100644 --- a/src/forge/Main/Index.js +++ b/src/forge/Main/Index.js @@ -19,11 +19,12 @@ const Search = Input.Search; class Index extends Component { constructor(props) { super(props); + const searchParams = new URLSearchParams(props.location.search.substring(1)); this.state = { projectsList: undefined, page: 1, limit: 15, - search: undefined, + search: searchParams.get('search'), sort: undefined, total: 0, isSpin: true, @@ -125,47 +126,29 @@ class Index extends Component { const url = `/projects/group_type_list.json`; axios.get(url).then((result) => { if (result && result.data) { - this.setTypeList(result.data, undefined) + this.setState({ + typeList: result.data + }) } }).catch((error) => { }) } - setTypeList = (list, active_type) => { - this.setState({ - typeList: list.map((item, key) => { - return ( -
  • this.changeType(`${item.project_type}`, list)}> -

    - {item.name} - {item.projects_count} -

    -
  • - ) - }) - }) - } - // 切换类型 - changeType = (type, list) => { + changeType = (type) => { this.setState({ isSpin: true, project_type: type, - search: undefined, - category_id: undefined, },()=>{ - this.setTypeList(list, type) - const { page, limit, sort , languageId } = this.state; - this.getListData(page, limit, undefined, sort, type, undefined , languageId); + const { page, limit, sort , languageId, search, category_id } = this.state; + this.getListData(page, limit, search, sort, type, category_id , languageId); }) } // 获取类型 getCategory = () => { const url = `/project_categories/group_list.json`; - axios.get(url).then((result) => { if (result && result.data) { - this.setCategoryList(result.data, undefined); } }).catch((error) => { }) @@ -177,39 +160,40 @@ class Index extends Component { }) } - changeCategory = (id, list) => { + changeCategory = (id) => { this.setState({ category_id: id, page: 1 },()=>{ - const { limit, sort, project_type , languageId } = this.state; - this.getListData(1, limit, undefined, sort, project_type, id , languageId); + const { limit, sort, project_type , languageId, search } = this.state; + this.getListData(1, limit, search, sort, project_type, id , languageId); }); } // 排序 ChangeSoryBy = (e) => { this.setState({ - sort_by: e.key, + sort: e.key, page: 1, - search: undefined, isSpin: true }) - const { limit, project_type, category_id , languageId } = this.state; - this.getListData(1, limit, undefined, e.key, project_type, category_id , languageId); + const { limit, search, project_type, category_id , languageId } = this.state; + this.getListData(1, limit, search, e.key, project_type, category_id , languageId); } // 搜索 searchFun = (value) => { + // 用户主动搜索之后,刷新路由,解决用户刷新页面又搜索路由中的内容 + if(this.props.location.search.indexOf('search') !== -1){ + this.props.history.push(this.props.location.pathname); + } this.setState({ page: 1, search: value, - isSpin: true, - project_type: undefined, - sort: "updated_on" + isSpin: true }) - const { limit, sort, category_id , languageId } = this.state; - this.getListData(1, limit, value, sort, undefined, category_id , languageId); + const { limit, sort, category_id , languageId, project_type } = this.state; + this.getListData(1, limit, value, sort, project_type, category_id , languageId); } changeSearchValue = (e) => { this.setState({ @@ -235,13 +219,14 @@ class Index extends Component { isSpin:true, languageId:e === 0 ?undefined:e }) - const { page, limit, sort , project_type , category_id } = this.state; - this.getListData(page, limit, undefined, sort, project_type, category_id ,e === 0 ?undefined:e); + const { page, limit, sort , project_type , category_id, search } = this.state; + this.getListData(page, limit, search, sort, project_type, category_id ,e === 0 ?undefined:e); } - menu =()=> { + menu =()=> { + const {sort} = this.state; return( - + 更新时间排序 创建时间排序 fork数量排序 @@ -275,9 +260,7 @@ class Index extends Component { render() { const { current_user } = this.props; - const { projectsList , recommendList , languageList , languageId , - isSpin, total, search, limit, page, typeList, categoryList , - recommendOriList , CategoryList , category_id } = this.state; + const { projectsList , recommendList , languageList , languageId, isSpin, total, search, limit, page, typeList, categoryList, recommendOriList , CategoryList , category_id, project_type } = this.state; // const setting={ // dots: true, @@ -342,12 +325,21 @@ class Index extends Component { } */}
    -
      -
    • 项目类型
    • - {typeList} +
        +
      • {this.changeType(undefined)}}>项目类型
      • + {typeList && typeList.map((item, key) => { + return ( +
      • {this.changeType(`${item.project_type}`)}}> +

        + {item.name} + {item.projects_count} +

        +
      • + ) + })}
      -
        -
      • 项目类别
      • +
          +
        • this.changeCategory(undefined)}>项目类别
        • { CategoryList && CategoryList.length > 0 ? CategoryList.map((item,key)=>{ return( @@ -397,6 +389,7 @@ class Index extends Component { className="list-r-Search" value={search} onChange={this.changeSearchValue} + allowClear />
    @@ -410,14 +403,14 @@ class Index extends Component { className="mr50" > - 新建 + 新建 } - 排序 + 排序
    diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index 090b9e51d..e2c3b2a41 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -63,7 +63,7 @@ class IndexItem extends Component { { item.forked_count && item.forked_count>0 ? - fork {item.forked_count} + fork {item.forked_count} :"" } diff --git a/src/forge/Main/projecthome/Index.jsx b/src/forge/Main/projecthome/Index.jsx index 3b56b455a..9df31cc26 100644 --- a/src/forge/Main/projecthome/Index.jsx +++ b/src/forge/Main/projecthome/Index.jsx @@ -29,8 +29,8 @@ function Index() { useEffect(()=>{ setIsSpin(true); getProject(); - },[cateID]) - + },[cateID, search]) + function getCate() { const url = `/project_categories/pinned_index.json`; axios.get(url).then(result=>{ @@ -40,14 +40,14 @@ function Index() { }).catch(error=>{}) } - function getProject(searchValue) { + function getProject() { const url = `/projects.json`; axios.get(url,{ params:{ pinned:"d", category_id:cateID, limit:LIMIT, - search:searchValue + search:search } }).then(result=>{ if(result && result.data){ @@ -57,15 +57,10 @@ function Index() { }).catch(error=>{}) } - function changeSearchValue(e){ - setSearch(e.target.value); + function searchFun(value){ + setSearch(value); } - function searchFun(value){ - setIsSpin(true); - getProject(value); - } - return(
    @@ -94,12 +89,10 @@ function Index() { size="middle" onSearch={searchFun} className="list-r-Search" - value={search} - onChange={changeSearchValue} style={{width:"300px"}} - allowClear={true} + allowClear /> - 更多 + 更多
    @@ -148,7 +141,7 @@ function Index() { { projectsList && projectsList.length > 0 &&
    - 查看更多开源项目 + 查看更多开源项目
    }
    diff --git a/src/forge/css/index.scss b/src/forge/css/index.scss index 07995d775..ddb307636 100644 --- a/src/forge/css/index.scss +++ b/src/forge/css/index.scss @@ -278,6 +278,7 @@ form{ line-height: 62px; border-bottom: 1px solid #E0E0E0; font-weight: 400; + cursor: pointer; } .ant-menu-inline{ border:none;