Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivWeb
Commits
eb641324
Commit
eb641324
authored
Dec 25, 2021
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复多用户切换,用户信息错乱
parent
fa23b26e
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
115 additions
and
105 deletions
+115
-105
proxy.js
config/proxy.js
+20
-0
app.js
src/app.js
+7
-88
reducer.js
src/containers/App/store/reducer.js
+1
-0
initConfig.js
src/initConfig.js
+8
-5
micro.js
src/micro.js
+21
-6
login.js
src/pages/user/login/login.js
+2
-2
baseLogin.js
src/pages/user/login/template/baseLogin.js
+6
-2
infoLogin.js
src/pages/user/login/template/infoLogin.js
+3
-1
yulin.js
src/pages/user/login/template/yulin.js
+3
-1
render.js
src/render.js
+37
-0
stores.js
src/stores.js
+7
-0
No files found.
config/proxy.js
View file @
eb641324
...
...
@@ -78,6 +78,26 @@ module.exports = {
pathRewrite
:
{
'/PandaCore'
:
'/PandaCore'
,
},
},
'/PandaInformatization'
:
{
target
:
proxyURL
,
changeOrigin
:
true
,
headers
:
{
'Access-Control-Allow-Origin'
:
'*'
,
},
pathRewrite
:
{
'/PandaInformatization'
:
'/PandaInformatization'
,
},
},
'/PandaWorkFlow'
:
{
target
:
proxyURL
,
changeOrigin
:
true
,
headers
:
{
'Access-Control-Allow-Origin'
:
'*'
,
},
pathRewrite
:
{
'/PandaWorkFlow'
:
'/PandaWorkFlow'
,
},
},
'/CityTemp'
:
{
// target: 'http://192.168.10.150:8777',
...
...
src/app.js
View file @
eb641324
...
...
@@ -8,114 +8,33 @@ import 'antd/dist/antd.less';
import
'file-loader?name=.htaccess!./.htaccess'
;
// eslint-disable-line import/extensions
import
'kit_utils/lib/format'
;
import
'sanitize.css/sanitize.css'
;
// import './locales/zh-CN';
// import './loader';
// import './vm';
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
{
event
}
from
'microser-data'
;
import
_
from
'lodash'
;
import
{
Button
,
ConfigProvider
,
message
,
notification
}
from
'antd'
;
import
{
ConnectedRouter
}
from
'connected-react-router/immutable'
;
import
Immutable
from
'immutable'
;
import
{
params
,
Storeage
}
from
'kit_utils'
;
import
{
Provider
}
from
'react-redux'
;
import
{
ConfigProvider
}
from
'antd'
;
import
{
Storeage
}
from
'kit_utils'
;
import
{
history
}
from
'@wisdom-utils/runtime'
;
import
ErrorBoundary
from
'./components/ErrorBoundary'
;
// import themePluginConfig from '../config/themePluginConfig';
import
{
appService
}
from
'./api'
;
// import { updateTheme } from './common/helpers/settingColor';
import
Container
from
'./components/Container'
;
import
configureStore
from
'./configureStore'
;
import
App
from
'./containers/App'
;
import
{
actionCreators
}
from
'./containers/App/store'
;
import
{
LocaleContainer
}
from
'./locales/locale'
;
import
{
initMicroApps
}
from
'./micro'
;
// import { initMicroApps } from './micro';
import
{
initGlobalConfig
}
from
'./initConfig'
import
'./utils/event'
;
import
store
from
'./stores'
// import Cookies from 'js-cookie';
// eslint-disable-next-line no-restricted-globals
const
namespace
=
`__PANDA_STORE__
${
location
.
hostname
}
`
;
window
.
createStoreage
=
new
Storeage
(
namespace
);
// eslint-disable-next-line no-underscore-dangle
const
initialState
=
Immutable
.
Map
();
const
store
=
configureStore
(
initialState
,
history
);
const
MOUNT_NODE
=
document
.
getElementById
(
'root'
);
ConfigProvider
.
config
({
prefixCls
:
'panda-console-base'
});
const
render
=
()
=>
{
// eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM
.
render
(
<
Provider
store
=
{
store
}
>
<
ConnectedRouter
history
=
{
history
}
>
<
LocaleContainer
>
<
ConfigProvider
prefixCls
=
"panda-console-base"
>
<
ErrorBoundary
>
<
Container
>
<
App
/>
<
/Container
>
<
/ErrorBoundary
>
<
/ConfigProvider
>
<
/LocaleContainer
>
<
/ConnectedRouter
>
<
/Provider>
,
MOUNT_NODE
,
);
};
// updateTheme('#ff9600');
const
loader
=
(
appContent
,
loading
)
=>
render
({
appContent
,
loading
});
const
initLocale
=
()
=>
{
localStorage
.
setItem
(
'umi_locale'
,
'zh-CN'
);
};
const
PRODUCT_NAME
=
[
'civ_water'
,
'civ_monitor'
];
const
initSensorType
=
()
=>
{
let
filterProduct
=
(
window
.
globalConfig
&&
window
.
globalConfig
.
products
)
||
[];
filterProduct
=
filterProduct
.
filter
(
item
=>
PRODUCT_NAME
.
includes
(
item
.
PackageName
),
);
if
(
filterProduct
.
length
>
0
)
{
appService
.
getSensorType
().
then
(
res
=>
{
store
.
dispatch
(
actionCreators
.
getConfig
(
Object
.
assign
({},
window
.
globalConfig
,
{
sensorType
:
res
.
data
,
}),
),
);
});
}
};
// const PRODUCT_NAME = ['civ_water', 'civ_monitor'];
const
initIsMock
=
()
=>
{
appService
.
sysConfiguration
({
moduleName
:
'是否mock数据'
,
})
.
then
(
res
=>
{
store
.
dispatch
(
actionCreators
.
getConfig
(
Object
.
assign
({},
window
.
globalConfig
,
{
isMock
:
res
.
data
===
'是'
,
}),
),
);
});
};
initGlobalConfig
(
loader
,
store
,
render
);
initGlobalConfig
();
initLocale
();
window
.
share
&&
window
.
share
.
event
&&
window
.
share
.
event
.
on
(
'triggerMicro'
,
()
=>
{
initMicroApps
(
loader
,
store
);
});
const
unlisten
=
history
.
listen
(
location
=>
{
if
(
location
.
pathname
.
indexOf
(
'/civbase/user/login'
)
>
-
1
)
{
initGlobalConfig
(
loader
,
store
,
render
);
initGlobalConfig
();
}
})
...
...
src/containers/App/store/reducer.js
View file @
eb641324
...
...
@@ -76,6 +76,7 @@ export const initialState = fromJS({
const
appReducer
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
GET_CONFIG
:
debugger
// eslint-disable-next-line no-debugger
// eslint-disable-next-line no-underscore-dangle
window
.
__INITIAL_STATE__
=
Object
.
assign
(
...
...
src/initConfig.js
View file @
eb641324
...
...
@@ -3,16 +3,19 @@ import { initMicroApps } from './micro';
import
{
params
,
Storeage
}
from
'kit_utils'
;
import
{
actionCreators
}
from
'./containers/App/store'
;
import
{
getToken
,
isString
}
from
'./utils/utils'
;
import
loader
,
{
render
}
from
'./render'
;
import
store
from
'./stores'
;
import
Login
from
'./pages/user/login/login'
;
const
namespace
=
`__PANDA_STORE__
${
location
.
hostname
}
`
;
window
.
createStoreage
=
new
Storeage
(
namespace
);
export
const
initGlobalConfig
=
(
loader
,
store
,
render
)
=>
{
export
const
initGlobalConfig
=
()
=>
{
// eslint-disable-next-line no-debugger
// eslint-disable-next-line no-undef
createStoreage
.
remove
(
`__PANDA_STORE__
${
location
.
hostname
}
`
);
window
.
globalConfig
=
{};
let
config
=
createStoreage
.
get
(
'globalConfig'
)
||
{};
window
.
__INITIAL_STATE__
=
{};
let
config
=
window
.
globalConfig
||
{};
//createStoreage.get('globalConfig') || {};
store
.
dispatch
(
actionCreators
.
updateComplexConfig
({}));
if
(
!
getToken
()
||
config
.
token
==
null
)
{
// eslint-disable-next-line no-undef
...
...
@@ -32,8 +35,8 @@ export const initGlobalConfig = (loader, store, render) => {
localStorage
.
removeItem
(
'loginSite'
);
}
if
(
config
.
token
!==
null
&&
Object
.
keys
(
c
onfig
).
length
>
0
)
{
store
.
dispatch
(
actionCreators
.
getConfig
(
c
onfig
));
if
(
window
.
globalConfig
.
token
!==
null
&&
Object
.
keys
(
window
.
globalC
onfig
).
length
>
0
)
{
store
.
dispatch
(
actionCreators
.
getConfig
(
window
.
globalC
onfig
));
// render({ appContent: '', loading: true });
initMicroApps
(
loader
,
store
);
if
(
config
.
isNewYear
)
{
...
...
src/micro.js
View file @
eb641324
...
...
@@ -9,12 +9,14 @@ import {
setDefaultMountApp
,
start
,
}
from
'qiankun'
;
import
{
store
as
microStore
}
from
'microser-data'
;
import
micorConfig
,
{
genActiveRule
}
from
'../config/micor'
;
import
pkg
from
'../package.json'
;
import
{
actionCreators
}
from
'./containers/App/store'
;
import
{
FILTER_FOLER_REG
}
from
'./utils/constants'
;
import
loader
from
'./render'
;
import
store
from
'./stores'
;
// eslint-disable-next-line no-undef
const
Logger
=
logger
(
'micro'
);
const
MICRO_STATUS
=
{
...
...
@@ -32,12 +34,15 @@ const MICRO_STATUS = {
LOAD_ERROR
:
'LOAD_ERROR'
,
};
export
const
initMicroApps
=
(
loader
,
store
)
=>
{
export
const
initMicroApps
=
()
=>
{
debugger
/* eslint-disable */
const
config
=
createStoreage
.
get
(
'globalConfig'
);
const
config
=
window
.
globalConfig
||
{};
//createStoreage.get('globalConfig');
const
application
=
config
&&
config
.
products
||
[];
let
products
=
[];
application
&&
Array
.
isArray
(
application
)
&&
application
.
length
>
0
&&
application
.
map
(
item
=>
{
if
(
item
.
PackageName
===
'report'
)
{
products
.
push
({
...
...
@@ -77,7 +82,8 @@ export const initMicroApps = (loader, store) => {
baseRoot
:
item
.
name
,
// eslint-
// disable-next-line no-undef
globalConfig
:
createStoreage
.
get
(
'globalConfig'
),
globalConfig
:
config
,
//createStoreage.get('globalConfig'),
XMLHttpRequest
:
window
.
XMLHttpRequest
,
};
return
item
;
...
...
@@ -103,6 +109,8 @@ export const initMicroApps = (loader, store) => {
app
=>
{
window
.
share
.
event
.
removeAllListeners
(
'changeRoute'
);
Logger
.
info
(
`[LifeCycle] after unmount %c%s
${
app
.
name
}
`
);
window
.
globalConfig
=
{}
createStoreage
.
remove
(
`__PANDA_STORE__
${
location
.
hostname
}
`
)
},
],
afterUnmount
:
[
app
=>
{}],
...
...
@@ -111,12 +119,19 @@ export const initMicroApps = (loader, store) => {
const
globalStore
=
store
.
getState
().
toJS
();
const
{
setGlobalState
}
=
initGlobalState
({
// eslint-disable-next-line no-undef
globalConfig
:
createStoreage
.
get
(
'globalConfig'
),
globalConfig
:
window
.
globalConfig
,
//createStoreage.get('globalConfig'),
global
:
globalStore
.
global
});
setGlobalState
({
// eslint-disable-next-line no-undef
globalConfig
:
createStoreage
.
get
(
'globalConfig'
),
globalConfig
:
window
.
globalConfig
,
//createStoreage.get('globalConfig'),
});
microStore
.
set
(
"props:globalConfig"
,
{
globalConfig
:
window
.
globalConfig
,
global
:
globalStore
.
global
});
start
({
sandbox
:
{
...
...
src/pages/user/login/login.js
View file @
eb641324
...
...
@@ -601,7 +601,7 @@ class Login {
generateType
:
params
.
getParams
(
'generateType'
)
||
''
})
.
then
(
response
=>
{
debugger
self
.
globalConfig
.
layout
=
'blank'
;
if
(
response
&&
response
.
token
)
{
...
...
@@ -645,7 +645,7 @@ class Login {
expires
:
date
,
path
:
'/'
,
})
debugger
// self.globalConfig.Industry = industry;
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
const
loginSite
=
{};
...
...
src/pages/user/login/template/baseLogin.js
View file @
eb641324
...
...
@@ -17,6 +17,7 @@ import styles from '../style.less';
import
useRenderQcode
from
'../js/useRenderQcode'
;
import
Account
from
'../js/useAccount'
;
import
IotComponent
from
'../js/useIOTComponent'
;
import
{
initMicroApps
}
from
'../../../../micro'
;
const
Login
=
forwardRef
((
props
,
_ref
)
=>
{
const
videoRef
=
useRef
();
const
loginRef
=
useRef
();
...
...
@@ -62,7 +63,9 @@ const Login = forwardRef((props, _ref) => {
setSubmitting
(
false
);
props
.
updateCurrentIndex
&&
props
.
updateCurrentIndex
(
0
);
props
.
history
.
push
(
`/?client=
${
props
.
global
.
client
}
`
);
window
.
share
.
event
.
emit
(
'triggerMicro'
,
props
.
global
);
// debugger
// window.share.event.emit('triggerMicro', props.global);
initMicroApps
();
});
action
&&
action
.
events
.
on
(
'loginError'
,
event
=>
{
setVisible
(
false
);
...
...
@@ -78,7 +81,8 @@ const Login = forwardRef((props, _ref) => {
action
&&
action
.
events
.
on
(
'loginSuccess'
,
event
=>
{
props
.
history
.
push
(
`/?client=
${
props
.
global
.
client
}
`
);
window
.
share
.
event
.
emit
(
'triggerMicro'
,
props
.
global
);
// window.share.event.emit('triggerMicro', props.global);
initMicroApps
();
});
action
&&
action
.
events
.
on
(
'loginError'
,
event
=>
{
...
...
src/pages/user/login/template/infoLogin.js
View file @
eb641324
...
...
@@ -24,6 +24,7 @@ import UnSelected from '@/assets/oa/login/unselected.jpg'
import
LoginAction
from
'../login'
;
import
{
actionCreators
}
from
'@/containers/App/store'
;
import
Cookies
from
'js-cookie'
;
import
{
initMicroApps
}
from
'../../../../micro'
;
const
Logger
=
logger
(
'login'
);
// 、登录页
class
InfoLogin
extends
React
.
Component
{
...
...
@@ -108,7 +109,8 @@ changeQrCode=(item)=>{
action
&&
action
.
events
.
on
(
'loginSuccess'
,
event
=>
{
this
.
props
.
updateCurrentIndex
&&
this
.
props
.
updateCurrentIndex
(
0
);
this
.
props
.
history
.
push
(
`/?client=
${
this
.
props
.
global
.
client
}
`
);
window
.
share
.
event
.
emit
(
'triggerMicro'
,
this
.
props
.
global
);
// window.share.event.emit('triggerMicro', this.props.global);
initMicroApps
();
});
action
&&
action
.
events
.
on
(
'loginError'
,
event
=>
{
...
...
src/pages/user/login/template/yulin.js
View file @
eb641324
...
...
@@ -20,6 +20,7 @@ import LoginAction from '../login';
import
{
actionCreators
}
from
'@/containers/App/store'
;
import
Cookies
from
'js-cookie'
;
import
QRCode
from
'qrcode.react'
;
import
{
initMicroApps
}
from
'../../../../micro'
;
const
Logger
=
logger
(
'login'
);
// 、登录页
class
InfoLogin
extends
React
.
Component
{
...
...
@@ -139,7 +140,8 @@ class InfoLogin extends React.Component {
action
&&
action
.
events
.
on
(
'loginSuccess'
,
event
=>
{
this
.
props
.
updateCurrentIndex
&&
this
.
props
.
updateCurrentIndex
(
0
);
this
.
props
.
history
.
push
(
`/?client=
${
this
.
props
.
global
.
client
}
`
);
window
.
share
.
event
.
emit
(
'triggerMicro'
,
this
.
props
.
global
);
// window.share.event.emit('triggerMicro', this.props.global);
initMicroApps
();
});
action
&&
action
.
events
.
on
(
'loginError'
,
event
=>
{
...
...
src/render.js
0 → 100644
View file @
eb641324
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
store
from
'./stores'
import
{
history
}
from
'@wisdom-utils/runtime'
;
import
{
Provider
}
from
'react-redux'
;
import
{
ConfigProvider
}
from
'antd'
;
import
{
ConnectedRouter
}
from
'connected-react-router/immutable'
;
import
ErrorBoundary
from
'./components/ErrorBoundary'
;
import
Container
from
'./components/Container'
;
import
{
LocaleContainer
}
from
'./locales/locale'
;
import
App
from
'./containers/App'
;
const
MOUNT_NODE
=
document
.
getElementById
(
'root'
);
export
const
render
=
()
=>
{
// eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM
.
render
(
<
Provider
store
=
{
store
}
>
<
ConnectedRouter
history
=
{
history
}
>
<
LocaleContainer
>
<
ConfigProvider
prefixCls
=
"panda-console-base"
>
<
ErrorBoundary
>
<
Container
>
<
App
/>
<
/Container
>
<
/ErrorBoundary
>
<
/ConfigProvider
>
<
/LocaleContainer
>
<
/ConnectedRouter
>
<
/Provider>
,
MOUNT_NODE
,
);
};
// updateTheme('#ff9600');
const
loader
=
(
appContent
,
loading
)
=>
render
({
appContent
,
loading
});
export
default
loader
;
\ No newline at end of file
src/stores.js
0 → 100644
View file @
eb641324
import
{
history
}
from
'@wisdom-utils/runtime'
;
import
Immutable
from
'immutable'
;
const
initialState
=
Immutable
.
Map
();
import
configureStore
from
'./configureStore'
;
const
store
=
configureStore
(
initialState
,
history
);
export
default
store
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment