@varlet/cli 1.27.8 → 1.27.10

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.
@@ -61,6 +61,8 @@ module.exports = {
61
61
  'zh-CN': '一个组件库',
62
62
  },
63
63
  header: {
64
+ darkMode: null,
65
+ versions: null,
64
66
  i18n: null,
65
67
  playground: null,
66
68
  github: 'https://github.com/varletjs/varlet',
@@ -90,15 +90,19 @@ function compile(cmd) {
90
90
  return [4 /*yield*/, Promise.all([runTask('types', compileTypes_1.compileTypes), runTask('template highlight', compileTemplateHighlight_1.compileTemplateHighlight)])];
91
91
  case 2:
92
92
  _b.sent();
93
+ process.env.TARGET_MODULE = 'module';
93
94
  return [4 /*yield*/, runTask('module', compileModule_1.compileModule)];
94
95
  case 3:
95
96
  _b.sent();
97
+ process.env.TARGET_MODULE = 'esm-bundle';
96
98
  return [4 /*yield*/, runTask('esm bundle', function () { return (0, compileModule_1.compileModule)('esm-bundle'); })];
97
99
  case 4:
98
100
  _b.sent();
101
+ process.env.TARGET_MODULE = 'commonjs';
99
102
  return [4 /*yield*/, runTask('commonjs', function () { return (0, compileModule_1.compileModule)('commonjs'); })];
100
103
  case 5:
101
104
  _b.sent();
105
+ process.env.TARGET_MODULE = 'umd';
102
106
  _a = !cmd.noUmd;
103
107
  if (!_a) return [3 /*break*/, 7];
104
108
  return [4 /*yield*/, runTask('umd', function () { return (0, compileModule_1.compileModule)('umd'); })];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.27.8",
3
+ "version": "1.27.10",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -33,9 +33,9 @@
33
33
  "@babel/helper-plugin-utils": "^7.14.5",
34
34
  "@babel/preset-env": "^7.14.8",
35
35
  "@babel/preset-typescript": "^7.14.5",
36
- "@varlet/icons": "1.27.8",
37
- "@varlet/markdown-vite-plugin": "1.27.8",
38
- "@varlet/touch-emulator": "1.27.8",
36
+ "@varlet/icons": "1.27.10",
37
+ "@varlet/markdown-vite-plugin": "1.27.10",
38
+ "@varlet/touch-emulator": "1.27.10",
39
39
  "@vitejs/plugin-vue": "2.2.0",
40
40
  "@vitejs/plugin-vue-jsx": "1.3.5",
41
41
  "@vue/babel-plugin-jsx": "1.1.1",
@@ -68,6 +68,7 @@
68
68
  "devDependencies": {
69
69
  "@types/babel__core": "^7.1.12",
70
70
  "@types/fs-extra": "^9.0.2",
71
+ "@types/glob": "^7.1.3",
71
72
  "@types/hash-sum": "^1.0.0",
72
73
  "@types/jest": "^26.0.15",
73
74
  "@types/lodash": "^4.14.174",
@@ -75,7 +76,7 @@
75
76
  "@types/semver": "^7.3.9"
76
77
  },
77
78
  "peerDependencies": {
78
- "@varlet/touch-emulator": "1.27.8",
79
+ "@varlet/touch-emulator": "1.27.10",
79
80
  "@vue/test-utils": "^2.0.0-rc.6",
80
81
  "clipboard": "^2.0.6",
81
82
  "live-server": "^1.2.1",
@@ -4,7 +4,7 @@
4
4
  <var-site-app-bar class="app-bar" title-position="left" :title="bigCamelizeComponentName">
5
5
  <template #left>
6
6
  <var-site-button v-if="showBackIcon" text round @click="back" color="transparent" text-color="#fff">
7
- <var-site-icon name="chevron-left" :size="28" style="margin-top: 1px" />
7
+ <var-site-icon name="chevron-left" class="arrow-left" style="margin-top: 1px" />
8
8
  </var-site-button>
9
9
  <var-site-button
10
10
  v-if="!showBackIcon && github"
@@ -15,7 +15,7 @@
15
15
  color="transparent"
16
16
  text-color="#fff"
17
17
  >
18
- <var-site-icon name="github" :size="28" style="margin-top: 1px" />
18
+ <var-site-icon name="github" class="github" style="margin-top: 1px" />
19
19
  </var-site-button>
20
20
  </template>
21
21
  <template #right>
@@ -31,21 +31,21 @@
31
31
  @click="toggleTheme"
32
32
  >
33
33
  <var-site-icon
34
- size="24px"
34
+ class="theme"
35
35
  color="#fff"
36
36
  :name="currentThemes === 'themes' ? 'white-balance-sunny' : 'weather-night'"
37
37
  />
38
38
  </var-site-button>
39
39
  <var-site-button
40
- style="padding-right: 6px"
40
+ class="i18n-button"
41
41
  text
42
42
  color="transparent"
43
43
  text-color="#fff"
44
44
  @click.stop="showMenu = true"
45
45
  v-if="languages"
46
46
  >
47
- <var-site-icon name="translate" :size="24" />
48
- <var-site-icon name="chevron-down" :size="22" />
47
+ <var-site-icon name="translate" class="i18n" />
48
+ <var-site-icon name="chevron-down" class="arrow-down" />
49
49
  </var-site-button>
50
50
  </template>
51
51
  </var-site-app-bar>
@@ -200,6 +200,7 @@ body {
200
200
  margin: 0;
201
201
  padding: 0;
202
202
  min-height: 100%;
203
+ font-size: 16px;
203
204
  font-family: 'Roboto', sans-serif;
204
205
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
205
206
  background: var(--site-config-color-bar);
@@ -246,7 +247,7 @@ header {
246
247
  }
247
248
 
248
249
  .router-view__block {
249
- padding: 54px 12px 15px;
250
+ padding: 55px 15px 15px;
250
251
  }
251
252
 
252
253
  * {
@@ -263,4 +264,28 @@ header {
263
264
  background: var(--site-config-color-mobile-language-active-background);
264
265
  }
265
266
  }
267
+
268
+ .arrow-left {
269
+ font-size: 28px !important;
270
+ }
271
+
272
+ .github {
273
+ font-size: 28px !important;
274
+ }
275
+
276
+ .theme {
277
+ font-size: 24px !important;
278
+ }
279
+
280
+ .i18n {
281
+ font-size: 24px !important;
282
+ }
283
+
284
+ .arrow-down {
285
+ font-size: 22px !important;
286
+ }
287
+
288
+ .i18n-button {
289
+ padding-right: 6px !important;
290
+ }
266
291
  </style>
@@ -6,19 +6,17 @@
6
6
  </h1>
7
7
  <h2 class="varlet-home__desc">{{ description[lang] }}</h2>
8
8
  </div>
9
- <var-site-cell
9
+
10
+ <div
11
+ class="varlet-home__cell"
10
12
  v-for="component in components"
11
13
  :key="component.text"
12
- @click="toComponent(component)"
13
14
  v-ripple
15
+ @click="toComponent(component)"
14
16
  >
15
- <template #extra>
16
- <var-site-icon name="chevron-right" size="14" />
17
- </template>
18
- <template #default>
19
- {{ component.text[lang] }}
20
- </template>
21
- </var-site-cell>
17
+ <span>{{ component.text[lang] }}</span>
18
+ <var-site-icon name="chevron-right" size="14" />
19
+ </div>
22
20
  </template>
23
21
 
24
22
  <script lang='ts'>
@@ -85,7 +83,7 @@ export default {
85
83
 
86
84
  .varlet-home__title {
87
85
  margin: 0 0 16px;
88
- font-size: 32px;
86
+ font-size: 34px;
89
87
  }
90
88
 
91
89
  .varlet-home__title,
@@ -103,8 +101,8 @@ export default {
103
101
  }
104
102
 
105
103
  .varlet-home__image {
106
- width: 32px;
107
- height: 32px;
104
+ width: 36px;
105
+ height: 36px;
108
106
  }
109
107
 
110
108
  .varlet-home__image,
@@ -117,7 +115,13 @@ export default {
117
115
  margin-left: 16px;
118
116
  }
119
117
 
120
- .var-site-cell {
118
+ .varlet-home__cell {
119
+ display: flex;
120
+ align-items: center;
121
+ justify-content: space-between;
122
+ min-height: 40px;
123
+ padding: 10px 12px;
124
+ font-size: 15px;
121
125
  cursor: pointer;
122
126
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
123
127
  transition: all 0.3s;
@@ -0,0 +1,64 @@
1
+ @import './var';
2
+
3
+ .var-site {
4
+ &--box {
5
+ box-sizing: border-box;
6
+
7
+ * {
8
+ box-sizing: border-box;
9
+ }
10
+ }
11
+
12
+ &--relative {
13
+ position: relative;
14
+ }
15
+
16
+ &--absolute {
17
+ position: absolute;
18
+ }
19
+
20
+ &--hidden {
21
+ overflow: hidden;
22
+ }
23
+
24
+ &--lock {
25
+ overflow: hidden;
26
+ }
27
+
28
+ &--block {
29
+ display: block;
30
+ }
31
+
32
+ &--inline-block {
33
+ display: inline-block;
34
+ }
35
+
36
+ &--flex {
37
+ display: flex;
38
+ }
39
+
40
+ &--inline-flex {
41
+ display: inline-flex;
42
+ }
43
+ }
44
+
45
+ :root {
46
+ --site-font-size-xs: @site-font-size-xs;
47
+ --site-font-size-sm: @site-font-size-sm;
48
+ --site-font-size-md: @site-font-size-md;
49
+ --site-font-size-lg: @site-font-size-lg;
50
+ --site-icon-size-xs: @site-icon-size-xs;
51
+ --site-icon-size-sm: @site-icon-size-sm;
52
+ --site-icon-size-md: @site-icon-size-md;
53
+ --site-icon-size-lg: @site-icon-size-lg;
54
+ --site-color-primary: @site-color-primary;
55
+ --site-color-info: @site-color-info;
56
+ --site-color-success: @site-color-success;
57
+ --site-color-warning: @site-color-warning;
58
+ --site-color-danger: @site-color-danger;
59
+ --site-color-disabled: @site-color-disabled;
60
+ --site-cubic-bezier: @site-cubic-bezier;
61
+ --site-shadow-key-umbra-opacity: @site-shadow-key-umbra-opacity;
62
+ --site-shadow-key-penumbra-opacity: @site-shadow-key-penumbra-opacity;
63
+ --site-shadow-key-ambient-opacity: @site-shadow-key-ambient-opacity;
64
+ }
@@ -0,0 +1,126 @@
1
+ .var-site-elevation {
2
+ &--0 {
3
+ box-shadow: 0 0 0 0 var(--site-shadow-key-umbra-opacity), 0 0 0 0 var(--site-shadow-key-penumbra-opacity),
4
+ 0 0 0 0 var(--site-shadow-key-ambient-opacity);
5
+ }
6
+
7
+ &--1 {
8
+ box-shadow: 0 2px 1px -1px var(--site-shadow-key-umbra-opacity), 0 1px 1px 0 var(--site-shadow-key-penumbra-opacity),
9
+ 0 1px 3px 0 var(--site-shadow-key-ambient-opacity);
10
+ }
11
+
12
+ &--2 {
13
+ box-shadow: 0 3px 1px -2px var(--site-shadow-key-umbra-opacity), 0 2px 2px 0 var(--site-shadow-key-penumbra-opacity),
14
+ 0 1px 5px 0 var(--site-shadow-key-ambient-opacity);
15
+ }
16
+
17
+ &--3 {
18
+ box-shadow: 0 3px 3px -2px var(--site-shadow-key-umbra-opacity), 0 3px 4px 0 var(--site-shadow-key-penumbra-opacity),
19
+ 0 1px 8px 0 var(--site-shadow-key-ambient-opacity);
20
+ }
21
+
22
+ &--4 {
23
+ box-shadow: 0 2px 4px -1px var(--site-shadow-key-umbra-opacity), 0 4px 5px 0 var(--site-shadow-key-penumbra-opacity),
24
+ 0 1px 10px 0 var(--site-shadow-key-ambient-opacity);
25
+ }
26
+
27
+ &--5 {
28
+ box-shadow: 0 3px 5px -1px var(--site-shadow-key-umbra-opacity), 0 5px 8px 0 var(--site-shadow-key-penumbra-opacity),
29
+ 0 1px 14px 0 var(--site-shadow-key-ambient-opacity);
30
+ }
31
+
32
+ &--6 {
33
+ box-shadow: 0 3px 5px -1px var(--site-shadow-key-umbra-opacity), 0 6px 10px 0 var(--site-shadow-key-penumbra-opacity),
34
+ 0 1px 18px 0 var(--site-shadow-key-ambient-opacity);
35
+ }
36
+
37
+ &--7 {
38
+ box-shadow: 0 4px 5px -2px var(--site-shadow-key-umbra-opacity), 0 7px 10px 1px var(--site-shadow-key-penumbra-opacity),
39
+ 0 2px 16px 1px var(--site-shadow-key-ambient-opacity);
40
+ }
41
+
42
+ &--8 {
43
+ box-shadow: 0 5px 5px -3px var(--site-shadow-key-umbra-opacity), 0 8px 10px 1px var(--site-shadow-key-penumbra-opacity),
44
+ 0 3px 14px 2px var(--site-shadow-key-ambient-opacity);
45
+ }
46
+
47
+ &--9 {
48
+ box-shadow: 0 5px 6px -3px var(--site-shadow-key-umbra-opacity), 0 9px 12px 1px var(--site-shadow-key-penumbra-opacity),
49
+ 0 3px 16px 2px var(--site-shadow-key-ambient-opacity);
50
+ }
51
+
52
+ &--10 {
53
+ box-shadow: 0 6px 6px -3px var(--site-shadow-key-umbra-opacity), 0 10px 14px 1px var(--site-shadow-key-penumbra-opacity),
54
+ 0 4px 18px 3px var(--site-shadow-key-ambient-opacity);
55
+ }
56
+
57
+ &--11 {
58
+ box-shadow: 0 6px 7px -4px var(--site-shadow-key-umbra-opacity), 0 11px 15px 1px var(--site-shadow-key-penumbra-opacity),
59
+ 0 4px 20px 3px var(--site-shadow-key-ambient-opacity);
60
+ }
61
+
62
+ &--12 {
63
+ box-shadow: 0 7px 8px -4px var(--site-shadow-key-umbra-opacity), 0 12px 17px 2px var(--site-shadow-key-penumbra-opacity),
64
+ 0 5px 22px 4px var(--site-shadow-key-ambient-opacity);
65
+ }
66
+
67
+ &--13 {
68
+ box-shadow: 0 7px 8px -4px var(--site-shadow-key-umbra-opacity), 0 13px 19px 2px var(--site-shadow-key-penumbra-opacity),
69
+ 0 5px 24px 4px var(--site-shadow-key-ambient-opacity);
70
+ }
71
+
72
+ &--14 {
73
+ box-shadow: 0 7px 9px -4px var(--site-shadow-key-umbra-opacity), 0 14px 21px 2px var(--site-shadow-key-penumbra-opacity),
74
+ 0 5px 26px 4px var(--site-shadow-key-ambient-opacity);
75
+ }
76
+
77
+ &--15 {
78
+ box-shadow: 0 8px 9px -5px var(--site-shadow-key-umbra-opacity), 0 15px 22px 2px var(--site-shadow-key-penumbra-opacity),
79
+ 0 6px 28px 5px var(--site-shadow-key-ambient-opacity);
80
+ }
81
+
82
+ &--16 {
83
+ box-shadow: 0 8px 10px -5px var(--site-shadow-key-umbra-opacity), 0 16px 24px 2px var(--site-shadow-key-penumbra-opacity),
84
+ 0 6px 30px 5px var(--site-shadow-key-ambient-opacity);
85
+ }
86
+
87
+ &--17 {
88
+ box-shadow: 0 8px 11px -5px var(--site-shadow-key-umbra-opacity), 0 17px 26px 2px var(--site-shadow-key-penumbra-opacity),
89
+ 0 6px 32px 5px var(--site-shadow-key-ambient-opacity);
90
+ }
91
+
92
+ &--18 {
93
+ box-shadow: 0 9px 11px -5px var(--site-shadow-key-umbra-opacity), 0 18px 28px 2px var(--site-shadow-key-penumbra-opacity),
94
+ 0 7px 34px 6px var(--site-shadow-key-ambient-opacity);
95
+ }
96
+
97
+ &--19 {
98
+ box-shadow: 0 9px 12px -6px var(--site-shadow-key-umbra-opacity), 0 19px 29px 2px var(--site-shadow-key-penumbra-opacity),
99
+ 0 7px 36px 6px var(--site-shadow-key-ambient-opacity);
100
+ }
101
+
102
+ &--20 {
103
+ box-shadow: 0 10px 13px -6px var(--site-shadow-key-umbra-opacity), 0 20px 31px 3px var(--site-shadow-key-penumbra-opacity),
104
+ 0 8px 38px 7px var(--site-shadow-key-ambient-opacity);
105
+ }
106
+
107
+ &--21 {
108
+ box-shadow: 0 10px 13px -6px var(--site-shadow-key-umbra-opacity), 0 21px 33px 3px var(--site-shadow-key-penumbra-opacity),
109
+ 0 8px 40px 7px var(--site-shadow-key-ambient-opacity);
110
+ }
111
+
112
+ &--22 {
113
+ box-shadow: 0 10px 14px -6px var(--site-shadow-key-umbra-opacity), 0 22px 35px 3px var(--site-shadow-key-penumbra-opacity),
114
+ 0 8px 42px 7px var(--site-shadow-key-ambient-opacity);
115
+ }
116
+
117
+ &--23 {
118
+ box-shadow: 0 11px 14px -7px var(--site-shadow-key-umbra-opacity), 0 23px 36px 3px var(--site-shadow-key-penumbra-opacity),
119
+ 0 9px 44px 8px var(--site-shadow-key-ambient-opacity);
120
+ }
121
+
122
+ &--24 {
123
+ box-shadow: 0 11px 15px -7px var(--site-shadow-key-umbra-opacity), 0 24px 38px 3px var(--site-shadow-key-penumbra-opacity),
124
+ 0 9px 46px 8px var(--site-shadow-key-ambient-opacity);
125
+ }
126
+ }
@@ -0,0 +1,27 @@
1
+ // 文字
2
+ @site-font-size-xs: 10px;
3
+ @site-font-size-sm: 12px;
4
+ @site-font-size-md: 14px;
5
+ @site-font-size-lg: 16px;
6
+
7
+ // 图标
8
+ @site-icon-size-xs: 16px;
9
+ @site-icon-size-sm: 18px;
10
+ @site-icon-size-md: 20px;
11
+ @site-icon-size-lg: 22px;
12
+
13
+ //颜色
14
+ @site-color-primary: #3a7afe;
15
+ @site-color-info: #00afef;
16
+ @site-color-success: #00c48f;
17
+ @site-color-warning: #ff9f00;
18
+ @site-color-danger: #f44336;
19
+ @site-color-disabled: #e0e0e0;
20
+
21
+ // 动画函数
22
+ @site-cubic-bezier: cubic-bezier(0.25, 0.8, 0.5, 1);
23
+
24
+ // 阴影
25
+ @site-shadow-key-umbra-opacity: rgba(0, 0, 0, 0.2);
26
+ @site-shadow-key-penumbra-opacity: rgba(0, 0, 0, 0.14);
27
+ @site-shadow-key-ambient-opacity: rgba(0, 0, 0, 0.12);
@@ -6,7 +6,7 @@ import { createApp } from 'vue'
6
6
  import { createRouter, createWebHashHistory } from 'vue-router'
7
7
 
8
8
  import Icon from '../components/icon'
9
- import AppBar from '../components/app-bar'
9
+ import AppBar from './components/app-bar'
10
10
  import Button from '../components/button'
11
11
  import Cell from '../components/cell'
12
12
  import Ripple from '../components/ripple'
@@ -386,6 +386,7 @@ iframe {
386
386
  padding: 20px;
387
387
  margin-bottom: 30px;
388
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
+
389
390
  &:first-child{
390
391
  margin-top: 30px;
391
392
  }
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { defineComponent, onMounted, onBeforeUnmount, ref, useAttrs } from 'vue'
2
+ import { defineComponent, onMounted, onBeforeUnmount, onUnmounted, ref, useAttrs } from 'vue'
3
3
  import { animationBoxData, animationEl, animationElClientRect } from '../floating'
4
4
 
5
5
  export default defineComponent({
@@ -15,13 +15,23 @@ export default defineComponent({
15
15
  mutationObserver.value = new MutationObserver(() => {
16
16
  animationElClientRect.value = varletLogoAnimationRef?.value?.getBoundingClientRect();
17
17
  });
18
- mutationObserver.value.observe(document.body, { attributes: true, subtree: true, childList:true });
18
+ const logoContainer = varletLogoAnimationRef.value?.parentNode?.parentNode
19
+ mutationObserver.value.observe(logoContainer || document.body, {
20
+ attributes: true,
21
+ subtree: true,
22
+ childList:true
23
+ });
19
24
  })
20
25
 
21
26
  onBeforeUnmount(() => {
22
27
  mutationObserver.value?.disconnect();
23
28
  })
24
29
 
30
+ onUnmounted(() => {
31
+ animationEl.value = undefined
32
+ animationElClientRect.value = undefined
33
+ })
34
+
25
35
  return {
26
36
  varletLogoAnimationRef,
27
37
  }
@@ -1,11 +1,37 @@
1
1
  <template>
2
2
  <div class="varlet-site-header">
3
- <div class="varlet-site-header__lead" @click="backRoot">
4
- <animation-box class="varlet-site-header__logo" />
5
- <div class="varlet-site-header__title" v-if="title">{{ title }}</div>
3
+ <div class="varlet-site-header__lead">
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
+ <div
10
+ class="varlet-site-header__versions"
11
+ @mouseenter="isOpenVersionsMenu = true"
12
+ @mouseleave="isOpenVersionsMenu = false"
13
+ v-if="versionItems"
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
+
9
35
  <a class="varlet-site-header__link" target="_blank" :href="playground" v-ripple v-if="playground">
10
36
  <var-site-icon name="code-json" :size="24" />
11
37
  </a>
@@ -24,29 +50,30 @@
24
50
  </div>
25
51
  <div
26
52
  class="varlet-site-header__language"
27
- @mouseenter="isOpenMenu = true"
28
- @mouseleave="isOpenMenu = false"
53
+ @mouseenter="isOpenLanguageMenu = true"
54
+ @mouseleave="isOpenLanguageMenu = false"
29
55
  v-if="languages"
30
56
  >
31
57
  <var-site-icon name="translate" size="26px" />
32
58
  <var-site-icon name="chevron-down" />
33
59
  <transition name="fade">
34
60
  <div
35
- class="varlet-site-header__language-list var-site-elevation--5"
36
- v-show="isOpenMenu"
37
- :style="{ pointerEvents: isOpenMenu ? 'auto' : 'none' }"
61
+ class="varlet-site-header__animation-list var-site-elevation--5"
62
+ v-show="isOpenLanguageMenu"
63
+ :style="{ pointerEvents: isOpenLanguageMenu ? 'auto' : 'none' }"
38
64
  >
39
65
  <var-site-cell
40
66
  v-for="(value, key) in nonEmptyLanguages"
41
67
  v-ripple
42
68
  :key="key"
43
- :class="{ 'varlet-site-header__language-list--active': language === key }"
69
+ :class="{ 'varlet-site-header__animation-list--active': language === key }"
44
70
  @click="handleLanguageChange(key)"
45
71
  >{{ value }}
46
72
  </var-site-cell>
47
73
  </div>
48
74
  </transition>
49
75
  </div>
76
+
50
77
  </div>
51
78
  </div>
52
79
  </template>
@@ -66,22 +93,26 @@ export default defineComponent({
66
93
  props: {
67
94
  language: {
68
95
  type: String,
69
- },
96
+ }
70
97
  },
71
98
  setup() {
72
99
  const title: Ref<string> = ref(get(config, 'title'))
73
100
  const logo: Ref<string> = ref(get(config, 'logo'))
74
101
  const themesKey = get(config, 'themesKey')
75
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'))
76
105
  const playground: Ref<string> = ref(get(config, 'pc.header.playground'))
77
106
  const github: Ref<string> = ref(get(config, 'pc.header.github'))
78
107
  const redirect = get(config, 'pc.redirect')
79
108
  const darkMode: Ref<boolean> = ref(get(config, 'pc.header.darkMode'))
80
109
  const currentThemes = ref(getBrowserThemes(themesKey))
81
110
 
82
- const isOpenMenu: Ref<boolean> = ref(false)
111
+ const isOpenLanguageMenu: Ref<boolean> = ref(false)
112
+ const isOpenVersionsMenu: Ref<boolean> = ref(false)
83
113
  const router = useRouter()
84
114
  const nonEmptyLanguages: ComputedRef<Record<string, string>> = computed(() => removeEmpty(languages.value))
115
+ const nonEmptyVersions: ComputedRef<Record<string, string>> = computed(() => removeEmpty(versionItems.value))
85
116
 
86
117
  const backRoot = () => {
87
118
  const { language: lang } = getPCLocationInfo()
@@ -91,7 +122,7 @@ export default defineComponent({
91
122
  const handleLanguageChange = (language: string) => {
92
123
  const { menuName } = getPCLocationInfo()
93
124
  router.replace(`/${language}/${menuName}`)
94
- isOpenMenu.value = false
125
+ isOpenLanguageMenu.value = false
95
126
  }
96
127
 
97
128
  const setCurrentThemes = (themes: 'themes' | 'darkThemes') => {
@@ -108,6 +139,14 @@ export default defineComponent({
108
139
  ;(document.getElementById('mobile') as HTMLIFrameElement).contentWindow!.postMessage(getThemesMessage(), '*')
109
140
  }
110
141
 
142
+ const open = (value: string) => {
143
+ if (value !== currentVersion.value) {
144
+ setTimeout(() => {
145
+ window.location.href = value
146
+ }, 350);
147
+ }
148
+ }
149
+
111
150
  watchThemes((themes, from) => {
112
151
  from === 'mobile' && setCurrentThemes(themes)
113
152
  })
@@ -118,13 +157,18 @@ export default defineComponent({
118
157
  return {
119
158
  logo,
120
159
  title,
160
+ currentVersion,
121
161
  languages,
162
+ versionItems,
122
163
  nonEmptyLanguages,
164
+ nonEmptyVersions,
123
165
  playground,
124
166
  github,
125
- isOpenMenu,
167
+ isOpenLanguageMenu,
168
+ isOpenVersionsMenu,
126
169
  darkMode,
127
170
  currentThemes,
171
+ open,
128
172
  backRoot,
129
173
  handleLanguageChange,
130
174
  toggleTheme,
@@ -198,6 +242,7 @@ export default defineComponent({
198
242
 
199
243
  &__title {
200
244
  font-size: 22px;
245
+ margin-right: 12px;
201
246
  }
202
247
 
203
248
  &__tail {
@@ -226,6 +271,23 @@ export default defineComponent({
226
271
  }
227
272
  }
228
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: 4px;
285
+
286
+ &:hover {
287
+ background: var(--site-config-color-nav-button-hover-background);
288
+ }
289
+ }
290
+
229
291
  &__link {
230
292
  border-radius: 50%;
231
293
  width: 42px;
@@ -264,7 +326,7 @@ export default defineComponent({
264
326
  }
265
327
  }
266
328
 
267
- &__language-list {
329
+ &__animation-list {
268
330
  background: var(--site-config-color-bar);
269
331
  cursor: pointer;
270
332
  color: var(--site-config-color-text);
@@ -287,5 +349,9 @@ export default defineComponent({
287
349
  color: var(--site-config-color-pc-language-active);
288
350
  }
289
351
  }
352
+
353
+ &__animation-versions {
354
+ left: -7px;
355
+ }
290
356
  }
291
357
  </style>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import config from '@config'
3
3
  import { get } from 'lodash-es'
4
- import { computed, defineComponent, onBeforeMount, onMounted, onBeforeUnmount, ref, watch, nextTick } from 'vue'
4
+ import { computed, defineComponent, onMounted, onBeforeUnmount, ref, watch, nextTick } from 'vue'
5
5
  import { animationBoxData, animationEl, animationElClientRect } from '../floating'
6
6
  import type { Ref, StyleValue } from 'vue'
7
7
  import { useRouter } from 'vue-router'
@@ -27,38 +27,33 @@ export default defineComponent({
27
27
  }))
28
28
 
29
29
  const router = useRouter()
30
- router.beforeEach(async () => {
31
- if (!floatingState.value) {
30
+ router.beforeEach(async (to: any, from: any) => {
31
+ if (!floatingState.value && from.path !== '/') {
32
32
  floatingState.value = true
33
33
  }
34
- await nextTick();
35
- })
36
-
37
- onBeforeMount(() => {
38
- floatingState.value = false
39
34
  })
40
35
 
41
36
  onMounted(() => {
42
- window.addEventListener('resize', resetPosition, false);
37
+ window.addEventListener('resize', resetPosition, false)
43
38
  })
44
39
 
45
40
  onBeforeUnmount(() => {
46
41
  resetTimer && clearTimeout(resetTimer)
47
- window.removeEventListener('resize', resetPosition);
42
+ window.removeEventListener('resize', resetPosition)
48
43
  })
49
44
 
50
45
  const land = () => {
51
- floatingState.value = false;
46
+ floatingState.value = false
52
47
  }
53
48
 
54
- let resetTimer: number;
49
+ let resetTimer: number
55
50
 
56
51
  const resetPosition = async () => {
57
52
  if (floatingState.value) {
58
53
  floatingState.value = false
59
- await nextTick();
54
+ await nextTick()
60
55
  }
61
- clearTimeout(resetTimer);
56
+ clearTimeout(resetTimer)
62
57
  const newBRect = animationEl.value?.getBoundingClientRect()
63
58
  if (newBRect) {
64
59
  resetTimer = window.setTimeout(() => {
@@ -73,21 +68,35 @@ export default defineComponent({
73
68
  styles,
74
69
  animationEl,
75
70
  floatingState,
76
- land
71
+ land,
77
72
  }
78
73
  },
79
74
  })
80
75
  </script>
81
76
 
82
77
  <template>
83
- <Teleport :to="animationEl" v-if="animationEl">
84
- <img v-show="!floatingState" v-bind="animationBoxData.attrs" :style="styles" :src="logo" alt="logo"
85
- v-if="logo && animationEl" class="varlet-cli-logo-animation" />
78
+ <Teleport :to="animationEl || 'body'">
79
+ <img
80
+ v-show="!floatingState"
81
+ v-bind="animationBoxData.attrs"
82
+ :style="styles"
83
+ :src="logo"
84
+ alt="logo"
85
+ v-if="logo && animationEl"
86
+ class="varlet-cli-logo-animation"
87
+ :class="{ 'varlet-cli-logo-position': !animationEl }"
88
+ />
86
89
  </Teleport>
87
90
  <div v-show="floatingState">
88
- <img @transitionend="land" v-bind="animationBoxData.attrs" :style="styles" :src="logo" alt="logo"
91
+ <img
92
+ @transitionend="land"
93
+ v-bind="animationBoxData.attrs"
94
+ :style="styles"
95
+ :src="logo"
96
+ alt="logo"
89
97
  v-if="logo && animationEl"
90
- class="varlet-cli-logo-animation varlet-cli-logo-position varlet-cli-logo-transition" />
98
+ class="varlet-cli-logo-animation varlet-cli-logo-position varlet-cli-logo-transition"
99
+ />
91
100
  </div>
92
101
  </template>
93
102
 
@@ -188,6 +188,7 @@
188
188
  height: 90px;
189
189
  flex-shrink: 0;
190
190
  margin-right: 25px;
191
+ z-index: 2;
191
192
  }
192
193
  }
193
194
  }
@@ -29,6 +29,7 @@ module.exports = {
29
29
  'zh-CN': '中文',
30
30
  'en-US': 'English',
31
31
  },
32
+ versions: null,
32
33
  github: 'https://github.com/varletjs/varlet',
33
34
  playground: 'https://varlet-ui-playground.vercel.app',
34
35
  darkMode: true,