hexo-theme-shokax 0.3.13 → 0.3.14

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.
Files changed (180) hide show
  1. package/CODE_OF_CONDUCT.md +128 -128
  2. package/CONTRIBUTING.md +58 -58
  3. package/LICENSE +660 -660
  4. package/LICENSE-shoka +21 -21
  5. package/README.md +99 -99
  6. package/README_en.MD +90 -90
  7. package/UsageRestrictions.md +25 -25
  8. package/_config.yml +370 -370
  9. package/_images.yml +9 -9
  10. package/languages/README.md +19 -19
  11. package/languages/default.yml +1 -1
  12. package/languages/en.yml +153 -153
  13. package/languages/ja.yml +153 -153
  14. package/languages/zh-CN.yml +153 -153
  15. package/languages/zh-HK.yml +153 -153
  16. package/languages/zh-TW.yml +153 -153
  17. package/layout/_alternate/atom.ejs +30 -30
  18. package/layout/_alternate/json.ejs +16 -16
  19. package/layout/_alternate/rss.ejs +34 -34
  20. package/layout/_mixin/breadcrumb.pug +33 -33
  21. package/layout/_mixin/card.pug +38 -38
  22. package/layout/_mixin/comment.pug +41 -41
  23. package/layout/_mixin/postmeta.pug +29 -29
  24. package/layout/_mixin/segment.pug +32 -32
  25. package/layout/_mixin/sidebar.pug +40 -40
  26. package/layout/_mixin/widgets.pug +33 -33
  27. package/layout/_partials/footer.pug +42 -42
  28. package/layout/_partials/head/head.pug +57 -57
  29. package/layout/_partials/head/head_com.pug +17 -17
  30. package/layout/_partials/head/pwa.pug +18 -18
  31. package/layout/_partials/header.pug +18 -18
  32. package/layout/_partials/layout.pug +139 -139
  33. package/layout/_partials/loading.pug +13 -13
  34. package/layout/_partials/pagination.pug +4 -4
  35. package/layout/_partials/post/copyright.pug +20 -20
  36. package/layout/_partials/post/footer.pug +25 -25
  37. package/layout/_partials/post/nav.pug +13 -13
  38. package/layout/_partials/post/post.pug +41 -41
  39. package/layout/_partials/post/reward.pug +18 -18
  40. package/layout/_partials/sidebar/menu.pug +37 -37
  41. package/layout/_partials/sidebar/overview.pug +42 -42
  42. package/layout/_partials/third-party/baidu-analytics.pug +11 -11
  43. package/layout/_partials/third-party/clarity.pug +8 -8
  44. package/layout/_partials/third-party/google-analytics.pug +9 -9
  45. package/layout/archive.pug +118 -118
  46. package/layout/category.pug +59 -59
  47. package/layout/index.pug +33 -33
  48. package/layout/page.pug +55 -55
  49. package/layout/post.pug +36 -36
  50. package/layout/tag.pug +43 -43
  51. package/package.json +47 -47
  52. package/source/assets/algolia_logo.svg +9 -9
  53. package/source/assets/logo.svg +16 -16
  54. package/source/css/_colors.styl +207 -207
  55. package/source/css/_common/components/components.styl +6 -6
  56. package/source/css/_common/components/highlight/highlight.styl +357 -357
  57. package/source/css/_common/components/highlight/operation.styl +21 -21
  58. package/source/css/_common/components/pages/collapse.styl +119 -119
  59. package/source/css/_common/components/pages/home.styl +391 -391
  60. package/source/css/_common/components/pages/pages.styl +56 -56
  61. package/source/css/_common/components/pages/tag-cloud.styl +12 -12
  62. package/source/css/_common/components/post/breadcrumb.styl +39 -39
  63. package/source/css/_common/components/post/copyright.styl +41 -41
  64. package/source/css/_common/components/post/expand.styl +263 -263
  65. package/source/css/_common/components/post/footer.styl +11 -11
  66. package/source/css/_common/components/post/header.styl +79 -79
  67. package/source/css/_common/components/post/nav.styl +63 -63
  68. package/source/css/_common/components/post/post.styl +29 -29
  69. package/source/css/_common/components/post/reward.styl +50 -50
  70. package/source/css/_common/components/post/rtl.styl +12 -12
  71. package/source/css/_common/components/post/tags.styl +39 -39
  72. package/source/css/_common/components/tags/collapse.styl +72 -72
  73. package/source/css/_common/components/tags/container.styl +49 -49
  74. package/source/css/_common/components/tags/label.styl +12 -12
  75. package/source/css/_common/components/tags/links.styl +77 -77
  76. package/source/css/_common/components/tags/list.styl +131 -131
  77. package/source/css/_common/components/tags/note.styl +70 -70
  78. package/source/css/_common/components/tags/player.styl +361 -361
  79. package/source/css/_common/components/tags/quiz.styl +200 -200
  80. package/source/css/_common/components/tags/tabs.styl +89 -89
  81. package/source/css/_common/components/tags/tags.styl +9 -9
  82. package/source/css/_common/components/third-party/loading.styl +222 -222
  83. package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
  84. package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
  85. package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
  86. package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
  87. package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
  88. package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
  89. package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
  90. package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
  91. package/source/css/_common/components/third-party/pace.styl +18 -18
  92. package/source/css/_common/components/third-party/search.styl +167 -167
  93. package/source/css/_common/components/third-party/theme.styl +151 -151
  94. package/source/css/_common/components/third-party/third-party.styl +22 -22
  95. package/source/css/_common/components/third-party/widgets.styl +57 -57
  96. package/source/css/_common/outline/footer/footer.styl +69 -69
  97. package/source/css/_common/outline/header/brand.styl +77 -77
  98. package/source/css/_common/outline/header/header.styl +20 -20
  99. package/source/css/_common/outline/header/image.styl +85 -85
  100. package/source/css/_common/outline/header/menu.styl +117 -117
  101. package/source/css/_common/outline/header/nav.styl +81 -81
  102. package/source/css/_common/outline/header/right.styl +15 -15
  103. package/source/css/_common/outline/header/tool.styl +207 -207
  104. package/source/css/_common/outline/header/waves.styl +57 -57
  105. package/source/css/_common/outline/mobile.styl +46 -46
  106. package/source/css/_common/outline/outline.styl +78 -78
  107. package/source/css/_common/outline/sidebar/author.styl +59 -59
  108. package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
  109. package/source/css/_common/outline/sidebar/menu.styl +63 -63
  110. package/source/css/_common/outline/sidebar/quick.styl +43 -43
  111. package/source/css/_common/outline/sidebar/related.styl +56 -56
  112. package/source/css/_common/outline/sidebar/sidebar.styl +75 -75
  113. package/source/css/_common/outline/sidebar/social.styl +69 -69
  114. package/source/css/_common/outline/sidebar/state.styl +37 -37
  115. package/source/css/_common/outline/sidebar/tab.styl +71 -71
  116. package/source/css/_common/outline/sidebar/toc.styl +47 -47
  117. package/source/css/_common/scaffolding/animate.styl +322 -322
  118. package/source/css/_common/scaffolding/base.styl +190 -190
  119. package/source/css/_common/scaffolding/buttons.styl +48 -48
  120. package/source/css/_common/scaffolding/divider.styl +36 -36
  121. package/source/css/_common/scaffolding/iconfont.styl +443 -443
  122. package/source/css/_common/scaffolding/normalize.styl +273 -273
  123. package/source/css/_common/scaffolding/pagination.styl +81 -81
  124. package/source/css/_common/scaffolding/ribbon.styl +38 -38
  125. package/source/css/_common/scaffolding/scaffolding.styl +14 -14
  126. package/source/css/_common/scaffolding/scrollbar.styl +37 -37
  127. package/source/css/_common/scaffolding/tables.styl +50 -50
  128. package/source/css/_common/scaffolding/tip.styl +19 -19
  129. package/source/css/_common/scaffolding/toggles.styl +59 -59
  130. package/source/css/_iconfont.styl +455 -455
  131. package/source/css/_mixins.styl +148 -148
  132. package/source/css/_variables.styl +89 -89
  133. package/source/css/app.styl +41 -41
  134. package/source/css/comment.styl +3 -3
  135. package/source/css/mermaid.styl +5 -5
  136. package/source/css/optimize.styl +5 -5
  137. package/scripts/filters/locals.js +0 -52
  138. package/scripts/filters/post.js +0 -5
  139. package/scripts/generaters/archive.js +0 -133
  140. package/scripts/generaters/config.js +0 -48
  141. package/scripts/generaters/images.js +0 -23
  142. package/scripts/generaters/index.js +0 -107
  143. package/scripts/generaters/pages.js +0 -15
  144. package/scripts/generaters/script.js +0 -118
  145. package/scripts/helpers/asset.js +0 -147
  146. package/scripts/helpers/engine.js +0 -153
  147. package/scripts/helpers/list_categories.js +0 -84
  148. package/scripts/helpers/summary_ai.js +0 -107
  149. package/scripts/helpers/symbols_count_time.js +0 -69
  150. package/scripts/plugin/check.js +0 -32
  151. package/scripts/plugin/index.js +0 -78
  152. package/scripts/plugin/lib/injects-point.js +0 -20
  153. package/scripts/plugin/lib/injects.js +0 -89
  154. package/scripts/tags/links.js +0 -44
  155. package/scripts/tags/media.js +0 -19
  156. package/scripts/utils.js +0 -14
  157. package/source/js/_app/components/sidebar.js +0 -209
  158. package/source/js/_app/fireworks.js +0 -10
  159. package/source/js/_app/globals/globalVars.js +0 -80
  160. package/source/js/_app/globals/handles.js +0 -98
  161. package/source/js/_app/globals/themeColor.js +0 -62
  162. package/source/js/_app/globals/thirdparty.js +0 -62
  163. package/source/js/_app/globals/tools.js +0 -66
  164. package/source/js/_app/library/anime.js +0 -106
  165. package/source/js/_app/library/dom.js +0 -34
  166. package/source/js/_app/library/loadFile.js +0 -36
  167. package/source/js/_app/library/proto.js +0 -163
  168. package/source/js/_app/library/scriptPjax.js +0 -70
  169. package/source/js/_app/library/storage.js +0 -12
  170. package/source/js/_app/library/vue.js +0 -53
  171. package/source/js/_app/page/comment.js +0 -23
  172. package/source/js/_app/page/common.js +0 -41
  173. package/source/js/_app/page/fancybox.js +0 -65
  174. package/source/js/_app/page/post.js +0 -244
  175. package/source/js/_app/page/search.js +0 -118
  176. package/source/js/_app/page/tab.js +0 -53
  177. package/source/js/_app/pjax/domInit.js +0 -76
  178. package/source/js/_app/pjax/refresh.js +0 -52
  179. package/source/js/_app/pjax/siteInit.js +0 -51
  180. package/source/js/_app/player.js +0 -771
@@ -1,19 +0,0 @@
1
- 'use strict';
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* global hexo */
7
- const js_yaml_1 = __importDefault(require("js-yaml"));
8
- function postMedia(args, content) {
9
- if (!args[0] || !content) {
10
- return;
11
- }
12
- const list = js_yaml_1.default.load(content);
13
- switch (args[0]) {
14
- case 'video':
15
- case 'audio':
16
- return `<div class="media-container"><div class="player" data-type="${args[0]}" data-src='${JSON.stringify(list)}'></div></div>`;
17
- }
18
- }
19
- hexo.extend.tag.register('media', postMedia, { ends: true });
package/scripts/utils.js DELETED
@@ -1,14 +0,0 @@
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;
@@ -1,209 +0,0 @@
1
- /* 边栏分区 */
2
- import { Container, diffY, menuToggle, showContents, sideBar } from '../globals/globalVars';
3
- import { clipBoard } from '../globals/tools';
4
- import { pageScroll, transition } from '../library/anime';
5
- import { $dom } from '../library/dom';
6
- export const sideBarToggleHandle = (event, force) => {
7
- if (sideBar.hasClass('on')) {
8
- sideBar.removeClass('on');
9
- menuToggle.removeClass('close');
10
- if (force) {
11
- // @ts-ignore
12
- // noinspection JSConstantReassignment
13
- sideBar.style = '';
14
- }
15
- else {
16
- transition(sideBar, 'slideRightOut');
17
- }
18
- }
19
- else {
20
- if (force) {
21
- // @ts-ignore
22
- // noinspection JSConstantReassignment
23
- sideBar.style = '';
24
- }
25
- else {
26
- transition(sideBar, 'slideRightIn', () => {
27
- sideBar.addClass('on');
28
- menuToggle.addClass('close');
29
- });
30
- }
31
- }
32
- };
33
- export const sideBarTab = () => {
34
- const sideBarInner = sideBar.child('.inner');
35
- if (sideBar.child('.tab')) {
36
- sideBarInner.removeChild(sideBar.child('.tab'));
37
- }
38
- const list = document.createElement('ul');
39
- let active = 'active';
40
- list.className = 'tab';
41
- ['contents', 'related', 'overview'].forEach((item) => {
42
- const element = sideBar.child('.panel.' + item);
43
- if (element.innerHTML.trim().length < 1) {
44
- if (item === 'contents') {
45
- showContents.display('none');
46
- }
47
- return;
48
- }
49
- if (item === 'contents') {
50
- showContents.display('');
51
- }
52
- const tab = document.createElement('li');
53
- const span = document.createElement('span');
54
- const text = document.createTextNode(element.attr('data-title'));
55
- span.appendChild(text);
56
- tab.appendChild(span);
57
- tab.addClass(item + ' item');
58
- if (active) {
59
- element.addClass(active);
60
- tab.addClass(active);
61
- }
62
- else {
63
- element.removeClass('active');
64
- }
65
- tab.addEventListener('click', (event) => {
66
- const target = event.currentTarget;
67
- if (target.hasClass('active'))
68
- return;
69
- sideBar.find('.tab .item').forEach((element) => {
70
- element.removeClass('active');
71
- });
72
- sideBar.find('.panel').forEach((element) => {
73
- element.removeClass('active');
74
- });
75
- sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
76
- target.addClass('active');
77
- });
78
- list.appendChild(tab);
79
- active = '';
80
- });
81
- if (list.childNodes.length > 1) {
82
- sideBarInner.insertBefore(list, sideBarInner.childNodes[0]);
83
- sideBar.child('.panels').style.paddingTop = '';
84
- }
85
- else {
86
- sideBar.child('.panels').style.paddingTop = '.625rem';
87
- }
88
- };
89
- export const sidebarTOC = () => {
90
- const activateNavByIndex = (index) => {
91
- const target = navItems[index];
92
- if (!target)
93
- return;
94
- if (target.hasClass('current')) {
95
- return;
96
- }
97
- $dom.each('.toc .active', (element) => {
98
- element && element.removeClass('active current');
99
- });
100
- sections.forEach((element) => {
101
- element && element.removeClass('active');
102
- });
103
- target.addClass('active current');
104
- sections[index] && sections[index].addClass('active');
105
- let parent = target.parentNode;
106
- while (!parent.matches('.contents')) {
107
- if (parent.matches('li')) {
108
- parent.addClass('active');
109
- const t = $dom(parent.child('a.toc-link').attr('href'));
110
- if (t) {
111
- t.addClass('active');
112
- }
113
- }
114
- parent = parent.parentNode;
115
- }
116
- // Scrolling to center active TOC element if TOC content is taller than viewport.
117
- if (getComputedStyle(sideBar).display !== 'none' && tocElement.hasClass('active')) {
118
- pageScroll(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
119
- }
120
- };
121
- const navItems = $dom.all('.contents li');
122
- if (navItems.length < 1) {
123
- return;
124
- }
125
- let sections = [...navItems];
126
- let activeLock = null;
127
- sections = sections.map((element, index) => {
128
- const link = element.child('a.toc-link');
129
- const anchor = $dom(decodeURI(link.attr('href')));
130
- if (!anchor)
131
- return null;
132
- const alink = anchor.child('a.anchor');
133
- const anchorScroll = (event) => {
134
- event.preventDefault();
135
- const target = $dom(decodeURI(event.currentTarget.attr('href')));
136
- activeLock = index;
137
- pageScroll(target, null, () => {
138
- activateNavByIndex(index);
139
- activeLock = null;
140
- });
141
- };
142
- // TOC item animation navigate.
143
- link.addEventListener('click', anchorScroll);
144
- alink && alink.addEventListener('click', (event) => {
145
- anchorScroll(event);
146
- clipBoard(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
147
- });
148
- return anchor;
149
- });
150
- const tocElement = sideBar.child('.contents.panel');
151
- const findIndex = (entries) => {
152
- let index = 0;
153
- let entry = entries[index];
154
- if (entry.boundingClientRect.top > 0) {
155
- index = sections.indexOf(entry.target);
156
- return index === 0 ? 0 : index - 1;
157
- }
158
- for (; index < entries.length; index++) {
159
- if (entries[index].boundingClientRect.top <= 0) {
160
- entry = entries[index];
161
- }
162
- else {
163
- return sections.indexOf(entry.target);
164
- }
165
- }
166
- return sections.indexOf(entry.target);
167
- };
168
- const createIntersectionObserver = () => {
169
- const observer = new IntersectionObserver((entries) => {
170
- const index = findIndex(entries) + (diffY < 0 ? 1 : 0);
171
- if (activeLock === null) {
172
- activateNavByIndex(index);
173
- }
174
- }, {
175
- rootMargin: '0px 0px -100% 0px', threshold: 0
176
- });
177
- sections.forEach((element) => {
178
- element && observer.observe(element);
179
- });
180
- };
181
- createIntersectionObserver();
182
- };
183
- export const backToTopHandle = () => {
184
- pageScroll(0);
185
- };
186
- export const goToBottomHandle = () => {
187
- pageScroll(parseInt(String(Container.changeOrGetHeight())));
188
- };
189
- export const goToCommentHandle = () => {
190
- pageScroll($dom('#comments'));
191
- };
192
- export const menuActive = () => {
193
- $dom.each('.menu .item:not(.title)', (element) => {
194
- const target = element.child('a[href]');
195
- const parentItem = element.parentNode.parentNode;
196
- if (!target)
197
- return;
198
- const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '');
199
- const isSubPath = !CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname);
200
- const active = target.hostname === location.hostname && (isSamePath || isSubPath);
201
- element.toggleClass('active', active);
202
- if (element.parentNode.child('.active') && parentItem.hasClass('dropdown')) {
203
- parentItem.removeClass('active').addClass('expand');
204
- }
205
- else {
206
- parentItem.removeClass('expand');
207
- }
208
- });
209
- };
@@ -1,10 +0,0 @@
1
- import firework from 'mouse-firework';
2
- /*
3
- * 烟花分区
4
- */
5
- export function initFireworks() {
6
- if (typeof CONFIG.fireworks === 'undefined') {
7
- return;
8
- }
9
- firework(CONFIG.fireworks);
10
- }
@@ -1,80 +0,0 @@
1
- import { $dom } from '../library/dom';
2
- import initProto from '../library/proto';
3
- initProto();
4
- export const statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root;
5
- export const scrollAction = { x: 0, y: 0 };
6
- export let diffY = 0;
7
- export let originTitle, titleTime;
8
- export const BODY = document.getElementsByTagName('body')[0];
9
- export const HTML = document.documentElement;
10
- export const Container = $dom('#container');
11
- export const loadCat = $dom('#loading');
12
- export const siteNav = $dom('#nav');
13
- export const siteHeader = $dom('#header');
14
- export const menuToggle = siteNav.child('.toggle');
15
- export const quickBtn = $dom('#quick');
16
- export const sideBar = $dom('#sidebar');
17
- export const siteBrand = $dom('#brand');
18
- export let toolBtn = $dom('#tool');
19
- export let toolPlayer;
20
- export let backToTop;
21
- export let goToComment;
22
- export let showContents;
23
- export let siteSearch = $dom('#search');
24
- export let siteNavHeight, headerHightInner, headerHight;
25
- export let oWinHeight = window.innerHeight;
26
- export let oWinWidth = window.innerWidth;
27
- export let LOCAL_HASH = 0;
28
- export let LOCAL_URL = window.location.href;
29
- export let pjax;
30
- export function setSiteNavHeight(value) {
31
- siteNavHeight = value;
32
- }
33
- export function setHeaderHightInner(value) {
34
- headerHightInner = value;
35
- }
36
- export function setHeaderHight(value) {
37
- headerHight = value;
38
- }
39
- export function setOWinHeight(value) {
40
- oWinHeight = value;
41
- }
42
- export function setOWinWidth(value) {
43
- oWinWidth = value;
44
- }
45
- export function setDiffY(value) {
46
- diffY = value;
47
- }
48
- export function setTitleTime(value) {
49
- titleTime = value;
50
- }
51
- export function setLocalHash(value) {
52
- LOCAL_HASH = value;
53
- }
54
- export function setLocalUrl(value) {
55
- LOCAL_URL = value;
56
- }
57
- export function setPjax(value) {
58
- pjax = value;
59
- }
60
- export function setOriginTitle(value) {
61
- originTitle = value;
62
- }
63
- export function setToolPlayer(value) {
64
- toolPlayer = value;
65
- }
66
- export function setBackToTop(value) {
67
- backToTop = value;
68
- }
69
- export function setGoToComment(value) {
70
- goToComment = value;
71
- }
72
- export function setShowContents(value) {
73
- showContents = value;
74
- }
75
- export function setToolBtn(value) {
76
- toolBtn = value;
77
- }
78
- export function setSiteSearch(value) {
79
- siteSearch = value;
80
- }
@@ -1,98 +0,0 @@
1
- import { sideBarToggleHandle } from '../components/sidebar';
2
- import { $dom, getDocHeight } from '../library/dom';
3
- import { backToTop, diffY, headerHight, headerHightInner, oWinWidth, originTitle, scrollAction, sideBar, siteBrand, siteHeader, siteNav, statics, titleTime, toolBtn, setSiteNavHeight, setHeaderHightInner, setHeaderHight, setOWinHeight, setOWinWidth, setDiffY, setTitleTime } from './globalVars';
4
- import { changeMetaTheme } from './themeColor';
5
- import { Loader } from './thirdparty';
6
- export const resizeHandle = () => {
7
- // 获取 siteNav 的高度
8
- setSiteNavHeight(siteNav.changeOrGetHeight());
9
- // 获取 siteHeader 的高度
10
- setHeaderHightInner(siteHeader.changeOrGetHeight());
11
- // 获取 #waves 的高度
12
- setHeaderHight(headerHightInner + $dom('#waves').changeOrGetHeight());
13
- // 判断窗口宽度是否改变
14
- if (oWinWidth !== window.innerWidth) {
15
- sideBarToggleHandle(null, 1);
16
- }
17
- // 记录窗口高度和宽度
18
- setOWinHeight(window.innerHeight);
19
- setOWinWidth(window.innerWidth);
20
- };
21
- export const scrollHandle = () => {
22
- // 获取窗口高度
23
- const winHeight = window.innerHeight;
24
- // 获取文档高度
25
- const docHeight = getDocHeight();
26
- // 计算可见内容高度
27
- const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
28
- // 判断页面是否滚动超过 headerHightInner
29
- const SHOW = window.scrollY > headerHightInner;
30
- // 判断页面是否开始滚动
31
- const startScroll = window.scrollY > 0;
32
- // 根据条件修改 meta theme
33
- if (SHOW) {
34
- changeMetaTheme('#FFF');
35
- }
36
- else {
37
- changeMetaTheme('#222');
38
- }
39
- // 控制导航栏的显示隐藏
40
- siteNav.toggleClass('show', SHOW);
41
- // 控制网站 logo 的显示隐藏
42
- toolBtn.toggleClass('affix', startScroll);
43
- // 控制侧边栏的显示隐藏,当滚动高度大于 headerHight 且窗口宽度大于 991px 时显示
44
- siteBrand.toggleClass('affix', startScroll);
45
- sideBar.toggleClass('affix', window.scrollY > headerHight && document.body.offsetWidth > 991);
46
- // 初始化滚动时导航栏的显示方向
47
- if (typeof scrollAction.y === 'undefined') {
48
- scrollAction.y = window.scrollY;
49
- }
50
- setDiffY(scrollAction.y - window.scrollY);
51
- // 控制滑动时导航栏显示
52
- if (diffY < 0) {
53
- siteNav.removeClass('up');
54
- siteNav.toggleClass('down', SHOW);
55
- }
56
- else if (diffY > 0) {
57
- siteNav.removeClass('down');
58
- siteNav.toggleClass('up', SHOW);
59
- }
60
- else { /* empty */ }
61
- scrollAction.y = window.scrollY;
62
- // 计算滚动百分比
63
- const scrollPercent = Math.round(Math.min(100 * window.scrollY / contentVisibilityHeight, 100)) + '%';
64
- // 更新回到顶部按钮的文字
65
- if (backToTop.child('span').innerText !== scrollPercent) {
66
- backToTop.child('span').innerText = scrollPercent;
67
- }
68
- // 更新百分比进度条的宽度
69
- if ($dom('#sidebar').hasClass('affix') || $dom('#sidebar').hasClass('on')) {
70
- $dom('.percent').changeOrGetWidth(scrollPercent);
71
- }
72
- };
73
- // 可见度监听(离开页面和返回时更改document的title)
74
- export const visibilityListener = () => {
75
- const iconNode = $dom('[rel="icon"]');
76
- document.addEventListener('visibilitychange', () => {
77
- switch (document.visibilityState) {
78
- case 'hidden':
79
- iconNode.attr('href', statics + CONFIG.favicon.hidden);
80
- document.title = LOCAL.favicon.hide;
81
- if (CONFIG.loader.switch) {
82
- Loader.show();
83
- }
84
- clearTimeout(titleTime);
85
- break;
86
- case 'visible':
87
- iconNode.attr('href', statics + CONFIG.favicon.normal);
88
- document.title = LOCAL.favicon.show;
89
- if (CONFIG.loader.switch) {
90
- Loader.hide(1000);
91
- }
92
- setTitleTime(setTimeout(() => {
93
- document.title = originTitle;
94
- }, 2000));
95
- break;
96
- }
97
- });
98
- };
@@ -1,62 +0,0 @@
1
- import { $storage } from '../library/storage';
2
- import { $dom } from '../library/dom';
3
- import { HTML } from './globalVars';
4
- /**
5
- * 更改日夜模式
6
- */
7
- export const changeTheme = (type) => {
8
- const btn = $dom('.theme .ic');
9
- if (type === 'dark') {
10
- HTML.attr('data-theme', type);
11
- btn.removeClass('i-sun');
12
- btn.addClass('i-moon');
13
- }
14
- else {
15
- HTML.attr('data-theme', null);
16
- btn.removeClass('i-moon');
17
- btn.addClass('i-sun');
18
- }
19
- };
20
- /**
21
- * 自动调整黑夜白天
22
- * 优先级: 手动选择>时间>跟随系统
23
- */
24
- export const autoDarkmode = () => {
25
- if (CONFIG.auto_dark.enable) {
26
- if (new Date().getHours() >= CONFIG.auto_dark.start || new Date().getHours() <= CONFIG.auto_dark.end) {
27
- changeTheme('dark');
28
- }
29
- else {
30
- changeTheme();
31
- }
32
- }
33
- };
34
- /**
35
- * 更改主题的meta
36
- */
37
- export const changeMetaTheme = (color) => {
38
- if (HTML.attr('data-theme') === 'dark') {
39
- color = '#222';
40
- }
41
- $dom('meta[name="theme-color"]').attr('content', color);
42
- };
43
- // 记忆日夜模式切换和系统亮暗模式监听
44
- export const themeColorListener = () => {
45
- window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mediaQueryList) => {
46
- if (mediaQueryList.matches) {
47
- changeTheme('dark');
48
- }
49
- else {
50
- changeTheme();
51
- }
52
- });
53
- const t = $storage.get('theme');
54
- if (t) {
55
- changeTheme(t);
56
- }
57
- else {
58
- if (CONFIG.darkmode) {
59
- changeTheme('dark');
60
- }
61
- }
62
- };
@@ -1,62 +0,0 @@
1
- // 与第三方js的交互或第三方嵌入js
2
- import { loadCat } from './globalVars';
3
- import { transition } from '../library/anime';
4
- // 加载动画
5
- export const Loader = {
6
- timer: undefined,
7
- lock: false,
8
- show() {
9
- clearTimeout(this.timer);
10
- document.body.removeClass('loaded');
11
- loadCat.attr('style', 'display:block');
12
- Loader.lock = false;
13
- },
14
- hide(sec) {
15
- if (!CONFIG.loader.start) {
16
- sec = -1;
17
- }
18
- this.timer = setTimeout(this.vanish, sec || 3000);
19
- },
20
- vanish() {
21
- if (Loader.lock) {
22
- return;
23
- }
24
- if (CONFIG.loader.start) {
25
- transition(loadCat, 0);
26
- }
27
- document.body.addClass('loaded');
28
- Loader.lock = true;
29
- }
30
- };
31
- export const isOutime = () => {
32
- let updateTime;
33
- if (CONFIG.outime.enable && LOCAL.outime) {
34
- const times = document.getElementsByTagName('time');
35
- if (times.length === 0) {
36
- return;
37
- }
38
- const posts = document.getElementsByClassName('body md');
39
- if (posts.length === 0) {
40
- return;
41
- }
42
- const now = Date.now(); // 当前时间戳
43
- const pubTime = new Date(times[0].dateTime); // 文章发布时间戳
44
- if (times.length === 1) {
45
- updateTime = pubTime; // 文章发布时间亦是最后更新时间
46
- }
47
- else {
48
- updateTime = new Date(times[1].dateTime); // 文章最后更新时间戳
49
- }
50
- // @ts-ignore
51
- const interval = parseInt(String(now - updateTime)); // 时间差
52
- const days = parseInt(String(CONFIG.outime.days)) || 30; // 设置时效,默认硬编码 30 天
53
- // 最后一次更新时间超过 days 天(毫秒)
54
- if (interval > (days * 86400000)) {
55
- // @ts-ignore
56
- const publish = parseInt(String((now - pubTime) / 86400000));
57
- const updated = parseInt(String(interval / 86400000));
58
- const template = LOCAL.template.replace('{{publish}}', String(publish)).replace('{{updated}}', String(updated));
59
- posts[0].insertAdjacentHTML('afterbegin', template);
60
- }
61
- }
62
- };
@@ -1,66 +0,0 @@
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) => {
7
- if (!msg) {
8
- return;
9
- }
10
- const tipbox = BODY.createChild('div', {
11
- innerHTML: msg,
12
- className: 'tip'
13
- });
14
- setTimeout(() => {
15
- tipbox.addClass('hide');
16
- setTimeout(() => {
17
- BODY.removeChild(tipbox);
18
- }, 300);
19
- }, 3000);
20
- };
21
- export const pagePosition = () => {
22
- // 判断配置项是否开启了自动记录滚动位置
23
- if (CONFIG.auto_scroll) {
24
- // 将当前页面的滚动位置存入本地缓存
25
- $storage.set(LOCAL_URL, String(scrollAction.y));
26
- }
27
- };
28
- export const positionInit = (comment) => {
29
- // 获取页面锚点
30
- const anchor = window.location.hash;
31
- let target = null;
32
- if (LOCAL_HASH) {
33
- $storage.del(LOCAL_URL);
34
- return;
35
- }
36
- if (anchor) {
37
- target = $dom(decodeURI(anchor));
38
- }
39
- else {
40
- target = CONFIG.auto_scroll ? parseInt($storage.get(LOCAL_URL)) : 0;
41
- }
42
- if (target) {
43
- pageScroll(target);
44
- setLocalHash(1);
45
- }
46
- if (comment && anchor && !LOCAL_HASH) {
47
- pageScroll(target);
48
- setLocalHash(1);
49
- }
50
- };
51
- /*
52
- 基于clipboard API的复制功能,仅在https环境下有效
53
- */
54
- export const clipBoard = (str, callback) => {
55
- if (navigator.clipboard && window.isSecureContext) {
56
- navigator.clipboard.writeText(str).then(() => {
57
- callback && callback(true);
58
- }, () => {
59
- callback && callback(false);
60
- });
61
- }
62
- else {
63
- console.error('Too old browser, clipborad API not supported.');
64
- callback && callback(false);
65
- }
66
- };