|
@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react'; |
|
|
import moment from 'moment'; |
|
|
import moment from 'moment'; |
|
|
import configStore from './store'; |
|
|
import configStore from './store'; |
|
|
import { Provider } from 'react-redux'; |
|
|
import { Provider } from 'react-redux'; |
|
|
import { createBrowserHistory } from 'history'; |
|
|
import { createBrowserHistory, push as pushs } from 'history'; |
|
|
import { ConnectedRouter } from 'connected-react-router' |
|
|
import { ConnectedRouter } from 'connected-react-router' |
|
|
import { Layout, NoMatch } from './containers'; |
|
|
import { Layout, NoMatch } from './containers'; |
|
|
import { BrowserRouter, Switch, Route } from "react-router-dom"; |
|
|
import { BrowserRouter, Switch, Route } from "react-router-dom"; |
|
@ -20,7 +20,7 @@ const { initLayout, initApiRoot, resize, initWebSocket } = layoutActions; |
|
|
|
|
|
|
|
|
const Root = props => { |
|
|
const Root = props => { |
|
|
const { sections, title, copyright, actions } = props; |
|
|
const { sections, title, copyright, actions } = props; |
|
|
const [history, setHistory] = useState(null) |
|
|
const [historys, setHistorys] = useState(null) |
|
|
const [store, setStore] = useState(null) |
|
|
const [store, setStore] = useState(null) |
|
|
const [outerRoutes, setOuterRoutes] = useState([]) |
|
|
const [outerRoutes, setOuterRoutes] = useState([]) |
|
|
const [combineRoutes, setCombineRoutes] = useState([]) |
|
|
const [combineRoutes, setCombineRoutes] = useState([]) |
|
@ -135,7 +135,7 @@ const Root = props => { |
|
|
const combineRoutes = flatRoutes(innerRoutes); |
|
|
const combineRoutes = flatRoutes(innerRoutes); |
|
|
|
|
|
|
|
|
setInnerRoutes(combineRoutes) |
|
|
setInnerRoutes(combineRoutes) |
|
|
setHistory(history) |
|
|
setHistorys(history) |
|
|
setStore(store) |
|
|
setStore(store) |
|
|
setOuterRoutes(outerRoutes.map(route => ( |
|
|
setOuterRoutes(outerRoutes.map(route => ( |
|
|
<Route |
|
|
<Route |
|
@ -165,15 +165,13 @@ const Root = props => { |
|
|
await store.dispatch(actions.auth.logout()) |
|
|
await store.dispatch(actions.auth.logout()) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
console.log(data); |
|
|
|
|
|
setAuthCrossLoading(false) |
|
|
setAuthCrossLoading(false) |
|
|
}); |
|
|
}); |
|
|
// setAuthCrossLoading(false) |
|
|
// setAuthCrossLoading(false) |
|
|
|
|
|
|
|
|
// MicroApp |
|
|
// MicroApp |
|
|
const microAppListen = async (data) => { |
|
|
const microAppListen = async (data) => { |
|
|
console.log(actions); |
|
|
// console.log('mid:' + data.data.mid); |
|
|
console.log('mid:' + data.data.mid); |
|
|
|
|
|
|
|
|
|
|
|
if (data.action == 'initMicro') { |
|
|
if (data.action == 'initMicro') { |
|
|
await store.dispatch(actions.auth.initAuth({ |
|
|
await store.dispatch(actions.auth.initAuth({ |
|
@ -183,13 +181,19 @@ const Root = props => { |
|
|
...(data.data || {}) |
|
|
...(data.data || {}) |
|
|
})) |
|
|
})) |
|
|
if (data?.data?.mid) { |
|
|
if (data?.data?.mid) { |
|
|
console.log(22315348); |
|
|
|
|
|
await store.dispatch(push('/callService')); |
|
|
await store.dispatch(push('/callService')); |
|
|
} else { |
|
|
} else { |
|
|
await store.dispatch(push('/noMatch')); |
|
|
await store.dispatch(push('/noMatch')); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
setMicroAppWaiting(false) |
|
|
setMicroAppWaiting(false) |
|
|
|
|
|
} else if (data.action == 'videoImplant') { |
|
|
|
|
|
history.push({ |
|
|
|
|
|
pathname: '/video_play_cross', |
|
|
|
|
|
query: { |
|
|
|
|
|
video: true, |
|
|
|
|
|
...(data.data || {}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (window.__MICRO_APP_ENVIRONMENT__) { |
|
|
if (window.__MICRO_APP_ENVIRONMENT__) { |
|
@ -208,7 +212,7 @@ const Root = props => { |
|
|
} |
|
|
} |
|
|
}, []) |
|
|
}, []) |
|
|
|
|
|
|
|
|
console.log(authCrossLoading, microAppWaiting); |
|
|
// console.log(authCrossLoading, microAppWaiting); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
@ -217,12 +221,12 @@ const Root = props => { |
|
|
<ConfigProvider locale={zhCN}> |
|
|
<ConfigProvider locale={zhCN}> |
|
|
<Provider store={store}> |
|
|
<Provider store={store}> |
|
|
<BrowserRouter basename={window.__MICRO_APP_BASE_ROUTE__ || '/'}> |
|
|
<BrowserRouter basename={window.__MICRO_APP_BASE_ROUTE__ || '/'}> |
|
|
<ConnectedRouter history={history}> |
|
|
<ConnectedRouter history={historys}> |
|
|
|
|
|
|
|
|
<Switch> |
|
|
<Switch> |
|
|
{outerRoutes} |
|
|
{outerRoutes} |
|
|
<Layout |
|
|
<Layout |
|
|
history={history} |
|
|
history={historys} |
|
|
routes={innnerRoutes} |
|
|
routes={innnerRoutes} |
|
|
authCrossLoading={authCrossLoading} |
|
|
authCrossLoading={authCrossLoading} |
|
|
microAppWaiting={microAppWaiting} |
|
|
microAppWaiting={microAppWaiting} |
|
@ -244,8 +248,8 @@ const Root = props => { |
|
|
{ |
|
|
{ |
|
|
resourceRoot.iotAuthWeb && !window.__MICRO_APP_ENVIRONMENT__ ? |
|
|
resourceRoot.iotAuthWeb && !window.__MICRO_APP_ENVIRONMENT__ ? |
|
|
<iframe id="iotAuth" src={`${resourceRoot.iotAuthWeb}/cross`} style={{ position: 'absolute', top: 0, height: 1, visibility: 'hidden' }} frameBorder={0} > |
|
|
<iframe id="iotAuth" src={`${resourceRoot.iotAuthWeb}/cross`} style={{ position: 'absolute', top: 0, height: 1, visibility: 'hidden' }} frameBorder={0} > |
|
|
<p>你的浏览器不支持 iframe。</p> |
|
|
<p p > 你的浏览器不支持 iframe。</p > |
|
|
</iframe> |
|
|
</iframe > |
|
|
: '' |
|
|
: '' |
|
|
} |
|
|
} |
|
|
</> |
|
|
</> |
|
|