Commit 3803be47 by zhanghaozhe

route-middle-page

parent 2b26e2bf
......@@ -40,8 +40,8 @@
"detail.js": "/static/js/detail.17bffc34.chunk.js",
"detail.js.map": "/static/js/detail.17bffc34.chunk.js.map",
"main.css": "/static/css/main.73526f2b.chunk.css",
"main.js": "/static/js/main.b79cfa44.chunk.js",
"main.js.map": "/static/js/main.b79cfa44.chunk.js.map",
"main.js": "/static/js/main.7d8e176e.chunk.js",
"main.js.map": "/static/js/main.7d8e176e.chunk.js.map",
"myorders.css": "/static/css/myorders.3ab93c8e.chunk.css",
"myorders.js": "/static/js/myorders.7769019f.chunk.js",
"myorders.js.map": "/static/js/myorders.7769019f.chunk.js.map",
......@@ -84,7 +84,7 @@
"static/js/30.71ffdc1e.chunk.js": "/static/js/30.71ffdc1e.chunk.js",
"static/js/30.71ffdc1e.chunk.js.map": "/static/js/30.71ffdc1e.chunk.js.map",
"index.html": "/index.html",
"precache-manifest.481670da1fbed380bd08147491a25ae9.js": "/precache-manifest.481670da1fbed380bd08147491a25ae9.js",
"precache-manifest.5923842c76d414466fa43a96c6f44033.js": "/precache-manifest.5923842c76d414466fa43a96c6f44033.js",
"service-worker.js": "/service-worker.js",
"static/css/23.7c331155.chunk.css.map": "/static/css/23.7c331155.chunk.css.map",
"static/css/24.1597b3e9.chunk.css.map": "/static/css/24.1597b3e9.chunk.css.map",
......
......@@ -104,12 +104,12 @@ self.__precacheManifest = [
"url": "/static/js/detail.17bffc34.chunk.js"
},
{
"revision": "304b200561196ceb60b9",
"revision": "9f64efe7e0bca2e65eb2",
"url": "/static/css/main.73526f2b.chunk.css"
},
{
"revision": "304b200561196ceb60b9",
"url": "/static/js/main.b79cfa44.chunk.js"
"revision": "9f64efe7e0bca2e65eb2",
"url": "/static/js/main.7d8e176e.chunk.js"
},
{
"revision": "96bdf3e260e6f85cfb74",
......@@ -232,7 +232,7 @@ self.__precacheManifest = [
"url": "/static/css/23.7c331155.chunk.css"
},
{
"revision": "0282591afc2b28d734595ccaedfc288d",
"revision": "8b0be0a33812d68389a83ddacac894c4",
"url": "/index.html"
}
];
\ No newline at end of file
......@@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");
importScripts(
"/precache-manifest.481670da1fbed380bd08147491a25ae9.js"
"/precache-manifest.5923842c76d414466fa43a96c6f44033.js"
);
workbox.clientsClaim();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,17 +2,13 @@ import React from 'react';
import { Route } from "react-router-dom";
import { connect } from "react-redux";
import jsCookie from 'js-cookie'
import Loading from './loading'
import Loading from './route-middle-page'
const PrivateRoute = ({component: Component, path, user, ...rest}) => {
let authenticated = jsCookie.get('token') && jsCookie.get('uid')
console.group('private-route')
console.log(authenticated)
console.groupEnd()
return (
<Route {...rest} render={props => {
return authenticated
......
......@@ -5,14 +5,11 @@ import { connect } from "react-redux";
import LoadingComponent from '@/common/Loading'
function Loading(props) {
function RouteMiddlePage(props) {
const [isLoading, setLoadingState] = useState(true)
useEffect(() => {
console.group('middle')
console.log(Object.values(user.data).every(item => !!item).length !== 0)
console.groupEnd()
let {user, location, history} = props
if (history.action === 'POP') {
......@@ -29,7 +26,17 @@ function Loading(props) {
history.replace('/passport', {from: location})
setLoadingState(false)
} else {
if (Object.values(user.data).every(item => !!item).length !== 0) {
let {data} = user || {
data: {
username: '',
avatar: '',
isVip: false,
token: '',
email: '',
uid: ''
}
}
if (Object.values(data).every(item => !!item).length !== 0) {
history.replace(location.pathname)
setLoadingState(false)
}
......@@ -52,4 +59,4 @@ export default compose(
null
),
withRouter
)(Loading)
\ No newline at end of file
)(RouteMiddlePage)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment