@zfqh/uview-x 0.0.0-stage → 0.0.1

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -3
  4. package/components/uv-badge/props.ts +83 -0
  5. package/components/uv-badge/uv-badge.vue +186 -0
  6. package/components/uv-button/props.ts +148 -0
  7. package/components/uv-button/uv-button.vue +565 -0
  8. package/components/uv-checkbox/props.ts +83 -0
  9. package/components/uv-checkbox/uv-checkbox.vue +403 -0
  10. package/components/uv-checkbox-group/props.ts +97 -0
  11. package/components/uv-checkbox-group/uv-checkbox-group.vue +163 -0
  12. package/components/uv-code/props.ts +48 -0
  13. package/components/uv-code/uv-code.vue +156 -0
  14. package/components/uv-dialog/props.ts +56 -0
  15. package/components/uv-dialog/uv-dialog.vue +492 -0
  16. package/components/uv-form/props.ts +59 -0
  17. package/components/uv-form/uv-form.vue +256 -0
  18. package/components/uv-form/valid.ts +1344 -0
  19. package/components/uv-form-item/props.ts +62 -0
  20. package/components/uv-form-item/uv-form-item.vue +335 -0
  21. package/components/uv-icon/icons.ts +161 -0
  22. package/components/uv-icon/props.ts +91 -0
  23. package/components/uv-icon/uv-icon.vue +204 -0
  24. package/components/uv-icon/uvicons.ttf +0 -0
  25. package/components/uv-input/props.ts +185 -0
  26. package/components/uv-input/uv-input.vue +431 -0
  27. package/components/uv-line/props.ts +42 -0
  28. package/components/uv-line/uv-line.vue +75 -0
  29. package/components/uv-line-progress/props.ts +43 -0
  30. package/components/uv-line-progress/uv-line-progress.vue +166 -0
  31. package/components/uv-loading-icon/props.ts +78 -0
  32. package/components/uv-loading-icon/uv-loading-icon.vue +226 -0
  33. package/components/uv-overlay/props.ts +38 -0
  34. package/components/uv-overlay/uv-overlay.vue +120 -0
  35. package/components/uv-popup/props.ts +101 -0
  36. package/components/uv-popup/uv-popup.vue +371 -0
  37. package/components/uv-safe-bottom/props.ts +18 -0
  38. package/components/uv-safe-bottom/uv-safe-bottom.vue +120 -0
  39. package/components/uv-status-bar/props.ts +22 -0
  40. package/components/uv-status-bar/uv-status-bar.vue +121 -0
  41. package/components/uv-tabs/props.ts +84 -0
  42. package/components/uv-tabs/uv-tabs.vue +432 -0
  43. package/components/uv-transition/props.ts +38 -0
  44. package/components/uv-transition/uv-transition.vue +170 -0
  45. package/hooks/index.ts +5 -0
  46. package/hooks/useDebounce.ts +35 -0
  47. package/hooks/useI18n.ts +95 -0
  48. package/hooks/useThrottle.ts +38 -0
  49. package/index.ts +23 -0
  50. package/libs/dayjs/index.ts +217 -0
  51. package/libs/index.ts +4 -0
  52. package/libs/luch-request/adapters/index.ts +133 -0
  53. package/libs/luch-request/core/InterceptorManager.ts +52 -0
  54. package/libs/luch-request/core/Request.ts +202 -0
  55. package/libs/luch-request/core/buildFullPath.ts +21 -0
  56. package/libs/luch-request/core/defaults.ts +34 -0
  57. package/libs/luch-request/core/dispatchRequest.ts +7 -0
  58. package/libs/luch-request/core/mergeConfig.ts +127 -0
  59. package/libs/luch-request/core/settle.ts +17 -0
  60. package/libs/luch-request/helpers/buildURL.ts +65 -0
  61. package/libs/luch-request/helpers/combineURLs.ts +15 -0
  62. package/libs/luch-request/helpers/isAbsoluteURL.ts +15 -0
  63. package/libs/luch-request/index.d.ts +197 -0
  64. package/libs/luch-request/index.ts +3 -0
  65. package/libs/luch-request/utils/clone.ts +265 -0
  66. package/libs/luch-request/utils.ts +136 -0
  67. package/locales/en.ts +78 -0
  68. package/locales/index.ts +169 -0
  69. package/locales/zh-Hans.ts +78 -0
  70. package/package.json +42 -4
  71. package/styles/color.scss +33 -0
  72. package/styles/common.scss +134 -0
  73. package/styles/components.scss +19 -0
  74. package/styles/index.scss +7 -0
  75. package/styles/theme.scss +44 -0
  76. package/styles/var.module.scss +32 -0
  77. package/styles/vue.scss +39 -0
  78. package/theme.scss +2 -0
  79. package/types/index.d.ts +66 -0
  80. package/utils/colorGradient.ts +139 -0
  81. package/utils/compat.ts +165 -0
  82. package/utils/compress.ts +34 -0
  83. package/utils/config.ts +95 -0
  84. package/utils/debounce.ts +7 -0
  85. package/utils/digit.ts +157 -0
  86. package/utils/function.ts +771 -0
  87. package/utils/http.ts +5 -0
  88. package/utils/index.ts +57 -0
  89. package/utils/locale.ts +296 -0
  90. package/utils/platform.ts +71 -0
  91. package/utils/route.ts +142 -0
  92. package/utils/test.ts +256 -0
  93. package/utils/throttle.ts +7 -0
@@ -0,0 +1,166 @@
1
+ <template>
2
+ <view
3
+ class="uv-line-progress"
4
+ :class="[p.customClass]"
5
+ :style="[$uv.addStyle(p.customStyle)]"
6
+ >
7
+ <view
8
+ ref="barRef"
9
+ class="uv-line-progress__background"
10
+ :style="[backgroundStyle]"
11
+ >
12
+ </view>
13
+ <view
14
+ class="uv-line-progress__line"
15
+ :style="[progressStyle]"
16
+ >
17
+ <slot>
18
+ <text
19
+ v-if="p.showText && innserPercentage >= 10"
20
+ class="uv-line-progress__text"
21
+ >{{ percentageText }}</text>
22
+ </slot>
23
+ </view>
24
+ </view>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { computed, onMounted, ref, watch } from 'vue'
29
+ import { $uv } from '../../utils'
30
+ import props from './props'
31
+ import { getRectNvue } from '../../utils/compat'
32
+
33
+ defineOptions({
34
+ name: 'uv-line-progress',
35
+ // #ifdef UNI-APP-X
36
+ styleIsolation: 'app-and-page',
37
+ // #endif
38
+ virtualHost: true,
39
+ })
40
+
41
+ /**
42
+ * lineProgress 线型进度条
43
+ * @description 展示操作或任务的当前进度,比如上传文件,是一个线形的进度条。
44
+ * @tutorial https://www.uvui.cn/components/lineProgress.html
45
+ * @property {String} activeColor 激活部分的颜色 ( 默认 '#19be6b' )
46
+ * @property {String} inactiveColor 背景色 ( 默认 '#ececec' )
47
+ * @property {String | Number} percentage 进度百分比,数值 ( 默认 0 )
48
+ * @property {Boolean} showText 是否在进度条内部显示百分比的值 ( 默认 true )
49
+ * @property {String | Number} height 进度条的高度,单位px ( 默认 12 )
50
+ * @property {Object} customStyle 定义需要用到的外部样式
51
+ * @example <uv-line-progress :percentage="70" :show-text="true"></uv-line-progress>
52
+ */
53
+ const p = defineProps(props)
54
+
55
+ // 控制范围在0-100之间
56
+ const innserPercentage = computed(() => {
57
+ return $uv.range(0, 100, p.percentage)
58
+ })
59
+
60
+ const percentageText = computed(() => `${innserPercentage.value}%`)
61
+
62
+ const barRef = ref<any>(null)
63
+ const nvueBarWidth = ref(0)
64
+
65
+ const resize = () => {
66
+ getRectNvue(barRef.value).then((size: any) => {
67
+ if (size && size.width > 0) {
68
+ nvueBarWidth.value = size.width
69
+ }
70
+ })
71
+ }
72
+
73
+ onMounted(() => {
74
+ resize()
75
+ })
76
+
77
+ watch(
78
+ () => innserPercentage.value,
79
+ () => resize()
80
+ )
81
+
82
+ const backgroundStyle = computed(() => {
83
+ const style: any = {
84
+ backgroundColor: p.inactiveColor,
85
+ height: $uv.addUnit($uv.getPx(p.height))
86
+ }
87
+ return style
88
+ })
89
+
90
+ // nvue 不支持百分比宽高:先测量父宽再写 px;其余目标继续用百分比。
91
+ const progressStyle = computed(() => {
92
+ const style: any = {
93
+ backgroundColor: p.activeColor,
94
+ height: $uv.addUnit($uv.getPx(p.height))
95
+ }
96
+ // #ifdef APP-NVUE
97
+ style.width = nvueBarWidth.value > 0 ? `${(nvueBarWidth.value * innserPercentage.value) / 100}px` : '0px'
98
+ // #endif
99
+ // #ifndef APP-NVUE
100
+ style.width = `${innserPercentage.value}%`
101
+ // #endif
102
+ return style
103
+ })
104
+
105
+ defineExpose({
106
+ resize
107
+ })
108
+ </script>
109
+
110
+ <style lang="scss">
111
+ @import '../../styles/components.scss';
112
+
113
+ .uv-line-progress {
114
+ /* #ifndef APP-NVUE */
115
+ display: flex;
116
+ /* #endif */
117
+ flex-direction: row;
118
+ align-items: stretch;
119
+ position: relative;
120
+ flex: 1;
121
+ overflow: hidden;
122
+ border-top-left-radius: 100px;
123
+ border-top-right-radius: 100px;
124
+ border-bottom-left-radius: 100px;
125
+ border-bottom-right-radius: 100px;
126
+ }
127
+
128
+ .uv-line-progress__background {
129
+ background-color: #ececec;
130
+ border-top-left-radius: 100px;
131
+ border-top-right-radius: 100px;
132
+ border-bottom-left-radius: 100px;
133
+ border-bottom-right-radius: 100px;
134
+ flex: 1;
135
+ }
136
+
137
+ .uv-line-progress__line {
138
+ position: absolute;
139
+ top: 0;
140
+ left: 0;
141
+ bottom: 0;
142
+ /* #ifndef APP-NVUE */
143
+ display: flex;
144
+ transition-property: width;
145
+ transition-duration: 0.5s;
146
+ transition-timing-function: ease;
147
+ /* #endif */
148
+ flex-direction: row;
149
+ align-items: center;
150
+ color: #ffffff;
151
+ border-top-left-radius: 100px;
152
+ border-top-right-radius: 100px;
153
+ border-bottom-left-radius: 100px;
154
+ border-bottom-right-radius: 100px;
155
+ justify-content: flex-end;
156
+ }
157
+
158
+ .uv-line-progress__text {
159
+ font-size: 10px;
160
+ align-items: center;
161
+ text-align: right;
162
+ color: #ffffff;
163
+ margin-right: 5px;
164
+ transform: scale(0.9);
165
+ }
166
+ </style>
@@ -0,0 +1,78 @@
1
+ // @ts-nocheck
2
+
3
+ import config from '../../utils/config';
4
+
5
+ const props = {
6
+ // 是否显示组件
7
+ show: {
8
+ type: Boolean,
9
+ default: true,
10
+ },
11
+ // 颜色
12
+ color: {
13
+ type: String,
14
+ default: '#909193',
15
+ },
16
+ // 提示文字颜色
17
+ textColor: {
18
+ type: String,
19
+ default: '#909193',
20
+ },
21
+ // 文字和图标是否垂直排列
22
+ vertical: {
23
+ type: Boolean,
24
+ default: false,
25
+ },
26
+ // 模式选择,circle-圆形,spinner-花朵形,semicircle-半圆形
27
+ mode: {
28
+ type: String,
29
+ default: 'spinner',
30
+ },
31
+ // 图标大小,单位默认px
32
+ size: {
33
+ type: [String, Number],
34
+ default: 24,
35
+ },
36
+ // 文字大小
37
+ textSize: {
38
+ type: [String, Number],
39
+ default: 15,
40
+ },
41
+ // 文字样式
42
+ textStyle: {
43
+ type: Object,
44
+ default: () => ({}),
45
+ },
46
+ // 文字内容
47
+ text: {
48
+ type: [String, Number],
49
+ default: '',
50
+ },
51
+ // 动画模式
52
+ timingFunction: {
53
+ type: String,
54
+ default: 'linear',
55
+ },
56
+ // 动画执行周期时间
57
+ duration: {
58
+ type: [String, Number],
59
+ default: 1200,
60
+ },
61
+ // mode=circle时的暗边颜色
62
+ inactiveColor: {
63
+ type: String,
64
+ default: '',
65
+ },
66
+ customStyle: {
67
+ type: [Object, String],
68
+ default: () => ({}),
69
+ },
70
+ customClass: {
71
+ type: String,
72
+ default: '',
73
+ },
74
+
75
+ ...config.props.loadingIcon,
76
+ };
77
+
78
+ export default props;
@@ -0,0 +1,226 @@
1
+ <template>
2
+ <view
3
+ v-if="p.show"
4
+ class="uv-loading-icon"
5
+ :class="[p.vertical ? 'uv-loading-icon--vertical' : '', p.customClass]"
6
+ :style="[$uv.addStyle(p.customStyle)]"
7
+ >
8
+ <view
9
+ class="uv-loading-icon__spinner"
10
+ :class="['uv-loading-icon__spinner--' + p.mode]"
11
+ :style="[spinnerStyle]"
12
+ >
13
+ <!-- #ifdef APP-NVUE -->
14
+ <loading-indicator
15
+ v-if="p.mode === 'spinner'"
16
+ :animating="true"
17
+ :style="{ color: p.color, width: $uv.addUnit(p.size), height: $uv.addUnit(p.size) }"
18
+ />
19
+ <!-- #endif -->
20
+ <!-- #ifndef APP-NVUE -->
21
+ <template v-if="p.mode === 'spinner'">
22
+ <view
23
+ v-for="(item, index) in array12"
24
+ :key="index"
25
+ class="uv-loading-icon__dot"
26
+ :style="[dotStyle(index)]"
27
+ >
28
+ <view
29
+ class="uv-loading-icon__dot-bar"
30
+ :style="{ backgroundColor: p.color }"
31
+ ></view>
32
+ </view>
33
+ </template>
34
+ <!-- #endif -->
35
+ </view>
36
+ <text
37
+ v-if="p.text"
38
+ class="uv-loading-icon__text"
39
+ :class="[p.vertical ? 'uv-loading-icon__text--vertical' : '']"
40
+ :style="[{
41
+ fontSize: $uv.addUnit(p.textSize),
42
+ color: p.textColor
43
+ }, $uv.addStyle(p.textStyle)]"
44
+ >{{ p.text }}</text>
45
+ </view>
46
+ </template>
47
+
48
+ <script setup lang="ts">
49
+ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
50
+ import { $uv } from '../../utils'
51
+ import props from './props'
52
+
53
+ defineOptions({
54
+ name: 'uv-loading-icon',
55
+ // #ifdef UNI-APP-X
56
+ styleIsolation: 'app-and-page',
57
+ // #endif
58
+ virtualHost: true,
59
+ })
60
+
61
+ /**
62
+ * loading 加载动画
63
+ * @description 此组件为一个小动画,目前用在uvui的loadmore加载更多和switch开关等组件的正在加载状态场景。
64
+ * @tutorial https://www.uvui.cn/components/loading.html
65
+ * @property {Boolean} show 是否显示组件 (默认 true)
66
+ * @property {String} color 动画活动区域的颜色 (默认 '#909193')
67
+ * @property {String} textColor 提示文本的颜色(默认 '#909193')
68
+ * @property {Boolean} vertical 文字和图标是否垂直排列 (默认 false )
69
+ * @property {String} mode 模式选择,circle-圆形,spinner-花朵形,semicircle-半圆形(默认 'spinner' )
70
+ * @property {String | Number} size 加载图标的大小,单位px (默认 24 )
71
+ * @property {String | Number} textSize 文字大小(默认 15 )
72
+ * @property {String | Number} text 文字内容
73
+ * @property {Object} textStyle 文字样式
74
+ * @property {String} timingFunction 动画模式 (默认 'linear' )
75
+ * @property {String | Number} duration 动画执行周期时间(默认 1200)
76
+ * @property {String} inactiveColor mode=circle时的暗边颜色
77
+ * @property {Object} customStyle 定义需要用到的外部样式
78
+ * @example <uv-loading-icon mode="circle"></uv-loading-icon>
79
+ */
80
+ const p = defineProps(props)
81
+
82
+ // 花瓣模式下 12 个点
83
+ const array12 = Array.from({
84
+ length: 12
85
+ })
86
+
87
+ const rotateDeg = ref(0)
88
+ let timer: any = null
89
+
90
+ const durationTime = computed(() => Number(p.duration) || 0)
91
+
92
+ // 当为circle类型时,给其另外三边设置一个更轻一些的颜色
93
+ // 之所以需要这么做的原因是,比如父组件传了color为红色,那么需要另外的三个边为浅红色
94
+ const otherBorderColor = computed(() => {
95
+ const lightColor = $uv.colorGradient(p.color, '#ffffff', 100)[80]
96
+ if (p.mode === 'circle') {
97
+ return p.inactiveColor ? p.inactiveColor : lightColor
98
+ }
99
+ return 'transparent'
100
+ })
101
+
102
+ const spinnerStyle = computed(() => {
103
+ return {
104
+ color: p.color,
105
+ width: $uv.addUnit(p.size),
106
+ height: $uv.addUnit(p.size),
107
+ borderTopColor: p.color,
108
+ borderBottomColor: otherBorderColor.value,
109
+ borderLeftColor: otherBorderColor.value,
110
+ borderRightColor: otherBorderColor.value,
111
+ transform: `rotate(${rotateDeg.value}deg)`,
112
+ transitionProperty: 'transform',
113
+ transitionDuration: `${durationTime.value}ms`,
114
+ // 花瓣模式按 12 个点步进旋转,圆形/半圆按传入的缓动函数
115
+ transitionTimingFunction: p.mode === 'spinner' ? 'steps(12)' : p.timingFunction
116
+ }
117
+ })
118
+
119
+ const dotStyle = (index: number) => {
120
+ return {
121
+ transform: `rotate(${(index + 1) * 30}deg)`,
122
+ opacity: 1 - 0.0625 * index
123
+ }
124
+ }
125
+
126
+ const clearTimer = () => {
127
+ if (timer) {
128
+ clearInterval(timer)
129
+ timer = null
130
+ }
131
+ }
132
+
133
+ const startRotate = () => {
134
+ clearTimer()
135
+ // duration 为 0 时不启动旋转,避免 0ms 定时器空转
136
+ if (durationTime.value <= 0) return
137
+ nextTick(() => {
138
+ // 用 CSS transition 代替 @keyframes / uni.createAnimation:每次增加 360deg 形成连续旋转
139
+ rotateDeg.value += 360
140
+ })
141
+ timer = setInterval(() => {
142
+ rotateDeg.value += 360
143
+ }, durationTime.value)
144
+ }
145
+
146
+ onMounted(() => {
147
+ startRotate()
148
+ })
149
+
150
+ onUnmounted(() => {
151
+ clearTimer()
152
+ })
153
+
154
+ watch(
155
+ () => p.duration,
156
+ () => {
157
+ startRotate()
158
+ }
159
+ )
160
+ </script>
161
+
162
+ <style lang="scss">
163
+ @import '../../styles/components.scss';
164
+ @import '../../styles/color.scss';
165
+
166
+ .uv-loading-icon {
167
+ display: flex;
168
+ flex-direction: row;
169
+ align-items: center;
170
+ justify-content: center;
171
+ color: #909193;
172
+ }
173
+ .uv-loading-icon--vertical {
174
+ flex-direction: column;
175
+ }
176
+ .uv-loading-icon__text {
177
+ margin-left: 4px;
178
+ color: $uv-content-color;
179
+ font-size: 14px;
180
+ line-height: 20px;
181
+ }
182
+ .uv-loading-icon__text--vertical {
183
+ margin-left: 0;
184
+ margin-top: 6px;
185
+ }
186
+ .uv-loading-icon__spinner {
187
+ position: relative;
188
+ /* #ifndef APP-NVUE */
189
+ box-sizing: border-box;
190
+ /* #endif */
191
+ }
192
+ .uv-loading-icon__spinner--semicircle {
193
+ border-width: 2px;
194
+ border-color: transparent;
195
+ border-top-right-radius: 100px;
196
+ border-top-left-radius: 100px;
197
+ border-bottom-left-radius: 100px;
198
+ border-bottom-right-radius: 100px;
199
+ border-style: solid;
200
+ }
201
+ .uv-loading-icon__spinner--circle {
202
+ border-top-right-radius: 100px;
203
+ border-top-left-radius: 100px;
204
+ border-bottom-left-radius: 100px;
205
+ border-bottom-right-radius: 100px;
206
+ border-width: 2px;
207
+ border-style: solid;
208
+ }
209
+ /* #ifndef APP-NVUE */
210
+ .uv-loading-icon__dot {
211
+ position: absolute;
212
+ top: 0;
213
+ left: 0;
214
+ width: 100%;
215
+ height: 100%;
216
+ display: flex;
217
+ flex-direction: column;
218
+ align-items: center;
219
+ }
220
+ .uv-loading-icon__dot-bar {
221
+ width: 2px;
222
+ height: 25%;
223
+ border-radius: 2px;
224
+ }
225
+ /* #endif */
226
+ </style>
@@ -0,0 +1,38 @@
1
+ // @ts-nocheck
2
+
3
+ import config from '../../utils/config';
4
+
5
+ const props = {
6
+ show: {
7
+ type: Boolean,
8
+ default: false,
9
+ },
10
+ zIndex: {
11
+ type: [String, Number],
12
+ default: 10070,
13
+ },
14
+ duration: {
15
+ type: [String, Number],
16
+ default: 300,
17
+ },
18
+ opacity: {
19
+ type: [String, Number],
20
+ default: 0.5,
21
+ },
22
+ hidden: {
23
+ type: Boolean,
24
+ default: true,
25
+ },
26
+ customStyle: {
27
+ type: [Object, String],
28
+ default: () => ({}),
29
+ },
30
+ customClass: {
31
+ type: String,
32
+ default: '',
33
+ },
34
+
35
+ ...config.props.overlay,
36
+ };
37
+
38
+ export default props;
@@ -0,0 +1,120 @@
1
+ <template>
2
+ <uv-transition
3
+ :show="p.show"
4
+ mode="fade"
5
+ :custom-class="overlayClass"
6
+ :duration="p.duration"
7
+ :custom-style="overlayStyle"
8
+ @click="clickHandler"
9
+ @touchmove="clear"
10
+ >
11
+ <slot />
12
+ </uv-transition>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { computed, onUnmounted, watch } from 'vue'
17
+ import { $uv } from '../../utils'
18
+ import props from './props'
19
+ import { preventEvent } from '../../utils/compat'
20
+
21
+ defineOptions({
22
+ name: 'uv-overlay',
23
+ // #ifdef UNI-APP-X
24
+ styleIsolation: 'app-and-page',
25
+ // #endif
26
+ virtualHost: true,
27
+ })
28
+
29
+ /**
30
+ * overlay 遮罩
31
+ * @description 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
32
+ * @tutorial https://www.uvui.cn/components/overlay.html
33
+ * @property {Boolean} show 是否显示遮罩(默认 false )
34
+ * @property {String | Number} zIndex zIndex 层级(默认 10070 )
35
+ * @property {String | Number} duration 动画时长,单位毫秒(默认 300 )
36
+ * @property {String | Number} opacity 不透明度值,当做rgba的第四个参数 (默认 0.5 )
37
+ * @property {Boolean} hidden 显示时 Web 的 body 是否添加 overflow: hidden(默认 true,仅 WEB 生效)
38
+ * @property {Object} customStyle 定义需要用到的外部样式
39
+ * @event {Function} click 点击遮罩发送事件
40
+ * @example <uv-overlay :show="show" @click="show = false"></uv-overlay>
41
+ */
42
+ const p = defineProps(props)
43
+
44
+ const emit = defineEmits(['click'])
45
+
46
+ const overlayClass = computed(() => {
47
+ const classes = ['uv-overlay']
48
+ if (p.customClass) classes.push(p.customClass)
49
+ return classes
50
+ })
51
+
52
+ const overlayStyle = computed(() => {
53
+ const style: any = {
54
+ position: 'fixed',
55
+ top: 0,
56
+ left: 0,
57
+ right: 0,
58
+ bottom: 0,
59
+ zIndex: p.zIndex,
60
+ backgroundColor: `rgba(0, 0, 0, ${p.opacity})`
61
+ }
62
+ return $uv.deepMerge(style, $uv.addStyle(p.customStyle))
63
+ })
64
+
65
+ const clickHandler = () => {
66
+ emit('click')
67
+ }
68
+
69
+ /**
70
+ * 触摸移动时阻止页面滚动穿透;nvue 无法阻止原生 scroller,仅做冒泡处理。
71
+ */
72
+ const clear = (event?: any) => {
73
+ if (event && typeof event.preventDefault === 'function') {
74
+ event.preventDefault()
75
+ }
76
+ preventEvent(event)
77
+ }
78
+
79
+ // #ifdef WEB || H5
80
+ const setBodyOverflow = (hidden: boolean) => {
81
+ const body = document.body
82
+ if (body && body.style) {
83
+ body.style.overflow = hidden ? 'hidden' : ''
84
+ }
85
+ }
86
+
87
+ watch(
88
+ () => p.show,
89
+ (show: boolean) => {
90
+ if (!p.hidden) return
91
+ setBodyOverflow(show)
92
+ }
93
+ )
94
+
95
+ onUnmounted(() => {
96
+ if (p.hidden) setBodyOverflow(false)
97
+ })
98
+ // #endif
99
+
100
+ defineExpose({
101
+ clear
102
+ })
103
+ </script>
104
+
105
+ <style lang="scss">
106
+ @import '../../styles/components.scss';
107
+
108
+ $uv-overlay-top: 0 !default;
109
+ $uv-overlay-left: 0 !default;
110
+ $uv-overlay-background-color: rgba(0, 0, 0, 0.7) !default;
111
+
112
+ .uv-overlay {
113
+ position: fixed;
114
+ top: $uv-overlay-top;
115
+ left: $uv-overlay-left;
116
+ right: 0;
117
+ bottom: 0;
118
+ background-color: $uv-overlay-background-color;
119
+ }
120
+ </style>