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