hexo-theme-shokax 0.3.9 → 0.3.11

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 (49) hide show
  1. package/README.md +4 -1
  2. package/_config.yml +26 -28
  3. package/layout/_mixin/comment.pug +1 -34
  4. package/layout/_mixin/segment.pug +1 -1
  5. package/layout/_partials/head/head.pug +1 -4
  6. package/layout/_partials/layout.pug +2 -2
  7. package/package.json +18 -17
  8. package/scripts/filters/locals.js +6 -0
  9. package/scripts/filters/post.js +2 -0
  10. package/scripts/generaters/archive.js +13 -1
  11. package/scripts/generaters/config.js +4 -1
  12. package/scripts/generaters/images.js +2 -0
  13. package/scripts/generaters/index.js +5 -2
  14. package/scripts/generaters/pages.js +0 -2
  15. package/scripts/generaters/script.js +34 -9
  16. package/scripts/helpers/asset.js +16 -7
  17. package/scripts/helpers/engine.js +24 -1
  18. package/scripts/helpers/list_categories.js +4 -0
  19. package/scripts/helpers/summary_ai.js +4 -0
  20. package/scripts/helpers/symbols_count_time.js +14 -8
  21. package/scripts/plugin/check.js +5 -3
  22. package/scripts/plugin/index.js +36 -9
  23. package/scripts/plugin/lib/injects.js +15 -0
  24. package/scripts/tags/media.js +1 -0
  25. package/source/js/_app/components/sidebar.js +54 -56
  26. package/source/js/_app/fireworks.js +6 -137
  27. package/source/js/_app/globals/globalVars.js +80 -96
  28. package/source/js/_app/globals/handles.js +81 -60
  29. package/source/js/_app/globals/themeColor.js +30 -26
  30. package/source/js/_app/globals/thirdparty.js +25 -24
  31. package/source/js/_app/globals/tools.js +36 -30
  32. package/source/js/_app/library/anime.js +31 -17
  33. package/source/js/_app/library/dom.js +12 -5
  34. package/source/js/_app/library/loadFile.js +7 -9
  35. package/source/js/_app/library/proto.js +59 -7
  36. package/source/js/_app/library/scriptPjax.js +14 -9
  37. package/source/js/_app/library/storage.js +2 -4
  38. package/source/js/_app/library/vue.js +16 -19
  39. package/source/js/_app/page/comment.js +10 -11
  40. package/source/js/_app/page/common.js +8 -12
  41. package/source/js/_app/page/fancybox.js +13 -14
  42. package/source/js/_app/page/post.js +43 -45
  43. package/source/js/_app/page/search.js +20 -20
  44. package/source/js/_app/page/tab.js +7 -10
  45. package/source/js/_app/pjax/domInit.js +29 -29
  46. package/source/js/_app/pjax/refresh.js +45 -50
  47. package/source/js/_app/pjax/siteInit.js +27 -31
  48. package/source/js/_app/player.js +44 -27
  49. package/test/dom.test.js +0 -86
@@ -1,96 +1,80 @@
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
- exports.setSiteSearch = exports.setToolBtn = exports.setShowContents = exports.setGoToComment = exports.setBackToTop = exports.setToolPlayer = exports.setOriginTitle = exports.setPjax = exports.setLocalUrl = exports.setLocalHash = exports.setTitleTime = exports.setDiffY = exports.setOWinWidth = exports.setOWinHeight = exports.setHeaderHight = exports.setHeaderHightInner = exports.setSiteNavHeight = exports.pjax = exports.LOCAL_URL = exports.LOCAL_HASH = exports.oWinWidth = exports.oWinHeight = exports.headerHight = exports.headerHightInner = exports.siteNavHeight = exports.siteSearch = exports.showContents = exports.goToComment = exports.backToTop = exports.toolPlayer = exports.toolBtn = exports.siteBrand = exports.sideBar = exports.quickBtn = exports.menuToggle = exports.siteHeader = exports.siteNav = exports.loadCat = exports.Container = exports.HTML = exports.BODY = exports.titleTime = exports.originTitle = exports.diffY = exports.scrollAction = exports.statics = void 0;
7
- const dom_1 = require("../library/dom");
8
- const proto_1 = __importDefault(require("../library/proto"));
9
- (0, proto_1.default)();
10
- exports.statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root;
11
- exports.scrollAction = { x: 0, y: 0 };
12
- exports.diffY = 0;
13
- exports.BODY = document.getElementsByTagName('body')[0];
14
- exports.HTML = document.documentElement;
15
- exports.Container = (0, dom_1.$dom)('#container');
16
- exports.loadCat = (0, dom_1.$dom)('#loading');
17
- exports.siteNav = (0, dom_1.$dom)('#nav');
18
- exports.siteHeader = (0, dom_1.$dom)('#header');
19
- exports.menuToggle = exports.siteNav.child('.toggle');
20
- exports.quickBtn = (0, dom_1.$dom)('#quick');
21
- exports.sideBar = (0, dom_1.$dom)('#sidebar');
22
- exports.siteBrand = (0, dom_1.$dom)('#brand');
23
- exports.toolBtn = (0, dom_1.$dom)('#tool');
24
- exports.siteSearch = (0, dom_1.$dom)('#search');
25
- exports.oWinHeight = window.innerHeight;
26
- exports.oWinWidth = window.innerWidth;
27
- exports.LOCAL_HASH = 0;
28
- exports.LOCAL_URL = window.location.href;
29
- function setSiteNavHeight(value) {
30
- exports.siteNavHeight = value;
31
- }
32
- exports.setSiteNavHeight = setSiteNavHeight;
33
- function setHeaderHightInner(value) {
34
- exports.headerHightInner = value;
35
- }
36
- exports.setHeaderHightInner = setHeaderHightInner;
37
- function setHeaderHight(value) {
38
- exports.headerHight = value;
39
- }
40
- exports.setHeaderHight = setHeaderHight;
41
- function setOWinHeight(value) {
42
- exports.oWinHeight = value;
43
- }
44
- exports.setOWinHeight = setOWinHeight;
45
- function setOWinWidth(value) {
46
- exports.oWinWidth = value;
47
- }
48
- exports.setOWinWidth = setOWinWidth;
49
- function setDiffY(value) {
50
- exports.diffY = value;
51
- }
52
- exports.setDiffY = setDiffY;
53
- function setTitleTime(value) {
54
- exports.titleTime = value;
55
- }
56
- exports.setTitleTime = setTitleTime;
57
- function setLocalHash(value) {
58
- exports.LOCAL_HASH = value;
59
- }
60
- exports.setLocalHash = setLocalHash;
61
- function setLocalUrl(value) {
62
- exports.LOCAL_URL = value;
63
- }
64
- exports.setLocalUrl = setLocalUrl;
65
- function setPjax(value) {
66
- exports.pjax = value;
67
- }
68
- exports.setPjax = setPjax;
69
- function setOriginTitle(value) {
70
- exports.originTitle = value;
71
- }
72
- exports.setOriginTitle = setOriginTitle;
73
- function setToolPlayer(value) {
74
- exports.toolPlayer = value;
75
- }
76
- exports.setToolPlayer = setToolPlayer;
77
- function setBackToTop(value) {
78
- exports.backToTop = value;
79
- }
80
- exports.setBackToTop = setBackToTop;
81
- function setGoToComment(value) {
82
- exports.goToComment = value;
83
- }
84
- exports.setGoToComment = setGoToComment;
85
- function setShowContents(value) {
86
- exports.showContents = value;
87
- }
88
- exports.setShowContents = setShowContents;
89
- function setToolBtn(value) {
90
- exports.toolBtn = value;
91
- }
92
- exports.setToolBtn = setToolBtn;
93
- function setSiteSearch(value) {
94
- exports.siteSearch = value;
95
- }
96
- exports.setSiteSearch = setSiteSearch;
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,80 +1,102 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.visibilityListener = exports.clickMenu = exports.scrollHandle = exports.resizeHandle = void 0;
4
- const sidebar_1 = require("../components/sidebar");
5
- const dom_1 = require("../library/dom");
6
- const globalVars_1 = require("./globalVars");
7
- const themeColor_1 = require("./themeColor");
8
- const thirdparty_1 = require("./thirdparty");
9
- const resizeHandle = () => {
10
- (0, globalVars_1.setSiteNavHeight)(globalVars_1.siteNav.changeOrGetHeight());
11
- (0, globalVars_1.setHeaderHightInner)(globalVars_1.siteHeader.changeOrGetHeight());
12
- (0, globalVars_1.setHeaderHight)(globalVars_1.headerHightInner + (0, dom_1.$dom)('#waves').changeOrGetHeight());
13
- if (globalVars_1.oWinWidth !== window.innerWidth) {
14
- (0, sidebar_1.sideBarToggleHandle)(null, 1);
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);
15
16
  }
16
- (0, globalVars_1.setOWinHeight)(window.innerHeight);
17
- (0, globalVars_1.setOWinWidth)(window.innerWidth);
17
+ // 记录窗口高度和宽度
18
+ setOWinHeight(window.innerHeight);
19
+ setOWinWidth(window.innerWidth);
18
20
  };
19
- exports.resizeHandle = resizeHandle;
20
- const scrollHandle = () => {
21
+ export const scrollHandle = () => {
22
+ // 获取窗口高度
21
23
  const winHeight = window.innerHeight;
22
- const docHeight = (0, dom_1.getDocHeight)();
24
+ // 获取文档高度
25
+ const docHeight = getDocHeight();
26
+ // 计算可见内容高度
23
27
  const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
24
- const SHOW = window.scrollY > globalVars_1.headerHightInner;
28
+ // 判断页面是否滚动超过 headerHightInner
29
+ const SHOW = window.scrollY > headerHightInner;
30
+ // 判断页面是否开始滚动
25
31
  const startScroll = window.scrollY > 0;
32
+ // 根据条件修改 meta theme
26
33
  if (SHOW) {
27
- (0, themeColor_1.changeMetaTheme)('#FFF');
34
+ changeMetaTheme('#FFF');
28
35
  }
29
36
  else {
30
- (0, themeColor_1.changeMetaTheme)('#222');
37
+ changeMetaTheme('#222');
31
38
  }
32
- globalVars_1.siteNav.toggleClass('show', SHOW);
33
- globalVars_1.toolBtn.toggleClass('affix', startScroll);
34
- globalVars_1.siteBrand.toggleClass('affix', startScroll);
35
- globalVars_1.sideBar.toggleClass('affix', window.scrollY > globalVars_1.headerHight && document.body.offsetWidth > 991);
36
- if (typeof globalVars_1.scrollAction.y === 'undefined') {
37
- globalVars_1.scrollAction.y = window.scrollY;
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;
38
49
  }
39
- (0, globalVars_1.setDiffY)(globalVars_1.scrollAction.y - window.scrollY);
40
- if (globalVars_1.diffY < 0) {
41
- globalVars_1.siteNav.removeClass('up');
42
- globalVars_1.siteNav.toggleClass('down', SHOW);
50
+ setDiffY(scrollAction.y - window.scrollY);
51
+ // 控制滑动时导航栏显示
52
+ if (diffY < 0) {
53
+ siteNav.removeClass('up');
54
+ siteNav.toggleClass('down', SHOW);
43
55
  }
44
- else if (globalVars_1.diffY > 0) {
45
- globalVars_1.siteNav.removeClass('down');
46
- globalVars_1.siteNav.toggleClass('up', SHOW);
56
+ else if (diffY > 0) {
57
+ siteNav.removeClass('down');
58
+ siteNav.toggleClass('up', SHOW);
47
59
  }
48
- else { }
49
- globalVars_1.scrollAction.y = window.scrollY;
60
+ else { /* empty */ }
61
+ scrollAction.y = window.scrollY;
62
+ // 计算滚动百分比
50
63
  const scrollPercent = Math.round(Math.min(100 * window.scrollY / contentVisibilityHeight, 100)) + '%';
51
- if (globalVars_1.backToTop.child('span').innerText !== scrollPercent) {
52
- globalVars_1.backToTop.child('span').innerText = scrollPercent;
64
+ // 更新回到顶部按钮的文字
65
+ if (backToTop.child('span').innerText !== scrollPercent) {
66
+ backToTop.child('span').innerText = scrollPercent;
53
67
  }
54
- if ((0, dom_1.$dom)('#sidebar').hasClass('affix') || (0, dom_1.$dom)('#sidebar').hasClass('on')) {
55
- (0, dom_1.$dom)('.percent').changeOrGetWidth(scrollPercent);
68
+ // 更新百分比进度条的宽度
69
+ if ($dom('#sidebar').hasClass('affix') || $dom('#sidebar').hasClass('on')) {
70
+ $dom('.percent').changeOrGetWidth(scrollPercent);
56
71
  }
57
72
  };
58
- exports.scrollHandle = scrollHandle;
59
- const clickMenu = () => {
60
- const menuElement = (0, dom_1.$dom)('#clickMenu');
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');
61
83
  window.oncontextmenu = function (event) {
62
- if (event.ctrlKey) {
84
+ if (event.ctrlKey) { // 当按下ctrl键时不触发自定义菜单
63
85
  return;
64
86
  }
65
87
  event.preventDefault();
66
- let x = event.offsetX;
88
+ let x = event.offsetX; // 触发点到页面窗口左边的距离
67
89
  let y = event.offsetY;
68
- const winWidth = window.innerWidth;
90
+ const winWidth = window.innerWidth; // 窗口的内部宽度(包括滚动条)
69
91
  const winHeight = window.innerHeight;
70
- const menuWidth = menuElement.offsetWidth;
92
+ const menuWidth = menuElement.offsetWidth; // 菜单宽度
71
93
  const menuHeight = menuElement.offsetHeight;
72
94
  x = winWidth - menuWidth >= x ? x : winWidth - menuWidth;
73
95
  y = winHeight - menuHeight >= y ? y : winHeight - menuHeight;
74
96
  menuElement.style.top = y + 'px';
75
97
  menuElement.style.left = x + 'px';
76
98
  menuElement.classList.add('active');
77
- dom_1.$dom.each('.clickSubmenu', (submenu) => {
99
+ $dom.each('.clickSubmenu', (submenu) => {
78
100
  if (x > (winWidth - menuWidth - submenu.offsetWidth)) {
79
101
  submenu.style.left = '-200px';
80
102
  }
@@ -88,30 +110,29 @@ const clickMenu = () => {
88
110
  menuElement.classList.remove('active');
89
111
  });
90
112
  };
91
- exports.clickMenu = clickMenu;
92
- const visibilityListener = () => {
93
- const iconNode = (0, dom_1.$dom)('[rel="icon"]');
113
+ // 可见度监听(离开页面和返回时更改document的title)
114
+ export const visibilityListener = () => {
115
+ const iconNode = $dom('[rel="icon"]');
94
116
  document.addEventListener('visibilitychange', () => {
95
117
  switch (document.visibilityState) {
96
118
  case 'hidden':
97
- iconNode.attr('href', globalVars_1.statics + CONFIG.favicon.hidden);
119
+ iconNode.attr('href', statics + CONFIG.favicon.hidden);
98
120
  document.title = LOCAL.favicon.hide;
99
121
  if (CONFIG.loader.switch) {
100
- thirdparty_1.Loader.show();
122
+ Loader.show();
101
123
  }
102
- clearTimeout(globalVars_1.titleTime);
124
+ clearTimeout(titleTime);
103
125
  break;
104
126
  case 'visible':
105
- iconNode.attr('href', globalVars_1.statics + CONFIG.favicon.normal);
127
+ iconNode.attr('href', statics + CONFIG.favicon.normal);
106
128
  document.title = LOCAL.favicon.show;
107
129
  if (CONFIG.loader.switch) {
108
- thirdparty_1.Loader.hide(1000);
130
+ Loader.hide(1000);
109
131
  }
110
- (0, globalVars_1.setTitleTime)(setTimeout(() => {
111
- document.title = globalVars_1.originTitle;
132
+ setTitleTime(setTimeout(() => {
133
+ document.title = originTitle;
112
134
  }, 2000));
113
135
  break;
114
136
  }
115
137
  });
116
138
  };
117
- exports.visibilityListener = visibilityListener;
@@ -1,58 +1,62 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.themeColorListener = exports.changeMetaTheme = exports.autoDarkmode = exports.changeTheme = void 0;
4
- const storage_1 = require("../library/storage");
5
- const dom_1 = require("../library/dom");
6
- const globalVars_1 = require("./globalVars");
7
- const changeTheme = (type) => {
8
- const btn = (0, dom_1.$dom)('.theme .ic');
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
9
  if (type === 'dark') {
10
- globalVars_1.HTML.attr('data-theme', type);
10
+ HTML.attr('data-theme', type);
11
11
  btn.removeClass('i-sun');
12
12
  btn.addClass('i-moon');
13
13
  }
14
14
  else {
15
- globalVars_1.HTML.attr('data-theme', null);
15
+ HTML.attr('data-theme', null);
16
16
  btn.removeClass('i-moon');
17
17
  btn.addClass('i-sun');
18
18
  }
19
19
  };
20
- exports.changeTheme = changeTheme;
21
- const autoDarkmode = () => {
20
+ /**
21
+ * 自动调整黑夜白天
22
+ * 优先级: 手动选择>时间>跟随系统
23
+ */
24
+ export const autoDarkmode = () => {
22
25
  if (CONFIG.auto_dark.enable) {
23
26
  if (new Date().getHours() >= CONFIG.auto_dark.start || new Date().getHours() <= CONFIG.auto_dark.end) {
24
- (0, exports.changeTheme)('dark');
27
+ changeTheme('dark');
25
28
  }
26
29
  else {
27
- (0, exports.changeTheme)();
30
+ changeTheme();
28
31
  }
29
32
  }
30
33
  };
31
- exports.autoDarkmode = autoDarkmode;
32
- const changeMetaTheme = (color) => {
33
- if (globalVars_1.HTML.attr('data-theme') === 'dark') {
34
+ /**
35
+ * 更改主题的meta
36
+ */
37
+ export const changeMetaTheme = (color) => {
38
+ if (HTML.attr('data-theme') === 'dark') {
34
39
  color = '#222';
35
40
  }
36
- (0, dom_1.$dom)('meta[name="theme-color"]').attr('content', color);
41
+ $dom('meta[name="theme-color"]').attr('content', color);
37
42
  };
38
- exports.changeMetaTheme = changeMetaTheme;
39
- const themeColorListener = () => {
43
+ // 记忆日夜模式切换和系统亮暗模式监听
44
+ export const themeColorListener = () => {
40
45
  window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mediaQueryList) => {
41
46
  if (mediaQueryList.matches) {
42
- (0, exports.changeTheme)('dark');
47
+ changeTheme('dark');
43
48
  }
44
49
  else {
45
- (0, exports.changeTheme)();
50
+ changeTheme();
46
51
  }
47
52
  });
48
- const t = storage_1.$storage.get('theme');
53
+ const t = $storage.get('theme');
49
54
  if (t) {
50
- (0, exports.changeTheme)(t);
55
+ changeTheme(t);
51
56
  }
52
57
  else {
53
58
  if (CONFIG.darkmode) {
54
- (0, exports.changeTheme)('dark');
59
+ changeTheme('dark');
55
60
  }
56
61
  }
57
62
  };
58
- exports.themeColorListener = themeColorListener;
@@ -1,25 +1,24 @@
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
- exports.isOutime = exports.Loader = exports.lazyload = void 0;
7
- const lozad_1 = __importDefault(require("lozad"));
8
- const globalVars_1 = require("./globalVars");
9
- const anime_1 = require("../library/anime");
10
- exports.lazyload = (0, lozad_1.default)('img, [data-background-image]', {
1
+ // 与第三方js的交互或第三方嵌入js
2
+ import lozad from 'lozad';
3
+ import { loadCat } from './globalVars';
4
+ import { transition } from '../library/anime';
5
+ /**
6
+ * 懒加载图片
7
+ */
8
+ export const lazyload = lozad('img, [data-background-image]', {
11
9
  loaded(el) {
12
10
  el.addClass('lozaded');
13
11
  }
14
12
  });
15
- exports.Loader = {
13
+ // 加载动画
14
+ export const Loader = {
16
15
  timer: undefined,
17
16
  lock: false,
18
17
  show() {
19
18
  clearTimeout(this.timer);
20
19
  document.body.removeClass('loaded');
21
- globalVars_1.loadCat.attr('style', 'display:block');
22
- exports.Loader.lock = false;
20
+ loadCat.attr('style', 'display:block');
21
+ Loader.lock = false;
23
22
  },
24
23
  hide(sec) {
25
24
  if (!CONFIG.loader.start) {
@@ -28,17 +27,17 @@ exports.Loader = {
28
27
  this.timer = setTimeout(this.vanish, sec || 3000);
29
28
  },
30
29
  vanish() {
31
- if (exports.Loader.lock) {
30
+ if (Loader.lock) {
32
31
  return;
33
32
  }
34
33
  if (CONFIG.loader.start) {
35
- (0, anime_1.transition)(globalVars_1.loadCat, 0);
34
+ transition(loadCat, 0);
36
35
  }
37
36
  document.body.addClass('loaded');
38
- exports.Loader.lock = true;
37
+ Loader.lock = true;
39
38
  }
40
39
  };
41
- const isOutime = () => {
40
+ export const isOutime = () => {
42
41
  let updateTime;
43
42
  if (CONFIG.outime.enable && LOCAL.outime) {
44
43
  const times = document.getElementsByTagName('time');
@@ -49,17 +48,20 @@ const isOutime = () => {
49
48
  if (posts.length === 0) {
50
49
  return;
51
50
  }
52
- const now = Date.now();
53
- const pubTime = new Date(times[0].dateTime);
51
+ const now = Date.now(); // 当前时间戳
52
+ const pubTime = new Date(times[0].dateTime); // 文章发布时间戳
54
53
  if (times.length === 1) {
55
- updateTime = pubTime;
54
+ updateTime = pubTime; // 文章发布时间亦是最后更新时间
56
55
  }
57
56
  else {
58
- updateTime = new Date(times[1].dateTime);
57
+ updateTime = new Date(times[1].dateTime); // 文章最后更新时间戳
59
58
  }
60
- const interval = parseInt(String(now - updateTime));
61
- const days = parseInt(String(CONFIG.outime.days)) || 30;
59
+ // @ts-ignore
60
+ const interval = parseInt(String(now - updateTime)); // 时间差
61
+ const days = parseInt(String(CONFIG.outime.days)) || 30; // 设置时效,默认硬编码 30 天
62
+ // 最后一次更新时间超过 days 天(毫秒)
62
63
  if (interval > (days * 86400000)) {
64
+ // @ts-ignore
63
65
  const publish = parseInt(String((now - pubTime) / 86400000));
64
66
  const updated = parseInt(String(interval / 86400000));
65
67
  const template = LOCAL.template.replace('{{publish}}', String(publish)).replace('{{updated}}', String(updated));
@@ -67,4 +69,3 @@ const isOutime = () => {
67
69
  }
68
70
  }
69
71
  };
70
- exports.isOutime = isOutime;