@varlet/cli 1.27.8-alpha.1651665460392 → 1.27.9
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/generators/base/varlet.config.js +2 -0
- package/lib/commands/compile.js +4 -0
- package/lib/commands/create.js +1 -1
- package/lib/compiler/compileSiteEntry.d.ts +3 -0
- package/lib/compiler/compileSiteEntry.js +86 -9
- package/lib/shared/constant.d.ts +4 -2
- package/lib/shared/constant.js +5 -3
- package/package.json +6 -5
- package/site/components/button/Button.vue +1 -1
- package/site/index.html +8 -0
- package/site/mobile/App.vue +32 -7
- package/site/mobile/components/AppHome.vue +17 -13
- package/site/{components → mobile/components}/app-bar/AppBar.vue +0 -0
- package/site/{components → mobile/components}/app-bar/appBar.less +0 -0
- package/site/{components → mobile/components}/app-bar/index.ts +0 -0
- package/site/{components → mobile/components}/app-bar/props.ts +0 -0
- package/site/mobile/components/styles/common.less +64 -0
- package/site/mobile/components/styles/elevation.less +126 -0
- package/site/mobile/components/styles/var.less +27 -0
- package/site/mobile/main.ts +1 -1
- package/site/pc/App.vue +14 -376
- package/site/pc/Layout.vue +397 -0
- package/site/pc/components/AnimationBox.vue +45 -0
- package/site/pc/components/AppHeader.vue +95 -35
- package/site/pc/components/AppSidebar.vue +2 -2
- package/site/pc/components/LogoAnimation.vue +119 -0
- package/site/pc/floating.ts +9 -0
- package/site/pc/pages/index/index.less +194 -0
- package/site/pc/pages/index/index.vue +125 -0
- package/site/pc/pages/index/locale/en-US.ts +5 -0
- package/site/pc/pages/index/locale/zh-CN.ts +5 -0
- package/varlet.default.config.js +16 -3
|
@@ -0,0 +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>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, onMounted, onBeforeUnmount, onUnmounted, ref, useAttrs } from 'vue'
|
|
3
|
+
import { animationBoxData, animationEl, animationElClientRect } from '../floating'
|
|
4
|
+
|
|
5
|
+
export default defineComponent({
|
|
6
|
+
name: 'AnimationBox',
|
|
7
|
+
setup() {
|
|
8
|
+
const mutationObserver = ref<MutationObserver>()
|
|
9
|
+
const varletLogoAnimationRef = ref<HTMLElement>()
|
|
10
|
+
animationBoxData.attrs = useAttrs()
|
|
11
|
+
|
|
12
|
+
onMounted(() => {
|
|
13
|
+
animationEl.value = varletLogoAnimationRef.value
|
|
14
|
+
animationElClientRect.value = varletLogoAnimationRef?.value?.getBoundingClientRect();
|
|
15
|
+
mutationObserver.value = new MutationObserver(() => {
|
|
16
|
+
animationElClientRect.value = varletLogoAnimationRef?.value?.getBoundingClientRect();
|
|
17
|
+
});
|
|
18
|
+
const logoContainer = varletLogoAnimationRef.value?.parentNode?.parentNode
|
|
19
|
+
mutationObserver.value.observe(logoContainer || document.body, {
|
|
20
|
+
attributes: true,
|
|
21
|
+
subtree: true,
|
|
22
|
+
childList:true
|
|
23
|
+
});
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
onBeforeUnmount(() => {
|
|
27
|
+
mutationObserver.value?.disconnect();
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
onUnmounted(() => {
|
|
31
|
+
animationEl.value = undefined
|
|
32
|
+
animationElClientRect.value = undefined
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
varletLogoAnimationRef,
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<div ref="varletLogoAnimationRef" data-animation="port"></div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="varlet-site-header">
|
|
3
3
|
<div class="varlet-site-header__lead">
|
|
4
|
-
<
|
|
5
|
-
<div class="varlet-site-header__title" v-if="title">{{ title }}</div>
|
|
4
|
+
<animation-box class="varlet-site-header__logo" @click="backRoot" />
|
|
5
|
+
<div class="varlet-site-header__title" v-if="title" @click="backRoot">{{ title }}</div>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
<div class="varlet-site-header__tail">
|
|
9
|
-
<
|
|
10
|
-
class="varlet-site-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
v-
|
|
14
|
-
v-if="playground"
|
|
9
|
+
<div
|
|
10
|
+
class="varlet-site-header__versions"
|
|
11
|
+
@mouseenter="isOpenVersionsMenu = true"
|
|
12
|
+
@mouseleave="isOpenVersionsMenu = false"
|
|
13
|
+
v-if="versionItems"
|
|
15
14
|
>
|
|
15
|
+
<span style="font-size: 14px;">{{ currentVersion }}</span>
|
|
16
|
+
<var-site-icon name="chevron-down" />
|
|
17
|
+
<transition name="fade">
|
|
18
|
+
<div
|
|
19
|
+
class="varlet-site-header__animation-list varlet-site-header__animation-versions var-site-elevation--5"
|
|
20
|
+
v-show="isOpenVersionsMenu"
|
|
21
|
+
:style="{ pointerEvents: isOpenVersionsMenu ? 'auto' : 'none' }"
|
|
22
|
+
>
|
|
23
|
+
<var-site-cell
|
|
24
|
+
v-for="(value, key) in nonEmptyVersions"
|
|
25
|
+
v-ripple
|
|
26
|
+
:key="key"
|
|
27
|
+
:class="{ 'varlet-site-header__animation-list--active': currentVersion === key }"
|
|
28
|
+
@click="open(value)"
|
|
29
|
+
>{{ key }}
|
|
30
|
+
</var-site-cell>
|
|
31
|
+
</div>
|
|
32
|
+
</transition>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<a class="varlet-site-header__link" target="_blank" :href="playground" v-ripple v-if="playground">
|
|
16
36
|
<var-site-icon name="code-json" :size="24" />
|
|
17
37
|
</a>
|
|
18
|
-
<a
|
|
19
|
-
class="varlet-site-header__link"
|
|
20
|
-
target="_blank"
|
|
21
|
-
:href="github"
|
|
22
|
-
v-ripple
|
|
23
|
-
v-if="github"
|
|
24
|
-
>
|
|
38
|
+
<a class="varlet-site-header__link" target="_blank" :href="github" v-ripple v-if="github">
|
|
25
39
|
<var-site-icon name="github" :size="28" />
|
|
26
40
|
</a>
|
|
27
|
-
<div
|
|
28
|
-
class="varlet-site-header__theme"
|
|
29
|
-
v-ripple
|
|
30
|
-
v-if="darkMode"
|
|
31
|
-
@click="toggleTheme"
|
|
32
|
-
>
|
|
41
|
+
<div class="varlet-site-header__theme" v-ripple v-if="darkMode" @click="toggleTheme">
|
|
33
42
|
<var-site-icon
|
|
34
43
|
size="26px"
|
|
35
44
|
:name="currentThemes === 'themes' ? 'white-balance-sunny' : 'weather-night'"
|
|
@@ -41,30 +50,30 @@
|
|
|
41
50
|
</div>
|
|
42
51
|
<div
|
|
43
52
|
class="varlet-site-header__language"
|
|
44
|
-
@mouseenter="
|
|
45
|
-
@mouseleave="
|
|
53
|
+
@mouseenter="isOpenLanguageMenu = true"
|
|
54
|
+
@mouseleave="isOpenLanguageMenu = false"
|
|
46
55
|
v-if="languages"
|
|
47
56
|
>
|
|
48
57
|
<var-site-icon name="translate" size="26px" />
|
|
49
58
|
<var-site-icon name="chevron-down" />
|
|
50
59
|
<transition name="fade">
|
|
51
60
|
<div
|
|
52
|
-
class="varlet-site-
|
|
53
|
-
v-show="
|
|
54
|
-
:style="{ pointerEvents:
|
|
61
|
+
class="varlet-site-header__animation-list var-site-elevation--5"
|
|
62
|
+
v-show="isOpenLanguageMenu"
|
|
63
|
+
:style="{ pointerEvents: isOpenLanguageMenu ? 'auto' : 'none' }"
|
|
55
64
|
>
|
|
56
65
|
<var-site-cell
|
|
57
66
|
v-for="(value, key) in nonEmptyLanguages"
|
|
58
67
|
v-ripple
|
|
59
68
|
:key="key"
|
|
60
|
-
:class="{ 'varlet-site-
|
|
69
|
+
:class="{ 'varlet-site-header__animation-list--active': language === key }"
|
|
61
70
|
@click="handleLanguageChange(key)"
|
|
62
|
-
|
|
63
|
-
{{ value }}
|
|
71
|
+
>{{ value }}
|
|
64
72
|
</var-site-cell>
|
|
65
73
|
</div>
|
|
66
74
|
</transition>
|
|
67
75
|
</div>
|
|
76
|
+
|
|
68
77
|
</div>
|
|
69
78
|
</div>
|
|
70
79
|
</template>
|
|
@@ -75,33 +84,45 @@ import { ref, computed, defineComponent } from 'vue'
|
|
|
75
84
|
import { get } from 'lodash-es'
|
|
76
85
|
import { getBrowserThemes, getPCLocationInfo, removeEmpty, setThemes, watchThemes } from '../../utils'
|
|
77
86
|
import { useRouter } from 'vue-router'
|
|
87
|
+
import AnimationBox from './AnimationBox.vue'
|
|
78
88
|
import type { Ref, ComputedRef } from 'vue'
|
|
79
89
|
|
|
80
90
|
export default defineComponent({
|
|
81
91
|
name: 'AppHeader',
|
|
92
|
+
components: { AnimationBox },
|
|
82
93
|
props: {
|
|
83
94
|
language: {
|
|
84
95
|
type: String,
|
|
85
|
-
}
|
|
96
|
+
}
|
|
86
97
|
},
|
|
87
98
|
setup() {
|
|
88
99
|
const title: Ref<string> = ref(get(config, 'title'))
|
|
89
100
|
const logo: Ref<string> = ref(get(config, 'logo'))
|
|
90
101
|
const themesKey = get(config, 'themesKey')
|
|
91
102
|
const languages: Ref<Record<string, string>> = ref(get(config, 'pc.header.i18n'))
|
|
103
|
+
const currentVersion: Ref<string> = ref(get(config, 'pc.header.version.current'))
|
|
104
|
+
const versionItems: Ref<Record<string, string>> = ref(get(config, 'pc.header.version.items'))
|
|
92
105
|
const playground: Ref<string> = ref(get(config, 'pc.header.playground'))
|
|
93
106
|
const github: Ref<string> = ref(get(config, 'pc.header.github'))
|
|
107
|
+
const redirect = get(config, 'pc.redirect')
|
|
94
108
|
const darkMode: Ref<boolean> = ref(get(config, 'pc.header.darkMode'))
|
|
95
109
|
const currentThemes = ref(getBrowserThemes(themesKey))
|
|
96
110
|
|
|
97
|
-
const
|
|
111
|
+
const isOpenLanguageMenu: Ref<boolean> = ref(false)
|
|
112
|
+
const isOpenVersionsMenu: Ref<boolean> = ref(false)
|
|
98
113
|
const router = useRouter()
|
|
99
114
|
const nonEmptyLanguages: ComputedRef<Record<string, string>> = computed(() => removeEmpty(languages.value))
|
|
115
|
+
const nonEmptyVersions: ComputedRef<Record<string, string>> = computed(() => removeEmpty(versionItems.value))
|
|
116
|
+
|
|
117
|
+
const backRoot = () => {
|
|
118
|
+
const { language: lang } = getPCLocationInfo()
|
|
119
|
+
router.replace(`/${lang}${redirect}`)
|
|
120
|
+
}
|
|
100
121
|
|
|
101
122
|
const handleLanguageChange = (language: string) => {
|
|
102
123
|
const { menuName } = getPCLocationInfo()
|
|
103
124
|
router.replace(`/${language}/${menuName}`)
|
|
104
|
-
|
|
125
|
+
isOpenLanguageMenu.value = false
|
|
105
126
|
}
|
|
106
127
|
|
|
107
128
|
const setCurrentThemes = (themes: 'themes' | 'darkThemes') => {
|
|
@@ -118,6 +139,14 @@ export default defineComponent({
|
|
|
118
139
|
;(document.getElementById('mobile') as HTMLIFrameElement).contentWindow!.postMessage(getThemesMessage(), '*')
|
|
119
140
|
}
|
|
120
141
|
|
|
142
|
+
const open = (value: string) => {
|
|
143
|
+
if (value !== currentVersion.value) {
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
window.location.href = value
|
|
146
|
+
}, 350);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
121
150
|
watchThemes((themes, from) => {
|
|
122
151
|
from === 'mobile' && setCurrentThemes(themes)
|
|
123
152
|
})
|
|
@@ -128,13 +157,19 @@ export default defineComponent({
|
|
|
128
157
|
return {
|
|
129
158
|
logo,
|
|
130
159
|
title,
|
|
160
|
+
currentVersion,
|
|
131
161
|
languages,
|
|
162
|
+
versionItems,
|
|
132
163
|
nonEmptyLanguages,
|
|
164
|
+
nonEmptyVersions,
|
|
133
165
|
playground,
|
|
134
166
|
github,
|
|
135
|
-
|
|
167
|
+
isOpenLanguageMenu,
|
|
168
|
+
isOpenVersionsMenu,
|
|
136
169
|
darkMode,
|
|
137
170
|
currentThemes,
|
|
171
|
+
open,
|
|
172
|
+
backRoot,
|
|
138
173
|
handleLanguageChange,
|
|
139
174
|
toggleTheme,
|
|
140
175
|
}
|
|
@@ -186,7 +221,7 @@ export default defineComponent({
|
|
|
186
221
|
padding: 0 30px;
|
|
187
222
|
justify-content: space-between;
|
|
188
223
|
user-select: none;
|
|
189
|
-
z-index:
|
|
224
|
+
z-index: 9;
|
|
190
225
|
background: var(--site-config-color-bar);
|
|
191
226
|
border-bottom: 1px solid var(--site-config-color-border);
|
|
192
227
|
box-sizing: border-box;
|
|
@@ -194,16 +229,20 @@ export default defineComponent({
|
|
|
194
229
|
&__lead {
|
|
195
230
|
display: flex;
|
|
196
231
|
align-items: center;
|
|
232
|
+
cursor: pointer;
|
|
197
233
|
}
|
|
198
234
|
|
|
199
235
|
&__logo {
|
|
200
236
|
width: 32px;
|
|
237
|
+
height: 32px;
|
|
201
238
|
margin-right: 12px;
|
|
202
239
|
flex-shrink: 0;
|
|
240
|
+
transition: 0.3s all ease-in-out;
|
|
203
241
|
}
|
|
204
242
|
|
|
205
243
|
&__title {
|
|
206
244
|
font-size: 22px;
|
|
245
|
+
margin-right: 12px;
|
|
207
246
|
}
|
|
208
247
|
|
|
209
248
|
&__tail {
|
|
@@ -232,6 +271,23 @@ export default defineComponent({
|
|
|
232
271
|
}
|
|
233
272
|
}
|
|
234
273
|
|
|
274
|
+
&__versions {
|
|
275
|
+
border-radius: 3px;
|
|
276
|
+
height: 40px;
|
|
277
|
+
display: flex;
|
|
278
|
+
align-items: center;
|
|
279
|
+
padding-right: 10px;
|
|
280
|
+
padding-left: 18px;
|
|
281
|
+
position: relative;
|
|
282
|
+
cursor: pointer;
|
|
283
|
+
transition: background-color 0.25s;
|
|
284
|
+
margin-right: 6px;
|
|
285
|
+
|
|
286
|
+
&:hover {
|
|
287
|
+
background: var(--site-config-color-nav-button-hover-background);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
235
291
|
&__link {
|
|
236
292
|
border-radius: 50%;
|
|
237
293
|
width: 42px;
|
|
@@ -270,7 +326,7 @@ export default defineComponent({
|
|
|
270
326
|
}
|
|
271
327
|
}
|
|
272
328
|
|
|
273
|
-
&
|
|
329
|
+
&__animation-list {
|
|
274
330
|
background: var(--site-config-color-bar);
|
|
275
331
|
cursor: pointer;
|
|
276
332
|
color: var(--site-config-color-text);
|
|
@@ -293,5 +349,9 @@ export default defineComponent({
|
|
|
293
349
|
color: var(--site-config-color-pc-language-active);
|
|
294
350
|
}
|
|
295
351
|
}
|
|
352
|
+
|
|
353
|
+
&__animation-versions {
|
|
354
|
+
left: -7px;
|
|
355
|
+
}
|
|
296
356
|
}
|
|
297
357
|
</style>
|