Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
e9e8775e
Commit
e9e8775e
authored
6 years ago
by
ιεΈ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use notification repalce modal for sw updated
parent
ac86837d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
src/global.js
src/global.js
+14
-6
No files found.
src/global.js
View file @
e9e8775e
import
{
Modal
,
message
}
from
'
antd
'
;
import
React
from
'
react
'
;
import
{
notification
,
Button
,
message
}
from
'
antd
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
// Notify user if offline now
...
...
@@ -8,11 +9,18 @@ window.addEventListener('sw.offline', () => {
// Pop up a prompt on the page asking the user if they want to use the latest version
window
.
addEventListener
(
'
sw.updated
'
,
e
=>
{
Modal
.
confirm
({
title
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated
'
}),
content
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.hint
'
}),
okText
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.ok
'
}),
onOk
:
async
()
=>
{
const
key
=
`open
${
Date
.
now
()}
`
;
const
btn
=
(
<
Button
type
=
"
primary
"
onClick
=
{()
=>
notification
.
close
(
key
)}
>
{
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.ok
'
})}
<
/Button
>
);
notification
.
open
({
message
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated
'
}),
description
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.hint
'
}),
btn
,
key
,
onClose
:
async
()
=>
{
// Check if there is sw whose state is waiting in ServiceWorkerRegistration
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
const
worker
=
e
.
detail
&&
e
.
detail
.
waiting
;
...
...
This diff is collapsed.
Click to expand it.
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