hy-app 0.6.4 → 0.6.6
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/attributes.json +1 -1
- package/components/hy-address-picker/hy-address-picker.vue +249 -249
- package/components/hy-address-picker/props.ts +103 -103
- package/components/hy-button/hy-button.vue +320 -289
- package/components/hy-button/props.ts +143 -143
- package/components/hy-button/typing.d.ts +43 -35
- package/components/hy-calendar/header.vue +58 -58
- package/components/hy-calendar/hy-calendar.vue +8 -6
- package/components/hy-calendar/month.vue +402 -402
- package/components/hy-calendar/props.ts +169 -169
- package/components/hy-calendar/typing.d.ts +47 -45
- package/components/hy-cell-item/hy-cell-item.vue +161 -161
- package/components/hy-cell-item/props.ts +59 -59
- package/components/hy-check-button/hy-check-button.vue +135 -135
- package/components/hy-code-input/hy-code-input.vue +231 -231
- package/components/hy-code-input/props.ts +90 -90
- package/components/hy-config-provider/hy-config-provider.vue +53 -53
- package/components/hy-config-provider/props.ts +30 -30
- package/components/hy-coupon/hy-coupon.vue +183 -183
- package/components/hy-coupon/props.ts +108 -108
- package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
- package/components/hy-datetime-picker/props.ts +144 -144
- package/components/hy-datetime-picker/typing.d.ts +2 -0
- package/components/hy-divider/props.ts +83 -83
- package/components/hy-empty/icon.ts +72 -72
- package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
- package/components/hy-form/hy-form.vue +220 -220
- package/components/hy-icon/hy-icon.vue +112 -112
- package/components/hy-index-bar/hy-index-bar.vue +185 -185
- package/components/hy-index-bar/index.scss +64 -64
- package/components/hy-index-bar/props.ts +94 -94
- package/components/hy-index-bar/typing.d.ts +36 -36
- package/components/hy-input/hy-input.vue +333 -333
- package/components/hy-input/props.ts +186 -186
- package/components/hy-modal/hy-modal.vue +211 -211
- package/components/hy-modal/props.ts +94 -94
- package/components/hy-modal/typing.d.ts +16 -16
- package/components/hy-notice-bar/hy-row-notice.vue +121 -121
- package/components/hy-notify/hy-notify.vue +174 -174
- package/components/hy-number-step/hy-number-step.vue +367 -367
- package/components/hy-overlay/hy-overlay.vue +61 -61
- package/components/hy-overlay/props.ts +38 -38
- package/components/hy-pagination/hy-pagination.vue +136 -136
- package/components/hy-pagination/props.ts +58 -58
- package/components/hy-parse/hy-parse.vue +550 -550
- package/components/hy-parse/node/node.vue +781 -781
- package/components/hy-parse/parser.js +1455 -1455
- package/components/hy-parse/props.ts +19 -19
- package/components/hy-parse/typing.d.ts +68 -68
- package/components/hy-picker/hy-picker.vue +435 -435
- package/components/hy-picker/props.ts +122 -122
- package/components/hy-picker/typing.d.ts +38 -38
- package/components/hy-qrcode/props.ts +72 -72
- package/components/hy-qrcode/qrcode.js.bak +1433 -1433
- package/components/hy-radio/props.ts +97 -97
- package/components/hy-read-more/props.ts +48 -48
- package/components/hy-search/props.ts +133 -133
- package/components/hy-signature/canvasHelper.ts +51 -51
- package/components/hy-signature/props.ts +121 -121
- package/components/hy-skeleton/hy-skeleton.vue +142 -142
- package/components/hy-skeleton/props.ts +46 -46
- package/components/hy-skeleton/typing.d.ts +31 -31
- package/components/hy-steps/hy-steps.vue +275 -275
- package/components/hy-steps/typing.d.ts +25 -25
- package/components/hy-swiper/hy-swiper.vue +3 -3
- package/components/hy-swiper/index.scss +5 -5
- package/components/hy-swiper/props.ts +0 -1
- package/components/hy-table/hy-table.vue +630 -630
- package/components/hy-table/props.ts +62 -62
- package/components/hy-table/typing.d.ts +29 -29
- package/components/hy-tabs/hy-tabs.vue +336 -335
- package/components/hy-tabs/props.ts +84 -77
- package/components/hy-tag/hy-tag.vue +173 -173
- package/components/hy-tag/props.ts +89 -89
- package/components/hy-text/hy-text.vue +237 -237
- package/components/hy-text/props.ts +115 -115
- package/components/hy-textarea/hy-textarea.vue +198 -198
- package/components/hy-toast/hy-toast.vue +200 -200
- package/components/hy-toast/props.ts +3 -3
- package/components/hy-transition/hy-transition.vue +157 -157
- package/components/hy-transition/props.ts +32 -32
- package/components/hy-upload/hy-upload.vue +384 -384
- package/components/hy-watermark/hy-watermark.vue +1058 -1058
- package/components/hy-watermark/props.ts +109 -109
- package/global.d.ts +94 -94
- package/libs/api/http.ts +119 -119
- package/libs/composables/index.ts +8 -8
- package/libs/composables/useMessage.ts +149 -149
- package/libs/composables/useToast.ts +45 -45
- package/libs/composables/useTranslate.ts +10 -10
- package/libs/css/_config.scss +5 -5
- package/libs/index.ts +8 -8
- package/libs/locale/index.ts +32 -32
- package/libs/locale/lang/en-US.ts +84 -84
- package/libs/locale/lang/zh-CN.ts +87 -87
- package/libs/typing/index.ts +2 -2
- package/libs/typing/modules/common.d.ts +139 -139
- package/libs/typing/modules/form.ts +176 -176
- package/libs/typing/modules/http.d.ts +19 -19
- package/libs/typing/modules/index.d.ts +12 -12
- package/libs/utils/inside.ts +340 -340
- package/libs/utils/inspect.ts +140 -140
- package/libs/utils/utils.ts +525 -525
- package/package.json +81 -81
- package/tags.json +1 -1
- package/web-types.json +1 -1
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<HyPopup
|
|
3
|
-
mode="center"
|
|
4
|
-
:zoom="modalOptions.zoom || zoom"
|
|
5
|
-
:show="showModal"
|
|
6
|
-
:round="modalOptions.round || round"
|
|
7
|
-
:customStyle="{
|
|
8
|
-
overflow: 'hidden',
|
|
9
|
-
marginTop: `-${addUnit(modalOptions.negativeTop || negativeTop)}`
|
|
10
|
-
}"
|
|
11
|
-
:closeOnClickOverlay="modalOptions.closeOnClickOverlay || closeOnClickOverlay"
|
|
12
|
-
:safeAreaInsetBottom="false"
|
|
13
|
-
:duration="400"
|
|
14
|
-
@click="clickHandler"
|
|
15
|
-
>
|
|
16
|
-
<view
|
|
17
|
-
class="hy-modal"
|
|
18
|
-
:style="{
|
|
19
|
-
width: addUnit(modalOptions.width || width)
|
|
20
|
-
}"
|
|
21
|
-
>
|
|
22
|
-
<view class="hy-modal__title" v-if="modalOptions.title || title">{{
|
|
23
|
-
modalOptions.title || title
|
|
24
|
-
}}</view>
|
|
25
|
-
<view
|
|
26
|
-
class="hy-modal__content"
|
|
27
|
-
:style="{
|
|
28
|
-
paddingTop: `${modalOptions.title || title ? 12 : 25}px`,
|
|
29
|
-
textAlign: modalOptions.contentTextAlign
|
|
30
|
-
}"
|
|
31
|
-
>
|
|
32
|
-
<slot v-if="$slots.default"></slot>
|
|
33
|
-
<text v-else class="hy-modal__content--text">
|
|
34
|
-
{{ modalOptions.content || content }}
|
|
35
|
-
</text>
|
|
36
|
-
</view>
|
|
37
|
-
<view class="hy-modal__button--group__confirm-button" v-if="$slots.confirmButton">
|
|
38
|
-
<slot name="confirmButton"></slot>
|
|
39
|
-
</view>
|
|
40
|
-
<template v-else>
|
|
41
|
-
<view
|
|
42
|
-
:class="[
|
|
43
|
-
'hy-modal__button--group',
|
|
44
|
-
(modalOptions.showCancelButton || showCancelButton) &&
|
|
45
|
-
(modalOptions.showConfirmButton || showConfirmButton) &&
|
|
46
|
-
(!(modalOptions.buttonReverse || buttonReverse)
|
|
47
|
-
? 'hy-modal__button--exact'
|
|
48
|
-
: 'hy-modal__button--exact--reverse')
|
|
49
|
-
]"
|
|
50
|
-
:style="{
|
|
51
|
-
flexDirection:
|
|
52
|
-
modalOptions.buttonReverse || buttonReverse ? 'row-reverse' : 'row'
|
|
53
|
-
}"
|
|
54
|
-
>
|
|
55
|
-
<view
|
|
56
|
-
class="hy-modal__button--group__wrapper first hy-modal__button--group__wrapper--cancel"
|
|
57
|
-
:hover-stay-time="150"
|
|
58
|
-
hover-class="hy-modal__button--group__wrapper--hover"
|
|
59
|
-
v-if="modalOptions.showCancelButton || showCancelButton"
|
|
60
|
-
@tap.stop="cancelHandler"
|
|
61
|
-
>
|
|
62
|
-
<text
|
|
63
|
-
class="hy-modal__button--group__wrapper--text hy-modal__button--group__wrapper--cancel__text"
|
|
64
|
-
:style="{
|
|
65
|
-
color: modalOptions.cancelColor || cancelColor
|
|
66
|
-
}"
|
|
67
|
-
>
|
|
68
|
-
{{ modalOptions.cancelText || cancelText }}
|
|
69
|
-
</text>
|
|
70
|
-
</view>
|
|
71
|
-
<view
|
|
72
|
-
class="hy-modal__button--group__wrapper last hy-modal__button--group__wrapper--confirm"
|
|
73
|
-
:hover-stay-time="150"
|
|
74
|
-
hover-class="hy-modal__button--group__wrapper--hover"
|
|
75
|
-
v-if="modalOptions.showConfirmButton || showConfirmButton"
|
|
76
|
-
@tap="confirmHandler"
|
|
77
|
-
>
|
|
78
|
-
<hy-loading v-if="modalLoading" mode="circle"></hy-loading>
|
|
79
|
-
<text
|
|
80
|
-
v-else
|
|
81
|
-
class="hy-modal__button--group__wrapper--text hy-modal__button--group__wrapper--confirm__text"
|
|
82
|
-
:style="{
|
|
83
|
-
color: modalOptions.confirmColor || confirmColor
|
|
84
|
-
}"
|
|
85
|
-
>
|
|
86
|
-
{{ modalOptions.confirmText || confirmText }}
|
|
87
|
-
</text>
|
|
88
|
-
</view>
|
|
89
|
-
</view>
|
|
90
|
-
</template>
|
|
91
|
-
</view>
|
|
92
|
-
</HyPopup>
|
|
93
|
-
</template>
|
|
94
|
-
|
|
95
|
-
<script lang="ts">
|
|
96
|
-
export default {
|
|
97
|
-
name: 'hy-modal',
|
|
98
|
-
options: {
|
|
99
|
-
addGlobalClass: true,
|
|
100
|
-
virtualHost: true,
|
|
101
|
-
styleIsolation: 'shared'
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
</script>
|
|
105
|
-
|
|
106
|
-
<script setup lang="ts">
|
|
107
|
-
import { ref, watch, computed } from 'vue'
|
|
108
|
-
import type { IModalEmits } from './typing'
|
|
109
|
-
import { addUnit, sleep, useMessageInject } from '../../libs'
|
|
110
|
-
import modalProps from './props'
|
|
111
|
-
// 组件
|
|
112
|
-
import HyPopup from '../hy-popup/hy-popup.vue'
|
|
113
|
-
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 弹出模态框,常用于消息提示、消息确认、在当前页面内完成特定的交互操作。
|
|
117
|
-
* @displayName hy-modal
|
|
118
|
-
*/
|
|
119
|
-
defineOptions({})
|
|
120
|
-
|
|
121
|
-
const props = defineProps(modalProps)
|
|
122
|
-
const emit = defineEmits<IModalEmits>()
|
|
123
|
-
const load = ref(props.loading)
|
|
124
|
-
|
|
125
|
-
// 尝试从 useMessage 注入状态
|
|
126
|
-
const messageState = useMessageInject()
|
|
127
|
-
|
|
128
|
-
// 计算属性,优先使用注入的状态
|
|
129
|
-
const showModal = computed(() => {
|
|
130
|
-
return messageState?.showModal.value || props.modelValue
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
const modalLoading = computed(() => {
|
|
134
|
-
return messageState?.loading.value || props.loading
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
const modalOptions = computed(() => {
|
|
138
|
-
return messageState?.modalOptions || {}
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
watch(
|
|
142
|
-
() => props.loading,
|
|
143
|
-
() => {
|
|
144
|
-
load.value = props.loading
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
watch(
|
|
149
|
-
() => props.modelValue,
|
|
150
|
-
(newVal) => {
|
|
151
|
-
if (!newVal) load.value = false
|
|
152
|
-
}
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* 点击确定按钮
|
|
157
|
-
* */
|
|
158
|
-
const confirmHandler = async () => {
|
|
159
|
-
if (modalLoading.value) return
|
|
160
|
-
|
|
161
|
-
// 优先使用注入的确认处理
|
|
162
|
-
if (messageState?.confirmHandler) {
|
|
163
|
-
messageState.confirmHandler()
|
|
164
|
-
} else {
|
|
165
|
-
// 如果配置了异步关闭,将按钮值为loading状态
|
|
166
|
-
emit('confirm')
|
|
167
|
-
|
|
168
|
-
await sleep()
|
|
169
|
-
if (!props.loading && props.autoClose) {
|
|
170
|
-
emit('update:modelValue', false)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* 点击取消按钮
|
|
177
|
-
* */
|
|
178
|
-
const cancelHandler = () => {
|
|
179
|
-
// 优先使用注入的取消处理
|
|
180
|
-
if (messageState?.cancelHandler) {
|
|
181
|
-
messageState.cancelHandler()
|
|
182
|
-
} else {
|
|
183
|
-
emit('update:modelValue', false)
|
|
184
|
-
emit('cancel')
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* 点击遮罩
|
|
190
|
-
* */
|
|
191
|
-
const clickHandler = () => {
|
|
192
|
-
const closeOnClickOverlay = modalOptions.value.closeOnClickOverlay || props.closeOnClickOverlay
|
|
193
|
-
|
|
194
|
-
if (closeOnClickOverlay) {
|
|
195
|
-
// 优先使用注入的关闭处理
|
|
196
|
-
if (messageState?.closeHandler) {
|
|
197
|
-
messageState.closeHandler()
|
|
198
|
-
} else {
|
|
199
|
-
emit('update:modelValue', false)
|
|
200
|
-
emit('close')
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
</script>
|
|
205
|
-
|
|
206
|
-
<style lang="scss" scoped>
|
|
207
|
-
@import './index.scss';
|
|
208
|
-
.modal__content__text {
|
|
209
|
-
text-align: v-bind(contentTextAlign);
|
|
210
|
-
}
|
|
211
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<HyPopup
|
|
3
|
+
mode="center"
|
|
4
|
+
:zoom="modalOptions.zoom || zoom"
|
|
5
|
+
:show="showModal"
|
|
6
|
+
:round="modalOptions.round || round"
|
|
7
|
+
:customStyle="{
|
|
8
|
+
overflow: 'hidden',
|
|
9
|
+
marginTop: `-${addUnit(modalOptions.negativeTop || negativeTop)}`
|
|
10
|
+
}"
|
|
11
|
+
:closeOnClickOverlay="modalOptions.closeOnClickOverlay || closeOnClickOverlay"
|
|
12
|
+
:safeAreaInsetBottom="false"
|
|
13
|
+
:duration="400"
|
|
14
|
+
@click="clickHandler"
|
|
15
|
+
>
|
|
16
|
+
<view
|
|
17
|
+
class="hy-modal"
|
|
18
|
+
:style="{
|
|
19
|
+
width: addUnit(modalOptions.width || width)
|
|
20
|
+
}"
|
|
21
|
+
>
|
|
22
|
+
<view class="hy-modal__title" v-if="modalOptions.title || title">{{
|
|
23
|
+
modalOptions.title || title
|
|
24
|
+
}}</view>
|
|
25
|
+
<view
|
|
26
|
+
class="hy-modal__content"
|
|
27
|
+
:style="{
|
|
28
|
+
paddingTop: `${modalOptions.title || title ? 12 : 25}px`,
|
|
29
|
+
textAlign: modalOptions.contentTextAlign
|
|
30
|
+
}"
|
|
31
|
+
>
|
|
32
|
+
<slot v-if="$slots.default"></slot>
|
|
33
|
+
<text v-else class="hy-modal__content--text">
|
|
34
|
+
{{ modalOptions.content || content }}
|
|
35
|
+
</text>
|
|
36
|
+
</view>
|
|
37
|
+
<view class="hy-modal__button--group__confirm-button" v-if="$slots.confirmButton">
|
|
38
|
+
<slot name="confirmButton"></slot>
|
|
39
|
+
</view>
|
|
40
|
+
<template v-else>
|
|
41
|
+
<view
|
|
42
|
+
:class="[
|
|
43
|
+
'hy-modal__button--group',
|
|
44
|
+
(modalOptions.showCancelButton || showCancelButton) &&
|
|
45
|
+
(modalOptions.showConfirmButton || showConfirmButton) &&
|
|
46
|
+
(!(modalOptions.buttonReverse || buttonReverse)
|
|
47
|
+
? 'hy-modal__button--exact'
|
|
48
|
+
: 'hy-modal__button--exact--reverse')
|
|
49
|
+
]"
|
|
50
|
+
:style="{
|
|
51
|
+
flexDirection:
|
|
52
|
+
modalOptions.buttonReverse || buttonReverse ? 'row-reverse' : 'row'
|
|
53
|
+
}"
|
|
54
|
+
>
|
|
55
|
+
<view
|
|
56
|
+
class="hy-modal__button--group__wrapper first hy-modal__button--group__wrapper--cancel"
|
|
57
|
+
:hover-stay-time="150"
|
|
58
|
+
hover-class="hy-modal__button--group__wrapper--hover"
|
|
59
|
+
v-if="modalOptions.showCancelButton || showCancelButton"
|
|
60
|
+
@tap.stop="cancelHandler"
|
|
61
|
+
>
|
|
62
|
+
<text
|
|
63
|
+
class="hy-modal__button--group__wrapper--text hy-modal__button--group__wrapper--cancel__text"
|
|
64
|
+
:style="{
|
|
65
|
+
color: modalOptions.cancelColor || cancelColor
|
|
66
|
+
}"
|
|
67
|
+
>
|
|
68
|
+
{{ modalOptions.cancelText || cancelText }}
|
|
69
|
+
</text>
|
|
70
|
+
</view>
|
|
71
|
+
<view
|
|
72
|
+
class="hy-modal__button--group__wrapper last hy-modal__button--group__wrapper--confirm"
|
|
73
|
+
:hover-stay-time="150"
|
|
74
|
+
hover-class="hy-modal__button--group__wrapper--hover"
|
|
75
|
+
v-if="modalOptions.showConfirmButton || showConfirmButton"
|
|
76
|
+
@tap="confirmHandler"
|
|
77
|
+
>
|
|
78
|
+
<hy-loading v-if="modalLoading" mode="circle"></hy-loading>
|
|
79
|
+
<text
|
|
80
|
+
v-else
|
|
81
|
+
class="hy-modal__button--group__wrapper--text hy-modal__button--group__wrapper--confirm__text"
|
|
82
|
+
:style="{
|
|
83
|
+
color: modalOptions.confirmColor || confirmColor
|
|
84
|
+
}"
|
|
85
|
+
>
|
|
86
|
+
{{ modalOptions.confirmText || confirmText }}
|
|
87
|
+
</text>
|
|
88
|
+
</view>
|
|
89
|
+
</view>
|
|
90
|
+
</template>
|
|
91
|
+
</view>
|
|
92
|
+
</HyPopup>
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<script lang="ts">
|
|
96
|
+
export default {
|
|
97
|
+
name: 'hy-modal',
|
|
98
|
+
options: {
|
|
99
|
+
addGlobalClass: true,
|
|
100
|
+
virtualHost: true,
|
|
101
|
+
styleIsolation: 'shared'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<script setup lang="ts">
|
|
107
|
+
import { ref, watch, computed } from 'vue'
|
|
108
|
+
import type { IModalEmits } from './typing'
|
|
109
|
+
import { addUnit, sleep, useMessageInject } from '../../libs'
|
|
110
|
+
import modalProps from './props'
|
|
111
|
+
// 组件
|
|
112
|
+
import HyPopup from '../hy-popup/hy-popup.vue'
|
|
113
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 弹出模态框,常用于消息提示、消息确认、在当前页面内完成特定的交互操作。
|
|
117
|
+
* @displayName hy-modal
|
|
118
|
+
*/
|
|
119
|
+
defineOptions({})
|
|
120
|
+
|
|
121
|
+
const props = defineProps(modalProps)
|
|
122
|
+
const emit = defineEmits<IModalEmits>()
|
|
123
|
+
const load = ref(props.loading)
|
|
124
|
+
|
|
125
|
+
// 尝试从 useMessage 注入状态
|
|
126
|
+
const messageState = useMessageInject()
|
|
127
|
+
|
|
128
|
+
// 计算属性,优先使用注入的状态
|
|
129
|
+
const showModal = computed(() => {
|
|
130
|
+
return messageState?.showModal.value || props.modelValue
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
const modalLoading = computed(() => {
|
|
134
|
+
return messageState?.loading.value || props.loading
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
const modalOptions = computed(() => {
|
|
138
|
+
return messageState?.modalOptions || {}
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
watch(
|
|
142
|
+
() => props.loading,
|
|
143
|
+
() => {
|
|
144
|
+
load.value = props.loading
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
watch(
|
|
149
|
+
() => props.modelValue,
|
|
150
|
+
(newVal) => {
|
|
151
|
+
if (!newVal) load.value = false
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 点击确定按钮
|
|
157
|
+
* */
|
|
158
|
+
const confirmHandler = async () => {
|
|
159
|
+
if (modalLoading.value) return
|
|
160
|
+
|
|
161
|
+
// 优先使用注入的确认处理
|
|
162
|
+
if (messageState?.confirmHandler) {
|
|
163
|
+
messageState.confirmHandler()
|
|
164
|
+
} else {
|
|
165
|
+
// 如果配置了异步关闭,将按钮值为loading状态
|
|
166
|
+
emit('confirm')
|
|
167
|
+
|
|
168
|
+
await sleep()
|
|
169
|
+
if (!props.loading && props.autoClose) {
|
|
170
|
+
emit('update:modelValue', false)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 点击取消按钮
|
|
177
|
+
* */
|
|
178
|
+
const cancelHandler = () => {
|
|
179
|
+
// 优先使用注入的取消处理
|
|
180
|
+
if (messageState?.cancelHandler) {
|
|
181
|
+
messageState.cancelHandler()
|
|
182
|
+
} else {
|
|
183
|
+
emit('update:modelValue', false)
|
|
184
|
+
emit('cancel')
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 点击遮罩
|
|
190
|
+
* */
|
|
191
|
+
const clickHandler = () => {
|
|
192
|
+
const closeOnClickOverlay = modalOptions.value.closeOnClickOverlay || props.closeOnClickOverlay
|
|
193
|
+
|
|
194
|
+
if (closeOnClickOverlay) {
|
|
195
|
+
// 优先使用注入的关闭处理
|
|
196
|
+
if (messageState?.closeHandler) {
|
|
197
|
+
messageState.closeHandler()
|
|
198
|
+
} else {
|
|
199
|
+
emit('update:modelValue', false)
|
|
200
|
+
emit('close')
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
</script>
|
|
205
|
+
|
|
206
|
+
<style lang="scss" scoped>
|
|
207
|
+
@import './index.scss';
|
|
208
|
+
.modal__content__text {
|
|
209
|
+
text-align: v-bind(contentTextAlign);
|
|
210
|
+
}
|
|
211
|
+
</style>
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { useTranslate } from '../../libs'
|
|
2
|
-
|
|
3
|
-
const { t } = useTranslate('modal')
|
|
4
|
-
|
|
5
|
-
const modalProps = {
|
|
6
|
-
/** 是否显示模态框 */
|
|
7
|
-
modelValue: {
|
|
8
|
-
type: Boolean,
|
|
9
|
-
default: false
|
|
10
|
-
},
|
|
11
|
-
/** 标题内容 */
|
|
12
|
-
title: String,
|
|
13
|
-
/** 模态框内容,如传入slot内容,则此参数无效 */
|
|
14
|
-
content: String,
|
|
15
|
-
/** 确认按钮的文字 */
|
|
16
|
-
confirmText: {
|
|
17
|
-
type: String,
|
|
18
|
-
default: () => t('confirm')
|
|
19
|
-
},
|
|
20
|
-
/** 取消按钮的文字 */
|
|
21
|
-
cancelText: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: () => t('cancel')
|
|
24
|
-
},
|
|
25
|
-
/** 是否显示确认按钮 */
|
|
26
|
-
showConfirmButton: {
|
|
27
|
-
type: Boolean,
|
|
28
|
-
default: true
|
|
29
|
-
},
|
|
30
|
-
/** 是否显示取消按钮 */
|
|
31
|
-
showCancelButton: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: false
|
|
34
|
-
},
|
|
35
|
-
/** 确认按钮的颜色 */
|
|
36
|
-
confirmColor: String,
|
|
37
|
-
/** 取消按钮的颜色 */
|
|
38
|
-
cancelColor: String,
|
|
39
|
-
/** 对调确认和取消的位置 */
|
|
40
|
-
buttonReverse: {
|
|
41
|
-
type: Boolean,
|
|
42
|
-
default: false
|
|
43
|
-
},
|
|
44
|
-
/** 是否开启缩放模式 */
|
|
45
|
-
zoom: {
|
|
46
|
-
type: Boolean,
|
|
47
|
-
default: true
|
|
48
|
-
},
|
|
49
|
-
/** 弹窗的圆角 */
|
|
50
|
-
round: {
|
|
51
|
-
type: [String, Number],
|
|
52
|
-
default: 16
|
|
53
|
-
},
|
|
54
|
-
/** 点击确认按钮自动关闭 */
|
|
55
|
-
autoClose: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: true
|
|
58
|
-
},
|
|
59
|
-
/** 加载按钮 */
|
|
60
|
-
loading: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
default: false
|
|
63
|
-
},
|
|
64
|
-
/** 是否允许点击遮罩关闭Modal */
|
|
65
|
-
closeOnClickOverlay: {
|
|
66
|
-
type: Boolean,
|
|
67
|
-
default: false
|
|
68
|
-
},
|
|
69
|
-
/** 往上偏移的值,给一个负的margin-top,往上偏移,避免和键盘重合的情况,单位任意,数值则默认为px单位 */
|
|
70
|
-
negativeTop: {
|
|
71
|
-
type: Number,
|
|
72
|
-
default: 0
|
|
73
|
-
},
|
|
74
|
-
/** modal宽度,不支持百分比,可以数值,px,rpx单位 */
|
|
75
|
-
width: {
|
|
76
|
-
type: [String, Number],
|
|
77
|
-
default: '550rpx'
|
|
78
|
-
},
|
|
79
|
-
/**
|
|
80
|
-
* 确认按钮的样式,如设置,将不会显示取消按钮
|
|
81
|
-
* @values circle,square
|
|
82
|
-
* */
|
|
83
|
-
confirmButtonShape: String,
|
|
84
|
-
/**
|
|
85
|
-
* 文案对齐方式
|
|
86
|
-
* @values left,center,right
|
|
87
|
-
* */
|
|
88
|
-
contentTextAlign: {
|
|
89
|
-
type: String,
|
|
90
|
-
default: 'left'
|
|
91
|
-
}
|
|
92
|
-
} as const
|
|
93
|
-
|
|
94
|
-
export default modalProps
|
|
1
|
+
import { useTranslate } from '../../libs'
|
|
2
|
+
|
|
3
|
+
const { t } = useTranslate('modal')
|
|
4
|
+
|
|
5
|
+
const modalProps = {
|
|
6
|
+
/** 是否显示模态框 */
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false
|
|
10
|
+
},
|
|
11
|
+
/** 标题内容 */
|
|
12
|
+
title: String,
|
|
13
|
+
/** 模态框内容,如传入slot内容,则此参数无效 */
|
|
14
|
+
content: String,
|
|
15
|
+
/** 确认按钮的文字 */
|
|
16
|
+
confirmText: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: () => t('confirm')
|
|
19
|
+
},
|
|
20
|
+
/** 取消按钮的文字 */
|
|
21
|
+
cancelText: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: () => t('cancel')
|
|
24
|
+
},
|
|
25
|
+
/** 是否显示确认按钮 */
|
|
26
|
+
showConfirmButton: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: true
|
|
29
|
+
},
|
|
30
|
+
/** 是否显示取消按钮 */
|
|
31
|
+
showCancelButton: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
/** 确认按钮的颜色 */
|
|
36
|
+
confirmColor: String,
|
|
37
|
+
/** 取消按钮的颜色 */
|
|
38
|
+
cancelColor: String,
|
|
39
|
+
/** 对调确认和取消的位置 */
|
|
40
|
+
buttonReverse: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
/** 是否开启缩放模式 */
|
|
45
|
+
zoom: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: true
|
|
48
|
+
},
|
|
49
|
+
/** 弹窗的圆角 */
|
|
50
|
+
round: {
|
|
51
|
+
type: [String, Number],
|
|
52
|
+
default: 16
|
|
53
|
+
},
|
|
54
|
+
/** 点击确认按钮自动关闭 */
|
|
55
|
+
autoClose: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true
|
|
58
|
+
},
|
|
59
|
+
/** 加载按钮 */
|
|
60
|
+
loading: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false
|
|
63
|
+
},
|
|
64
|
+
/** 是否允许点击遮罩关闭Modal */
|
|
65
|
+
closeOnClickOverlay: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false
|
|
68
|
+
},
|
|
69
|
+
/** 往上偏移的值,给一个负的margin-top,往上偏移,避免和键盘重合的情况,单位任意,数值则默认为px单位 */
|
|
70
|
+
negativeTop: {
|
|
71
|
+
type: Number,
|
|
72
|
+
default: 0
|
|
73
|
+
},
|
|
74
|
+
/** modal宽度,不支持百分比,可以数值,px,rpx单位 */
|
|
75
|
+
width: {
|
|
76
|
+
type: [String, Number],
|
|
77
|
+
default: '550rpx'
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* 确认按钮的样式,如设置,将不会显示取消按钮
|
|
81
|
+
* @values circle,square
|
|
82
|
+
* */
|
|
83
|
+
confirmButtonShape: String,
|
|
84
|
+
/**
|
|
85
|
+
* 文案对齐方式
|
|
86
|
+
* @values left,center,right
|
|
87
|
+
* */
|
|
88
|
+
contentTextAlign: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: 'left'
|
|
91
|
+
}
|
|
92
|
+
} as const
|
|
93
|
+
|
|
94
|
+
export default modalProps
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { ExtractPropTypes } from 'vue'
|
|
2
|
-
import modalProps from '@/package/components/hy-modal/props'
|
|
3
|
-
|
|
4
|
-
export interface HyModalProps extends ExtractPropTypes<typeof modalProps> {}
|
|
5
|
-
|
|
6
|
-
export interface IModalEmits {
|
|
7
|
-
/** 点击确认按钮时触发 */
|
|
8
|
-
(e: 'confirm'): void
|
|
9
|
-
/** 点击取消按钮时触发 */
|
|
10
|
-
(e: 'cancel'): void
|
|
11
|
-
/** 点击遮罩关闭时触发 */
|
|
12
|
-
(e: 'close'): void
|
|
13
|
-
/** 更新值触发 */
|
|
14
|
-
(e: 'update:modelValue', show: boolean): void
|
|
15
|
-
(e: 'update:loading', show: boolean): void
|
|
16
|
-
}
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import modalProps from '@/package/components/hy-modal/props'
|
|
3
|
+
|
|
4
|
+
export interface HyModalProps extends ExtractPropTypes<typeof modalProps> {}
|
|
5
|
+
|
|
6
|
+
export interface IModalEmits {
|
|
7
|
+
/** 点击确认按钮时触发 */
|
|
8
|
+
(e: 'confirm'): void
|
|
9
|
+
/** 点击取消按钮时触发 */
|
|
10
|
+
(e: 'cancel'): void
|
|
11
|
+
/** 点击遮罩关闭时触发 */
|
|
12
|
+
(e: 'close'): void
|
|
13
|
+
/** 更新值触发 */
|
|
14
|
+
(e: 'update:modelValue', show: boolean): void
|
|
15
|
+
(e: 'update:loading', show: boolean): void
|
|
16
|
+
}
|