From a3dc1d6adf04ec1588c43effc6f85c820e7ea368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 14 Oct 2019 15:35:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/package.json | 1 - public/react/public/index.html | 5 +- public/react/public/index.test.html | 5 +- public/react/src/App.js | 25 +++++++--- public/react/src/modules/tpm/TPMIndexHOC.js | 55 ++++++++++++++++++--- 5 files changed, 74 insertions(+), 17 deletions(-) diff --git a/public/react/package.json b/public/react/package.json index d13714922..6a0cf6d09 100644 --- a/public/react/package.json +++ b/public/react/package.json @@ -68,7 +68,6 @@ "react-content-loader": "^3.1.1", "react-dev-utils": "^5.0.0", "react-dom": "^16.9.0", - "react-helmet": "^5.2.1", "react-hot-loader": "^4.0.0", "react-infinite-scroller": "^1.2.4", "react-loadable": "^5.3.1", diff --git a/public/react/public/index.html b/public/react/public/index.html index 321fbe0e5..bf8046e56 100755 --- a/public/react/public/index.html +++ b/public/react/public/index.html @@ -11,7 +11,7 @@ - + - EduCoder + + diff --git a/public/react/src/App.js b/public/react/src/App.js index ed52b9f14..bf9e98c79 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -275,7 +275,7 @@ class App extends Component { Addcoursestypes:false, mydisplay:false, occupation:0, - getapi:undefined, + getHelmetapi:undefined, } } @@ -358,22 +358,35 @@ class App extends Component { axios.get(url).then((response) => { if(response){ this.setState({ - getapi:response.data.setting - }) + getHelmetapi:response.data.setting + }); + document.title = response.data.setting.name; + var link = document.createElement('link'), + oldLink = document.getElementById('dynamic-favicon'); + link.id = 'dynamic-favicon'; + link.rel = 'shortcut icon'; + link.href = response.data.setting.nav_logo_url; + if (oldLink) { + document.head.removeChild(oldLink); + } + document.head.appendChild(link); } }).catch((error) => { }); - } + }; render() { - - + let{getHelmetapi}=this.state; + // console.log("appappapp"); + // console.log(getHelmetapi); return ( + + this.Modifyloginvalue()}> diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 25c359956..1646e2b87 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -7,8 +7,8 @@ import NewFooter from './NewFooter' import SiderBar from './SiderBar' import { getUrl, downloadFile } from 'educoder' import axios from 'axios'; -import { Spin } from 'antd' -import './TPMIndex.css' +import { Spin } from 'antd'; +import './TPMIndex.css'; import LoginDialog from '../login/LoginDialog'; import AccountProfile from '../user/AccountProfile'; @@ -83,7 +83,8 @@ export function TPMIndexHOC(WrappedComponent) { globalLoading: false, dataquerys:{}, - isloginCancel:undefined + isloginCancel:undefined, + mygetHelmetapi:undefined, } } @@ -147,6 +148,8 @@ export function TPMIndexHOC(WrappedComponent) { } componentDidMount() { + console.log("TPMIndexHOC========"); + console.log(this.props); window.addEventListener('keyup', this.keyupListener) if(this.props.match.path==="/"){ @@ -207,7 +210,7 @@ export function TPMIndexHOC(WrappedComponent) { } } }); - + this.getAppdata(); } /** 课堂权限相关方法,暂时写这里了 ----------------------------------------START @@ -277,7 +280,32 @@ export function TPMIndexHOC(WrappedComponent) { // // } + //获取当前定制信息 + getAppdata=()=>{ + let url = "/setting.json"; + axios.get(url).then((response) => { + if(response){ + this.setState({ + mygetHelmetapi:response.data.setting, + }); + // console.log("获取当前定制信息"); + // console.log(response.data.setting); + document.title = response.data.setting.name; + var link = document.createElement('link'), + oldLink = document.getElementById('dynamic-favicon'); + link.id = 'dynamic-favicon'; + link.rel = 'shortcut icon'; + link.href = response.data.setting.nav_logo_url; + if (oldLink) { + document.head.removeChild(oldLink); + } + document.head.appendChild(link); + } + + }).catch((error) => { + }); + }; /** 课堂权限相关方法,暂时写这里了 ----------------------------------------END */ @@ -534,6 +562,19 @@ export function TPMIndexHOC(WrappedComponent) { hideGlobalLoading = () => { this.setState({ globalLoading: false }) } + getAppdata=()=>{ + let url = "/setting.json"; + axios.get(url).then((response) => { + if(response){ + this.setState({ + getHelmetapi:response.data.setting + }) + } + + }).catch((error) => { + + }); + }; render() { let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state; const common = { @@ -569,10 +610,12 @@ export function TPMIndexHOC(WrappedComponent) { yslslowCheckresults:this.yslslowCheckresults, yslslowCheckresultsNo:this.yslslowCheckresultsNo, - } + }; + // console.log("this.props.getHelmetapi"); + // console.log(this.props.getHelmetapi); return (
- {isRender===true ? this.hideLoginDialog()} {...this.props} {...this.state}