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
1cc31222
Commit
1cc31222
authored
Dec 19, 2021
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加免密登陆
parent
47aedd6a
Pipeline
#40604
passed with stages
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
172 additions
and
47 deletions
+172
-47
index.js
src/containers/App/index.js
+1
-1
actions.js
src/containers/App/store/actions.js
+1
-1
reducer.js
src/containers/App/store/reducer.js
+3
-3
BasicLayout.js
src/layouts/BasicLayout.js
+1
-1
BasicLayout1.js
src/layouts/BasicLayout1.js
+17
-19
BlankLayout.js
src/layouts/BlankLayout.js
+2
-1
micro.js
src/micro.js
+2
-1
login.js
src/pages/user/login/login.js
+75
-19
noSecret.js
src/pages/user/login/noSecret.js
+63
-0
config.js
src/routes/config.js
+7
-1
No files found.
src/containers/App/index.js
View file @
1cc31222
...
...
@@ -47,7 +47,7 @@ function App(props) {
<
/Helmet
>
<
Router
basename
=
{
config
.
base
||
pkg
.
name
.
toLocaleLowerCase
()
||
''
}
>
<
Switch
>
{
renderRoutes
(
dyRoutes
(
props
.
menu
||
[]
).
routes
)}
{
renderRoutes
(
dyRoutes
(
props
.
menu
||
[],
props
.
global
.
layout
).
routes
)}
<
/Switch
>
<
/Router
>
<
/
>
...
...
src/containers/App/store/actions.js
View file @
1cc31222
...
...
@@ -204,7 +204,7 @@ export function logout(data) {
localStorage
.
removeItem
(
'access_token'
);
// eslint-disable-next-line no-undef,no-restricted-globals
createStoreage
.
remove
(
`__PANDA_STORE__
${
location
.
hostname
}
`
);
createStoreage
.
remove
(
`__PANDA_STORE__MICRO_
${
location
.
hostname
}
`
)
return
{
type
:
LOGINOUT
,
data
:
{
...
...
src/containers/App/store/reducer.js
View file @
1cc31222
...
...
@@ -93,7 +93,6 @@ const appReducer = (state = initialState, action) => {
window
.
__INITIAL_STATE__
.
mdi
=
'SDI'
;
window
.
__INITIAL_STATE__
.
menu
=
'banner-left'
;
window
.
globalConfig
=
AppConfig
(
window
.
__INITIAL_STATE__
);
// eslint-disable-next-line no-undef
createStoreage
.
set
(
'globalConfig'
,
window
.
globalConfig
);
// eslint-disable-next-line no-undef,no-case-declarations
...
...
@@ -111,13 +110,14 @@ const appReducer = (state = initialState, action) => {
flatMenu
=
generFlatRoutes
(
generMenu
||
[],
null
,
null
,
modulePkg
);
}
const
home
=
flatMenu
.
find
(
item
=>
{
let
path
=
item
.
path
.
split
(
"|"
);
let
path
=
decodeURI
(
item
.
path
)
.
split
(
"|"
);
let
currentPath
=
path
[
0
];
if
(
/^
\/
/
.
test
(
currentPath
))
{
currentPath
=
currentPath
.
replace
(
/^
\/
/
,
''
);
}
return
currentPath
===
homepage
return
currentPath
===
decodeURI
(
homepage
)
});
let
currentMenuIndex
=
0
;
...
...
src/layouts/BasicLayout.js
View file @
1cc31222
...
...
@@ -463,7 +463,7 @@ const BasicLayout = props => {
useEffect
(()
=>
{
siteAction
.
setGlobalConfig
(
props
.
global
);
if
(
!
Cookies
.
get
(
'token'
))
{
debugger
let
client
=
props
.
global
.
get
(
'client'
);
client
=
_
.
isNull
(
client
)
||
_
.
isUndefined
(
client
)
||
client
===
'undefined'
?
client
:
'city'
;
history
.
replace
(
`/user/login?client=
${
client
}
`
);
...
...
src/layouts/BasicLayout1.js
View file @
1cc31222
...
...
@@ -501,20 +501,9 @@ const BasicLayout = props => {
return
(
<
SecurityLayout
loading
>
{
collapse
&&
props
.
global
.
loginTemplate
===
'新春 - 智联.html'
?
null
:
(
props
.
global
.
loginTemplate
===
'新春 - 智联.html'
&&
(
<
img
src
=
{
logo
}
style
=
{{
width
:
'120px'
,
position
:
'absolute'
,
bottom
:
'40px'
,
zIndex
:
500
,
left
:
'12px'
,
}}
/>
)
)}
<
div
className
=
{
classNames
(
layoutStyles
.
basicLayout
)}
>
{
props
.
global
.
layout
!==
'blank'
?
(
<
div
className
=
{
classNames
(
layoutStyles
.
basicLayout
)}
>
<
div
className
=
{
layoutStyles
[
'layout-has-slider'
]}
style
=
{{
minHeight
:
'100%'
}}
>
<
div
style
=
{{
width
:
collapse
?
'48px'
:
'80px'
,
...
...
@@ -661,10 +650,6 @@ const BasicLayout = props => {
renderRoutes
(
props
.
route
.
routes
)
}
{
/* {
!window.location.pathname.startsWith('/civbase/civweb4') && <CreateBaseMap options={{type: 'ArcgisMap'}}/>
} */
}
<
div
id
=
"micro-container"
className
=
"subapp-container"
>
{
/*<CreateBaseMap/>*/
}
{
props
.
children
}
...
...
@@ -674,7 +659,20 @@ const BasicLayout = props => {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div>
)
:
(
<
PageContainer
style
=
{{
paddingTop
:
'0px'
,
height
:
'100%'
}}
>
{
renderRoutes
(
props
.
route
.
routes
)
}
<
div
id
=
"micro-container"
className
=
"subapp-container"
>
{
/*<CreateBaseMap/>*/
}
{
props
.
children
}
<
/div
>
<
/PageContainer
>
)
}
<
/SecurityLayout>
)
;
};
const
mapStateToProps
=
state
=>
({
...
...
src/layouts/BlankLayout.js
View file @
1cc31222
...
...
@@ -2,4 +2,4 @@ import React from 'react';
const
Layout
=
({
children
})
=>
<>
{
children
}
<
/>
;
export
default
Layout
;
export
default
Layout
;
\ No newline at end of file
src/micro.js
View file @
1cc31222
...
...
@@ -36,7 +36,7 @@ export const initMicroApps = (loader, store) => {
/* eslint-disable */
const
config
=
createStoreage
.
get
(
'globalConfig'
);
const
application
=
config
.
products
||
[];
const
application
=
config
&&
config
.
products
||
[];
let
products
=
[];
application
&&
Array
.
isArray
(
application
)
&&
application
.
length
>
0
&&
application
.
map
(
item
=>
{
products
.
push
({
...
...
@@ -182,6 +182,7 @@ export const defaultApp = () => {
// eslint-disable-next-line no-undef
const
config
=
createStoreage
.
get
(
'globalConfig'
);
if
(
config
&&
config
.
token
)
{
debugger
const
basePath
=
config
.
homepage
!==
''
&&
FILTER_FOLER_REG
.
test
(
config
.
homepage
)
?
'civweb4'
:
'civweb4'
;
if
(
config
&&
config
.
home
)
{
setDefaultMountApp
(
`/civbase/
${
config
.
home
.
path
.
replace
(
/^
\/
/
,
''
)}
`
);
...
...
src/pages/user/login/login.js
View file @
1cc31222
import
'kit_logger'
;
import
{
params
}
from
'kit_utils'
;
import
{
message
}
from
'antd'
;
import
{
decode
,
encode
}
from
'js-base64'
;
import
Cookies
from
'js-cookie'
;
...
...
@@ -33,16 +33,25 @@ class Login {
}
init
()
{
const
self
=
this
;
this
.
loginFailed
=
false
;
this
.
guid
=
Math
.
round
(
Math
.
random
()
*
10000
+
Date
.
now
()).
toString
(
16
);
this
.
redirect_state
=
Cookies
.
get
(
'redirect_state'
);
const
token
=
this
.
globalConfig
.
initToken
||
Cookies
.
get
(
'token'
);
let
{
ddCode
}
=
this
.
globalConfig
;
const
{
loginName
}
=
this
.
globalConfig
;
const
{
password
}
=
this
.
globalConfig
;
let
{
loginName
}
=
this
.
globalConfig
;
let
{
password
}
=
this
.
globalConfig
;
loginName
=
params
.
getParams
(
'loginName'
)
?
params
.
getParams
(
'loginName'
):
loginName
;
const
redirect
=
params
.
getParams
(
'redirect'
);
if
(
redirect
)
{
this
.
globalConfig
.
homepage
=
redirect
;
this
.
globalConfig
.
layout
=
'blank'
;
}
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
password
=
params
.
getParams
(
'password'
)
?
params
.
getParams
(
'password'
):
password
;
const
loginMode
=
Cookies
.
get
(
'loginMode'
)
||
null
;
if
(
loginMode
&&
loginMode
===
'iotWechat'
)
ddCode
=
null
;
const
self
=
this
;
// self.qrcodeLogin(self.globalConfig.qrcodeData.code);
if
(
token
)
{
self
.
getToweb
(
token
);
...
...
@@ -52,6 +61,7 @@ class Login {
}
else
if
(
ddCode
&&
loginMode
===
'qywx'
)
{
self
.
qywxLoginIn
(
ddCode
);
}
else
if
(
!!
loginName
&&
!!
password
)
{
self
.
otherLoginIn
(
loginName
,
password
);
}
else
if
(
self
.
globalConfig
.
qrcodeData
&&
...
...
@@ -199,6 +209,7 @@ class Login {
'request.preventCache'
:
Date
.
now
(),
})
.
then
(
response
=>
{
const
result
=
response
&&
response
.
code
===
SERVICE_INTERFACE_SUCCESS_CODE
?
Array
.
isArray
(
response
.
data
)
...
...
@@ -206,10 +217,12 @@ class Login {
:
[]
:
response
;
if
(
result
&&
result
.
length
>
0
)
{
self
.
globalConfig
=
Object
.
assign
(
self
.
globalConfig
,
result
.
shift
(),
{
const
config
=
result
.
shift
();
self
.
globalConfig
=
Object
.
assign
(
self
.
globalConfig
,
config
,
{
theme
:
self
.
globalConfig
.
theme
,
menu
:
self
.
globalConfig
.
menu
,
style
:
self
.
globalConfig
.
style
,
homepage
:
params
.
getParams
(
'redirect'
)
||
self
.
globalConfig
.
homepage
||
config
.
homepage
});
if
(
self
.
globalConfig
.
hasOwnProperty
(
'webConfig'
))
{
...
...
@@ -301,6 +314,7 @@ class Login {
}
})
.
catch
(
error
=>
{
console
.
log
(
error
);
// Logger.log(error);
this
.
handleLoginError
();
// Logger.log('获取网络配置失败');
...
...
@@ -394,6 +408,7 @@ class Login {
}
goLogin
()
{
debugger
if
(
this
.
globalConfig
.
style
===
'ios'
&&
this
.
globalConfig
.
loginTemplate
===
'IOSCloud.html'
...
...
@@ -570,8 +585,8 @@ class Login {
}
otherLoginIn
(
usr
,
pwd
)
{
const
uesrName
=
decode
(
usr
.
substring
(
0
,
usr
.
length
-
3
));
const
password
=
decode
(
pwd
.
substring
(
0
,
pwd
.
length
-
3
));
//
const uesrName = decode(usr.substring(0, usr.length - 3));
//
const password = decode(pwd.substring(0, pwd.length - 3));
const
self
=
this
;
// eslint-disable-next-line no-undef
appService
...
...
@@ -579,16 +594,20 @@ class Login {
f
:
'json'
,
expiration
:
this
.
globalConfig
.
expiration
,
// token过期时间(单位:秒)
client
:
'referer'
,
username
:
u
esrName
,
password
:
sha1
(
p
asswor
d
).
toUpperCase
(),
username
:
u
sr
,
password
:
sha1
(
p
w
d
).
toUpperCase
(),
referer
:
this
.
globalConfig
.
client
,
skipMenuTest
:
1
,
generateType
:
'pandaoa'
})
.
then
(
response
=>
{
debugger
self
.
globalConfig
.
layout
=
'blank'
;
if
(
response
&&
response
.
token
)
{
const
tk
=
response
.
token
;
this
.
globalConfig
.
token
=
tk
;
self
.
globalConfig
.
token
=
tk
;
// eslint-disable-next-line no-undef,no-debugger
getUserInfo
(
{
token
:
tk
,
...
...
@@ -600,17 +619,54 @@ class Login {
)
// eslint-disable-next-line no-shadow
.
then
(
response
=>
{
if
(
response
&&
response
.
errMsg
)
{
this
.
globalConfig
.
userInfo
=
{};
if
(
response
.
data
.
Groups
&&
response
.
data
.
Groups
instanceof
Array
&&
response
.
data
.
Groups
.
length
)
{
this
.
globalConfig
.
userInfo
.
Groups
=
response
.
data
.
Groups
;
try
{
if
(
response
&&
!
response
.
errMsg
)
{
self
.
globalConfig
.
userInfo
=
Object
.
assign
(
{},
response
,
self
.
globalConfig
.
userInfo
,
);
if
(
response
.
hasOwnProperty
(
'data'
))
{
self
.
globalConfig
.
userInfo
=
{
...
self
.
globalConfig
.
userInfo
,
...
response
.
data
}
}
const
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
24
*
60
*
60
*
1000
);
// date = date.toGMTString();
const
encodeSite
=
encode
(
encodeURIComponent
(
response
.
site
));
Cookies
.
set
(
'site'
,
encodeSite
,
{
expires
:
date
,
path
:
'/'
,
});
Cookies
.
set
(
'token'
,
tk
,
{
expires
:
date
,
path
:
'/'
,
})
// self.globalConfig.Industry = industry;
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
const
loginSite
=
{};
loginSite
[
tk
]
=
response
.
site
;
// Cookie.set()
localStorage
.
setItem
(
'loginSite'
,
JSON
.
stringify
(
loginSite
));
self
.
writeLogs
();
self
.
getIndustry
(
false
,
tk
);
}
else
{
message
.
error
(
response
.
errMsg
);
if
(
self
.
goLogin
())
{
return
false
;
}
// self.handleLoginError(failCallback);
}
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
self
.
getUserInfoAndConfig
();
}
catch
(
error
)
{
console
.
log
(
error
);
if
(
self
.
goLogin
())
{
return
false
;
}
// self.handleLoginError(failCallback);
}
});
}
else
{
...
...
src/pages/user/login/noSecret.js
0 → 100644
View file @
1cc31222
import
'kit_utils/lib/format'
;
import
React
,
{
forwardRef
,
useEffect
,
useRef
,
useState
}
from
'react'
;
import
{
params
}
from
'kit_utils'
;
import
{
connect
}
from
'react-redux'
;
import
{
useHistory
,
withRouter
}
from
'@wisdom-utils/runtime'
;
import
{
actionCreators
}
from
'@/containers/App/store'
;
import
LoginAction
from
'./login'
;
const
Login
=
forwardRef
((
props
,
_ref
)
=>
{
const
history
=
useHistory
();
const
[
action
,
setAction
]
=
useState
(
()
=>
new
LoginAction
(
Object
.
assign
({},
props
,
{
history
}),
()
=>
{},
true
),
);
useEffect
(()
=>
{
action
.
globalConfig
=
props
.
global
;
},
[
props
.
global
]);
useEffect
(()
=>
{
action
&&
action
.
events
.
on
(
'loginSuccess'
,
event
=>
{
//http://127.0.0.1:8080/civbase/civweb4/
// props.updateConfig(Object.assign({}, props.global, {
// homepage: params.getParams('redirect')
// }));
// props.history.push('/' + params.getParams('redirect'))
props
.
history
.
push
(
`/?client=
${
props
.
global
.
client
}
`
);
window
.
share
.
event
.
emit
(
'triggerMicro'
,
props
.
global
);
});
},
[
props
.
globalConfig
&&
props
.
globalConfig
.
userInfo
])
// action &&
// action.events.on('loginError', event => {
// // setVisible(false);
// // setSubmitting(false);
// });
return
<
div
>
{
props
.
children
}
<
/div>
;
});
const
mapStateToProps
=
state
=>
({
global
:
state
.
getIn
([
'global'
,
'globalConfig'
]),
loginMode
:
state
.
getIn
([
'global'
,
'loginMode'
]),
});
const
mapDispatchToProps
=
dispatch
=>
({
updateConfig
(
config
)
{
dispatch
(
actionCreators
.
getConfig
(
config
));
},
createContext
(
data
)
{
dispatch
(
actionCreators
.
createContext
(
data
));
},
updateLoginMode
(
mode
)
{
dispatch
(
actionCreators
.
changeLoginMode
(
mode
));
},
updateCurrentIndex
(
index
)
{
dispatch
(
actionCreators
.
updateCurrentIndex
(
index
));
},
});
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
,
)(
Login
);
src/routes/config.js
View file @
1cc31222
...
...
@@ -6,8 +6,9 @@ import UserLayout from '../layouts/UserLayout';
import
BootPage
from
'../pages/bootpage'
;
import
Login
from
'../pages/user/login'
;
import
CommonMenu
from
'../pages/commonMenu'
;
import
NoSecret
from
'../pages/user/login/noSecret'
;
export
const
dyRoutes
=
routes
=>
{
export
const
dyRoutes
=
(
routes
,
layout
)
=>
{
// eslint-disable-next-line no-shadow
const
dyRoutes
=
routes
||
[];
return
{
...
...
@@ -21,6 +22,11 @@ export const dyRoutes = routes => {
path
:
'/user/login'
,
component
:
Login
,
},
{
name
:
'noscret'
,
path
:
'/user/noscret'
,
component
:
NoSecret
}
],
},
{
...
...
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