Update
This commit is contained in:
parent
1bd7c6c62c
commit
d01ab1522b
|
@ -7,13 +7,13 @@ steps:
|
||||||
image: node:lts-buster
|
image: node:lts-buster
|
||||||
commands:
|
commands:
|
||||||
- apt-get update -y && apt-get install git -y
|
- apt-get update -y && apt-get install git -y
|
||||||
- yarn install
|
- yarn init-build
|
||||||
- yarn drone-build
|
- yarn drone-build
|
||||||
|
|
||||||
- name: git-push
|
- name: git-push
|
||||||
image: appleboy/drone-git-push
|
image: appleboy/drone-git-push
|
||||||
settings:
|
settings:
|
||||||
path: "public/"
|
path: "./public/"
|
||||||
force: true
|
force: true
|
||||||
ssh_key:
|
ssh_key:
|
||||||
from_secret: ssh_key
|
from_secret: ssh_key
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# blog.186526.xyz
|
# blog.186526.xyz
|
||||||
|
|
||||||
Use GPL-3.0 open source on git.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
|
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的开源
|
在git.186526.xyz上使用GPL-3.0的开源。
|
||||||
除非另有说明,否则文章将以相同方式使用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议
|
除非另有说明,否则文章将以相同方式使用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议。
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"init-build": "yarn;yarn --cwd ./themes/suka",
|
||||||
"build": "hexo generate",
|
"build": "hexo generate",
|
||||||
"clean": "hexo clean",
|
"clean": "hexo clean",
|
||||||
"deploy": "hexo deploy",
|
"deploy": "hexo deploy",
|
||||||
"server": "hexo server",
|
"server": "hexo server",
|
||||||
"build-cloudflare": "yarn;yarn --cwd ./themes/suka;hexo generate;node cleancache.js",
|
"build-cloudflare": "yarn build",
|
||||||
"vercel-build": "yarn build-cloudflare",
|
"vercel-build": "yarn build;node cleancache.js",
|
||||||
"drone-build": "yarn;yarn --cwd ./themes/suka;hexo generate"
|
"drone-build": "yarn build"
|
||||||
},
|
},
|
||||||
"hexo": {
|
"hexo": {
|
||||||
"version": "5.3.0"
|
"version": "5.4.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"autoprefixer": "^10.2.5",
|
"autoprefixer": "^10.2.5",
|
||||||
|
|
|
@ -164,7 +164,7 @@ window.addEventListener("load", () => {
|
||||||
|
|
||||||
由于在同一页面中,同时只能存在一个 `Service Worker`,所以我们需要考虑到 `Service Worker` 的更新情况。
|
由于在同一页面中,同时只能存在一个 `Service Worker`,所以我们需要考虑到 `Service Worker` 的更新情况。
|
||||||
|
|
||||||
你可以通过监听 `navigator.serviceWorker` 的 `controllerchange` 时间来更新 `Service Worker`。
|
你可以通过监听 `navigator.serviceWorker` 的 `controllerchange` 事件来更新 `Service Worker`。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
|
|
|
@ -26,13 +26,13 @@ async function main() {
|
||||||
}
|
}
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
globalThis.buildEnvironment = a;
|
globalThis.buildEnvironment = a;
|
||||||
|
console.log(globalThis.buildEnvironment);
|
||||||
},100);
|
},100);
|
||||||
}));
|
}));
|
||||||
}else{
|
}else{
|
||||||
return `Amazon Linux 2 (Karoo) @ Node.js ${process.version}`;
|
return `Amazon Linux 2 (Karoo) @ Node.js ${process.version}`;
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
console.log(globalThis.buildEnvironment);
|
|
||||||
}
|
}
|
||||||
main();
|
main();
|
||||||
|
|
||||||
|
|
|
@ -1,90 +1,104 @@
|
||||||
(function () {
|
(function () {
|
||||||
|
if (typeof globalThis === 'undefined') {
|
||||||
|
var globalThis = window;
|
||||||
|
}
|
||||||
|
|
||||||
console.log('\n %c 186526\'s Blog | © 186526 \n', 'color: #fff; background: #444; padding:5px 0;');
|
console.log('\n %c 186526\'s Blog | © 186526 \n', 'color: #fff; background: #444; padding:5px 0;');
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", function () {
|
||||||
whenAvailable("Pjax", () => {
|
whenAvailable("Pjax", function () {
|
||||||
const pjax = new Pjax({
|
var pjax = new Pjax({
|
||||||
elements: "a:not([target=_blank])",
|
elements: "a:not([target=_blank])",
|
||||||
selectors: [
|
selectors: ["title", "meta[name=description]", ".pjax"],
|
||||||
"title",
|
|
||||||
"meta[name=description]",
|
|
||||||
".pjax",
|
|
||||||
],
|
|
||||||
cacheBust: !1
|
cacheBust: !1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
document.addEventListener("pjax:send", send);
|
document.addEventListener("pjax:send", send);
|
||||||
document.addEventListener("pjax:success", suc);
|
document.addEventListener("pjax:success", suc);
|
||||||
});
|
});
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', function () {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker.register('/sw.js', {
|
||||||
.register('/sw.js', {
|
scope: '/'
|
||||||
scope: '/',
|
}).then(function (registration) {
|
||||||
})
|
console.log('ServiceWorker registration successful with scope: ', registration.scope);
|
||||||
.then(function (registration) {
|
}).catch(function (err) {
|
||||||
console.log(
|
|
||||||
'ServiceWorker registration successful with scope: ',
|
|
||||||
registration.scope,
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch(function (err) {
|
|
||||||
console.warn('ServiceWorker registration failed: ', err);
|
console.warn('ServiceWorker registration failed: ', err);
|
||||||
});
|
});
|
||||||
navigator.serviceWorker.addEventListener('controllerchange', () => {
|
navigator.serviceWorker.addEventListener('controllerchange', function () {
|
||||||
let d = document.querySelector("title");
|
var d = document.querySelector("title");
|
||||||
d.innerText = "Need update Service Worker - " + d.innerText;
|
d.innerText = "Need update Service Worker - " + d.innerText; //d=document.body;
|
||||||
//d=document.body;
|
|
||||||
//d.innerHTML = `<div class="toast toast-primary">Service Worker已经更新 请刷新页面进行安装</div>` + d.innerHTML;
|
//d.innerHTML = `<div class="toast toast-primary">Service Worker已经更新 请刷新页面进行安装</div>` + d.innerHTML;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (/HeadlessChrome/.test(window.navigator.userAgent)) { return; }
|
|
||||||
|
if (/HeadlessChrome/.test(window.navigator.userAgent)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!window.dataLayer) {
|
if (!window.dataLayer) {
|
||||||
let d = document, a = d.createElement("script");
|
var d = document,
|
||||||
|
a = d.createElement("script");
|
||||||
a.async = true;
|
a.async = true;
|
||||||
a.src = "https://www.googletagmanager.com/gtag/js?id=G-ENYRL7T64N";
|
a.src = "https://www.googletagmanager.com/gtag/js?id=G-ENYRL7T64N";
|
||||||
d.head.appendChild(a);
|
d.head.appendChild(a);
|
||||||
}
|
}
|
||||||
if(typeof navigator.connection !== "undefined") {
|
|
||||||
|
if (typeof navigator.connection !== "undefined") {
|
||||||
if (navigator.connection.rtt <= 600 & navigator.connection.downlink >= 0.5) {
|
if (navigator.connection.rtt <= 600 & navigator.connection.downlink >= 0.5) {
|
||||||
fontsInit();
|
fontsInit();
|
||||||
} else {
|
} else {
|
||||||
setTimeout(fontsInit, 5000);
|
setTimeout(fontsInit, 5000);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
setTimeout(fontsInit,1000);
|
setTimeout(fontsInit, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
function gtag() { dataLayer.push(arguments); }
|
|
||||||
|
function gtag() {
|
||||||
|
dataLayer.push(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
gtag('js', new Date());
|
gtag('js', new Date());
|
||||||
gtag('config', 'G-ENYRL7T64N');
|
gtag('config', 'G-ENYRL7T64N');
|
||||||
});
|
});
|
||||||
let fontsInit = () => {
|
|
||||||
let d = document, url = "/css/fonts.min.css";
|
var fontsInit = function fontsInit() {
|
||||||
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 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", () => {
|
var send = function send() {
|
||||||
|
whenAvailable("NProgress", function () {
|
||||||
NProgress.inc();
|
NProgress.inc();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
let suc = () => {
|
|
||||||
whenAvailable("NProgress", () => {
|
var suc = function suc() {
|
||||||
|
whenAvailable("NProgress", function () {
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
});
|
});
|
||||||
whenAvailable("LazyLoad", () => {
|
whenAvailable("LazyLoad", function () {
|
||||||
new LazyLoad(globalThis.lazyLoadOptions)
|
new LazyLoad(globalThis.lazyLoadOptions);
|
||||||
});
|
});
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
function gtag() { dataLayer.push(arguments); }
|
|
||||||
|
function gtag() {
|
||||||
|
dataLayer.push(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
gtag('js', new Date());
|
gtag('js', new Date());
|
||||||
gtag('config', 'G-ENYRL7T64N');
|
gtag('config', 'G-ENYRL7T64N');
|
||||||
};
|
};
|
||||||
document.addEventListener('LoadValine', () => {
|
|
||||||
|
document.addEventListener('LoadValine', function () {
|
||||||
if (document.querySelector("#vcomments")) {
|
if (document.querySelector("#vcomments")) {
|
||||||
valinedo();
|
valinedo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let whenAvailable = (name, callback) => {
|
|
||||||
|
globalThis.whenAvailable = function (name, callback) {
|
||||||
var interval = 100;
|
var interval = 100;
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
if (window[name]) {
|
if (window[name]) {
|
||||||
|
@ -94,8 +108,11 @@
|
||||||
}
|
}
|
||||||
}, interval);
|
}, interval);
|
||||||
};
|
};
|
||||||
globalThis.__BLOG__ = (() => new Object({
|
|
||||||
|
globalThis.__BLOG__ = function () {
|
||||||
|
return new Object({
|
||||||
name: "186526's Blog",
|
name: "186526's Blog",
|
||||||
use: "hexo@^5.0",
|
use: "hexo@^5.0"
|
||||||
}))();
|
});
|
||||||
})();
|
}();
|
||||||
|
})();
|
Loading…
Reference in New Issue