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
P
pro-blocks
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
pro-blocks
Commits
6e65ecd5
Commit
6e65ecd5
authored
Dec 04, 2018
by
陈帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix reloadSW no trigger error
parent
8bc421a7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
25 deletions
+33
-25
.eslintignore
.eslintignore
+2
-1
src/global.js
src/global.js
+31
-24
No files found.
.eslintignore
View file @
6e65ecd5
/functions/mock/**
/scripts
/config
\ No newline at end of file
src/global.js
View file @
6e65ecd5
...
...
@@ -9,18 +9,7 @@ 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
=>
{
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
()
=>
{
const
reloadSW
=
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
;
...
...
@@ -42,6 +31,24 @@ window.addEventListener('sw.updated', e => {
// Refresh current page to use the updated HTML and other assets after SW has skiped waiting
window
.
location
.
reload
(
true
);
return
true
;
},
};
const
key
=
`open
${
Date
.
now
()}
`
;
const
btn
=
(
<
Button
type
=
"
primary
"
onClick
=
{()
=>
{
notification
.
close
(
key
);
reloadSW
();
}}
>
{
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
()
=>
{},
});
});
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