Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
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
Dec 01, 2018
by
ιεΈ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use notification repalce modal for sw updated
parent
ac86837d
Changes
1
Show 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
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
// Notify user if offline now
// Notify user if offline now
...
@@ -8,11 +9,18 @@ window.addEventListener('sw.offline', () => {
...
@@ -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
// Pop up a prompt on the page asking the user if they want to use the latest version
window
.
addEventListener
(
'
sw.updated
'
,
e
=>
{
window
.
addEventListener
(
'
sw.updated
'
,
e
=>
{
Modal
.
confirm
({
const
key
=
`open
${
Date
.
now
()}
`
;
title
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated
'
}),
const
btn
=
(
content
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.hint
'
}),
<
Button
type
=
"
primary
"
onClick
=
{()
=>
notification
.
close
(
key
)}
>
okText
:
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.ok
'
}),
{
formatMessage
({
id
:
'
app.pwa.serviceworker.updated.ok
'
})}
onOk
:
async
()
=>
{
<
/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
// Check if there is sw whose state is waiting in ServiceWorkerRegistration
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
const
worker
=
e
.
detail
&&
e
.
detail
.
waiting
;
const
worker
=
e
.
detail
&&
e
.
detail
.
waiting
;
...
...
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