hexo-theme-shokax 0.3.11 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/README_en.MD +13 -5
- package/_config.yml +28 -62
- package/layout/_mixin/comment.pug +1 -1
- package/layout/_mixin/segment.pug +1 -1
- package/layout/_partials/head/head.pug +2 -8
- package/layout/_partials/layout.pug +5 -5
- package/layout/_partials/post/post.pug +1 -1
- package/layout/_partials/post/reward.pug +1 -1
- package/layout/_partials/sidebar/overview.pug +1 -1
- package/package.json +17 -23
- package/scripts/filters/post.js +1 -1
- package/scripts/generaters/script.js +17 -13
- package/scripts/helpers/asset.js +19 -82
- package/scripts/helpers/summary_ai.js +1 -1
- package/scripts/plugin/index.js +11 -22
- package/scripts/utils.js +14 -0
- package/source/css/_common/components/tags/tabs.styl +3 -1
- package/source/css/_common/scaffolding/base.styl +6 -6
- package/source/css/_iconfont.styl +4 -0
- package/source/js/_app/components/sidebar.js +0 -1
- package/source/js/_app/globals/handles.js +0 -40
- package/source/js/_app/globals/thirdparty.js +0 -9
- package/source/js/_app/globals/tools.js +3 -29
- package/source/js/_app/library/anime.js +1 -4
- package/source/js/_app/library/loadFile.js +3 -3
- package/source/js/_app/page/fancybox.js +1 -0
- package/source/js/_app/pjax/domInit.js +2 -2
- package/source/js/_app/pjax/refresh.js +1 -3
- package/source/js/_app/pjax/siteInit.js +2 -0
- package/source/js/_app/player.js +1 -4
- package/source/css/twikoo.css +0 -2002
package/scripts/plugin/index.js
CHANGED
@@ -32,11 +32,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
32
|
};
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
34
34
|
const injects_1 = __importDefault(require("./lib/injects"));
|
35
|
-
const
|
36
|
-
// @ts-ignore
|
37
|
-
// import { version } from '../../package.json'
|
35
|
+
const package_json_1 = require("../../package.json");
|
38
36
|
const fs = __importStar(require("node:fs"));
|
39
|
-
const version = '0.3.10';
|
40
37
|
hexo.on('generateBefore', () => {
|
41
38
|
// 加载`theme_injects`过滤器
|
42
39
|
(0, injects_1.default)(hexo);
|
@@ -49,19 +46,11 @@ hexo.on('generateBefore', () => {
|
|
49
46
|
});
|
50
47
|
hexo.on('generateAfter', () => {
|
51
48
|
// 检查版本更新
|
52
|
-
(
|
53
|
-
|
54
|
-
'User-Agent': 'Theme ShokaX Client'
|
55
|
-
}
|
56
|
-
}, (res) => {
|
57
|
-
let result = '';
|
58
|
-
res.on('data', (data) => {
|
59
|
-
result += data;
|
60
|
-
});
|
61
|
-
res.on('end', () => {
|
49
|
+
fetch('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest').then((res) => {
|
50
|
+
res.json().then((resp) => {
|
62
51
|
try {
|
63
|
-
const latest =
|
64
|
-
const current = version.split('.');
|
52
|
+
const latest = resp.tag_name.replace('v', '').split('.');
|
53
|
+
const current = package_json_1.version.split('.');
|
65
54
|
let isOutdated = false;
|
66
55
|
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
67
56
|
if (!current[i] || latest[i] > current[i]) {
|
@@ -77,13 +66,13 @@ hexo.on('generateAfter', () => {
|
|
77
66
|
hexo.log.warn('Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.');
|
78
67
|
}
|
79
68
|
}
|
80
|
-
catch (
|
81
|
-
hexo.log.
|
82
|
-
hexo.log.
|
69
|
+
catch (e) {
|
70
|
+
hexo.log.warn('Failed to detect version info. Error message:');
|
71
|
+
hexo.log.warn(e);
|
83
72
|
}
|
73
|
+
}).catch((e) => {
|
74
|
+
hexo.log.warn('Failed to detect version info. Error message:');
|
75
|
+
hexo.log.warn(e);
|
84
76
|
});
|
85
|
-
}).on('error', err => {
|
86
|
-
hexo.log.error('Failed to detect version info. Error message:');
|
87
|
-
hexo.log.error(err);
|
88
77
|
});
|
89
78
|
});
|
package/scripts/utils.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getVendorLink = void 0;
|
4
|
+
function getVendorLink(hexo, source) {
|
5
|
+
const VendorsCfg = hexo.theme.config.vendors;
|
6
|
+
const tagIdx = source.indexOf('|');
|
7
|
+
if (tagIdx !== -1) {
|
8
|
+
return `${VendorsCfg.cdns[source.substring(0, tagIdx)]}/${source.substring(tagIdx + 1)}`;
|
9
|
+
}
|
10
|
+
else {
|
11
|
+
return source;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.getVendorLink = getVendorLink;
|
@@ -39,12 +39,14 @@
|
|
39
39
|
width: auto;
|
40
40
|
height: auto;
|
41
41
|
background: none;
|
42
|
-
border-radius:
|
42
|
+
border-radius: 0;
|
43
43
|
border-bottom: .125rem solid transparent;
|
44
44
|
}
|
45
45
|
|
46
46
|
&.active::before {
|
47
47
|
border-bottom-color: var(--primary-color);
|
48
|
+
left: 0;
|
49
|
+
right: 0;
|
48
50
|
}
|
49
51
|
}
|
50
52
|
}
|
@@ -149,12 +149,12 @@ input, textarea {
|
|
149
149
|
@font-face {
|
150
150
|
font-family: 'ic';
|
151
151
|
font-display: swap;
|
152
|
-
src: url('//at.alicdn.com/t/font_' + $iconfont + '.eot');
|
153
|
-
src: url('//at.alicdn.com/t/font_' + $iconfont + '.eot?#iefix') format('embedded-opentype'),
|
154
|
-
url('//at.alicdn.com/t/font_' + $iconfont + '.woff2') format('woff2'),
|
155
|
-
url('//at.alicdn.com/t/font_' + $iconfont + '.woff') format('woff'),
|
156
|
-
url('//at.alicdn.com/t/font_' + $iconfont + '.ttf') format('truetype'),
|
157
|
-
url('//at.alicdn.com/t/font_' + $iconfont + '.svg#ic') format('svg');
|
152
|
+
src: url('//at.alicdn.com/t/c/font_' + $iconfont + '.eot');
|
153
|
+
src: url('//at.alicdn.com/t/c/font_' + $iconfont + '.eot?#iefix') format('embedded-opentype'),
|
154
|
+
url('//at.alicdn.com/t/c/font_' + $iconfont + '.woff2') format('woff2'),
|
155
|
+
url('//at.alicdn.com/t/c/font_' + $iconfont + '.woff') format('woff'),
|
156
|
+
url('//at.alicdn.com/t/c/font_' + $iconfont + '.ttf') format('truetype'),
|
157
|
+
url('//at.alicdn.com/t/c/font_' + $iconfont + '.svg#ic') format('svg');
|
158
158
|
}
|
159
159
|
|
160
160
|
@font-face {
|
@@ -70,46 +70,6 @@ export const scrollHandle = () => {
|
|
70
70
|
$dom('.percent').changeOrGetWidth(scrollPercent);
|
71
71
|
}
|
72
72
|
};
|
73
|
-
/**
|
74
|
-
* 此函数用于修改右键点击显示菜单 <br/>
|
75
|
-
* 需要在document下存在如下元素:
|
76
|
-
* - id为clickMenu的容器(右键菜单容器)
|
77
|
-
* - class为clickSubmenu的容器(可以有0到无限个)(子菜单容器)
|
78
|
-
* CSS应有如下class:
|
79
|
-
* - clickMenu的active类(控制显示)
|
80
|
-
*/
|
81
|
-
export const clickMenu = () => {
|
82
|
-
const menuElement = $dom('#clickMenu');
|
83
|
-
window.oncontextmenu = function (event) {
|
84
|
-
if (event.ctrlKey) { // 当按下ctrl键时不触发自定义菜单
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
event.preventDefault();
|
88
|
-
let x = event.offsetX; // 触发点到页面窗口左边的距离
|
89
|
-
let y = event.offsetY;
|
90
|
-
const winWidth = window.innerWidth; // 窗口的内部宽度(包括滚动条)
|
91
|
-
const winHeight = window.innerHeight;
|
92
|
-
const menuWidth = menuElement.offsetWidth; // 菜单宽度
|
93
|
-
const menuHeight = menuElement.offsetHeight;
|
94
|
-
x = winWidth - menuWidth >= x ? x : winWidth - menuWidth;
|
95
|
-
y = winHeight - menuHeight >= y ? y : winHeight - menuHeight;
|
96
|
-
menuElement.style.top = y + 'px';
|
97
|
-
menuElement.style.left = x + 'px';
|
98
|
-
menuElement.classList.add('active');
|
99
|
-
$dom.each('.clickSubmenu', (submenu) => {
|
100
|
-
if (x > (winWidth - menuWidth - submenu.offsetWidth)) {
|
101
|
-
submenu.style.left = '-200px';
|
102
|
-
}
|
103
|
-
else {
|
104
|
-
submenu.style.left = '';
|
105
|
-
submenu.style.right = '-200px';
|
106
|
-
}
|
107
|
-
});
|
108
|
-
};
|
109
|
-
window.addEventListener('click', () => {
|
110
|
-
menuElement.classList.remove('active');
|
111
|
-
});
|
112
|
-
};
|
113
73
|
// 可见度监听(离开页面和返回时更改document的title)
|
114
74
|
export const visibilityListener = () => {
|
115
75
|
const iconNode = $dom('[rel="icon"]');
|
@@ -1,15 +1,6 @@
|
|
1
1
|
// 与第三方js的交互或第三方嵌入js
|
2
|
-
import lozad from 'lozad';
|
3
2
|
import { loadCat } from './globalVars';
|
4
3
|
import { transition } from '../library/anime';
|
5
|
-
/**
|
6
|
-
* 懒加载图片
|
7
|
-
*/
|
8
|
-
export const lazyload = lozad('img, [data-background-image]', {
|
9
|
-
loaded(el) {
|
10
|
-
el.addClass('lozaded');
|
11
|
-
}
|
12
|
-
});
|
13
4
|
// 加载动画
|
14
5
|
export const Loader = {
|
15
6
|
timer: undefined,
|
@@ -49,44 +49,18 @@ export const positionInit = (comment) => {
|
|
49
49
|
}
|
50
50
|
};
|
51
51
|
/*
|
52
|
-
|
53
|
-
它将使用 Clipboard API 将文本复制到剪贴板。如果不支持,它会创建一个隐藏的文本区域并使用 document.execCommand('copy') 将文本复制到剪贴板。
|
54
|
-
最后,它会回调传入的函数并传入一个布尔值表示是否成功复制。
|
52
|
+
基于clipboard API的复制功能,仅在https环境下有效
|
55
53
|
*/
|
56
54
|
export const clipBoard = (str, callback) => {
|
57
55
|
if (navigator.clipboard && window.isSecureContext) {
|
58
56
|
navigator.clipboard.writeText(str).then(() => {
|
59
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
60
57
|
callback && callback(true);
|
61
58
|
}, () => {
|
62
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
63
59
|
callback && callback(false);
|
64
60
|
});
|
65
61
|
}
|
66
62
|
else {
|
67
|
-
|
68
|
-
|
69
|
-
style: {
|
70
|
-
top: window.scrollY + 'px',
|
71
|
-
position: 'absolute',
|
72
|
-
opacity: '0'
|
73
|
-
},
|
74
|
-
readOnly: true,
|
75
|
-
value: str
|
76
|
-
});
|
77
|
-
const selection = document.getSelection();
|
78
|
-
const selected = selection.rangeCount > 0 ? selection.getRangeAt(0) : false;
|
79
|
-
ta.select();
|
80
|
-
ta.setSelectionRange(0, str.length);
|
81
|
-
ta.readOnly = false;
|
82
|
-
const result = document.execCommand('copy');
|
83
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
84
|
-
callback && callback(result);
|
85
|
-
ta.blur(); // For iOS
|
86
|
-
if (selected) {
|
87
|
-
selection.removeAllRanges();
|
88
|
-
selection.addRange(selected);
|
89
|
-
}
|
90
|
-
BODY.removeChild(ta);
|
63
|
+
console.error('Too old browser, clipborad API not supported.');
|
64
|
+
callback && callback(false);
|
91
65
|
}
|
92
66
|
};
|
@@ -66,6 +66,7 @@ export const transition = (target, type, complete, begin) => {
|
|
66
66
|
};
|
67
67
|
break;
|
68
68
|
default:
|
69
|
+
// @ts-ignore
|
69
70
|
animation = type;
|
70
71
|
// @ts-ignore
|
71
72
|
display = type.display;
|
@@ -76,12 +77,10 @@ export const transition = (target, type, complete, begin) => {
|
|
76
77
|
duration: 200,
|
77
78
|
easing: 'linear',
|
78
79
|
begin() {
|
79
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
80
80
|
begin && begin();
|
81
81
|
},
|
82
82
|
complete() {
|
83
83
|
target.display(display);
|
84
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
85
84
|
complete && complete();
|
86
85
|
}
|
87
86
|
}, animation)).play();
|
@@ -101,9 +100,7 @@ export const pageScroll = (target, offset, complete) => {
|
|
101
100
|
scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
|
102
101
|
// 完成回调函数
|
103
102
|
complete() {
|
104
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
105
103
|
complete && complete();
|
106
104
|
}
|
107
105
|
}).play();
|
108
|
-
// 调用 anime.js 函数,并传入参数
|
109
106
|
};
|
@@ -4,15 +4,15 @@ import { getScript } from './scriptPjax';
|
|
4
4
|
*/
|
5
5
|
const assetUrl = (asset, type) => {
|
6
6
|
const str = CONFIG[asset][type];
|
7
|
+
if (str.includes('http')) {
|
8
|
+
return str;
|
9
|
+
}
|
7
10
|
if (str.includes('gh') || str.includes('combine')) {
|
8
11
|
return `https://cdn.jsdelivr.net/${str}`;
|
9
12
|
}
|
10
13
|
if (str.includes('npm')) {
|
11
14
|
return `https://cdn.jsdelivr.net/${str}`;
|
12
15
|
}
|
13
|
-
if (str.includes('http')) {
|
14
|
-
return str;
|
15
|
-
}
|
16
16
|
return `/${str}`;
|
17
17
|
};
|
18
18
|
export const vendorJs = (type, callback, condition) => {
|
@@ -3,6 +3,7 @@ import { vendorCss, vendorJs } from '../library/loadFile';
|
|
3
3
|
export const postFancybox = (p) => {
|
4
4
|
if ($dom(p + ' .md img')) {
|
5
5
|
vendorCss('fancybox');
|
6
|
+
vendorCss('justifiedGallery');
|
6
7
|
vendorJs('fancybox', () => {
|
7
8
|
const q = jQuery.noConflict();
|
8
9
|
$dom.each(p + ' p.gallery', (element) => {
|
@@ -25,8 +25,8 @@ export default function domInit() {
|
|
25
25
|
backToTop.addEventListener('click', backToTopHandle);
|
26
26
|
goToComment.addEventListener('click', goToCommentHandle);
|
27
27
|
showContents.addEventListener('click', sideBarToggleHandle);
|
28
|
-
if (typeof mediaPlayer !== 'undefined') {
|
29
|
-
mediaPlayer(toolPlayer);
|
28
|
+
if (typeof mediaPlayer !== 'undefined' && !CONFIG.noPlayer) {
|
29
|
+
/* @__PURE__ */ mediaPlayer(toolPlayer);
|
30
30
|
$dom('main').addEventListener('click', () => {
|
31
31
|
toolPlayer.player.mini();
|
32
32
|
});
|
@@ -9,7 +9,7 @@ import { loadCat, menuToggle, setLocalHash, setLocalUrl, setOriginTitle, sideBar
|
|
9
9
|
import { mediaPlayer } from '../player';
|
10
10
|
import { pagePosition, positionInit } from '../globals/tools';
|
11
11
|
import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar';
|
12
|
-
import { Loader, isOutime
|
12
|
+
import { Loader, isOutime } from '../globals/thirdparty';
|
13
13
|
import { tabFormat } from '../page/tab';
|
14
14
|
export const pjaxReload = () => {
|
15
15
|
pagePosition();
|
@@ -30,7 +30,6 @@ export const siteRefresh = (reload) => {
|
|
30
30
|
vendorCss('katex');
|
31
31
|
vendorJs('copy_tex');
|
32
32
|
vendorCss('mermaid');
|
33
|
-
vendorJs('chart');
|
34
33
|
if (reload !== 1) {
|
35
34
|
$dom.each('script[data-pjax]', pjaxScript);
|
36
35
|
}
|
@@ -49,6 +48,5 @@ export const siteRefresh = (reload) => {
|
|
49
48
|
positionInit();
|
50
49
|
}, 500);
|
51
50
|
cardActive();
|
52
|
-
lazyload.observe();
|
53
51
|
isOutime();
|
54
52
|
};
|
@@ -9,6 +9,7 @@ import { pagePosition } from '../globals/tools';
|
|
9
9
|
import { initFireworks } from '../fireworks';
|
10
10
|
import Pjax from 'theme-shokax-pjax';
|
11
11
|
import { initVue } from '../library/vue';
|
12
|
+
import { lazyLoad } from 'unlazy';
|
12
13
|
const siteInit = () => {
|
13
14
|
domInit();
|
14
15
|
initVue();
|
@@ -32,6 +33,7 @@ const siteInit = () => {
|
|
32
33
|
themeColorListener();
|
33
34
|
algoliaSearch(pjax);
|
34
35
|
initFireworks();
|
36
|
+
lazyLoad();
|
35
37
|
window.addEventListener('scroll', scrollHandle);
|
36
38
|
window.addEventListener('resize', resizeHandle);
|
37
39
|
window.addEventListener('pjax:send', pjaxReload);
|
package/source/js/_app/player.js
CHANGED
@@ -6,10 +6,7 @@ import { $storage } from './library/storage';
|
|
6
6
|
import { tabFormat } from './page/tab';
|
7
7
|
let NOWPLAYING = null;
|
8
8
|
const isMobile = /mobile/i.test(window.navigator.userAgent);
|
9
|
-
export const mediaPlayer = (t, config) => {
|
10
|
-
if (CONFIG.noPlayer) {
|
11
|
-
return;
|
12
|
-
}
|
9
|
+
export const mediaPlayer = /* @__PURE__ */ (t, config) => {
|
13
10
|
const buttons = {
|
14
11
|
el: {},
|
15
12
|
create() {
|