hexo-theme-shokax 0.3.12 → 0.4.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/README.md +10 -3
  2. package/README_en.MD +13 -5
  3. package/_config.yml +19 -16
  4. package/layout/_mixin/comment.pug +4 -4
  5. package/layout/_mixin/segment.pug +1 -1
  6. package/layout/_partials/head/head.pug +0 -1
  7. package/layout/_partials/post/post.pug +1 -1
  8. package/layout/_partials/post/reward.pug +1 -1
  9. package/layout/_partials/sidebar/overview.pug +1 -1
  10. package/package.json +11 -11
  11. package/scripts/filters/locals.d.ts +1 -0
  12. package/scripts/filters/locals.ts +59 -0
  13. package/scripts/filters/post.d.ts +0 -0
  14. package/scripts/filters/post.js +1 -1
  15. package/scripts/filters/post.ts +6 -0
  16. package/scripts/generaters/archive.d.ts +1 -0
  17. package/scripts/generaters/archive.ts +144 -0
  18. package/scripts/generaters/config.d.ts +1 -0
  19. package/scripts/generaters/config.ts +52 -0
  20. package/scripts/generaters/images.d.ts +1 -0
  21. package/scripts/generaters/images.ts +26 -0
  22. package/scripts/generaters/index.d.ts +1 -0
  23. package/scripts/generaters/index.ts +110 -0
  24. package/scripts/generaters/pages.d.ts +0 -0
  25. package/scripts/generaters/pages.ts +16 -0
  26. package/scripts/generaters/script.d.ts +1 -0
  27. package/scripts/generaters/script.js +25 -6
  28. package/scripts/generaters/script.ts +110 -0
  29. package/scripts/helpers/asset.d.ts +1 -0
  30. package/scripts/helpers/asset.ts +158 -0
  31. package/scripts/helpers/engine.d.ts +1 -0
  32. package/scripts/helpers/engine.ts +171 -0
  33. package/scripts/helpers/list_categories.d.ts +1 -0
  34. package/scripts/helpers/list_categories.ts +104 -0
  35. package/scripts/helpers/summary_ai.d.ts +1 -0
  36. package/scripts/helpers/summary_ai.js +1 -1
  37. package/scripts/helpers/summary_ai.ts +100 -0
  38. package/scripts/helpers/symbols_count_time.d.ts +1 -0
  39. package/scripts/helpers/symbols_count_time.ts +76 -0
  40. package/scripts/plugin/check.d.ts +1 -0
  41. package/scripts/plugin/check.ts +35 -0
  42. package/scripts/plugin/index.d.ts +6 -0
  43. package/scripts/plugin/index.ts +52 -0
  44. package/scripts/plugin/lib/injects-point.d.ts +5 -0
  45. package/scripts/plugin/lib/injects-point.ts +20 -0
  46. package/scripts/plugin/lib/injects.d.ts +2 -0
  47. package/scripts/plugin/lib/injects.ts +101 -0
  48. package/scripts/tags/links.d.ts +1 -0
  49. package/scripts/tags/links.ts +75 -0
  50. package/scripts/tags/media.d.ts +1 -0
  51. package/scripts/tags/media.ts +19 -0
  52. package/source/css/_common/components/tags/tabs.styl +3 -1
  53. package/source/css/_common/scaffolding/base.styl +6 -6
  54. package/source/css/_iconfont.styl +4 -0
  55. package/source/js/_app/components/sidebar.ts +237 -0
  56. package/source/js/_app/globals/globalVars.ts +98 -0
  57. package/source/js/_app/globals/handles.ts +122 -0
  58. package/source/js/_app/globals/themeColor.ts +64 -0
  59. package/source/js/_app/globals/thirdparty.ts +63 -0
  60. package/source/js/_app/globals/tools.ts +74 -0
  61. package/source/js/_app/library/anime.ts +109 -0
  62. package/source/js/_app/library/declare.d.ts +117 -0
  63. package/source/js/_app/library/dom.ts +26 -0
  64. package/source/js/_app/library/libtype.d.ts +4 -0
  65. package/source/js/_app/library/loadFile.ts +41 -0
  66. package/source/js/_app/library/proto.ts +143 -0
  67. package/source/js/_app/library/scriptPjax.ts +72 -0
  68. package/source/js/_app/library/storage.ts +12 -0
  69. package/source/js/_app/library/vue.ts +60 -0
  70. package/source/js/_app/page/common.ts +42 -0
  71. package/source/js/_app/page/fancybox.ts +70 -0
  72. package/source/js/_app/page/post.ts +265 -0
  73. package/source/js/_app/page/search.ts +129 -0
  74. package/source/js/_app/page/tab.ts +59 -0
  75. package/source/js/_app/pjax/domInit.ts +95 -0
  76. package/source/js/_app/pjax/refresh.ts +75 -0
  77. package/source/js/_app/pjax/siteInit.ts +67 -0
  78. package/source/js/_app/player.ts +798 -0
  79. package/source/css/twikoo.css +0 -2002
  80. package/source/js/_app/components/sidebar.js +0 -210
  81. package/source/js/_app/fireworks.js +0 -10
  82. package/source/js/_app/globals/globalVars.js +0 -80
  83. package/source/js/_app/globals/handles.js +0 -138
  84. package/source/js/_app/globals/themeColor.js +0 -62
  85. package/source/js/_app/globals/thirdparty.js +0 -71
  86. package/source/js/_app/globals/tools.js +0 -92
  87. package/source/js/_app/library/anime.js +0 -109
  88. package/source/js/_app/library/dom.js +0 -34
  89. package/source/js/_app/library/loadFile.js +0 -36
  90. package/source/js/_app/library/proto.js +0 -163
  91. package/source/js/_app/library/scriptPjax.js +0 -70
  92. package/source/js/_app/library/storage.js +0 -12
  93. package/source/js/_app/library/vue.js +0 -53
  94. package/source/js/_app/page/comment.js +0 -23
  95. package/source/js/_app/page/common.js +0 -41
  96. package/source/js/_app/page/fancybox.js +0 -65
  97. package/source/js/_app/page/post.js +0 -244
  98. package/source/js/_app/page/search.js +0 -118
  99. package/source/js/_app/page/tab.js +0 -53
  100. package/source/js/_app/pjax/domInit.js +0 -76
  101. package/source/js/_app/pjax/refresh.js +0 -53
  102. package/source/js/_app/pjax/siteInit.js +0 -49
  103. package/source/js/_app/player.js +0 -774
@@ -0,0 +1,109 @@
1
+ import anime from 'theme-shokax-anime'
2
+ import { siteNavHeight } from '../globals/globalVars'
3
+ import type { AnimeOptions } from 'theme-shokax-anime/dist/types'
4
+
5
+ /**
6
+ * 参数 动画效果
7
+ * 0 元素逐渐消失
8
+ * 1 元素逐渐出现
9
+ * bounceUpIn 元素从下方弹跳出现
10
+ * shrinkIn 元素从放大到正常大小出现
11
+ * slideRightIn 元素从右侧滑入
12
+ * slideRightOut 元素向右侧滑出
13
+ * TODO 函数功能过于复杂,需要拆分
14
+ */
15
+ export const transition = (target: HTMLElement, type: number|string|Function, complete?: Function, begin?: Function): void => {
16
+ let animation:Partial<AnimeOptions>
17
+ let display = 'none'
18
+ switch (type) {
19
+ case 0:
20
+ animation = { opacity: [1, 0] }
21
+ break
22
+ case 1:
23
+ animation = { opacity: [0, 1] }
24
+ display = 'block'
25
+ break
26
+ case 'bounceUpIn':
27
+ animation = {
28
+ begin (anim) {
29
+ target.display('block')
30
+ },
31
+ translateY: [
32
+ { value: -60, duration: 200 },
33
+ { value: 10, duration: 200 },
34
+ { value: -5, duration: 200 },
35
+ { value: 0, duration: 200 }
36
+ ],
37
+ opacity: [0, 1]
38
+ }
39
+ display = 'block'
40
+ break
41
+ case 'shrinkIn':
42
+ animation = {
43
+ begin (anim) {
44
+ target.display('block')
45
+ },
46
+ scale: [
47
+ { value: 1.1, duration: 300 },
48
+ { value: 1, duration: 200 }
49
+ ],
50
+ opacity: 1
51
+ }
52
+ display = 'block'
53
+ break
54
+ case 'slideRightIn':
55
+ animation = {
56
+ begin (anim) {
57
+ target.display('block')
58
+ },
59
+ translateX: ['100%', '0%'],
60
+ opacity: [0, 1]
61
+ }
62
+ display = 'block'
63
+ break
64
+ case 'slideRightOut':
65
+ animation = {
66
+ translateX: ['0%', '100%'],
67
+ opacity: [1, 0]
68
+ }
69
+ break
70
+ default:
71
+ // @ts-ignore
72
+ animation = type
73
+ // @ts-ignore
74
+ display = type.display
75
+ break
76
+ }
77
+ anime(Object.assign({
78
+ targets: target,
79
+ duration: 200,
80
+ easing: 'linear',
81
+ begin () {
82
+ begin && begin()
83
+ },
84
+ complete () {
85
+ target.display(display)
86
+ complete && complete()
87
+ }
88
+ }, animation)).play()
89
+ }
90
+
91
+ export const pageScroll = (target: HTMLElement|number, offset?: number, complete?: Function) => {
92
+ // target: 滚动到的目标元素或坐标(number)
93
+ // offset: 可选的偏移量
94
+ // complete: 可选的回调函数,在动画完成时调用
95
+ anime({
96
+ // 动画目标
97
+ targets: typeof offset === 'number' && typeof target !== 'number' ? target.parentNode : document.scrollingElement,
98
+ // 动画持续时间
99
+ duration: 500,
100
+ // 动画缓动函数
101
+ easing: 'easeInOutQuad',
102
+ // 如果 offset 存在,则滚动到 offset,如果 target 是数字,则滚动到 target,如果 target 是 DOM 元素,则滚动到下述表达式
103
+ scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
104
+ // 完成回调函数
105
+ complete () {
106
+ complete && complete()
107
+ }
108
+ }).play()
109
+ }
@@ -0,0 +1,117 @@
1
+ /*
2
+ 对注释的说明: 部分注释为openai-chatgpt生成的注释,可能存在描述或语义的问题
3
+ */
4
+ interface AudioItem {
5
+ title: string;
6
+ list: string[];
7
+ }
8
+
9
+ declare interface EventTarget {
10
+ createChild(tag: string, obj: Object, positon?: string): HTMLElement;
11
+ wrapObject(obj: Object): void;
12
+ changeOrGetHeight(h: number | string): void;
13
+ changeOrGetHeight(): number;
14
+ changeOrGetWidth(w: number | string): void;
15
+ changeOrGetWidth(): number;
16
+ getTop(): number;
17
+ left(): number;
18
+ insertAfter(element: HTMLElement): void;
19
+ display(d: string): EventTarget;
20
+ display():string
21
+ child(selector: string): HTMLElement;
22
+ find(selector: string): NodeListOf<HTMLElement>;
23
+ _class(type: string, className: string, display?: boolean): void;
24
+ addClass(className: string): EventTarget;
25
+ removeClass(className: string): EventTarget;
26
+ toggleClass(className: string, display?: boolean): EventTarget;
27
+ hasClass(className: string): boolean;
28
+ }
29
+
30
+ declare const LOCAL: {
31
+ path: string;
32
+ ignores: Array<(uri:string)=>boolean>;
33
+ audio: string[];
34
+ search: {
35
+ placeholder: string,
36
+ empty: string,
37
+ stats: string
38
+ };
39
+ quiz: {
40
+ choice: string,
41
+ multiple: string,
42
+ true_false: string,
43
+ essay: string,
44
+ gap_fill: string,
45
+ mistake: string
46
+ };
47
+ nocopy: boolean;
48
+ copyright: string;
49
+ outime: boolean
50
+ template: string
51
+ favicon: {
52
+ hide: string
53
+ show: string
54
+ }
55
+ }
56
+ declare const CONFIG: {
57
+ hostname: string;
58
+ fireworks: any;
59
+ audio: AudioItem[];
60
+ version: number
61
+ root: string
62
+ statics: string
63
+ outime: {
64
+ enable: boolean
65
+ days: number
66
+ }
67
+ favicon: {
68
+ normal: string,
69
+ hidden: string
70
+ }
71
+ darkmode: boolean
72
+ auto_dark: {
73
+ enable: boolean
74
+ start: number
75
+ end: number
76
+ }
77
+ auto_scroll: boolean
78
+ loader: {
79
+ start: boolean
80
+ switch: boolean
81
+ }
82
+ js: {
83
+ chart: string
84
+ copy_tex: string
85
+ fancybox: string
86
+ echarts: string
87
+ }
88
+ css: {
89
+ valine: string
90
+ katex: string
91
+ mermaid: string
92
+ fancybox: string
93
+ }
94
+ search: any,
95
+ valine: string
96
+ quicklink: {
97
+ ignores: any
98
+ timeout: number
99
+ priority: string
100
+ }
101
+ playerAPI: string
102
+ }
103
+ declare const instantsearch: any
104
+
105
+ declare function algoliasearch(appID: string, apiKey: string): any;
106
+
107
+ declare const quicklink: any
108
+
109
+ // esbuild 静态常量
110
+ declare const __shokax_player__:boolean
111
+ declare const __shokax_fireworks__:boolean
112
+ declare const __shokax_search__:boolean
113
+ declare const __shokax_VL__:boolean
114
+ declare const __shokax_outime__:boolean
115
+ declare const __shokax_tabs__: boolean
116
+ declare const __shokax_quiz__: boolean
117
+ declare const __shokax_fancybox__: boolean
@@ -0,0 +1,26 @@
1
+ const getDocHeight = () => $dom('main > .inner').offsetHeight
2
+ /**
3
+ * 获取一个dom选择器对应的元素
4
+ */
5
+ const $dom = (selector: string, element: Document = document): HTMLElement => {
6
+ // 在测试环境中这能优化0.01-0.02ms左右
7
+ if (selector[0] === '#') {
8
+ return <HTMLElement> element.getElementById(selector.substring(1))
9
+ }
10
+ return <HTMLElement> element.querySelector(selector)
11
+ }
12
+
13
+ /**
14
+ * 获取具有此选择器的所有dom节点
15
+ */
16
+ $dom.all = (selector: string, element: Document = document): NodeListOf<HTMLElement> => {
17
+ return element.querySelectorAll(selector)
18
+ }
19
+ /**
20
+ * 获取具有此选择器的所有dom节点,并依次执行callback函数
21
+ */
22
+ $dom.each = (selector: string, callback: (value: HTMLElement, key: number, parent: NodeListOf<Element>) => void, element?: Document): void => {
23
+ $dom.all(selector, element).forEach(callback)
24
+ }
25
+
26
+ export { $dom, getDocHeight }
@@ -0,0 +1,4 @@
1
+ export {}
2
+ declare global {
3
+ const Vue: typeof import('vue')
4
+ }
@@ -0,0 +1,41 @@
1
+ import { getScript } from './scriptPjax'
2
+
3
+ /**
4
+ * 用途是根据不同的资源名称和类型生成相应的资源 URL。
5
+ */
6
+ const assetUrl = (asset: string, type: string): string => {
7
+ const str = CONFIG[asset][type]
8
+ if (str.includes('http')) {
9
+ return str
10
+ }
11
+ if (str.includes('gh') || str.includes('combine')) {
12
+ return `https://cdn.jsdelivr.net/${str}`
13
+ }
14
+ if (str.includes('npm')) {
15
+ return `https://cdn.jsdelivr.net/${str}`
16
+ }
17
+ return `/${str}`
18
+ }
19
+
20
+ export const vendorJs = (type: string, callback?: Function, condition?: string) => {
21
+ if (LOCAL[type]) {
22
+ getScript(assetUrl('js', type), callback || function () {
23
+ window[type] = true
24
+ }, condition || window[type])
25
+ }
26
+ }
27
+
28
+ export const vendorCss = (type: string, condition?: string): void => {
29
+ if (window['css' + type]) {
30
+ return
31
+ }
32
+
33
+ if (LOCAL[type]) {
34
+ document.head.createChild('link', {
35
+ rel: 'stylesheet',
36
+ href: assetUrl('css', type)
37
+ })
38
+
39
+ window['css' + type] = true
40
+ }
41
+ }
@@ -0,0 +1,143 @@
1
+ import { $dom } from './dom'
2
+
3
+ export default function initProto () {
4
+ Object.assign(HTMLElement.prototype, {
5
+ /**
6
+ * 创建一个子节点并放置
7
+ */
8
+ createChild (tag: string, obj: ElementCreationOptions, positon?: string): HTMLElement {
9
+ const child = document.createElement(tag)
10
+ Object.assign(child, obj)
11
+ switch (positon) {
12
+ case 'after':
13
+ this.insertAfter(child)
14
+ break
15
+ case 'replace':
16
+ this.innerHTML = ''
17
+ this.appendChild(child)
18
+ break
19
+ default:
20
+ this.appendChild(child)
21
+ }
22
+ return child
23
+ },
24
+ /**
25
+ * 此方法使用`<div>`包装一个 DOM 元素
26
+ * @param obj 需要被包装的对象
27
+ */
28
+ wrapObject (obj: HTMLElement) {
29
+ const box = document.createElement('div')
30
+ Object.assign(box, obj)
31
+ this.parentNode.insertBefore(box, this)
32
+ this.parentNode.removeChild(this)
33
+ box.appendChild(this)
34
+ },
35
+ changeOrGetHeight (h?: number | string): number {
36
+ if (h) {
37
+ // TODO 0rem是期望的值吗?
38
+ this.style.height = typeof h === 'number' ? h + 'rem' : h
39
+ }
40
+ return this.getBoundingClientRect().height
41
+ },
42
+ /**
43
+ 此函数将元素的宽度设置为指定值,如果未提供值,则返回元素的宽度.<br />
44
+ 宽度可以作为数字提供(假定它以`rem`为单位).作为字符串提供则直接设置为元素宽度
45
+ */
46
+ changeOrGetWidth (w?: number | string): number {
47
+ if (w) {
48
+ // TODO 0rem是期望的值吗?
49
+ this.style.width = typeof w === 'number' ? w + 'rem' : w
50
+ }
51
+ return this.getBoundingClientRect().width
52
+ },
53
+ getTop (): number {
54
+ return this.getBoundingClientRect().top
55
+ },
56
+ left (): number {
57
+ return this.getBoundingClientRect().left
58
+ },
59
+ /**
60
+ * 将此节点插入父节点的下一个节点之前
61
+ */
62
+ insertAfter (element: HTMLElement): void {
63
+ const parent = this.parentNode
64
+ if (parent.lastChild === this) {
65
+ parent.appendChild(element)
66
+ } else {
67
+ parent.insertBefore(element, this.nextSibling)
68
+ }
69
+ },
70
+ /**
71
+ * 当d为空时返回此节点的CSSStyle display属性 <br />
72
+ * 反之,将d设置为此节点的CSSStyle display属性
73
+ */
74
+ display (d?: string): string | EventTarget {
75
+ if (d == null) {
76
+ return this.style.display
77
+ } else {
78
+ this.style.display = d
79
+ return this
80
+ }
81
+ },
82
+ /**
83
+ * 找到此节点第一个符合selector选择器的子节点
84
+ */
85
+ child (selector: string): HTMLElement {
86
+ return $dom(selector, this)
87
+ },
88
+ /**
89
+ * 找到此节点所有符合selector选择器的子节点
90
+ */
91
+ find (selector: string): NodeListOf<HTMLElement> {
92
+ return $dom.all(selector, this)
93
+ },
94
+ /**
95
+ * 这个方法接受三个参数:
96
+ * type 表示操作类型('add'、'remove'、'toggle'),
97
+ * className 是一个或多个要操作的类名,
98
+ * display 是一个可选的布尔值,用于在执行切换操作时指定类名是否应显示或隐藏。
99
+ * 该方法会根据操作类型执行相应的类名操作。
100
+ */
101
+ _class (type: string, className: string, display?: boolean): void {
102
+ const classNames = className.indexOf(' ') ? className.split(' ') : [className]
103
+ classNames.forEach((name) => {
104
+ if (type === 'toggle') {
105
+ this.classList.toggle(name, display)
106
+ } else {
107
+ this.classList[type](name)
108
+ }
109
+ })
110
+ },
111
+ /**
112
+ * 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'add',然后执行添加类名的操作。
113
+ * 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
114
+ */
115
+ addClass (className: string): EventTarget {
116
+ this._class('add', className)
117
+ return this
118
+ },
119
+ /**
120
+ * 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'remove',然后执行移除类名的操作。
121
+ * 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
122
+ */
123
+ removeClass (className: string): EventTarget {
124
+ this._class('remove', className)
125
+ return this
126
+ },
127
+ /**
128
+ * 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'toggle',然后执行切换类名的操作。
129
+ * 如果提供了 display 参数,它将根据布尔值决定是否显示或隐藏类名。
130
+ * 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
131
+ */
132
+ toggleClass (className: string, display?: boolean): EventTarget {
133
+ this._class('toggle', className, display)
134
+ return this
135
+ },
136
+ /**
137
+ * 这个方法返回一个布尔值,表示元素是否包含指定的类名。
138
+ */
139
+ hasClass (className: string): boolean {
140
+ return this.classList.contains(className)
141
+ }
142
+ })
143
+ }
@@ -0,0 +1,72 @@
1
+ // rocket-loader & Auto minify(cloudflare) 补丁
2
+ // cloudflare 的上述功能会导致DOMContentLoaded事件无法触发,此补丁会将DOMContentLoaded重定向为load事件
3
+ export function cloudflareInit () {
4
+ let inCloudFlare = true
5
+ window.addEventListener('DOMContentLoaded', function () {
6
+ inCloudFlare = false
7
+ })
8
+
9
+ if (document.readyState === 'loading') {
10
+ window.addEventListener('load', function () {
11
+ if (inCloudFlare) {
12
+ window.dispatchEvent(new Event('DOMContentLoaded'))
13
+ console.log('%c ☁️cloudflare patch ' + '%c running(rocket & minify)', 'color: white; background: #ff8c00; padding: 5px 3px;', 'padding: 4px;border:1px solid #ff8c00')
14
+ }
15
+ })
16
+ }
17
+ }
18
+
19
+ export const getScript = (url: string, callback?: Function, condition?: string): void => {
20
+ // url: 脚本文件的URL地址
21
+ // callback: 当脚本加载完成时要执行的回调函数
22
+ // condition: 可选的条件参数,如果存在,则执行callback
23
+ if (condition) {
24
+ // 如果条件存在,则执行回调函数
25
+ callback()
26
+ } else {
27
+ let script = document.createElement('script')
28
+
29
+ // @ts-ignore
30
+ script.onload = function (_, isAbort: boolean) {
31
+ // _: 事件对象
32
+ // isAbort: 是否中止
33
+ // @ts-ignore
34
+ if (isAbort || !script.readyState) {
35
+ console.log('abort!')
36
+ script.onload = null
37
+ script = undefined
38
+ if (!isAbort && callback) setTimeout(callback, 0)
39
+ }
40
+ }
41
+ script.src = url
42
+ document.head.appendChild(script)
43
+ }
44
+ }
45
+
46
+ export const pjaxScript = (element: HTMLScriptElement) => {
47
+ const { text, parentNode, id, className, type, src, dataset } = element
48
+ const code = text || element.textContent || element.innerHTML || ''
49
+ parentNode.removeChild(element)
50
+ const script = document.createElement('script')
51
+ if (id) {
52
+ script.id = id
53
+ }
54
+ if (className) {
55
+ script.className = className
56
+ }
57
+ if (type) {
58
+ script.type = type
59
+ }
60
+ if (src) {
61
+ // Force synchronous loading of peripheral JS.
62
+ script.src = src
63
+ script.async = false
64
+ }
65
+ if (dataset.pjax !== undefined) {
66
+ script.dataset.pjax = ''
67
+ }
68
+ if (code !== '') {
69
+ script.appendChild(document.createTextNode(code))
70
+ }
71
+ parentNode.appendChild(script)
72
+ }
@@ -0,0 +1,12 @@
1
+ // Html5LocalStorage的一个API
2
+ export const $storage = {
3
+ set (key: string, value: string): void {
4
+ localStorage.setItem(key, value)
5
+ },
6
+ get (key: string): string {
7
+ return localStorage.getItem(key)
8
+ },
9
+ del (key: string): void {
10
+ localStorage.removeItem(key)
11
+ }
12
+ }
@@ -0,0 +1,60 @@
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
+
7
+ export function initVue () {
8
+ Vue.createApp(
9
+ {
10
+ data () {
11
+ return {
12
+
13
+ }
14
+ },
15
+ methods: {
16
+ changeThemeByBtn () {
17
+ let c: { (): void; (): void; (): void }
18
+ const btn = $dom('.theme').child('.ic')
19
+
20
+ const neko = BODY.createChild('div', {
21
+ id: 'neko',
22
+ 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>'
23
+ })
24
+
25
+ const hideNeko = () => {
26
+ transition(neko, {
27
+ // @ts-ignore
28
+ delay: 2500,
29
+ opacity: 0
30
+ }, () => {
31
+ BODY.removeChild(neko)
32
+ })
33
+ }
34
+
35
+ if (btn.hasClass('i-sun')) {
36
+ c = () => {
37
+ neko.addClass('dark')
38
+ changeTheme('dark')
39
+ $storage.set('theme', 'dark')
40
+ hideNeko()
41
+ }
42
+ } else {
43
+ neko.addClass('dark')
44
+ c = () => {
45
+ neko.removeClass('dark')
46
+ changeTheme()
47
+ $storage.set('theme', 'light')
48
+ hideNeko()
49
+ }
50
+ }
51
+ transition(neko, 1, () => {
52
+ setTimeout(c, 210)
53
+ }, () => {
54
+ neko.display('block')
55
+ })
56
+ }
57
+ }
58
+ }
59
+ ).mount('#rightNav')
60
+ }
@@ -0,0 +1,42 @@
1
+ import { $dom } from '../library/dom'
2
+
3
+ export const cardActive = () => {
4
+ if (!$dom('.index.wrap')) { return }
5
+ const io = new IntersectionObserver((entries) => {
6
+ entries.forEach((article) => {
7
+ if (article.target.hasClass('show')) {
8
+ io.unobserve(article.target)
9
+ } else {
10
+ if (article.isIntersecting || article.intersectionRatio > 0) {
11
+ article.target.addClass('show')
12
+ io.unobserve(article.target)
13
+ }
14
+ }
15
+ })
16
+ }, {
17
+ root: null,
18
+ threshold: [0.3]
19
+ })
20
+
21
+ $dom.each('.index.wrap article.item, .index.wrap section.item', (article) => {
22
+ io.observe(article)
23
+ })
24
+
25
+ $dom('.index.wrap .item:first-child').addClass('show')
26
+
27
+ $dom.each('.cards .item', (element) => {
28
+ ['mouseenter', 'touchstart'].forEach((item) => {
29
+ element.addEventListener(item, () => {
30
+ if ($dom('.cards .item.active')) {
31
+ $dom('.cards .item.active').removeClass('active')
32
+ }
33
+ element.addClass('active')
34
+ }, { passive: true })
35
+ });
36
+ ['mouseleave'].forEach((item) => {
37
+ element.addEventListener(item, () => {
38
+ element.removeClass('active')
39
+ }, { passive: true })
40
+ })
41
+ })
42
+ }