修改路由相关issue及顺带测出的问题

This commit is contained in:
何童崇 2021-09-03 13:48:56 +08:00
parent a5bdf26f96
commit ebd94ed3a1
10 changed files with 25 additions and 28 deletions

View File

@ -25,7 +25,7 @@ if (isDev) {
}
debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' :
window.location.search.indexOf('debug=s') !== -1 ? 'student' :
window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student'
window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin'
}
window._debugType = debugType;
export function initAxiosInterceptors(props) {

View File

@ -12,11 +12,7 @@ import Loadable from "react-loadable";
import Loading from "../Loading";
import { ImageLayerOfCommentHOC } from "../modules/page/layers/ImageLayerOfCommentHOC";
//404页面
const Shixunnopage = Loadable({
loader: () => import('../modules/404/Shixunnopage'),
loading: Loading,
})
const ProjectNew = Loadable({
loader: () => import("./New/Index"),
loading: Loading,

View File

@ -512,7 +512,7 @@ class Detail extends Component {
{
watchers_count > 0 ?
platform ?
<Link className="detail_tag_btn_count" style={{ color: `${watched ? "#2878FF" : "#666"}` }} to={platform ? { pathname: `/${owner}/${projectsId}/watchers`, state } : ""}>
<Link className="detail_tag_btn_count" style={{ color: `${watched ? "#2878FF" : "#666"}` }} to={platform ? { pathname: `/${owner}/${projectsId}/following`, state } : ""}>
{watchers_count}
</Link>
:
@ -729,7 +729,7 @@ class Detail extends Component {
(props) => (<MergeIndexDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/:owner/:projectsId/watchers"
<Route path="/:owner/:projectsId/following"
render={
(props) => (<WatchUsers {...this.props} {...props} {...this.state} {...common} />)
}

View File

@ -72,7 +72,7 @@ function UndoEvent(props){
<Link to={`/${i.user && i.user.login}`}><img src={getImageUrl(`/${i.user && i.user.image_url}`)} alt="" className="notifyImg"/></Link>
<div className="notifyFlex">
<p className="notifyInfos">
<Link to={`/${i.login}`} className="font-15 mr20">{i.user && i.user.name}</Link>
<Link to={`/${i.user && i.user.login}`} className="font-15 mr20">{i.user && i.user.name}</Link>
<span className="color-grey-9">{i.time_ago}</span>
</p>
<FlexAJ>

View File

@ -11,7 +11,7 @@ function Activity({list}) {
list.map((i,k)=>{
return(
<li>
<Link to={`/${i.user_login}`}><img src={getImageUrl(`/system/lets/letter_avatars/2/D/169_162_140/120.png`)} alt="" className="aImg"/></Link>
<Link to={`/${i.user_login}`}><img src={getImageUrl(`${i.user_avatar}`)} alt="" className="aImg"/></Link>
<div className="aInfos">
<AlignCenter>
<Link to={`/${i.user_login}`} className="name">{i.user_name}</Link>

View File

@ -24,7 +24,7 @@ export default withRouter(
secondRouter = props.location.pathname.split('/')[2];
}
let userRouterArr = ['statistics', 'projects', 'notice', 'devops', 'organizes', 'info', 'watchers', 'fan_users', 'password'];
let userRouterArr = ['statistics', 'projects', 'notice', 'devops', 'organizes', 'info', 'following', 'followers', 'password'];
return (
<Switch>

View File

@ -84,10 +84,10 @@ class Infos extends Component {
this.setState({menuKey:"4",route_type:undefined});
}else if(pathname === `/${username}/organizes`){
this.setState({menuKey:"5",route_type:undefined});
}else if(pathname === `/${username}/watchers`){
this.setState({menuKey:undefined,route_type:"watchers"});
}else if(pathname === `/${username}/fan_users`){
this.setState({menuKey:undefined,route_type:"fan_users"});
}else if(pathname === `/${username}/following`){
this.setState({menuKey:undefined,route_type:"following"});
}else if(pathname === `/${username}/followers`){
this.setState({menuKey:undefined,route_type:"followers"});
}else{
this.setState({menuKey:undefined,route_type:undefined});
}
@ -249,17 +249,17 @@ class Infos extends Component {
</div>
<div className="focusBox">
<Link
to={`/${user && user.login}/watchers`}
className={`with50 text-center pull-left ${route_type === "watchers" ? "text-primary" : ""}`}
onClick={() =>this.route_link("watchers")}
to={`/${user && user.login}/following`}
className={`with50 text-center pull-left ${route_type === "following" ? "text-primary" : ""}`}
onClick={() =>this.route_link("following")}
>
<div>{current_user && user && user.login === current_user.login ? "我关注的" : "TA关注的"}</div>
<span>{user && user.watching_count}</span>
</Link>
<Link
to={`/${user && user.login}/fan_users`}
onClick={() =>this.route_link("fan_users")}
className={`with50 text-center pull-left ${route_type === "fan_users" ? "text-primary" : ""}`}
to={`/${user && user.login}/followers`}
onClick={() =>this.route_link("followers")}
className={`with50 text-center pull-left ${route_type === "followers" ? "text-primary" : ""}`}
>
<div>{current_user && user && user.login === current_user.login ? "关注我的" : "关注TA的"}</div>
<span>{user && user.watched_count}</span>
@ -308,7 +308,7 @@ class Infos extends Component {
{user && (
<Switch {...this.props}>
<Route
path="/:username/watchers"
path="/:username/following"
render={() => {
return <WatchsUser {...this.props} {...this.state} userType="watchers" fetchUser={this.fetchUser}/>;
}}
@ -320,7 +320,7 @@ class Infos extends Component {
}}
></Route>
<Route
path="/:username/fan_users"
path="/:username/followers"
render={() => {
return <FanUser {...this.props} {...this.state} userType="fan_users" fetchUser={this.fetchUser}/>;
}}

View File

@ -22,8 +22,8 @@ class CommonList extends Component {
};
get_watchers = () => {
const { login, userType } = this.props;
const url = `/users/${login}/${userType}.json`;
const { userType, match: { params: { username } } } = this.props;
const url = `/users/${username}/${userType}.json`;
const { page, limit, search } = this.state;
this.setState({
isSpin: true,

View File

@ -3,10 +3,10 @@ import CommonLists from "./common_lists"
class FanUsers extends Component {
render() {
const {user, current_user , fetchUser} = this.props
const {user, current_user , match, fetchUser} = this.props
return (
<div>
{user && user.login && <CommonLists userType="fan_users" login={user.login} current_user={current_user} fetchUser={fetchUser}/>}
{user && user.login && <CommonLists userType="fan_users" login={user.login} current_user={current_user} match={match} fetchUser={fetchUser}/>}
</div>
);
}

View File

@ -2,7 +2,7 @@ import React, { Component } from "react";
import CommonLists from "./common_lists"
class WatcherUsers extends Component {
render() {
const {user, current_user , fetchUser } = this.props;
const {user, current_user , match, fetchUser } = this.props;
return (
user && user.login &&
<CommonLists
@ -10,6 +10,7 @@ class WatcherUsers extends Component {
login={user.login}
current_user={current_user}
fetchUser={fetchUser}
match={match}
/>
);
}