hexo-theme-shokax 0.5.0-dev-d82f54b → 0.5.0-dev-2f28258
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/README.md +3 -5
- package/UsageRestrictions.md +1 -1
- package/_config.yml +10 -63
- package/_images.yml +0 -2
- package/layout/_mixin/comment.pug +1 -0
- package/layout/_mixin/segment.pug +1 -1
- package/layout/_partials/footer.pug +4 -1
- package/layout/_partials/head/head.pug +1 -1
- package/layout/_partials/header.pug +1 -0
- package/layout/_partials/layout.pug +5 -12
- package/layout/_partials/post/footer.pug +2 -0
- package/layout/_partials/post/nav.pug +1 -1
- package/layout/_partials/post/post.pug +3 -1
- package/layout/_partials/post/reward.pug +1 -1
- package/layout/_partials/sidebar/overview.pug +2 -0
- package/layout/page.pug +0 -2
- package/layout/post.pug +0 -2
- package/package.json +16 -24
- package/scripts/filters/post.js +1 -1
- package/scripts/generaters/script.js +43 -22
- package/scripts/generaters/summary_ai.js +1 -0
- package/scripts/helpers/engine.js +4 -56
- package/scripts/plugin/index.js +24 -1
- package/scripts/plugin/lib/injects-point.js +40 -0
- package/scripts/plugin/lib/injects.js +105 -0
- package/scripts/tags/media.js +1 -1
- package/source/css/app.styl +0 -3
- package/source/js/_app/components/comments.ts +0 -1
- package/source/js/_app/components/sidebar.ts +4 -2
- package/source/js/_app/globals/globalVars.ts +1 -6
- package/source/js/_app/library/declare.d.ts +0 -4
- package/source/js/_app/library/vue.ts +1 -0
- package/source/js/_app/page/imageviewer.ts +20 -0
- package/source/js/_app/page/post.ts +3 -19
- package/source/js/_app/pjax/domInit.ts +19 -11
- package/source/js/_app/pjax/refresh.ts +2 -9
- package/source/js/_app/player.ts +11 -9
- package/toolbox/compiler.mjs +19 -8
- package/eslint.config.mjs +0 -55
- package/source/css/optimize.styl +0 -6
- package/source/js/_app/page/fancybox.ts +0 -66
package/scripts/plugin/index.js
CHANGED
@@ -1,7 +1,30 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
9
|
+
for (let key of __getOwnPropNames(from))
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
}
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
1
23
|
var import_package = require("../../package.json");
|
2
24
|
var import_promises = require("node:fs/promises");
|
25
|
+
var import_injects = __toESM(require("./lib/injects"));
|
3
26
|
hexo.on("generateBefore", async () => {
|
4
|
-
|
27
|
+
(0, import_injects.default)(hexo);
|
5
28
|
try {
|
6
29
|
await (0, import_promises.unlink)("cf-patch.js");
|
7
30
|
} catch (e) {
|
@@ -0,0 +1,40 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var injects_point_exports = {};
|
19
|
+
__export(injects_point_exports, {
|
20
|
+
default: () => injects_point_default
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(injects_point_exports);
|
23
|
+
var injects_point_default = {
|
24
|
+
views: [
|
25
|
+
"head",
|
26
|
+
"sidebar",
|
27
|
+
"rightNav",
|
28
|
+
"postMeta",
|
29
|
+
"postBodyEnd",
|
30
|
+
"footer",
|
31
|
+
"bodyEnd",
|
32
|
+
"comment",
|
33
|
+
"status"
|
34
|
+
],
|
35
|
+
styles: [
|
36
|
+
"variable",
|
37
|
+
"mixin",
|
38
|
+
"style"
|
39
|
+
]
|
40
|
+
};
|
@@ -0,0 +1,105 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
+
mod
|
26
|
+
));
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
+
var injects_exports = {};
|
29
|
+
__export(injects_exports, {
|
30
|
+
default: () => injects_default
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(injects_exports);
|
33
|
+
var import_node_fs = __toESM(require("node:fs"));
|
34
|
+
var import_node_path = __toESM(require("node:path"));
|
35
|
+
var import_injects_point = __toESM(require("./injects-point"));
|
36
|
+
/*!
|
37
|
+
inject.js in next-theme/hexo-theme-next by next-theme
|
38
|
+
under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
|
39
|
+
https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
|
40
|
+
*/
|
41
|
+
const defaultExtname = ".pug";
|
42
|
+
class StylusInject {
|
43
|
+
files;
|
44
|
+
base_dir;
|
45
|
+
constructor(base_dir) {
|
46
|
+
this.base_dir = base_dir;
|
47
|
+
this.files = [];
|
48
|
+
}
|
49
|
+
push(file) {
|
50
|
+
this.files.push(import_node_path.default.resolve(this.base_dir, file));
|
51
|
+
}
|
52
|
+
}
|
53
|
+
class ViewInject {
|
54
|
+
base_dir;
|
55
|
+
raws;
|
56
|
+
constructor(base_dir) {
|
57
|
+
this.base_dir = base_dir;
|
58
|
+
this.raws = [];
|
59
|
+
}
|
60
|
+
raw(name, raw, ...args) {
|
61
|
+
if (import_node_path.default.extname(name) === "") {
|
62
|
+
name += defaultExtname;
|
63
|
+
}
|
64
|
+
this.raws.push({ name, raw, args });
|
65
|
+
}
|
66
|
+
file(name, file, ...args) {
|
67
|
+
if (import_node_path.default.extname(name) === "") {
|
68
|
+
name += import_node_path.default.extname(file);
|
69
|
+
}
|
70
|
+
this.raw(name, import_node_fs.default.readFileSync(import_node_path.default.resolve(this.base_dir, file), "utf8"), ...args);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
function initInject(base_dir) {
|
74
|
+
const injects = {};
|
75
|
+
import_injects_point.default.styles.forEach((item) => {
|
76
|
+
injects[item] = new StylusInject(base_dir);
|
77
|
+
});
|
78
|
+
import_injects_point.default.views.forEach((item) => {
|
79
|
+
injects[item] = new ViewInject(base_dir);
|
80
|
+
});
|
81
|
+
return injects;
|
82
|
+
}
|
83
|
+
var injects_default = (hexo) => {
|
84
|
+
const injects = initInject(hexo.base_dir);
|
85
|
+
hexo.execFilterSync("theme_inject", injects);
|
86
|
+
hexo.theme.config.injects = {};
|
87
|
+
import_injects_point.default.styles.forEach((type) => {
|
88
|
+
hexo.theme.config.injects[type] = injects[type].files;
|
89
|
+
});
|
90
|
+
import_injects_point.default.views.forEach((type) => {
|
91
|
+
const configs = /* @__PURE__ */ Object.create(null);
|
92
|
+
hexo.theme.config.injects[type] = [];
|
93
|
+
injects[type].raws.forEach((injectObj, index) => {
|
94
|
+
const name = `inject/${type}/${injectObj.name}`;
|
95
|
+
hexo.theme.setView(name, injectObj.raw);
|
96
|
+
configs[name] = {
|
97
|
+
layout: name,
|
98
|
+
locals: injectObj.args[0],
|
99
|
+
options: injectObj.args[1],
|
100
|
+
order: injectObj.args[2] || index
|
101
|
+
};
|
102
|
+
});
|
103
|
+
hexo.theme.config.injects[type] = Object.values(configs).sort((x, y) => x.order - y.order);
|
104
|
+
});
|
105
|
+
};
|
package/scripts/tags/media.js
CHANGED
@@ -30,7 +30,7 @@ function postMedia(args, content) {
|
|
30
30
|
switch (args[0]) {
|
31
31
|
case "video":
|
32
32
|
case "audio":
|
33
|
-
return `<div class="media-container"><div class="player" data-type="${args[0]}"
|
33
|
+
return `<div class="media-container"><div class="player" data-type="${args[0]}" src='${JSON.stringify(list)}'></div></div>`;
|
34
34
|
}
|
35
35
|
}
|
36
36
|
hexo.extend.tag.register("media", postMedia, { ends: true });
|
package/source/css/app.styl
CHANGED
@@ -108,14 +108,16 @@ export const sidebarTOC = () => {
|
|
108
108
|
}
|
109
109
|
|
110
110
|
document.querySelectorAll('.toc .active').forEach((element) => {
|
111
|
-
element && element.classList.remove('active
|
111
|
+
element && element.classList.remove('active')
|
112
|
+
element && element.classList.remove('current')
|
112
113
|
})
|
113
114
|
|
114
115
|
sections.forEach((element) => {
|
115
116
|
element && element.classList.remove('active')
|
116
117
|
})
|
117
118
|
|
118
|
-
target.classList.add('active
|
119
|
+
target.classList.add('active')
|
120
|
+
target.classList.add('current')
|
119
121
|
sections[index] && sections[index].classList.add('active')
|
120
122
|
|
121
123
|
let parent = <Element> target.parentNode
|
@@ -14,10 +14,9 @@ export const quickBtn = document.getElementById('quick')
|
|
14
14
|
export const sideBar = document.getElementById('sidebar')
|
15
15
|
export const siteBrand = document.getElementById('brand')
|
16
16
|
export let toolBtn = document.getElementById('tool')
|
17
|
-
export let toolPlayer
|
18
17
|
export let backToTop: HTMLElement
|
19
18
|
export let goToComment
|
20
|
-
export let showContents
|
19
|
+
export let showContents: HTMLElement
|
21
20
|
export let siteSearch = document.getElementById('search')
|
22
21
|
export let siteNavHeight: number, headerHightInner: number, headerHight: number
|
23
22
|
export let oWinHeight = window.innerHeight
|
@@ -64,10 +63,6 @@ export function setOriginTitle (value:string):void {
|
|
64
63
|
originTitle = value
|
65
64
|
}
|
66
65
|
|
67
|
-
export function setToolPlayer (value:any):void {
|
68
|
-
toolPlayer = value
|
69
|
-
}
|
70
|
-
|
71
66
|
export function setBackToTop (value:HTMLElement):void {
|
72
67
|
backToTop = value
|
73
68
|
}
|
@@ -84,13 +84,10 @@ interface configType {
|
|
84
84
|
}
|
85
85
|
js: {
|
86
86
|
copy_tex: vendorUrl
|
87
|
-
fancybox: vendorUrl
|
88
87
|
}
|
89
88
|
css: {
|
90
|
-
valine: vendorUrl
|
91
89
|
katex: vendorUrl
|
92
90
|
mermaid: vendorUrl
|
93
|
-
fancybox: vendorUrl
|
94
91
|
}
|
95
92
|
search: any,
|
96
93
|
waline: {
|
@@ -122,7 +119,6 @@ declare const __shokax_VL__:boolean
|
|
122
119
|
declare const __shokax_outime__:boolean
|
123
120
|
declare const __shokax_tabs__: boolean
|
124
121
|
declare const __shokax_quiz__: boolean
|
125
|
-
declare const __shokax_fancybox__: boolean
|
126
122
|
declare const __shokax_waline__:boolean
|
127
123
|
declare const __shokax_twikoo__:boolean
|
128
124
|
declare const shokax_CONFIG:configType
|
@@ -2,6 +2,7 @@ import { transition } from './anime'
|
|
2
2
|
import { BODY } from '../globals/globalVars'
|
3
3
|
import { changeTheme } from '../globals/themeColor'
|
4
4
|
import { createChild, setDisplay } from './proto'
|
5
|
+
|
5
6
|
export function initVue () {
|
6
7
|
function changeThemeByBtn () {
|
7
8
|
let c: { (): void; (): void; (): void }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import DOMPurify from 'dompurify';
|
2
|
+
import { HanaImgViewer } from 'hana-img-viewer'
|
3
|
+
import { createApp } from 'vue';
|
4
|
+
|
5
|
+
export const postImageViewer = (p: string) => {
|
6
|
+
document.querySelectorAll(`${p} .md img:not(.emoji):not(.vemoji)`).forEach((element) => {
|
7
|
+
const img = element as HTMLImageElement;
|
8
|
+
const imgSrc = DOMPurify.sanitize(img.dataset.src);
|
9
|
+
|
10
|
+
const wrapper = document.createElement('div');
|
11
|
+
console.log(wrapper)
|
12
|
+
img.replaceWith(wrapper);
|
13
|
+
|
14
|
+
console.log(imgSrc)
|
15
|
+
const app = createApp(HanaImgViewer, { src: imgSrc, maskOpacity: 0.8 });
|
16
|
+
console.log(app)
|
17
|
+
app.mount(wrapper);
|
18
|
+
console.log(app)
|
19
|
+
});
|
20
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { postImageViewer } from './imageviewer'
|
2
2
|
import { clipBoard, showtip } from '../globals/tools'
|
3
3
|
import { CONFIG, BODY } from '../globals/globalVars'
|
4
4
|
import { pageScroll, transition } from '../library/anime'
|
@@ -7,9 +7,7 @@ import { getDisplay, setDisplay, wrapObject } from '../library/proto'
|
|
7
7
|
export const postBeauty = () => {
|
8
8
|
if (!document.querySelector('.md')) { return }
|
9
9
|
|
10
|
-
|
11
|
-
postFancybox('.post.block')
|
12
|
-
}
|
10
|
+
postImageViewer('.post.block');
|
13
11
|
|
14
12
|
(document.querySelector('.post.block') as HTMLTextAreaElement).oncopy = (event) => {
|
15
13
|
showtip(LOCAL.copyright)
|
@@ -32,11 +30,7 @@ export const postBeauty = () => {
|
|
32
30
|
event.clipboardData.setData('text/html', htmlData)
|
33
31
|
event.clipboardData.setData('text/plain', textData)
|
34
32
|
} else {
|
35
|
-
|
36
|
-
if (window.clipboardData) {
|
37
|
-
// @ts-ignore
|
38
|
-
return window.clipboardData.setData('text', textData)
|
39
|
-
}
|
33
|
+
throw new Error('Clipboard API not supported')
|
40
34
|
}
|
41
35
|
}
|
42
36
|
}
|
@@ -229,16 +223,6 @@ export const postBeauty = () => {
|
|
229
223
|
element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)]
|
230
224
|
})
|
231
225
|
|
232
|
-
// if (__shokax_player__) {
|
233
|
-
// $dom.each('.md div.player', (element) => {
|
234
|
-
// mediaPlayer(element, {
|
235
|
-
// type: element.getAttribute('data-type'),
|
236
|
-
// mode: 'order',
|
237
|
-
// btns: []
|
238
|
-
// }).player.load(JSON.parse(element.getAttribute('data-src'))).fetch()
|
239
|
-
// })
|
240
|
-
// }
|
241
|
-
|
242
226
|
const angleDown = document.querySelectorAll('.show-btn .i-angle-down')
|
243
227
|
if (angleDown.length) {
|
244
228
|
const io = new IntersectionObserver((entries) => {
|
@@ -5,7 +5,6 @@ import {
|
|
5
5
|
loadCat,
|
6
6
|
menuToggle,
|
7
7
|
quickBtn, setBackToTop, setGoToComment, setShowContents, setToolBtn,
|
8
|
-
setToolPlayer,
|
9
8
|
showContents,
|
10
9
|
siteHeader,
|
11
10
|
siteNav,
|
@@ -13,8 +12,9 @@ import {
|
|
13
12
|
} from '../globals/globalVars'
|
14
13
|
import { Loader } from '../globals/thirdparty'
|
15
14
|
import { createChild } from '../library/proto'
|
15
|
+
import { initAudioPlayer } from '../player'
|
16
16
|
|
17
|
-
export default function domInit () {
|
17
|
+
export default async function domInit () {
|
18
18
|
document.querySelectorAll('.overview .menu > .item').forEach((el) => {
|
19
19
|
siteNav.querySelector('.menu').appendChild(el.cloneNode(true))
|
20
20
|
})
|
@@ -29,11 +29,22 @@ export default function domInit () {
|
|
29
29
|
if (!toolBtn) {
|
30
30
|
setToolBtn(createChild(siteHeader, 'div', {
|
31
31
|
id: 'tool',
|
32
|
-
innerHTML:
|
32
|
+
innerHTML: `<div class="item player">
|
33
|
+
${__shokax_player__ ? '<div class="play-pause btn" id="playBtn"></div><div class="music btn btn" id="showBtn"></div>' : ''}
|
34
|
+
</div>
|
35
|
+
<div class="item contents">
|
36
|
+
<i class="ic i-list-ol"></i>
|
37
|
+
</div>
|
38
|
+
<div class="item chat">
|
39
|
+
<i class="ic i-comments"></i>
|
40
|
+
</div>
|
41
|
+
<div class="item back-to-top">
|
42
|
+
<i class="ic i-arrow-up"></i>
|
43
|
+
<span>0%</span>
|
44
|
+
</div>`
|
33
45
|
}))
|
34
46
|
}
|
35
47
|
|
36
|
-
setToolPlayer(toolBtn.querySelector('.player'))
|
37
48
|
setBackToTop(toolBtn.querySelector('.back-to-top'))
|
38
49
|
setGoToComment(toolBtn.querySelector('.chat'))
|
39
50
|
setShowContents(toolBtn.querySelector('.contents'))
|
@@ -42,13 +53,10 @@ export default function domInit () {
|
|
42
53
|
goToComment.addEventListener('click', goToCommentHandle)
|
43
54
|
showContents.addEventListener('click', sideBarToggleHandle)
|
44
55
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
// toolPlayer.player.mini()
|
50
|
-
// })
|
51
|
-
// }
|
56
|
+
if (__shokax_player__) {
|
57
|
+
await initAudioPlayer()
|
58
|
+
}
|
59
|
+
|
52
60
|
|
53
61
|
const createIntersectionObserver = () => {
|
54
62
|
// waves在视口外时停止动画
|
@@ -8,7 +8,6 @@ import { positionInit } from '../globals/tools'
|
|
8
8
|
import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar'
|
9
9
|
import { Loader, isOutime } from '../globals/thirdparty'
|
10
10
|
import { tabFormat } from '../page/tab'
|
11
|
-
import { lazyLoad } from 'unlazy'
|
12
11
|
|
13
12
|
export const siteRefresh = async (reload) => {
|
14
13
|
if (__shokax_antiFakeWebsite__) {
|
@@ -53,9 +52,8 @@ export const siteRefresh = async (reload) => {
|
|
53
52
|
sideBarTab()
|
54
53
|
sidebarTOC()
|
55
54
|
|
56
|
-
import('../page/post')
|
57
|
-
|
58
|
-
})
|
55
|
+
const pagePost = await import('../page/post')
|
56
|
+
pagePost.postBeauty()
|
59
57
|
|
60
58
|
const cpel = document.getElementById('copyright')
|
61
59
|
if (cpel) {
|
@@ -84,8 +82,6 @@ export const siteRefresh = async (reload) => {
|
|
84
82
|
comment.observe(cpel)
|
85
83
|
}
|
86
84
|
|
87
|
-
lazyLoad()
|
88
|
-
|
89
85
|
if (__shokax_waline__) {
|
90
86
|
import('../components/comments').then(async ({walineRecentComments}) => {
|
91
87
|
await walineRecentComments()
|
@@ -102,9 +98,6 @@ export const siteRefresh = async (reload) => {
|
|
102
98
|
tabFormat()
|
103
99
|
}
|
104
100
|
|
105
|
-
// if (__shokax_player__) {
|
106
|
-
// toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {})
|
107
|
-
// }
|
108
101
|
if (sessionStorage.getItem('loaded') === 'true') {
|
109
102
|
Loader.hide(30)
|
110
103
|
} else {
|
package/source/js/_app/player.ts
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
import { initPlayer } from 'nyx-player'
|
2
1
|
import { CONFIG } from './globals/globalVars'
|
2
|
+
import 'nyx-player/style'
|
3
3
|
|
4
|
-
const
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
export const initAudioPlayer = async function () {
|
5
|
+
const urls = []
|
6
|
+
CONFIG.audio.forEach((item) => {
|
7
|
+
urls.push({
|
8
|
+
name: item.title,
|
9
|
+
url: item.list[0]
|
10
|
+
})
|
9
11
|
})
|
10
|
-
})
|
11
|
-
|
12
|
-
|
12
|
+
const { initPlayer } = await import('nyx-player')
|
13
|
+
initPlayer("#player","#showBtn", urls, "#playBtn", "html[data-theme="dark"]", "shokax")
|
14
|
+
}
|
package/toolbox/compiler.mjs
CHANGED
@@ -5,6 +5,7 @@ compatibility: ShokaX v0.5.x-dev
|
|
5
5
|
import fs from 'fs/promises'
|
6
6
|
import { buildSync } from 'esbuild'
|
7
7
|
import { glob } from 'glob'
|
8
|
+
import { build } from 'esbuild'
|
8
9
|
|
9
10
|
const CONFIG = {
|
10
11
|
|
@@ -18,21 +19,31 @@ const jsons = await glob('./scripts/**/*.json');
|
|
18
19
|
|
19
20
|
console.log('RUN THIS SCRIPT IN YOUR SHOKAX THEME ROOT DIRECTORY!')
|
20
21
|
console.log('Using esbuild compiler...')
|
21
|
-
|
22
|
+
|
23
|
+
await build({
|
22
24
|
entryPoints: entryPoints,
|
23
|
-
outdir: 'scripts',
|
24
25
|
bundle: false,
|
25
26
|
format: 'cjs',
|
26
27
|
target: ['esnext'],
|
27
28
|
platform: 'node',
|
28
29
|
loader: { '.ts': 'ts' },
|
30
|
+
outdir: 'scripts'
|
29
31
|
})
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
|
33
|
+
console.log('deleting ts and json files...')
|
34
|
+
|
35
|
+
await Promise.all(
|
36
|
+
entryPoints.map(async (entry) => {
|
37
|
+
await fs.unlink(entry)
|
38
|
+
})
|
39
|
+
)
|
40
|
+
|
41
|
+
await Promise.all(
|
42
|
+
jsons.map(async (entry)=>{
|
43
|
+
await fs.unlink(entry)
|
44
|
+
})
|
45
|
+
)
|
46
|
+
|
36
47
|
console.log('Finished compiling.')
|
37
48
|
|
38
49
|
console.log('Done.')
|
package/eslint.config.mjs
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
export default [
|
2
|
-
{
|
3
|
-
files: ['*.ts', '*.tsx', '*.vue'],
|
4
|
-
languageOptions: {
|
5
|
-
parser: '@typescript-eslint/parser',
|
6
|
-
parserOptions: {
|
7
|
-
ecmaVersion: 2022
|
8
|
-
}
|
9
|
-
},
|
10
|
-
plugins: {
|
11
|
-
'@typescript-eslint': await import('@typescript-eslint/eslint-plugin'),
|
12
|
-
'vue': await import('eslint-plugin-vue')
|
13
|
-
},
|
14
|
-
rules: {
|
15
|
-
camelcase: 'off',
|
16
|
-
'n/no-callback-literal': 'off',
|
17
|
-
'@typescript-eslint/ban-types': 'off',
|
18
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
19
|
-
'@typescript-eslint/no-var-requires': 'off',
|
20
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
21
|
-
'prefer-const': 'off'
|
22
|
-
}
|
23
|
-
},
|
24
|
-
{
|
25
|
-
files: ['*.js', '*.jsx'],
|
26
|
-
languageOptions: {
|
27
|
-
ecmaVersion: 2022
|
28
|
-
},
|
29
|
-
env: {
|
30
|
-
browser: true,
|
31
|
-
commonjs: true,
|
32
|
-
es6: true,
|
33
|
-
node: true
|
34
|
-
},
|
35
|
-
extends: [
|
36
|
-
'standard'
|
37
|
-
],
|
38
|
-
rules: {
|
39
|
-
camelcase: 'off',
|
40
|
-
'n/no-callback-literal': 'off',
|
41
|
-
'prefer-const': 'off'
|
42
|
-
}
|
43
|
-
},
|
44
|
-
{
|
45
|
-
files: ['*.vue'],
|
46
|
-
languageOptions: {
|
47
|
-
parserOptions: {
|
48
|
-
ecmaVersion: 2022
|
49
|
-
}
|
50
|
-
},
|
51
|
-
extends: [
|
52
|
-
'plugin:vue/vue3-recommended'
|
53
|
-
]
|
54
|
-
}
|
55
|
-
];
|
package/source/css/optimize.styl
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
import { insertAfter } from '../library/proto'
|
2
|
-
import DOMPurify from 'dompurify';
|
3
|
-
|
4
|
-
// TODO 使用PhotoSwipe替换Fancybox
|
5
|
-
export const postFancybox = (p:string) => {
|
6
|
-
if (document.querySelector(p + ' .md img')) {
|
7
|
-
// vendorCss('fancybox')
|
8
|
-
// vendorCss('justifiedGallery')
|
9
|
-
document.querySelectorAll(p + ' p.gallery').forEach((element) => {
|
10
|
-
const box = document.createElement('div')
|
11
|
-
box.className = 'gallery'
|
12
|
-
box.setAttribute('data-height', String(element.getAttribute('data-height') || 220))
|
13
|
-
|
14
|
-
box.innerHTML = element.innerHTML.replace(/<br>/g, '')
|
15
|
-
|
16
|
-
element.parentNode.insertBefore(box, element)
|
17
|
-
element.remove()
|
18
|
-
})
|
19
|
-
|
20
|
-
document.querySelectorAll(p + ' .md img:not(.emoji):not(.vemoji)').forEach((element) => {
|
21
|
-
const $image = $(element)
|
22
|
-
const imageLink = DOMPurify.sanitize($image.attr('data-src') || $image.attr('src')) // 替换
|
23
|
-
const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a')
|
24
|
-
let info; let captionClass = 'image-info'
|
25
|
-
if (!$image.is('a img')) {
|
26
|
-
$image.data('safe-src', imageLink)
|
27
|
-
if (!$image.is('.gallery img')) {
|
28
|
-
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default')
|
29
|
-
} else {
|
30
|
-
captionClass = 'jg-caption'
|
31
|
-
}
|
32
|
-
}
|
33
|
-
if ((info = element.getAttribute('title'))) {
|
34
|
-
$imageWrapLink.attr('data-caption', info)
|
35
|
-
const para = document.createElement('span')
|
36
|
-
const txt = document.createTextNode(info)
|
37
|
-
para.appendChild(txt)
|
38
|
-
para.addClass(captionClass)
|
39
|
-
insertAfter(element, para)
|
40
|
-
}
|
41
|
-
})
|
42
|
-
|
43
|
-
document.querySelectorAll(p + ' div.gallery').forEach((el, i) => {
|
44
|
-
// @ts-ignore
|
45
|
-
$(el).justifiedGallery({
|
46
|
-
rowHeight: $(el).data('height') || 120,
|
47
|
-
rel: 'gallery-' + i
|
48
|
-
}).on('jg.complete', function () {
|
49
|
-
$(this).find('a').each((k, ele) => {
|
50
|
-
ele.setAttribute('data-fancybox', 'gallery-' + i)
|
51
|
-
})
|
52
|
-
})
|
53
|
-
})
|
54
|
-
|
55
|
-
$.fancybox.defaults.hash = false
|
56
|
-
$(p + ' .fancybox').fancybox({
|
57
|
-
loop: true,
|
58
|
-
// @ts-ignore
|
59
|
-
helpers: {
|
60
|
-
overlay: {
|
61
|
-
locked: false
|
62
|
-
}
|
63
|
-
}
|
64
|
-
})
|
65
|
-
}
|
66
|
-
}
|