diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 0966e3bf4..213d68752 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -117,6 +117,18 @@ const MilepostDetail = Loadable({ loader: () => import('../Order/MilepostDetail'), loading: Loading, }) +const WatchUsers = Loadable({ + loader: () => import('../UsersList/watch_users'), + loading: Loading, +}) +const PraiseUsers = Loadable({ + loader: () => import('../UsersList/praise_users'), + loading: Loading, +}) +const ForkUsers = Loadable({ + loader: () => import('../UsersList/fork_users'), + loading: Loading, +}) const TrendsIndex = Loadable({ @@ -200,9 +212,14 @@ class Detail extends Component{ // 关注和取消关注 focusFunc =(flag)=>{ const { project_id } = this.state; + axios({ method: flag? 'delete' : 'post', - url: `/projects/${project_id}/watchers/${flag? 'unfollow' : 'follow'}.json` + url: `/watchers/${flag? 'unfollow' : 'follow'}.json`, + params: { + target_type: "project", + id: project_id + } }) .then(result => { if(result && result.data.status === 0){ @@ -363,19 +380,28 @@ class Detail extends Component{ {watched ? '取消关注':'关注'} - {watchers_count} + + {watchers_count} + + {/* {watchers_count} */} this.pariseFunc(praised)}> {praised ? '取消点赞':'点赞'} - {praises_count} + + {praises_count} + + {/* {praises_count} */} Fork - {forked_count} + + {forked_count} + + {/* {forked_count} */} @@ -539,6 +565,21 @@ class Detail extends Component{ (props) => () } > + () + } + > + () + } + > + () + } + > () diff --git a/src/forge/Main/list.css b/src/forge/Main/list.css index bb44a62c4..aec778499 100644 --- a/src/forge/Main/list.css +++ b/src/forge/Main/list.css @@ -308,10 +308,14 @@ } .detail_tag_btn_count{ padding:0px 10px; - color: #fff; + color: #fff !important; background: #1C91FF; border-radius: 0px 4px 4px 0px; } +.detail_tag_btn_count:hover{ + color: #1C91FF !important; + background: #fff; +} /* 详情-代码 */ .branch-wrapper{ border:1px solid #eee; diff --git a/src/forge/UsersList/common_users.js b/src/forge/UsersList/common_users.js new file mode 100644 index 000000000..8c5079787 --- /dev/null +++ b/src/forge/UsersList/common_users.js @@ -0,0 +1,147 @@ +import React, { Component } from "react"; +import { Link } from "react-router-dom"; +import axios from "axios"; +import { getImageUrl } from "educoder"; +import { Spin, Pagination } from "antd"; +import "./list.css"; +import NoneData from "../Nodata"; +import FocusButton from "./focus_button"; +class CommonUsers extends Component { + constructor(props) { + super(props); + this.state = { + user_type: this.props.user_type, + type_title: this.props.type_title, + project_id: this.props.project_id, + users: null, + count: 0, + limit: 20, + page: 1, + isSpin: false, + }; + } + + componentDidMount = () => { + this.getUsersList(); + }; + + getUsersList = (page, limit) => { + this.setState({ + isSpin: true, + }); + const { user_type, project_id } = this.state; + + const url = `/projects/${project_id}/${user_type}.json`; + axios + .get(url, { + params: { + page, + limit, + }, + }) + .then((result) => { + if (result) { + this.setState({ + count: result.data.count, + users: result.data.users, + isSpin: false, + }); + } + }) + .catch((error) => { + console.log(error); + }); + }; + + // 翻页 + ChangePage = (page) => { + this.setState({ + page, + isSpin: true, + }); + const { limit } = this.state; + this.getUsersList(page, limit); + }; + + render() { + const { users, count, page, limit, isSpin, type_title } = this.state; + const Paginations = ( + + {count > limit ? ( +
+ +
+ ) : ( + "" + )} +
+ ); + + const renderList = () => { + if (users && users.length > 0) { + return users.map((item, key) => { + return ( +
+
+
+ + + +
+
+
+ + {item.name} + +
+
+ + 加入时间:{item.format_time} +
+ +
+
+
+ ); + }); + } + }; + return ( +
+
+
+
{type_title}
+ +
+ {count === 0 ? ( + + ) : ( + renderList() + )} +
+
+ {Paginations} +
+
+
+ ); + } +} + +export default CommonUsers; diff --git a/src/forge/UsersList/focus_button.js b/src/forge/UsersList/focus_button.js new file mode 100644 index 000000000..9ea17173c --- /dev/null +++ b/src/forge/UsersList/focus_button.js @@ -0,0 +1,73 @@ +import React, { Component } from "react"; +import axios from "axios"; +import { Spin, Button } from "antd"; +import "./list.css"; + +class FocusButton extends Component { + constructor(props) { + super(props); + this.state = { + is_watch: false, + id: "", + isSpin: false, + }; + } + + componentDidMount = () => { + this.set_watch(); + }; + + set_watch = () => { + this.setState({ + is_watch: this.props.is_watch, + id: this.props.id, + isSpin: false, + }); + }; + + // 关注和取消关注 + focusFunc = (flag) => { + const { id } = this.state; + this.setState({ isSpin: true }); + axios({ + method: flag ? "delete" : "post", + url: `/watchers/${flag ? "unfollow" : "follow"}.json`, + params: { + target_type: "user", + id: id, + }, + }) + .then((result) => { + if (result && result.data.status === 0) { + this.setState({ + is_watch: result.data.watched, + isSpin: false, + }); + } + }) + .catch((error) => { + console.log(error); + }); + }; + + render() { + const { is_watch, isSpin } = this.state; + return ( + + ); + } +} + +export default FocusButton; diff --git a/src/forge/UsersList/fork_users.js b/src/forge/UsersList/fork_users.js new file mode 100644 index 000000000..00a5726e3 --- /dev/null +++ b/src/forge/UsersList/fork_users.js @@ -0,0 +1,144 @@ +import React, { Component } from "react"; +import { Link } from "react-router-dom"; +import axios from "axios"; +import { getImageUrl } from "educoder"; +import { Spin, Pagination } from "antd"; +import "./list.css"; +import NoneData from "../Nodata"; +// import FocusButton from "./focus_button"; +class ForkUsers extends Component { + constructor(props) { + super(props); + this.state = { + users: null, + count: 0, + limit: 20, + page: 1, + isSpin: false, + }; + } + + componentDidMount = () => { + this.getUsersList(); + }; + + getUsersList = (page, limit) => { + this.setState({ + isSpin: true, + }); + const { projectsId } = this.props.match.params; + + const url = `/projects/${projectsId}/fork_users.json`; + axios + .get(url, { + params: { + page, + limit, + }, + }) + .then((result) => { + if (result) { + this.setState({ + count: result.data.count, + users: result.data.users, + isSpin: false, + }); + } + }) + .catch((error) => { + console.log(error); + }); + }; + + // 翻页 + ChangePage = (page) => { + this.setState({ + page, + isSpin: true, + }); + const { limit } = this.state; + this.getUsersList(page, limit); + }; + + render() { + const { users, count, page, limit, isSpin } = this.state; + const Paginations = ( + + {count > limit ? ( +
+ +
+ ) : ( + "" + )} +
+ ); + + const renderList = () => { + if (users && users.length > 0) { + return users.map((item, key) => { + return ( +
+
+
+ + + +
+
+
+ + {item.name} + +
+
+ + fork时间:{item.format_time} +
+ {/* */} +
+
+
+ ); + }); + } + }; + return ( +
+
+
+
Fork列表
+ +
+ {count === 0 ? ( + + ) : ( + renderList() + )} +
+
+ {Paginations} +
+
+
+ ); + } +} + +export default ForkUsers; diff --git a/src/forge/UsersList/list.css b/src/forge/UsersList/list.css new file mode 100644 index 000000000..8f85157dc --- /dev/null +++ b/src/forge/UsersList/list.css @@ -0,0 +1,100 @@ +.background-f { + background: #fff; +} +.background-g { + background: rgb(234, 235, 236); +} +.pt-15 { + padding-top: 15px; +} +.mr-4{margin-right: 4px;} +.pb-10 { + padding-bottom: 10px; +} +.plr-20 { + padding: 0 20px; +} +.font-18 { + font-size: 18px; + font-weight: 600; +} +.font-12 { + font-size: 12px; +} +.font-15 { + font-size: 15px; +} +.border-b-line { + border-bottom: 1px solid #eee; +} +.list-item { + width: 100%; +} +.w-100 { + width: 100%; +} +.w-25 { + width: 25%; +} +.p-10 { + padding: 10px; +} +.pd-105 { + padding: 15px 10px; +} +.grid-item { + display: grid !important; + align-items: center; + grid-template-columns: max-content 1fr; +} +.avatar-60 { + height: 60px; + width: 60px; + border-radius: 50%; +} +.text-primary { + color: #5091ff !important; +} +.text-primary:hover { + color: #2878ff !important; +} +.text-yellow{ + color: #FFA802 !important +} +.text-gray { + color: #888888; +} +.ml12 { + margin-left: 12px; +} +.user-join-time { + font-size: 14px !important; + color: #60b25e; +} +.btn-cir-grey { + background: rgba(250, 250, 250, 1); + color: #888888; + font-weight: normal; + border: 1px solid rgba(238, 238, 238, 1); + border-radius: 2px; + cursor: pointer; +} +.wd-75 { + width: 75px; +} +.pbt15 { + padding: 15px 0; +} +.pbt25 { + padding: 25px 0; +} +.mlr10 { + margin: 0 15px; +} +.user-list-items { + height: 100%; + width: 100%; + display: inline-block; +} +.max-w-200{max-width: 200px;} +.inline-block{display: inline-block;} diff --git a/src/forge/UsersList/praise_users.js b/src/forge/UsersList/praise_users.js new file mode 100644 index 000000000..22c9a8071 --- /dev/null +++ b/src/forge/UsersList/praise_users.js @@ -0,0 +1,32 @@ +import React, { Component } from "react"; +import CommonUsers from "./common_users" +class PraiseUsers extends Component { + constructor(props) { + super(props); + this.state = { + projectId: null + }; + } + + componentDidMount = () => { + this.get_projectId(); + }; + + get_projectId = () => { + this.setState({ + projectId: this.props.match.params.projectsId + }) + }; + + render() { + const { projectId } = this.state; + return ( +
+ {projectId && } +
+ + ); + } +} + +export default PraiseUsers; diff --git a/src/forge/UsersList/watch_users.js b/src/forge/UsersList/watch_users.js new file mode 100644 index 000000000..6c477ddb6 --- /dev/null +++ b/src/forge/UsersList/watch_users.js @@ -0,0 +1,32 @@ +import React, { Component } from "react"; +import CommonUsers from "./common_users" +class WatchUsers extends Component { + constructor(props) { + super(props); + this.state = { + projectId: null + }; + } + + componentDidMount = () => { + this.get_projectId(); + }; + + get_projectId = () => { + this.setState({ + projectId: this.props.match.params.projectsId + }) + }; + + render() { + const { projectId } = this.state; + return ( +
+ {projectId && } +
+ + ); + } +} + +export default WatchUsers; diff --git a/src/modules/tpm/NewHeader.js b/src/modules/tpm/NewHeader.js index c132384df..4c2f499d8 100644 --- a/src/modules/tpm/NewHeader.js +++ b/src/modules/tpm/NewHeader.js @@ -921,6 +921,9 @@ class NewHeader extends Component {