@varlet/cli 1.27.7-alpha.1651056904329 → 1.27.8

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