@varlet/cli 1.22.0-alpha.3 → 1.22.0-alpha.64
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/README.en-US.md +11 -0
- package/README.md +11 -0
- package/generators/sfc/package.json +3 -3
- package/generators/sfc/varlet.config.js +5 -0
- package/generators/tsx/package.json +3 -3
- package/generators/tsx/varlet.config.js +5 -0
- package/lib/commands/dev.js +14 -3
- package/lib/commands/preview.d.ts +1 -0
- package/lib/commands/preview.js +65 -0
- package/lib/compiler/compileSiteEntry.d.ts +1 -4
- package/lib/compiler/compileSiteEntry.js +10 -20
- package/lib/config/jest.config.js +0 -1
- package/lib/config/vite.config.js +16 -7
- package/lib/index.js +2 -0
- package/lib/shared/constant.d.ts +1 -9
- package/lib/shared/constant.js +2 -10
- package/lib/site/components/app-bar/index.d.ts +3 -0
- package/lib/site/components/app-bar/index.js +12 -0
- package/lib/site/components/app-bar/props.d.ts +21 -0
- package/lib/site/components/app-bar/props.js +28 -0
- package/lib/site/components/button/index.d.ts +3 -0
- package/lib/site/components/button/index.js +12 -0
- package/lib/site/components/button/props.d.ts +62 -0
- package/lib/site/components/button/props.js +69 -0
- package/lib/site/components/cell/index.d.ts +3 -0
- package/lib/site/components/cell/index.js +12 -0
- package/lib/site/components/cell/props.d.ts +27 -0
- package/lib/site/components/cell/props.js +30 -0
- package/lib/site/components/context/index.d.ts +15 -0
- package/lib/site/components/context/index.js +11 -0
- package/lib/site/components/context/lock.d.ts +10 -0
- package/lib/site/components/context/lock.js +94 -0
- package/lib/site/components/context/zIndex.d.ts +4 -0
- package/lib/site/components/context/zIndex.js +19 -0
- package/lib/site/components/icon/index.d.ts +3 -0
- package/lib/site/components/icon/index.js +12 -0
- package/lib/site/components/icon/props.d.ts +23 -0
- package/lib/site/components/icon/props.js +25 -0
- package/lib/site/components/loading/index.d.ts +3 -0
- package/lib/site/components/loading/index.js +12 -0
- package/lib/site/components/loading/props.d.ts +26 -0
- package/lib/site/components/loading/props.js +34 -0
- package/lib/site/components/menu/index.d.ts +3 -0
- package/lib/site/components/menu/index.js +12 -0
- package/lib/site/components/menu/props.d.ts +40 -0
- package/lib/site/components/menu/props.js +43 -0
- package/lib/site/components/progress/index.d.ts +3 -0
- package/lib/site/components/progress/index.js +12 -0
- package/lib/site/components/progress/props.d.ts +43 -0
- package/lib/site/components/progress/props.js +57 -0
- package/lib/site/components/ripple/index.d.ts +8 -0
- package/lib/site/components/ripple/index.js +125 -0
- package/lib/site/components/utils/components.d.ts +53 -0
- package/lib/site/components/utils/components.js +279 -0
- package/lib/site/components/utils/elements.d.ts +30 -0
- package/lib/site/components/utils/elements.js +240 -0
- package/lib/site/components/utils/shared.d.ts +36 -0
- package/lib/site/components/utils/shared.js +181 -0
- package/lib/site/mobile/main.d.ts +3 -0
- package/lib/site/mobile/main.js +93 -0
- package/lib/site/pc/main.d.ts +3 -0
- package/lib/site/pc/main.js +69 -0
- package/lib/site/useProgress.d.ts +4 -0
- package/lib/site/useProgress.js +58 -0
- package/lib/site/utils.d.ts +24 -0
- package/lib/site/utils.js +133 -0
- package/package.json +10 -9
- package/site/.DS_Store +0 -0
- package/site/components/app-bar/AppBar.vue +45 -0
- package/site/components/app-bar/appBar.less +66 -0
- package/site/components/app-bar/index.ts +10 -0
- package/site/components/app-bar/props.ts +25 -0
- package/site/components/button/Button.vue +84 -0
- package/site/components/button/button.less +183 -0
- package/site/components/button/index.ts +10 -0
- package/site/components/button/props.ts +70 -0
- package/site/components/cell/Cell.vue +42 -0
- package/site/components/cell/cell.less +74 -0
- package/site/components/cell/index.ts +10 -0
- package/site/components/cell/props.ts +27 -0
- package/site/components/context/index.ts +17 -0
- package/site/components/context/lock.ts +103 -0
- package/site/components/context/zIndex.ts +20 -0
- package/site/components/icon/Icon.vue +68 -0
- package/site/components/icon/icon.less +25 -0
- package/site/components/icon/index.ts +10 -0
- package/site/components/icon/props.ts +24 -0
- package/site/components/loading/Loading.vue +55 -0
- package/site/components/loading/index.ts +10 -0
- package/site/components/loading/loading.less +420 -0
- package/site/components/loading/props.ts +37 -0
- package/site/components/menu/Menu.vue +113 -0
- package/site/components/menu/index.ts +10 -0
- package/site/components/menu/menu.less +27 -0
- package/site/components/menu/props.ts +43 -0
- package/site/components/progress/Progress.vue +108 -0
- package/site/components/progress/index.ts +10 -0
- package/site/components/progress/progress.less +98 -0
- package/site/components/progress/props.ts +55 -0
- package/site/components/ripple/index.ts +167 -0
- package/site/components/ripple/ripple.less +17 -0
- package/site/components/styles/common.less +64 -0
- package/site/components/styles/elevation.less +126 -0
- package/site/components/styles/var.less +27 -0
- package/site/components/utils/components.ts +53 -0
- package/site/components/utils/elements.ts +83 -0
- package/site/components/utils/shared.ts +27 -0
- package/site/mobile/App.vue +21 -17
- package/site/mobile/components/AppHome.vue +6 -6
- package/site/mobile/main.ts +15 -8
- package/site/pc/App.vue +16 -11
- package/site/pc/components/AppHeader.vue +15 -11
- package/site/pc/components/AppMobile.vue +3 -3
- package/site/pc/components/AppSidebar.vue +17 -21
- package/site/pc/main.ts +8 -5
- package/site/useProgress.ts +11 -9
- package/site/utils.ts +14 -3
- package/varlet.default.config.js +3 -2
- package/generators/sfc/yarn.lock +0 -11231
- package/generators/tsx/yarn.lock +0 -11231
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
@site-button-default-color: #f5f5f5;
|
|
2
|
+
@site-button-primary-color: var(--site-color-primary);
|
|
3
|
+
@site-button-danger-color: var(--site-color-danger);
|
|
4
|
+
@site-button-success-color: var(--site-color-success);
|
|
5
|
+
@site-button-warning-color: var(--site-color-warning);
|
|
6
|
+
@site-button-info-color: var(--site-color-info);
|
|
7
|
+
@site-button-disabled-color: var(--site-color-disabled);
|
|
8
|
+
@site-button-disabled-text-color: #bdbdbd;
|
|
9
|
+
@site-button-border-radius: 4px;
|
|
10
|
+
@site-button-mini-padding: 0 9px;
|
|
11
|
+
@site-button-small-padding: 0 11px;
|
|
12
|
+
@site-button-normal-padding: 0 15px;
|
|
13
|
+
@site-button-large-padding: 0 22px;
|
|
14
|
+
@site-button-round-padding: 6px;
|
|
15
|
+
@site-button-mini-height: 20px;
|
|
16
|
+
@site-button-small-height: 28px;
|
|
17
|
+
@site-button-normal-height: 36px;
|
|
18
|
+
@site-button-large-height: 44px;
|
|
19
|
+
|
|
20
|
+
:root {
|
|
21
|
+
--site-button-default-color: @site-button-default-color;
|
|
22
|
+
--site-button-primary-color: @site-button-primary-color;
|
|
23
|
+
--site-button-danger-color: @site-button-danger-color;
|
|
24
|
+
--site-button-success-color: @site-button-success-color;
|
|
25
|
+
--site-button-warning-color: @site-button-warning-color;
|
|
26
|
+
--site-button-info-color: @site-button-info-color;
|
|
27
|
+
--site-button-disabled-color: @site-button-disabled-color;
|
|
28
|
+
--site-button-disabled-text-color: @site-button-disabled-text-color;
|
|
29
|
+
--site-button-border-radius: @site-button-border-radius;
|
|
30
|
+
--site-button-mini-padding: @site-button-mini-padding;
|
|
31
|
+
--site-button-small-padding: @site-button-small-padding;
|
|
32
|
+
--site-button-normal-padding: @site-button-normal-padding;
|
|
33
|
+
--site-button-large-padding: @site-button-large-padding;
|
|
34
|
+
--site-button-round-padding: @site-button-round-padding;
|
|
35
|
+
--site-button-mini-height: @site-button-mini-height;
|
|
36
|
+
--site-button-small-height: @site-button-small-height;
|
|
37
|
+
--site-button-normal-height: @site-button-normal-height;
|
|
38
|
+
--site-button-large-height: @site-button-large-height;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.var-site-button {
|
|
42
|
+
position: relative;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
align-items: center;
|
|
45
|
+
outline: none;
|
|
46
|
+
border: none;
|
|
47
|
+
line-height: 1.2;
|
|
48
|
+
border-radius: var(--site-button-border-radius);
|
|
49
|
+
user-select: none;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
font-family: inherit;
|
|
52
|
+
transition: box-shadow 0.2s;
|
|
53
|
+
will-change: box-shadow;
|
|
54
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
|
|
57
|
+
&:active {
|
|
58
|
+
box-shadow: 0 3px 5px -1px var(--site-shadow-key-umbra-opacity), 0 5px 8px 0 var(--site-shadow-key-penumbra-opacity),
|
|
59
|
+
0 1px 14px 0 var(--site-shadow-key-ambient-opacity);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&__loading {
|
|
63
|
+
position: absolute;
|
|
64
|
+
top: 50%;
|
|
65
|
+
left: 50%;
|
|
66
|
+
transform: translate(-50%, -50%);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&--default {
|
|
70
|
+
color: inherit;
|
|
71
|
+
background-color: var(--site-button-default-color);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&--primary {
|
|
75
|
+
color: #fff;
|
|
76
|
+
background-color: var(--site-button-primary-color);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&--info {
|
|
80
|
+
color: #fff;
|
|
81
|
+
background-color: var(--site-button-info-color);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&--success {
|
|
85
|
+
color: #fff;
|
|
86
|
+
background-color: var(--site-button-success-color);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&--warning {
|
|
90
|
+
color: #fff;
|
|
91
|
+
background-color: var(--site-button-warning-color);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&--danger {
|
|
95
|
+
color: #fff;
|
|
96
|
+
background-color: var(--site-button-danger-color);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&--disabled {
|
|
100
|
+
background-color: var(--site-button-disabled-color);
|
|
101
|
+
color: var(--site-button-disabled-text-color);
|
|
102
|
+
cursor: not-allowed;
|
|
103
|
+
box-shadow: none !important;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&--block {
|
|
107
|
+
width: 100%;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&--text {
|
|
111
|
+
background-color: transparent;
|
|
112
|
+
|
|
113
|
+
&:active {
|
|
114
|
+
box-shadow: none;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&--text-default {
|
|
119
|
+
color: inherit;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&--text-primary {
|
|
123
|
+
color: var(--site-button-primary-color);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&--text-info {
|
|
127
|
+
color: var(--site-button-info-color);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&--text-success {
|
|
131
|
+
color: var(--site-button-success-color);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&--text-warning {
|
|
135
|
+
color: var(--site-button-warning-color);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&--text-danger {
|
|
139
|
+
color: var(--site-button-danger-color);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&--text-disabled {
|
|
143
|
+
color: var(--site-button-disabled-text-color);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&--normal {
|
|
147
|
+
height: var(--site-button-normal-height);
|
|
148
|
+
padding: var(--site-button-normal-padding);
|
|
149
|
+
font-size: var(--site-font-size-md);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&--large {
|
|
153
|
+
height: var(--site-button-large-height);
|
|
154
|
+
padding: var(--site-button-large-padding);
|
|
155
|
+
font-size: var(--site-font-size-lg);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&--small {
|
|
159
|
+
height: var(--site-button-small-height);
|
|
160
|
+
padding: var(--site-button-small-padding);
|
|
161
|
+
font-size: var(--site-font-size-sm);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&--mini {
|
|
165
|
+
height: var(--site-button-mini-height);
|
|
166
|
+
padding: var(--site-button-mini-padding);
|
|
167
|
+
font-size: var(--site-font-size-xs);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&--round {
|
|
171
|
+
padding: var(--site-button-round-padding);
|
|
172
|
+
border-radius: 50%;
|
|
173
|
+
height: auto;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&--outline {
|
|
177
|
+
border: thin solid currentColor;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&--hidden {
|
|
181
|
+
opacity: 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { props as loadingProps } from '../loading/props'
|
|
2
|
+
import { pickProps } from '../utils/components'
|
|
3
|
+
import type { PropType } from 'vue'
|
|
4
|
+
|
|
5
|
+
function typeValidator(type: string): boolean {
|
|
6
|
+
return ['default', 'primary', 'info', 'success', 'warning', 'danger'].includes(type)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function sizeValidator(size: string): boolean {
|
|
10
|
+
return ['normal', 'mini', 'small', 'large'].includes(size)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const props = {
|
|
14
|
+
type: {
|
|
15
|
+
type: String as PropType<'default' | 'primary' | 'info' | 'success' | 'warning' | 'danger'>,
|
|
16
|
+
default: 'default',
|
|
17
|
+
validator: typeValidator,
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
type: String as PropType<'normal' | 'mini' | 'small' | 'large'>,
|
|
21
|
+
default: 'normal',
|
|
22
|
+
validator: sizeValidator,
|
|
23
|
+
},
|
|
24
|
+
loading: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
round: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false,
|
|
31
|
+
},
|
|
32
|
+
block: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false,
|
|
35
|
+
},
|
|
36
|
+
text: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
outline: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false,
|
|
43
|
+
},
|
|
44
|
+
disabled: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
ripple: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true,
|
|
51
|
+
},
|
|
52
|
+
color: {
|
|
53
|
+
type: String,
|
|
54
|
+
},
|
|
55
|
+
textColor: {
|
|
56
|
+
type: String,
|
|
57
|
+
},
|
|
58
|
+
loadingRadius: {
|
|
59
|
+
type: [Number, String],
|
|
60
|
+
default: 12,
|
|
61
|
+
},
|
|
62
|
+
loadingType: pickProps(loadingProps, 'type'),
|
|
63
|
+
loadingSize: pickProps(loadingProps, 'size'),
|
|
64
|
+
onClick: {
|
|
65
|
+
type: Function as PropType<(e: Event) => void>,
|
|
66
|
+
},
|
|
67
|
+
onTouchstart: {
|
|
68
|
+
type: Function as PropType<(e: Event) => void>,
|
|
69
|
+
},
|
|
70
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="var-site-cell" :class="[border ? 'var-site-cell--border' : null]">
|
|
3
|
+
<div class="var-site-cell__icon" :class="[iconClass ? iconClass : null]" v-if="$slots.icon || icon">
|
|
4
|
+
<slot name="icon">
|
|
5
|
+
<var-site-icon class="var-site--flex" :name="icon" />
|
|
6
|
+
</slot>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="var-site-cell__content">
|
|
9
|
+
<div class="var-site-cell__title" :class="[titleClass ? titleClass : null]">
|
|
10
|
+
<slot>{{ title }}</slot>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="var-site-cell__desc" :class="[descClass ? descClass : null]" v-if="$slots.desc || desc">
|
|
13
|
+
<slot name="desc">
|
|
14
|
+
{{ desc }}
|
|
15
|
+
</slot>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="var-site-cell__extra" :class="[extraClass ? extraClass : null]" v-if="$slots.extra">
|
|
19
|
+
<slot name="extra" />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import { defineComponent } from 'vue'
|
|
26
|
+
import { props } from './props'
|
|
27
|
+
import Icon from '../icon'
|
|
28
|
+
|
|
29
|
+
export default defineComponent({
|
|
30
|
+
name: 'VarSiteCell',
|
|
31
|
+
components: {
|
|
32
|
+
[Icon.name]: Icon,
|
|
33
|
+
},
|
|
34
|
+
props,
|
|
35
|
+
})
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style lang="less">
|
|
39
|
+
@import '../styles/common';
|
|
40
|
+
@import '../icon/icon';
|
|
41
|
+
@import './cell';
|
|
42
|
+
</style>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
@site-cell-font-size: var(--site-font-size-md);
|
|
2
|
+
@site-cell-desc-font-size: var(--site-font-size-sm);
|
|
3
|
+
@site-cell-desc-color: rgba(0, 0, 0, 0.6);
|
|
4
|
+
@site-cell-padding: 10px 12px;
|
|
5
|
+
@site-cell-min-height: 40px;
|
|
6
|
+
@site-cell-border-color: #bcc2cb;
|
|
7
|
+
@site-cell-border-left: 12px;
|
|
8
|
+
@site-cell-border-right: 12px;
|
|
9
|
+
@site-cell-icon-right: 8px;
|
|
10
|
+
@site-cell-extra-left: 8px;
|
|
11
|
+
|
|
12
|
+
:root {
|
|
13
|
+
--site-cell-font-size: @site-cell-font-size;
|
|
14
|
+
--site-cell-desc-font-size: @site-cell-desc-font-size;
|
|
15
|
+
--site-cell-desc-color: @site-cell-desc-color;
|
|
16
|
+
--site-cell-padding: @site-cell-padding;
|
|
17
|
+
--site-cell-min-height: @site-cell-min-height;
|
|
18
|
+
--site-cell-border-color: @site-cell-border-color;
|
|
19
|
+
--site-cell-border-left: @site-cell-border-left;
|
|
20
|
+
--site-cell-border-right: @site-cell-border-right;
|
|
21
|
+
--site-cell-icon-right: @site-cell-icon-right;
|
|
22
|
+
--site-cell-extra-left: @site-cell-extra-left;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.var-site-cell {
|
|
26
|
+
align-items: center;
|
|
27
|
+
display: flex;
|
|
28
|
+
min-height: var(--site-cell-min-height);
|
|
29
|
+
outline: none;
|
|
30
|
+
padding: var(--site-cell-padding);
|
|
31
|
+
position: relative;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
font-size: var(--site-cell-font-size);
|
|
34
|
+
|
|
35
|
+
&--border {
|
|
36
|
+
&::after {
|
|
37
|
+
position: absolute;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
content: ' ';
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
right: var(--site-cell-border-right);
|
|
42
|
+
bottom: 0;
|
|
43
|
+
left: var(--site-cell-border-left);
|
|
44
|
+
border-bottom: 1px solid var(--site-cell-border-color);
|
|
45
|
+
transform: scaleY(0.5);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&__icon {
|
|
50
|
+
margin-right: var(--site-cell-icon-right);
|
|
51
|
+
flex: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__content {
|
|
55
|
+
flex: 1;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&__title {
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
text-overflow: ellipsis;
|
|
62
|
+
white-space: nowrap;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&__desc {
|
|
66
|
+
font-size: var(--site-cell-desc-font-size);
|
|
67
|
+
color: var(--site-cell-desc-color);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&__extra {
|
|
71
|
+
flex: 0;
|
|
72
|
+
margin-left: var(--site-cell-extra-left);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const props = {
|
|
2
|
+
title: {
|
|
3
|
+
type: [Number, String],
|
|
4
|
+
},
|
|
5
|
+
icon: {
|
|
6
|
+
type: String,
|
|
7
|
+
},
|
|
8
|
+
desc: {
|
|
9
|
+
type: String,
|
|
10
|
+
},
|
|
11
|
+
border: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false,
|
|
14
|
+
},
|
|
15
|
+
iconClass: {
|
|
16
|
+
type: String,
|
|
17
|
+
},
|
|
18
|
+
titleClass: {
|
|
19
|
+
type: String,
|
|
20
|
+
},
|
|
21
|
+
descClass: {
|
|
22
|
+
type: String,
|
|
23
|
+
},
|
|
24
|
+
extraClass: {
|
|
25
|
+
type: String,
|
|
26
|
+
},
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { reactive } from 'vue'
|
|
2
|
+
|
|
3
|
+
interface Context {
|
|
4
|
+
locks: Record<any, number>
|
|
5
|
+
zIndex: number
|
|
6
|
+
touchmoveForbid: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const context: Context = {
|
|
10
|
+
locks: {},
|
|
11
|
+
zIndex: 2000,
|
|
12
|
+
touchmoveForbid: true,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const _ContextComponent = reactive<Context>(context)
|
|
16
|
+
|
|
17
|
+
export default reactive<Context>(context)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { watch, onBeforeMount, onUnmounted, onDeactivated, onActivated, getCurrentInstance } from 'vue'
|
|
2
|
+
import type { ComponentInternalInstance } from 'vue'
|
|
3
|
+
import context from '.'
|
|
4
|
+
|
|
5
|
+
export function resolveLock() {
|
|
6
|
+
const lockCounts: number = Object.keys(context.locks).length
|
|
7
|
+
lockCounts <= 0 ? document.body.classList.remove('var-site--lock') : document.body.classList.add('var-site--lock')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function addLock(uid: number) {
|
|
11
|
+
context.locks[uid] = 1
|
|
12
|
+
resolveLock()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function releaseLock(uid: number) {
|
|
16
|
+
delete context.locks[uid]
|
|
17
|
+
resolveLock()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 组件锁操作
|
|
22
|
+
* @param props 组件props
|
|
23
|
+
* @param state 组件props中控制组件加锁的开关对应的key值
|
|
24
|
+
* @param use 组件props中控制组件加锁的开关是否可用对应的key值
|
|
25
|
+
*/
|
|
26
|
+
export function useLock(props: any, state: string, use?: string) {
|
|
27
|
+
const { uid } = getCurrentInstance() as ComponentInternalInstance
|
|
28
|
+
if (use) {
|
|
29
|
+
watch(
|
|
30
|
+
() => props[use],
|
|
31
|
+
(newValue: boolean) => {
|
|
32
|
+
if (newValue === false) {
|
|
33
|
+
// 改变为禁用状态 组件解锁
|
|
34
|
+
releaseLock(uid)
|
|
35
|
+
} else if (newValue === true && props[state] === true) {
|
|
36
|
+
// 改变为启用状态 并且popup处于开启状态 组件加锁
|
|
37
|
+
addLock(uid)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
watch(
|
|
44
|
+
() => props[state],
|
|
45
|
+
(newValue: boolean) => {
|
|
46
|
+
if (use && props[use] === false) {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (newValue === true) {
|
|
51
|
+
// popup开启 组件加锁
|
|
52
|
+
addLock(uid)
|
|
53
|
+
} else {
|
|
54
|
+
// popup关闭 组件解锁
|
|
55
|
+
releaseLock(uid)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
onBeforeMount(() => {
|
|
61
|
+
if (use && props[use] === false) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (props[state] === true) {
|
|
66
|
+
// popup处于开启状态 组件挂载 组件加锁
|
|
67
|
+
addLock(uid)
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
onUnmounted(() => {
|
|
72
|
+
if (use && props[use] === false) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (props[state] === true) {
|
|
77
|
+
// popup处于开启状态 组件卸载 组件解锁
|
|
78
|
+
releaseLock(uid)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
onActivated(() => {
|
|
83
|
+
if (use && props[use] === false) {
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (props[state] === true) {
|
|
88
|
+
// popup处于开启状态 组件处于keepalive前台 组件加锁
|
|
89
|
+
addLock(uid)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
onDeactivated(() => {
|
|
94
|
+
if (use && props[use] === false) {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (props[state] === true) {
|
|
99
|
+
// popup处于开启状态 组件处于keepalive后台 组件解锁
|
|
100
|
+
releaseLock(uid)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import context from './index'
|
|
2
|
+
import { watch, ref } from 'vue'
|
|
3
|
+
import type { Ref } from 'vue'
|
|
4
|
+
|
|
5
|
+
export function useZIndex(source: any, count: number) {
|
|
6
|
+
const zIndex: Ref<number> = ref(context.zIndex)
|
|
7
|
+
|
|
8
|
+
watch(
|
|
9
|
+
source,
|
|
10
|
+
(newValue) => {
|
|
11
|
+
if (newValue) {
|
|
12
|
+
context.zIndex += count
|
|
13
|
+
zIndex.value = context.zIndex
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{ immediate: true }
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
return { zIndex }
|
|
20
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
class="var-site-icon"
|
|
4
|
+
:is="isURL(name) ? 'img' : 'i'"
|
|
5
|
+
:class="[
|
|
6
|
+
`${namespace}--set`,
|
|
7
|
+
isURL(name) ? 'var-site-icon__image' : `${namespace}-${nextName}`,
|
|
8
|
+
shrinking ? 'var-site-icon--shrinking' : null,
|
|
9
|
+
]"
|
|
10
|
+
:style="{
|
|
11
|
+
color,
|
|
12
|
+
transition: `all ${toNumber(transition)}ms`,
|
|
13
|
+
width: isURL(name) ? toSizeUnit(size) : null,
|
|
14
|
+
height: isURL(name) ? toSizeUnit(size) : null,
|
|
15
|
+
fontSize: toSizeUnit(size),
|
|
16
|
+
}"
|
|
17
|
+
:src="isURL(name) ? nextName : null"
|
|
18
|
+
@click="onClick"
|
|
19
|
+
/>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { defineComponent, watch, ref, nextTick } from 'vue'
|
|
24
|
+
import { isURL, toNumber } from '../utils/shared'
|
|
25
|
+
import { toSizeUnit } from '../utils/elements'
|
|
26
|
+
import { props } from './props'
|
|
27
|
+
import type { Ref } from 'vue'
|
|
28
|
+
|
|
29
|
+
export default defineComponent({
|
|
30
|
+
name: 'VarSiteIcon',
|
|
31
|
+
props,
|
|
32
|
+
setup(props) {
|
|
33
|
+
const nextName: Ref<string | undefined> = ref('')
|
|
34
|
+
const shrinking: Ref<boolean> = ref(false)
|
|
35
|
+
|
|
36
|
+
const handleNameChange = async (newName: string | undefined, oldName: string | undefined) => {
|
|
37
|
+
const { transition } = props
|
|
38
|
+
|
|
39
|
+
if (oldName == null || toNumber(transition) === 0) {
|
|
40
|
+
nextName.value = newName
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
shrinking.value = true
|
|
45
|
+
await nextTick()
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
oldName != null && (nextName.value = newName)
|
|
48
|
+
shrinking.value = false
|
|
49
|
+
}, toNumber(transition))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
watch(() => props.name, handleNameChange, { immediate: true })
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
nextName,
|
|
56
|
+
shrinking,
|
|
57
|
+
isURL,
|
|
58
|
+
toNumber,
|
|
59
|
+
toSizeUnit,
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<style lang="less">
|
|
66
|
+
@import '../styles/common';
|
|
67
|
+
@import './icon';
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@import '@varlet/icons/dist/css/varlet-icons.less';
|
|
2
|
+
|
|
3
|
+
@site-icon-size: 20px;
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--site-icon-size: @site-icon-size;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.var-site-icon {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
font-size: var(--site-icon-size);
|
|
14
|
+
color: inherit;
|
|
15
|
+
|
|
16
|
+
&--shrinking {
|
|
17
|
+
transform: scale(0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__image {
|
|
21
|
+
width: var(--site-icon-size);
|
|
22
|
+
height: var(--site-icon-size);
|
|
23
|
+
object-fit: cover;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
export const props = {
|
|
4
|
+
name: {
|
|
5
|
+
type: String,
|
|
6
|
+
},
|
|
7
|
+
size: {
|
|
8
|
+
type: [Number, String],
|
|
9
|
+
},
|
|
10
|
+
color: {
|
|
11
|
+
type: String,
|
|
12
|
+
},
|
|
13
|
+
namespace: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: 'var-icon',
|
|
16
|
+
},
|
|
17
|
+
transition: {
|
|
18
|
+
type: [Number, String],
|
|
19
|
+
default: 0,
|
|
20
|
+
},
|
|
21
|
+
onClick: {
|
|
22
|
+
type: Function as PropType<(event: Event) => void>,
|
|
23
|
+
},
|
|
24
|
+
}
|