diff --git a/src/App.js b/src/App.js index f5c3fce4b..26fb64694 100644 --- a/src/App.js +++ b/src/App.js @@ -150,6 +150,11 @@ const Badge = Loadable({ // loading: Loading, // }) +const Topic = Loadable({ + loader: () => import('./forge/topic'), + loading: Loading, +}) + // 此处仅维护前端可能的一级路由,不用进行项目或者组织判断的字段。 const keyWord = ["explore", "settings", "setting", "mulan", "wiki", "issues", "setting", "trending", "code", "projects", "pulls", "mine", "login", "register", "email", "export", "nopage", "404", "403", "500", "501", "search", "organize", "login", "register", "resetPassword", "aboutus","educoder", "glcc","bindlogin", "softbot"]; @@ -390,6 +395,9 @@ class App extends Component { {/* 查询 */} + {/* 项目标签列表页 */} + + ( diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index b0bb7fcba..6871a5f94 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -592,7 +592,7 @@ function CoderDepot(props){ {desc &&

{desc}

} {/* 项目标签 */} {topics &&
- {topics.map(item=>{item.name})} + {topics.map(item=>{item.name})}
} { website && diff --git a/src/forge/Main/IndexItem.js b/src/forge/Main/IndexItem.js index efd3fc3b6..a591ed0d8 100644 --- a/src/forge/Main/IndexItem.js +++ b/src/forge/Main/IndexItem.js @@ -71,7 +71,7 @@ class IndexItem extends Component {

{item.description}

{/* 项目标签 */} {item.topics &&
- {item.topics.map(topic=>{topic.name})} + {item.topics.map(topic=>{topic.name})}
}
diff --git a/src/forge/Main/projecthome/Index.jsx b/src/forge/Main/projecthome/Index.jsx index 719e21a5c..5ea66b1e7 100644 --- a/src/forge/Main/projecthome/Index.jsx +++ b/src/forge/Main/projecthome/Index.jsx @@ -123,7 +123,7 @@ function Index() {
{/* 项目标签 */} {i.topics &&
- {i.topics.map(item=>{item.name})} + {i.topics.map(item=>{item.name})}
}
{i.category && i.category.id ? {i.category.name} :"" } diff --git a/src/forge/topic/index.jsx b/src/forge/topic/index.jsx new file mode 100644 index 000000000..792853fd8 --- /dev/null +++ b/src/forge/topic/index.jsx @@ -0,0 +1,126 @@ +import React, { useState } from 'react'; +import { withRouter } from "react-router"; +import { SnackbarHOC } from "educoder"; +import { CNotificationHOC } from "../../modules/courses/common/CNotificationHOC"; +import { TPMIndexHOC } from "../../modules/tpm/TPMIndexHOC"; +import './index.scss'; +import { useEffect } from 'react'; +import { Pagination, Select } from 'antd'; +import axios from 'axios'; +import { Link } from 'react-router-dom'; +import { getImageUrl } from 'educoder'; +import Nodata from '../Nodata'; +const Option = Select.Option; + +export default withRouter((CNotificationHOC()(SnackbarHOC()(TPMIndexHOC((props) => { + console.log('props', props); + const {match:{params:{name, id}}, current_user:{user_id}} = props; + const [languageList, setLanguageList] = useState(undefined); + const [languageId, setLanguageId] = useState(undefined); + const [sort, setSort] = useState("praises_count"); + const [page, setPage] = useState(1); + const [limit, setLimit] = useState(15); + const [projectsList, setProjectsList] = useState(undefined); + const [total, setTotal] = useState(undefined); + + useEffect(()=>{ + // 设置网页标题 + name && (document.title = `项目标签-${decodeURIComponent(name)}`); + // 获取语言列表 + axios.get(`/project_languages.json`).then(result=>{ + result && setLanguageList(result.data.project_languages) + }) + }, []) + + useEffect(()=>{ + axios.get(`/projects.json`, { + params: { + user_id: user_id, + page, + limit, + sort_by: sort, + language_id:languageId? languageId : undefined, + topic_id:id + } + }).then((result) => { + if (result) { + console.log('result', result); + setProjectsList(result.data.projects); + setTotal(result.data.total_count); + } + }).catch((error) => { + console.log('error', error); + }) + }, [sort, page, languageId]) + + return ( +
+

#{decodeURIComponent(name)}

+
+ 平台共6个项目与此标签相匹配 +
+ + +
+
+ {/* 无数据 */} + {projectsList && projectsList.length === 0 && } + {/* 项目列表 */} + {projectsList && projectsList.length>0 && projectsList.map(i=>{ + return
+ {/* 仓库拥有者头像 */} + +
+
+ {/* 仓库拥有者名称 */} + {i.author && i.author.name}/{i.name} + {/* 点赞数 */} + {i.praises_count > 0 ? {i.praises_count} :"" } + {/* fork数 */} + {i.forked_count > 0 ? {i.forked_count}:""} +
+ {/* 仓库描述 */} +
{i.description}
+ {/* 项目标签 */} + {i.topics &&
+ {i.topics.map(item=>{item.name})} +
} +
+ {/* 仓库类别 */} + {i.category && i.category.id ? {i.category.name} :"" } + {/* 仓库语言 */} + {i.language && i.language.id ? {i.language.name} :""} + {/* 更新时间 */} + 更新于{i.time_ago} +
+
+
+ })} + {/* 分页 */} + {total > limit && limit} + onChange={(page) => { setPage(page) }} + current={page} + total={total} + showTotal={total => `共 ${total} 条`} + />} +
+ )} +))))) \ No newline at end of file diff --git a/src/forge/topic/index.scss b/src/forge/topic/index.scss new file mode 100644 index 000000000..6e7977e83 --- /dev/null +++ b/src/forge/topic/index.scss @@ -0,0 +1,95 @@ +.topicRepoList{ + width: 900px; + margin: 0 auto; + .flexBoxTopic{ + display: flex; + align-items: center; + justify-content: space-between; + } + &>h2{ + font-weight: 700; + } + .topicRepoHead{ + color:#5f6872; + padding: 10px 15px; + border-bottom:1px solid rgba(153, 153, 153, 0.16); + } + .repoImg{ + width:32px; + height: 32px; + object-fit: cover; + border-radius: 50%; + } + .repoTopic{ + align-items: flex-start; + border-bottom:1px solid rgba(153, 153, 153, 0.1); + justify-content: flex-start; + padding: 20px 0 15px; + .rightInfo{ + flex: 1; + } + .repoTitle{ + flex: 1; + } + } + .descTopic{ + color:#414141; + line-height: 24px; + } + .proListTopics{ + display: flex; + flex-wrap: wrap; + .proListTopic{ + background-color:#f3f8ff; + border-radius: 4px; + max-width: 158px; + padding: 0 10px; + height: 24px; + line-height: 24px; + color: #4c5b76; + margin-bottom: 5px !important; + } + } + .info3{ + justify-content: flex-start; + color: #7D7D7D; + height: 20px; + line-height: 20px; + display: flex; + align-items: center; + .category{ + position: relative; + padding-left: 11px; + margin-right: 10px; + &::before{ + position: absolute; + content: ""; + width: 6px; + height: 6px; + border-radius: 50%; + background-color: #466AFF; + top: 7px; + left: 0px; + } + } + .language{ + position: relative; + &.hasCate{ + padding-left: 11px; + } + &.hasCate::before{ + position: absolute; + content: ""; + width: 1px; + height: 10px; + border-radius: 50%; + border-left: 1px solid #9e9e9e; + bottom: 5px; + left: 0px; + } + } + } + .pagTopic{ + text-align: center; + } +} \ No newline at end of file diff --git a/src/forge/users/GeneralView/ConcentrateProject.jsx b/src/forge/users/GeneralView/ConcentrateProject.jsx index 2dde1cca0..9fe436ead 100644 --- a/src/forge/users/GeneralView/ConcentrateProject.jsx +++ b/src/forge/users/GeneralView/ConcentrateProject.jsx @@ -72,7 +72,7 @@ function ConcentrateProject({userLogin,current,showCompeleteDialog,completeProfi

{i.description}

{/* 项目标签 */} {i.topics &&
- {i.topics.map(item=>{item.name})} + {i.topics.map(item=>{item.name})}
} { i.category && {i.category.name} }