hexo-theme-volantis 5.8.1 → 6.0.0
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/CHANGELOG.md +3 -44
- package/_cdn.yml +449 -0
- package/_config.yml +155 -157
- package/languages/en.yml +9 -10
- package/languages/zh-CN.yml +11 -15
- package/languages/zh-TW.yml +10 -11
- package/layout/_meta/category.ejs +10 -5
- package/layout/_meta/counter.ejs +14 -17
- package/layout/_meta/tags.ejs +3 -0
- package/layout/_meta/walinecount.ejs +1 -1
- package/layout/_partial/article.ejs +8 -3
- package/layout/_partial/cover.ejs +4 -4
- package/layout/_partial/footer.ejs +1 -1
- package/layout/_partial/head.ejs +7 -18
- package/layout/_partial/header.ejs +6 -6
- package/layout/_partial/post.ejs +3 -3
- package/layout/_partial/scripts/_ctrl.ejs +43 -2
- package/layout/_partial/scripts/config.ejs +69 -0
- package/layout/_partial/scripts/global.ejs +137 -60
- package/layout/_partial/scripts/index.ejs +16 -23
- package/layout/_plugins/_page_plugins/artitalk/index.ejs +1 -1
- package/layout/_plugins/_page_plugins/bbtalk/index.ejs +1 -1
- package/layout/_plugins/_page_plugins/fcircle/index.ejs +9 -8
- package/layout/_plugins/_page_plugins/katex/index.ejs +3 -3
- package/layout/_plugins/_page_plugins/mathjax/index.ejs +1 -1
- package/layout/_plugins/aplayer/layout.ejs +31 -23
- package/layout/_plugins/aplayer/script.ejs +93 -65
- package/layout/_plugins/comments/artalk/script.ejs +31 -40
- package/layout/_plugins/comments/discuss/script.ejs +1 -1
- package/layout/_plugins/comments/disqusjs/script.ejs +2 -2
- package/layout/_plugins/comments/gitalk/script.ejs +1 -1
- package/layout/_plugins/comments/twikoo/script.ejs +1 -1
- package/layout/_plugins/comments/vssue/script.ejs +3 -3
- package/layout/_plugins/comments/waline/script.ejs +2 -2
- package/layout/_plugins/github-api/script.ejs +3 -3
- package/layout/_plugins/lazyload/script.ejs +1 -1
- package/layout/_plugins/nodewaves/script.ejs +1 -1
- package/layout/_plugins/pace/script.ejs +15 -0
- package/layout/_plugins/parallax/script.ejs +1 -1
- package/layout/_plugins/pjax/index.ejs +66 -11
- package/layout/_plugins/pjax/pdata.ejs +5 -5
- package/layout/_plugins/preload/script.ejs +2 -2
- package/layout/_plugins/rightmenus/layout.ejs +4 -4
- package/layout/_plugins/scrollreveal/script.ejs +2 -2
- package/layout/_plugins/search/script.ejs +11 -8
- package/layout/_plugins/swiper/script.ejs +2 -2
- package/layout/{_partial/scripts/toc.ejs → _plugins/toc/script.ejs} +40 -36
- package/layout/_widget/webinfo.ejs +13 -14
- package/layout/friends.ejs +2 -2
- package/layout/layout.ejs +1 -15
- package/package.json +4 -4
- package/scripts/events/lib/cdn.js +206 -0
- package/scripts/events/lib/check-configuration.js +7 -7
- package/scripts/events/lib/check-environment.js +17 -17
- package/scripts/events/lib/config.js +0 -24
- package/scripts/events/lib/render-stylus.js +5 -5
- package/scripts/events/lib/stellar-tag-utils.js +2 -2
- package/scripts/filters/hexo-blog-encrypt-callback.js +44 -0
- package/scripts/filters/img.js +1 -1
- package/scripts/filters/replace.js +3 -3
- package/scripts/filters/z-lazyload.js +3 -5
- package/scripts/helpers/first-style.js +2 -2
- package/scripts/helpers/head/generate_seo.js +11 -9
- package/scripts/helpers/head/generate_title__keywords__description.js +19 -6
- package/scripts/helpers/related-posts.js +3 -3
- package/scripts/helpers/structured-data/lib/blogposting.js +1 -1
- package/scripts/helpers/structured-data/lib/breadcrumblist.js +1 -1
- package/scripts/helpers/structured-data/lib/config.js +1 -1
- package/scripts/helpers/structured-data/lib/website.js +1 -1
- package/scripts/helpers//346/226/207/347/253/240/346/216/250/350/215/220.js +184 -0
- package/scripts/tags/btn.js +2 -2
- package/scripts/tags/btns.js +3 -3
- package/scripts/tags/checkbox.js +6 -6
- package/scripts/tags/contributors.js +7 -7
- package/scripts/tags/dropmenu.js +8 -8
- package/scripts/tags/fancybox.js +6 -6
- package/scripts/tags/folding.js +5 -5
- package/scripts/tags/frame.js +3 -3
- package/scripts/tags/friends.js +8 -8
- package/scripts/tags/ghcard.js +7 -7
- package/scripts/tags/image.js +6 -6
- package/scripts/tags/inline-labels.js +6 -6
- package/scripts/tags/link.js +5 -5
- package/scripts/tags/md.js +4 -4
- package/scripts/tags/media.js +5 -5
- package/scripts/tags/note.js +12 -12
- package/scripts/tags/pandown.js +29 -29
- package/scripts/tags/site.js +4 -4
- package/scripts/tags/span.js +4 -4
- package/scripts/tags/table.js +2 -2
- package/scripts/tags/tabs.js +23 -23
- package/scripts/tags/timeline.js +5 -5
- package/source/css/_first/base_first.styl +1 -1
- package/source/css/_style/_layout/article.styl +43 -0
- package/source/css/_style/_layout/main.styl +1 -1
- package/source/css/_style/_layout/search.styl +206 -14
- package/source/css/_style/_plugins/index.styl +1 -3
- package/source/js/app.js +133 -160
- package/source/js/plugins/parallax.js +1 -1
- package/source/js/plugins/rightMenus.js +24 -20
- package/source/js/search/algolia.js +239 -0
- package/source/js/search/hexo.js +8 -2
- package/source/js/search/meilisearch.js +220 -0
- package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +0 -127
- package/layout/_partial/scripts/_ctrl/coverCtrl.ejs +0 -43
- package/layout/_plugins/analytics/LCCounter.ejs +0 -207
- package/layout/_plugins/pjax/animate.ejs +0 -31
- package/layout/_plugins/rightmenu/layout.ejs +0 -119
- package/scripts/helpers/revisioned.js +0 -167
- package/source/css/_style/_plugins/pjaxanimate.styl +0 -160
- package/source/js/plugins/rightMenu.js +0 -577
- /package/layout/{_partial/scripts/content-visibility-scroll-fix.ejs → _plugins/content-visibility/script.ejs} +0 -0
|
@@ -1,577 +0,0 @@
|
|
|
1
|
-
const RightMenu = (() => {
|
|
2
|
-
const
|
|
3
|
-
rightMenuConfig = volantis.GLOBAL_CONFIG.plugins.rightmenu,
|
|
4
|
-
messageRightMenu = volantis.GLOBAL_CONFIG.plugins.message.enable && volantis.GLOBAL_CONFIG.plugins.message.rightmenu.enable;
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
fn = {},
|
|
8
|
-
_rightMenuWrapper = document.getElementById('rightmenu-wrapper'),
|
|
9
|
-
_rightMenuContent = document.getElementById('rightmenu-content'),
|
|
10
|
-
_printHtml = document.getElementById('printHtml'),
|
|
11
|
-
_menuMusic = document.getElementById('menuMusic'),
|
|
12
|
-
_readingModel = document.getElementById('readingModel'),
|
|
13
|
-
_readBkg = document.getElementById('read_bkg');
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
_menuLoad = document.querySelectorAll('.menuLoad-Content'),
|
|
17
|
-
_menuOption = document.querySelector('.menu-Option'),
|
|
18
|
-
_searchWord = document.querySelector('.menu-Option[data-fn-type="searchWord"]'),
|
|
19
|
-
_copyText = document.querySelector('.menu-Option[data-fn-type="copyText"]'),
|
|
20
|
-
_copyPaste = document.querySelector('.menu-Option[data-fn-type="copyPaste"]'),
|
|
21
|
-
_copySelect = document.querySelector('.menu-Option[data-fn-type="copySelect"]'),
|
|
22
|
-
_copyCut = document.querySelector('.menu-Option[data-fn-type="copyCut"]'),
|
|
23
|
-
_copyHref = document.querySelector('.menu-Option[data-fn-type="copyHref"]'),
|
|
24
|
-
_copySrc = document.querySelector('.menu-Option[data-fn-type="copySrc"]'),
|
|
25
|
-
_copyImg = document.querySelector('.menu-Option[data-fn-type="copyImg"]'),
|
|
26
|
-
_openTab = document.querySelector('.menu-Option[data-fn-type="openTab"]'),
|
|
27
|
-
_backward = document.querySelector('#menuMusic .backward'),
|
|
28
|
-
_toggle = document.querySelector('#menuMusic .toggle'),
|
|
29
|
-
_forward = document.querySelector('#menuMusic .forward');
|
|
30
|
-
|
|
31
|
-
const urlRegx = /^((https|http)?:\/\/)+[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
|
|
32
|
-
|
|
33
|
-
fn.init = () => {
|
|
34
|
-
DOMController.visible(_menuMusic, false);
|
|
35
|
-
DOMController.visible(_menuOption, false);
|
|
36
|
-
if (_readBkg) _readBkg.parentNode.removeChild(_readBkg);
|
|
37
|
-
|
|
38
|
-
const readBkg = document.createElement("div");
|
|
39
|
-
readBkg.className = "common_read_bkg common_read_hide";
|
|
40
|
-
readBkg.id = "read_bkg";
|
|
41
|
-
window.document.body.appendChild(readBkg);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fn.initEvent = () => {
|
|
45
|
-
window.document.oncontextmenu = (event) => {
|
|
46
|
-
if (event.ctrlKey || document.body.offsetWidth <= 500) {
|
|
47
|
-
fn.hideMenu();
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return fn.popMenu(event);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
_rightMenuWrapper.oncontextmenu = (event) => {
|
|
54
|
-
event.stopPropagation();
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
window.removeEventListener('blur', fn.hideMenu);
|
|
60
|
-
window.addEventListener('blur', fn.hideMenu);
|
|
61
|
-
document.body.removeEventListener('click', fn.hideMenu);
|
|
62
|
-
document.body.addEventListener('click', fn.hideMenu);
|
|
63
|
-
|
|
64
|
-
if (_forward && _toggle && _forward) {
|
|
65
|
-
_backward.onclick = (e) => {
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
e.stopPropagation();
|
|
68
|
-
RightMenuAplayer.aplayerBackward();
|
|
69
|
-
}
|
|
70
|
-
_toggle.onclick = (e) => {
|
|
71
|
-
e.preventDefault();
|
|
72
|
-
e.stopPropagation();
|
|
73
|
-
RightMenuAplayer.aplayerToggle();
|
|
74
|
-
}
|
|
75
|
-
_forward.onclick = (e) => {
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
e.stopPropagation();
|
|
78
|
-
RightMenuAplayer.aplayerForward();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 菜单位置设定
|
|
84
|
-
fn.popMenu = (event) => {
|
|
85
|
-
let mouseClientX = event.clientX;
|
|
86
|
-
let mouseClientY = event.clientY;
|
|
87
|
-
let screenWidth = document.documentElement.clientWidth || document.body.clientWidth;
|
|
88
|
-
let screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
fn.setMenuItem(event);
|
|
92
|
-
DOMController.visible(_rightMenuWrapper);
|
|
93
|
-
_rightMenuWrapper.focus();
|
|
94
|
-
_rightMenuWrapper.style.zIndex = '-2147483648';
|
|
95
|
-
let menuWidth = _rightMenuContent.offsetWidth;
|
|
96
|
-
let menuHeight = _rightMenuContent.offsetHeight;
|
|
97
|
-
let showLeft = mouseClientX + menuWidth > screenWidth ? mouseClientX - menuWidth + 10 : mouseClientX;
|
|
98
|
-
let showTop = mouseClientY + menuHeight > screenHeight ? mouseClientY - menuHeight + 10 : mouseClientY;
|
|
99
|
-
showTop = mouseClientY + menuHeight > screenHeight && showTop < menuHeight && mouseClientY < menuHeight ?
|
|
100
|
-
showTop + (screenHeight - menuHeight - showTop - 10) : showTop;
|
|
101
|
-
_rightMenuWrapper.style.left = showLeft + "px";
|
|
102
|
-
_rightMenuWrapper.style.top = showTop + "px";
|
|
103
|
-
_rightMenuWrapper.style.zIndex = '2147483648';
|
|
104
|
-
if (volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice) fn.showMessage();
|
|
105
|
-
} catch (error) {
|
|
106
|
-
_rightMenuWrapper.blur();
|
|
107
|
-
console.error(error);
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 消息提示
|
|
115
|
-
fn.showMessage = () => {
|
|
116
|
-
const NoticeRightMenu = localStorage.getItem('NoticeRightMenu') === 'true';
|
|
117
|
-
if (messageRightMenu && !NoticeRightMenu)
|
|
118
|
-
VolantisApp.message('右键菜单', '唤醒原系统菜单请使用:<kbd>Ctrl</kbd> + <kbd>右键</kbd>', {
|
|
119
|
-
icon: rightMenuConfig.faicon + ' fa-exclamation-square red',
|
|
120
|
-
time: 9000
|
|
121
|
-
}, () => {
|
|
122
|
-
localStorage.setItem('NoticeRightMenu', 'true')
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// 菜单项设置
|
|
127
|
-
fn.setMenuItem = (event) => {
|
|
128
|
-
let optionFlag = false;
|
|
129
|
-
const eventTarget = event.target;
|
|
130
|
-
const selectText = window.getSelection().toString();
|
|
131
|
-
DOMController.visible(_openTab, false); // 隐藏新标签页打开
|
|
132
|
-
|
|
133
|
-
// 判断是否是输入框
|
|
134
|
-
if (eventTarget.tagName.toLowerCase() === 'input' || eventTarget.tagName.toLowerCase() === 'textarea') {
|
|
135
|
-
const inputStr = eventTarget.value;
|
|
136
|
-
|
|
137
|
-
// 全选
|
|
138
|
-
if (inputStr.length > 0) {
|
|
139
|
-
DOMController.visible(_copySelect);
|
|
140
|
-
_copySelect.onclick = () => {
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
eventTarget.select();
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
DOMController.visible(_copySelect, false);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 剪切
|
|
149
|
-
if (selectText) {
|
|
150
|
-
DOMController.visible(_copyCut);
|
|
151
|
-
_copyCut.onclick = () => {
|
|
152
|
-
const statrPos = eventTarget.selectionStart;
|
|
153
|
-
const endPos = eventTarget.selectionEnd;
|
|
154
|
-
fn.copyString(selectText);
|
|
155
|
-
eventTarget.value = inputStr.substring(0, statrPos) + inputStr.substring(endPos, inputStr.length);
|
|
156
|
-
eventTarget.selectionStart = statrPos;
|
|
157
|
-
eventTarget.selectionEnd = statrPos;
|
|
158
|
-
eventTarget.focus();
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
DOMController.visible(_copyCut, false);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 粘贴
|
|
165
|
-
fn.readClipboard().then(text => {
|
|
166
|
-
// 如果剪切板存在内容
|
|
167
|
-
if (!!text) {
|
|
168
|
-
DOMController.visible(_copyPaste);
|
|
169
|
-
_copyPaste.onclick = () => {
|
|
170
|
-
fn.insertAtCaret(eventTarget, text);
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
DOMController.visible(_copyPaste, false);
|
|
174
|
-
}
|
|
175
|
-
}).catch((err) => {
|
|
176
|
-
console.error(err);
|
|
177
|
-
DOMController.visible(_copyPaste, false);
|
|
178
|
-
});
|
|
179
|
-
} else {
|
|
180
|
-
DOMController.visible(_copySelect, false);
|
|
181
|
-
DOMController.visible(_copyPaste, false);
|
|
182
|
-
DOMController.visible(_copyCut, false);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// 新标签打开链接
|
|
186
|
-
const eventHref = eventTarget.href;
|
|
187
|
-
if (!!eventHref && urlRegx.test(eventHref)) {
|
|
188
|
-
optionFlag = true;
|
|
189
|
-
DOMController.visible(_copyHref);
|
|
190
|
-
DOMController.visible(_openTab);
|
|
191
|
-
if (_copyHref) _copyHref.onclick = () => {
|
|
192
|
-
fn.copyString(eventHref);
|
|
193
|
-
}
|
|
194
|
-
_openTab.onclick = () => {
|
|
195
|
-
window.open(eventHref);
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
DOMController.visible(_copyHref, false);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// 新标签打开图片 & 复制图片链接
|
|
202
|
-
const eventSrc = eventTarget.currentSrc;
|
|
203
|
-
if (!!eventSrc && urlRegx.test(eventSrc)) {
|
|
204
|
-
optionFlag = true;
|
|
205
|
-
DOMController.visible(_copySrc);
|
|
206
|
-
DOMController.visible(_openTab);
|
|
207
|
-
|
|
208
|
-
_copySrc.onclick = () => {
|
|
209
|
-
fn.copyString(eventSrc);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
_openTab.onclick = () => {
|
|
213
|
-
window.open(eventSrc);
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
216
|
-
DOMController.visible(_copySrc, false);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// 复制图片
|
|
220
|
-
if (!!eventSrc && urlRegx.test(eventSrc) && eventSrc.trimEnd().endsWith('.png')) {
|
|
221
|
-
optionFlag = true;
|
|
222
|
-
DOMController.visible(_copyImg);
|
|
223
|
-
|
|
224
|
-
_copyImg.onclick = () => {
|
|
225
|
-
fn.writeClipImg(event, flag => {
|
|
226
|
-
if (flag && messageRightMenu) VolantisApp.message('系统提示', '图片复制成功!', {
|
|
227
|
-
icon: rightMenuConfig.faicon + ' fa-images'
|
|
228
|
-
});
|
|
229
|
-
}, (error) => {
|
|
230
|
-
if (messageRightMenu) VolantisApp.message('系统提示', '复制失败:' + error, {
|
|
231
|
-
icon: rightMenuConfig.faicon + ' fa-exclamation-square red'
|
|
232
|
-
});
|
|
233
|
-
})
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
DOMController.visible(_copyImg, false);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// 复制文本
|
|
240
|
-
if (selectText) {
|
|
241
|
-
optionFlag = true;
|
|
242
|
-
DOMController.visible(_copyText);
|
|
243
|
-
DOMController.visible(_searchWord);
|
|
244
|
-
|
|
245
|
-
_copyText.onclick = () => {
|
|
246
|
-
fn.copyString(selectText);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
!!_searchWord && (_searchWord.onclick = () => {
|
|
250
|
-
OpenSearch(selectText);
|
|
251
|
-
})
|
|
252
|
-
} else {
|
|
253
|
-
DOMController.visible(_copyText, false);
|
|
254
|
-
DOMController.visible(_searchWord, false);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// 打印
|
|
258
|
-
const _printArticle = document.querySelector('#post.article') || null;
|
|
259
|
-
const pathName = window.location.pathname;
|
|
260
|
-
if (!!_printArticle) {
|
|
261
|
-
DOMController.visible(_printHtml);
|
|
262
|
-
DOMController.visible(_readingModel);
|
|
263
|
-
|
|
264
|
-
if (_printHtml) {
|
|
265
|
-
_printHtml.onclick = () => {
|
|
266
|
-
if (window.location.pathname === pathName) {
|
|
267
|
-
const message = '是否打印当前页面?<br><em style="font-size: 80%">建议打印时勾选背景图形</em><br>';
|
|
268
|
-
if (messageRightMenu) VolantisApp.question('', message, {}, () => {
|
|
269
|
-
fn.printHtml();
|
|
270
|
-
})
|
|
271
|
-
} else {
|
|
272
|
-
fn.hideMenu();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (_readingModel) {
|
|
278
|
-
_readingModel.onclick = () => {
|
|
279
|
-
if (window.location.pathname === pathName) {
|
|
280
|
-
fn.readingModel();
|
|
281
|
-
} else {
|
|
282
|
-
fn.readingModel();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
} else {
|
|
288
|
-
DOMController.visible(_printHtml, false);
|
|
289
|
-
DOMController.visible(_readingModel, false);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if (volantis.GLOBAL_CONFIG.plugins.aplayer.enable
|
|
293
|
-
&& typeof RightMenuAplayer !== 'undefined'
|
|
294
|
-
&& RightMenuAplayer.APlayer.player !== undefined) {
|
|
295
|
-
if (rightMenuConfig.music_alwaysShow) {
|
|
296
|
-
DOMController.visible(_menuMusic);
|
|
297
|
-
} else if (RightMenuAplayer.APlayer.status === 'play' || RightMenuAplayer.APlayer.status === 'undefined') {
|
|
298
|
-
optionFlag = true;
|
|
299
|
-
DOMController.visible(_menuMusic);
|
|
300
|
-
} else {
|
|
301
|
-
DOMController.visible(_menuMusic, false);
|
|
302
|
-
}
|
|
303
|
-
} else {
|
|
304
|
-
DOMController.visible(_menuMusic, false);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
_menuLoad.forEach(ele => {
|
|
308
|
-
DOMController.visible(ele, !optionFlag);
|
|
309
|
-
})
|
|
310
|
-
|
|
311
|
-
if (volantis.GLOBAL_CONFIG.plugins.aplayer.enable
|
|
312
|
-
&& rightMenuConfig.layout.includes('music')) {
|
|
313
|
-
RightMenuAplayer.checkAPlayer();
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// 隐藏菜单
|
|
318
|
-
fn.hideMenu = () => {
|
|
319
|
-
DOMController.visible(_rightMenuWrapper, false);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// 复制字符串
|
|
323
|
-
fn.copyString = (str) => {
|
|
324
|
-
VolantisApp.utilWriteClipText(str)
|
|
325
|
-
.then(() => {
|
|
326
|
-
if (messageRightMenu) {
|
|
327
|
-
VolantisApp.messageCopyright();
|
|
328
|
-
}
|
|
329
|
-
}).catch(e => {
|
|
330
|
-
if (messageRightMenu) {
|
|
331
|
-
VolantisApp.message('系统提示', e, {
|
|
332
|
-
icon: rightMenuConfig.faicon + ' fa-exclamation-square red'
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
})
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// 写入文本到剪切板
|
|
339
|
-
fn.writeClipText = (str) => {
|
|
340
|
-
try {
|
|
341
|
-
return navigator.clipboard
|
|
342
|
-
.writeText(str)
|
|
343
|
-
.then(() => {
|
|
344
|
-
return Promise.resolve()
|
|
345
|
-
})
|
|
346
|
-
.catch(err => {
|
|
347
|
-
return Promise.reject(err)
|
|
348
|
-
})
|
|
349
|
-
} catch (e) {
|
|
350
|
-
const input = document.createElement('input');
|
|
351
|
-
input.setAttribute('readonly', 'readonly');
|
|
352
|
-
document.body.appendChild(input);
|
|
353
|
-
input.setAttribute('value', str);
|
|
354
|
-
input.select();
|
|
355
|
-
try {
|
|
356
|
-
let result = document.execCommand('copy')
|
|
357
|
-
document.body.removeChild(input);
|
|
358
|
-
if (!result || result === 'unsuccessful') {
|
|
359
|
-
return Promise.reject('复制文本失败!')
|
|
360
|
-
} else {
|
|
361
|
-
return Promise.resolve()
|
|
362
|
-
}
|
|
363
|
-
} catch (e) {
|
|
364
|
-
document.body.removeChild(input);
|
|
365
|
-
return Promise.reject(
|
|
366
|
-
'当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作!'
|
|
367
|
-
)
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// 写入图片到剪切板
|
|
373
|
-
fn.writeClipImg = async function (event, success, error) {
|
|
374
|
-
const eventSrc = rightMenuConfig.customPicUrl.enable ?
|
|
375
|
-
event.target.currentSrc.replace(rightMenuConfig.customPicUrl.old, rightMenuConfig.customPicUrl.new) :
|
|
376
|
-
event.target.currentSrc;
|
|
377
|
-
const parentElement = event.target.parentElement;
|
|
378
|
-
try {
|
|
379
|
-
const data = await fetch(eventSrc);
|
|
380
|
-
const blob = await data.blob();
|
|
381
|
-
await navigator.clipboard
|
|
382
|
-
.write([
|
|
383
|
-
new ClipboardItem({
|
|
384
|
-
[blob.type]: blob
|
|
385
|
-
})
|
|
386
|
-
]).then(() => {
|
|
387
|
-
success(true);
|
|
388
|
-
}, (e) => {
|
|
389
|
-
console.error('图片复制失败:', e);
|
|
390
|
-
error(e);
|
|
391
|
-
});
|
|
392
|
-
} catch (e) {
|
|
393
|
-
const dom = document;
|
|
394
|
-
try {
|
|
395
|
-
if (dom.body.createTextRange) {
|
|
396
|
-
const textRange = document.body.createTextRange();
|
|
397
|
-
textRange.moveToElementText(parentElement);
|
|
398
|
-
textRange.select();
|
|
399
|
-
} else if (window.getSelection) {
|
|
400
|
-
const selection = window.getSelection();
|
|
401
|
-
const range = document.createRange();
|
|
402
|
-
range.selectNodeContents(parentElement);
|
|
403
|
-
selection.removeAllRanges();
|
|
404
|
-
selection.addRange(range);
|
|
405
|
-
}
|
|
406
|
-
document.execCommand('copy');
|
|
407
|
-
window.getSelection().removeAllRanges();
|
|
408
|
-
success(false);
|
|
409
|
-
} catch (e) {
|
|
410
|
-
console.error(e);
|
|
411
|
-
error('不支持复制当前图片!');
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// 请求读取剪切板
|
|
417
|
-
fn.readClipboard = async () => {
|
|
418
|
-
const result = await navigator.permissions.query({
|
|
419
|
-
name: 'clipboard-read'
|
|
420
|
-
});
|
|
421
|
-
if (result.state === 'granted' || result.state === 'prompt') {
|
|
422
|
-
// 修改为 .read() 可以获取剪切板中的文字/图片
|
|
423
|
-
// 返回的是 ClipboardItem
|
|
424
|
-
return navigator.clipboard
|
|
425
|
-
.readText()
|
|
426
|
-
.then(text => text)
|
|
427
|
-
.catch(err => Promise.reject(err));
|
|
428
|
-
}
|
|
429
|
-
return Promise.reject(result);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// 粘贴文本
|
|
433
|
-
fn.insertAtCaret = (elemt, value) => {
|
|
434
|
-
const startPos = elemt.selectionStart,
|
|
435
|
-
endPos = elemt.selectionEnd;
|
|
436
|
-
if (document.selection) {
|
|
437
|
-
elemt.focus();
|
|
438
|
-
var sel = document.selection.createRange();
|
|
439
|
-
sel.text = value;
|
|
440
|
-
elemt.focus();
|
|
441
|
-
} else {
|
|
442
|
-
if (startPos || startPos == '0') {
|
|
443
|
-
var scrollTop = elemt.scrollTop;
|
|
444
|
-
elemt.value = elemt.value.substring(0, startPos) + value + elemt.value.substring(endPos, elemt.value.length);
|
|
445
|
-
elemt.focus();
|
|
446
|
-
elemt.selectionStart = startPos + value.length;
|
|
447
|
-
elemt.selectionEnd = startPos + value.length;
|
|
448
|
-
elemt.scrollTop = scrollTop;
|
|
449
|
-
} else {
|
|
450
|
-
elemt.value += value;
|
|
451
|
-
elemt.focus();
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// 执行打印页面
|
|
457
|
-
fn.printHtml = () => {
|
|
458
|
-
if (volantis.isReadModel) fn.readingModel();
|
|
459
|
-
DOMController.setAttribute('details', 'open', 'true');
|
|
460
|
-
DOMController.remove('.cus-article-bkg');
|
|
461
|
-
DOMController.remove('.iziToast-overlay');
|
|
462
|
-
DOMController.remove('.iziToast-wrapper');
|
|
463
|
-
DOMController.remove('.prev-next');
|
|
464
|
-
DOMController.remove('footer');
|
|
465
|
-
DOMController.remove('#l_header');
|
|
466
|
-
DOMController.remove('#l_cover');
|
|
467
|
-
DOMController.remove('#l_side');
|
|
468
|
-
DOMController.remove('#comments');
|
|
469
|
-
DOMController.remove('#s-top');
|
|
470
|
-
DOMController.remove('#BKG');
|
|
471
|
-
DOMController.remove('#rightmenu-wrapper');
|
|
472
|
-
DOMController.remove('.nav-tabs');
|
|
473
|
-
DOMController.remove('.parallax-mirror');
|
|
474
|
-
DOMController.remove('.new-meta-item.share');
|
|
475
|
-
DOMController.remove('div.footer');
|
|
476
|
-
DOMController.setStyle('body', 'backgroundColor', 'unset');
|
|
477
|
-
DOMController.setStyle('#l_main', 'width', '100%');
|
|
478
|
-
DOMController.setStyle('#post', 'boxShadow', 'none');
|
|
479
|
-
DOMController.setStyle('#post', 'background', 'none');
|
|
480
|
-
DOMController.setStyle('#post', 'padding', '0');
|
|
481
|
-
DOMController.setStyle('h1', 'textAlign', 'center');
|
|
482
|
-
DOMController.setStyle('h1', 'fontWeight', '600');
|
|
483
|
-
DOMController.setStyle('h1', 'fontSize', '2rem');
|
|
484
|
-
DOMController.setStyle('h1', 'marginBottom', '20px');
|
|
485
|
-
DOMController.setStyle('.tab-pane', 'display', 'block');
|
|
486
|
-
DOMController.setStyle('.tab-content', 'borderTop', 'none');
|
|
487
|
-
DOMController.setStyle('.highlight>table pre', 'whiteSpace', 'pre-wrap');
|
|
488
|
-
DOMController.setStyle('.highlight>table pre', 'wordBreak', 'break-all');
|
|
489
|
-
DOMController.setStyle('.fancybox img', 'height', 'auto');
|
|
490
|
-
DOMController.setStyle('.fancybox img', 'weight', 'auto');
|
|
491
|
-
|
|
492
|
-
setTimeout(() => {
|
|
493
|
-
window.print();
|
|
494
|
-
document.body.innerHTML = '';
|
|
495
|
-
window.location.reload();
|
|
496
|
-
}, 50);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// 阅读模式
|
|
500
|
-
fn.readingModel = () => {
|
|
501
|
-
if (typeof ScrollReveal === 'function') ScrollReveal().clean('#comments');
|
|
502
|
-
DOMController.fadeToggle(document.querySelector('#l_header'))
|
|
503
|
-
DOMController.fadeToggle(document.querySelector('footer'))
|
|
504
|
-
DOMController.fadeToggle(document.querySelector('#s-top'))
|
|
505
|
-
DOMController.fadeToggle(document.querySelector('.article-meta#bottom'))
|
|
506
|
-
DOMController.fadeToggle(document.querySelector('.prev-next'))
|
|
507
|
-
DOMController.fadeToggle(document.querySelector('#l_side'))
|
|
508
|
-
DOMController.fadeToggle(document.querySelector('#comments'))
|
|
509
|
-
|
|
510
|
-
DOMController.toggleClass(document.querySelector('#l_main'), 'common_read')
|
|
511
|
-
DOMController.toggleClass(document.querySelector('#l_main'), 'common_read_main')
|
|
512
|
-
DOMController.toggleClass(document.querySelector('#l_body'), 'common_read')
|
|
513
|
-
DOMController.toggleClass(document.querySelector('#safearea'), 'common_read')
|
|
514
|
-
DOMController.toggleClass(document.querySelector('#pjax-container'), 'common_read')
|
|
515
|
-
DOMController.toggleClass(document.querySelector('#read_bkg'), 'common_read_hide')
|
|
516
|
-
DOMController.toggleClass(document.querySelector('h1'), 'common_read_h1')
|
|
517
|
-
DOMController.toggleClass(document.querySelector('#post'), 'post_read')
|
|
518
|
-
DOMController.toggleClass(document.querySelector('#l_cover'), 'read_cover')
|
|
519
|
-
DOMController.toggleClass(document.querySelector('.widget.toc-wrapper'), 'post_read')
|
|
520
|
-
|
|
521
|
-
volantis.isReadModel = volantis.isReadModel === undefined ? true : !volantis.isReadModel;
|
|
522
|
-
if (volantis.isReadModel) {
|
|
523
|
-
const option = {
|
|
524
|
-
backgroundColor: 'var(--color-read-post)',
|
|
525
|
-
icon: rightMenuConfig.faicon + ' fa-book-reader',
|
|
526
|
-
time: 5000
|
|
527
|
-
}
|
|
528
|
-
if (messageRightMenu) VolantisApp.message('系统提示', '阅读模式已开启,您可以点击屏幕空白处退出。', option);
|
|
529
|
-
document.querySelector('#l_body').removeEventListener('click', fn.readingModel);
|
|
530
|
-
document.querySelector('#l_body').addEventListener('click', (event) => {
|
|
531
|
-
if (DOMController.hasClass(event.target, 'common_read')) {
|
|
532
|
-
fn.readingModel();
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
} else {
|
|
536
|
-
document.querySelector('#l_body').removeEventListener('click', fn.readingModel);
|
|
537
|
-
document.querySelector('#post').removeEventListener('click', fn.readingModel);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
return {
|
|
542
|
-
init: (notice = false) => {
|
|
543
|
-
fn.init();
|
|
544
|
-
fn.initEvent();
|
|
545
|
-
if (notice && messageRightMenu) VolantisApp.message('系统提示', '自定义右键注册成功。');
|
|
546
|
-
},
|
|
547
|
-
destroy: (notice = false) => {
|
|
548
|
-
fn.hideMenu();
|
|
549
|
-
window.document.oncontextmenu = () => {
|
|
550
|
-
return true
|
|
551
|
-
};
|
|
552
|
-
if (notice && messageRightMenu) VolantisApp.message('系统提示', '自定义右键注销成功。');
|
|
553
|
-
},
|
|
554
|
-
hideMenu: fn.hideMenu,
|
|
555
|
-
readingModel: fn.readingModel
|
|
556
|
-
}
|
|
557
|
-
})()
|
|
558
|
-
|
|
559
|
-
Object.freeze(RightMenu);
|
|
560
|
-
|
|
561
|
-
volantis.requestAnimationFrame(() => {
|
|
562
|
-
if (document.readyState !== 'loading') {
|
|
563
|
-
RightMenu.init();
|
|
564
|
-
|
|
565
|
-
volantis.pjax.send(() => {
|
|
566
|
-
RightMenu.hideMenu();
|
|
567
|
-
})
|
|
568
|
-
} else {
|
|
569
|
-
document.addEventListener("DOMContentLoaded", function () {
|
|
570
|
-
RightMenu.init();
|
|
571
|
-
|
|
572
|
-
volantis.pjax.send(() => {
|
|
573
|
-
RightMenu.hideMenu();
|
|
574
|
-
})
|
|
575
|
-
})
|
|
576
|
-
}
|
|
577
|
-
});
|
|
File without changes
|