vitepress-theme-element-plus 1.3.1 → 1.3.2

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 (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +3 -3
  3. package/client/components/A11yTag.vue +29 -29
  4. package/client/components/ApiTyping.vue +54 -54
  5. package/client/components/Backdrop.vue +41 -41
  6. package/client/components/Bili.vue +94 -94
  7. package/client/components/Content.vue +148 -148
  8. package/client/components/DeprecatedTag.vue +19 -19
  9. package/client/components/Doc.vue +185 -185
  10. package/client/components/DocAside.vue +46 -46
  11. package/client/components/DocAsideOutline.vue +145 -145
  12. package/client/components/DocFooter.vue +162 -162
  13. package/client/components/Footer.vue +100 -100
  14. package/client/components/FooterCopyright.vue +27 -27
  15. package/client/components/Layout.vue +156 -156
  16. package/client/components/Link.vue +41 -41
  17. package/client/components/LocalNav.vue +160 -160
  18. package/client/components/Nav.vue +69 -69
  19. package/client/components/NavBar.vue +203 -203
  20. package/client/components/NavBarTitle.vue +89 -89
  21. package/client/components/Sidebar.vue +129 -129
  22. package/client/components/SidebarGroup.vue +51 -51
  23. package/client/components/SidebarItem.vue +304 -304
  24. package/client/components/ThemeToggler.vue +129 -129
  25. package/client/components/VPNavBarSearch.vue +23 -23
  26. package/client/hooks/useBackTop.ts +71 -71
  27. package/client/hooks/useLangs.ts +50 -50
  28. package/client/hooks/useSidebarControl.ts +78 -78
  29. package/client/hooks/useSize.ts +69 -69
  30. package/client/icons/dark.vue +8 -8
  31. package/client/icons/light.vue +8 -8
  32. package/client/utils/client/common.ts +49 -49
  33. package/client/utils/client/outline.ts +116 -116
  34. package/client/utils/common.ts +90 -90
  35. package/index.ts +45 -45
  36. package/package.json +2 -2
  37. package/shared/constants.ts +3 -3
  38. package/styles/base.scss +105 -105
  39. package/styles/code.scss +290 -290
  40. package/styles/doc-content.scss +363 -363
  41. package/styles/index.scss +71 -71
  42. package/styles/tag-content.scss +30 -30
@@ -1,90 +1,90 @@
1
- const HASH_RE = /#.*$/
2
- const HASH_OR_QUERY_RE = /[?#].*$/
3
- const INDEX_OR_EXT_RE = /(?:(^|\/)index)?\.(?:md|html)$/
4
-
5
- export const inBrowser = typeof document !== 'undefined'
6
-
7
- export function isActive(
8
- currentPath: string,
9
- matchPath?: string,
10
- asRegex: boolean = false,
11
- ): boolean {
12
- if (matchPath === undefined) {
13
- return false
14
- }
15
-
16
- currentPath = normalize(`/${currentPath}`)
17
-
18
- if (asRegex) {
19
- return new RegExp(matchPath).test(currentPath)
20
- }
21
-
22
- if (normalize(matchPath) !== currentPath) {
23
- return false
24
- }
25
-
26
- const hashMatch = matchPath.match(HASH_RE)
27
-
28
- if (hashMatch) {
29
- return (inBrowser ? location.hash : '') === hashMatch[0]
30
- }
31
-
32
- return true
33
- }
34
-
35
- function normalize(path: string): string {
36
- return decodeURI(path)
37
- .replace(HASH_OR_QUERY_RE, '')
38
- .replace(INDEX_OR_EXT_RE, '$1')
39
- }
40
-
41
- export function ensureStartingSlash(path: string): string {
42
- return /^\//.test(path) ? path : `/${path}`
43
- }
44
-
45
- export function isPlainObject(obj: any) {
46
- // 首先排除 null 和非对象类型
47
- if (obj === null || typeof obj !== 'object') {
48
- return false
49
- }
50
-
51
- // 检查对象的构造函数是否是 Object
52
- if (obj.constructor !== Object) {
53
- return false
54
- }
55
-
56
- // 检查对象的原型是否是 Object.prototype
57
- if (Object.getPrototypeOf(obj) !== Object.prototype) {
58
- return false
59
- }
60
-
61
- return true
62
- }
63
-
64
- export function isString(value) {
65
- return typeof value === 'string'
66
- }
67
-
68
- export function capitalizeFirstLetter(string: string) {
69
- if (!string)
70
- return '' // 如果字符串为空,返回空字符串
71
- return string.charAt(0).toUpperCase() + string.slice(1)
72
- }
73
-
74
- export function throttleAndDebounce(fn: () => void, delay: number): () => void {
75
- let timeoutId: NodeJS.Timeout
76
- let called = false
77
-
78
- return () => {
79
- if (timeoutId)
80
- clearTimeout(timeoutId)
81
-
82
- if (!called) {
83
- fn()
84
- ;(called = true) && setTimeout(() => (called = false), delay)
85
- }
86
- else {
87
- timeoutId = setTimeout(fn, delay)
88
- }
89
- }
90
- }
1
+ const HASH_RE = /#.*$/
2
+ const HASH_OR_QUERY_RE = /[?#].*$/
3
+ const INDEX_OR_EXT_RE = /(?:(^|\/)index)?\.(?:md|html)$/
4
+
5
+ export const inBrowser = typeof document !== 'undefined'
6
+
7
+ export function isActive(
8
+ currentPath: string,
9
+ matchPath?: string,
10
+ asRegex: boolean = false,
11
+ ): boolean {
12
+ if (matchPath === undefined) {
13
+ return false
14
+ }
15
+
16
+ currentPath = normalize(`/${currentPath}`)
17
+
18
+ if (asRegex) {
19
+ return new RegExp(matchPath).test(currentPath)
20
+ }
21
+
22
+ if (normalize(matchPath) !== currentPath) {
23
+ return false
24
+ }
25
+
26
+ const hashMatch = matchPath.match(HASH_RE)
27
+
28
+ if (hashMatch) {
29
+ return (inBrowser ? location.hash : '') === hashMatch[0]
30
+ }
31
+
32
+ return true
33
+ }
34
+
35
+ function normalize(path: string): string {
36
+ return decodeURI(path)
37
+ .replace(HASH_OR_QUERY_RE, '')
38
+ .replace(INDEX_OR_EXT_RE, '$1')
39
+ }
40
+
41
+ export function ensureStartingSlash(path: string): string {
42
+ return /^\//.test(path) ? path : `/${path}`
43
+ }
44
+
45
+ export function isPlainObject(obj: any) {
46
+ // 首先排除 null 和非对象类型
47
+ if (obj === null || typeof obj !== 'object') {
48
+ return false
49
+ }
50
+
51
+ // 检查对象的构造函数是否是 Object
52
+ if (obj.constructor !== Object) {
53
+ return false
54
+ }
55
+
56
+ // 检查对象的原型是否是 Object.prototype
57
+ if (Object.getPrototypeOf(obj) !== Object.prototype) {
58
+ return false
59
+ }
60
+
61
+ return true
62
+ }
63
+
64
+ export function isString(value) {
65
+ return typeof value === 'string'
66
+ }
67
+
68
+ export function capitalizeFirstLetter(string: string) {
69
+ if (!string)
70
+ return '' // 如果字符串为空,返回空字符串
71
+ return string.charAt(0).toUpperCase() + string.slice(1)
72
+ }
73
+
74
+ export function throttleAndDebounce(fn: () => void, delay: number): () => void {
75
+ let timeoutId: NodeJS.Timeout
76
+ let called = false
77
+
78
+ return () => {
79
+ if (timeoutId)
80
+ clearTimeout(timeoutId)
81
+
82
+ if (!called) {
83
+ fn()
84
+ ;(called = true) && setTimeout(() => (called = false), delay)
85
+ }
86
+ else {
87
+ timeoutId = setTimeout(fn, delay)
88
+ }
89
+ }
90
+ }
package/index.ts CHANGED
@@ -1,45 +1,45 @@
1
- import type { DefaultTheme, Theme } from 'vitepress'
2
- import VPTheme from 'vitepress/theme'
3
- import Layout from './client/components/Layout.vue'
4
- import 'element-plus/theme-chalk/base.css'
5
- import 'element-plus/theme-chalk/el-tag.css'
6
- import 'element-plus/theme-chalk/dark/css-vars.css'
7
- import './styles/index.scss'
8
- import './styles/base.scss'
9
- import './styles/code.scss'
10
- import './styles/doc-content.scss'
11
- import './styles/tag-content.scss'
12
-
13
- const EPTheme: Theme = {
14
- extends: VPTheme,
15
- Layout,
16
- }
17
- // #region snippet
18
- export interface FooterBlogrollLink {
19
- text: string
20
- link: string
21
- }
22
-
23
- export interface FooterBlogrollSection {
24
- title: string
25
- children: FooterBlogrollLink[]
26
- }
27
-
28
- export interface EPThemeFooter extends DefaultTheme.Footer {
29
- /**
30
- * 友情链接配置
31
- */
32
- blogroll?: FooterBlogrollSection[]
33
- }
34
-
35
- export interface EPThemeConfig extends DefaultTheme.Config {
36
- /**
37
- * 文档版本号
38
- */
39
- version?: string
40
- footer?: EPThemeFooter
41
- }
42
- // #endregion snippet
43
-
44
- export { Layout }
45
- export default EPTheme
1
+ import type { DefaultTheme, Theme } from 'vitepress'
2
+ import VPTheme from 'vitepress/theme'
3
+ import Layout from './client/components/Layout.vue'
4
+ import 'element-plus/theme-chalk/base.css'
5
+ import 'element-plus/theme-chalk/el-tag.css'
6
+ import 'element-plus/theme-chalk/dark/css-vars.css'
7
+ import './styles/index.scss'
8
+ import './styles/base.scss'
9
+ import './styles/code.scss'
10
+ import './styles/doc-content.scss'
11
+ import './styles/tag-content.scss'
12
+
13
+ const EPTheme: Theme = {
14
+ extends: VPTheme,
15
+ Layout,
16
+ }
17
+ // #region snippet
18
+ export interface FooterBlogrollLink {
19
+ text: string
20
+ link: string
21
+ }
22
+
23
+ export interface FooterBlogrollSection {
24
+ title: string
25
+ children: FooterBlogrollLink[]
26
+ }
27
+
28
+ export interface EPThemeFooter extends DefaultTheme.Footer {
29
+ /**
30
+ * 友情链接配置
31
+ */
32
+ blogroll?: FooterBlogrollSection[]
33
+ }
34
+
35
+ export interface EPThemeConfig extends DefaultTheme.Config {
36
+ /**
37
+ * 文档版本号
38
+ */
39
+ version?: string
40
+ footer?: EPThemeFooter
41
+ }
42
+ // #endregion snippet
43
+
44
+ export { Layout }
45
+ export default EPTheme
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitepress-theme-element-plus",
3
3
  "type": "module",
4
- "version": "1.3.1",
4
+ "version": "1.3.2",
5
5
  "description": "A VitePress theme for Element Plus",
6
6
  "author": "Hezhengxu",
7
7
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "styles"
36
36
  ],
37
37
  "peerDependencies": {
38
- "vitepress": "2.0.0-alpha.12"
38
+ "vitepress": "^2.0.0-alpha.12"
39
39
  },
40
40
  "dependencies": {
41
41
  "@iconify/vue": "^4"
@@ -1,3 +1,3 @@
1
- export const NOT_ARTICLE_LAYOUTS = ['blog', 'tags', 'categorys', 'projects', 'home', 'page']
2
-
3
- export const DEFAULT_PAGE_SIZE = 5
1
+ export const NOT_ARTICLE_LAYOUTS = ['blog', 'tags', 'categorys', 'projects', 'home', 'page']
2
+
3
+ export const DEFAULT_PAGE_SIZE = 5
package/styles/base.scss CHANGED
@@ -1,105 +1,105 @@
1
- ::before,
2
- ::after {
3
- box-sizing: border-box;
4
- }
5
-
6
- html {
7
- line-height: 1.4;
8
- font-size: 16px;
9
- text-size-adjust: 100%;
10
- font-family: var(--font-family);
11
- font-weight: 400;
12
- -webkit-font-smoothing: antialiased;
13
- -webkit-tap-highlight-color: transparent;
14
- }
15
-
16
- body {
17
- margin: 0;
18
- width: 100%;
19
- min-width: 320px;
20
- min-height: 100vh;
21
- line-height: 1.4;
22
- font-size: 16px;
23
- font-weight: 400;
24
- color: var(--text-color);
25
- background-color: var(--bg-color);
26
- direction: ltr;
27
- font-synthesis: none;
28
- text-rendering: optimizeLegibility;
29
- -webkit-font-smoothing: antialiased;
30
- -moz-osx-font-smoothing: grayscale;
31
- transition: background-color var(--el-transition-duration-fast);
32
- }
33
-
34
- main {
35
- display: block;
36
- }
37
-
38
- a,
39
- area,
40
- button,
41
- [role='button'],
42
- input,
43
- label,
44
- select,
45
- summary,
46
- textarea {
47
- touch-action: manipulation;
48
- }
49
-
50
- * {
51
- scrollbar-color: var(--el-scrollbar-bg-color) var(--el-fill-color-light);
52
- }
53
-
54
- ::-webkit-scrollbar {
55
- width: 6px;
56
- }
57
-
58
- ::-webkit-scrollbar:horizontal {
59
- height: 6px;
60
- }
61
-
62
- ::-webkit-scrollbar-track {
63
- border-radius: 10px;
64
- }
65
-
66
- ::-webkit-scrollbar-thumb {
67
- background-color: #0003;
68
- border-radius: 10px;
69
- transition: all 0.2s ease-in-out;
70
- }
71
-
72
- ::-webkit-scrollbar-thumb:hover {
73
- cursor: pointer;
74
- background-color: #0000004d;
75
- }
76
-
77
- .dark ::-webkit-scrollbar-thumb {
78
- background-color: #fff3;
79
- }
80
-
81
- .dark ::-webkit-scrollbar-thumb:hover {
82
- background-color: #fff6;
83
- }
84
-
85
- ::view-transition-old(root),
86
- ::view-transition-new(root) {
87
- animation: none;
88
- mix-blend-mode: normal;
89
- }
90
-
91
- ::view-transition-old(root) {
92
- z-index: 1;
93
- }
94
-
95
- ::view-transition-new(root) {
96
- z-index: 2147483646;
97
- }
98
-
99
- .dark::view-transition-old(root) {
100
- z-index: 2147483646;
101
- }
102
-
103
- .dark::view-transition-new(root) {
104
- z-index: 1;
105
- }
1
+ ::before,
2
+ ::after {
3
+ box-sizing: border-box;
4
+ }
5
+
6
+ html {
7
+ line-height: 1.4;
8
+ font-size: 16px;
9
+ text-size-adjust: 100%;
10
+ font-family: var(--font-family);
11
+ font-weight: 400;
12
+ -webkit-font-smoothing: antialiased;
13
+ -webkit-tap-highlight-color: transparent;
14
+ }
15
+
16
+ body {
17
+ margin: 0;
18
+ width: 100%;
19
+ min-width: 320px;
20
+ min-height: 100vh;
21
+ line-height: 1.4;
22
+ font-size: 16px;
23
+ font-weight: 400;
24
+ color: var(--text-color);
25
+ background-color: var(--bg-color);
26
+ direction: ltr;
27
+ font-synthesis: none;
28
+ text-rendering: optimizeLegibility;
29
+ -webkit-font-smoothing: antialiased;
30
+ -moz-osx-font-smoothing: grayscale;
31
+ transition: background-color var(--el-transition-duration-fast);
32
+ }
33
+
34
+ main {
35
+ display: block;
36
+ }
37
+
38
+ a,
39
+ area,
40
+ button,
41
+ [role='button'],
42
+ input,
43
+ label,
44
+ select,
45
+ summary,
46
+ textarea {
47
+ touch-action: manipulation;
48
+ }
49
+
50
+ * {
51
+ scrollbar-color: var(--el-scrollbar-bg-color) var(--el-fill-color-light);
52
+ }
53
+
54
+ ::-webkit-scrollbar {
55
+ width: 6px;
56
+ }
57
+
58
+ ::-webkit-scrollbar:horizontal {
59
+ height: 6px;
60
+ }
61
+
62
+ ::-webkit-scrollbar-track {
63
+ border-radius: 10px;
64
+ }
65
+
66
+ ::-webkit-scrollbar-thumb {
67
+ background-color: #0003;
68
+ border-radius: 10px;
69
+ transition: all 0.2s ease-in-out;
70
+ }
71
+
72
+ ::-webkit-scrollbar-thumb:hover {
73
+ cursor: pointer;
74
+ background-color: #0000004d;
75
+ }
76
+
77
+ .dark ::-webkit-scrollbar-thumb {
78
+ background-color: #fff3;
79
+ }
80
+
81
+ .dark ::-webkit-scrollbar-thumb:hover {
82
+ background-color: #fff6;
83
+ }
84
+
85
+ ::view-transition-old(root),
86
+ ::view-transition-new(root) {
87
+ animation: none;
88
+ mix-blend-mode: normal;
89
+ }
90
+
91
+ ::view-transition-old(root) {
92
+ z-index: 1;
93
+ }
94
+
95
+ ::view-transition-new(root) {
96
+ z-index: 2147483646;
97
+ }
98
+
99
+ .dark::view-transition-old(root) {
100
+ z-index: 2147483646;
101
+ }
102
+
103
+ .dark::view-transition-new(root) {
104
+ z-index: 1;
105
+ }