@sugarat/theme 0.2.25 → 0.2.27
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/node.d.ts +6 -0
- package/node.js +3 -0
- package/package.json +2 -1
- package/src/components/BlogApp.vue +4 -0
- package/src/composables/config/blog.ts +6 -1
- package/src/composables/config/index.ts +7 -0
- package/src/hooks/useOml2d.ts +77 -0
- package/src/node.ts +4 -1
- package/src/utils/node/theme.ts +4 -0
package/node.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { DefaultTheme, UserConfig } from 'vitepress';
|
|
|
2
2
|
import { ElButton } from 'element-plus';
|
|
3
3
|
import { RSSOptions } from 'vitepress-plugin-rss';
|
|
4
4
|
import { Repo, Mapping } from '@giscus/vue';
|
|
5
|
+
import { Options } from 'oh-my-live2d';
|
|
5
6
|
export { tabsMarkdownPlugin } from 'vitepress-plugin-tabs';
|
|
6
7
|
|
|
7
8
|
type RSSPluginOptions = RSSOptions;
|
|
@@ -384,6 +385,11 @@ declare namespace Theme {
|
|
|
384
385
|
* @default true
|
|
385
386
|
*/
|
|
386
387
|
backToTop?: boolean | BackToTop;
|
|
388
|
+
/**
|
|
389
|
+
* oh-my-live2d 的 loadOml2d 方法的配置选项
|
|
390
|
+
* 详见 https://oml2d.com/options/Options.html
|
|
391
|
+
*/
|
|
392
|
+
oml2d?: Options;
|
|
387
393
|
}
|
|
388
394
|
interface BackToTop {
|
|
389
395
|
/**
|
package/node.js
CHANGED
|
@@ -456,6 +456,8 @@ function patchVPThemeConfig(cfg, vpThemeConfig = {}) {
|
|
|
456
456
|
vpThemeConfig.sidebar = patchDefaultThemeSideBar(cfg)?.sidebar;
|
|
457
457
|
return vpThemeConfig;
|
|
458
458
|
}
|
|
459
|
+
function checkConfig(cfg) {
|
|
460
|
+
}
|
|
459
461
|
|
|
460
462
|
// src/utils/node/vitePlugins.ts
|
|
461
463
|
var import_node_path3 = __toESM(require("path"));
|
|
@@ -562,6 +564,7 @@ function coverImgTransform() {
|
|
|
562
564
|
|
|
563
565
|
// src/node.ts
|
|
564
566
|
function getThemeConfig(cfg) {
|
|
567
|
+
checkConfig(cfg);
|
|
565
568
|
const pagesData = getArticles(cfg);
|
|
566
569
|
const extraVPConfig = {};
|
|
567
570
|
const vitePlugins = getVitePlugins(cfg);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarat/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
|
|
5
5
|
"author": "sugar",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"gray-matter": "^4.0.3",
|
|
43
43
|
"markdown-it-task-checkbox": "^1.0.6",
|
|
44
44
|
"mermaid": "^10.2.4",
|
|
45
|
+
"oh-my-live2d": "^0.10.0",
|
|
45
46
|
"swiper": "^11.0.5",
|
|
46
47
|
"vitepress-markdown-timeline": "^1.2.1",
|
|
47
48
|
"vitepress-plugin-mermaid": "2.0.13",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import Theme from 'vitepress/theme'
|
|
3
3
|
import { useData } from 'vitepress'
|
|
4
4
|
import { computed } from 'vue'
|
|
5
|
+
import { useOml2d } from '../hooks/useOml2d'
|
|
5
6
|
import { useBlogThemeMode } from '../composables/config/blog'
|
|
6
7
|
import BlogHomeInfo from './BlogHomeInfo.vue'
|
|
7
8
|
import BlogHomeBanner from './BlogHomeBanner.vue'
|
|
@@ -22,6 +23,9 @@ const { frontmatter } = useData()
|
|
|
22
23
|
const layout = computed(() => frontmatter.value.layout)
|
|
23
24
|
const isBlogTheme = useBlogThemeMode()
|
|
24
25
|
const { Layout } = Theme
|
|
26
|
+
|
|
27
|
+
// oh-my-live2d 扩展
|
|
28
|
+
useOml2d()
|
|
25
29
|
</script>
|
|
26
30
|
|
|
27
31
|
<template>
|
|
@@ -76,7 +76,6 @@ export function withConfigProvider(App: Component) {
|
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
|
-
|
|
80
79
|
export function useDocMetaInsertSelector() {
|
|
81
80
|
const blogConfig = useConfig()
|
|
82
81
|
const { frontmatter } = useData()
|
|
@@ -98,6 +97,12 @@ export function useConfig() {
|
|
|
98
97
|
export function useBlogConfig() {
|
|
99
98
|
return inject(configSymbol)!.value.blog!
|
|
100
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* 获取 oh-my-live2d的配置选项
|
|
102
|
+
*/
|
|
103
|
+
export function useOml2dOptions() {
|
|
104
|
+
return inject(configSymbol)!.value.blog?.oml2d
|
|
105
|
+
}
|
|
101
106
|
|
|
102
107
|
export function useBlogThemeMode() {
|
|
103
108
|
return inject(configSymbol)!.value?.blog?.blog ?? true
|
|
@@ -3,6 +3,7 @@ import type { ElButton } from 'element-plus'
|
|
|
3
3
|
import type { DefaultTheme } from 'vitepress'
|
|
4
4
|
import type { RSSOptions } from 'vitepress-plugin-rss'
|
|
5
5
|
import type { Mapping, Repo } from '@giscus/vue'
|
|
6
|
+
import type { Options as Oml2dOptions } from 'oh-my-live2d'
|
|
6
7
|
|
|
7
8
|
type RSSPluginOptions = RSSOptions
|
|
8
9
|
|
|
@@ -416,6 +417,12 @@ export namespace Theme {
|
|
|
416
417
|
* @default true
|
|
417
418
|
*/
|
|
418
419
|
backToTop?: boolean | BackToTop
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* oh-my-live2d 的 loadOml2d 方法的配置选项
|
|
423
|
+
* 详见 https://oml2d.com/options/Options.html
|
|
424
|
+
*/
|
|
425
|
+
oml2d?: Oml2dOptions
|
|
419
426
|
}
|
|
420
427
|
|
|
421
428
|
export interface BackToTop {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { onMounted } from 'vue'
|
|
2
|
+
import type { Options } from 'oh-my-live2d'
|
|
3
|
+
import { useOml2dOptions } from '../composables/config/blog'
|
|
4
|
+
|
|
5
|
+
const defaultModelOptions: any = {
|
|
6
|
+
scale: 0.08,
|
|
7
|
+
position: [-30, 0],
|
|
8
|
+
stageStyle: {
|
|
9
|
+
width: 220
|
|
10
|
+
},
|
|
11
|
+
mobilePosition: [-10, 0],
|
|
12
|
+
mobileScale: 0.05,
|
|
13
|
+
mobileStageStyle: {
|
|
14
|
+
width: 150
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
const defaultOptions: Options = {
|
|
18
|
+
tips: {
|
|
19
|
+
copyTips: {
|
|
20
|
+
duration: 2000,
|
|
21
|
+
message: ['复制成功,感谢您的支持!'],
|
|
22
|
+
},
|
|
23
|
+
style: {
|
|
24
|
+
top: '-50px',
|
|
25
|
+
fontSize: '14px',
|
|
26
|
+
padding: '10px',
|
|
27
|
+
width: '200px'
|
|
28
|
+
},
|
|
29
|
+
mobileStyle: {
|
|
30
|
+
top: '-80px',
|
|
31
|
+
left: '80px',
|
|
32
|
+
fontSize: '14px',
|
|
33
|
+
padding: '4px 10px',
|
|
34
|
+
width: '110px'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function useOml2d() {
|
|
39
|
+
const oml2dOptions = useOml2dOptions()
|
|
40
|
+
onMounted(async () => {
|
|
41
|
+
if (oml2dOptions) {
|
|
42
|
+
const { loadOml2d } = await import('oh-my-live2d')
|
|
43
|
+
loadOml2d({
|
|
44
|
+
...defaultOptions,
|
|
45
|
+
...oml2dOptions,
|
|
46
|
+
models: oml2dOptions?.models?.map(model => ({
|
|
47
|
+
...defaultModelOptions,
|
|
48
|
+
...model,
|
|
49
|
+
stageStyle: {
|
|
50
|
+
...defaultModelOptions.stageStyle,
|
|
51
|
+
...model.stageStyle
|
|
52
|
+
},
|
|
53
|
+
mobileStageStyle: {
|
|
54
|
+
...defaultModelOptions.mobileStageStyle,
|
|
55
|
+
...model.mobileStageStyle
|
|
56
|
+
}
|
|
57
|
+
})),
|
|
58
|
+
tips: {
|
|
59
|
+
...defaultOptions.tips,
|
|
60
|
+
...oml2dOptions.tips,
|
|
61
|
+
style: {
|
|
62
|
+
...defaultOptions?.tips?.style,
|
|
63
|
+
...oml2dOptions?.tips?.style
|
|
64
|
+
},
|
|
65
|
+
mobileStyle: {
|
|
66
|
+
...defaultOptions?.tips?.mobileStyle,
|
|
67
|
+
...oml2dOptions?.tips?.mobileStyle
|
|
68
|
+
},
|
|
69
|
+
copyTips: {
|
|
70
|
+
...defaultOptions?.tips?.copyTips,
|
|
71
|
+
...oml2dOptions?.tips?.copyTips
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
package/src/node.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
patchOptimizeDeps,
|
|
7
7
|
registerMdPlugins,
|
|
8
8
|
} from './utils/node/mdPlugins'
|
|
9
|
-
import { getArticles, patchVPThemeConfig } from './utils/node/theme'
|
|
9
|
+
import { checkConfig, getArticles, patchVPThemeConfig } from './utils/node/theme'
|
|
10
10
|
import { getVitePlugins, registerVitePlugins } from './utils/node/vitePlugins'
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -14,6 +14,9 @@ import { getVitePlugins, registerVitePlugins } from './utils/node/vitePlugins'
|
|
|
14
14
|
* @param cfg 主题配置
|
|
15
15
|
*/
|
|
16
16
|
export function getThemeConfig(cfg?: Partial<Theme.BlogConfig>) {
|
|
17
|
+
// 配置校验
|
|
18
|
+
checkConfig(cfg)
|
|
19
|
+
|
|
17
20
|
// 文章数据
|
|
18
21
|
const pagesData = getArticles(cfg)
|
|
19
22
|
const extraVPConfig: any = {}
|