Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
html
/
MeteorologicalBureau
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5fc572da
authored
Jul 02, 2020
by
fengfan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ios
parent
17788ed7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
ipadCtr/index.html
+25
-0
ipadCtr/serviceWorker.js
+61
-0
No files found.
ipadCtr/index.html
View file @
5fc572da
...
...
@@ -3,6 +3,10 @@
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1.0"
>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
/>
<meta
name=
"apple-mobile-app-status-bar-style"
content=
"black"
/>
<!-- <link rel="apple-touch-icon" href="icon.png" /> -->
<!-- <link rel="apple-touch-icon-precomposed" href="icon.png" /> -->
<title>
ipad
</title>
</head>
<body>
...
...
@@ -10,3 +14,24 @@
<!-- built files will be auto injected -->
</body>
</html>
<script>
// https://www.jianshu.com/p/d2fd27b1b6f1
/* 判断当前浏览器是否支持serviceWorker */
// if ('serviceWorker' in navigator) {
// /* 当页面加载完成就创建一个serviceWorker */
// window.addEventListener('load', function () {
// /* 创建并指定对应的执行内容 */
// /* scope 参数是可选的,可以用来指定你想让 service worker 控制的内容的子目录。 在这个例子里,我们指定了 '/',表示 根网域下的所有内容。这也是默认值。 */
// navigator.serviceWorker.register('/static/serviceWorker.js')
// .then(function (registration) {
// console.log('ServiceWorker registration successful with scope: ', registration.scope);
// })
// .catch(function (err) {
// console.log('ServiceWorker registration failed: ', err);
// });
// });
// }
</script>
ipadCtr/serviceWorker.js
0 → 100644
View file @
5fc572da
// <script>
// /* 判断当前浏览器是否支持serviceWorker */
// if ('serviceWorker' in navigator) {
// /* 当页面加载完成就创建一个serviceWorker */
// window.addEventListener('load', function () {
// /* 创建并指定对应的执行内容 */
// /* scope 参数是可选的,可以用来指定你想让 service worker 控制的内容的子目录。 在这个例子里,我们指定了 '/',表示 根网域下的所有内容。这也是默认值。 */
// navigator.serviceWorker.register('/serviceWorker.js')
// .then(function (registration) {
// console.log('ServiceWorker registration successful with scope: ', registration.scope);
// })
// .catch(function (err) {
// console.log('ServiceWorker registration failed: ', err);
// });
// });
// }
// </script>
this
.
addEventListener
(
'install'
,
function
(
event
)
{
/* 通过这个方法可以防止缓存未完成,就关闭serviceWorker */
event
.
waitUntil
(
/* 创建一个名叫V1的缓存版本 */
caches
.
open
(
'v1'
).
then
(
function
(
cache
)
{
/* 指定要缓存的内容,地址为相对于跟域名的访问路径 */
return
cache
.
addAll
([
'/index.html'
,
'/static/js/manifest.js'
,
'/static/js/vendor.js'
,
'/static/js/app.js'
,
'/static/css/app.css'
,
'/static/img/content.png'
,
'/static/img/back.png'
,
'/static/img/btn-light.png'
,
'/static/img/bg.jpg'
,
'/static/img/nav.png'
,
'/static/img/sidebar.png'
,
'/static/img/select.png'
,
'/static/img/btn-light.png'
,
]);
})
);
});
// /* 注册fetch事件,拦截全站的请求 */
this
.
addEventListener
(
'fetch'
,
function
(
event
)
{
// event.respondWith(
// // magic goes here
// /* 在缓存中匹配对应请求资源直接返回 */
// caches.match(event.request)
// );
});
\ No newline at end of file
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