From c8c35d3e233bbcb88857237f32d00487ea5ef0cb Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 13 Sep 2024 15:21:54 +0800 Subject: [PATCH] =?UTF-8?q?fork=E4=BB=93=E5=BA=93=E6=B2=A1=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E3=80=81=E5=88=A0=E9=99=A4=E4=BB=93=E5=BA=93=E4=B8=8D?= =?UTF-8?q?=E7=94=A8=E5=88=B7=E6=96=B0=E8=A6=81=E6=8F=90=E7=A4=BA=E3=80=81?= =?UTF-8?q?=E4=B8=93=E5=8C=BA=E6=96=B0=E9=97=BB=E8=B5=84=E8=AE=AF=E8=B7=AF?= =?UTF-8?q?=E7=94=B1undefined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 3 --- src/forge/Dataset/Index.jsx | 2 +- src/forge/Information/Pages/main.jsx | 2 +- src/forge/Information/Pages/newsList.jsx | 1 - src/forge/Information/fetch.js | 2 +- src/forge/Main/Detail.js | 27 +++++++++++++++++++----- src/forge/users/Index.jsx | 1 - 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/App.js b/src/App.js index 43d0c1424..13a1f85fa 100644 --- a/src/App.js +++ b/src/App.js @@ -170,7 +170,6 @@ const keyWord = ["explore", "settings", "setting", "mulan", "wiki", "issues", "s class App extends Component { constructor(props) { super(props); - console.log("base:",props.projectBase && props.projectBase.author && props.projectBase.author.type); this.state = { Addcoursestype: false, Addcoursestypes: false, @@ -219,7 +218,6 @@ class App extends Component { let url = `/owners/${pathname}.json`; axios.get(url).then((response) => { if (response && response.status === 200) { - console.log("data:",response.data.type); this.setState({ pathType: response.data.type || '404', pathName: pathname, @@ -337,7 +335,6 @@ class App extends Component { render() { const { pathType, pathName, mygetHelmetapi } = this.state; - console.log("pathType:",pathType); return ( diff --git a/src/forge/Dataset/Index.jsx b/src/forge/Dataset/Index.jsx index 070bb57cb..53b667a25 100644 --- a/src/forge/Dataset/Index.jsx +++ b/src/forge/Dataset/Index.jsx @@ -75,7 +75,7 @@ function Index(props){ key:3, width:"10%", render:(value,item)=>{ - return + return } }, { diff --git a/src/forge/Information/Pages/main.jsx b/src/forge/Information/Pages/main.jsx index 60d3fd758..ff5659fcd 100644 --- a/src/forge/Information/Pages/main.jsx +++ b/src/forge/Information/Pages/main.jsx @@ -85,7 +85,7 @@ function Main(props){ setMainList(rows); // 隐藏判断原因:首页查看全部跳转过来后要默认选择指定的cateID而不是第一个 // if (temp !== tempEnum.zone) { - selectCate(cateId) + selectCate(cateId || (rows[0] && rows[0].id)) // } setIsSpin(false); } diff --git a/src/forge/Information/Pages/newsList.jsx b/src/forge/Information/Pages/newsList.jsx index 67a84e154..47278e649 100644 --- a/src/forge/Information/Pages/newsList.jsx +++ b/src/forge/Information/Pages/newsList.jsx @@ -25,7 +25,6 @@ function NewsList(props){ const [ menuSpin , setMenuSpin ] = useState(true); const { id, temp } = props; - useEffect(()=>{ if(id && cateId ){ setMenuSpin(true); diff --git a/src/forge/Information/fetch.js b/src/forge/Information/fetch.js index af0dc1afd..905da4472 100644 --- a/src/forge/Information/fetch.js +++ b/src/forge/Information/fetch.js @@ -6,7 +6,7 @@ function beforeFetch(actionUrl){ axios.defaults.withCredentials = true; } const config = { - // headers:{Authorization:"Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjo0NCwidXNlcl9rZXkiOiI3NWY3MmJmYmE2NGU4N2U3NWVjNWMwZDk2OThkMDFiN2EyODE0YjYwIiwidXNlcm5hbWUiOiJpbm5vdiJ9.IviAyZQjPFc4rT3ejAKfJYx3_QgS78RCKHx1XS-A4uI_mrc7_l6wK76HVIoPCEvP0Qimzyc6dpeVW4cE2fILZw"}, + headers:{Authorization:"Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjo0NCwidXNlcl9rZXkiOiI3NWY3MmJmYmE2NGU4N2U3NWVjNWMwZDk2OThkMDFiN2EyODE0YjYwIiwidXNlcm5hbWUiOiJpbm5vdiJ9.IviAyZQjPFc4rT3ejAKfJYx3_QgS78RCKHx1XS-A4uI_mrc7_l6wK76HVIoPCEvP0Qimzyc6dpeVW4cE2fILZw"}, baseURL: actionUrl, timeout: 1800000, // 请求超时时间 } diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 250451864..24f81bbbd 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -227,6 +227,24 @@ class Detail extends Component { } } + + componentDidUpdate = async (prevState) => { + let prevParam = prevState.match.params; + let propsParam = this.props.match.params; + if (prevState && this.props && (prevParam.projectsId !== propsParam.projectsId || prevParam.owner !== propsParam.owner)) { + const { projectsId, owner } = this.props.match.params; + const data = await getProjectFunc(owner, projectsId); + if (data.data) { + this.getProject(data.data) + } + } + + this.props.history.listen((history) => { + // 非issue链接地址清除cookie states,具体保存和操作在order.js页面 + this.clearIssueCookies(history); + }) + } + clearIssueCookies = (history) => { const { pathname } = history; const { projectsId, owner } = this.props.match.params; @@ -237,9 +255,7 @@ class Detail extends Component { } } async componentWillMount() { - const { projectsId, owner } = this.props.match.params; - console.log(this.props); if (!this.props.projectBase) { const data = await getProjectFunc(owner, projectsId); if (data && data.data) { @@ -517,12 +533,13 @@ class Detail extends Component { const url = `/${owner}/${projectsId}/forks.json`; axios.post(url).then(result => { if (result && result.data.status === 0) { - if (result.data.message === "fork失败,你已拥有了这个项目") { - this.props.history.push(`/${current_user && current_user.login}/${projectsId}`); + this.props.showNotification(result.data.message); + if (result.data.message && result.data.message.indexOf("fork失败")>-1) { + // this.props.history.push(`/${current_user && current_user.login}/${projectsId}`); return; } this.props.history.push(`/${current_user && current_user.login}/${result.data.identifier}`); - this.props.showNotification(result.data.message); + this.props.showNpsModal("indexProject", 3); } this.setState({ diff --git a/src/forge/users/Index.jsx b/src/forge/users/Index.jsx index d0631a393..9ad571647 100644 --- a/src/forge/users/Index.jsx +++ b/src/forge/users/Index.jsx @@ -21,7 +21,6 @@ const Infos = Loadable({ class DetailTop extends Component { constructor(props) { super(props); - console.log("userinfos:",props); this.state = {} } render() {