mirror of
https://github.com/caojiezi2003/Snavigation.git
synced 2024-11-23 10:59:46 +00:00
fix
This commit is contained in:
parent
2513963927
commit
944d1d4efe
@ -21,8 +21,6 @@
|
||||
<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 =
|
||||
@ -77,7 +75,7 @@
|
||||
<i id="icon-se" class="iconfont icon-baidu"></i>
|
||||
</div>
|
||||
<input class="wd" type="text" name="wd" placeholder="想要搜点什么" onfocus="this.placeholder=''"
|
||||
onblur="this.placeholder='想要搜点什么'" autocomplete="off" required="required">
|
||||
onblur="this.placeholder='想要搜点什么'" autocomplete="off">
|
||||
<div class="sou-button">
|
||||
<button class="s" id="s-button">
|
||||
<i id="icon-sou" class="iconfont icon-sousuo"></i>
|
||||
@ -524,7 +522,6 @@
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="./js/main.js"></script>
|
||||
<script type="text/javascript" src="./js/set.js"></script>
|
||||
<script type="text/javascript" src="./js/time.js"></script>
|
||||
<script type="text/javascript" src="./js/js.cookie.js"></script>
|
||||
</body>
|
||||
|
||||
|
73
js/main.js
73
js/main.js
@ -30,11 +30,25 @@ window.addEventListener('load', function () {
|
||||
|
||||
}, false)
|
||||
|
||||
//屏蔽浏览器默认右键
|
||||
// document.oncontextmenu = function () {
|
||||
// undefined
|
||||
// return false;
|
||||
// }
|
||||
//进入问候
|
||||
now = new Date(), hour = now.getHours()
|
||||
if (hour < 6) {
|
||||
var hello = "凌晨好";
|
||||
} else if (hour < 9) {
|
||||
var hello = "早上好";
|
||||
} else if (hour < 12) {
|
||||
var hello = "上午好";
|
||||
} else if (hour < 14) {
|
||||
var hello = "中午好";
|
||||
} else if (hour < 17) {
|
||||
var hello = "下午好";
|
||||
} else if (hour < 19) {
|
||||
var hello = "傍晚好";
|
||||
} else if (hour < 22) {
|
||||
var hello = "晚上好";
|
||||
} else {
|
||||
var hello = "夜深了";
|
||||
}
|
||||
|
||||
//获取时间
|
||||
var t = null;
|
||||
@ -107,22 +121,33 @@ $(function () {
|
||||
})
|
||||
})
|
||||
|
||||
// 检测浏览器是否支持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()
|
||||
}
|
||||
//控制台输出
|
||||
var styleTitle1 = `
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: rgb(244,167,89);
|
||||
`
|
||||
var styleTitle2 = `
|
||||
font-size:12px;
|
||||
color: rgb(244,167,89);
|
||||
`
|
||||
var styleContent = `
|
||||
color: rgb(30,152,255);
|
||||
`
|
||||
var title1 = 'Snavigation'
|
||||
var title2 = `
|
||||
_____ __ __ _______ ____ __
|
||||
|_ _| \\/ |/ ____\\ \\ / /\\ \\ / /
|
||||
| | | \\ / | (___ \\ \\_/ / \\ \\_/ /
|
||||
| | | |\\/| |\\___ \\ \\ / \\ /
|
||||
_| |_| | | |____) | | | | |
|
||||
|_____|_| |_|_____/ |_| |_|
|
||||
`
|
||||
var content = `
|
||||
版 本 号:1.0
|
||||
更新日期:2022-03-22
|
||||
|
||||
Github: https://github.com/imsyy/Snavigation
|
||||
`
|
||||
console.log(`%c${title1} %c${title2}
|
||||
%c${content}`, styleTitle1, styleTitle2, styleContent)
|
10
js/set.js
10
js/set.js
@ -635,11 +635,21 @@ $(document).ready(function () {
|
||||
$(".search-engine").slideUp(160);
|
||||
});
|
||||
|
||||
$("#s-button").focus(function () {
|
||||
focusWd();
|
||||
keywordReminder();
|
||||
$(".search-engine").slideUp(160);
|
||||
});
|
||||
|
||||
// 搜索框失去焦点事件
|
||||
$(".wd").blur(function () {
|
||||
blurWd();
|
||||
});
|
||||
|
||||
$("#s-button").blur(function () {
|
||||
blurWd();
|
||||
});
|
||||
|
||||
// 自动提示( 调用百度 api )
|
||||
$('.wd').keyup(function (event) {
|
||||
var key = event.keyCode;
|
||||
|
48
js/sw.js
48
js/sw.js
@ -1,48 +0,0 @@
|
||||
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())
|
||||
)
|
||||
})
|
18
js/time.js
18
js/time.js
@ -1,18 +0,0 @@
|
||||
now = new Date(), hour = now.getHours()
|
||||
if (hour < 6) {
|
||||
var hello = "凌晨好";
|
||||
} else if (hour < 9) {
|
||||
var hello = "早上好";
|
||||
} else if (hour < 12) {
|
||||
var hello = "上午好";
|
||||
} else if (hour < 14) {
|
||||
var hello = "中午好";
|
||||
} else if (hour < 17) {
|
||||
var hello = "下午好";
|
||||
} else if (hour < 19) {
|
||||
var hello = "傍晚好";
|
||||
} else if (hour < 22) {
|
||||
var hello = "晚上好";
|
||||
} else {
|
||||
var hello = "夜深了";
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user