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
|
@@ -44,48 +44,126 @@
|
|
|
44
44
|
</template>
|
|
45
45
|
|
|
46
46
|
<script lang="ts">
|
|
47
|
+
/**
|
|
48
|
+
* 该组件用于滚动通告场景,有多种模式可供选择
|
|
49
|
+
* @displayName hy-notice-bar
|
|
50
|
+
*/
|
|
51
|
+
defineOptions({})
|
|
47
52
|
export default {
|
|
48
53
|
name: 'hy-notice-bar',
|
|
49
54
|
options: {
|
|
50
55
|
addGlobalClass: true,
|
|
51
56
|
virtualHost: true,
|
|
52
|
-
styleIsolation: 'shared'
|
|
53
|
-
}
|
|
57
|
+
styleIsolation: 'shared',
|
|
58
|
+
},
|
|
54
59
|
}
|
|
55
60
|
</script>
|
|
56
61
|
|
|
57
62
|
<script setup lang="ts">
|
|
58
|
-
import { ref, toRefs } from
|
|
59
|
-
import
|
|
60
|
-
import
|
|
63
|
+
import { ref, toRefs } from 'vue'
|
|
64
|
+
import type { INoticeBarEmits } from './typing'
|
|
65
|
+
import { IconConfig } from '../../config'
|
|
66
|
+
|
|
61
67
|
// 组件
|
|
62
|
-
import HyRowNotice from
|
|
63
|
-
import HyColumnNotice from
|
|
68
|
+
import HyRowNotice from './hy-row-notice.vue'
|
|
69
|
+
import HyColumnNotice from './hy-column-notice.vue'
|
|
64
70
|
|
|
65
|
-
const show = ref(true)
|
|
71
|
+
const show = ref(true)
|
|
66
72
|
|
|
67
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
68
|
-
const
|
|
69
|
-
|
|
73
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
74
|
+
const props = defineProps({
|
|
75
|
+
/** 显示的内容,数组 */
|
|
76
|
+
text: {
|
|
77
|
+
type: [String, Array],
|
|
78
|
+
default: [],
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* 通告滚动模式,row-横向滚动,column-竖向滚动
|
|
82
|
+
* @values row,column
|
|
83
|
+
* */
|
|
84
|
+
direction: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: 'row',
|
|
87
|
+
},
|
|
88
|
+
/** direction = row时,是否使用步进形式滚动 */
|
|
89
|
+
step: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: false,
|
|
92
|
+
},
|
|
93
|
+
/** 是否显示左侧的音量图标 */
|
|
94
|
+
icon: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: IconConfig.NOTIFICATION_FILL,
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* 通告模式,link-显示右箭头,closable-显示右侧关闭图标
|
|
100
|
+
* @values link,closable
|
|
101
|
+
* */
|
|
102
|
+
mode: String,
|
|
103
|
+
/** 文字颜色,各图标也会使用文字颜色 */
|
|
104
|
+
color: String,
|
|
105
|
+
/** 背景颜色 */
|
|
106
|
+
bgColor: String,
|
|
107
|
+
/** 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度 */
|
|
108
|
+
speed: {
|
|
109
|
+
type: Number,
|
|
110
|
+
default: 80,
|
|
111
|
+
},
|
|
112
|
+
/** 字体大小,单位px */
|
|
113
|
+
fontSize: {
|
|
114
|
+
type: [String, Number],
|
|
115
|
+
default: 14,
|
|
116
|
+
},
|
|
117
|
+
/** 滚动一个周期的时间长,单位ms */
|
|
118
|
+
duration: {
|
|
119
|
+
type: Number,
|
|
120
|
+
default: 2000,
|
|
121
|
+
},
|
|
122
|
+
/** 是否禁止用手滑动切换 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序 */
|
|
123
|
+
disableTouch: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: true,
|
|
126
|
+
},
|
|
127
|
+
/**
|
|
128
|
+
* 分布
|
|
129
|
+
* @values flex-start,flex-start,center
|
|
130
|
+
* */
|
|
131
|
+
justifyContent: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: 'flex-start',
|
|
134
|
+
},
|
|
135
|
+
/**
|
|
136
|
+
* 跳转类型
|
|
137
|
+
* @values navigateTo,redirectTo,switchTab,reLaunch
|
|
138
|
+
* */
|
|
139
|
+
linkType: {
|
|
140
|
+
type: String,
|
|
141
|
+
default: 'navigateTo',
|
|
142
|
+
},
|
|
143
|
+
/** 跳转地址 */
|
|
144
|
+
url: String,
|
|
145
|
+
})
|
|
146
|
+
const { mode, linkType, url } = toRefs(props)
|
|
147
|
+
const emit = defineEmits<INoticeBarEmits>()
|
|
70
148
|
|
|
71
149
|
/**
|
|
72
150
|
* @description 点击通告栏
|
|
73
151
|
* */
|
|
74
152
|
const click = (index: number) => {
|
|
75
|
-
emit(
|
|
76
|
-
if (url.value && linkType.value && mode.value ===
|
|
77
|
-
(uni as any)[linkType.value]({ url: url.value })
|
|
153
|
+
emit('click', index)
|
|
154
|
+
if (url.value && linkType.value && mode.value === 'link') {
|
|
155
|
+
;(uni as any)[linkType.value]({ url: url.value })
|
|
78
156
|
}
|
|
79
|
-
}
|
|
157
|
+
}
|
|
80
158
|
/**
|
|
81
159
|
* @description 点击关闭按钮
|
|
82
160
|
* */
|
|
83
161
|
const close = () => {
|
|
84
|
-
show.value = false
|
|
85
|
-
emit(
|
|
86
|
-
}
|
|
162
|
+
show.value = false
|
|
163
|
+
emit('close')
|
|
164
|
+
}
|
|
87
165
|
</script>
|
|
88
166
|
|
|
89
167
|
<style lang="scss" scoped>
|
|
90
|
-
@import
|
|
168
|
+
@import './index.scss';
|
|
91
169
|
</style>
|
|
@@ -1,66 +1,71 @@
|
|
|
1
|
-
import type { CSSProperties } from
|
|
1
|
+
import type { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
|
-
export type NoticeBarModeVo =
|
|
3
|
+
export type NoticeBarModeVo = 'closable' | 'link' | ''
|
|
4
4
|
|
|
5
5
|
export default interface HyNoticeBarProps {
|
|
6
6
|
/**
|
|
7
7
|
* @description 显示的内容,数组
|
|
8
8
|
* */
|
|
9
|
-
text: string[] | string
|
|
9
|
+
text: string[] | string
|
|
10
10
|
/**
|
|
11
11
|
* @description 通告滚动模式,row-横向滚动,column-竖向滚动 ( 默认 'row' )
|
|
12
12
|
* */
|
|
13
|
-
direction?: HyApp.DirectionType
|
|
13
|
+
direction?: HyApp.DirectionType
|
|
14
14
|
/**
|
|
15
15
|
* @description direction = row时,是否使用步进形式滚动 ( 默认 false )
|
|
16
16
|
* */
|
|
17
|
-
step?: boolean
|
|
17
|
+
step?: boolean
|
|
18
18
|
/**
|
|
19
19
|
* @description 是否显示左侧的音量图标 ( 默认 'volume' )
|
|
20
20
|
* */
|
|
21
|
-
icon?: string | HyIconConfig
|
|
21
|
+
icon?: string | HyIconConfig
|
|
22
22
|
/**
|
|
23
23
|
* @description 通告模式,link-显示右箭头,closable-显示右侧关闭图标
|
|
24
24
|
* */
|
|
25
|
-
mode?: NoticeBarModeVo
|
|
25
|
+
mode?: NoticeBarModeVo
|
|
26
26
|
/**
|
|
27
27
|
* @description 文字颜色,各图标也会使用文字颜色 ( 默认 '#f9ae3d' )
|
|
28
28
|
* */
|
|
29
|
-
color?: string
|
|
29
|
+
color?: string
|
|
30
30
|
/**
|
|
31
31
|
* @description 背景颜色 ( 默认 '#fdf6ec' )
|
|
32
32
|
* */
|
|
33
|
-
bgColor?: string
|
|
33
|
+
bgColor?: string
|
|
34
34
|
/**
|
|
35
35
|
* @description 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度 ( 默认 80 )
|
|
36
36
|
* */
|
|
37
|
-
speed?: number
|
|
37
|
+
speed?: number
|
|
38
38
|
/**
|
|
39
39
|
* @description 字体大小 ( 默认 14 )
|
|
40
40
|
* */
|
|
41
|
-
fontSize?: number | string
|
|
41
|
+
fontSize?: number | string
|
|
42
42
|
/**
|
|
43
43
|
* @description 滚动一个周期的时间长,单位ms ( 默认 2000 )
|
|
44
44
|
* */
|
|
45
|
-
duration?: number
|
|
45
|
+
duration?: number
|
|
46
46
|
/**
|
|
47
47
|
* @description 是否禁止用手滑动切换 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序(默认34) ( 默认 true )
|
|
48
48
|
* */
|
|
49
|
-
disableTouch?: boolean
|
|
49
|
+
disableTouch?: boolean
|
|
50
50
|
/**
|
|
51
51
|
* @description 分布
|
|
52
52
|
* */
|
|
53
|
-
justifyContent?: HyApp.JustifyContentType
|
|
53
|
+
justifyContent?: HyApp.JustifyContentType
|
|
54
54
|
/**
|
|
55
55
|
* @description 跳转类型
|
|
56
56
|
* */
|
|
57
|
-
linkType?: HyApp.NavigationType
|
|
57
|
+
linkType?: HyApp.NavigationType
|
|
58
58
|
/**
|
|
59
59
|
* @description 跳转地址
|
|
60
60
|
* */
|
|
61
|
-
url?: string
|
|
61
|
+
url?: string
|
|
62
62
|
/**
|
|
63
63
|
* @description 定义需要用到的外部样式
|
|
64
64
|
* */
|
|
65
|
-
customStyle?: CSSProperties
|
|
65
|
+
customStyle?: CSSProperties
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface INoticeBarEmits {
|
|
69
|
+
(e: 'click', index: number): void
|
|
70
|
+
(e: 'close'): void
|
|
66
71
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<hy-transition mode="slide-down" :customStyle="containerStyle" :show="open">
|
|
3
3
|
<view
|
|
4
|
-
class="hy-notify"
|
|
5
|
-
:class="[`hy-notify--${tmpConfig?.type}`]"
|
|
4
|
+
:class="['hy-notify', `hy-notify--${tmpConfig?.type}`, customClass]"
|
|
6
5
|
:style="[backgroundColor, customStyle]"
|
|
7
6
|
>
|
|
8
7
|
<hy-status-bar v-if="tmpConfig?.safeAreaInsetTop"></hy-status-bar>
|
|
@@ -22,36 +21,90 @@
|
|
|
22
21
|
fontSize: addUnit(tmpConfig?.fontSize),
|
|
23
22
|
color: tmpConfig?.color,
|
|
24
23
|
}"
|
|
25
|
-
>{{ tmpConfig?.message }}</text
|
|
26
24
|
>
|
|
25
|
+
{{ tmpConfig?.message }}
|
|
26
|
+
</text>
|
|
27
27
|
</view>
|
|
28
28
|
</view>
|
|
29
29
|
</hy-transition>
|
|
30
30
|
</template>
|
|
31
31
|
|
|
32
32
|
<script lang="ts">
|
|
33
|
+
/**
|
|
34
|
+
* 一般用于页面顶部向下滑出一个提示,尔后自动收起的场景。
|
|
35
|
+
* @displayName hy-notify
|
|
36
|
+
*/
|
|
37
|
+
defineOptions({})
|
|
33
38
|
export default {
|
|
34
|
-
name:
|
|
39
|
+
name: 'hy-notify',
|
|
35
40
|
options: {
|
|
36
41
|
addGlobalClass: true,
|
|
37
42
|
virtualHost: true,
|
|
38
|
-
styleIsolation:
|
|
43
|
+
styleIsolation: 'shared',
|
|
39
44
|
},
|
|
40
|
-
}
|
|
45
|
+
}
|
|
41
46
|
</script>
|
|
42
47
|
|
|
43
48
|
<script setup lang="ts">
|
|
44
|
-
import type IProps from
|
|
45
|
-
import
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
49
|
+
import type IProps from './typing'
|
|
50
|
+
import { computed, ref } from 'vue'
|
|
51
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
52
|
+
import { IconConfig } from '../../config'
|
|
53
|
+
|
|
54
|
+
import { addUnit } from '../../utils'
|
|
48
55
|
// 组件
|
|
49
|
-
import HyTransition from
|
|
50
|
-
import HyStatusBar from
|
|
51
|
-
import HyIcon from
|
|
52
|
-
import { IconConfig } from "@/package";
|
|
56
|
+
import HyTransition from '../hy-transition/hy-transition.vue'
|
|
57
|
+
import HyStatusBar from '../hy-status-bar/hy-status-bar.vue'
|
|
58
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
53
59
|
|
|
54
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
60
|
+
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
61
|
+
const props = defineProps({
|
|
62
|
+
/** 到顶部的距离 */
|
|
63
|
+
top: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 0,
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* 主题
|
|
69
|
+
* @values primary,success,warning,error,info
|
|
70
|
+
* */
|
|
71
|
+
type: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: 'primary',
|
|
74
|
+
},
|
|
75
|
+
/** 字体颜色 */
|
|
76
|
+
color: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: '#FFFFFF',
|
|
79
|
+
},
|
|
80
|
+
/** 背景颜色 */
|
|
81
|
+
bgColor: String,
|
|
82
|
+
/** 图标名称 */
|
|
83
|
+
icon: String,
|
|
84
|
+
/** 展示的文字内容 */
|
|
85
|
+
message: String,
|
|
86
|
+
/** 展示时长,为0时不消失,单位ms */
|
|
87
|
+
duration: {
|
|
88
|
+
type: Number,
|
|
89
|
+
default: 3000,
|
|
90
|
+
},
|
|
91
|
+
/** 字体大小 */
|
|
92
|
+
fontSize: {
|
|
93
|
+
type: [Number, String],
|
|
94
|
+
default: 15,
|
|
95
|
+
},
|
|
96
|
+
/** 是否留出顶部安全距离 */
|
|
97
|
+
safeAreaInsetTop: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: false,
|
|
100
|
+
},
|
|
101
|
+
/** 定义需要用到的外部样式 */
|
|
102
|
+
customStyle: {
|
|
103
|
+
type: Object as PropType<CSSProperties>,
|
|
104
|
+
},
|
|
105
|
+
/** 自定义外部类名 */
|
|
106
|
+
customClass: String,
|
|
107
|
+
})
|
|
55
108
|
|
|
56
109
|
const config = ref<IProps>({
|
|
57
110
|
// 到顶部的距离
|
|
@@ -70,100 +123,99 @@ const config = ref<IProps>({
|
|
|
70
123
|
fontSize: props.fontSize,
|
|
71
124
|
// 是否留出顶部安全距离(状态栏高度)
|
|
72
125
|
safeAreaInsetTop: props.safeAreaInsetTop,
|
|
73
|
-
})
|
|
74
|
-
const tmpConfig = ref<IProps>({})
|
|
75
|
-
const open = ref(false)
|
|
76
|
-
let timer: ReturnType<typeof setTimeout
|
|
126
|
+
})
|
|
127
|
+
const tmpConfig = ref<IProps>({})
|
|
128
|
+
const open = ref(false)
|
|
129
|
+
let timer: ReturnType<typeof setTimeout>
|
|
77
130
|
|
|
78
131
|
/**
|
|
79
132
|
* @description 容器样式
|
|
80
133
|
* */
|
|
81
134
|
const containerStyle = computed(() => {
|
|
82
|
-
let top = 0
|
|
135
|
+
let top = 0
|
|
83
136
|
if (tmpConfig.value.top === 0) {
|
|
84
137
|
// #ifdef H5
|
|
85
138
|
// H5端,导航栏为普通元素,需要将组件移动到导航栏的下边沿
|
|
86
139
|
// H5的导航栏高度为44px
|
|
87
|
-
top = 44
|
|
140
|
+
top = 44
|
|
88
141
|
// #endif
|
|
89
142
|
}
|
|
90
143
|
const style: CSSProperties = {
|
|
91
144
|
top: addUnit(tmpConfig.value.top === 0 ? top : tmpConfig.value.top),
|
|
92
145
|
// 因为组件底层为hy-transition组件,必须将其设置为fixed定位
|
|
93
146
|
// 让其出现在导航栏底部
|
|
94
|
-
position:
|
|
147
|
+
position: 'fixed',
|
|
95
148
|
left: 0,
|
|
96
149
|
right: 0,
|
|
97
150
|
zIndex: 10076,
|
|
98
|
-
}
|
|
99
|
-
return style
|
|
100
|
-
})
|
|
151
|
+
}
|
|
152
|
+
return style
|
|
153
|
+
})
|
|
101
154
|
/**
|
|
102
155
|
* @description 组件背景颜色
|
|
103
156
|
*/
|
|
104
157
|
const backgroundColor = computed(() => {
|
|
105
|
-
const style: CSSProperties = {}
|
|
158
|
+
const style: CSSProperties = {}
|
|
106
159
|
if (tmpConfig.value.bgColor) {
|
|
107
|
-
style.backgroundColor = tmpConfig.value.bgColor
|
|
160
|
+
style.backgroundColor = tmpConfig.value.bgColor
|
|
108
161
|
}
|
|
109
|
-
return style
|
|
110
|
-
})
|
|
162
|
+
return style
|
|
163
|
+
})
|
|
111
164
|
|
|
112
165
|
/**
|
|
113
166
|
* @description 默认主题下的图标
|
|
114
167
|
* */
|
|
115
168
|
const icon = computed(() => {
|
|
116
|
-
let icon
|
|
169
|
+
let icon
|
|
117
170
|
switch (tmpConfig.value.type) {
|
|
118
|
-
case
|
|
119
|
-
return IconConfig.SUCCESS
|
|
120
|
-
case
|
|
121
|
-
return IconConfig.CLOSE_CIRCLE
|
|
122
|
-
case
|
|
123
|
-
return IconConfig.NOTICE
|
|
171
|
+
case 'success':
|
|
172
|
+
return IconConfig.SUCCESS
|
|
173
|
+
case 'error':
|
|
174
|
+
return IconConfig.CLOSE_CIRCLE
|
|
175
|
+
case 'warning':
|
|
176
|
+
return IconConfig.NOTICE
|
|
124
177
|
default:
|
|
125
|
-
return icon
|
|
178
|
+
return icon
|
|
126
179
|
}
|
|
127
|
-
})
|
|
180
|
+
})
|
|
128
181
|
|
|
129
182
|
const show = (options: IProps) => {
|
|
130
183
|
// 不将结果合并到this.config变量,避免多次调用hy-toast,前后的配置造成混乱
|
|
131
|
-
tmpConfig.value = Object.assign(config.value, options)
|
|
184
|
+
tmpConfig.value = Object.assign(config.value, options)
|
|
132
185
|
// 任何定时器初始化之前,都要执行清除操作,否则可能会造成混乱
|
|
133
|
-
clearTimer()
|
|
134
|
-
open.value = true
|
|
186
|
+
clearTimer()
|
|
187
|
+
open.value = true
|
|
135
188
|
if (tmpConfig.value.duration && tmpConfig.value.duration! > 0) {
|
|
136
189
|
timer = setTimeout(() => {
|
|
137
|
-
open.value = false
|
|
190
|
+
open.value = false
|
|
138
191
|
// 倒计时结束,清除定时器,隐藏toast组件
|
|
139
|
-
clearTimer()
|
|
192
|
+
clearTimer()
|
|
140
193
|
// 判断是否存在callback方法,如果存在就执行
|
|
141
|
-
typeof tmpConfig.value.complete ===
|
|
142
|
-
|
|
143
|
-
}, tmpConfig.value.duration);
|
|
194
|
+
typeof tmpConfig.value.complete === 'function' && tmpConfig.value.complete()
|
|
195
|
+
}, tmpConfig.value.duration)
|
|
144
196
|
}
|
|
145
|
-
}
|
|
197
|
+
}
|
|
146
198
|
/**
|
|
147
199
|
* @description 关闭notify
|
|
148
200
|
* */
|
|
149
201
|
const close = () => {
|
|
150
|
-
clearTimer()
|
|
151
|
-
}
|
|
202
|
+
clearTimer()
|
|
203
|
+
}
|
|
152
204
|
/**
|
|
153
205
|
* @description 清除定时任务
|
|
154
206
|
* */
|
|
155
207
|
const clearTimer = () => {
|
|
156
|
-
open.value = false
|
|
208
|
+
open.value = false
|
|
157
209
|
// 清除定时器
|
|
158
|
-
clearTimeout(timer)
|
|
159
|
-
}
|
|
210
|
+
clearTimeout(timer)
|
|
211
|
+
}
|
|
160
212
|
|
|
161
213
|
defineExpose({
|
|
162
214
|
show,
|
|
163
215
|
close,
|
|
164
|
-
})
|
|
216
|
+
})
|
|
165
217
|
</script>
|
|
166
218
|
|
|
167
219
|
<style scoped lang="scss">
|
|
168
|
-
@import
|
|
220
|
+
@import './index.scss';
|
|
169
221
|
</style>
|