From 400ce3f8cd9d5b856f3a00e948a8f81fc45f5314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Fri, 9 Dec 2022 14:32:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=99=BB=E5=BD=95=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=89=BE=E5=9B=9E=E5=AF=86=E7=A0=81=E7=AD=896?= =?UTF-8?q?=E4=B8=AA=E7=BD=91=E9=A1=B5=E6=A0=87=E9=A2=98=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9Ewiki=E6=98=BE=E7=A4=BA=E6=96=87=E6=A1=88=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=8C=E4=BB=8E=E6=88=91=E5=85=B3=E6=B3=A8=E7=9A=84?= =?UTF-8?q?/=E5=85=B3=E6=B3=A8=E6=88=91=E7=9A=84=E8=B7=B3=E5=9B=9E?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E4=B9=8B=E5=90=8E=E6=97=A0?= =?UTF-8?q?tab=E5=AF=BC=E8=88=AA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 10 +++++----- src/forge/Wiki/EditWiki.jsx | 2 +- src/forge/users/Infos.js | 12 +++++++++-- src/forge/users/fan_users.js | 17 ++++++++++++++++ src/forge/users/watch_users.js | 20 ++++++++++++++++++- src/modules/loginRegister/Login.jsx | 10 +++++++++- .../loginRegister/LoginRegisterPage.jsx | 3 ++- src/modules/loginRegister/Register.jsx | 10 +++++++++- src/modules/loginRegister/ResetPassword.jsx | 10 +++++++++- src/modules/search/index.jsx | 9 ++++++++- 10 files changed, 89 insertions(+), 14 deletions(-) diff --git a/src/App.js b/src/App.js index 28b3f7861..7027c8516 100644 --- a/src/App.js +++ b/src/App.js @@ -290,7 +290,7 @@ class App extends Component { }; render() { - const { pathType, pathName } = this.state; + const { pathType, pathName, mygetHelmetapi } = this.state; return ( @@ -348,7 +348,7 @@ class App extends Component { {/* 查询 */} - + } + render={(props) =>} > {/* 注册 */} } + render={(props) =>} > {/* 忘记密码 */} } + render={(props) =>} > {/* 关于我们 */} diff --git a/src/forge/Wiki/EditWiki.jsx b/src/forge/Wiki/EditWiki.jsx index 3ba29ff41..cb786c3fa 100644 --- a/src/forge/Wiki/EditWiki.jsx +++ b/src/forge/Wiki/EditWiki.jsx @@ -184,7 +184,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail, return (
- Wiki 编辑页面 + Wiki {wikiName ? '编辑' : '新增'}页面
diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js index c0b1e4b40..a703597a1 100644 --- a/src/forge/users/Infos.js +++ b/src/forge/users/Infos.js @@ -83,8 +83,15 @@ class Infos extends Component { if(pathname === `/${username}`){ this.setState({route_type:undefined}); if(load){ + // 切换不同tab以及第一次渲染 this.setState({ - menuKey:load.show_super_description ? "6" :"0" + menuKey: load.show_super_description ? "6" : typeof(load) === 'object' ? '0' : load + }) + }else{ + // 从我关注的/关注我的返回 + const {user} = this.state; + user && this.setState({ + menuKey: user.show_super_description ? "6" : "0" }) } }else if(pathname === `/${username}/statistics`){ @@ -119,7 +126,8 @@ class Infos extends Component { const { pathname } = this.props.location; const prevPath = prevProps.location.pathname; if(prevPath && pathname && prevPath !== pathname){ - this.renderPath(pathname); + const {menuKey} = this.state; + this.renderPath(pathname, menuKey); } this.props.history.listen(()=>{ if (document.body.scrollTop || document.documentElement.scrollTop > 0) { diff --git a/src/forge/users/fan_users.js b/src/forge/users/fan_users.js index 327481762..e629498c2 100644 --- a/src/forge/users/fan_users.js +++ b/src/forge/users/fan_users.js @@ -1,6 +1,23 @@ import React, { Component } from "react"; import CommonLists from "./common_lists" class FanUsers extends Component { + componentDidMount=()=>{ + this.updateDocumentTitle(); + } + + componentDidUpdate(){ + this.updateDocumentTitle(); + } + + // 更新网页标题 + updateDocumentTitle(){ + const {user, current_user} = this.props; + if(user && current_user){ + const {username, login} = user; + const title_type =login === current_user.login ? "我" : "TA"; + document.title = `关注${title_type}的-${username}` + } + } render() { const {user, current_user , match, fetchUser} = this.props diff --git a/src/forge/users/watch_users.js b/src/forge/users/watch_users.js index cebc3e86c..d6d2bda98 100644 --- a/src/forge/users/watch_users.js +++ b/src/forge/users/watch_users.js @@ -1,8 +1,26 @@ import React, { Component } from "react"; import CommonLists from "./common_lists" class WatcherUsers extends Component { + componentDidMount=()=>{ + this.updateDocumentTitle(); + } + + componentDidUpdate(){ + this.updateDocumentTitle(); + } + + // 更新网页标题 + updateDocumentTitle(){ + const {user, current_user} = this.props; + if(user && current_user){ + const {username, login} = user; + const title_type =login === current_user.login ? "我" : "TA"; + document.title = `${title_type}的关注-${username}` + } + } + render() { - const {user, current_user , match, fetchUser } = this.props; + const {user, current_user , match, fetchUser} = this.props; return ( user && user.login && { + if(mygetHelmetapi){ + const {name} = mygetHelmetapi; + document.title = name; + } + }, [mygetHelmetapi]) + // 登录表单提交 function handleSubmit(){ setMessage(undefined); diff --git a/src/modules/loginRegister/LoginRegisterPage.jsx b/src/modules/loginRegister/LoginRegisterPage.jsx index 788bbf40c..1a5a4e2c5 100644 --- a/src/modules/loginRegister/LoginRegisterPage.jsx +++ b/src/modules/loginRegister/LoginRegisterPage.jsx @@ -10,6 +10,7 @@ import img2 from './img/img2.png'; import '../loginRegister/LoginRegisterPage.scss'; function LoginRegisterPage(props){ + const {mygetHelmetapi} = props; return(
@@ -18,7 +19,7 @@ function LoginRegisterPage(props){
- {props.location.pathname === "/login" ? : props.location.pathname === "/register" ? : } + {props.location.pathname === "/login" ? : props.location.pathname === "/register" ? : }
diff --git a/src/modules/loginRegister/Register.jsx b/src/modules/loginRegister/Register.jsx index 33b52a846..6083fe6f6 100644 --- a/src/modules/loginRegister/Register.jsx +++ b/src/modules/loginRegister/Register.jsx @@ -6,7 +6,7 @@ import { setmiyah } from 'educoder'; import './LoginRegisterPage.scss'; function Register(props){ - const {form} = props; + const {form, mygetHelmetapi} = props; const {getFieldDecorator, setFieldsValue } = form; //用户输入的符合规则的邮箱(用于获取验证码) const [emailStr, setEmailStr] = useState(undefined); @@ -27,6 +27,14 @@ function Register(props){ //页面加载完自动聚焦到第一个输入框 // const inputEl = useRef(null); + // 配置网页标题 + useEffect(()=>{ + if(mygetHelmetapi){ + const {name} = mygetHelmetapi; + document.title = name; + } + }, [mygetHelmetapi]) + //注册表单提交 function handleSubmit(){ form.validateFields((err, values) => { diff --git a/src/modules/loginRegister/ResetPassword.jsx b/src/modules/loginRegister/ResetPassword.jsx index 782d9482a..b460e3f8a 100644 --- a/src/modules/loginRegister/ResetPassword.jsx +++ b/src/modules/loginRegister/ResetPassword.jsx @@ -6,7 +6,7 @@ import { setmiyah } from 'educoder'; import './LoginRegisterPage.scss'; function ResetPassword(props) { - const {form } = props; + const {form, mygetHelmetapi } = props; const {getFieldDecorator } = form; const [emailStr, setEmailStr] = useState(undefined); const [secondsStr, setSecondsStr] = useState(60); @@ -21,6 +21,14 @@ function ResetPassword(props) { //页面加载完自动聚焦到第一个输入框 const inputEl = useRef(null); + // 配置网页标题 + useEffect(()=>{ + if(mygetHelmetapi){ + const {name} = mygetHelmetapi; + document.title = name; + } + }, [mygetHelmetapi]) + //重置密码表单提交 function handleSubmit() { form.validateFieldsAndScroll((err, values) => { diff --git a/src/modules/search/index.jsx b/src/modules/search/index.jsx index 89d72f4be..a2bd2ae80 100644 --- a/src/modules/search/index.jsx +++ b/src/modules/search/index.jsx @@ -10,7 +10,7 @@ import './index.scss'; const { Search } = Input; const { TabPane } = Tabs; -const GlobalSearch = ({ location, showNotification, history }) => { +const GlobalSearch = ({ location, showNotification, history, mygetHelmetapi }) => { const size = 10; let defaultValue = decodeURI(location.search.split("=")[1] || ""); @@ -34,6 +34,13 @@ const GlobalSearch = ({ location, showNotification, history }) => { const [ref, setRef] = useState(undefined); const [focus, setFocus] = useState(0); + // 配置网页标题 + useEffect(()=>{ + if(mygetHelmetapi){ + const {name} = mygetHelmetapi; + document.title = name; + } + }, [mygetHelmetapi]) useEffect(() => { searchDataList();