From 8dc47a215785dd0428b35c0e1e61dc14c20f3530 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:45:03 +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/src/App.js                     | 46 +++++++++++++++++---
 public/react/src/modules/tpm/TPMIndexHOC.js | 48 +++++++++++++++++----
 2 files changed, 80 insertions(+), 14 deletions(-)

diff --git a/public/react/src/App.js b/public/react/src/App.js
index bf9e98c79..8a1986cc8 100644
--- a/public/react/src/App.js
+++ b/public/react/src/App.js
@@ -357,15 +357,40 @@ class App extends Component {
 		let url = "/setting.json";
 		axios.get(url).then((response) => {
 			if(response){
-				this.setState({
-					getHelmetapi:response.data.setting
-				});
-				document.title = response.data.setting.name;
+				if(response.data){
+					this.setState({
+						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);
+				}else {
+					document.title = "EduCoder";
+					var link = document.createElement('link'),
+						oldLink = document.getElementById('dynamic-favicon');
+					link.id = 'dynamic-favicon';
+					link.rel = 'shortcut icon';
+					link.href = "/react/build/./favicon.ico";
+					if (oldLink) {
+						document.head.removeChild(oldLink);
+					}
+					document.head.appendChild(link);
+				}
+
+			}else{
+				document.title = "EduCoder";
 				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;
+				link.href = "/react/build/./favicon.ico";
 				if (oldLink) {
 					document.head.removeChild(oldLink);
 				}
@@ -373,7 +398,16 @@ class App extends Component {
 			}
 
 		}).catch((error) => {
-
+			document.title = "EduCoder";
+			var link = document.createElement('link'),
+				oldLink = document.getElementById('dynamic-favicon');
+			link.id = 'dynamic-favicon';
+			link.rel = 'shortcut icon';
+			link.href = "/react/build/./favicon.ico";
+			if (oldLink) {
+				document.head.removeChild(oldLink);
+			}
+			document.head.appendChild(link);
 		});
 	};
 
diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js
index 1646e2b87..f0dacf2be 100644
--- a/public/react/src/modules/tpm/TPMIndexHOC.js
+++ b/public/react/src/modules/tpm/TPMIndexHOC.js
@@ -285,17 +285,40 @@ export function TPMIndexHOC(WrappedComponent) {
 				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;
+						if(response.data){
+							this.setState({
+								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);
+						}else {
+							document.title = "EduCoder";
+							var link = document.createElement('link'),
+								oldLink = document.getElementById('dynamic-favicon');
+							link.id = 'dynamic-favicon';
+							link.rel = 'shortcut icon';
+							link.href = "/react/build/./favicon.ico";
+							if (oldLink) {
+								document.head.removeChild(oldLink);
+							}
+							document.head.appendChild(link);
+						}
+
+					}else{
+						document.title = "EduCoder";
 						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;
+						link.href = "/react/build/./favicon.ico";
 						if (oldLink) {
 							document.head.removeChild(oldLink);
 						}
@@ -303,7 +326,16 @@ export function TPMIndexHOC(WrappedComponent) {
 					}
 
 				}).catch((error) => {
-
+					document.title = "EduCoder";
+					var link = document.createElement('link'),
+						oldLink = document.getElementById('dynamic-favicon');
+					link.id = 'dynamic-favicon';
+					link.rel = 'shortcut icon';
+					link.href = "/react/build/./favicon.ico";
+					if (oldLink) {
+						document.head.removeChild(oldLink);
+					}
+					document.head.appendChild(link);
 				});
 			};
       /**