uniapp-dyckui 4.1.5 → 4.1.7

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.
@@ -1,275 +1,335 @@
1
- <template>
2
- <view v-if="showDialog" class="dialog-wrapper" @click="handleMaskClick">
3
- <view class="dialog-container" @click.stop>
4
- <!-- 上部分内容 -->
5
- <view class="dialog-content">
6
- <view class="dialog-icon">
7
- <image v-if="icon" :src="icon" alt="dialog-icon" />
8
- <!-- 默认图标 -->
9
- <view v-else class="default-icon" />
10
- </view>
11
- <text class="dialog-title">{{ title }}</text>
12
- <text class="dialog-description">{{ description }}</text>
13
- </view>
14
-
15
- <!-- 分割线 -->
16
- <view class="dialog-divider" />
17
-
18
- <!-- 下部分按钮 -->
19
- <view class="dialog-buttons">
20
- <!-- 类型1: 取消和打开app -->
21
- <template v-if="type === 'open-app'">
22
- <view class="dialog-button dialog-button-cancel" @click="handleCancel">
23
- 取消
24
- </view>
25
- <view class="dialog-button dialog-button-primary" @click="handleConfirm">
26
- 打开app
27
- </view>
28
- </template>
29
-
30
- <!-- 类型2: 知道了 -->
31
- <template v-else-if="type === 'confirm'">
32
- <view class="dialog-button dialog-button-full dialog-button-primary" @click="handleConfirm">
33
- 知道了
34
- </view>
35
- </template>
36
-
37
- <!-- 类型3: 取消和继续访问 -->
38
- <template v-else-if="type === 'continue'">
39
- <view class="dialog-button dialog-button-cancel" @click="handleCancel">
40
- 取消
41
- </view>
42
- <view class="dialog-button dialog-button-primary" @click="handleConfirm">
43
- 继续访问
44
- </view>
45
- </template>
46
- </view>
47
- </view>
48
- </view>
49
- </template>
50
-
51
- <script setup lang="ts">
52
- import { ref, watch } from 'vue'
53
-
54
- // 弹窗类型定义
55
- type DialogType = 'open-app' | 'confirm' | 'continue'
56
-
57
- // Props定义
58
- interface Props {
59
- // 控制弹窗显示/隐藏(支持v-model)
60
- modelValue: boolean
61
- // 弹窗类型
62
- type?: DialogType
63
- // 弹窗标题
64
- title?: string
65
- // 弹窗说明文字
66
- description?: string
67
- // 图标路径
68
- icon?: string
69
- // 是否显示遮罩层
70
- mask?: boolean
71
- // 遮罩层透明度
72
- maskOpacity?: number
73
- // 点击遮罩是否关闭弹窗
74
- closeOnMaskClick?: boolean
75
- }
76
-
77
- // Props默认值
78
- const props = withDefaults(defineProps<Props>(), {
79
- modelValue: false,
80
- type: 'confirm',
81
- title: '',
82
- description: '',
83
- icon: '',
84
- mask: true,
85
- maskOpacity: 0.5,
86
- closeOnMaskClick: true,
87
- })
88
-
89
- // Emits定义
90
- const emit = defineEmits<{
91
- (e: 'update:modelValue', value: boolean): void
92
- (e: 'confirm'): void
93
- (e: 'cancel'): void
94
- }>()
95
-
96
- // 本地状态
97
- const showDialog = ref(props.modelValue)
98
-
99
- // 监听modelValue变化
100
- watch(() => props.modelValue, (newVal) => {
101
- showDialog.value = newVal
102
- })
103
-
104
- // 监听showDialog变化
105
- watch(() => showDialog.value, (newVal) => {
106
- emit('update:modelValue', newVal)
107
- })
108
-
109
- // 点击遮罩层
110
- function handleMaskClick() {
111
- if (props.closeOnMaskClick) {
112
- showDialog.value = false
113
- }
114
- }
115
-
116
- // 点击确认按钮
117
- function handleConfirm() {
118
- emit('confirm')
119
- // 确认后关闭弹窗
120
- showDialog.value = false
121
- }
122
-
123
- // 点击取消按钮
124
- function handleCancel() {
125
- emit('cancel')
126
- // 取消后关闭弹窗
127
- showDialog.value = false
128
- }
129
- </script>
130
-
131
- <style scoped>
132
- /* 弹窗容器 */
133
- .dialog-wrapper {
134
- position: fixed;
135
- top: 0;
136
- left: 0;
137
- right: 0;
138
- bottom: 0;
139
- z-index: 1000;
140
- display: flex;
141
- align-items: center;
142
- justify-content: center;
143
- background-color: rgba(0, 0, 0, v-bind('maskOpacity'));
144
- animation: fadeIn 300ms ease;
145
- }
146
-
147
- /* 弹窗主体 */
148
- .dialog-container {
149
- width: 80%;
150
- max-width: 800rpx;
151
- background-color: #fff;
152
- border-radius: 32rpx;
153
- overflow: hidden;
154
- box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.15);
155
- animation: scaleIn 300ms ease;
156
- background-image: url('@/assets/u2.png');
157
- background-size: cover;
158
- background-position: center;
159
- }
160
-
161
- /* 上部分内容 */
162
- .dialog-content {
163
- padding: 60rpx 40rpx;
164
- text-align: center;
165
- }
166
-
167
- /* 图标 */
168
- .dialog-icon {
169
- margin-bottom: 40rpx;
170
- display: flex;
171
- justify-content: center;
172
- align-items: center;
173
- }
174
-
175
- .dialog-icon image {
176
- width: 120rpx;
177
- height: 120rpx;
178
- object-fit: contain;
179
- }
180
-
181
- .default-icon {
182
- width: 120rpx;
183
- height: 120rpx;
184
- background-color: #f0f0f0;
185
- border-radius: 50%;
186
- }
187
-
188
- /* 标题 */
189
- .dialog-title {
190
- font-size: 36rpx;
191
- font-weight: bold;
192
- color: #333;
193
- margin: 0 0 20rpx 0;
194
- }
195
-
196
- /* 说明文字 */
197
- .dialog-description {
198
- font-size: 28rpx;
199
- color: #666;
200
- margin: 0;
201
- line-height: 1.5;
202
- }
203
-
204
- /* 分割线 */
205
- .dialog-divider {
206
- height: 2rpx;
207
- background-color: #e5e5e5;
208
- margin: 0;
209
- }
210
-
211
- /* 按钮区域 */
212
- .dialog-buttons {
213
- display: flex;
214
- flex-direction: row;
215
- align-items: center;
216
- }
217
-
218
- /* 按钮 */
219
- .dialog-button {
220
- flex: 1;
221
- padding: 30rpx;
222
- border: none;
223
- background: none;
224
- font-size: 32rpx;
225
- font-weight: 500;
226
- cursor: pointer;
227
- transition: background-color 0.3s ease;
228
- text-align: center;
229
- box-sizing: border-box;
230
- }
231
-
232
- /* 全宽按钮 */
233
- .dialog-button-full {
234
- width: 100%;
235
- }
236
-
237
- /* 取消按钮 */
238
- .dialog-button-cancel {
239
- color: #666;
240
- }
241
-
242
- .dialog-button-cancel:hover {
243
- background-color: #f5f5f5;
244
- }
245
-
246
- /* 主要按钮 */
247
- .dialog-button-primary {
248
- color: #1989fa;
249
- }
250
-
251
- .dialog-button-primary:hover {
252
- background-color: #f0f9ff;
253
- }
254
-
255
- /* 动画效果 */
256
- @keyframes fadeIn {
257
- from {
258
- opacity: 0;
259
- }
260
- to {
261
- opacity: 1;
262
- }
263
- }
264
-
265
- @keyframes scaleIn {
266
- from {
267
- transform: scale(0.8);
268
- opacity: 0;
269
- }
270
- to {
271
- transform: scale(1);
272
- opacity: 1;
273
- }
274
- }
275
- </style>
1
+ <template>
2
+ <view v-if="showDialog" class="dialog-wrapper" @click="handleMaskClick">
3
+ <view class="dialog-container" @click.stop>
4
+ <!-- 上部分内容 -->
5
+ <view class="dialog-content">
6
+ <view class="dialog-icon">
7
+ <!-- 图标插槽包装器 -->
8
+ <slot name="icon">
9
+ <!-- 自定义字体图标 -->
10
+ <text v-if="customIcon" class="iconfont dialog-icon-custom">{{ customIcon }}</text>
11
+ <!-- 根据图标类型显示字体图标 -->
12
+ <text v-else-if="iconType === 'phone'" class="iconfont dialog-button-primary icon-shouji" />
13
+ <text v-else-if="iconType === 'screen'" class="iconfont dialog-button-primary icon-xianshiqi" />
14
+ <text v-else-if="iconType === 'links'" class="iconfont dialog-button-primary icon-xianshiqi1" />
15
+ <text v-else-if="iconType === 'links2'" class="iconfont dialog-button-primary icon-lianjiewangzhi" />
16
+ <!-- 兼容旧版本的图片图标 -->
17
+ <image v-else-if="icon" :src="icon" alt="dialog-icon" />
18
+ <!-- 默认图标 -->
19
+ <view v-else class="default-icon" />
20
+ </slot>
21
+ </view>
22
+ <view class="dialog-title">
23
+ {{ title }}
24
+ </view>
25
+ <text class="dialog-description">{{ description }}</text>
26
+ </view>
27
+
28
+ <!-- 分割线 -->
29
+ <view class="dialog-divider" />
30
+
31
+ <!-- 下部分按钮 -->
32
+ <view class="dialog-buttons">
33
+ <!-- 类型1: 取消和打开app -->
34
+ <template v-if="type === 'open-app'">
35
+ <view class="dialog-button dialog-button-cancel" @click="handleCancel">
36
+ 取消
37
+ </view>
38
+ <view class="dialog-button dialog-button-primary" @click="handleConfirm">
39
+ 打开app
40
+ </view>
41
+ </template>
42
+
43
+ <!-- 类型2: 知道了 -->
44
+ <template v-else-if="type === 'confirm'">
45
+ <view class="dialog-button dialog-button-full dialog-button-primary" @click="handleConfirm">
46
+ 知道了
47
+ </view>
48
+ </template>
49
+
50
+ <!-- 类型3: 取消和继续访问 -->
51
+ <template v-else-if="type === 'continue'">
52
+ <view class="dialog-button dialog-button-cancel" @click="handleCancel">
53
+ 取消
54
+ </view>
55
+ <view class="dialog-button dialog-button-primary" @click="handleConfirm">
56
+ 继续访问
57
+ </view>
58
+ </template>
59
+ </view>
60
+ </view>
61
+ </view>
62
+ </template>
63
+
64
+ <script setup lang="ts">
65
+ import { ref, watch } from 'vue'
66
+
67
+ // 弹窗类型定义
68
+ type DialogType = 'open-app' | 'confirm' | 'continue'
69
+
70
+ // Props定义
71
+ interface Props {
72
+ // 控制弹窗显示/隐藏(支持v-model)
73
+ modelValue?: boolean
74
+ // 弹窗类型
75
+ type?: DialogType
76
+ // 弹窗标题
77
+ title?: string
78
+ // 弹窗说明文字
79
+ description?: string
80
+ // 图标路径(兼容旧版本)
81
+ icon?: string
82
+ // 图标类型:phone、screen、links、links2
83
+ iconType?: 'phone' | 'screen' | 'links' | 'links2'
84
+ // 自定义字体图标
85
+ customIcon?: string
86
+ // 是否显示遮罩层
87
+ mask?: boolean
88
+ // 遮罩层透明度
89
+ maskOpacity?: number
90
+ // 点击遮罩是否关闭弹窗
91
+ closeOnMaskClick?: boolean
92
+ }
93
+
94
+ // Props默认值
95
+ const props = withDefaults(defineProps<Props>(), {
96
+ modelValue: false,
97
+ type: 'confirm',
98
+ title: '',
99
+ description: '',
100
+ icon: '',
101
+ iconType: undefined,
102
+ customIcon: '',
103
+ mask: true,
104
+ maskOpacity: 0.5,
105
+ closeOnMaskClick: true,
106
+ })
107
+
108
+ // Emits定义
109
+ const emit = defineEmits<{
110
+ (e: 'update:modelValue', value: boolean): void
111
+ (e: 'confirm'): void
112
+ (e: 'cancel'): void
113
+ }>()
114
+
115
+ // 本地状态
116
+ const showDialog = ref(props.modelValue)
117
+
118
+ // 监听modelValue变化
119
+ watch(() => props.modelValue, (newVal) => {
120
+ showDialog.value = newVal
121
+ })
122
+
123
+ // 监听showDialog变化
124
+ watch(() => showDialog.value, (newVal) => {
125
+ emit('update:modelValue', newVal)
126
+ })
127
+
128
+ // 点击遮罩层
129
+ function handleMaskClick() {
130
+ if (props.closeOnMaskClick) {
131
+ showDialog.value = false
132
+ }
133
+ }
134
+
135
+ // 点击确认按钮
136
+ function handleConfirm() {
137
+ emit('confirm')
138
+ // 确认后关闭弹窗
139
+ showDialog.value = false
140
+ }
141
+
142
+ // 点击取消按钮
143
+ function handleCancel() {
144
+ emit('cancel')
145
+ // 取消后关闭弹窗
146
+ showDialog.value = false
147
+ }
148
+ </script>
149
+
150
+ <style scoped>
151
+ /* 弹窗容器 */
152
+ .dialog-wrapper {
153
+ position: fixed;
154
+ top: 0;
155
+ left: 0;
156
+ right: 0;
157
+ bottom: 0;
158
+ z-index: 1000;
159
+ display: flex;
160
+ align-items: center;
161
+ justify-content: center;
162
+ background-color: rgba(0, 0, 0, v-bind('maskOpacity'));
163
+ animation: fadeIn 300ms ease;
164
+ }
165
+
166
+ /* 弹窗主体 */
167
+ .dialog-container {
168
+ width: 80%;
169
+ max-width: 800rpx;
170
+ background-color: #fff;
171
+ border-radius: 32rpx;
172
+ overflow: hidden;
173
+ box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.15);
174
+ animation: scaleIn 300ms ease;
175
+ background-image: url('@/assets/u2.png');
176
+ background-size: cover;
177
+ background-position: center;
178
+ }
179
+
180
+ /* 上部分内容 */
181
+ .dialog-content {
182
+ padding: 60rpx 40rpx;
183
+ text-align: center;
184
+ }
185
+
186
+ /* 图标 */
187
+ .dialog-icon {
188
+ margin-bottom: 40rpx;
189
+ display: flex;
190
+ justify-content: center;
191
+ align-items: center;
192
+ display: inline-block;
193
+ border-radius: 50%;
194
+ border: 2rpx solid rgb(151, 150, 150);
195
+ }
196
+
197
+ /* 确保dialog-icon容器内的所有直接子元素都应用相同的基础样式 */
198
+ .dialog-icon > * {
199
+ width: 120rpx;
200
+ height: 120rpx;
201
+ font-size: 80rpx;
202
+ display: flex;
203
+ justify-content: center;
204
+ align-items: center;
205
+ }
206
+
207
+ .dialog-icon image {
208
+ object-fit: contain;
209
+ }
210
+
211
+ /* 字体图标样式 */
212
+ .dialog-icon .iconfont {
213
+ /* 已通过 .dialog-icon > * 应用基础样式 */
214
+ }
215
+
216
+ /* 自定义字体图标 */
217
+ .dialog-icon-custom {
218
+ color: #1989fa;
219
+ }
220
+
221
+ /* 成功图标 */
222
+ .dialog-icon-success {
223
+ color: #67c23a;
224
+ }
225
+
226
+ /* 警告图标 */
227
+ .dialog-icon-warning {
228
+ color: #e6a23c;
229
+ }
230
+
231
+ /* 错误图标 */
232
+ .dialog-icon-error {
233
+ color: #f56c6c;
234
+ }
235
+
236
+ /* 信息图标 */
237
+ .dialog-icon-info {
238
+ color: #909399;
239
+ }
240
+
241
+ .default-icon {
242
+ width: 120rpx;
243
+ height: 120rpx;
244
+ background-color: #f0f0f0;
245
+ border-radius: 50%;
246
+ }
247
+
248
+ /* 标题 */
249
+ .dialog-title {
250
+ font-size: 36rpx;
251
+ font-weight: bold;
252
+ color: #333;
253
+ margin: 0 0 20rpx 0;
254
+ }
255
+
256
+ /* 说明文字 */
257
+ .dialog-description {
258
+ font-size: 28rpx;
259
+ color: #666;
260
+ margin: 0;
261
+ line-height: 1.5;
262
+ }
263
+
264
+ /* 分割线 */
265
+ .dialog-divider {
266
+ height: 2rpx;
267
+ background-color: #e5e5e5;
268
+ margin: 0;
269
+ }
270
+
271
+ /* 按钮区域 */
272
+ .dialog-buttons {
273
+ display: flex;
274
+ flex-direction: row;
275
+ align-items: center;
276
+ }
277
+
278
+ /* 按钮 */
279
+ .dialog-button {
280
+ flex: 1;
281
+ padding: 30rpx;
282
+ border: none;
283
+ background: none;
284
+ font-size: 32rpx;
285
+ font-weight: 500;
286
+ cursor: pointer;
287
+ transition: background-color 0.3s ease;
288
+ text-align: center;
289
+ box-sizing: border-box;
290
+ }
291
+
292
+ /* 全宽按钮 */
293
+ .dialog-button-full {
294
+ width: 100%;
295
+ }
296
+
297
+ /* 取消按钮 */
298
+ .dialog-button-cancel {
299
+ color: #666;
300
+ }
301
+
302
+ .dialog-button-cancel:hover {
303
+ background-color: #f5f5f5;
304
+ }
305
+
306
+ /* 主要按钮 */
307
+ .dialog-button-primary {
308
+ color: #00599c;
309
+ }
310
+
311
+ .dialog-button-primary:hover {
312
+ background-color: #f0f9ff;
313
+ }
314
+
315
+ /* 动画效果 */
316
+ @keyframes fadeIn {
317
+ from {
318
+ opacity: 0;
319
+ }
320
+ to {
321
+ opacity: 1;
322
+ }
323
+ }
324
+
325
+ @keyframes scaleIn {
326
+ from {
327
+ transform: scale(0.8);
328
+ opacity: 0;
329
+ }
330
+ to {
331
+ transform: scale(1);
332
+ opacity: 1;
333
+ }
334
+ }
335
+ </style>
@@ -226,7 +226,6 @@ function lockScroll() {
226
226
  // #endif
227
227
 
228
228
  // #ifdef MP
229
- // @ts-expect-error 小程序特有API,TypeScript类型定义缺失
230
229
  uni.hideTabBar()
231
230
  // #endif
232
231
  }
@@ -243,7 +242,6 @@ function unlockScroll() {
243
242
  // #endif
244
243
 
245
244
  // #ifdef MP
246
- // @ts-expect-error 小程序特有API,TypeScript类型定义缺失
247
245
  uni.showTabBar()
248
246
  // #endif
249
247
  }