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
b72c6572
Commit
b72c6572
authored
Dec 01, 2021
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 优化token过期退出登陆
parent
87a06f9e
Pipeline
#39262
passed with stages
in 14 minutes 27 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
88 deletions
+11
-88
index.js
src/api/index.js
+5
-8
app.js
src/app.js
+4
-78
actions.js
src/containers/App/store/actions.js
+1
-1
index.js
src/pages/user/login/index.js
+1
-1
No files found.
src/api/index.js
View file @
b72c6572
import
{
Modal
,
notification
}
from
'antd'
;
import
{
instanceRequest
,
service
}
from
'@wisdom-utils/utils'
;
import
{
event
}
from
'microser-data'
;
import
{
actionCreators
}
from
'../containers/App/store'
;
import
AppService
from
'./service/base'
;
import
notificationService
from
'./service/notification'
;
const
{
warning
}
=
Modal
;
...
...
@@ -13,7 +14,7 @@ instanceRequest.transformRequestURL = function(url) {
return
url
;
}
if
(
window
.
globalConfig
&&
window
.
globalConfig
.
hasGateWay
&&
/^
\/(
cityinterface|CityInterface|CityServer|PandaInformatization
)
/
.
test
(
url
))
{
if
(
window
.
globalConfig
&&
window
.
globalConfig
.
hasGateWay
&&
/^
\/(
cityinterface|CityInterface|City
interface|City
Server|PandaInformatization
)
/
.
test
(
url
))
{
return
/
\/
CityInterface
\/
rest
\/
services.svc
\/
GetConfig/
.
test
(
url
)
?
url
?
/^
\/
GateWay/
.
test
(
url
)
?
url
:
'/GateWay'
+
url
:
'/GateWay'
+
url
:
'/GateWay'
+
url
;
}
return
url
;
...
...
@@ -49,10 +50,8 @@ instanceRequest.setErrorHandler(error => {
content
:
`
${
codeMessage
[
status
]}
`
,
centered
:
true
,
onOk
(
close
)
{
window
.
share
&&
window
.
share
.
event
&&
window
.
share
.
event
.
emit
(
'triggerLoginout'
);
close
();
event
.
emit
(
'event:logout'
);
close
();
},
});
}
...
...
@@ -71,8 +70,6 @@ instanceRequest.setErrorHandler(error => {
}
return
response
;
});
console
.
log
(
"instanceRequest"
,
instanceRequest
)
const
appService
=
service
(
AppService
);
const
noticeService
=
service
(
notificationService
);
export
{
appService
,
noticeService
};
src/app.js
View file @
b72c6572
...
...
@@ -21,10 +21,6 @@ import { params, Storeage } from 'kit_utils';
import
{
Provider
}
from
'react-redux'
;
import
{
history
}
from
'@wisdom-utils/runtime'
;
import
ErrorBoundary
from
'./components/ErrorBoundary'
;
import
{
useIntl
}
from
'@/locales/localeExports'
;
// import { ErrorBoundary } from '@ant-design/pro-utils';
import
defaultSettings
from
'../config/defaultSetting'
;
// import themePluginConfig from '../config/themePluginConfig';
import
{
appService
}
from
'./api'
;
import
{
updateTheme
}
from
'./common/helpers/settingColor'
;
...
...
@@ -38,8 +34,6 @@ import Login from './pages/user/login/login';
import
{
getToken
,
isString
}
from
'./utils/utils'
;
import
'./utils/event'
;
import
Cookies
from
'js-cookie'
;
const
isHttps
=
document
.
location
.
protocol
===
'https:'
;
const
{
pwa
}
=
defaultSettings
;
// eslint-disable-next-line no-restricted-globals
const
namespace
=
`__PANDA_STORE__
${
location
.
hostname
}
`
;
window
.
createStoreage
=
new
Storeage
(
namespace
);
...
...
@@ -232,77 +226,9 @@ initLocale();
window
.
share
&&
window
.
share
.
event
&&
window
.
share
.
event
.
on
(
'triggerMicro'
,
()
=>
{
initMicroApps
(
loader
,
store
);
});
event
.
on
(
'initConfig'
,
()
=>
{
event
.
on
(
'
event:
initConfig'
,
()
=>
{
initGlobalConfig
();
});
if
(
pwa
)
{
// const appPWA = window.i18n.getI18n('app');
window
.
addEventListener
(
'sw.offline'
,
()
=>
{
message
.
warning
(
useIntl
().
formatMessage
({
id
:
'app.pwa.offline'
}));
});
window
.
addEventListener
(
'sw.updated'
,
event
=>
{
const
e
=
event
;
const
reloadSW
=
async
()
=>
{
const
worker
=
e
.
detail
&&
e
.
detail
.
waiting
;
if
(
!
worker
)
{
return
true
;
}
await
new
Promise
((
resolve
,
reject
)
=>
{
const
channel
=
new
MessageChannel
();
channel
.
port1
.
onmessage
=
msgEvent
=>
{
if
(
msgEvent
.
data
.
error
)
{
reject
(
msgEvent
.
data
.
error
);
}
else
{
resolve
(
msgEvent
.
data
);
}
};
worker
.
postMessage
({
type
:
'skip-waiting'
},
[
channel
.
port2
]);
});
window
.
location
.
reload
(
true
);
return
true
;
};
const
key
=
`open
${
Date
.
now
()}
`
;
const
btn
=
(
<
Button
type
=
"primary"
onClick
=
{()
=>
{
notification
.
close
(
key
);
reloadSW
();
}}
>
{
useIntl
().
formatMessage
({
id
:
'app.pwa.serviceworker.updated.ok'
})}
<
/Button
>
);
notification
.
open
({
message
:
useIntl
().
formatMessage
({
id
:
'pwa.serviceworker.updated'
}),
description
:
useIntl
().
formatMessage
({
id
:
'pwa.serviceworker.updated.hint'
,
}),
btn
,
key
,
onClose
:
async
()
=>
null
,
});
});
}
else
if
(
'serviceWorker'
in
navigator
&&
isHttps
)
{
const
{
serviceWorker
}
=
navigator
;
if
(
serviceWorker
.
getRegistrations
)
{
serviceWorker
.
getRegistrations
().
then
(
sws
=>
{
sws
.
forEach
(
sw
=>
{
sw
.
unregister
();
});
});
}
serviceWorker
.
getRegistration
().
then
(
sw
=>
{
if
(
sw
)
sw
.
unregister
();
});
if
(
window
.
caches
&&
window
.
caches
.
keys
)
{
caches
.
keys
().
then
(
keys
=>
{
keys
.
forEach
(
key
=>
{
caches
.
delete
(
key
);
});
});
}
}
event
.
on
(
'event:logout'
,
()
=>
{
store
.
dispatch
(
actionCreators
.
logout
())
});
src/containers/App/store/actions.js
View file @
b72c6572
...
...
@@ -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
}
`
);
event
.
emit
(
'initConfig'
);
event
.
emit
(
'
event:
initConfig'
);
return
{
type
:
LOGINOUT
,
data
:
{
...
...
src/pages/user/login/index.js
View file @
b72c6572
...
...
@@ -6,7 +6,7 @@ import InfoLogin from './template/infoLogin';
import
Yulin
from
'./template/yulin'
;
/* eslint-disable */
export
default
()
=>
{
debugger
const
loginTemplate
=
window
.
globalConfig
&&
window
.
globalConfig
.
loginTemplate
;
switch
(
loginTemplate
)
{
case
'新春 - 智联.html'
:
...
...
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