This commit is contained in:
底层用户 2022-03-22 20:29:15 +08:00
parent 52431d93b0
commit 2513963927
12 changed files with 114 additions and 28 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

BIN
img/icon/favicon_128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
img/icon/favicon_144.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
img/icon/favicon_32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

BIN
img/icon/favicon_64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -21,6 +21,14 @@
<script type="text/javascript"
src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/izitoast/1.4.0/js/iziToast.min.js">
</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>
<body>

View File

@ -107,18 +107,22 @@ $(function () {
})
})
//监听网页宽度
// window.addEventListener('load', function () {
// if (window.innerWidth <= 512) {
// $('.wd').attr('placeholder', '搜索');
// } else {
// $('.wd').attr('placeholder', '想要搜点什么');
// }
// window.addEventListener('resize', function () {
// if (window.innerWidth <= 512) {
// $('.wd').attr('placeholder', '搜索');
// } else {
// $('.wd').attr('placeholder', '想要搜点什么');
// }
// })
// })
// 检测浏览器是否支持SW
function registerServiceWorker() {
// 注册 service worker
return navigator.serviceWorker.register('./js/sw.js').then(registration => {
console.log('注册成功');
// 返回
return registration;
})
.catch(err => {
console.error('注册失败', err);
});
}
window.onload = function () {
//是否支持
if (!('serviceWorker' in navigator)) {
return;
}
registerServiceWorker()
}

View File

@ -232,7 +232,7 @@ function setBgImgInit() {
pictures[7] = './img/background8.webp';
pictures[8] = './img/background9.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]) //随机默认壁纸
break;
case "2":
@ -698,10 +698,7 @@ $(document).ready(function () {
});
// 快捷方式添加按钮点击
$("#set-quick").click(function (event) {
if ($(this).attr("class") === "on") {
closeSet();
} else {
$("#set-quick").click(function () {
openSet();
// 设置内容加载
@ -711,7 +708,6 @@ $(document).ready(function () {
//添加快捷方式
$("#set-quick-menu").trigger('click');
$(".set_quick_list_add").trigger('click');
}
});
// 修改默认搜索引擎

48
js/sw.js Normal file
View 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
View 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"
}
]
}