hy-app 0.2.13 → 0.2.15
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/components/hy-action-sheet/hy-action-sheet.vue +81 -13
- package/components/hy-action-sheet/typing.d.ts +1 -3
- package/components/hy-address-picker/hy-address-picker.vue +109 -8
- package/components/hy-address-picker/index.scss +2 -2
- package/components/hy-address-picker/typing.d.ts +39 -30
- package/components/hy-avatar/hy-avatar.vue +78 -4
- package/components/hy-avatar/typing.d.ts +21 -16
- package/components/hy-back-top/hy-back-top.vue +86 -28
- package/components/hy-back-top/typing.d.ts +17 -12
- package/components/hy-badge/hy-badge.vue +114 -43
- package/components/hy-badge/typing.d.ts +20 -15
- package/components/hy-button/HyButton.docgen.js +6 -0
- package/components/hy-button/hy-button.vue +70 -77
- package/components/hy-button/props.ts +40 -41
- package/components/hy-calendar/hy-calendar.vue +290 -143
- package/components/hy-calendar/typing.d.ts +38 -31
- package/components/hy-card/hy-card.vue +139 -36
- package/components/hy-card/typing.d.ts +39 -28
- package/components/hy-cell/hy-cell.vue +131 -67
- package/components/hy-cell/typing.d.ts +6 -1
- package/components/hy-check-button/hy-check-button.vue +101 -32
- package/components/hy-check-button/typing.d.ts +26 -19
- package/components/hy-checkbox/hy-checkbox.vue +167 -78
- package/components/hy-checkbox/typing.d.ts +26 -19
- package/components/hy-code-input/hy-code-input.vue +101 -5
- package/components/hy-code-input/typing.d.ts +9 -0
- package/components/hy-config-provider/hy-config-provider.vue +44 -24
- package/components/hy-config-provider/typing.d.ts +0 -4
- package/components/hy-count-down/hy-count-down.vue +99 -62
- package/components/hy-count-down/typing.d.ts +18 -5
- package/components/hy-count-to/hy-count-to.vue +165 -113
- package/components/hy-count-to/typing.d.ts +15 -11
- package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
- package/components/hy-datetime-picker/typing.d.ts +49 -39
- package/components/hy-divider/hy-divider.vue +128 -64
- package/components/hy-divider/typing.d.ts +16 -16
- package/components/hy-dropdown/hy-dropdown.vue +57 -19
- package/components/hy-dropdown/typing.d.ts +14 -14
- package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
- package/components/hy-dropdown-item/typing.d.ts +13 -6
- package/components/hy-empty/hy-empty.vue +64 -6
- package/components/hy-empty/typing.d.ts +5 -0
- package/components/hy-float-button/hy-float-button.vue +117 -5
- package/components/hy-float-button/typing.d.ts +7 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
- package/components/hy-folding-panel/typing.d.ts +24 -15
- package/components/hy-grid/hy-grid.vue +95 -35
- package/components/hy-grid/typing.d.ts +24 -19
- package/components/hy-icon/hy-icon.vue +84 -6
- package/components/hy-icon/typing.d.ts +5 -0
- package/components/hy-image/hy-image.vue +105 -6
- package/components/hy-image/typing.d.ts +9 -0
- package/components/hy-input/hy-input.vue +277 -130
- package/components/hy-input/props.ts +13 -14
- package/components/hy-input/typing.d.ts +59 -38
- package/components/hy-line/hy-line.vue +65 -25
- package/components/hy-line-progress/hy-line-progress.vue +68 -35
- package/components/hy-list/hy-list.vue +127 -61
- package/components/hy-list/typing.d.ts +19 -12
- package/components/hy-loading/hy-loading.vue +79 -25
- package/components/hy-menu/hy-menu.vue +69 -45
- package/components/hy-menu/typing.d.ts +22 -15
- package/components/hy-modal/hy-modal.vue +91 -4
- package/components/hy-modal/typing.d.ts +11 -0
- package/components/hy-navbar/hy-navbar.vue +105 -25
- package/components/hy-navbar/typing.d.ts +25 -20
- package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
- package/components/hy-notice-bar/typing.d.ts +22 -17
- package/components/hy-notify/hy-notify.vue +106 -54
- package/components/hy-number-step/hy-number-step.vue +211 -120
- package/components/hy-number-step/typing.d.ts +45 -28
- package/components/hy-overlay/hy-overlay.vue +60 -16
- package/components/hy-overlay/typing.d.ts +11 -6
- package/components/hy-pagination/hy-pagination.vue +94 -37
- package/components/hy-pagination/typing.d.ts +20 -11
- package/components/hy-picker/hy-picker.vue +225 -160
- package/components/hy-picker/typing.d.ts +51 -28
- package/components/hy-popover/hy-popover.vue +55 -7
- package/components/hy-popover/typing.d.ts +21 -1
- package/components/hy-popup/hy-popup.vue +164 -99
- package/components/hy-popup/typing.d.ts +11 -0
- package/components/hy-price/hy-price.vue +77 -30
- package/components/hy-price/typing.d.ts +10 -10
- package/components/hy-qrcode/hy-qrcode.vue +75 -5
- package/components/hy-qrcode/typing.d.ts +25 -16
- package/components/hy-radio/hy-radio.vue +169 -88
- package/components/hy-radio/typing.d.ts +29 -22
- package/components/hy-rate/hy-rate.vue +155 -104
- package/components/hy-rate/typing.d.ts +23 -16
- package/components/hy-read-more/hy-read-more.vue +83 -56
- package/components/hy-read-more/typing.d.ts +18 -11
- package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
- package/components/hy-scroll-list/typing.d.ts +14 -7
- package/components/hy-search/hy-search.vue +168 -62
- package/components/hy-search/typing.d.ts +47 -26
- package/components/hy-signature/hy-signature.vue +354 -272
- package/components/hy-signature/typing.d.ts +65 -52
- package/components/hy-slider/hy-slider.vue +208 -160
- package/components/hy-slider/typing.d.ts +28 -17
- package/components/hy-steps/hy-steps.vue +125 -99
- package/components/hy-steps/typing.d.ts +21 -14
- package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
- package/components/hy-submit-bar/typing.d.ts +30 -23
- package/components/hy-subsection/hy-subsection.vue +139 -96
- package/components/hy-subsection/typing.d.ts +23 -16
- package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
- package/components/hy-swipe-action/typing.d.ts +26 -17
- package/components/hy-swiper/hy-swiper.vue +178 -73
- package/components/hy-swiper/typing.d.ts +37 -28
- package/components/hy-switch/hy-switch.vue +107 -60
- package/components/hy-switch/typing.d.ts +25 -18
- package/components/hy-tabs/hy-tabs.vue +170 -160
- package/components/hy-tabs/typing.d.ts +36 -22
- package/components/hy-tag/hy-tag.vue +133 -58
- package/components/hy-tag/typing.d.ts +26 -18
- package/components/hy-text/hy-text.vue +106 -6
- package/components/hy-text/typing.d.ts +31 -26
- package/components/hy-textarea/hy-textarea.vue +183 -89
- package/components/hy-textarea/typing.d.ts +41 -24
- package/components/hy-tooltip/hy-tooltip.vue +145 -101
- package/components/hy-tooltip/typing.d.ts +18 -13
- package/components/hy-transition/hy-transition.vue +48 -13
- package/components/hy-transition/typing.d.ts +17 -0
- package/components/hy-upload/hy-upload.vue +113 -148
- package/components/hy-upload/typing.d.ts +71 -71
- package/components/hy-warn/hy-warn.vue +79 -36
- package/components/hy-warn/typing.d.ts +18 -11
- package/components/hy-waterfall/hy-waterfall.vue +90 -77
- package/components/hy-watermark/hy-watermark.vue +82 -5
- package/components/hy-watermark/typing.d.ts +20 -20
- package/global.d.ts +39 -59
- package/package.json +5 -13
- package/utils/inspect.ts +3 -1
- package/web-types.json +1 -1
- package/component-helper.ts +0 -177
- package/components.json +0 -3287
- package/dist/attributes.json +0 -1
- package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
- package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
- package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
- package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
- package/dist/docs/components/hy-badge/hy-badge.md +0 -13
- package/dist/docs/components/hy-button/hy-button.md +0 -61
- package/dist/docs/components/hy-calendar/header.md +0 -17
- package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
- package/dist/docs/components/hy-calendar/month.md +0 -38
- package/dist/docs/components/hy-card/hy-card.md +0 -24
- package/dist/docs/components/hy-cell/hy-cell.md +0 -26
- package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
- package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
- package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
- package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
- package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
- package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
- package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
- package/dist/docs/components/hy-divider/hy-divider.md +0 -13
- package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
- package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
- package/dist/docs/components/hy-empty/hy-empty.md +0 -20
- package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
- package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
- package/dist/docs/components/hy-form/hy-form.md +0 -29
- package/dist/docs/components/hy-grid/hy-grid.md +0 -19
- package/dist/docs/components/hy-icon/hy-icon.md +0 -13
- package/dist/docs/components/hy-image/hy-image.md +0 -22
- package/dist/docs/components/hy-input/hy-input.md +0 -29
- package/dist/docs/components/hy-line/hy-line.md +0 -7
- package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
- package/dist/docs/components/hy-list/hy-list.md +0 -25
- package/dist/docs/components/hy-loading/hy-loading.md +0 -14
- package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
- package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
- package/dist/docs/components/hy-login/hy-login.md +0 -14
- package/dist/docs/components/hy-menu/hy-menu.md +0 -21
- package/dist/docs/components/hy-modal/hy-modal.md +0 -23
- package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
- package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
- package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
- package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
- package/dist/docs/components/hy-notify/hy-notify.md +0 -23
- package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
- package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
- package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
- package/dist/docs/components/hy-parse/hy-parse.md +0 -46
- package/dist/docs/components/hy-parse/node/node.md +0 -7
- package/dist/docs/components/hy-picker/hy-picker.md +0 -32
- package/dist/docs/components/hy-popover/hy-popover.md +0 -34
- package/dist/docs/components/hy-popup/hy-popup.md +0 -22
- package/dist/docs/components/hy-price/hy-price.md +0 -13
- package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
- package/dist/docs/components/hy-radio/hy-radio.md +0 -21
- package/dist/docs/components/hy-rate/hy-rate.md +0 -14
- package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
- package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
- package/dist/docs/components/hy-search/hy-search.md +0 -27
- package/dist/docs/components/hy-signature/hy-signature.md +0 -45
- package/dist/docs/components/hy-slider/hy-slider.md +0 -24
- package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
- package/dist/docs/components/hy-steps/hy-steps.md +0 -23
- package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
- package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
- package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
- package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
- package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
- package/dist/docs/components/hy-switch/hy-switch.md +0 -20
- package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
- package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
- package/dist/docs/components/hy-tag/hy-tag.md +0 -21
- package/dist/docs/components/hy-text/hy-text.md +0 -13
- package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
- package/dist/docs/components/hy-toast/hy-toast.md +0 -17
- package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
- package/dist/docs/components/hy-transition/hy-transition.md +0 -25
- package/dist/docs/components/hy-upload/hy-upload.md +0 -25
- package/dist/docs/components/hy-warn/hy-warn.md +0 -14
- package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
- package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
- package/dist/docs/components/message/TheMessage.md +0 -17
- package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
- package/dist/tags.json +0 -1
- package/dist/web-types.json +0 -1
- package/docgen.config.js +0 -14
- package/web-types.config.js +0 -7
|
@@ -3,39 +3,86 @@
|
|
|
3
3
|
-->
|
|
4
4
|
|
|
5
5
|
<template>
|
|
6
|
-
<text class="hy-price" :style="priceStyle" @tap="handleClick">
|
|
6
|
+
<text :class="['hy-price', customClass]" :style="priceStyle" @tap="handleClick">
|
|
7
7
|
<text class="hy-price__prefix">{{ symbol }}</text>
|
|
8
|
-
<text
|
|
9
|
-
|
|
10
|
-
:style="[{ 'font-size': addUnit(getPx(size) * ratio) }]"
|
|
11
|
-
>{{ priceOne[0] }}
|
|
8
|
+
<text class="hy-price__text" :style="[{ 'font-size': addUnit(getPx(size) * ratio) }]">
|
|
9
|
+
{{ priceOne[0] }}
|
|
12
10
|
</text>
|
|
13
11
|
<text class="hy-price__decimal">
|
|
14
|
-
{{
|
|
12
|
+
{{ '.' + priceOne[1].slice(0, num) }}
|
|
15
13
|
</text>
|
|
16
14
|
</text>
|
|
17
15
|
</template>
|
|
18
16
|
|
|
19
17
|
<script lang="ts">
|
|
18
|
+
/**
|
|
19
|
+
* 业务组件,突出金额小数点前大,小数点后小
|
|
20
|
+
* @displayName hy-price
|
|
21
|
+
*/
|
|
22
|
+
defineOptions({})
|
|
20
23
|
export default {
|
|
21
24
|
name: 'hy-price',
|
|
22
25
|
options: {
|
|
23
26
|
addGlobalClass: true,
|
|
24
27
|
virtualHost: true,
|
|
25
|
-
styleIsolation: 'shared'
|
|
26
|
-
}
|
|
28
|
+
styleIsolation: 'shared',
|
|
29
|
+
},
|
|
27
30
|
}
|
|
28
31
|
</script>
|
|
29
32
|
|
|
30
33
|
<script setup lang="ts">
|
|
31
|
-
import { computed,
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import { addUnit, getPx } from "../../utils";
|
|
34
|
+
import { computed, toRefs } from 'vue'
|
|
35
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
36
|
+
import { addUnit, getPx } from '../../utils'
|
|
35
37
|
|
|
36
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
37
|
-
const
|
|
38
|
-
|
|
38
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
39
|
+
const props = defineProps({
|
|
40
|
+
/** 传入金额值 */
|
|
41
|
+
text: String,
|
|
42
|
+
/** 金额符号 */
|
|
43
|
+
symbol: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: '¥',
|
|
46
|
+
},
|
|
47
|
+
/** 比例大小 */
|
|
48
|
+
ratio: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 1.4,
|
|
51
|
+
},
|
|
52
|
+
/** 保留小数点后几位数 */
|
|
53
|
+
num: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 2,
|
|
56
|
+
},
|
|
57
|
+
/** 字体颜色 */
|
|
58
|
+
color: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: '#FE3232',
|
|
61
|
+
},
|
|
62
|
+
/** 字体大小 */
|
|
63
|
+
size: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 12,
|
|
66
|
+
},
|
|
67
|
+
/** 字体粗细 */
|
|
68
|
+
weight: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: 500,
|
|
71
|
+
},
|
|
72
|
+
/** 是否倾斜 */
|
|
73
|
+
slant: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false,
|
|
76
|
+
},
|
|
77
|
+
/** 定义需要用到的外部样式 */
|
|
78
|
+
customStyle: {
|
|
79
|
+
type: Object as PropType<CSSProperties>,
|
|
80
|
+
},
|
|
81
|
+
/** 自定义外部类名 */
|
|
82
|
+
customClass: String,
|
|
83
|
+
})
|
|
84
|
+
const { text, color, weight, size, slant, customStyle } = toRefs(props)
|
|
85
|
+
const emit = defineEmits(['click'])
|
|
39
86
|
|
|
40
87
|
/**
|
|
41
88
|
* @description 价格整体样式
|
|
@@ -44,42 +91,42 @@ const priceStyle = computed<CSSProperties>(() => {
|
|
|
44
91
|
const style: CSSProperties = {
|
|
45
92
|
color: color.value,
|
|
46
93
|
fontWeight: weight.value,
|
|
47
|
-
fontStyle: slant.value ?
|
|
94
|
+
fontStyle: slant.value ? 'oblique' : '',
|
|
48
95
|
fontSize: addUnit(size.value),
|
|
49
|
-
}
|
|
96
|
+
}
|
|
50
97
|
|
|
51
|
-
return Object.assign(style, customStyle.value)
|
|
52
|
-
})
|
|
98
|
+
return Object.assign(style, customStyle.value)
|
|
99
|
+
})
|
|
53
100
|
|
|
54
101
|
/**
|
|
55
102
|
* @description 价格处理
|
|
56
103
|
* */
|
|
57
104
|
const priceOne = computed(() => {
|
|
58
|
-
let value =
|
|
59
|
-
if (typeof text.value !==
|
|
60
|
-
value = text.value.toString()
|
|
105
|
+
let value = ''
|
|
106
|
+
if (typeof text.value !== 'string') {
|
|
107
|
+
value = text.value.toString()
|
|
61
108
|
} else {
|
|
62
|
-
value = text.value
|
|
109
|
+
value = text.value
|
|
63
110
|
}
|
|
64
111
|
if (/\./g.test(value)) {
|
|
65
112
|
if (Number(value)) {
|
|
66
|
-
return value.split(
|
|
113
|
+
return value.split('.')
|
|
67
114
|
} else {
|
|
68
|
-
return [
|
|
115
|
+
return ['0', '00']
|
|
69
116
|
}
|
|
70
117
|
} else {
|
|
71
|
-
return [value,
|
|
118
|
+
return [value, '000000']
|
|
72
119
|
}
|
|
73
|
-
})
|
|
120
|
+
})
|
|
74
121
|
|
|
75
122
|
/**
|
|
76
123
|
* @description 点击事件
|
|
77
124
|
* */
|
|
78
125
|
const handleClick = () => {
|
|
79
|
-
emit(
|
|
80
|
-
}
|
|
126
|
+
emit('click', text.value)
|
|
127
|
+
}
|
|
81
128
|
</script>
|
|
82
129
|
|
|
83
130
|
<style lang="scss" scoped>
|
|
84
|
-
@import
|
|
131
|
+
@import './index.scss';
|
|
85
132
|
</style>
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export default interface HyPriceProps {
|
|
4
4
|
/**
|
|
5
5
|
* @description 传入金额值
|
|
6
6
|
* */
|
|
7
|
-
text: string | number
|
|
7
|
+
text: string | number
|
|
8
8
|
/**
|
|
9
9
|
* @description 金额符号(默认:¥)
|
|
10
10
|
* */
|
|
11
|
-
symbol?: string
|
|
11
|
+
symbol?: string
|
|
12
12
|
/**
|
|
13
13
|
* @description 比例大小(默认:1.4)
|
|
14
14
|
* */
|
|
15
|
-
ratio?: number
|
|
15
|
+
ratio?: number
|
|
16
16
|
/**
|
|
17
17
|
* @description 保留小数点后几位数(默认:2)
|
|
18
18
|
* */
|
|
19
|
-
num?: number
|
|
19
|
+
num?: number
|
|
20
20
|
/**
|
|
21
21
|
* @description 字体颜色(默认:#FE3232)
|
|
22
22
|
* */
|
|
23
|
-
color?: string
|
|
23
|
+
color?: string
|
|
24
24
|
/**
|
|
25
25
|
* @description 字体大小(默认:12)
|
|
26
26
|
* */
|
|
27
|
-
size?: string | number
|
|
27
|
+
size?: string | number
|
|
28
28
|
/**
|
|
29
29
|
* @description 字体粗细(默认:500)
|
|
30
30
|
* */
|
|
31
|
-
weight?: number
|
|
31
|
+
weight?: number
|
|
32
32
|
/**
|
|
33
33
|
* @description 是否倾斜(默认:false)
|
|
34
34
|
* */
|
|
35
|
-
slant?: boolean
|
|
35
|
+
slant?: boolean
|
|
36
36
|
/**
|
|
37
37
|
* @description 自定义样式
|
|
38
38
|
* */
|
|
39
|
-
customStyle?: CSSProperties
|
|
39
|
+
customStyle?: CSSProperties
|
|
40
40
|
}
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script lang="ts">
|
|
24
|
+
/**
|
|
25
|
+
* 根据提供的字符串前端JS生成二维码展示
|
|
26
|
+
* @displayName hy-qrcode
|
|
27
|
+
*/
|
|
28
|
+
defineOptions({})
|
|
24
29
|
export default {
|
|
25
30
|
name: 'hy-qrcode',
|
|
26
31
|
options: {
|
|
@@ -33,8 +38,7 @@ export default {
|
|
|
33
38
|
|
|
34
39
|
<script setup lang="ts">
|
|
35
40
|
import { getCurrentInstance, toRefs, ref, onMounted } from 'vue'
|
|
36
|
-
import
|
|
37
|
-
import type IProps from './typing'
|
|
41
|
+
import type { IQrcodeEmits } from './typing'
|
|
38
42
|
import QRCode from './qrcode.js'
|
|
39
43
|
import { addUnit, error } from '../../utils'
|
|
40
44
|
import { IconConfig } from '../../config'
|
|
@@ -43,9 +47,75 @@ import { IconConfig } from '../../config'
|
|
|
43
47
|
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
44
48
|
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
45
49
|
|
|
46
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
50
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
51
|
+
const props = defineProps({
|
|
52
|
+
/** 实例ID字符串(如果有多个二维码组件必须设置不一样的cid) */
|
|
53
|
+
cid: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: 'hy-qrcode-canvas' + Math.random().toString(),
|
|
56
|
+
},
|
|
57
|
+
/** 二维码大小 */
|
|
58
|
+
size: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 200,
|
|
61
|
+
},
|
|
62
|
+
/** 二维码内容 */
|
|
63
|
+
text: String,
|
|
64
|
+
/** 是否显示二维码 */
|
|
65
|
+
show: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true,
|
|
68
|
+
},
|
|
69
|
+
/** 二维码背景色 */
|
|
70
|
+
background: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: '#ffffff',
|
|
73
|
+
},
|
|
74
|
+
/** 二维码颜色 */
|
|
75
|
+
foreground: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: '#000000',
|
|
78
|
+
},
|
|
79
|
+
/** 定位角点颜色 */
|
|
80
|
+
pdGround: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: '#000000',
|
|
83
|
+
},
|
|
84
|
+
/** 是否是自定义组件 */
|
|
85
|
+
usingComponents: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: true,
|
|
88
|
+
},
|
|
89
|
+
/** 容错级别 */
|
|
90
|
+
lv: {
|
|
91
|
+
type: Number,
|
|
92
|
+
default: 3,
|
|
93
|
+
},
|
|
94
|
+
/** 二维码中间图标 */
|
|
95
|
+
icon: String,
|
|
96
|
+
/** 二维码中间图标大小 */
|
|
97
|
+
iconSize: {
|
|
98
|
+
type: Number,
|
|
99
|
+
default: 40,
|
|
100
|
+
},
|
|
101
|
+
/** 显示加载状态 */
|
|
102
|
+
showLoading: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
default: true,
|
|
105
|
+
},
|
|
106
|
+
/** 加载中提示语 */
|
|
107
|
+
loadingText: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: '二维码生成中',
|
|
110
|
+
},
|
|
111
|
+
/** 是否预览 */
|
|
112
|
+
allowPreview: {
|
|
113
|
+
type: Boolean,
|
|
114
|
+
default: false,
|
|
115
|
+
},
|
|
116
|
+
})
|
|
47
117
|
const { text, allowPreview } = toRefs(props)
|
|
48
|
-
const emit = defineEmits(
|
|
118
|
+
const emit = defineEmits<IQrcodeEmits>()
|
|
49
119
|
|
|
50
120
|
const instance = getCurrentInstance()
|
|
51
121
|
const loading = ref(false)
|
|
@@ -106,7 +176,7 @@ const _saveCode = () => {
|
|
|
106
176
|
/**
|
|
107
177
|
* @description 预览
|
|
108
178
|
* */
|
|
109
|
-
const preview = (e) => {
|
|
179
|
+
const preview = (e: Event) => {
|
|
110
180
|
// 预览图片
|
|
111
181
|
// console.log(this.result)
|
|
112
182
|
if (allowPreview.value) {
|
|
@@ -1,64 +1,73 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
3
|
export default interface HyQrcodeProps {
|
|
4
4
|
/**
|
|
5
5
|
* @description 实例ID字符串(如果有多个二维码组件必须设置不一样的cid)
|
|
6
6
|
* */
|
|
7
|
-
cid?: string
|
|
7
|
+
cid?: string
|
|
8
8
|
/**
|
|
9
9
|
* @description 二维码大小
|
|
10
10
|
* */
|
|
11
|
-
size?: string | number
|
|
11
|
+
size?: string | number
|
|
12
12
|
/**
|
|
13
13
|
* @description 二维码内容
|
|
14
14
|
* */
|
|
15
|
-
text: string
|
|
15
|
+
text: string
|
|
16
16
|
/**
|
|
17
17
|
* @description 是否显示二维码
|
|
18
18
|
* */
|
|
19
|
-
show?: boolean
|
|
19
|
+
show?: boolean
|
|
20
20
|
/**
|
|
21
21
|
* @description 二维码背景色
|
|
22
22
|
* */
|
|
23
|
-
background?: string
|
|
23
|
+
background?: string
|
|
24
24
|
/**
|
|
25
25
|
* @description 二维码颜色
|
|
26
26
|
* */
|
|
27
|
-
foreground?: string
|
|
27
|
+
foreground?: string
|
|
28
28
|
/**
|
|
29
29
|
* @description 定位角点颜色
|
|
30
30
|
* */
|
|
31
|
-
pdGround?: string
|
|
31
|
+
pdGround?: string
|
|
32
32
|
/**
|
|
33
33
|
* @description 容错级别
|
|
34
34
|
* */
|
|
35
|
-
lv?: number
|
|
35
|
+
lv?: number
|
|
36
36
|
/**
|
|
37
37
|
* @description 是否是自定义组件
|
|
38
38
|
* */
|
|
39
|
-
usingComponents?: boolean
|
|
39
|
+
usingComponents?: boolean
|
|
40
40
|
/**
|
|
41
41
|
* @description 二维码中间图标
|
|
42
42
|
* */
|
|
43
|
-
icon?: string
|
|
43
|
+
icon?: string
|
|
44
44
|
/**
|
|
45
45
|
* @description 二维码中间图标大小
|
|
46
46
|
* */
|
|
47
|
-
iconSize?: string | number
|
|
47
|
+
iconSize?: string | number
|
|
48
48
|
/**
|
|
49
49
|
* @description 显示加载状态
|
|
50
50
|
* */
|
|
51
|
-
showLoading?: boolean
|
|
51
|
+
showLoading?: boolean
|
|
52
52
|
/**
|
|
53
53
|
* @description 加载中提示语
|
|
54
54
|
* */
|
|
55
|
-
loadingText?: string
|
|
55
|
+
loadingText?: string
|
|
56
56
|
/**
|
|
57
57
|
* @description 是否预览
|
|
58
58
|
* */
|
|
59
|
-
allowPreview?: boolean
|
|
59
|
+
allowPreview?: boolean
|
|
60
60
|
/**
|
|
61
61
|
* @description 定义需要用到的外部样式
|
|
62
62
|
* */
|
|
63
|
-
customStyle?: CSSProperties
|
|
63
|
+
customStyle?: CSSProperties
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface IQrcodeEmits {
|
|
67
|
+
/** 二维码生成成功 */
|
|
68
|
+
(e: 'result', res: any): void
|
|
69
|
+
/** 打开图片事件 */
|
|
70
|
+
(e: 'preview', res: string, event: Event): void
|
|
71
|
+
/** 长按事件 */
|
|
72
|
+
(e: 'longPress'): void
|
|
64
73
|
}
|