This commit is contained in:
186526 2021-04-29 18:29:50 +08:00
parent 1bd7c6c62c
commit d01ab1522b
Signed by untrusted user: 186526
GPG Key ID: C7EB1E6B8CC5E51D
6 changed files with 120 additions and 102 deletions

View File

@ -7,13 +7,13 @@ steps:
image: node:lts-buster
commands:
- apt-get update -y && apt-get install git -y
- yarn install
- yarn init-build
- yarn drone-build
- name: git-push
image: appleboy/drone-git-push
settings:
path: "public/"
path: "./public/"
force: true
ssh_key:
from_secret: ssh_key

View File

@ -1,7 +1,7 @@
# blog.186526.xyz
Use GPL-3.0 open source on git.186526.xyz
Unless otherwise specified, the articles will be signed-non-commercial use-shared in the same way
Use GPL-3.0 open source on git.186526.xyz.
Unless otherwise specified, the articles will be signed-non-commercial use-shared (CC BY-NC-SA 4.0) in the same way.
在git.186526.xyz上使用GPL-3.0的开源
除非另有说明,否则文章将以相同方式使用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议
在git.186526.xyz上使用GPL-3.0的开源
除非另有说明,否则文章将以相同方式使用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议

View File

@ -3,16 +3,17 @@
"version": "0.0.0",
"private": true,
"scripts": {
"init-build": "yarn;yarn --cwd ./themes/suka",
"build": "hexo generate",
"clean": "hexo clean",
"deploy": "hexo deploy",
"server": "hexo server",
"build-cloudflare": "yarn;yarn --cwd ./themes/suka;hexo generate;node cleancache.js",
"vercel-build": "yarn build-cloudflare",
"drone-build": "yarn;yarn --cwd ./themes/suka;hexo generate"
"build-cloudflare": "yarn build",
"vercel-build": "yarn build;node cleancache.js",
"drone-build": "yarn build"
},
"hexo": {
"version": "5.3.0"
"version": "5.4.0"
},
"dependencies": {
"autoprefixer": "^10.2.5",
@ -41,4 +42,4 @@
"spectre.css": "^0.5.9",
"yarn": "^1.22.10"
}
}
}

View File

@ -164,7 +164,7 @@ window.addEventListener("load", () => {
由于在同一页面中,同时只能存在一个 `Service Worker`,所以我们需要考虑到 `Service Worker` 的更新情况。
你可以通过监听 `navigator.serviceWorker``controllerchange` 时间来更新 `Service Worker`
你可以通过监听 `navigator.serviceWorker``controllerchange` 事件来更新 `Service Worker`
```js
window.addEventListener("load", () => {

View File

@ -26,13 +26,13 @@ async function main() {
}
setTimeout(function () {
globalThis.buildEnvironment = a;
console.log(globalThis.buildEnvironment);
},100);
}));
}else{
return `Amazon Linux 2 (Karoo) @ Node.js ${process.version}`;
}
})()
console.log(globalThis.buildEnvironment);
}
main();

View File

@ -1,101 +1,118 @@
(function () {
if (typeof globalThis === 'undefined') {
var globalThis = window;
}
console.log('\n %c 186526\'s Blog | © 186526 \n', 'color: #fff; background: #444; padding:5px 0;');
window.addEventListener("load", () => {
whenAvailable("Pjax", () => {
const pjax = new Pjax({
elements: "a:not([target=_blank])",
selectors: [
"title",
"meta[name=description]",
".pjax",
],
cacheBust: !1
});
window.addEventListener("load", function () {
whenAvailable("Pjax", function () {
var pjax = new Pjax({
elements: "a:not([target=_blank])",
selectors: ["title", "meta[name=description]", ".pjax"],
cacheBust: !1
});
document.addEventListener("pjax:send", send);
document.addEventListener("pjax:success", suc);
});
document.addEventListener("pjax:send", send);
document.addEventListener("pjax:success", suc);
});
window.addEventListener('load', () => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/sw.js', {
scope: '/',
})
.then(function (registration) {
console.log(
'ServiceWorker registration successful with scope: ',
registration.scope,
);
})
.catch(function (err) {
console.warn('ServiceWorker registration failed: ', err);
});
navigator.serviceWorker.addEventListener('controllerchange', () => {
let d = document.querySelector("title");
d.innerText = "Need update Service Worker - " + d.innerText;
//d=document.body;
//d.innerHTML = `<div class="toast toast-primary">Service Worker已经更新 请刷新页面进行安装</div>` + d.innerHTML;
});
window.addEventListener('load', function () {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', {
scope: '/'
}).then(function (registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function (err) {
console.warn('ServiceWorker registration failed: ', err);
});
navigator.serviceWorker.addEventListener('controllerchange', function () {
var d = document.querySelector("title");
d.innerText = "Need update Service Worker - " + d.innerText; //d=document.body;
//d.innerHTML = `<div class="toast toast-primary">Service Worker已经更新 请刷新页面进行安装</div>` + d.innerHTML;
});
}
if (/HeadlessChrome/.test(window.navigator.userAgent)) {
return;
}
if (!window.dataLayer) {
var d = document,
a = d.createElement("script");
a.async = true;
a.src = "https://www.googletagmanager.com/gtag/js?id=G-ENYRL7T64N";
d.head.appendChild(a);
}
if (typeof navigator.connection !== "undefined") {
if (navigator.connection.rtt <= 600 & navigator.connection.downlink >= 0.5) {
fontsInit();
} else {
setTimeout(fontsInit, 5000);
}
if (/HeadlessChrome/.test(window.navigator.userAgent)) { return; }
if (!window.dataLayer) {
let d = document, a = d.createElement("script");
a.async = true;
a.src = "https://www.googletagmanager.com/gtag/js?id=G-ENYRL7T64N";
d.head.appendChild(a);
}
if(typeof navigator.connection !== "undefined") {
if (navigator.connection.rtt <= 600 & navigator.connection.downlink >= 0.5) {
fontsInit();
} else {
setTimeout(fontsInit, 5000);
}
}else {
setTimeout(fontsInit,1000);
}
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-ENYRL7T64N');
} else {
setTimeout(fontsInit, 1000);
}
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-ENYRL7T64N');
});
let fontsInit = () => {
let d = document, url = "/css/fonts.min.css";
d.head.innerHTML += `<link rel="preload" href="${url}" as="style" onload="this.onload=null;this.rel='stylesheet'"><noscript><link rel="stylesheet" href="${url}"></noscript>`;
var fontsInit = function fontsInit() {
var d = document,
url = "/css/fonts.min.css";
d.head.innerHTML += "<link rel=\"preload\" href=\"".concat(url, "\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\"><noscript><link rel=\"stylesheet\" href=\"").concat(url, "\"></noscript>");
};
let send = () => {
whenAvailable("NProgress", () => {
NProgress.inc();
});
var send = function send() {
whenAvailable("NProgress", function () {
NProgress.inc();
});
};
let suc = () => {
whenAvailable("NProgress", () => {
NProgress.done();
});
whenAvailable("LazyLoad", () => {
new LazyLoad(globalThis.lazyLoadOptions)
});
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-ENYRL7T64N');
var suc = function suc() {
whenAvailable("NProgress", function () {
NProgress.done();
});
whenAvailable("LazyLoad", function () {
new LazyLoad(globalThis.lazyLoadOptions);
});
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-ENYRL7T64N');
};
document.addEventListener('LoadValine', () => {
if (document.querySelector("#vcomments")) {
valinedo();
}
document.addEventListener('LoadValine', function () {
if (document.querySelector("#vcomments")) {
valinedo();
}
});
let whenAvailable = (name, callback) => {
var interval = 100;
window.setTimeout(function () {
if (window[name]) {
callback(window[name]);
} else {
window.setTimeout(arguments.callee, interval);
}
}, interval);
globalThis.whenAvailable = function (name, callback) {
var interval = 100;
window.setTimeout(function () {
if (window[name]) {
callback(window[name]);
} else {
window.setTimeout(arguments.callee, interval);
}
}, interval);
};
globalThis.__BLOG__ = (() => new Object({
globalThis.__BLOG__ = function () {
return new Object({
name: "186526's Blog",
use: "hexo@^5.0",
}))();
})();
use: "hexo@^5.0"
});
}();
})();