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
8252d329
Commit
8252d329
authored
Sep 23, 2022
by
杨思琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 弱口令检测
parent
7b6f465f
Pipeline
#60930
waiting for manual action with stages
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
238 additions
and
262 deletions
+238
-262
index.js
src/components/Container/ValidDefaultPWD/index.js
+35
-38
AvatarDropdown.js
...youts/AppLayout/components/GlobalHeader/AvatarDropdown.js
+11
-2
login.js
src/pages/user/login/login.js
+78
-137
render.js
src/render.js
+114
-85
No files found.
src/components/Container/ValidDefaultPWD/index.js
View file @
8252d329
...
...
@@ -16,61 +16,65 @@ const formItemLayout = {
* 云平台上判断是否是默认密码
* 如果是默认密码,强制要求修改密码
*/
let
info
=
'666'
;
let
infoPre
=
'panda'
;
const
ValidContainer
=
props
=>
{
const
[
needChangePassword
,
setNeedChangePassword
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
// eslint-disable-next-line react/no-this-in-sfc
const
password
=
localStorage
.
getItem
(
'password_token'
);
let
rules
=
localStorage
.
getItem
(
'password_pwdRegex'
);
const
rulesTip
=
localStorage
.
getItem
(
'password_pwdRegexTip'
);
let
reg
;
try
{
reg
=
new
RegExp
(
rules
);
}
catch
(
error
)
{
rules
=
''
;
reg
=
new
RegExp
(
rules
);
}
useEffect
(()
=>
{
if
(
window
.
location
.
origin
.
replace
(
/^
(
http|https
)
:
\/\/
/
,
''
)
!==
'panda-water.cn'
)
return
;
//
if (window.location.origin.replace(/^(http|https):\/\//, '') !== 'panda-water.cn') return;
const
{
global
}
=
props
;
const
tk
=
global
.
token
;
// eslint-disable-next-line no-eval
if
(
tk
)
{
appService
.
validDefaultPWD
({
ignoreSite
:
true
,
token
:
tk
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
const
{
data
}
=
res
;
setNeedChangePassword
(
data
.
valid
);
info
=
data
.
info
;
if
(
rules
!==
''
&&
!
reg
.
test
(
password
))
{
setNeedChangePassword
(
true
);
}
}).
catch
(
err
=>
{
})
}
},
[]);
const
handleOK
=
(
e
)
=>
{
const
handleOK
=
e
=>
{
e
.
stopPropagation
();
form
.
validateFields
()
.
then
(
(
res
)
=>
{
.
then
(
res
=>
{
const
params
=
{
password
:
`
${
infoPre
}${
info
}
`
,
// 拼接默认密码
password
,
// 拼接默认密码
newpassword
:
res
.
newPwd
,
token
:
window
.
globalConfig
.
token
,
ignoreSite
:
true
,
}
}
;
appService
.
changePassword
(
params
)
.
then
((
res
)
=>
{
// eslint-disable-next-line no-shadow
.
then
(
res
=>
{
if
(
res
.
success
)
{
message
.
success
(
globalHeader
[
'component.account.password.update.success'
]);
setTimeout
(()
=>
{
//
setNeedChangePassword(false);
props
.
logout
();
setNeedChangePassword
(
false
);
//
props.logout();
},
300
);
}
else
{
message
.
error
(
globalHeader
[
'component.account.oldpassword.errorMessage'
]);
}
})
.
catch
(
(
error
)
=>
{
.
catch
(
error
=>
{
message
.
error
(
globalHeader
[
'component.account.password.update.fail'
]);
});
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
}
}
;
return
(
<>
{
props
.
children
}
...
...
@@ -87,7 +91,7 @@ const ValidContainer = props => {
// zIndex={2000}
>
<
div
className
=
{
styles
[
'info-label'
]}
>
<
ExclamationCircleFilled
style
=
{{
color
:
'#FCAC0F'
,
fontSize
:
'16px'
}}
/
>
<
ExclamationCircleFilled
style
=
{{
color
:
'#FCAC0F'
,
fontSize
:
'16px'
}}
/
>
<
span
>
用户首次登录之前必须修改密码
<
/span
>
<
/div
>
<
Form
labelAlign
=
"left"
{...
formItemLayout
}
form
=
{
form
}
>
...
...
@@ -100,16 +104,9 @@ const ValidContainer = props => {
message
:
'请输入新密码'
,
},
{
pattern
:
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
a-zA-Z0-9_
]{8,16}
$/
,
message
:
'密码需为8-16个数字、字符和下划线'
,
pattern
:
reg
,
message
:
rulesTip
,
},
({
getFieldValue
})
=>
({
validator
(
rule
,
value
)
{
if
(
value
===
`
${
infoPre
}${
props
?.
global
?.
userInfo
?.
loginName
??
info
}
` || value === 'panda666')
return Promise.reject('密码规则不允许');
return Promise.resolve();
},
})
]}
hasFeedback
>
...
...
@@ -127,13 +124,13 @@ const ValidContainer = props => {
},
({
getFieldValue
})
=>
({
validator
(
rule
,
value
)
{
if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9_]{8,16}$/.test(value))
return Promise.reject('密码需为8-16个数字、字符和下划线');
if (value === `
$
{
infoPre
}
$
{
props
?.
global
?.
userInfo
?.
loginName
??
info
}
` || value === 'panda666')
return Promise.reject('密码规则不允许');
if
(
!
reg
.
test
(
value
))
// eslint-disable-next-line prefer-promise-reject-errors
return
Promise
.
reject
(
rulesTip
);
if
(
!
value
||
getFieldValue
(
'newPwd'
)
===
value
)
{
return
Promise
.
resolve
();
}
// eslint-disable-next-line prefer-promise-reject-errors
return
Promise
.
reject
(
'确认密码与新密码输入不一致'
);
},
}),
...
...
src/layouts/AppLayout/components/GlobalHeader/AvatarDropdown.js
View file @
8252d329
...
...
@@ -41,7 +41,16 @@ class AvatarDropdown extends React.Component {
popVisible
:
false
,
path
:
null
,
action
:
API
.
UPLOAD_FILE_URL
,
rulesTip
:
localStorage
.
getItem
(
'password_pwdRegexTip'
),
reg
:
''
};
let
rules
=
localStorage
.
getItem
(
'password_pwdRegex'
);
try
{
this
.
state
.
reg
=
new
RegExp
(
rules
);
}
catch
(
error
)
{
rules
=
''
;
this
.
state
.
reg
=
new
RegExp
(
rules
);
}
}
loginout
=
(
event
)
=>
{
// eslint-disable-next-line no-undef
...
...
@@ -424,8 +433,8 @@ class AvatarDropdown extends React.Component {
message
:
'请输入新密码'
,
},
{
pattern
:
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
a-zA-Z0-9!@#$%^&*_
]{8,16}
$/
,
message
:
'密码字符长度为8-16个字符'
,
pattern
:
this
.
state
.
reg
,
message
:
this
.
state
.
rulesTip
,
},
]}
hasFeedback
...
...
src/pages/user/login/login.js
View file @
8252d329
...
...
@@ -8,11 +8,7 @@ import sha1 from 'sha1';
import
{
SlideVerify
}
from
'@wisdom-utils/components'
;
import
{
appService
,
noticeService
}
from
'@/api'
;
import
{
getUserInfo
,
getWebSiteConfig
}
from
'@/api/service/base'
;
import
{
SERVICE_APP_LOGIN_MODE
,
SERVICE_INTERFACE_SUCCESS_CODE
,
WX_REDIRECT_URI
,
}
from
'@/constants'
;
import
{
SERVICE_APP_LOGIN_MODE
,
SERVICE_INTERFACE_SUCCESS_CODE
,
WX_REDIRECT_URI
}
from
'@/constants'
;
import
store
from
'@/stores'
;
import
{
DEFAULT_MQTT_PATH
,
...
...
@@ -23,8 +19,7 @@ import {
// eslint-disable-next-line no-undef
const
Logger
=
logger
(
'login'
);
const
getGlobalConfig
=
()
=>
store
.
getState
().
toJS
().
global
?.
globalConfig
??
{};
const
getGlobalConfig
=
()
=>
store
.
getState
().
toJS
().
global
?.
globalConfig
??
{};
class
Login
{
constructor
(
props
,
callback
,
isInit
)
{
this
.
events
=
window
.
share
.
event
;
...
...
@@ -54,9 +49,7 @@ class Login {
let
{
ddCode
}
=
this
.
globalConfig
;
let
{
loginName
}
=
this
.
globalConfig
;
let
{
password
}
=
this
.
globalConfig
;
loginName
=
params
.
getParams
(
'loginName'
)
?
params
.
getParams
(
'loginName'
)
:
loginName
;
loginName
=
params
.
getParams
(
'loginName'
)
?
params
.
getParams
(
'loginName'
)
:
loginName
;
const
homepage
=
params
.
getParams
(
'homepage'
);
const
generateType
=
params
.
getParams
(
'generateType'
);
if
(
homepage
)
{
...
...
@@ -68,9 +61,7 @@ class Login {
}
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
password
=
params
.
getParams
(
'password'
)
?
params
.
getParams
(
'password'
)
:
password
;
password
=
params
.
getParams
(
'password'
)
?
params
.
getParams
(
'password'
)
:
password
;
const
loginMode
=
Cookies
.
get
(
'loginMode'
)
||
null
;
if
(
loginMode
&&
loginMode
===
'iotWechat'
)
ddCode
=
null
;
// self.qrcodeLogin(self.globalConfig.qrcodeData.code);
...
...
@@ -86,15 +77,11 @@ class Login {
self
.
otherLoginIn
(
loginName
,
password
);
}
else
if
(
self
.
globalConfig
.
qrcodeData
&&
(
self
.
globalConfig
.
qrcodeData
.
state
&&
self
.
globalConfig
.
qrcodeData
.
state
===
this
.
redirect_state
)
&&
(
self
.
globalConfig
.
qrcodeData
.
state
&&
self
.
globalConfig
.
qrcodeData
.
state
===
this
.
redirect_state
)
&&
self
.
globalConfig
.
qrcodeData
.
code
!==
''
)
{
self
.
qrcodeLogin
(
self
.
globalConfig
.
qrcodeData
.
code
);
}
else
if
(
!!
self
.
globalConfig
.
isSingleLogin
&&
!!
self
.
globalConfig
.
singleLoginCode
)
{
}
else
if
(
!!
self
.
globalConfig
.
isSingleLogin
&&
!!
self
.
globalConfig
.
singleLoginCode
)
{
//
}
else
if
(
self
.
goLogin
())
{
return
false
;
...
...
@@ -105,7 +92,6 @@ class Login {
this
.
globalConfig
.
token
=
token
;
const
self
=
this
;
// eslint-disable-next-line no-undef
getUserInfo
({
token
:
this
.
globalConfig
.
token
,
subOID
:
'subOID'
,
...
...
@@ -116,7 +102,6 @@ class Login {
if
(
response
&&
response
.
code
===
0
)
{
self
.
globalConfig
.
userInfo
=
window
?.
globalConfig
?.
transformUserInfo
?.(
response
.
data
)
??
{};
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
self
.
getUserInfoAndConfig
();
}
else
{
self
.
logout
&&
self
.
logout
();
...
...
@@ -125,10 +110,7 @@ class Login {
window
.
location
.
href
=
`
${
window
.
location
.
origin
}
`
;
return
false
;
}
if
(
self
.
globalConfig
.
style
===
'ios'
&&
self
.
globalConfig
.
loginTemplate
===
'IOSCloud.html'
)
{
if
(
self
.
globalConfig
.
style
===
'ios'
&&
self
.
globalConfig
.
loginTemplate
===
'IOSCloud.html'
)
{
window
.
location
.
href
=
`
${
window
.
location
.
origin
}
`
;
return
false
;
}
...
...
@@ -140,8 +122,7 @@ class Login {
writeLogs
()
{
if
(
this
.
globalConfig
.
userInfo
.
UserImge
===
''
)
{
// _config.userInfo.UserImge = __webpack_public_path__ + "assets/images/icon/熊猫新2.png";
this
.
globalConfig
.
userInfo
.
UserImge
=
'https://panda-water.cn/web4/assets/images/icon/熊猫新2.png'
;
this
.
globalConfig
.
userInfo
.
UserImge
=
'https://panda-water.cn/web4/assets/images/icon/熊猫新2.png'
;
}
if
(
this
.
globalConfig
.
userInfo
.
site
)
{
...
...
@@ -150,10 +131,7 @@ class Login {
.
writeLogs
({
origin
:
window
.
location
.
origin
,
client
:
this
.
globalConfig
.
client
,
site
:
this
.
globalConfig
.
userInfo
&&
this
.
globalConfig
.
userInfo
.
site
?
this
.
globalConfig
.
userInfo
.
site
:
''
,
site
:
this
.
globalConfig
.
userInfo
&&
this
.
globalConfig
.
userInfo
.
site
?
this
.
globalConfig
.
userInfo
.
site
:
''
,
loginName
:
this
.
globalConfig
.
userInfo
&&
this
.
globalConfig
.
userInfo
.
fullName
?
this
.
globalConfig
.
userInfo
.
fullName
...
...
@@ -167,10 +145,7 @@ class Login {
.
loginLogs
({
origin
:
window
.
location
.
origin
,
client
:
this
.
globalConfig
.
client
,
site
:
this
.
globalConfig
.
userInfo
&&
this
.
globalConfig
.
userInfo
.
site
?
this
.
globalConfig
.
userInfo
.
site
:
''
,
site
:
this
.
globalConfig
.
userInfo
&&
this
.
globalConfig
.
userInfo
.
site
?
this
.
globalConfig
.
userInfo
.
site
:
''
,
loginName
:
this
.
globalConfig
.
userInfo
&&
this
.
globalConfig
.
userInfo
.
fullName
?
this
.
globalConfig
.
userInfo
.
fullName
...
...
@@ -182,15 +157,9 @@ class Login {
getIndustry
(
flag
,
token
,
getIndustry
)
{
this
.
globalConfig
.
userInfo
.
Industries
=
[];
if
(
this
.
globalConfig
.
userInfo
.
Groups
&&
this
.
globalConfig
.
userInfo
.
Groups
.
length
)
{
if
(
this
.
globalConfig
.
userInfo
.
Groups
&&
this
.
globalConfig
.
userInfo
.
Groups
.
length
)
{
this
.
globalConfig
.
userInfo
.
Groups
.
forEach
(
group
=>
{
if
(
group
.
industry
&&
this
.
globalConfig
.
userInfo
.
Industries
.
indexOf
(
group
.
industry
)
<
0
)
{
if
(
group
.
industry
&&
this
.
globalConfig
.
userInfo
.
Industries
.
indexOf
(
group
.
industry
)
<
0
)
{
this
.
globalConfig
.
userInfo
.
Industries
.
push
(
group
.
industry
);
}
});
...
...
@@ -237,19 +206,16 @@ class Login {
if
(
res
.
data
[
0
])
{
const
data
=
res
.
data
[
0
];
mqttConfig
.
mqtt_IsSSL
=
data
.
IsSSL
?
data
.
IsSSL
:
false
;
mqttConfig
.
mqtt_mess
.
site_code
=
data
.
SiteCode
||
self
.
globalConfig
.
userInfo
.
site
;
mqttConfig
.
mqtt_mess
.
site_code
=
data
.
SiteCode
||
self
.
globalConfig
.
userInfo
.
site
;
mqttConfig
.
mqtt_mess
.
TcpIP
=
data
.
TcpIP
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
data
.
TcpPort
?
parseInt
(
data
.
TcpPort
)
:
8083
;
mqttConfig
.
mqtt_mess
.
MessageLevel
=
data
.
MessageLevel
?
data
.
MessageLevel
:
DEFAULT_PARSE_LEVEL
;
// eslint-disable-next-line radix
mqttConfig
.
mqtt_mess
.
TcpPort
=
data
.
TcpPort
?
parseInt
(
data
.
TcpPort
)
:
8083
;
mqttConfig
.
mqtt_mess
.
MessageLevel
=
data
.
MessageLevel
?
data
.
MessageLevel
:
DEFAULT_PARSE_LEVEL
;
if
(
data
.
NginxStart
)
{
mqttConfig
.
nginxStart
=
data
.
NginxStart
;
mqttConfig
.
mqtt_mess
.
TcpIP
=
window
.
location
.
hostname
;
// eslint-disable-next-line radix
mqttConfig
.
mqtt_mess
.
TcpPort
=
parseInt
(
window
.
location
.
port
);
mqttConfig
.
mqtt_path
=
'/ws/'
;
}
else
{
...
...
@@ -258,13 +224,9 @@ class Login {
}
else
{
mqttConfig
.
mqtt_mess
.
TcpIP
=
DEFAULT_TCP_IP
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
DEFAULT_TCP_PORT
;
mqttConfig
.
mqtt_IsSSL
=
`
${
mqttConfig
.
mqtt_mess
.
TcpIP
}
:
${
mqttConfig
.
mqtt_mess
.
TcpPort
}
`
;
mqttConfig
.
mqtt_IsSSL
=
`
${
mqttConfig
.
mqtt_mess
.
TcpIP
}
:
${
mqttConfig
.
mqtt_mess
.
TcpPort
}
`
;
}
mqttConfig
.
mqtt_iotIP
=
`
${
mqttConfig
.
mqtt_mess
.
TcpIP
}
:
${
mqttConfig
.
mqtt_mess
.
TcpPort
}
`
;
mqttConfig
.
mqtt_iotIP
=
`
${
mqttConfig
.
mqtt_mess
.
TcpIP
}
:
${
mqttConfig
.
mqtt_mess
.
TcpPort
}
`
;
self
.
globalConfig
=
Object
.
assign
(
self
.
globalConfig
,
{
...
mqttConfig
,
...
...
@@ -287,11 +249,8 @@ class Login {
const
config
=
result
.
shift
();
const
homeType
=
config
.
productType
||
'civweb4'
;
// 产品类型和首页路径同时有才行
let
homepage
=
params
.
getParams
(
'homepage'
)
?
params
.
getParams
(
'homepage'
)
:
homeType
&&
config
.
homepage
?
`
${
homeType
}
/
${
params
.
getParams
(
'homepage'
)
||
config
.
homepage
}
`
:
''
;
// eslint-disable-next-line prettier/prettier
const
homepage
=
params
.
getParams
(
'homepage'
)
?
params
.
getParams
(
'homepage'
)
:
(
homeType
&&
config
.
homepage
?
`
${
homeType
}
/
${
params
.
getParams
(
'homepage'
)
||
config
.
homepage
}
`
:
''
);
self
.
globalConfig
=
Object
.
assign
(
self
.
globalConfig
,
config
,
{
theme
:
self
.
globalConfig
.
theme
,
...
...
@@ -347,20 +306,16 @@ class Login {
if
(
resultData
&&
resultData
.
length
>
0
)
{
const
mainConf
=
resultData
.
shift
();
const
mainType
=
mainConf
.
productType
||
'civweb4'
;
if
(
mainConf
.
homepage
)
self
.
globalConfig
.
homepage
=
`
${
mainType
}
/
${
mainConf
.
homepage
}
`
;
if
(
mainConf
.
bannerLogo
)
self
.
globalConfig
.
bannerLogo
=
mainConf
.
bannerLogo
;
if
(
mainConf
.
homepage
)
self
.
globalConfig
.
homepage
=
`
${
mainType
}
/
${
mainConf
.
homepage
}
`
;
if
(
mainConf
.
bannerLogo
)
self
.
globalConfig
.
bannerLogo
=
mainConf
.
bannerLogo
;
if
(
mainConf
.
logo
)
self
.
globalConfig
.
logo
=
mainConf
.
logo
;
if
(
mainConf
.
mdi
)
self
.
globalConfig
.
mdi
=
mainConf
.
mdi
;
if
(
mainConf
.
menu
)
self
.
globalConfig
.
menu
=
mainConf
.
menu
;
if
(
mainConf
.
shortcutIcon
)
self
.
globalConfig
.
shortcutIcon
=
mainConf
.
shortcutIcon
;
if
(
mainConf
&&
mainConf
.
hasOwnProperty
(
'topMenu'
))
self
.
globalConfig
.
topMenu
=
mainConf
.
topMenu
;
if
(
mainConf
&&
mainConf
.
navTheme
&&
self
.
globalConfig
.
CloudStyle
!==
'否'
)
self
.
globalConfig
.
navTheme
=
mainConf
.
navTheme
;
// 云平台统一navTheme
if
(
mainConf
.
shortcutIcon
)
self
.
globalConfig
.
shortcutIcon
=
mainConf
.
shortcutIcon
;
// eslint-disable-next-line no-prototype-builtins
if
(
mainConf
&&
mainConf
.
hasOwnProperty
(
'topMenu'
))
self
.
globalConfig
.
topMenu
=
mainConf
.
topMenu
;
if
(
mainConf
&&
mainConf
.
navTheme
&&
self
.
globalConfig
.
CloudStyle
!==
'否'
)
self
.
globalConfig
.
navTheme
=
mainConf
.
navTheme
;
// 云平台统一navTheme
// 云平台切换站点 应用站点自己主题配置
if
(
config
.
CloudStyle
===
'否'
)
{
...
...
@@ -368,13 +323,13 @@ class Login {
primaryColor
:
config
.
primaryColor
,
navTheme
:
config
.
navTheme
,
headerPrimaryColor
:
config
.
headerPrimaryColor
,
}
}
;
}
else
{
self
.
globalConfig
.
variableTheme
=
{
primaryColor
:
mainConf
.
primaryColor
,
navTheme
:
mainConf
.
navTheme
,
headerPrimaryColor
:
mainConf
.
headerPrimaryColor
,
}
}
;
}
// if (mainConf.productType)
// self.globalConfig.productType = mainConf.productType;
...
...
@@ -385,19 +340,14 @@ class Login {
self
.
callback
&&
self
.
callback
();
// console.log("===loginSuccess===")
getIndustry
?
self
.
events
.
emit
(
'toggleIndustry'
)
:
self
.
events
.
emit
(
'loginSuccess'
,
self
.
history
);
getIndustry
?
self
.
events
.
emit
(
'toggleIndustry'
)
:
self
.
events
.
emit
(
'loginSuccess'
,
self
.
history
);
});
}
else
{
// loginSuccess
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
// console.log("===loginSuccess===")
getIndustry
?
self
.
events
.
emit
(
'toggleIndustry'
)
:
self
.
events
.
emit
(
'loginSuccess'
,
self
.
history
);
getIndustry
?
self
.
events
.
emit
(
'toggleIndustry'
)
:
self
.
events
.
emit
(
'loginSuccess'
,
self
.
history
);
window
.
share
.
event
=
self
.
events
;
self
.
callback
&&
self
.
callback
();
}
...
...
@@ -430,13 +380,8 @@ class Login {
// eslint-disable-next-line radix
MAX_BOTTOM
=
parseInt
(
item
.
bottom
);
}
if
(
!
isScale
&&
item
.
url
.
toLowerCase
().
indexOf
(
'widgets/zoom'
)
>
-
1
)
isScale
=
true
;
if
(
widgetIndex
===
-
1
&&
item
.
url
.
indexOf
(
'ToggleProject/ToggleProject'
)
>
-
1
)
widgetIndex
=
index
;
if
(
!
isScale
&&
item
.
url
.
toLowerCase
().
indexOf
(
'widgets/zoom'
)
>
-
1
)
isScale
=
true
;
if
(
widgetIndex
===
-
1
&&
item
.
url
.
indexOf
(
'ToggleProject/ToggleProject'
)
>
-
1
)
widgetIndex
=
index
;
});
const
{
layers
=
[]
}
=
this
.
globalConfig
.
mapsettings
||
{};
...
...
@@ -467,8 +412,7 @@ class Login {
}
if
(
layer
.
backgroundColor
)
{
this
.
globalConfig
.
mapsettings
.
areasettings
.
backgroundColor
=
layer
.
backgroundColor
;
this
.
globalConfig
.
mapsettings
.
areasettings
.
backgroundColor
=
layer
.
backgroundColor
;
}
if
(
layer
.
boundColor
)
{
...
...
@@ -481,11 +425,9 @@ class Login {
// eslint-disable-next-line radix
if
(
Number
.
isInteger
(
parseInt
(
layer
.
backgroundOpacity
)))
{
this
.
globalConfig
.
mapsettings
.
areasettings
.
backgroundOpacity
=
layer
.
backgroundOpacity
;
this
.
globalConfig
.
mapsettings
.
areasettings
.
backgroundOpacity
=
layer
.
backgroundOpacity
;
}
if
(
layer
.
extent
)
this
.
globalConfig
.
mapsettings
.
areasettings
.
extent
=
layer
.
extent
;
if
(
layer
.
extent
)
this
.
globalConfig
.
mapsettings
.
areasettings
.
extent
=
layer
.
extent
;
if
(
layer
.
basemaps
&&
layer
.
basemaps
.
length
>
0
)
{
this
.
globalConfig
.
mapsettings
.
basemaps
=
layer
.
basemaps
;
}
...
...
@@ -519,10 +461,7 @@ class Login {
}
goLogin
()
{
if
(
this
.
globalConfig
.
style
===
'ios'
&&
this
.
globalConfig
.
loginTemplate
===
'IOSCloud.html'
)
{
if
(
this
.
globalConfig
.
style
===
'ios'
&&
this
.
globalConfig
.
loginTemplate
===
'IOSCloud.html'
)
{
window
.
location
.
href
=
`
${
window
.
location
.
origin
}
/#login`
;
return
true
;
}
...
...
@@ -580,7 +519,7 @@ class Login {
self
.
getUserInfoAndConfig
();
}
else
{
self
.
handleLoginError
();
message
.
error
(
"登录失败,用户信息错误"
);
message
.
error
(
'登录失败,用户信息错误'
);
self
.
hasTry
=
true
;
// 已经输错过密码
}
});
...
...
@@ -704,9 +643,7 @@ class Login {
expiration
:
this
.
globalConfig
.
expiration
,
// token过期时间(单位:秒)
client
:
'referer'
,
username
:
usr
,
password
:
params
.
getParams
(
'generateType'
)
?
pwd
:
sha1
(
pwd
).
toUpperCase
(),
password
:
params
.
getParams
(
'generateType'
)
?
pwd
:
sha1
(
pwd
).
toUpperCase
(),
referer
:
this
.
globalConfig
.
client
,
skipMenuTest
:
1
,
generateType
:
params
.
getParams
(
'generateType'
)
||
''
,
...
...
@@ -792,14 +729,11 @@ class Login {
/* eslint-disable */
let
_industrySite
=
null
;
if
(
industry
)
{
const
userInfo
=
self
.
globalConfig
.
userInfo
&&
self
.
globalConfig
.
userInfo
.
Groups
&&
self
.
globalConfig
.
userInfo
.
Groups
instanceof
Array
?
self
.
globalConfig
.
userInfo
.
Groups
.
find
(
enter
=>
enter
.
industry
===
industry
,
)
?
self
.
globalConfig
.
userInfo
.
Groups
.
find
(
enter
=>
enter
.
industry
===
industry
)
:
null
;
if
(
industry
===
'熊猫新产品'
&&
site
)
{
...
...
@@ -832,8 +766,7 @@ class Login {
if
(
self
.
isSignIn
||
!!
industry
)
{
// eslint-disable-next-line no-undef
getUserInfo
(
{
getUserInfo
({
token
,
subOID
:
'subOID'
,
industry
,
...
...
@@ -842,8 +775,7 @@ class Login {
'request.preventCache'
:
Date
.
now
(),
// self.globalConfig.userInfo.site ? self.globalConfig.userInfo.site: this.getLocalSiteBytoken(token),
// industrySite ? _industrySite : this.getLocalSiteBytoken(token),
},
)
})
.
then
(
response
=>
{
try
{
if
(
response
&&
response
.
code
===
0
)
{
...
...
@@ -901,17 +833,24 @@ class Login {
transformLoginHander
(
response
,
isRememberPWD
)
{
const
self
=
this
;
const
token
=
response
&&
(
response
.
token
?
response
.
token
:
(
response
.
access_token
!==
null
&&
response
.
user_token
!==
null
)
?
response
.
user_token
:
''
);
const
token
=
response
&&
(
response
.
token
?
response
.
token
:
response
.
access_token
!==
null
&&
response
.
user_token
!==
null
?
response
.
user_token
:
''
);
if
(
token
)
{
const
exp
=
86400000
;
self
.
globalConfig
.
token
=
token
;
if
(
response
.
access_token
!==
""
)
{
if
(
response
.
access_token
!==
''
)
{
self
.
globalConfig
.
access_token
=
response
.
access_token
;
localStorage
.
setItem
(
'access_token'
,
response
.
access_token
);
localStorage
.
setItem
(
'password_token'
,
self
.
globalConfig
.
password
);
Cookies
.
set
(
'client'
,
self
.
globalConfig
.
client
,
{
expires
:
exp
/
(
24
*
60
*
60
*
1000
),
path
:
'/'
,
})
})
;
}
if
(
isRememberPWD
)
{
Cookies
.
set
(
'client'
,
self
.
globalConfig
.
client
,
{
...
...
@@ -939,36 +878,42 @@ class Login {
login
(
usr
,
pwd
,
userPhone
,
isRememberPWD
,
mode
=
SERVICE_APP_LOGIN_MODE
.
password
)
{
this
.
globalConfig
=
getGlobalConfig
();
const
self
=
this
;
if
(
window
.
globalConfig
&&
window
.
globalConfig
.
hasGateWay
)
{
usr
=
userPhone
?
userPhone
:
usr
;
appService
.
authorizationToken
({
self
.
globalConfig
.
password
=
pwd
;
if
(
window
.
globalConfig
&&
window
.
globalConfig
.
hasGateWay
)
{
usr
=
userPhone
?
userPhone
:
usr
;
appService
.
authorizationToken
({
loginName
:
usr
,
password
:
pwd
?
(
params
.
getParams
(
'generateType'
)
?
pwd
:
sha1
(
pwd
).
toUpperCase
())
:
''
,
type
:
mode
,
generateType
:
params
.
getParams
(
'generateType'
)
||
''
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
generateType
:
params
.
getParams
(
'generateType'
)
||
''
,
})
.
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
const
data
=
res
.
data
;
self
.
updateConfig
&&
self
.
updateConfig
(
Object
.
assign
({},
self
.
globalConfig
,
{
self
.
updateConfig
&&
self
.
updateConfig
(
Object
.
assign
({},
self
.
globalConfig
,
{
access_token
:
data
.
access_token
,
token
:
data
.
user_token
,
}));
return
data
}),
);
return
data
;
}
else
{
message
.
error
({
duration
:
3
,
content
:
`授权失败:
${
res
.
msg
}
`
content
:
`授权失败:
${
res
.
msg
}
`
,
});
self
.
events
.
emit
(
'loginError'
,
res
.
msg
);
return
Promise
.
reject
(
res
)
return
Promise
.
reject
(
res
);
}
}).
then
((
res
)
=>
{
self
.
transformLoginHander
(
res
,
isRememberPWD
)
})
.
then
(
res
=>
{
self
.
transformLoginHander
(
res
,
isRememberPWD
);
});
}
else
{
appService
.
generateToken
(
{
appService
.
generateToken
(
{
f
:
'json'
,
expiration
:
this
.
globalConfig
.
expiration
,
// token过期时间(单位:秒)
client
:
'referer'
,
...
...
@@ -980,22 +925,18 @@ class Login {
'request.preventCache'
:
Date
.
now
(),
ignoreSite
:
true
,
loginName
:
usr
,
generateType
:
params
.
getParams
(
'generateType'
)
||
''
},
)
generateType
:
params
.
getParams
(
'generateType'
)
||
''
,
})
.
then
(
response
=>
{
self
.
transformLoginHander
(
response
,
isRememberPWD
)
self
.
transformLoginHander
(
response
,
isRememberPWD
);
})
.
catch
(
error
=>
{
self
.
hasTry
=
true
;
self
.
handleLoginError
();
self
.
events
.
emit
(
'loginError'
,
error
.
message
);
message
.
error
(
'登录服务异常'
);
});
}
}
loginHandler
(
user
,
pwd
,
userPhone
,
isRememberPWD
,
ref
)
{
...
...
src/render.js
View file @
8252d329
import
React
,
{
useEffect
}
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
{
ConfigProvider
,
message
,
Modal
,
notification
,
}
from
'antd'
;
import
{
ConfigProvider
,
message
,
Modal
,
notification
}
from
'antd'
;
import
{
ConnectedRouter
}
from
'connected-react-router/immutable'
;
import
Cookies
from
'js-cookie'
;
import
canUseDom
from
'rc-util/lib/Dom/canUseDom'
;
...
...
@@ -15,19 +10,13 @@ import { Provider } from 'react-redux';
import
{
LocaleContainer
}
from
'@wisdom-utils/components'
;
import
{
history
}
from
'@wisdom-utils/runtime'
;
import
{
params
,
Storeage
,
}
from
'@wisdom-utils/utils/lib/helpers'
;
import
{
params
,
Storeage
}
from
'@wisdom-utils/utils/lib/helpers'
;
import
{
appService
}
from
'./api'
;
import
Container
from
'./components/Container'
;
import
App
from
'./containers/App'
;
import
{
actionCreators
}
from
'./containers/App/store'
;
import
{
defaultApp
,
initMicroApps
,
}
from
'./micro'
;
import
{
defaultApp
,
initMicroApps
}
from
'./micro'
;
import
Login
from
'./pages/user/login/login'
;
import
store
from
'./stores'
;
import
{
getToken
}
from
'./utils/utils'
;
...
...
@@ -36,53 +25,48 @@ const { getThemeVariables } = require('antd/dist/theme');
const
defaultSetting
=
require
(
'../config/defaultSetting'
);
const
MOUNT_NODE
=
document
.
getElementById
(
'root'
);
const
customPrefixCls
=
'panda-console-base'
;
// eslint-disable-next-line no-restricted-globals
const
namespace
=
`__PANDA_STORE__
${
location
.
hostname
}
`
;
window
.
createStoreage
=
new
Storeage
(
namespace
);
const
dynamicStyleMark
=
`-panda-
${
Date
.
now
()}
-
${
Math
.
random
()}
`
;
function
getStyle
(
prefixCls
,
theme
)
{
const
variables
=
{};
Object
.
keys
(
theme
).
forEach
(
item
=>
{
variables
[
item
]
=
theme
[
item
]
})
const
cssList
=
Object
.
keys
(
variables
).
map
(
key
=>
`--
${
prefixCls
}
-
${
key
}
:
${
variables
[
key
]}
;`
,
);
variables
[
item
]
=
theme
[
item
];
});
const
cssList
=
Object
.
keys
(
variables
).
map
(
key
=>
`--
${
prefixCls
}
-
${
key
}
:
${
variables
[
key
]}
;`
);
return
`
:root {
${
cssList
.
join
(
'
\
n'
)}
}
`
.
trim
();
}
const
registerTheme
=
function
(
prefixCls
,
theme
)
{
const
style
=
getStyle
(
prefixCls
,
theme
);
if
(
canUseDom
())
{
updateCSS
(
style
,
`
${
dynamicStyleMark
}
-dynamic-theme`
)
if
(
canUseDom
())
{
updateCSS
(
style
,
`
${
dynamicStyleMark
}
-dynamic-theme`
)
;
}
}
};
export
const
AppInitState
=
()
=>
{
const
getClient
=
()
=>
{
const
value
=
params
.
getParams
(
'client'
)
||
sessionStorage
.
getItem
(
'client'
);
const
client
=
value
&&
value
!==
'undefined'
?
value
:
'city'
;
return
client
;
}
}
;
const
client
=
getClient
();
let
config
=
window
.
globalConfig
||
{};
// eslint-disable-next-line no-undef, no-restricted-globals
createStoreage
.
remove
(
`__PANDA_STORE__
${
location
.
hostname
}
`
);
window
.
globalConfig
=
{};
// eslint-disable-next-line no-underscore-dangle
window
.
__INITIAL_STATE__
=
{};
if
(
!
getToken
()
||
config
.
token
==
null
)
{
...
...
@@ -105,53 +89,82 @@ export const AppInitState = () => {
}
const
initGeteWay
=
()
=>
{
appService
.
getWateWayConfig
({
ignoreSite
:
true
}).
then
(
res
=>
{
const
hasGateWay
=
!
res
||
!
res
.
data
?
false
:
_
.
isString
(
res
.
data
)
?
JSON
.
parse
(
res
.
data
)
:
typeof
res
.
data
===
'boolean'
?
res
.
data
:
false
;
appService
.
getWateWayConfig
({
ignoreSite
:
true
})
.
then
(
res
=>
{
// eslint-disable-next-line prettier/prettier, no-undef
const
hasGateWay
=
!
res
||
!
res
.
data
?
false
:
_
.
isString
(
res
.
data
)
?
JSON
.
parse
(
res
.
data
)
:
(
typeof
res
.
data
===
'boolean'
?
res
.
data
:
false
);
return
{
hasGateWay
,
apiGatewayDomain
:
`
${
window
.
location
.
origin
}${
hasGateWay
?
'/PandaCore/GateWay'
:
''
}
`
,
};
}).
then
(
gateWayConfig
=>
{
})
.
then
(
gateWayConfig
=>
{
// eslint-disable-next-line no-use-before-define
initGlobalConfig
(
gateWayConfig
);
}).
catch
(
err
=>
{
})
.
catch
(
err
=>
{
// eslint-disable-next-line no-use-before-define
initGlobalConfig
();
});
}
};
const
initGlobalConfig
=
(
gateWayConfig
=
{})
=>
{
appService
.
queryConfig
({
appService
.
queryConfig
({
client
:
client
||
'city'
,
ignoreSite
:
true
,
}).
then
(
res
=>
{
})
.
then
(
res
=>
{
if
(
res
)
{
const
{
data
}
=
res
;
if
(
!
data
.
client
)
{
data
.
client
=
client
;
}
store
.
dispatch
(
actionCreators
.
getConfig
(
Object
.
assign
({},
data
,{
if
(
data
.
pwdRegex
)
{
localStorage
.
setItem
(
'password_pwdRegex'
,
data
.
pwdRegex
);
}
if
(
data
.
pwdRegexTip
)
{
localStorage
.
setItem
(
'password_pwdRegexTip'
,
data
.
pwdRegexTip
);
}
store
.
dispatch
(
actionCreators
.
getConfig
(
Object
.
assign
(
{},
data
,
{
token
:
''
,
access_token
:
''
,
userInfo
:
null
,
},
gateWayConfig
)));
},
gateWayConfig
,
),
),
);
const
products
=
(
data
.
products
||
[]).
map
(
item
=>
{
if
(
item
.
PackageName
===
'civweb4'
)
{
return
'web4_console'
return
'web4_console'
;
}
return
`
${
item
.
PackageName
}
-main`
;
});
if
(
products
&&
products
.
length
>
0
)
{
if
(
products
&&
products
.
length
>
0
)
{
Object
.
keys
(
products
).
forEach
(
item
=>
{
window
[
products
[
item
]]
&&
window
[
products
[
item
]]
&&
window
[
products
[
item
]].
unmount
&&
window
[
products
[
item
]].
unmount
({
store
:
store
});
window
[
products
[
item
]]
&&
window
[
products
[
item
]]
&&
window
[
products
[
item
]].
unmount
&&
window
[
products
[
item
]].
unmount
({
store
});
});
initMicroApps
();
}
// eslint-disable-next-line no-new
if
(
getToken
())
{
// eslint-disable-next-line no-new
const
action
=
new
Login
({
global
:
Object
.
assign
({},
data
,
const
action
=
new
Login
(
{
global
:
Object
.
assign
(
{},
data
,
{
token
:
getToken
(),
},
...
...
@@ -164,28 +177,27 @@ export const AppInitState = () => {
},
()
=>
{
(
async
()
=>
{
(
await
(
getToken
()
&&
window
.
globalConfig
&&
window
.
globalConfig
.
token
))
&&
(
await
(
getToken
()
&&
window
.
globalConfig
&&
window
.
globalConfig
.
token
))
&&
// eslint-disable-next-line no-use-before-define
initMicroApps
(
loader
,
store
);
})();
},
true
,
);
action
.
events
.
on
(
'loginSuccess'
,
event
=>
{
action
.
events
.
on
(
'loginSuccess'
,
event
=>
{
window
.
history
.
pushState
(
''
,
''
,
`/?client=
${
client
}
`
);
defaultApp
();
})
});
}
return
window
.
globalConfig
.
variableTheme
return
window
.
globalConfig
.
variableTheme
;
}
})
.
then
(
themeConfig
=>
{
ConfigProvider
.
config
({
prefixCls
:
customPrefixCls
,
theme
:
{
primaryColor
:
themeConfig
.
primaryColor
}
primaryColor
:
themeConfig
.
primaryColor
,
},
});
registerTheme
(
customPrefixCls
,
{
...
...
@@ -196,8 +208,7 @@ export const AppInitState = () => {
.
catch
(
error
=>
{
store
.
dispatch
(
actionCreators
.
getConfigError
(
error
));
});
}
};
const
initLocale
=
()
=>
{
localStorage
.
setItem
(
'umi_locale'
,
'zh-CN'
);
...
...
@@ -221,33 +232,33 @@ export const AppInitState = () => {
// 添加主题变更事件监听
const
initAppTheme
=
()
=>
{
const
hasThemeChanged
=
(
preTheme
,
theme
)
=>
{
if
(
!
preTheme
&&
!
theme
)
return
false
if
(
!
preTheme
&&
!
theme
)
return
false
;
if
(
preTheme
&&
theme
&&
preTheme
&&
theme
&&
(
!
theme
.
primaryColor
||
theme
.
primaryColor
===
preTheme
.
primaryColor
)
&&
(
!
theme
.
navTheme
||
theme
.
navTheme
===
preTheme
.
navTheme
)
&&
(
!
theme
.
headerPrimaryColor
||
theme
.
headerPrimaryColor
===
preTheme
.
headerPrimaryColor
)
)
return
false
return
true
}
store
.
subscribe
((
function
()
{
let
preVariableTheme
=
store
.
getState
().
toJS
().
global
?.
globalConfig
?.
variableTheme
;
)
return
false
;
return
true
;
};
store
.
subscribe
(
(
function
()
{
const
preVariableTheme
=
store
.
getState
().
toJS
().
global
?.
globalConfig
?.
variableTheme
;
return
function
()
{
// if (!preVariableTheme)
const
variableTheme
=
store
.
getState
().
toJS
().
global
?.
globalConfig
?.
variableTheme
;
if
(
!
hasThemeChanged
(
preVariableTheme
,
variableTheme
))
return
false
const
{
primaryColor
:
prePrimaryColor
,
navTheme
:
preNavTheme
,
headerPrimaryColor
:
preHeaderPrimaryColor
,
}
=
(
preVariableTheme
||
{});
if
(
!
hasThemeChanged
(
preVariableTheme
,
variableTheme
))
return
false
;
const
{
primaryColor
:
prePrimaryColor
,
navTheme
:
preNavTheme
,
headerPrimaryColor
:
preHeaderPrimaryColor
}
=
preVariableTheme
||
{};
const
{
primaryColor
,
headerPrimaryColor
}
=
variableTheme
;
if
(
primaryColor
&&
primaryColor
!==
prePrimaryColor
)
{
ConfigProvider
.
config
({
prefixCls
:
customPrefixCls
,
theme
:
{
primaryColor
,
}
},
});
}
if
(
headerPrimaryColor
&&
headerPrimaryColor
!==
preHeaderPrimaryColor
)
{
...
...
@@ -255,17 +266,17 @@ export const AppInitState = () => {
'header-bg-color'
:
headerPrimaryColor
,
});
}
}
})())
};
})(),
);
};
initLocale
();
initMessageVoice
();
initGeteWay
();
initAppTheme
();
}
}
;
const
RootContainer
=
(
props
)
=>
{
const
RootContainer
=
props
=>
{
const
{
loading
}
=
props
;
useEffect
(()
=>
{
...
...
@@ -284,7 +295,7 @@ const RootContainer = (props) => {
};
if
(
finalConfig
.
prefixCls
)
{
Modal
.
config
({
ConfigProvider
.
config
({
rootPrefixCls
:
customPrefixCls
,
});
message
.
config
({
...
...
@@ -295,27 +306,45 @@ const RootContainer = (props) => {
});
}
return
React
.
createElement
(
Provider
,
{
store
:
store
,
},
React
.
createElement
(
ConnectedRouter
,
{
history
:
history
,
},
React
.
createElement
(
LocaleContainer
,
{
return
React
.
createElement
(
Provider
,
{
store
,
},
React
.
createElement
(
ConnectedRouter
,
{
history
,
},
React
.
createElement
(
LocaleContainer
,
{
prefixCls
:
customPrefixCls
,
},
React
.
createElement
(
ConfigProvider
,
{
},
React
.
createElement
(
ConfigProvider
,
{
prefixCls
:
customPrefixCls
,
},
React
.
createElement
(
Container
,
null
,
React
.
createElement
(
App
,
{
},
React
.
createElement
(
Container
,
null
,
React
.
createElement
(
App
,
{
loading
,
}))))));
}),
),
),
),
),
);
};
export
const
render
=
({
loading
})
=>
{
// eslint-disable-next-line react-hooks/rules-of-hooks
ReactDOM
.
render
(
<
RootContainer
loading
=
{
loading
}
/>, MOUNT_NODE
)
;
};
// updateTheme('#ff9600');
const
loader
=
(
loading
)
=>
render
({
loading
});
const
loader
=
loading
=>
render
({
loading
});
export
default
loader
;
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