@varlet/cli 1.27.16 → 1.27.17-alpha.1656907860130
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/LICENCE +21 -21
- package/README.en-US.md +401 -401
- package/README.md +396 -396
- package/generators/base/.prettierignore +9 -9
- package/generators/base/.prettierrc +5 -5
- package/generators/base/README.md +82 -82
- package/generators/base/babel.config.js +10 -10
- package/generators/base/public/highlight.css +1 -1
- package/generators/base/public/logo.svg +1 -1
- package/generators/base/shims/shims-md.d.ts +4 -4
- package/generators/base/shims/shims-vue.d.ts +6 -6
- package/generators/base/tsconfig.json +13 -13
- package/generators/config/default/base/docs/home.zh-CN.md +10 -10
- package/generators/config/default/base/package.json +1 -0
- package/generators/config/default/base/types/basicComponent.d.ts +7 -7
- package/generators/config/default/base/types/button.d.ts +12 -12
- package/generators/config/default/base/types/index.d.ts +6 -6
- package/generators/config/default/base/varlet.config.js +110 -110
- package/generators/config/default/sfc/src/button/Button.vue +30 -30
- package/generators/config/default/sfc/src/button/__tests__/index.spec.js +7 -7
- package/generators/config/default/sfc/src/button/button.less +14 -14
- package/generators/config/default/sfc/src/button/docs/zh-CN.md +47 -47
- package/generators/config/default/sfc/src/button/example/BasicUse.vue +7 -7
- package/generators/config/default/sfc/src/button/example/ModifyColor.vue +7 -7
- package/generators/config/default/sfc/src/button/example/index.vue +13 -13
- package/generators/config/default/sfc/src/button/index.ts +10 -10
- package/generators/config/default/tsx/src/button/Button.tsx +31 -31
- package/generators/config/default/tsx/src/button/__tests__/index.spec.js +7 -7
- package/generators/config/default/tsx/src/button/button.less +14 -14
- package/generators/config/default/tsx/src/button/docs/zh-CN.md +47 -47
- package/generators/config/default/tsx/src/button/example/BasicUse.vue +7 -7
- package/generators/config/default/tsx/src/button/example/ModifyColor.vue +7 -7
- package/generators/config/default/tsx/src/button/example/index.vue +13 -13
- package/generators/config/default/tsx/src/button/index.ts +10 -10
- package/generators/config/i18n/base/docs/home.en-US.md +11 -11
- package/generators/config/i18n/base/docs/home.zh-CN.md +10 -10
- package/generators/config/i18n/base/package.json +1 -0
- package/generators/config/i18n/base/types/basicComponent.d.ts +7 -7
- package/generators/config/i18n/base/types/button.d.ts +12 -12
- package/generators/config/i18n/base/types/index.d.ts +7 -7
- package/generators/config/i18n/base/types/locale.d.ts +24 -24
- package/generators/config/i18n/base/varlet.config.js +122 -122
- package/generators/config/i18n/sfc/src/button/Button.vue +36 -36
- package/generators/config/i18n/sfc/src/button/__tests__/index.spec.js +7 -7
- package/generators/config/i18n/sfc/src/button/button.less +14 -14
- package/generators/config/i18n/sfc/src/button/docs/en-US.md +34 -34
- package/generators/config/i18n/sfc/src/button/docs/zh-CN.md +34 -34
- package/generators/config/i18n/sfc/src/button/example/BasicUse.vue +11 -11
- package/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +11 -11
- package/generators/config/i18n/sfc/src/button/example/index.vue +13 -13
- package/generators/config/i18n/sfc/src/button/example/locale/en-US.ts +5 -5
- package/generators/config/i18n/sfc/src/button/example/locale/index.ts +23 -23
- package/generators/config/i18n/sfc/src/button/example/locale/zh-CN.ts +5 -5
- package/generators/config/i18n/sfc/src/button/index.ts +10 -10
- package/generators/config/i18n/sfc/src/locale/__tests__/index.spec.js +51 -51
- package/generators/config/i18n/sfc/src/locale/docs/en-US.md +26 -26
- package/generators/config/i18n/sfc/src/locale/docs/zh-CN.md +25 -25
- package/generators/config/i18n/sfc/src/locale/en-US.d.ts +5 -5
- package/generators/config/i18n/sfc/src/locale/en-US.ts +7 -7
- package/generators/config/i18n/sfc/src/locale/index.ts +67 -67
- package/generators/config/i18n/sfc/src/locale/zh-CN.d.ts +5 -5
- package/generators/config/i18n/sfc/src/locale/zh-CN.ts +7 -7
- package/generators/config/i18n/tsx/src/button/Button.tsx +35 -35
- package/generators/config/i18n/tsx/src/button/__tests__/index.spec.js +7 -7
- package/generators/config/i18n/tsx/src/button/button.less +14 -14
- package/generators/config/i18n/tsx/src/button/docs/en-US.md +34 -34
- package/generators/config/i18n/tsx/src/button/docs/zh-CN.md +34 -34
- package/generators/config/i18n/tsx/src/button/example/BasicUse.vue +11 -11
- package/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +11 -11
- package/generators/config/i18n/tsx/src/button/example/index.vue +13 -13
- package/generators/config/i18n/tsx/src/button/example/locale/en-US.ts +5 -5
- package/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -23
- package/generators/config/i18n/tsx/src/button/example/locale/zh-CN.ts +5 -5
- package/generators/config/i18n/tsx/src/button/index.ts +10 -10
- package/generators/config/i18n/tsx/src/locale/__tests__/index.spec.js +51 -51
- package/generators/config/i18n/tsx/src/locale/docs/en-US.md +26 -26
- package/generators/config/i18n/tsx/src/locale/docs/zh-CN.md +25 -25
- package/generators/config/i18n/tsx/src/locale/en-US.d.ts +5 -5
- package/generators/config/i18n/tsx/src/locale/en-US.ts +7 -7
- package/generators/config/i18n/tsx/src/locale/index.ts +67 -67
- package/generators/config/i18n/tsx/src/locale/zh-CN.d.ts +5 -5
- package/generators/config/i18n/tsx/src/locale/zh-CN.ts +7 -7
- package/lib/commands/build.d.ts +1 -1
- package/lib/commands/build.js +67 -67
- package/lib/commands/changelog.d.ts +6 -6
- package/lib/commands/changelog.js +27 -27
- package/lib/commands/commitLint.d.ts +1 -1
- package/lib/commands/commitLint.js +21 -21
- package/lib/commands/compile.d.ts +5 -5
- package/lib/commands/compile.js +119 -119
- package/lib/commands/create.d.ts +3 -3
- package/lib/commands/create.js +132 -132
- package/lib/commands/dev.d.ts +3 -3
- package/lib/commands/dev.js +123 -123
- package/lib/commands/gen.d.ts +1 -1
- package/lib/commands/gen.js +112 -112
- package/lib/commands/jest.d.ts +8 -8
- package/lib/commands/jest.js +81 -81
- package/lib/commands/lint.d.ts +1 -1
- package/lib/commands/lint.js +123 -123
- package/lib/commands/preview.d.ts +1 -1
- package/lib/commands/preview.js +74 -74
- package/lib/commands/release.d.ts +3 -3
- package/lib/commands/release.js +267 -269
- package/lib/compiler/compileModule.d.ts +5 -5
- package/lib/compiler/compileModule.js +186 -186
- package/lib/compiler/compileSFC.d.ts +2 -2
- package/lib/compiler/compileSFC.js +132 -132
- package/lib/compiler/compileScript.d.ts +17 -17
- package/lib/compiler/compileScript.js +202 -202
- package/lib/compiler/compileSiteEntry.d.ts +13 -13
- package/lib/compiler/compileSiteEntry.js +237 -237
- package/lib/compiler/compileStyle.d.ts +11 -11
- package/lib/compiler/compileStyle.js +101 -101
- package/lib/compiler/compileTemplateHighlight.d.ts +10 -10
- package/lib/compiler/compileTemplateHighlight.js +193 -193
- package/lib/compiler/compileTypes.d.ts +2 -2
- package/lib/compiler/compileTypes.js +88 -88
- package/lib/config/babel.config.d.ts +2 -2
- package/lib/config/babel.config.js +31 -31
- package/lib/config/babel.sfc.transform.d.ts +1 -1
- package/lib/config/babel.sfc.transform.js +18 -18
- package/lib/config/jest.config.d.ts +1 -1
- package/lib/config/jest.config.js +36 -36
- package/lib/config/jest.media.mock.js +2 -2
- package/lib/config/jest.style.mock.js +2 -2
- package/lib/config/varlet.config.d.ts +1 -1
- package/lib/config/varlet.config.js +24 -24
- package/lib/config/vite.config.d.ts +5 -5
- package/lib/config/vite.config.js +162 -162
- package/lib/index.d.ts +2 -2
- package/lib/index.js +83 -83
- package/lib/shared/constant.d.ts +43 -43
- package/lib/shared/constant.js +50 -50
- package/lib/shared/fsUtils.d.ts +12 -12
- package/lib/shared/fsUtils.js +108 -108
- package/lib/shared/logger.d.ts +7 -7
- package/lib/shared/logger.js +20 -20
- package/package.json +7 -8
- package/preset.js +3 -3
- package/site/components/button/Button.vue +84 -84
- package/site/components/button/button.less +183 -183
- package/site/components/button/index.ts +10 -10
- package/site/components/button/props.ts +70 -70
- package/site/components/cell/Cell.vue +42 -42
- package/site/components/cell/cell.less +74 -74
- package/site/components/cell/index.ts +10 -10
- package/site/components/cell/props.ts +27 -27
- package/site/components/code-example/CodeExample.vue +143 -143
- package/site/components/code-example/codeExample.less +41 -41
- package/site/components/code-example/index.ts +10 -10
- package/site/components/context/index.ts +17 -17
- package/site/components/context/lock.ts +103 -103
- package/site/components/context/zIndex.ts +20 -20
- package/site/components/icon/Icon.vue +68 -68
- package/site/components/icon/icon.less +26 -26
- package/site/components/icon/index.ts +10 -10
- package/site/components/icon/props.ts +24 -24
- package/site/components/loading/Loading.vue +55 -55
- package/site/components/loading/index.ts +10 -10
- package/site/components/loading/loading.less +420 -420
- package/site/components/loading/props.ts +37 -37
- package/site/components/progress/Progress.vue +108 -108
- package/site/components/progress/index.ts +10 -10
- package/site/components/progress/progress.less +98 -98
- package/site/components/progress/props.ts +55 -55
- package/site/components/ripple/index.ts +167 -167
- package/site/components/ripple/ripple.less +17 -17
- package/site/components/snackbar/Snackbar.vue +38 -38
- package/site/components/snackbar/core.vue +117 -117
- package/site/components/snackbar/index.tsx +270 -270
- package/site/components/snackbar/props.ts +94 -94
- package/site/components/snackbar/snackbar.less +135 -135
- package/site/components/styles/common.less +64 -64
- package/site/components/styles/elevation.less +126 -126
- package/site/components/styles/var.less +27 -27
- package/site/components/utils/components.ts +69 -69
- package/site/components/utils/elements.ts +85 -85
- package/site/index.html +49 -49
- package/site/mobile/App.vue +291 -291
- package/site/mobile/components/AppHome.vue +134 -134
- package/site/mobile/components/AppType.vue +22 -22
- package/site/mobile/components/app-bar/AppBar.vue +69 -69
- package/site/mobile/components/app-bar/appBar.less +56 -56
- package/site/mobile/components/app-bar/index.ts +10 -10
- package/site/mobile/components/app-bar/props.ts +25 -25
- package/site/mobile/components/styles/common.less +64 -64
- package/site/mobile/components/styles/elevation.less +126 -126
- package/site/mobile/components/styles/var.less +27 -27
- package/site/mobile/main.ts +74 -74
- package/site/mobile.html +41 -41
- package/site/module.d.ts +5 -5
- package/site/pc/App.vue +43 -43
- package/site/pc/Layout.vue +397 -397
- package/site/pc/components/AnimationBox.vue +45 -45
- package/site/pc/components/AppHeader.vue +355 -355
- package/site/pc/components/AppMobile.vue +54 -54
- package/site/pc/components/AppSidebar.vue +134 -134
- package/site/pc/components/LogoAnimation.vue +119 -119
- package/site/pc/floating.ts +9 -9
- package/site/pc/main.ts +94 -94
- package/site/pc/pages/index/index.less +194 -194
- package/site/pc/pages/index/index.vue +128 -125
- package/site/pc/pages/index/locale/en-US.ts +3 -5
- package/site/pc/pages/index/locale/zh-CN.ts +3 -5
- package/site/tsconfig.json +11 -11
- package/site/useProgress.ts +75 -75
- package/site/utils.ts +153 -153
- package/tsconfig.json +14 -14
- package/varlet.default.config.js +151 -145
package/site/pc/Layout.vue
CHANGED
|
@@ -1,397 +1,397 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import config from '@config'
|
|
3
|
-
import AppMobile from './components/AppMobile.vue'
|
|
4
|
-
import AppHeader from './components/AppHeader.vue'
|
|
5
|
-
import AppSidebar from './components/AppSidebar.vue'
|
|
6
|
-
import { defineComponent, nextTick, onMounted, ref, watch } from 'vue'
|
|
7
|
-
import { useRoute } from 'vue-router'
|
|
8
|
-
import { get } from 'lodash-es'
|
|
9
|
-
import { getPCLocationInfo, MenuTypes } from '../utils'
|
|
10
|
-
import type { Ref } from 'vue'
|
|
11
|
-
|
|
12
|
-
export interface Menu {
|
|
13
|
-
doc: string
|
|
14
|
-
text: Record<string, string>
|
|
15
|
-
type: MenuTypes
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default defineComponent({
|
|
19
|
-
components: {
|
|
20
|
-
AppMobile,
|
|
21
|
-
AppHeader,
|
|
22
|
-
AppSidebar
|
|
23
|
-
},
|
|
24
|
-
setup() {
|
|
25
|
-
const menu: Ref<Menu[]> = ref(get(config, 'pc.menu', []))
|
|
26
|
-
const useMobile = ref(get(config, 'useMobile'))
|
|
27
|
-
const mobileRedirect = get(config, 'mobile.redirect')
|
|
28
|
-
|
|
29
|
-
const language: Ref<string> = ref('')
|
|
30
|
-
const componentName: Ref<null | string> = ref(null)
|
|
31
|
-
const menuName: Ref<string> = ref('')
|
|
32
|
-
const doc: Ref<HTMLElement | null> = ref(null)
|
|
33
|
-
const route = useRoute()
|
|
34
|
-
|
|
35
|
-
const getComponentNameByMenuName = (menuName: string) => {
|
|
36
|
-
const currentMenu = menu.value.find(menu => menu.doc === menuName)
|
|
37
|
-
return currentMenu?.type === MenuTypes.COMPONENT ? menuName : mobileRedirect.slice(1)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const init = () => {
|
|
41
|
-
const { menuName } = getPCLocationInfo()
|
|
42
|
-
|
|
43
|
-
nextTick(() => {
|
|
44
|
-
const children = document
|
|
45
|
-
.querySelector('.varlet-site-sidebar')!
|
|
46
|
-
.getElementsByClassName('var-site-cell')
|
|
47
|
-
const index = menu.value.findIndex((item) => item.doc === menuName)
|
|
48
|
-
|
|
49
|
-
if (index !== -1) {
|
|
50
|
-
children[index].scrollIntoView({
|
|
51
|
-
block: 'center',
|
|
52
|
-
inline: 'start',
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const handleSidebarChange = (menu: Menu) => {
|
|
59
|
-
doc.value!.scrollTop = 0
|
|
60
|
-
componentName.value = getComponentNameByMenuName(menu.doc)
|
|
61
|
-
menuName.value = menu.doc
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
onMounted(init)
|
|
65
|
-
|
|
66
|
-
watch(
|
|
67
|
-
() => route.path,
|
|
68
|
-
() => {
|
|
69
|
-
const { language: lang, menuName: _menuName } = getPCLocationInfo()
|
|
70
|
-
if (!lang || !_menuName) {
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
componentName.value = getComponentNameByMenuName(_menuName)
|
|
75
|
-
menuName.value = _menuName
|
|
76
|
-
language.value = lang
|
|
77
|
-
document.title = get(config, 'pc.title')[lang] as string
|
|
78
|
-
},
|
|
79
|
-
{ immediate: true }
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
menu,
|
|
84
|
-
language,
|
|
85
|
-
componentName,
|
|
86
|
-
menuName,
|
|
87
|
-
doc,
|
|
88
|
-
useMobile,
|
|
89
|
-
handleSidebarChange,
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
})
|
|
93
|
-
</script>
|
|
94
|
-
|
|
95
|
-
<template>
|
|
96
|
-
<div class="varlet-site">
|
|
97
|
-
<app-header :language="language" />
|
|
98
|
-
|
|
99
|
-
<div class="varlet-site-content">
|
|
100
|
-
<app-sidebar
|
|
101
|
-
:language="language"
|
|
102
|
-
:menu="menu"
|
|
103
|
-
:menu-name="menuName"
|
|
104
|
-
@change="handleSidebarChange"
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
<div
|
|
108
|
-
class="varlet-site-doc-container"
|
|
109
|
-
ref="doc"
|
|
110
|
-
:class="[!useMobile && 'varlet-site-doc-container--pc-only']"
|
|
111
|
-
>
|
|
112
|
-
<router-view />
|
|
113
|
-
</div>
|
|
114
|
-
|
|
115
|
-
<app-mobile
|
|
116
|
-
:component-name="componentName"
|
|
117
|
-
:language="language"
|
|
118
|
-
:replace="menuName"
|
|
119
|
-
v-show="useMobile"
|
|
120
|
-
/>
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
123
|
-
</template>
|
|
124
|
-
|
|
125
|
-
<style>
|
|
126
|
-
.hljs {
|
|
127
|
-
background: var(--site-config-color-hl-background) !important;
|
|
128
|
-
padding: 0 !important;
|
|
129
|
-
transition: all .25s
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.hljs code {
|
|
133
|
-
line-height: 31px;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.hljs-comment, .hljs-meta, .hljs-quote {
|
|
137
|
-
color: var(--site-config-color-hl-group-a)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.hljs-keyword, .hljs-name, .hljs-selector-tag, .hljs-tag {
|
|
141
|
-
color: var(--site-config-color-hl-group-b)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.hljs-attribute, .hljs-selector-id {
|
|
145
|
-
color: var(--site-config-color-hl-group-c)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.hljs-addition, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-string {
|
|
149
|
-
color: var(--site-config-color-hl-group-d)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.hljs-subst {
|
|
153
|
-
color: var(--site-config-color-hl-group-e)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.hljs-link, .hljs-regexp {
|
|
157
|
-
color: var(--site-config-color-hl-group-f)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.hljs-doctag, .hljs-section, .hljs-title, .hljs-type {
|
|
161
|
-
color: var(--site-config-color-hl-group-g)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.hljs-bullet, .hljs-literal, .hljs-symbol, .hljs-template-variable, .hljs-variable {
|
|
165
|
-
color: var(--site-config-color-hl-group-h)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.hljs-deletion, .hljs-number {
|
|
169
|
-
color: var(--site-config-color-hl-group-i)
|
|
170
|
-
}
|
|
171
|
-
</style>
|
|
172
|
-
|
|
173
|
-
<style lang="less">
|
|
174
|
-
@doc-active: {
|
|
175
|
-
display: inline;
|
|
176
|
-
font-family: inherit;
|
|
177
|
-
padding: 0;
|
|
178
|
-
white-space: pre-wrap;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
* {
|
|
182
|
-
transition: background-color .25s, box-shadow .25s;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
iframe {
|
|
186
|
-
display: block;
|
|
187
|
-
width: 100%;
|
|
188
|
-
height: 100%;
|
|
189
|
-
border: none;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.varlet {
|
|
193
|
-
&-introduce {
|
|
194
|
-
display: flex;
|
|
195
|
-
flex-direction: column;
|
|
196
|
-
align-items: center;
|
|
197
|
-
margin: 20px 0;
|
|
198
|
-
padding: 90px 40px;
|
|
199
|
-
border-top: 6px solid var(--site-config-color-introduce-border);
|
|
200
|
-
border-radius: 2px;
|
|
201
|
-
background: var(--site-config-color-bar);
|
|
202
|
-
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
203
|
-
|
|
204
|
-
&__row {
|
|
205
|
-
display: flex;
|
|
206
|
-
align-items: center;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
&__image {
|
|
210
|
-
width: 60px;
|
|
211
|
-
margin-right: 20px;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
&__name {
|
|
215
|
-
font-size: 60px;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
&__des {
|
|
219
|
-
color: var(--site-config-color-sub-text);
|
|
220
|
-
font-size: 16px;
|
|
221
|
-
margin-top: 16px;
|
|
222
|
-
-webkit-font-smoothing: antialiased;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
&-component-preview {
|
|
227
|
-
margin-top: 20px;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
&-site {
|
|
231
|
-
min-width: 1200px;
|
|
232
|
-
padding: 60px 0 0;
|
|
233
|
-
&-content {
|
|
234
|
-
display: flex;
|
|
235
|
-
background: var(--site-config-color-body);
|
|
236
|
-
margin-left: 240px;
|
|
237
|
-
min-height: calc(100vh - 60px);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
&-doc-container {
|
|
241
|
-
flex: 1 0 0;
|
|
242
|
-
min-width: 500px;
|
|
243
|
-
padding: 0 25px;
|
|
244
|
-
overflow-x: hidden;
|
|
245
|
-
|
|
246
|
-
&::-webkit-scrollbar {
|
|
247
|
-
display: none;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
&--pc-only {
|
|
251
|
-
padding: 0 90px 0 30px;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
&-doc {
|
|
256
|
-
a {
|
|
257
|
-
color: var(--site-config-color-link);
|
|
258
|
-
-webkit-font-smoothing: antialiased;
|
|
259
|
-
word-break: keep-all;
|
|
260
|
-
font-size: 15px;
|
|
261
|
-
@doc-active();
|
|
262
|
-
|
|
263
|
-
&:hover {
|
|
264
|
-
opacity: 0.8;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
h1,
|
|
269
|
-
h2,
|
|
270
|
-
h3,
|
|
271
|
-
h4,
|
|
272
|
-
h5,
|
|
273
|
-
h6 {
|
|
274
|
-
position: relative;
|
|
275
|
-
color: var(--site-config-color-text);
|
|
276
|
-
font-weight: normal;
|
|
277
|
-
line-height: 1.5;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
h1 {
|
|
281
|
-
line-height: 40px;
|
|
282
|
-
font-size: 30px;
|
|
283
|
-
cursor: default;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
h2 {
|
|
287
|
-
margin: 30px 0 20px;
|
|
288
|
-
font-size: 25px;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
h3 {
|
|
292
|
-
font-size: 18px;
|
|
293
|
-
margin: 0;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
h4 {
|
|
297
|
-
margin: 18px 0 0;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
p,
|
|
301
|
-
ul,
|
|
302
|
-
ol {
|
|
303
|
-
-webkit-font-smoothing: antialiased;
|
|
304
|
-
color: var(--site-config-color-text);
|
|
305
|
-
font-size: 15px;
|
|
306
|
-
line-height: 26px;
|
|
307
|
-
border-radius: 4px;
|
|
308
|
-
background: var(--site-config-color-bar);
|
|
309
|
-
list-style: none;
|
|
310
|
-
margin: 14px 0 0;
|
|
311
|
-
padding: 0;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
pre {
|
|
315
|
-
margin: 0;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
code {
|
|
319
|
-
position: relative;
|
|
320
|
-
display: block;
|
|
321
|
-
padding: 10px 16px;
|
|
322
|
-
overflow-x: auto;
|
|
323
|
-
font-size: 13px;
|
|
324
|
-
font-family: Consolas, Monaco, monospace;
|
|
325
|
-
white-space: pre-wrap;
|
|
326
|
-
word-wrap: break-word;
|
|
327
|
-
color: var(--site-config-color-hl-code);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
p code,
|
|
331
|
-
li code,
|
|
332
|
-
table code {
|
|
333
|
-
-webkit-font-smoothing: antialiased;
|
|
334
|
-
word-break: keep-all;
|
|
335
|
-
color: var(--site-config-color-primary);
|
|
336
|
-
font-size: 15px;
|
|
337
|
-
@doc-active();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
table {
|
|
341
|
-
-webkit-font-smoothing: antialiased;
|
|
342
|
-
width: 100%;
|
|
343
|
-
margin-top: 12px;
|
|
344
|
-
color: var(--site-config-color-text);
|
|
345
|
-
background: var(--site-config-color-bar);
|
|
346
|
-
font-size: 14px;
|
|
347
|
-
line-height: 28px;
|
|
348
|
-
border-collapse: collapse;
|
|
349
|
-
border-radius: 4px;
|
|
350
|
-
|
|
351
|
-
th {
|
|
352
|
-
padding: 8px 16px;
|
|
353
|
-
font-weight: 500;
|
|
354
|
-
text-align: left;
|
|
355
|
-
color: var(--site-config-color-sub-text);
|
|
356
|
-
font-size: 13px;
|
|
357
|
-
-webkit-font-smoothing: antialiased;
|
|
358
|
-
border-bottom: 1px solid var(--site-config-color-border);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
td {
|
|
362
|
-
padding: 8px 16px;
|
|
363
|
-
border-bottom: 1px solid var(--site-config-color-border);
|
|
364
|
-
color: var(--site-config-color-text);
|
|
365
|
-
font-family: Consolas, Monaco, monospace;
|
|
366
|
-
|
|
367
|
-
code {
|
|
368
|
-
white-space: pre-wrap;
|
|
369
|
-
padding: 0;
|
|
370
|
-
font-size: 13px;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
em {
|
|
375
|
-
color: var(--site-config-color-type);
|
|
376
|
-
font-style: normal;
|
|
377
|
-
-webkit-font-smoothing: antialiased;
|
|
378
|
-
font-size: 13px;
|
|
379
|
-
@doc-active();
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
.card {
|
|
384
|
-
border-radius: 4px;
|
|
385
|
-
background: var(--site-config-color-bar);
|
|
386
|
-
padding: 20px;
|
|
387
|
-
margin-bottom: 30px;
|
|
388
|
-
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
389
|
-
|
|
390
|
-
&:first-child{
|
|
391
|
-
margin-top: 30px;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import config from '@config'
|
|
3
|
+
import AppMobile from './components/AppMobile.vue'
|
|
4
|
+
import AppHeader from './components/AppHeader.vue'
|
|
5
|
+
import AppSidebar from './components/AppSidebar.vue'
|
|
6
|
+
import { defineComponent, nextTick, onMounted, ref, watch } from 'vue'
|
|
7
|
+
import { useRoute } from 'vue-router'
|
|
8
|
+
import { get } from 'lodash-es'
|
|
9
|
+
import { getPCLocationInfo, MenuTypes } from '../utils'
|
|
10
|
+
import type { Ref } from 'vue'
|
|
11
|
+
|
|
12
|
+
export interface Menu {
|
|
13
|
+
doc: string
|
|
14
|
+
text: Record<string, string>
|
|
15
|
+
type: MenuTypes
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default defineComponent({
|
|
19
|
+
components: {
|
|
20
|
+
AppMobile,
|
|
21
|
+
AppHeader,
|
|
22
|
+
AppSidebar
|
|
23
|
+
},
|
|
24
|
+
setup() {
|
|
25
|
+
const menu: Ref<Menu[]> = ref(get(config, 'pc.menu', []))
|
|
26
|
+
const useMobile = ref(get(config, 'useMobile'))
|
|
27
|
+
const mobileRedirect = get(config, 'mobile.redirect')
|
|
28
|
+
|
|
29
|
+
const language: Ref<string> = ref('')
|
|
30
|
+
const componentName: Ref<null | string> = ref(null)
|
|
31
|
+
const menuName: Ref<string> = ref('')
|
|
32
|
+
const doc: Ref<HTMLElement | null> = ref(null)
|
|
33
|
+
const route = useRoute()
|
|
34
|
+
|
|
35
|
+
const getComponentNameByMenuName = (menuName: string) => {
|
|
36
|
+
const currentMenu = menu.value.find(menu => menu.doc === menuName)
|
|
37
|
+
return currentMenu?.type === MenuTypes.COMPONENT ? menuName : mobileRedirect.slice(1)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const init = () => {
|
|
41
|
+
const { menuName } = getPCLocationInfo()
|
|
42
|
+
|
|
43
|
+
nextTick(() => {
|
|
44
|
+
const children = document
|
|
45
|
+
.querySelector('.varlet-site-sidebar')!
|
|
46
|
+
.getElementsByClassName('var-site-cell')
|
|
47
|
+
const index = menu.value.findIndex((item) => item.doc === menuName)
|
|
48
|
+
|
|
49
|
+
if (index !== -1) {
|
|
50
|
+
children[index].scrollIntoView({
|
|
51
|
+
block: 'center',
|
|
52
|
+
inline: 'start',
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const handleSidebarChange = (menu: Menu) => {
|
|
59
|
+
doc.value!.scrollTop = 0
|
|
60
|
+
componentName.value = getComponentNameByMenuName(menu.doc)
|
|
61
|
+
menuName.value = menu.doc
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onMounted(init)
|
|
65
|
+
|
|
66
|
+
watch(
|
|
67
|
+
() => route.path,
|
|
68
|
+
() => {
|
|
69
|
+
const { language: lang, menuName: _menuName } = getPCLocationInfo()
|
|
70
|
+
if (!lang || !_menuName) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
componentName.value = getComponentNameByMenuName(_menuName)
|
|
75
|
+
menuName.value = _menuName
|
|
76
|
+
language.value = lang
|
|
77
|
+
document.title = get(config, 'pc.title')[lang] as string
|
|
78
|
+
},
|
|
79
|
+
{ immediate: true }
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
menu,
|
|
84
|
+
language,
|
|
85
|
+
componentName,
|
|
86
|
+
menuName,
|
|
87
|
+
doc,
|
|
88
|
+
useMobile,
|
|
89
|
+
handleSidebarChange,
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<template>
|
|
96
|
+
<div class="varlet-site">
|
|
97
|
+
<app-header :language="language" />
|
|
98
|
+
|
|
99
|
+
<div class="varlet-site-content">
|
|
100
|
+
<app-sidebar
|
|
101
|
+
:language="language"
|
|
102
|
+
:menu="menu"
|
|
103
|
+
:menu-name="menuName"
|
|
104
|
+
@change="handleSidebarChange"
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<div
|
|
108
|
+
class="varlet-site-doc-container"
|
|
109
|
+
ref="doc"
|
|
110
|
+
:class="[!useMobile && 'varlet-site-doc-container--pc-only']"
|
|
111
|
+
>
|
|
112
|
+
<router-view />
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<app-mobile
|
|
116
|
+
:component-name="componentName"
|
|
117
|
+
:language="language"
|
|
118
|
+
:replace="menuName"
|
|
119
|
+
v-show="useMobile"
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
124
|
+
|
|
125
|
+
<style>
|
|
126
|
+
.hljs {
|
|
127
|
+
background: var(--site-config-color-hl-background) !important;
|
|
128
|
+
padding: 0 !important;
|
|
129
|
+
transition: all .25s
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.hljs code {
|
|
133
|
+
line-height: 31px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.hljs-comment, .hljs-meta, .hljs-quote {
|
|
137
|
+
color: var(--site-config-color-hl-group-a)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.hljs-keyword, .hljs-name, .hljs-selector-tag, .hljs-tag {
|
|
141
|
+
color: var(--site-config-color-hl-group-b)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.hljs-attribute, .hljs-selector-id {
|
|
145
|
+
color: var(--site-config-color-hl-group-c)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.hljs-addition, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-string {
|
|
149
|
+
color: var(--site-config-color-hl-group-d)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.hljs-subst {
|
|
153
|
+
color: var(--site-config-color-hl-group-e)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.hljs-link, .hljs-regexp {
|
|
157
|
+
color: var(--site-config-color-hl-group-f)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.hljs-doctag, .hljs-section, .hljs-title, .hljs-type {
|
|
161
|
+
color: var(--site-config-color-hl-group-g)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.hljs-bullet, .hljs-literal, .hljs-symbol, .hljs-template-variable, .hljs-variable {
|
|
165
|
+
color: var(--site-config-color-hl-group-h)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.hljs-deletion, .hljs-number {
|
|
169
|
+
color: var(--site-config-color-hl-group-i)
|
|
170
|
+
}
|
|
171
|
+
</style>
|
|
172
|
+
|
|
173
|
+
<style lang="less">
|
|
174
|
+
@doc-active: {
|
|
175
|
+
display: inline;
|
|
176
|
+
font-family: inherit;
|
|
177
|
+
padding: 0;
|
|
178
|
+
white-space: pre-wrap;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
* {
|
|
182
|
+
transition: background-color .25s, box-shadow .25s;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
iframe {
|
|
186
|
+
display: block;
|
|
187
|
+
width: 100%;
|
|
188
|
+
height: 100%;
|
|
189
|
+
border: none;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.varlet {
|
|
193
|
+
&-introduce {
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-direction: column;
|
|
196
|
+
align-items: center;
|
|
197
|
+
margin: 20px 0;
|
|
198
|
+
padding: 90px 40px;
|
|
199
|
+
border-top: 6px solid var(--site-config-color-introduce-border);
|
|
200
|
+
border-radius: 2px;
|
|
201
|
+
background: var(--site-config-color-bar);
|
|
202
|
+
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
203
|
+
|
|
204
|
+
&__row {
|
|
205
|
+
display: flex;
|
|
206
|
+
align-items: center;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
&__image {
|
|
210
|
+
width: 60px;
|
|
211
|
+
margin-right: 20px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&__name {
|
|
215
|
+
font-size: 60px;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&__des {
|
|
219
|
+
color: var(--site-config-color-sub-text);
|
|
220
|
+
font-size: 16px;
|
|
221
|
+
margin-top: 16px;
|
|
222
|
+
-webkit-font-smoothing: antialiased;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&-component-preview {
|
|
227
|
+
margin-top: 20px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
&-site {
|
|
231
|
+
min-width: 1200px;
|
|
232
|
+
padding: 60px 0 0;
|
|
233
|
+
&-content {
|
|
234
|
+
display: flex;
|
|
235
|
+
background: var(--site-config-color-body);
|
|
236
|
+
margin-left: 240px;
|
|
237
|
+
min-height: calc(100vh - 60px);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
&-doc-container {
|
|
241
|
+
flex: 1 0 0;
|
|
242
|
+
min-width: 500px;
|
|
243
|
+
padding: 0 25px;
|
|
244
|
+
overflow-x: hidden;
|
|
245
|
+
|
|
246
|
+
&::-webkit-scrollbar {
|
|
247
|
+
display: none;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&--pc-only {
|
|
251
|
+
padding: 0 90px 0 30px;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
&-doc {
|
|
256
|
+
a {
|
|
257
|
+
color: var(--site-config-color-link);
|
|
258
|
+
-webkit-font-smoothing: antialiased;
|
|
259
|
+
word-break: keep-all;
|
|
260
|
+
font-size: 15px;
|
|
261
|
+
@doc-active();
|
|
262
|
+
|
|
263
|
+
&:hover {
|
|
264
|
+
opacity: 0.8;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
h1,
|
|
269
|
+
h2,
|
|
270
|
+
h3,
|
|
271
|
+
h4,
|
|
272
|
+
h5,
|
|
273
|
+
h6 {
|
|
274
|
+
position: relative;
|
|
275
|
+
color: var(--site-config-color-text);
|
|
276
|
+
font-weight: normal;
|
|
277
|
+
line-height: 1.5;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
h1 {
|
|
281
|
+
line-height: 40px;
|
|
282
|
+
font-size: 30px;
|
|
283
|
+
cursor: default;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
h2 {
|
|
287
|
+
margin: 30px 0 20px;
|
|
288
|
+
font-size: 25px;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
h3 {
|
|
292
|
+
font-size: 18px;
|
|
293
|
+
margin: 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
h4 {
|
|
297
|
+
margin: 18px 0 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
p,
|
|
301
|
+
ul,
|
|
302
|
+
ol {
|
|
303
|
+
-webkit-font-smoothing: antialiased;
|
|
304
|
+
color: var(--site-config-color-text);
|
|
305
|
+
font-size: 15px;
|
|
306
|
+
line-height: 26px;
|
|
307
|
+
border-radius: 4px;
|
|
308
|
+
background: var(--site-config-color-bar);
|
|
309
|
+
list-style: none;
|
|
310
|
+
margin: 14px 0 0;
|
|
311
|
+
padding: 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
pre {
|
|
315
|
+
margin: 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
code {
|
|
319
|
+
position: relative;
|
|
320
|
+
display: block;
|
|
321
|
+
padding: 10px 16px;
|
|
322
|
+
overflow-x: auto;
|
|
323
|
+
font-size: 13px;
|
|
324
|
+
font-family: Consolas, Monaco, monospace;
|
|
325
|
+
white-space: pre-wrap;
|
|
326
|
+
word-wrap: break-word;
|
|
327
|
+
color: var(--site-config-color-hl-code);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
p code,
|
|
331
|
+
li code,
|
|
332
|
+
table code {
|
|
333
|
+
-webkit-font-smoothing: antialiased;
|
|
334
|
+
word-break: keep-all;
|
|
335
|
+
color: var(--site-config-color-primary);
|
|
336
|
+
font-size: 15px;
|
|
337
|
+
@doc-active();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
table {
|
|
341
|
+
-webkit-font-smoothing: antialiased;
|
|
342
|
+
width: 100%;
|
|
343
|
+
margin-top: 12px;
|
|
344
|
+
color: var(--site-config-color-text);
|
|
345
|
+
background: var(--site-config-color-bar);
|
|
346
|
+
font-size: 14px;
|
|
347
|
+
line-height: 28px;
|
|
348
|
+
border-collapse: collapse;
|
|
349
|
+
border-radius: 4px;
|
|
350
|
+
|
|
351
|
+
th {
|
|
352
|
+
padding: 8px 16px;
|
|
353
|
+
font-weight: 500;
|
|
354
|
+
text-align: left;
|
|
355
|
+
color: var(--site-config-color-sub-text);
|
|
356
|
+
font-size: 13px;
|
|
357
|
+
-webkit-font-smoothing: antialiased;
|
|
358
|
+
border-bottom: 1px solid var(--site-config-color-border);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
td {
|
|
362
|
+
padding: 8px 16px;
|
|
363
|
+
border-bottom: 1px solid var(--site-config-color-border);
|
|
364
|
+
color: var(--site-config-color-text);
|
|
365
|
+
font-family: Consolas, Monaco, monospace;
|
|
366
|
+
|
|
367
|
+
code {
|
|
368
|
+
white-space: pre-wrap;
|
|
369
|
+
padding: 0;
|
|
370
|
+
font-size: 13px;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
em {
|
|
375
|
+
color: var(--site-config-color-type);
|
|
376
|
+
font-style: normal;
|
|
377
|
+
-webkit-font-smoothing: antialiased;
|
|
378
|
+
font-size: 13px;
|
|
379
|
+
@doc-active();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.card {
|
|
384
|
+
border-radius: 4px;
|
|
385
|
+
background: var(--site-config-color-bar);
|
|
386
|
+
padding: 20px;
|
|
387
|
+
margin-bottom: 30px;
|
|
388
|
+
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
389
|
+
|
|
390
|
+
&:first-child{
|
|
391
|
+
margin-top: 30px;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
</style>
|