hy-app 0.4.3 → 0.4.5

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 (147) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +1 -1
  2. package/components/hy-address-picker/hy-address-picker.vue +1 -1
  3. package/components/hy-avatar/hy-avatar.vue +1 -1
  4. package/components/hy-back-top/hy-back-top.vue +1 -2
  5. package/components/hy-badge/hy-badge.vue +1 -1
  6. package/components/hy-button/hy-button.vue +1 -2
  7. package/components/hy-calendar/hy-calendar.vue +3 -11
  8. package/components/hy-calendar/month.vue +1 -1
  9. package/components/hy-card/hy-card.vue +1 -1
  10. package/components/hy-cell/hy-cell.vue +1 -2
  11. package/components/hy-cell/props.ts +1 -1
  12. package/components/hy-check-button/hy-check-button.vue +2 -2
  13. package/components/hy-checkbox/hy-checkbox.vue +2 -3
  14. package/components/hy-checkbox-group/hy-checkbox-group.vue +1 -1
  15. package/components/hy-checkbox-item/hy-checkbox-item.vue +1 -2
  16. package/components/hy-code-input/hy-code-input.vue +1 -1
  17. package/components/hy-config-provider/hy-config-provider.vue +2 -3
  18. package/components/hy-config-provider/props.ts +1 -1
  19. package/components/hy-count-down/index.ts +1 -1
  20. package/components/hy-count-to/hy-count-to.vue +1 -1
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +2 -3
  22. package/components/hy-datetime-picker/props.ts +1 -1
  23. package/components/hy-divider/hy-divider.vue +1 -2
  24. package/components/hy-divider/props.ts +1 -1
  25. package/components/hy-dropdown/hy-dropdown.vue +2 -3
  26. package/components/hy-dropdown/props.ts +1 -1
  27. package/components/hy-dropdown-item/hy-dropdown-item.vue +1 -2
  28. package/components/hy-empty/hy-empty.vue +1 -1
  29. package/components/hy-flex/hy-flex.vue +1 -1
  30. package/components/hy-float-button/hy-float-button.vue +1 -2
  31. package/components/hy-float-button/props.ts +14 -14
  32. package/components/hy-folding-panel/hy-folding-panel.vue +2 -3
  33. package/components/hy-folding-panel/props.ts +1 -1
  34. package/components/hy-form/hy-form.vue +1 -1
  35. package/components/hy-form-group/hy-form-group.vue +183 -111
  36. package/components/hy-form-group/typing.d.ts +1 -1
  37. package/components/hy-form-item/hy-form-item.vue +1 -1
  38. package/components/hy-grid/hy-grid.vue +1 -1
  39. package/components/hy-icon/hy-icon.vue +1 -1
  40. package/components/hy-icon/index.scss +1 -1
  41. package/components/hy-image/hy-image.vue +1 -2
  42. package/components/hy-image/props.ts +10 -10
  43. package/components/hy-input/hy-input.vue +1 -2
  44. package/components/hy-line/hy-line.vue +1 -1
  45. package/components/hy-line-progress/hy-line-progress.vue +1 -2
  46. package/components/hy-list/hy-list.vue +1 -1
  47. package/components/hy-loading/hy-loading.vue +1 -1
  48. package/components/hy-menu/hy-menu.vue +1 -1
  49. package/components/hy-modal/hy-modal.vue +2 -2
  50. package/components/hy-modal/props.ts +13 -13
  51. package/components/hy-navbar/hy-navbar.vue +1 -2
  52. package/components/hy-navbar/props.ts +1 -1
  53. package/components/hy-notice-bar/hy-column-notice.vue +1 -2
  54. package/components/hy-notice-bar/hy-notice-bar.vue +1 -1
  55. package/components/hy-notice-bar/hy-row-notice.vue +1 -2
  56. package/components/hy-notice-bar/props.ts +1 -1
  57. package/components/hy-notify/hy-notify.vue +1 -2
  58. package/components/hy-number-step/hy-number-step.vue +1 -2
  59. package/components/hy-overlay/hy-overlay.vue +1 -1
  60. package/components/hy-pagination/hy-pagination.vue +1 -1
  61. package/components/hy-picker/hy-picker.vue +1 -2
  62. package/components/hy-popover/hy-popover.vue +9 -3
  63. package/components/hy-popup/hy-popup.vue +2 -3
  64. package/components/hy-price/hy-price.vue +3 -2
  65. package/components/hy-qrcode/hy-qrcode.vue +1 -1
  66. package/components/hy-radio/hy-radio.vue +1 -2
  67. package/components/hy-rate/hy-rate.vue +6 -4
  68. package/components/hy-rate/props.ts +6 -6
  69. package/components/hy-read-more/hy-read-more.vue +1 -2
  70. package/components/hy-scroll-list/hy-scroll-list.vue +1 -1
  71. package/components/hy-scroll-list/props.ts +0 -1
  72. package/components/hy-search/hy-search.vue +3 -3
  73. package/components/hy-signature/hy-signature.vue +1 -1
  74. package/components/hy-slider/hy-slider.vue +3 -13
  75. package/components/hy-slider/props.ts +1 -1
  76. package/components/hy-status-bar/hy-status-bar.vue +1 -1
  77. package/components/hy-status-bar/props.ts +1 -1
  78. package/components/hy-steps/hy-steps.vue +1 -2
  79. package/components/hy-subsection/hy-subsection.vue +1 -1
  80. package/components/hy-subsection/props.ts +0 -1
  81. package/components/hy-subsection/typing.d.ts +0 -1
  82. package/components/hy-swipe-action/hy-swipe-action.vue +1 -2
  83. package/components/hy-swiper/hy-swiper-indicator.vue +1 -1
  84. package/components/hy-swiper/hy-swiper.vue +2 -3
  85. package/components/hy-swiper/typing.d.ts +35 -36
  86. package/components/hy-switch/hy-switch.vue +2 -2
  87. package/components/hy-switch/typing.d.ts +0 -1
  88. package/components/hy-tabs/hy-tabs.vue +2 -3
  89. package/components/hy-tag/hy-tag.vue +1 -2
  90. package/components/hy-text/hy-text.vue +2 -2
  91. package/components/hy-text/typing.d.ts +26 -26
  92. package/components/hy-textarea/hy-textarea.vue +2 -2
  93. package/components/hy-toast/hy-toast.vue +33 -19
  94. package/components/hy-toast/index.scss +3 -2
  95. package/components/hy-toast/typing.d.ts +1 -1
  96. package/components/hy-tooltip/hy-tooltip.vue +8 -2
  97. package/components/hy-transition/hy-transition.vue +1 -1
  98. package/components/hy-upload/hy-upload.vue +7 -2
  99. package/components/hy-upload/props.ts +1 -1
  100. package/components/hy-warn/hy-warn.vue +1 -2
  101. package/components/hy-warn/typing.d.ts +12 -13
  102. package/components/hy-waterfall/hy-waterfall.vue +1 -1
  103. package/components/hy-watermark/hy-watermark.vue +1 -1
  104. package/components/index.ts +117 -118
  105. package/index.ts +1 -7
  106. package/{api → libs/api}/http.ts +2 -2
  107. package/libs/common/index.ts +2 -0
  108. package/libs/common/queue.ts +28 -0
  109. package/{composables → libs/composables}/index.ts +1 -0
  110. package/{composables → libs/composables}/usePopover.ts +7 -2
  111. package/{common/shakeService.ts → libs/composables/useShakeService.ts} +4 -2
  112. package/{composables → libs/composables}/useShare.ts +3 -0
  113. package/libs/composables/useToast.ts +45 -0
  114. package/{composables → libs/composables}/useTouch.ts +3 -0
  115. package/{global → libs/global}/register-properties.ts +1 -1
  116. package/libs/index.ts +7 -0
  117. package/{typing → libs/typing}/index.ts +0 -1
  118. package/{typing → libs/typing}/modules/form.ts +7 -7
  119. package/{utils → libs/utils}/utils.ts +1 -0
  120. package/package.json +2 -2
  121. package/common/index.ts +0 -3
  122. package/common/queue.ts +0 -34
  123. package/components/hy-form/README.md +0 -301
  124. package/components/hy-text/index.ts +0 -0
  125. package/components/yk-dialog/yk-dialog.vue +0 -129
  126. package/composables/useToast.ts +0 -51
  127. package/typing/modules/dialog.ts +0 -17
  128. /package/{api → libs/api}/index.ts +0 -0
  129. /package/{common → libs/common}/versionControl.ts +0 -0
  130. /package/{composables → libs/composables}/useQueue.ts +0 -0
  131. /package/{config → libs/config}/color.ts +0 -0
  132. /package/{config → libs/config}/icon.ts +0 -0
  133. /package/{config → libs/config}/index.ts +0 -0
  134. /package/{static/font → libs/css}/iconfont.css +0 -0
  135. /package/{global → libs/global}/index.ts +0 -0
  136. /package/{typing → libs/typing}/modules/common.d.ts +0 -0
  137. /package/{typing → libs/typing}/modules/enum.ts +0 -0
  138. /package/{typing → libs/typing}/modules/http.ts +0 -0
  139. /package/{typing → libs/typing}/modules/icon.d.ts +0 -0
  140. /package/{typing → libs/typing}/modules/rect.ts +0 -0
  141. /package/{utils → libs/utils}/address.json +0 -0
  142. /package/{utils → libs/utils}/base64.ts +0 -0
  143. /package/{utils → libs/utils}/calendar.js +0 -0
  144. /package/{utils → libs/utils}/colorGradient.ts +0 -0
  145. /package/{utils → libs/utils}/index.ts +0 -0
  146. /package/{utils → libs/utils}/inside.ts +0 -0
  147. /package/{utils → libs/utils}/inspect.ts +0 -0
@@ -1,301 +0,0 @@
1
- # 表单组件 (hy-form-simple)
2
-
3
- 一个简单易用的表单组件,包含 `hy-form-simple` 和 `hy-form-item-simple` 两个组件,支持表单验证、数据绑定等功能。
4
-
5
- ## 组件特性
6
-
7
- - ✅ 表单数据双向绑定
8
- - ✅ 表单验证(必填、长度、类型、自定义验证)
9
- - ✅ 实时验证和失焦验证
10
- - ✅ 支持多种表单控件
11
- - ✅ 灵活的标签布局
12
- - ✅ 错误信息显示
13
- - ✅ 表单重置和清除验证
14
-
15
- ## 基础用法
16
-
17
- ```vue
18
- <template>
19
- <hy-form-simple
20
- ref="formRef"
21
- :model="formData"
22
- :rules="rules"
23
- label-width="80px"
24
- @submit="handleSubmit"
25
- >
26
- <hy-form-item-simple label="用户名" prop="username" required>
27
- <hy-input v-model="formData.username" placeholder="请输入用户名" />
28
- </hy-form-item-simple>
29
-
30
- <hy-form-item-simple label="手机号" prop="phone" required>
31
- <hy-input v-model="formData.phone" type="number" placeholder="请输入手机号" />
32
- </hy-form-item-simple>
33
-
34
- <hy-form-item-simple label="性别" prop="gender">
35
- <hy-radio v-model="formData.gender" :columns="genderOptions" />
36
- </hy-form-item-simple>
37
- </hy-form-simple>
38
- </template>
39
-
40
- <script setup lang="ts">
41
- import { reactive, ref } from 'vue'
42
-
43
- const formData = reactive({
44
- username: '',
45
- phone: '',
46
- gender: ''
47
- })
48
-
49
- const rules = {
50
- username: [
51
- { required: true, message: '请输入用户名' },
52
- { min: 2, max: 20, message: '用户名长度在 2 到 20 个字符' }
53
- ],
54
- phone: [
55
- { required: true, message: '请输入手机号' },
56
- { type: 'phone', message: '请输入正确的手机号' }
57
- ]
58
- }
59
-
60
- const formRef = ref()
61
-
62
- const handleSubmit = (data: any) => {
63
- console.log('表单数据:', data)
64
- }
65
- </script>
66
- ```
67
-
68
- ## API
69
-
70
- ### hy-form-simple Props
71
-
72
- | 参数 | 说明 | 类型 | 默认值 |
73
- |------|------|------|--------|
74
- | model | 表单数据对象 | `Record<string, any>` | `{}` |
75
- | rules | 验证规则 | `FormItemRule` | `{}` |
76
- | labelWidth | 标签宽度 | `string \| number` | `'auto'` |
77
- | labelPosition | 标签位置 | `'left' \| 'top'` | `'left'` |
78
- | labelAlign | 标签对齐方式 | `'left' \| 'center' \| 'right'` | `'left'` |
79
-
80
- ### hy-form-simple Events
81
-
82
- | 事件名 | 说明 | 回调参数 |
83
- |--------|------|----------|
84
- | submit | 表单提交时触发 | `(data: Record<string, any>)` |
85
- | validate | 表单验证时触发 | `(valid: boolean, errors: Record<string, string>)` |
86
-
87
- ### hy-form-simple Methods
88
-
89
- | 方法名 | 说明 | 参数 |
90
- |--------|------|------|
91
- | validate | 验证表单 | - |
92
- | resetFields | 重置表单 | - |
93
- | clearValidate | 清除验证 | `(fields?: string[])` |
94
- | submit | 提交表单 | - |
95
-
96
- ### hy-form-item-simple Props
97
-
98
- | 参数 | 说明 | 类型 | 默认值 |
99
- |------|------|------|--------|
100
- | label | 标签文本 | `string` | `''` |
101
- | prop | 表单字段名 | `string` | `''` |
102
- | required | 是否必填 | `boolean` | `false` |
103
- | rules | 验证规则 | `any` | `{}` |
104
-
105
- ### hy-form-item-simple Events
106
-
107
- | 事件名 | 说明 | 回调参数 |
108
- |--------|------|----------|
109
- | change | 值变化时触发 | `(value: any)` |
110
- | blur | 失焦时触发 | `(value: any)` |
111
-
112
- ### hy-form-item-simple Methods
113
-
114
- | 方法名 | 说明 | 参数 |
115
- |--------|------|------|
116
- | validate | 验证字段 | `(trigger?: 'blur' \| 'change')` |
117
- | resetField | 重置字段 | - |
118
- | clearValidate | 清除验证 | - |
119
-
120
- ## 验证规则
121
-
122
- ### 基础验证
123
-
124
- ```javascript
125
- const rules = {
126
- username: [
127
- { required: true, message: '请输入用户名' },
128
- { min: 2, max: 20, message: '用户名长度在 2 到 20 个字符' }
129
- ]
130
- }
131
- ```
132
-
133
- ### 类型验证
134
-
135
- ```javascript
136
- const rules = {
137
- phone: [
138
- { required: true, message: '请输入手机号' },
139
- { type: 'phone', message: '请输入正确的手机号' }
140
- ],
141
- email: [
142
- { type: 'email', message: '请输入正确的邮箱格式' }
143
- ],
144
- password: [
145
- { type: 'password', message: '密码格式不正确' }
146
- ]
147
- }
148
- ```
149
-
150
- ### 自定义验证
151
-
152
- ```javascript
153
- const rules = {
154
- confirmPassword: [
155
- { required: true, message: '请确认密码' },
156
- {
157
- validator: (value: string) => {
158
- if (value !== formData.password) {
159
- return '两次输入的密码不一致'
160
- }
161
- return true
162
- }
163
- }
164
- ]
165
- }
166
- ```
167
-
168
- ### 触发时机
169
-
170
- ```javascript
171
- const rules = {
172
- username: [
173
- {
174
- required: true,
175
- message: '请输入用户名',
176
- trigger: ['blur', 'change'] // 失焦和变化时都验证
177
- }
178
- ]
179
- }
180
- ```
181
-
182
- ## 支持的表单控件
183
-
184
- - `hy-input` - 输入框
185
- - `hy-textarea` - 文本域
186
- - `hy-radio` - 单选框
187
- - `hy-check-button` - 选择按钮
188
- - `hy-switch` - 开关
189
- - `hy-picker` - 选择器
190
- - `hy-datetime-picker` - 时间选择器
191
- - `hy-address-picker` - 地址选择器
192
- - 其他自定义组件
193
-
194
- ## 完整示例
195
-
196
- ```vue
197
- <template>
198
- <view class="form-demo">
199
- <hy-form-simple
200
- ref="formRef"
201
- :model="formData"
202
- :rules="rules"
203
- label-width="100px"
204
- label-position="left"
205
- @submit="handleSubmit"
206
- >
207
- <hy-form-item-simple label="用户名" prop="username" required>
208
- <hy-input v-model="formData.username" placeholder="请输入用户名" />
209
- </hy-form-item-simple>
210
-
211
- <hy-form-item-simple label="手机号" prop="phone" required>
212
- <hy-input v-model="formData.phone" type="number" placeholder="请输入手机号" />
213
- </hy-form-item-simple>
214
-
215
- <hy-form-item-simple label="邮箱" prop="email">
216
- <hy-input v-model="formData.email" placeholder="请输入邮箱" />
217
- </hy-form-item-simple>
218
-
219
- <hy-form-item-simple label="性别" prop="gender">
220
- <hy-radio v-model="formData.gender" :columns="genderOptions" />
221
- </hy-form-item-simple>
222
-
223
- <hy-form-item-simple label="爱好" prop="hobbies">
224
- <hy-check-button
225
- v-model="formData.hobbies"
226
- :columns="hobbyOptions"
227
- select-type="multiple"
228
- />
229
- </hy-form-item-simple>
230
-
231
- <hy-form-item-simple label="备注" prop="remark">
232
- <hy-textarea v-model="formData.remark" placeholder="请输入备注" />
233
- </hy-form-item-simple>
234
- </hy-form-simple>
235
-
236
- <view class="form-actions">
237
- <hy-button type="primary" @click="handleSubmit">提交</hy-button>
238
- <hy-button @click="handleReset">重置</hy-button>
239
- </view>
240
- </view>
241
- </template>
242
-
243
- <script setup lang="ts">
244
- import { reactive, ref } from 'vue'
245
-
246
- const formData = reactive({
247
- username: '',
248
- phone: '',
249
- email: '',
250
- gender: '',
251
- hobbies: [],
252
- remark: ''
253
- })
254
-
255
- const rules = {
256
- username: [
257
- { required: true, message: '请输入用户名' },
258
- { min: 2, max: 20, message: '用户名长度在 2 到 20 个字符' }
259
- ],
260
- phone: [
261
- { required: true, message: '请输入手机号' },
262
- { type: 'phone', message: '请输入正确的手机号' }
263
- ],
264
- email: [
265
- { type: 'email', message: '请输入正确的邮箱格式' }
266
- ]
267
- }
268
-
269
- const genderOptions = [
270
- { text: '男', value: 'male' },
271
- { text: '女', value: 'female' }
272
- ]
273
-
274
- const hobbyOptions = [
275
- { text: '阅读', value: 'reading' },
276
- { text: '音乐', value: 'music' },
277
- { text: '运动', value: 'sports' }
278
- ]
279
-
280
- const formRef = ref()
281
-
282
- const handleSubmit = () => {
283
- const result = formRef.value?.submit()
284
- if (result) {
285
- console.log('表单提交成功:', result)
286
- }
287
- }
288
-
289
- const handleReset = () => {
290
- formRef.value?.resetFields()
291
- }
292
- </script>
293
- ```
294
-
295
- ## 注意事项
296
-
297
- 1. 表单组件使用 `provide/inject` 进行数据通信,确保 `hy-form-item-simple` 组件在 `hy-form-simple` 内部使用
298
- 2. 验证规则支持数组形式,可以设置多个验证规则
299
- 3. 自定义验证函数返回 `true` 表示验证通过,返回 `false` 或字符串表示验证失败
300
- 4. 表单数据会自动双向绑定,无需手动处理数据同步
301
- 5. 支持实时验证和失焦验证,可以通过 `trigger` 属性控制验证时机
File without changes
@@ -1,129 +0,0 @@
1
- <template>
2
- <view class="promptBox">
3
- <view class="prompt">
4
- <image class="promptRipple" src="../../public/icons/warning.png"></image>
5
-
6
- <view class="promptTit">
7
- {{ title }}
8
- </view>
9
- <view class="promptDesc"> 我是内容 </view>
10
- <view class="pBtnBox">
11
- <button class="pBtnCancel" @click="onCancel">取消</button>
12
- <button class="pBtnOk" @click="onOk('hahahhaah')">确定</button>
13
- </view>
14
- </view>
15
- </view>
16
- </template>
17
-
18
- <script setup lang="ts">
19
- import { ref } from "vue";
20
-
21
- const title = ref("我是标题");
22
- </script>
23
-
24
- <style lang="scss" scoped>
25
- .promptBox {
26
- position: absolute;
27
- top: 0;
28
- left: 0;
29
- width: 100%;
30
- height: 100%;
31
- background: rgba(0, 0, 0, 0.4);
32
- z-index: 9999;
33
-
34
- .prompt {
35
- position: fixed;
36
- width: 300px;
37
- height: 234px;
38
- border-radius: 16px;
39
- background: linear-gradient(180deg, #e3eeff 0%, #ffffff 100%);
40
- left: 50%;
41
- top: 50%;
42
- transform: translate(-50%, -50%);
43
- z-index: 100;
44
- background-size: cover;
45
- display: flex;
46
- flex-direction: column;
47
- justify-content: flex-start;
48
- align-items: center;
49
-
50
- .promptRipple {
51
- position: absolute;
52
- top: -50px;
53
- width: 100px;
54
- height: 100px;
55
- z-index: -1;
56
- }
57
-
58
- .promptIcon {
59
- position: absolute;
60
- top: 0;
61
- transform: translateY(-50%);
62
- width: 110px;
63
- height: 110px;
64
- border-radius: 90px;
65
- overflow: hidden;
66
- // background: linear-gradient(149.98deg, rgba(132, 181, 255, 1) 5.7%, rgba(33, 119, 250, 1) 90.23%);
67
- // box-shadow: 0px 4px 10px rgba(18, 103, 232, 0.4);
68
- }
69
-
70
- .promptTit {
71
- width: 80%;
72
- font-size: 20px;
73
- font-family: PingFang SC;
74
- font-weight: 500;
75
- color: rgba(0, 0, 0, 1);
76
- text-align: center;
77
- margin-top: 66px;
78
- }
79
-
80
- .promptDesc {
81
- height: 40px;
82
- margin-top: 12px;
83
- color: rgba(102, 102, 102, 1);
84
- font-family: PingFang SC;
85
- font-size: 14px;
86
- text-align: center;
87
- }
88
-
89
- .pBtnBox {
90
- width: 280px;
91
- display: flex;
92
- justify-content: space-around;
93
- align-items: center;
94
- margin-top: 12px;
95
-
96
- .pBtnOk {
97
- width: 120px;
98
- height: 44px;
99
- line-height: 44px;
100
- border-radius: 8px !important;
101
- background: linear-gradient(
102
- 301.23deg,
103
- rgba(71, 143, 253, 1) 0%,
104
- rgba(18, 103, 232, 1) 102.96%
105
- );
106
- border: none;
107
- color: #ffffff;
108
- font-weight: 500;
109
- font-size: 15px;
110
- }
111
-
112
- .pBtnCancel {
113
- width: 120px;
114
- height: 44px;
115
- line-height: 44px;
116
- border-radius: 8px;
117
- background: rgba(224, 237, 255, 1);
118
- color: rgba(18, 103, 232, 1);
119
- font-weight: 500;
120
- font-size: 15px;
121
- }
122
- }
123
- }
124
- }
125
-
126
- button::after {
127
- border: none;
128
- }
129
- </style>
@@ -1,51 +0,0 @@
1
- import type ToastOptions from "../components/hy-toast/typing";
2
- import { error } from "@/package";
3
-
4
- // 用于缓存全局唯一实例
5
- let toastInstance: any = null;
6
-
7
- /**
8
- * useToast 适用于任意页面直接调用 toast
9
- * 兼容 H5 + 微信小程序 + App
10
- */
11
- export const useToast = () => {
12
- // 如果已经有实例,直接复用
13
- if (toastInstance) return toastInstance;
14
-
15
- const info = (msg: string, opt?: ToastOptions) =>
16
- createToast({ message: msg, type: "info", ...opt });
17
- const success = (msg: string, opt?: ToastOptions) =>
18
- createToast({ message: msg, type: "success", ...opt });
19
- const error = (msg: string, opt?: ToastOptions) =>
20
- createToast({ message: msg, type: "error", ...opt });
21
- const warning = (msg: string, opt?: ToastOptions) =>
22
- createToast({ message: msg, type: "warning", ...opt });
23
- const primary = (msg: string, opt?: ToastOptions) =>
24
- createToast({ message: msg, type: "primary", ...opt });
25
- const loading = (msg: string, opt?: ToastOptions) =>
26
- createToast({ message: msg, loading: true, ...opt });
27
- const close = (all?: boolean) => {
28
- if (toastInstance && toastInstance.hide) toastInstance.hide();
29
- };
30
-
31
- return { info, success, error, warning, primary, loading, close };
32
- };
33
-
34
- /**
35
- * ✅ 实现
36
- * 由于小程序不支持动态 mount vue 组件
37
- * 所以需要依赖页面上放置 <HyToast ref="toastRef" /> 元素
38
- */
39
- function createToast(options: ToastOptions) {
40
- const pages = getCurrentPages();
41
- const currentPage = pages[pages.length - 1];
42
- const vm = currentPage.$vm || currentPage;
43
-
44
- // 确保页面有 ref="toastRef" 的 hy-toast
45
- if (vm?.$refs?.toastRef) {
46
- vm.$refs.toastRef.show(options);
47
- toastInstance = vm.$refs.toastRef;
48
- } else {
49
- error('[useToast] 请在页面 template 中添加 <HyToast ref="toastRef" />');
50
- }
51
- }
@@ -1,17 +0,0 @@
1
- export interface ResultParam {
2
- confirm: boolean; // 为 true 时,表示用户点击了确定按钮
3
- cancel: boolean; // 为 true 时,表示用户点击了取消
4
- }
5
-
6
- export interface DialogParam {
7
- icon?: string;
8
- title?: string;
9
- content?: string;
10
- confirmText?: string;
11
- cancelText?: string;
12
- shape?: "circle" | "square";
13
- confirmColor?: string;
14
- cancelColor?: string;
15
- showCancel?: boolean;
16
- result?: Function; // 回调用户操作结果
17
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes