hexo-theme-shokax 0.3.12 → 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 +8 -11
- package/layout/_mixin/segment.pug +1 -1
- package/layout/_partials/head/head.pug +0 -1
- 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 +10 -10
- package/scripts/filters/post.js +1 -1
- package/scripts/generaters/script.js +4 -1
- package/scripts/helpers/summary_ai.js +1 -1
- 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/pjax/domInit.js +2 -2
- package/source/js/_app/pjax/refresh.js +1 -2
- 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/README.md
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
# 公告
|
|
1
|
+
# 📣 公告
|
|
2
2
|
[关于ShokaX markdown扩展特性的讨论](https://github.com/theme-shoka-x/hexo-theme-shokaX/discussions/177) \
|
|
3
3
|
[关于删除部分评论系统的讨论](https://github.com/theme-shoka-x/hexo-theme-shokaX/discussions/175)
|
|
4
|
+
|
|
4
5
|
# hexo-theme-shokaX
|
|
5
6
|

|
|
6
7
|

|
|
7
8
|

|
|
8
9
|

|
|
9
10
|
|
|
10
|
-
语言(language): 简体中文 | [English](./README_en.MD) \
|
|
11
|
+
#### 语言(language): 简体中文 | [English](./README_en.MD) \
|
|
11
12
|
此项目是shoka的一个二次开发版(算精神续作),致力于提高性能和优化魔改体验 \
|
|
12
13
|
诞生原因是目前shoka已经两年没有更新了,积压了大量BUG和功能请求。
|
|
13
14
|
|
|
14
15
|
shokaX的社区资源导航和插件仓库为[awesome-shokaX](https://github.com/theme-shoka-x/awesome-shokaX)
|
|
15
16
|
|
|
17
|
+
## 技术栈
|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+

|
|
22
|
+
|
|
16
23
|
## 💬 和shoka的区别
|
|
17
24
|
原先shoka使用了javascript+Native+nunjucks的技术 \
|
|
18
25
|
而shokaX则使用了typescript+Vue 3+Pug的技术搭配 \
|
|
@@ -61,7 +68,7 @@ SXC install shokaX
|
|
|
61
68
|
- [Typescript 中文网](https://www.tslang.cn/docs/home.html)
|
|
62
69
|
- [Easy hexo](https://easyhexo.com/)
|
|
63
70
|
|
|
64
|
-
# 许可证
|
|
71
|
+
# [许可证](https://github.com/theme-shoka-x/hexo-theme-shokaX/blob/main/LICENSE)
|
|
65
72
|
许可证: AGPL 3 or later
|
|
66
73
|
|
|
67
74
|
## 特别说明
|
package/README_en.MD
CHANGED
|
@@ -7,12 +7,18 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|
|
|
10
|
-
Language: [简体中文](./README.md) | English \
|
|
10
|
+
#### Language: [简体中文](./README.md) | English \
|
|
11
11
|
This project is a fork (spiritual successor) of Shoka, aimed at improving performance and optimizing the modified experience. \
|
|
12
12
|
The reason for its creation is that Shoka has not been updated for two years, accumulating a large number of bugs and feature requests.
|
|
13
13
|
|
|
14
14
|
The community resource guide and plugin repository for shokaX are available at [awesome-shokaX](https://github.com/theme-shoka-x/awesome-shokaX)
|
|
15
15
|
|
|
16
|
+
## Technology Stack
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+
|
|
16
22
|
## 💬 Differences from Shoka
|
|
17
23
|
The original Shoka used a combination of JavaScript + Native + Nunjucks technologies. \
|
|
18
24
|
ShokaX, on the other hand, uses TypeScript + Vue 3 + Pug technologies and has changed many hard-to-access CDN links.
|
|
@@ -35,7 +41,7 @@ Notes:
|
|
|
35
41
|
## 🔧 How to Install
|
|
36
42
|
Note: This project requires node.js 18.x or higher to run. \
|
|
37
43
|
It is recommended to use [ShokaX-CLI](https://github.com/zkz098/shokaX-CLI) \
|
|
38
|
-
[Click here](https://docs.kaitaku.xyz/guide
|
|
44
|
+
[Click here](https://docs.kaitaku.xyz/en/guide/) for the next configuration steps.
|
|
39
45
|
|
|
40
46
|
## 📚 Sub-projects
|
|
41
47
|
- [ShokaX docs](https://github.com/theme-shoka-x/shokaX-docs) ShokaX Theme Documentation (work in progress, contributions welcome!)
|
|
@@ -48,13 +54,15 @@ It is recommended to use [ShokaX-CLI](https://github.com/zkz098/shokaX-CLI) \
|
|
|
48
54
|
[ShokaX Official Development Documentation](https://docs.kaitaku.xyz/develop/basic/)
|
|
49
55
|
|
|
50
56
|
Recommended reading for contributing:
|
|
51
|
-
- [Hexo Official Documentation](https://hexo.io/zh-cn/docs/templates)
|
|
52
|
-
- [Stylus
|
|
57
|
+
- [Hexo Official Documentation]([https://hexo.io/zh-cn/docs/templates](https://hexo.io/docs/templates.html))
|
|
58
|
+
- [Stylus Documentation](https://stylus-lang.com/)
|
|
59
|
+
- [Stylus Chinese Documentation](https://stylus.bootcss.com/)
|
|
53
60
|
- [Pug Template Engine Chinese Documentation](https://www.pugjs.cn/api/getting-started.html)
|
|
61
|
+
- [TypeScript Documentation](https://www.typescriptlang.org/docs/)
|
|
54
62
|
- [TypeScript Chinese Documentation](https://www.tslang.cn/docs/home.html)
|
|
55
63
|
- [Easy Hexo](https://easyhexo.com/)
|
|
56
64
|
|
|
57
|
-
# License
|
|
65
|
+
# [License](https://github.com/theme-shoka-x/hexo-theme-shokaX/blob/main/LICENSE)
|
|
58
66
|
License: AGPL 3 or later
|
|
59
67
|
|
|
60
68
|
## Special Note
|
package/_config.yml
CHANGED
|
@@ -21,7 +21,6 @@ pwa:
|
|
|
21
21
|
|
|
22
22
|
# 实验性特性
|
|
23
23
|
experiments:
|
|
24
|
-
noIE: true # TODO 阻止IE浏览器访问(ShokaX不支持IE的任何版本)
|
|
25
24
|
noPlayer: false # 禁用音乐播放器
|
|
26
25
|
gradient: false # 使用CSS渐变作为文章封面
|
|
27
26
|
fixedCover: "" # 主页面cover(为空则使用bing随机图片)
|
|
@@ -77,7 +76,7 @@ loader:
|
|
|
77
76
|
|
|
78
77
|
# 使用polyfill.io自动处理浏览器兼容问题
|
|
79
78
|
polyfill:
|
|
80
|
-
enable:
|
|
79
|
+
enable: false
|
|
81
80
|
features:
|
|
82
81
|
- default
|
|
83
82
|
- fetch
|
|
@@ -155,9 +154,9 @@ font:
|
|
|
155
154
|
external: true
|
|
156
155
|
family: Inconsolata
|
|
157
156
|
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
iconfont: "
|
|
157
|
+
# //at.alicdn.com/t/c/font_4415496_59g1326wajd.css => 4415496_59g1326wajd
|
|
158
|
+
# 自定义iconfont图标参见文档教程
|
|
159
|
+
iconfont: "4415496_59g1326wajd"
|
|
161
160
|
|
|
162
161
|
menu:
|
|
163
162
|
home: / || home
|
|
@@ -175,9 +174,9 @@ menu:
|
|
|
175
174
|
# https://twikoo.js.org
|
|
176
175
|
twikoo:
|
|
177
176
|
enable: false
|
|
178
|
-
link: "https://cdn.staticfile.org/twikoo/1.6.
|
|
177
|
+
link: "https://cdn.staticfile.org/twikoo/1.6.30/twikoo.all.min.js"
|
|
179
178
|
mode: vercel # vercel或tencent
|
|
180
|
-
envId: "https://
|
|
179
|
+
envId: "https://example.com" # twikoo环境ID,vercel填地址
|
|
181
180
|
region:
|
|
182
181
|
|
|
183
182
|
# https://waline.js.org/
|
|
@@ -212,8 +211,6 @@ summary:
|
|
|
212
211
|
openai:
|
|
213
212
|
remote: "https://api.openai.com"
|
|
214
213
|
apikey: "key"
|
|
215
|
-
custom:
|
|
216
|
-
remote: "http://localhost:8000"
|
|
217
214
|
|
|
218
215
|
|
|
219
216
|
# Social Links
|
|
@@ -222,7 +219,7 @@ summary:
|
|
|
222
219
|
# Value before `||` delimiter is the target permalink,
|
|
223
220
|
# secend value is the name of Font icon.
|
|
224
221
|
social:
|
|
225
|
-
|
|
222
|
+
github: https://github.com/name || github || "#191717"
|
|
226
223
|
#google: https://plus.google.com/yourname || google
|
|
227
224
|
#twitter: https://twitter.com/yourname || twitter || "#00aff0"
|
|
228
225
|
#zhihu: https://www.zhihu.com/people/yourname || zhihu || "#1e88e5"
|
|
@@ -366,7 +363,7 @@ vendors:
|
|
|
366
363
|
# mouse_firework: npm_webcache|mouse-firework@0.0.4/dist/index.umd.js
|
|
367
364
|
async_js:
|
|
368
365
|
fancybox: bytedance|??jquery/3.5.1/jquery.min.js,fancybox/3.5.7/jquery.fancybox.min.js,justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
|
369
|
-
copy_tex: npm_webcache|katex@0.16.7/contrib/copy-tex.min.js
|
|
366
|
+
copy_tex: npm_webcache|katex@0.16.7/dist/contrib/copy-tex.min.js
|
|
370
367
|
css:
|
|
371
368
|
katex: npm_webcache|katex@0.16.7/dist/katex.min.css
|
|
372
369
|
comment: css/comment.css
|
|
@@ -11,7 +11,7 @@ mixin SMRender(item)
|
|
|
11
11
|
div(class="cover" style=`background: linear-gradient(to bottom right, ${random_color()}, ${random_color()});`)
|
|
12
12
|
else
|
|
13
13
|
div(class="cover")
|
|
14
|
-
!= _url(link1, '<img data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
|
|
14
|
+
!= _url(link1, '<img loading="lazy" data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
|
|
15
15
|
div(class="info")
|
|
16
16
|
+PMRender(item)
|
|
17
17
|
h3
|
|
@@ -11,7 +11,7 @@ article(itemscope itemtype="http://schema.org/Article" class="post block" lang=t
|
|
|
11
11
|
if post.photos && post.photos.length
|
|
12
12
|
div(class="gallery" itemscope itemtype="http://schema.org/ImageGallery")
|
|
13
13
|
each photo in post.photos
|
|
14
|
-
img(data-src=_image_url(photo, post.path) itemprop="contentUrl")
|
|
14
|
+
img(loading="lazy" data-src=_image_url(photo, post.path) itemprop="contentUrl")
|
|
15
15
|
if theme.summary.enable && page.layout === 'post'
|
|
16
16
|
div(class='tabs' id='summary')
|
|
17
17
|
div(class="show-btn")
|
|
@@ -13,6 +13,6 @@ if page.reward !== false
|
|
|
13
13
|
else
|
|
14
14
|
- var translation = name
|
|
15
15
|
div
|
|
16
|
-
img(data-src=`${url_for(theme.statics + theme.assets + image) }` alt=`${ author } ${ translation }`)
|
|
16
|
+
img(loading="lazy" data-src=`${url_for(theme.statics + theme.assets + image) }` alt=`${ author } ${ translation }`)
|
|
17
17
|
p
|
|
18
18
|
!= translation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
div(class="author" itemprop="author" itemscope itemtype="http://schema.org/Person")
|
|
2
|
-
img(class="image" itemprop="image" alt=author
|
|
2
|
+
img(loading="lazy" class="image" itemprop="image" alt=author
|
|
3
3
|
data-src=url_for(theme.statics + theme.assets + '/'+ theme.sidebar.avatar))
|
|
4
4
|
p(class="name" itemprop="name")
|
|
5
5
|
!= author
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hexo-theme-shokax",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "a hexo theme based on shoka",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
|
|
7
7
|
"author": "zkz098",
|
|
8
8
|
"license": "AGPL-3.0-or-later",
|
|
9
|
+
"packageManager": "pnpm@8.14.1",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"test": "tsc --build --verbose",
|
|
11
12
|
"build": "cd ./source && tsc --build --verbose && cd ../scripts && tsc --build --verbose"
|
|
@@ -14,31 +15,30 @@
|
|
|
14
15
|
"@types/fancybox": "^3.5.6",
|
|
15
16
|
"@types/jquery": "^3.5.29",
|
|
16
17
|
"@types/js-yaml": "^4.0.9",
|
|
17
|
-
"@types/
|
|
18
|
-
"@
|
|
19
|
-
"@typescript-eslint/
|
|
20
|
-
"@typescript-eslint/parser": "^6.19.0",
|
|
18
|
+
"@types/node": "^20.11.10",
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
|
20
|
+
"@typescript-eslint/parser": "^6.19.1",
|
|
21
21
|
"eslint": "^8.56.0",
|
|
22
22
|
"eslint-config-standard": "~17",
|
|
23
23
|
"eslint-plugin-import": "^2.29.1",
|
|
24
24
|
"eslint-plugin-n": "^16.6.2",
|
|
25
25
|
"eslint-plugin-promise": "^6.1.1",
|
|
26
26
|
"eslint-plugin-vue": "^9.20.1",
|
|
27
|
-
"instantsearch.js": "^4.64.
|
|
27
|
+
"instantsearch.js": "^4.64.1",
|
|
28
28
|
"typescript": "^5.3.3",
|
|
29
29
|
"vue": "^3.4.15"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"esbuild": "^0.
|
|
32
|
+
"esbuild": "^0.20.0",
|
|
33
33
|
"hexo": "7.0.0",
|
|
34
34
|
"hexo-fs": "^4.1.1",
|
|
35
35
|
"hexo-pagination": "^3.0.0",
|
|
36
36
|
"hexo-util": "^3.2.0",
|
|
37
37
|
"js-yaml": "^4.1.0",
|
|
38
|
-
"
|
|
39
|
-
"mouse-firework": "^0.0.4",
|
|
38
|
+
"mouse-firework": "^0.0.5",
|
|
40
39
|
"theme-shokax-anime": "^0.0.6",
|
|
41
|
-
"theme-shokax-pjax": "^0.0.3"
|
|
40
|
+
"theme-shokax-pjax": "^0.0.3",
|
|
41
|
+
"unlazy": "^0.10.4"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=18.0.0"
|
package/scripts/filters/post.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* global hexo */
|
|
2
2
|
hexo.extend.filter.register('after_post_render', (data) => {
|
|
3
3
|
// 使用正则表达式将<img>标签的src属性替换为data-src属性
|
|
4
|
-
data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 data-src=');
|
|
4
|
+
data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=');
|
|
5
5
|
}, 0);
|
|
@@ -101,7 +101,10 @@ hexo.extend.generator.register('script', function (locals) {
|
|
|
101
101
|
platform: 'browser',
|
|
102
102
|
format: 'iife',
|
|
103
103
|
target: ['es2022'],
|
|
104
|
-
minify: true
|
|
104
|
+
minify: true,
|
|
105
|
+
define: {
|
|
106
|
+
__UNLAZY_LOGGING__: 'false'
|
|
107
|
+
}
|
|
105
108
|
});
|
|
106
109
|
text += fs.readFileSync('shokax_temp.js');
|
|
107
110
|
const result = hexo.render.renderSync({ text, engine: 'js' });
|
|
@@ -11,7 +11,7 @@ let db;
|
|
|
11
11
|
function postMessage(path, content, dbPath, startMessage) {
|
|
12
12
|
if (node_fs_1.default.existsSync('summary.json')) {
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
db = JSON.parse(node_fs_1.default.readFileSync('summary.json'));
|
|
14
|
+
db = JSON.parse(node_fs_1.default.readFileSync('summary.json', { encoding: 'utf-8' }));
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
db = {};
|
|
@@ -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
|
};
|
|
@@ -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();
|
|
@@ -48,6 +48,5 @@ export const siteRefresh = (reload) => {
|
|
|
48
48
|
positionInit();
|
|
49
49
|
}, 500);
|
|
50
50
|
cardActive();
|
|
51
|
-
lazyload.observe();
|
|
52
51
|
isOutime();
|
|
53
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() {
|