hexo-theme-shokax 0.3.9 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -1
- package/_config.yml +26 -28
- package/layout/_mixin/comment.pug +1 -34
- package/layout/_mixin/segment.pug +1 -1
- package/layout/_partials/head/head.pug +1 -4
- package/layout/_partials/layout.pug +2 -2
- package/package.json +18 -17
- package/scripts/filters/locals.js +6 -0
- package/scripts/filters/post.js +2 -0
- package/scripts/generaters/archive.js +13 -1
- package/scripts/generaters/config.js +4 -1
- package/scripts/generaters/images.js +2 -0
- package/scripts/generaters/index.js +5 -2
- package/scripts/generaters/pages.js +0 -2
- package/scripts/generaters/script.js +34 -9
- package/scripts/helpers/asset.js +16 -7
- package/scripts/helpers/engine.js +24 -1
- package/scripts/helpers/list_categories.js +4 -0
- package/scripts/helpers/summary_ai.js +4 -0
- package/scripts/helpers/symbols_count_time.js +14 -8
- package/scripts/plugin/check.js +5 -3
- package/scripts/plugin/index.js +36 -9
- package/scripts/plugin/lib/injects.js +15 -0
- package/scripts/tags/media.js +1 -0
- package/source/js/_app/components/sidebar.js +54 -56
- package/source/js/_app/fireworks.js +6 -137
- package/source/js/_app/globals/globalVars.js +80 -96
- package/source/js/_app/globals/handles.js +81 -60
- package/source/js/_app/globals/themeColor.js +30 -26
- package/source/js/_app/globals/thirdparty.js +25 -24
- package/source/js/_app/globals/tools.js +36 -30
- package/source/js/_app/library/anime.js +31 -17
- package/source/js/_app/library/dom.js +12 -5
- package/source/js/_app/library/loadFile.js +7 -9
- package/source/js/_app/library/proto.js +59 -7
- package/source/js/_app/library/scriptPjax.js +14 -9
- package/source/js/_app/library/storage.js +2 -4
- package/source/js/_app/library/vue.js +16 -19
- package/source/js/_app/page/comment.js +10 -11
- package/source/js/_app/page/common.js +8 -12
- package/source/js/_app/page/fancybox.js +13 -14
- package/source/js/_app/page/post.js +43 -45
- package/source/js/_app/page/search.js +20 -20
- package/source/js/_app/page/tab.js +7 -10
- package/source/js/_app/pjax/domInit.js +29 -29
- package/source/js/_app/pjax/refresh.js +45 -50
- package/source/js/_app/pjax/siteInit.js +27 -31
- package/source/js/_app/player.js +44 -27
- package/test/dom.test.js +0 -86
@@ -1,65 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
const
|
7
|
-
const globalVars_1 = require("./globalVars");
|
8
|
-
const showtip = (msg) => {
|
1
|
+
import { pageScroll } from '../library/anime';
|
2
|
+
import { $dom } from '../library/dom';
|
3
|
+
import { $storage } from '../library/storage';
|
4
|
+
import { BODY, LOCAL_HASH, LOCAL_URL, scrollAction, setLocalHash } from './globalVars';
|
5
|
+
// 显示提示(现阶段用于版权及复制结果提示)
|
6
|
+
export const showtip = (msg) => {
|
9
7
|
if (!msg) {
|
10
8
|
return;
|
11
9
|
}
|
12
|
-
const tipbox =
|
10
|
+
const tipbox = BODY.createChild('div', {
|
13
11
|
innerHTML: msg,
|
14
12
|
className: 'tip'
|
15
13
|
});
|
16
14
|
setTimeout(() => {
|
17
15
|
tipbox.addClass('hide');
|
18
16
|
setTimeout(() => {
|
19
|
-
|
17
|
+
BODY.removeChild(tipbox);
|
20
18
|
}, 300);
|
21
19
|
}, 3000);
|
22
20
|
};
|
23
|
-
|
24
|
-
|
21
|
+
export const pagePosition = () => {
|
22
|
+
// 判断配置项是否开启了自动记录滚动位置
|
25
23
|
if (CONFIG.auto_scroll) {
|
26
|
-
|
24
|
+
// 将当前页面的滚动位置存入本地缓存
|
25
|
+
$storage.set(LOCAL_URL, String(scrollAction.y));
|
27
26
|
}
|
28
27
|
};
|
29
|
-
|
30
|
-
|
28
|
+
export const positionInit = (comment) => {
|
29
|
+
// 获取页面锚点
|
31
30
|
const anchor = window.location.hash;
|
32
31
|
let target = null;
|
33
|
-
if (
|
34
|
-
|
32
|
+
if (LOCAL_HASH) {
|
33
|
+
$storage.del(LOCAL_URL);
|
35
34
|
return;
|
36
35
|
}
|
37
36
|
if (anchor) {
|
38
|
-
target =
|
37
|
+
target = $dom(decodeURI(anchor));
|
39
38
|
}
|
40
39
|
else {
|
41
|
-
target = CONFIG.auto_scroll ? parseInt(
|
40
|
+
target = CONFIG.auto_scroll ? parseInt($storage.get(LOCAL_URL)) : 0;
|
42
41
|
}
|
43
42
|
if (target) {
|
44
|
-
|
45
|
-
|
43
|
+
pageScroll(target);
|
44
|
+
setLocalHash(1);
|
46
45
|
}
|
47
|
-
if (comment && anchor && !
|
48
|
-
|
49
|
-
|
46
|
+
if (comment && anchor && !LOCAL_HASH) {
|
47
|
+
pageScroll(target);
|
48
|
+
setLocalHash(1);
|
50
49
|
}
|
51
50
|
};
|
52
|
-
|
53
|
-
|
51
|
+
/*
|
52
|
+
这段代码是用来复制文本的。它使用了浏览器的 Clipboard API,如果浏览器支持该 API 并且当前页面是安全协议 (https),
|
53
|
+
它将使用 Clipboard API 将文本复制到剪贴板。如果不支持,它会创建一个隐藏的文本区域并使用 document.execCommand('copy') 将文本复制到剪贴板。
|
54
|
+
最后,它会回调传入的函数并传入一个布尔值表示是否成功复制。
|
55
|
+
*/
|
56
|
+
export const clipBoard = (str, callback) => {
|
54
57
|
if (navigator.clipboard && window.isSecureContext) {
|
55
58
|
navigator.clipboard.writeText(str).then(() => {
|
59
|
+
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
56
60
|
callback && callback(true);
|
57
61
|
}, () => {
|
62
|
+
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
58
63
|
callback && callback(false);
|
59
64
|
});
|
60
65
|
}
|
61
66
|
else {
|
62
|
-
|
67
|
+
// TODO 根据caniuse,需要此polyfill的设备不足5%,应考虑删除
|
68
|
+
const ta = BODY.createChild('textarea', {
|
63
69
|
style: {
|
64
70
|
top: window.scrollY + 'px',
|
65
71
|
position: 'absolute',
|
@@ -74,13 +80,13 @@ const clipBoard = (str, callback) => {
|
|
74
80
|
ta.setSelectionRange(0, str.length);
|
75
81
|
ta.readOnly = false;
|
76
82
|
const result = document.execCommand('copy');
|
83
|
+
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
77
84
|
callback && callback(result);
|
78
|
-
ta.blur();
|
85
|
+
ta.blur(); // For iOS
|
79
86
|
if (selected) {
|
80
87
|
selection.removeAllRanges();
|
81
88
|
selection.addRange(selected);
|
82
89
|
}
|
83
|
-
|
90
|
+
BODY.removeChild(ta);
|
84
91
|
}
|
85
92
|
};
|
86
|
-
exports.clipBoard = clipBoard;
|
@@ -1,12 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
import anime from 'theme-shokax-anime';
|
2
|
+
import { siteNavHeight } from '../globals/globalVars';
|
3
|
+
/**
|
4
|
+
* 参数 动画效果
|
5
|
+
* 0 元素逐渐消失
|
6
|
+
* 1 元素逐渐出现
|
7
|
+
* bounceUpIn 元素从下方弹跳出现
|
8
|
+
* shrinkIn 元素从放大到正常大小出现
|
9
|
+
* slideRightIn 元素从右侧滑入
|
10
|
+
* slideRightOut 元素向右侧滑出
|
11
|
+
* TODO 函数功能过于复杂,需要拆分
|
12
|
+
*/
|
13
|
+
export const transition = (target, type, complete, begin) => {
|
10
14
|
let animation;
|
11
15
|
let display = 'none';
|
12
16
|
switch (type) {
|
@@ -63,33 +67,43 @@ const transition = (target, type, complete, begin) => {
|
|
63
67
|
break;
|
64
68
|
default:
|
65
69
|
animation = type;
|
70
|
+
// @ts-ignore
|
66
71
|
display = type.display;
|
67
72
|
break;
|
68
73
|
}
|
69
|
-
(
|
74
|
+
anime(Object.assign({
|
70
75
|
targets: target,
|
71
76
|
duration: 200,
|
72
77
|
easing: 'linear',
|
73
78
|
begin() {
|
79
|
+
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
74
80
|
begin && begin();
|
75
81
|
},
|
76
82
|
complete() {
|
77
83
|
target.display(display);
|
84
|
+
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
78
85
|
complete && complete();
|
79
86
|
}
|
80
87
|
}, animation)).play();
|
81
88
|
};
|
82
|
-
|
83
|
-
|
84
|
-
|
89
|
+
export const pageScroll = (target, offset, complete) => {
|
90
|
+
// target: 滚动到的目标元素或坐标(number)
|
91
|
+
// offset: 可选的偏移量
|
92
|
+
// complete: 可选的回调函数,在动画完成时调用
|
93
|
+
anime({
|
94
|
+
// 动画目标
|
85
95
|
targets: typeof offset === 'number' && typeof target !== 'number' ? target.parentNode : document.scrollingElement,
|
96
|
+
// 动画持续时间
|
86
97
|
duration: 500,
|
98
|
+
// 动画缓动函数
|
87
99
|
easing: 'easeInOutQuad',
|
88
|
-
|
100
|
+
// 如果 offset 存在,则滚动到 offset,如果 target 是数字,则滚动到 target,如果 target 是 DOM 元素,则滚动到下述表达式
|
101
|
+
scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
|
102
|
+
// 完成回调函数
|
89
103
|
complete() {
|
104
|
+
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
90
105
|
complete && complete();
|
91
106
|
}
|
92
|
-
};
|
93
|
-
|
107
|
+
}).play();
|
108
|
+
// 调用 anime.js 函数,并传入参数
|
94
109
|
};
|
95
|
-
exports.pageScroll = pageScroll;
|
@@ -1,21 +1,27 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getDocHeight = exports.$dom = void 0;
|
4
1
|
const getDocHeight = () => $dom('main > .inner').offsetHeight;
|
5
|
-
|
2
|
+
/**
|
3
|
+
* 获取一个dom选择器对应的元素
|
4
|
+
*/
|
6
5
|
const $dom = (selector, element = document) => {
|
6
|
+
// 在测试环境中这能优化0.01-0.02ms左右
|
7
7
|
if (selector[0] === '#') {
|
8
8
|
return element.getElementById(selector.substring(1));
|
9
9
|
}
|
10
10
|
return element.querySelector(selector);
|
11
11
|
};
|
12
|
-
|
12
|
+
/**
|
13
|
+
* 获取具有此选择器的所有dom节点
|
14
|
+
*/
|
13
15
|
$dom.all = (selector, element = document) => {
|
14
16
|
return element.querySelectorAll(selector);
|
15
17
|
};
|
18
|
+
/**
|
19
|
+
* 获取具有此选择器的所有dom节点,并依次执行callback函数
|
20
|
+
*/
|
16
21
|
$dom.each = (selector, callback, element) => {
|
17
22
|
$dom.all(selector, element).forEach(callback);
|
18
23
|
};
|
24
|
+
// TODO 异步化意义不明确,代码实现存在问题
|
19
25
|
$dom.asyncify = async (selector, element = document) => {
|
20
26
|
if (selector[0] === '#') {
|
21
27
|
return element.getElementById(selector.substring(1));
|
@@ -25,3 +31,4 @@ $dom.asyncify = async (selector, element = document) => {
|
|
25
31
|
$dom.asyncifyEach = (selector, callback, element) => {
|
26
32
|
$dom.all(selector, element).forEach(callback);
|
27
33
|
};
|
34
|
+
export { $dom, getDocHeight };
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { getScript } from './scriptPjax';
|
2
|
+
/**
|
3
|
+
* 用途是根据不同的资源名称和类型生成相应的资源 URL。
|
4
|
+
*/
|
5
5
|
const assetUrl = (asset, type) => {
|
6
6
|
const str = CONFIG[asset][type];
|
7
7
|
if (str.includes('gh') || str.includes('combine')) {
|
@@ -15,15 +15,14 @@ const assetUrl = (asset, type) => {
|
|
15
15
|
}
|
16
16
|
return `/${str}`;
|
17
17
|
};
|
18
|
-
const vendorJs = (type, callback, condition) => {
|
18
|
+
export const vendorJs = (type, callback, condition) => {
|
19
19
|
if (LOCAL[type]) {
|
20
|
-
|
20
|
+
getScript(assetUrl('js', type), callback || function () {
|
21
21
|
window[type] = true;
|
22
22
|
}, condition || window[type]);
|
23
23
|
}
|
24
24
|
};
|
25
|
-
|
26
|
-
const vendorCss = (type, condition) => {
|
25
|
+
export const vendorCss = (type, condition) => {
|
27
26
|
if (window['css' + type]) {
|
28
27
|
return;
|
29
28
|
}
|
@@ -35,4 +34,3 @@ const vendorCss = (type, condition) => {
|
|
35
34
|
window['css' + type] = true;
|
36
35
|
}
|
37
36
|
};
|
38
|
-
exports.vendorCss = vendorCss;
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const dom_1 = require("./dom");
|
4
|
-
function initProto() {
|
1
|
+
import { $dom } from './dom';
|
2
|
+
export default function initProto() {
|
5
3
|
Object.assign(HTMLElement.prototype, {
|
4
|
+
/**
|
5
|
+
* 创建一个子节点并放置
|
6
|
+
*/
|
6
7
|
createChild(tag, obj, positon) {
|
7
8
|
const child = document.createElement(tag);
|
8
9
|
Object.assign(child, obj);
|
@@ -19,6 +20,10 @@ function initProto() {
|
|
19
20
|
}
|
20
21
|
return child;
|
21
22
|
},
|
23
|
+
/**
|
24
|
+
* 此方法使用`<div>`包装一个 DOM 元素
|
25
|
+
* @param obj 需要被包装的对象
|
26
|
+
*/
|
22
27
|
wrapObject(obj) {
|
23
28
|
const box = document.createElement('div');
|
24
29
|
Object.assign(box, obj);
|
@@ -28,12 +33,18 @@ function initProto() {
|
|
28
33
|
},
|
29
34
|
changeOrGetHeight(h) {
|
30
35
|
if (h) {
|
36
|
+
// TODO 0rem是期望的值吗?
|
31
37
|
this.style.height = typeof h === 'number' ? h + 'rem' : h;
|
32
38
|
}
|
33
39
|
return this.getBoundingClientRect().height;
|
34
40
|
},
|
41
|
+
/**
|
42
|
+
此函数将元素的宽度设置为指定值,如果未提供值,则返回元素的宽度.<br />
|
43
|
+
宽度可以作为数字提供(假定它以`rem`为单位).作为字符串提供则直接设置为元素宽度
|
44
|
+
*/
|
35
45
|
changeOrGetWidth(w) {
|
36
46
|
if (w) {
|
47
|
+
// TODO 0rem是期望的值吗?
|
37
48
|
this.style.width = typeof w === 'number' ? w + 'rem' : w;
|
38
49
|
}
|
39
50
|
return this.getBoundingClientRect().width;
|
@@ -44,6 +55,12 @@ function initProto() {
|
|
44
55
|
left() {
|
45
56
|
return this.getBoundingClientRect().left;
|
46
57
|
},
|
58
|
+
/**
|
59
|
+
* 该函数接受两个参数:`type`字符串和 `value`字符串的可选参数。该函数具有基于参数值的三个主要逻辑分支。 <br />
|
60
|
+
* 1. `value`如果是`null`,则该函数从当前上下文中删除具有`type`函数名称的属性。 <br />
|
61
|
+
* 2. `value`如果为真,则该函数将使用`type`参数指定的名称将属性设置为当前上下文中`value`参数的值。然后,该函数返回当前上下文。 <br />
|
62
|
+
* 3. `value`如果不是真,则该函数返回属性的值,该值具有当前上下文中的参数指定的名称。
|
63
|
+
*/
|
47
64
|
attr(type, value) {
|
48
65
|
if (value === null) {
|
49
66
|
return this.removeAttribute(type);
|
@@ -56,6 +73,9 @@ function initProto() {
|
|
56
73
|
return this.getAttribute(type);
|
57
74
|
}
|
58
75
|
},
|
76
|
+
/**
|
77
|
+
* 将此节点插入父节点的下一个节点之前
|
78
|
+
*/
|
59
79
|
insertAfter(element) {
|
60
80
|
const parent = this.parentNode;
|
61
81
|
if (parent.lastChild === this) {
|
@@ -65,6 +85,10 @@ function initProto() {
|
|
65
85
|
parent.insertBefore(element, this.nextSibling);
|
66
86
|
}
|
67
87
|
},
|
88
|
+
/**
|
89
|
+
* 当d为空时返回此节点的CSSStyle display属性 <br />
|
90
|
+
* 反之,将d设置为此节点的CSSStyle display属性
|
91
|
+
*/
|
68
92
|
display(d) {
|
69
93
|
if (d == null) {
|
70
94
|
return this.style.display;
|
@@ -74,12 +98,25 @@ function initProto() {
|
|
74
98
|
return this;
|
75
99
|
}
|
76
100
|
},
|
101
|
+
/**
|
102
|
+
* 找到此节点第一个符合selector选择器的子节点
|
103
|
+
*/
|
77
104
|
child(selector) {
|
78
|
-
return
|
105
|
+
return $dom(selector, this);
|
79
106
|
},
|
107
|
+
/**
|
108
|
+
* 找到此节点所有符合selector选择器的子节点
|
109
|
+
*/
|
80
110
|
find(selector) {
|
81
|
-
return
|
111
|
+
return $dom.all(selector, this);
|
82
112
|
},
|
113
|
+
/**
|
114
|
+
* 这个方法接受三个参数:
|
115
|
+
* type 表示操作类型('add'、'remove'、'toggle'),
|
116
|
+
* className 是一个或多个要操作的类名,
|
117
|
+
* display 是一个可选的布尔值,用于在执行切换操作时指定类名是否应显示或隐藏。
|
118
|
+
* 该方法会根据操作类型执行相应的类名操作。
|
119
|
+
*/
|
83
120
|
_class(type, className, display) {
|
84
121
|
const classNames = className.indexOf(' ') ? className.split(' ') : [className];
|
85
122
|
classNames.forEach((name) => {
|
@@ -91,21 +128,36 @@ function initProto() {
|
|
91
128
|
}
|
92
129
|
});
|
93
130
|
},
|
131
|
+
/**
|
132
|
+
* 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'add',然后执行添加类名的操作。
|
133
|
+
* 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
|
134
|
+
*/
|
94
135
|
addClass(className) {
|
95
136
|
this._class('add', className);
|
96
137
|
return this;
|
97
138
|
},
|
139
|
+
/**
|
140
|
+
* 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'remove',然后执行移除类名的操作。
|
141
|
+
* 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
|
142
|
+
*/
|
98
143
|
removeClass(className) {
|
99
144
|
this._class('remove', className);
|
100
145
|
return this;
|
101
146
|
},
|
147
|
+
/**
|
148
|
+
* 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'toggle',然后执行切换类名的操作。
|
149
|
+
* 如果提供了 display 参数,它将根据布尔值决定是否显示或隐藏类名。
|
150
|
+
* 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
|
151
|
+
*/
|
102
152
|
toggleClass(className, display) {
|
103
153
|
this._class('toggle', className, display);
|
104
154
|
return this;
|
105
155
|
},
|
156
|
+
/**
|
157
|
+
* 这个方法返回一个布尔值,表示元素是否包含指定的类名。
|
158
|
+
*/
|
106
159
|
hasClass(className) {
|
107
160
|
return this.classList.contains(className);
|
108
161
|
}
|
109
162
|
});
|
110
163
|
}
|
111
|
-
exports.default = initProto;
|
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
function cloudflareInit() {
|
1
|
+
// rocket-loader & Auto minify(cloudflare) 补丁
|
2
|
+
// cloudflare 的上述功能会导致DOMContentLoaded事件无法触发,此补丁会将DOMContentLoaded重定向为load事件
|
3
|
+
export function cloudflareInit() {
|
5
4
|
let inCloudFlare = true;
|
6
5
|
window.addEventListener('DOMContentLoaded', function () {
|
7
6
|
inCloudFlare = false;
|
@@ -15,14 +14,21 @@ function cloudflareInit() {
|
|
15
14
|
});
|
16
15
|
}
|
17
16
|
}
|
18
|
-
|
19
|
-
|
17
|
+
export const getScript = (url, callback, condition) => {
|
18
|
+
// url: 脚本文件的URL地址
|
19
|
+
// callback: 当脚本加载完成时要执行的回调函数
|
20
|
+
// condition: 可选的条件参数,如果存在,则执行callback
|
20
21
|
if (condition) {
|
22
|
+
// 如果条件存在,则执行回调函数
|
21
23
|
callback();
|
22
24
|
}
|
23
25
|
else {
|
24
26
|
let script = document.createElement('script');
|
27
|
+
// @ts-ignore
|
25
28
|
script.onload = function (_, isAbort) {
|
29
|
+
// _: 事件对象
|
30
|
+
// isAbort: 是否中止
|
31
|
+
// @ts-ignore
|
26
32
|
if (isAbort || !script.readyState) {
|
27
33
|
console.log('abort!');
|
28
34
|
script.onload = null;
|
@@ -35,8 +41,7 @@ const getScript = (url, callback, condition) => {
|
|
35
41
|
document.head.appendChild(script);
|
36
42
|
}
|
37
43
|
};
|
38
|
-
|
39
|
-
const pjaxScript = (element) => {
|
44
|
+
export const pjaxScript = (element) => {
|
40
45
|
const { text, parentNode, id, className, type, src, dataset } = element;
|
41
46
|
const code = text || element.textContent || element.innerHTML || '';
|
42
47
|
parentNode.removeChild(element);
|
@@ -51,6 +56,7 @@ const pjaxScript = (element) => {
|
|
51
56
|
script.type = type;
|
52
57
|
}
|
53
58
|
if (src) {
|
59
|
+
// Force synchronous loading of peripheral JS.
|
54
60
|
script.src = src;
|
55
61
|
script.async = false;
|
56
62
|
}
|
@@ -62,4 +68,3 @@ const pjaxScript = (element) => {
|
|
62
68
|
}
|
63
69
|
parentNode.appendChild(script);
|
64
70
|
};
|
65
|
-
exports.pjaxScript = pjaxScript;
|
@@ -1,12 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const globalVars_1 = require("../globals/globalVars");
|
8
|
-
const themeColor_1 = require("../globals/themeColor");
|
9
|
-
function initVue() {
|
1
|
+
import { $storage } from './storage';
|
2
|
+
import { transition } from './anime';
|
3
|
+
import { $dom } from './dom';
|
4
|
+
import { BODY } from '../globals/globalVars';
|
5
|
+
import { changeTheme } from '../globals/themeColor';
|
6
|
+
export function initVue() {
|
10
7
|
Vue.createApp({
|
11
8
|
data() {
|
12
9
|
return {};
|
@@ -14,24 +11,25 @@ function initVue() {
|
|
14
11
|
methods: {
|
15
12
|
changeThemeByBtn() {
|
16
13
|
let c;
|
17
|
-
const btn =
|
18
|
-
const neko =
|
14
|
+
const btn = $dom('.theme').child('.ic');
|
15
|
+
const neko = BODY.createChild('div', {
|
19
16
|
id: 'neko',
|
20
17
|
innerHTML: '<div class="planet"><div class="sun"></div><div class="moon"></div></div><div class="body"><div class="face"><section class="eyes left"><span class="pupil"></span></section><section class="eyes right"><span class="pupil"></span></section><span class="nose"></span></div></div>'
|
21
18
|
});
|
22
19
|
const hideNeko = () => {
|
23
|
-
|
20
|
+
transition(neko, {
|
21
|
+
// @ts-ignore
|
24
22
|
delay: 2500,
|
25
23
|
opacity: 0
|
26
24
|
}, () => {
|
27
|
-
|
25
|
+
BODY.removeChild(neko);
|
28
26
|
});
|
29
27
|
};
|
30
28
|
if (btn.hasClass('i-sun')) {
|
31
29
|
c = () => {
|
32
30
|
neko.addClass('dark');
|
33
|
-
|
34
|
-
|
31
|
+
changeTheme('dark');
|
32
|
+
$storage.set('theme', 'dark');
|
35
33
|
hideNeko();
|
36
34
|
};
|
37
35
|
}
|
@@ -39,12 +37,12 @@ function initVue() {
|
|
39
37
|
neko.addClass('dark');
|
40
38
|
c = () => {
|
41
39
|
neko.removeClass('dark');
|
42
|
-
|
43
|
-
|
40
|
+
changeTheme();
|
41
|
+
$storage.set('theme', 'light');
|
44
42
|
hideNeko();
|
45
43
|
};
|
46
44
|
}
|
47
|
-
|
45
|
+
transition(neko, 1, () => {
|
48
46
|
setTimeout(c, 210);
|
49
47
|
}, () => {
|
50
48
|
neko.display('block');
|
@@ -53,4 +51,3 @@ function initVue() {
|
|
53
51
|
}
|
54
52
|
}).mount('#rightNav');
|
55
53
|
}
|
56
|
-
exports.initVue = initVue;
|
@@ -1,24 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const element = (0, dom_1.$dom)('#comments');
|
1
|
+
import { $dom } from '../library/dom';
|
2
|
+
import { transition } from '../library/anime';
|
3
|
+
import { goToComment } from '../globals/globalVars';
|
4
|
+
// TODO 此函数在twikoo下可能不适用
|
5
|
+
export default function loadComments() {
|
6
|
+
const element = $dom('#comments');
|
8
7
|
if (!element) {
|
9
|
-
|
8
|
+
goToComment.display('none');
|
10
9
|
return;
|
11
10
|
}
|
12
11
|
else {
|
13
|
-
|
12
|
+
goToComment.display('');
|
14
13
|
}
|
15
14
|
const io = new IntersectionObserver((entries, observer) => {
|
16
15
|
const entry = entries[0];
|
16
|
+
// vendorCss('valine')
|
17
17
|
if (entry.isIntersecting || entry.intersectionRatio > 0) {
|
18
|
-
|
18
|
+
transition($dom('#comments'), 'bounceUpIn');
|
19
19
|
observer.disconnect();
|
20
20
|
}
|
21
21
|
});
|
22
22
|
io.observe(element);
|
23
23
|
}
|
24
|
-
exports.default = loadComments;
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const dom_1 = require("../library/dom");
|
5
|
-
const cardActive = () => {
|
6
|
-
if (!(0, dom_1.$dom)('.index.wrap')) {
|
1
|
+
import { $dom } from '../library/dom';
|
2
|
+
export const cardActive = () => {
|
3
|
+
if (!$dom('.index.wrap')) {
|
7
4
|
return;
|
8
5
|
}
|
9
6
|
const io = new IntersectionObserver((entries) => {
|
@@ -22,15 +19,15 @@ const cardActive = () => {
|
|
22
19
|
root: null,
|
23
20
|
threshold: [0.3]
|
24
21
|
});
|
25
|
-
|
22
|
+
$dom.each('.index.wrap article.item, .index.wrap section.item', (article) => {
|
26
23
|
io.observe(article);
|
27
24
|
});
|
28
|
-
|
29
|
-
|
25
|
+
$dom('.index.wrap .item:first-child').addClass('show');
|
26
|
+
$dom.each('.cards .item', (element) => {
|
30
27
|
['mouseenter', 'touchstart'].forEach((item) => {
|
31
28
|
element.addEventListener(item, () => {
|
32
|
-
if (
|
33
|
-
|
29
|
+
if ($dom('.cards .item.active')) {
|
30
|
+
$dom('.cards .item.active').removeClass('active');
|
34
31
|
}
|
35
32
|
element.addClass('active');
|
36
33
|
}, { passive: true });
|
@@ -42,4 +39,3 @@ const cardActive = () => {
|
|
42
39
|
});
|
43
40
|
});
|
44
41
|
};
|
45
|
-
exports.cardActive = cardActive;
|