wpa test
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 17 KiB |
BIN
img/icon/favicon_128.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
img/icon/favicon_144.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
img/icon/favicon_32.png
Normal file
After Width: | Height: | Size: 654 B |
BIN
img/icon/favicon_64.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
@ -21,6 +21,14 @@
|
|||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/izitoast/1.4.0/js/iziToast.min.js">
|
src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/izitoast/1.4.0/js/iziToast.min.js">
|
||||||
</script>
|
</script>
|
||||||
|
<!-- PWA -->
|
||||||
|
<link rel="manifest" href="manifest.json">
|
||||||
|
<!-- IE Out -->
|
||||||
|
<script>
|
||||||
|
if ( /*@cc_on!@*/ false || (!!window.MSInputMethodContext && !!document.documentMode)) window.location.href =
|
||||||
|
"https://www.imsyy.top/upgrade-your-browser/index.html?referrer=" + encodeURIComponent(window.location
|
||||||
|
.href);
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
34
js/main.js
@ -107,18 +107,22 @@ $(function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
//监听网页宽度
|
// 检测浏览器是否支持SW
|
||||||
// window.addEventListener('load', function () {
|
function registerServiceWorker() {
|
||||||
// if (window.innerWidth <= 512) {
|
// 注册 service worker
|
||||||
// $('.wd').attr('placeholder', '搜索');
|
return navigator.serviceWorker.register('./js/sw.js').then(registration => {
|
||||||
// } else {
|
console.log('注册成功');
|
||||||
// $('.wd').attr('placeholder', '想要搜点什么');
|
// 返回
|
||||||
// }
|
return registration;
|
||||||
// window.addEventListener('resize', function () {
|
})
|
||||||
// if (window.innerWidth <= 512) {
|
.catch(err => {
|
||||||
// $('.wd').attr('placeholder', '搜索');
|
console.error('注册失败', err);
|
||||||
// } else {
|
});
|
||||||
// $('.wd').attr('placeholder', '想要搜点什么');
|
}
|
||||||
// }
|
window.onload = function () {
|
||||||
// })
|
//是否支持
|
||||||
// })
|
if (!('serviceWorker' in navigator)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
registerServiceWorker()
|
||||||
|
}
|
@ -232,7 +232,7 @@ function setBgImgInit() {
|
|||||||
pictures[7] = './img/background8.webp';
|
pictures[7] = './img/background8.webp';
|
||||||
pictures[8] = './img/background9.webp';
|
pictures[8] = './img/background9.webp';
|
||||||
pictures[9] = './img/background10.webp';
|
pictures[9] = './img/background10.webp';
|
||||||
var rd = Math.floor(Math.random()*10);
|
var rd = Math.floor(Math.random() * 10);
|
||||||
$('#bg').attr('src', pictures[rd]) //随机默认壁纸
|
$('#bg').attr('src', pictures[rd]) //随机默认壁纸
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
@ -698,10 +698,7 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 快捷方式添加按钮点击
|
// 快捷方式添加按钮点击
|
||||||
$("#set-quick").click(function (event) {
|
$("#set-quick").click(function () {
|
||||||
if ($(this).attr("class") === "on") {
|
|
||||||
closeSet();
|
|
||||||
} else {
|
|
||||||
openSet();
|
openSet();
|
||||||
|
|
||||||
// 设置内容加载
|
// 设置内容加载
|
||||||
@ -711,7 +708,6 @@ $(document).ready(function () {
|
|||||||
//添加快捷方式
|
//添加快捷方式
|
||||||
$("#set-quick-menu").trigger('click');
|
$("#set-quick-menu").trigger('click');
|
||||||
$(".set_quick_list_add").trigger('click');
|
$(".set_quick_list_add").trigger('click');
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 修改默认搜索引擎
|
// 修改默认搜索引擎
|
||||||
|
48
js/sw.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
const CURCACHE = 'CURCACHE_test_1'
|
||||||
|
const RUNTIME = 'runtime';
|
||||||
|
const CURCACHE_URLS = [
|
||||||
|
'./',
|
||||||
|
'index.html'
|
||||||
|
]
|
||||||
|
self.addEventListener('install', e => {
|
||||||
|
e.waitUntil(
|
||||||
|
//存储缓存路径对应的资源
|
||||||
|
caches.open(CURCACHE).then(cache => {
|
||||||
|
cache.addAll(CURCACHE_URLS)
|
||||||
|
}).then(
|
||||||
|
self.skipWaiting()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
//代理请求,使用缓存,请求发送之前
|
||||||
|
self.addEventListener('fetch', e => {
|
||||||
|
e.respondWith(
|
||||||
|
//缓存是否匹配
|
||||||
|
caches.match(e.request).then(function (response) {
|
||||||
|
if (response != null) {
|
||||||
|
//命中缓存返回缓存,结束请求
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
//未命中缓存,正常请求
|
||||||
|
return fetch(e.request.url)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
//假设上个版本的key为precache_test_2 反正不等于CURCACHE
|
||||||
|
self.addEventListener('activate', e => {
|
||||||
|
e.waitUntil(
|
||||||
|
//遍历当前缓存keys
|
||||||
|
caches.keys().then(cacheNames => {
|
||||||
|
return Promise.all(
|
||||||
|
cacheNames.map(function (cacheName) {
|
||||||
|
//是否等于当前key,保留自己
|
||||||
|
if (cacheName !== CURCACHE) {
|
||||||
|
return caches.delete(cacheName);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}).then(() => self.clients.claim())
|
||||||
|
)
|
||||||
|
})
|
30
manifest.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "Snavigation",
|
||||||
|
"short_name": "Snavigation",
|
||||||
|
"display": "standalone",
|
||||||
|
"start_url": "/",
|
||||||
|
"theme_color": "#efefef",
|
||||||
|
"background_color": "#333333",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "img/icon/favicon_32.png",
|
||||||
|
"sizes": "32x32",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "img/icon/favicon_64.png",
|
||||||
|
"sizes": "64x64",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "img/icon/favicon_128.png",
|
||||||
|
"sizes": "128x128",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "img/icon/favicon_144.png",
|
||||||
|
"sizes": "144x144",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|