hy-app 0.1.1

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 (206) hide show
  1. package/README.md +42 -0
  2. package/api/http.ts +138 -0
  3. package/api/index.ts +1 -0
  4. package/common/index.ts +1 -0
  5. package/common/versionControl.ts +102 -0
  6. package/components/dialog/TheDialog.vue +128 -0
  7. package/components/dialog/index.ts +38 -0
  8. package/components/hy-address-picker/hy-address-picker.vue +262 -0
  9. package/components/hy-address-picker/props.ts +27 -0
  10. package/components/hy-address-picker/typing.d.ts +98 -0
  11. package/components/hy-avatar/hy-avatar.vue +217 -0
  12. package/components/hy-avatar/props.ts +20 -0
  13. package/components/hy-avatar/typing.d.ts +64 -0
  14. package/components/hy-back-top/hy-back-top.vue +71 -0
  15. package/components/hy-back-top/props.ts +23 -0
  16. package/components/hy-back-top/typing.d.ts +49 -0
  17. package/components/hy-badge/hy-badge.vue +155 -0
  18. package/components/hy-badge/props.ts +19 -0
  19. package/components/hy-badge/typing.d.ts +60 -0
  20. package/components/hy-button/hy-button.vue +394 -0
  21. package/components/hy-button/props.ts +36 -0
  22. package/components/hy-button/typing.d.ts +125 -0
  23. package/components/hy-card/hy-card.vue +198 -0
  24. package/components/hy-card/props.ts +29 -0
  25. package/components/hy-card/typing.d.ts +112 -0
  26. package/components/hy-cell/hy-cell.vue +268 -0
  27. package/components/hy-cell/props.ts +20 -0
  28. package/components/hy-cell/typing.d.ts +98 -0
  29. package/components/hy-check-button/hy-check-button.vue +71 -0
  30. package/components/hy-check-button/props.ts +20 -0
  31. package/components/hy-check-button/typing.d.ts +79 -0
  32. package/components/hy-checkbox/hy-checkbox.vue +299 -0
  33. package/components/hy-checkbox/props.ts +28 -0
  34. package/components/hy-checkbox/typing.d.ts +77 -0
  35. package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
  36. package/components/hy-datetime-picker/props.ts +36 -0
  37. package/components/hy-datetime-picker/typing.d.ts +135 -0
  38. package/components/hy-divider/hy-divider.vue +164 -0
  39. package/components/hy-divider/props.ts +21 -0
  40. package/components/hy-divider/typing.d.ts +64 -0
  41. package/components/hy-empty/hy-empty.vue +122 -0
  42. package/components/hy-empty/props.ts +21 -0
  43. package/components/hy-empty/typing.d.ts +68 -0
  44. package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
  45. package/components/hy-folding-panel/props.ts +17 -0
  46. package/components/hy-folding-panel/typing.d.ts +59 -0
  47. package/components/hy-form/hy-form.vue +372 -0
  48. package/components/hy-form/props.ts +15 -0
  49. package/components/hy-form/typing.d.ts +51 -0
  50. package/components/hy-grid/hy-grid.vue +126 -0
  51. package/components/hy-grid/props.ts +16 -0
  52. package/components/hy-grid/typing.d.ts +62 -0
  53. package/components/hy-icon/hy-icon.vue +207 -0
  54. package/components/hy-icon/props.ts +24 -0
  55. package/components/hy-icon/typing.d.ts +80 -0
  56. package/components/hy-input/hy-input.vue +402 -0
  57. package/components/hy-input/props.ts +41 -0
  58. package/components/hy-input/typing.d.ts +148 -0
  59. package/components/hy-line/hy-line.vue +44 -0
  60. package/components/hy-line/props.ts +12 -0
  61. package/components/hy-line/typing.d.ts +32 -0
  62. package/components/hy-line-progress/hy-line-progress.vue +118 -0
  63. package/components/hy-line-progress/props.ts +12 -0
  64. package/components/hy-line-progress/typing.d.ts +28 -0
  65. package/components/hy-list/hy-list.vue +250 -0
  66. package/components/hy-list/props.ts +18 -0
  67. package/components/hy-list/typing.d.ts +50 -0
  68. package/components/hy-login/ThePhoneLogin.vue +106 -0
  69. package/components/hy-login/TheUserLogin.vue +391 -0
  70. package/components/hy-login/hy-login.vue +283 -0
  71. package/components/hy-login/props.ts +32 -0
  72. package/components/hy-login/typing.d.ts +60 -0
  73. package/components/hy-modal/hy-modal.vue +240 -0
  74. package/components/hy-modal/props.ts +24 -0
  75. package/components/hy-modal/typing.d.ts +70 -0
  76. package/components/hy-navbar/hy-navbar.vue +194 -0
  77. package/components/hy-navbar/props.ts +24 -0
  78. package/components/hy-navbar/typing.d.ts +81 -0
  79. package/components/hy-notice-bar/hy-column-notice.vue +130 -0
  80. package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
  81. package/components/hy-notice-bar/hy-row-notice.vue +182 -0
  82. package/components/hy-notice-bar/props.ts +19 -0
  83. package/components/hy-notice-bar/typing.d.ts +56 -0
  84. package/components/hy-number-step/hy-number-step.vue +428 -0
  85. package/components/hy-number-step/props.ts +29 -0
  86. package/components/hy-number-step/typing.d.ts +104 -0
  87. package/components/hy-overlay/hy-overlay.vue +54 -0
  88. package/components/hy-overlay/props.ts +10 -0
  89. package/components/hy-overlay/typing.d.ts +24 -0
  90. package/components/hy-picker/hy-picker.vue +499 -0
  91. package/components/hy-picker/props.ts +30 -0
  92. package/components/hy-picker/typing.d.ts +115 -0
  93. package/components/hy-popup/hy-popup.vue +269 -0
  94. package/components/hy-popup/props.ts +21 -0
  95. package/components/hy-popup/typing.d.ts +68 -0
  96. package/components/hy-price/hy-price.vue +86 -0
  97. package/components/hy-price/props.ts +13 -0
  98. package/components/hy-price/typing.d.ts +36 -0
  99. package/components/hy-qrcode/hy-qrcode.vue +153 -0
  100. package/components/hy-qrcode/props.ts +20 -0
  101. package/components/hy-qrcode/qrcode.js +1364 -0
  102. package/components/hy-qrcode/typing.d.ts +64 -0
  103. package/components/hy-radio/hy-radio.vue +319 -0
  104. package/components/hy-radio/props.ts +28 -0
  105. package/components/hy-radio/typing.d.ts +85 -0
  106. package/components/hy-rate/hy-rate.vue +261 -0
  107. package/components/hy-rate/props.ts +18 -0
  108. package/components/hy-rate/typing.d.ts +60 -0
  109. package/components/hy-read-more/hy-read-more.vue +134 -0
  110. package/components/hy-read-more/props.ts +20 -0
  111. package/components/hy-read-more/typing.d.ts +44 -0
  112. package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
  113. package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
  114. package/components/hy-scroll-list/props.ts +12 -0
  115. package/components/hy-scroll-list/typing.d.ts +28 -0
  116. package/components/hy-search/hy-search.vue +294 -0
  117. package/components/hy-search/props.ts +29 -0
  118. package/components/hy-search/typing.d.ts +109 -0
  119. package/components/hy-slider/hy-slider.vue +511 -0
  120. package/components/hy-slider/props.ts +21 -0
  121. package/components/hy-slider/typing.d.ts +68 -0
  122. package/components/hy-steps/hy-steps.vue +352 -0
  123. package/components/hy-steps/props.ts +15 -0
  124. package/components/hy-steps/typing.d.ts +58 -0
  125. package/components/hy-subsection/hy-subsection.vue +272 -0
  126. package/components/hy-subsection/props.ts +16 -0
  127. package/components/hy-subsection/typing.d.ts +44 -0
  128. package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
  129. package/components/hy-swiper/hy-swiper.vue +242 -0
  130. package/components/hy-swiper/props.ts +30 -0
  131. package/components/hy-swiper/typing.d.ts +107 -0
  132. package/components/hy-switch/hy-switch.vue +168 -0
  133. package/components/hy-switch/props.ts +16 -0
  134. package/components/hy-switch/typing.d.ts +48 -0
  135. package/components/hy-tabs/hy-tabs.vue +416 -0
  136. package/components/hy-tabs/props.ts +26 -0
  137. package/components/hy-tabs/typing.d.ts +86 -0
  138. package/components/hy-tag/hy-tag.vue +374 -0
  139. package/components/hy-tag/props.ts +22 -0
  140. package/components/hy-tag/typing.d.ts +76 -0
  141. package/components/hy-textarea/hy-textarea.vue +229 -0
  142. package/components/hy-textarea/props.ts +26 -0
  143. package/components/hy-textarea/typing.d.ts +27 -0
  144. package/components/hy-tooltip/hy-tooltip.vue +332 -0
  145. package/components/hy-tooltip/props.ts +17 -0
  146. package/components/hy-tooltip/typing.d.ts +52 -0
  147. package/components/hy-transition/hy-transition.vue +150 -0
  148. package/components/hy-transition/index.scss +113 -0
  149. package/components/hy-transition/props.ts +10 -0
  150. package/components/hy-transition/typing.d.ts +36 -0
  151. package/components/hy-upload/hy-upload.vue +557 -0
  152. package/components/hy-upload/props.ts +29 -0
  153. package/components/hy-upload/typing.d.ts +147 -0
  154. package/components/hy-warn/hy-warn.vue +228 -0
  155. package/components/hy-warn/props.ts +14 -0
  156. package/components/hy-warn/typing.d.ts +40 -0
  157. package/components/hy-waterfall/hy-waterfall.vue +51 -0
  158. package/components/hy-waterfall/props.ts +10 -0
  159. package/components/hy-waterfall/typing.d.ts +20 -0
  160. package/components/index.ts +162 -0
  161. package/components/message/TheMessage.vue +169 -0
  162. package/components/message/index.ts +54 -0
  163. package/components/u-form/form.js +22 -0
  164. package/components/u-form/hy-form.vue +324 -0
  165. package/components/u-form/props.js +49 -0
  166. package/components/u-form/schema.js +1451 -0
  167. package/components/u-form/u-form.vue +267 -0
  168. package/components/u-form/utils.js +65 -0
  169. package/components/u-form-item/formItem.js +24 -0
  170. package/components/u-form-item/hy-form-item.vue +360 -0
  171. package/components/u-form-item/props.js +57 -0
  172. package/components/u-form-item/u-form-item.vue +294 -0
  173. package/components/yk-dialog/yk-dialog.vue +129 -0
  174. package/components/yk-tabbar/props.ts +49 -0
  175. package/components/yk-tabbar/yk-tabbar.vue +224 -0
  176. package/config/color.ts +6 -0
  177. package/config/icon.ts +366 -0
  178. package/config/index.ts +2 -0
  179. package/global/index.ts +6 -0
  180. package/global/register-properties.ts +37 -0
  181. package/index.ts +8 -0
  182. package/libs/css/common.scss +0 -0
  183. package/libs/css/iconfont.css +379 -0
  184. package/libs/css/iconfont.ttf +0 -0
  185. package/libs/css/mixin.scss +15 -0
  186. package/package.json +42 -0
  187. package/public/icons/error.png +0 -0
  188. package/public/icons/success.png +0 -0
  189. package/public/icons/warning.png +0 -0
  190. package/store/index.ts +1 -0
  191. package/store/userInfo.ts +25 -0
  192. package/theme.scss +94 -0
  193. package/typing/index.ts +7 -0
  194. package/typing/modules/common.d.ts +50 -0
  195. package/typing/modules/dialog.ts +17 -0
  196. package/typing/modules/enum.ts +67 -0
  197. package/typing/modules/form.ts +161 -0
  198. package/typing/modules/http.ts +68 -0
  199. package/typing/modules/icon.d.ts +366 -0
  200. package/typing/modules/img.ts +15 -0
  201. package/typing/modules/rect.ts +10 -0
  202. package/utils/address.json +5890 -0
  203. package/utils/base64.ts +119 -0
  204. package/utils/index.ts +3 -0
  205. package/utils/inside.ts +310 -0
  206. package/utils/utils.ts +446 -0
@@ -0,0 +1,27 @@
1
+ import { CSSProperties } from "vue";
2
+
3
+ export default interface IProps {
4
+ modelValue: string;
5
+ placeholder?: string;
6
+ placeholderClass?: string;
7
+ placeholderStyle?: CSSProperties;
8
+ height?: number;
9
+ confirmType?: "done" | "send" | "search" | "next" | "go";
10
+ disabled?: boolean;
11
+ count?: boolean;
12
+ focus?: boolean;
13
+ autoHeight?: boolean;
14
+ fixed?: boolean;
15
+ cursorSpacing?: number;
16
+ cursor?: string;
17
+ showConfirmBar?: boolean;
18
+ selectionStart?: number;
19
+ selectionEnd?: number;
20
+ adjustPosition?: boolean;
21
+ disableDefaultPadding?: boolean;
22
+ holdKeyboard?: boolean;
23
+ maxlength?: number;
24
+ border?: HyApp.BorderType;
25
+ formatter?: ((value: string) => string) | null;
26
+ customStyle?: CSSProperties;
27
+ }
@@ -0,0 +1,332 @@
1
+ <template>
2
+ <view class="u-tooltip" :style="customStyle">
3
+ <HyOverlay
4
+ :show="showTooltip && tooltipTop !== -10000 && overlay"
5
+ :customStyle="{ backgroundColor: 'rgba(0, 0, 0, 0)' }"
6
+ @click="overlayClickHandler"
7
+ ></HyOverlay>
8
+ <view class="u-tooltip__wrapper">
9
+ <text
10
+ class="u-tooltip__wrapper__text"
11
+ :id="textId"
12
+ :ref="textId"
13
+ :userSelect="false"
14
+ :selectable="false"
15
+ @longpress.stop="longPressHandler"
16
+ :style="{
17
+ color: color,
18
+ backgroundColor:
19
+ bgColor && showTooltip && tooltipTop !== -10000
20
+ ? bgColor
21
+ : 'transparent'
22
+ }"
23
+ >{{ text }}</text
24
+ >
25
+ <HyTransition
26
+ mode="fade"
27
+ :show="showTooltip"
28
+ :duration="300"
29
+ :customStyle="{
30
+ position: 'absolute',
31
+ top: addUnit(tooltipTop),
32
+ zIndex: zIndex,
33
+ ...tooltipStyle
34
+ }"
35
+ >
36
+ <view
37
+ class="u-tooltip__wrapper__popup"
38
+ :id="tooltipId"
39
+ :ref="tooltipId"
40
+ >
41
+ <view
42
+ v-if="showCopy || buttons.length"
43
+ class="u-tooltip__wrapper__popup__indicator"
44
+ hover-class="u-tooltip__wrapper__popup__indicator--hover"
45
+ :style="[
46
+ indicatorStyle,
47
+ {
48
+ width: addUnit(indicatorWidth),
49
+ height: addUnit(indicatorWidth)
50
+ }
51
+ ]"
52
+ >
53
+ <!-- 由于nvue不支持三角形绘制,这里就做一个四方形,再旋转45deg,得到露出的一个三角 -->
54
+ </view>
55
+ <view class="u-tooltip__wrapper__popup__list">
56
+ <view
57
+ v-if="showCopy"
58
+ class="u-tooltip__wrapper__popup__list__btn"
59
+ hover-class="u-tooltip__wrapper__popup__list__btn--hover"
60
+ @tap="setClipboardData"
61
+ >
62
+ <text class="u-tooltip__wrapper__popup__list__btn__text"
63
+ >复制</text
64
+ >
65
+ </view>
66
+ <HyLine
67
+ direction="column"
68
+ color="#8d8e90"
69
+ v-if="showCopy && buttons.length > 0"
70
+ length="18"
71
+ ></HyLine>
72
+ <block v-for="(item, index) in buttons" :key="index">
73
+ <view
74
+ class="u-tooltip__wrapper__popup__list__btn"
75
+ hover-class="u-tooltip__wrapper__popup__list__btn--hover"
76
+ >
77
+ <text
78
+ class="u-tooltip__wrapper__popup__list__btn__text"
79
+ @tap="btnClickHandler(index)"
80
+ >{{ item }}</text
81
+ >
82
+ </view>
83
+ <HyLine
84
+ direction="column"
85
+ color="#8d8e90"
86
+ v-if="index < buttons.length - 1"
87
+ length="18"
88
+ ></HyLine>
89
+ </block>
90
+ </view>
91
+ </view>
92
+ </HyTransition>
93
+ </view>
94
+ </view>
95
+ </template>
96
+
97
+ <script setup lang="ts">
98
+ import { computed, CSSProperties, toRefs, ref, reactive, onMounted } from "vue";
99
+ import defaultProps from "./props";
100
+ import IProps from "./typing";
101
+ import { addUnit, getRect, guid, sleep } from "../../utils";
102
+
103
+ // 组件
104
+ import HyOverlay from "../hy-overlay/hy-overlay.vue";
105
+ import HyTransition from "../hy-transition/hy-transition.vue";
106
+ import HyLine from "../hy-line/hy-line.vue";
107
+
108
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
109
+ const { showToast, copyText, text, showCopy, buttons, direction } =
110
+ toRefs(props);
111
+ const emit = defineEmits(["click"]);
112
+
113
+ const showTooltip = ref<boolean>(true);
114
+ const textId = ref(guid());
115
+ const tooltipId = ref(guid());
116
+ const tooltipTop = ref<number>(-10000);
117
+ // 气泡的位置信息
118
+ const tooltipInfo = ref<UniApp.NodeInfo>({
119
+ width: 0,
120
+ left: 0
121
+ });
122
+ const textInfo = ref<UniApp.NodeInfo>({
123
+ width: 0,
124
+ left: 0,
125
+ right: 0
126
+ });
127
+ // 三角形指示器的样式
128
+ const indicatorStyle = ref<CSSProperties>({
129
+ left: 0,
130
+ right: 0
131
+ });
132
+ // 气泡在可能超出屏幕边沿范围时,重新定位后,距离屏幕边沿的距离
133
+ const screenGap = ref(12);
134
+ // 三角形指示器的宽高,由于对元素进行了角度旋转,精确计算指示器位置时,需要用到其尺寸信息
135
+ const indicatorWidth = ref(14);
136
+
137
+ // 特别处理H5的复制,因为H5浏览器是自带系统复制功能的,在H5环境
138
+ // 当一些依赖参数变化时,需要重新计算气泡和指示器的位置信息
139
+ const propsChange = computed(() => {
140
+ return [text.value, buttons.value];
141
+ });
142
+ // 计算气泡和指示器的位置信息
143
+ const tooltipStyle = computed(() => {
144
+ const style: CSSProperties = {
145
+ transform: `translateY(${direction.value === "top" ? "-100%" : "100%"})`
146
+ },
147
+ // #ifdef APP || H5 || MP-WEIXIN
148
+ sysInfo = uni.getWindowInfo();
149
+ // #endif
150
+ if (
151
+ tooltipInfo.value.width! / 2 >
152
+ textInfo.value.left! + textInfo.value.width! / 2 - screenGap.value
153
+ ) {
154
+ indicatorStyle.value = {};
155
+ style.left = `-${addUnit(textInfo.value.left! - screenGap.value)}`;
156
+ indicatorStyle.value.left = addUnit(
157
+ textInfo.value.width! / 2 - Number(style.left) - indicatorWidth.value / 2
158
+ );
159
+ } else if (
160
+ tooltipInfo.value.width! / 2 >
161
+ sysInfo.windowWidth -
162
+ textInfo.value.right! +
163
+ textInfo.value.width! / 2 -
164
+ screenGap.value
165
+ ) {
166
+ indicatorStyle.value = {};
167
+ style.right = `-${addUnit(
168
+ sysInfo.windowWidth - textInfo.value.right! - screenGap.value
169
+ )}`;
170
+ indicatorStyle.value.right = addUnit(
171
+ textInfo.value.width! / 2 - Number(style.right) - indicatorWidth.value / 2
172
+ );
173
+ } else {
174
+ const left = Math.abs(
175
+ textInfo.value.width! / 2 - tooltipInfo.value.width! / 2
176
+ );
177
+ style.left =
178
+ textInfo.value.width! > tooltipInfo.value.width!
179
+ ? addUnit(left)
180
+ : -addUnit(left);
181
+ indicatorStyle.value = {};
182
+ }
183
+ if (direction.value === "top") {
184
+ style.marginTop = "-10px";
185
+ indicatorStyle.value.bottom = "-4px";
186
+ } else {
187
+ style.marginBottom = "-10px";
188
+ indicatorStyle.value.top = "-4px";
189
+ }
190
+ return style;
191
+ });
192
+
193
+ onMounted(() => {
194
+ getElRect();
195
+ });
196
+
197
+ /**
198
+ * @description 长按触发事件
199
+ * */
200
+ const longPressHandler = () => {
201
+ tooltipTop.value = 0;
202
+ showTooltip.value = true;
203
+ };
204
+
205
+ /**
206
+ * @description 点击透明遮罩
207
+ * */
208
+ const overlayClickHandler = () => {
209
+ showTooltip.value = false;
210
+ };
211
+
212
+ /**
213
+ * @description 点击弹出按钮
214
+ * */
215
+ const btnClickHandler = (index: number) => {
216
+ showTooltip.value = false;
217
+ // 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
218
+ emit("click", showCopy.value ? index + 1 : index);
219
+ };
220
+
221
+ /**
222
+ * @description 元素尺寸
223
+ * */
224
+ const getElRect = () => {
225
+ // 调用之前,先将指示器调整到屏幕外,方便获取尺寸
226
+ showTooltip.value = true;
227
+ tooltipTop.value = -10000;
228
+ sleep(500).then(() => {
229
+ getRect(`#${tooltipId.value}`).then((size) => {
230
+ tooltipInfo.value = size as UniApp.NodeInfo;
231
+ // 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果
232
+ showTooltip.value = false;
233
+ });
234
+ getRect(`#${textId.value}`).then((size) => {
235
+ textInfo.value = size as UniApp.NodeInfo;
236
+ });
237
+ });
238
+ };
239
+ /**
240
+ * @description 复制文本到粘贴板
241
+ * */
242
+ const setClipboardData = () => {
243
+ // 关闭组件
244
+ showTooltip.value = false;
245
+ emit("click", 0);
246
+ uni.setClipboardData({
247
+ // 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
248
+ data: copyText.value || text.value,
249
+ success: () => {
250
+ showToast.value &&
251
+ uni.showToast({
252
+ title: "复制成功"
253
+ });
254
+ },
255
+ fail: () => {
256
+ showToast.value &&
257
+ uni.showToast({
258
+ title: "复制失败"
259
+ });
260
+ },
261
+ complete: () => {
262
+ showTooltip.value = false;
263
+ }
264
+ });
265
+ };
266
+ </script>
267
+
268
+ <style lang="scss" scoped>
269
+ @import "../../libs/css/mixin.scss";
270
+
271
+ .u-tooltip {
272
+ position: relative;
273
+ @include flex;
274
+
275
+ &__wrapper {
276
+ @include flex;
277
+ justify-content: center;
278
+ /* #ifndef APP-NVUE */
279
+ white-space: nowrap;
280
+ /* #endif */
281
+
282
+ &__text {
283
+ font-size: 14px;
284
+ }
285
+
286
+ &__popup {
287
+ @include flex;
288
+ justify-content: center;
289
+
290
+ &__list {
291
+ background-color: #060607;
292
+ position: relative;
293
+ flex: 1;
294
+ border-radius: 5px;
295
+ padding: 0px 0;
296
+ @include flex(row);
297
+ align-items: center;
298
+ overflow: hidden;
299
+
300
+ &__btn {
301
+ padding: 11px 13px;
302
+
303
+ &--hover {
304
+ background-color: #58595b;
305
+ }
306
+
307
+ &__text {
308
+ line-height: 12px;
309
+ font-size: 13px;
310
+ color: #ffffff;
311
+ }
312
+ }
313
+ }
314
+
315
+ &__indicator {
316
+ position: absolute;
317
+ background-color: #060607;
318
+ width: 14px;
319
+ height: 14px;
320
+ bottom: -4px;
321
+ transform: rotate(45deg);
322
+ border-radius: 2px;
323
+ z-index: -1;
324
+
325
+ &--hover {
326
+ background-color: #58595b;
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ </style>
@@ -0,0 +1,17 @@
1
+ import IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ text: "",
5
+ copyText: "",
6
+ size: 14,
7
+ color: "#606266",
8
+ bgColor: "transparent",
9
+ direction: "top",
10
+ zIndex: 10071,
11
+ showCopy: true,
12
+ buttons: [],
13
+ overlay: true,
14
+ showToast: true
15
+ };
16
+
17
+ export default defaultProps;
@@ -0,0 +1,52 @@
1
+ import { CSSProperties } from "vue";
2
+
3
+ export default interface IProps {
4
+ /**
5
+ * @description 需要显示的提示文字
6
+ * */
7
+ text: string;
8
+ /**
9
+ * @description 点击复制按钮时,复制的文本,为空则使用text值
10
+ * */
11
+ copyText?: string;
12
+ /**
13
+ * @description 文本大小(默认 14 )
14
+ * */
15
+ size?: number | string;
16
+ /**
17
+ * @description 字体颜色(默认 '#606266' )
18
+ * */
19
+ color?: string;
20
+ /**
21
+ * @description 弹出提示框时,文本的背景色(默认 'transparent' )
22
+ * */
23
+ bgColor?: string;
24
+ /**
25
+ * @description 弹出提示的方向,top-上方,bottom-下方(默认 'top' )
26
+ * */
27
+ direction?: HyApp.TopBottomType;
28
+ /**
29
+ * @description 弹出提示的z-index,nvue无效(默认 10071 )
30
+ * */
31
+ zIndex?: number;
32
+ /**
33
+ * @description 是否显示复制按钮(默认 true )
34
+ * */
35
+ showCopy?: boolean;
36
+ /**
37
+ * @description 扩展的按钮组
38
+ * */
39
+ buttons?: string[];
40
+ /**
41
+ * @description 是否显示透明遮罩以防止触摸穿透(默认 true )
42
+ * */
43
+ overlay?: boolean;
44
+ /**
45
+ * @description 是否显示遮罩
46
+ * */
47
+ showToast?: boolean;
48
+ /**
49
+ * @description 定义需要用到的外部样式
50
+ * */
51
+ customStyle?: CSSProperties;
52
+ }
@@ -0,0 +1,150 @@
1
+ <template>
2
+ <view
3
+ v-if="hasInit"
4
+ class="hy-transition"
5
+ ref="u-transition"
6
+ @tap="clickHandler"
7
+ :class="classes"
8
+ :style="[mergeStyle]"
9
+ >
10
+ <slot />
11
+ </view>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { computed, CSSProperties, ref, watch, nextTick, toRefs } from "vue";
16
+ import { sleep } from "../../utils";
17
+ import defaultProps from "./props";
18
+ import IProps from "./typing";
19
+
20
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
21
+ const { show, mode, duration } = toRefs(props);
22
+ const emit = defineEmits([
23
+ "click",
24
+ "beforeEnter",
25
+ "enter",
26
+ "afterEnter",
27
+ "beforeLeave",
28
+ "leave",
29
+ "afterLeave"
30
+ ]);
31
+
32
+ const hasInit = ref<boolean>(false); // 是否显示/隐藏组件
33
+ const viewStyle = ref<CSSProperties>({}); // 组件内部的样式
34
+ const status = ref<string>(""); // 记录组件动画的状态
35
+ const transitionEnded = ref<boolean>(false); // 组件是否结束的标记
36
+ const display = ref<boolean>(false); // 组件是否展示
37
+ const classes = ref<string>(""); // 应用的类名
38
+
39
+ // #ifndef APP-NVUE
40
+ // 定义类名,通过给元素动态切换类名,赋予元素一定的css动画样式
41
+ const getClassNames = (name: string) => ({
42
+ enter: `u-${name}-enter u-${name}-enter-active`,
43
+ "enter-to": `u-${name}-enter-to u-${name}-enter-active`,
44
+ leave: `u-${name}-leave u-${name}-leave-active`,
45
+ "leave-to": `u-${name}-leave-to u-${name}-leave-active`
46
+ });
47
+ // #endif
48
+
49
+ // #ifndef APP-NVUE
50
+ // vue版本的组件进场处理
51
+ const vueEnter = async () => {
52
+ // 动画进入时的类名
53
+ const classNames = getClassNames(mode.value);
54
+ // 定义状态和发出动画进入前事件
55
+ status.value = "enter";
56
+ emit("beforeEnter");
57
+ hasInit.value = true;
58
+ display.value = true;
59
+ classes.value = classNames.enter;
60
+ await nextTick();
61
+ {
62
+ // https://github.com/umicro/uView2.0/issues/545
63
+ await sleep(20);
64
+ // 标识动画尚未结束
65
+ emit("enter");
66
+ transitionEnded.value = false;
67
+ // 组件动画进入后触发的事件
68
+ emit("afterEnter");
69
+ // 赋予组件enter-to类名
70
+ classes.value = classNames["enter-to"];
71
+ }
72
+ };
73
+ // 动画离场处理
74
+ const vueLeave = async () => {
75
+ // 如果不是展示状态,无需执行逻辑
76
+ if (!display.value) return;
77
+ const classNames = getClassNames(mode.value);
78
+ // 标记离开状态和发出事件
79
+ status.value = "leave";
80
+ emit("beforeLeave");
81
+ // 获得类名
82
+ classes.value = classNames.leave;
83
+
84
+ await nextTick();
85
+ {
86
+ // 动画正在离场的状态
87
+ transitionEnded.value = false;
88
+ emit("leave");
89
+ // 组件执行动画,到了执行的执行时间后,执行一些额外处理
90
+ setTimeout(() => onTransitionEnd(), duration.value);
91
+ classes.value = classNames["leave-to"];
92
+ }
93
+ };
94
+ // #endif
95
+
96
+ watch(
97
+ () => props.show,
98
+ (newVal) => {
99
+ // vue和nvue分别执行不同的方法
100
+ // #ifdef APP-NVUE
101
+ // newVal ? nvueEnter() : nvueLeave()
102
+ // #endif
103
+ // #ifndef APP-NVUE
104
+ newVal ? vueEnter() : vueLeave();
105
+ // #endif
106
+ },
107
+ { immediate: true }
108
+ );
109
+
110
+ const mergeStyle = computed(() => {
111
+ const { duration, customStyle, timingFunction } = props;
112
+ return {
113
+ // #ifndef APP-NVUE
114
+ transitionDuration: `${duration}ms`,
115
+ // display: `${this.display ? '' : 'none'}`,
116
+ transitionTimingFunction: timingFunction,
117
+ // #endif
118
+ // 避免自定义样式影响到动画属性,所以写在viewStyle前面
119
+ ...customStyle,
120
+ ...viewStyle
121
+ };
122
+ });
123
+
124
+ // 组件被点击发出事件
125
+ const clickHandler = () => {
126
+ emit("click");
127
+ };
128
+
129
+ const onTransitionEnd = () => {
130
+ // 如果已经是结束的状态,无需再处理
131
+ if (transitionEnded.value) return;
132
+ transitionEnded.value = true;
133
+ // 发出组件动画执行后的事件
134
+ emit(status.value === "leave" ? "afterLeave" : "afterEnter");
135
+ if (!show.value && display.value) {
136
+ display.value = false;
137
+ hasInit.value = false;
138
+ }
139
+ };
140
+ </script>
141
+
142
+ <style lang="scss" scoped>
143
+ /* #ifndef APP-NVUE */
144
+ // vue版本动画相关的样式抽离在外部文件
145
+ @import "./index.scss";
146
+ /* #endif */
147
+
148
+ .hy-transition {
149
+ }
150
+ </style>
@@ -0,0 +1,113 @@
1
+ /**
2
+ * vue版本动画内置的动画模式有如下:
3
+ * fade:淡入
4
+ * zoom:缩放
5
+ * fade-zoom:缩放淡入
6
+ * fade-up:上滑淡入
7
+ * fade-down:下滑淡入
8
+ * fade-left:左滑淡入
9
+ * fade-right:右滑淡入
10
+ * slide-up:上滑进入
11
+ * slide-down:下滑进入
12
+ * slide-left:左滑进入
13
+ * slide-right:右滑进入
14
+ */
15
+
16
+ $u-zoom-scale: scale(0.95);
17
+
18
+ .u-fade-enter-active,
19
+ .u-fade-leave-active {
20
+ transition-property: opacity;
21
+ }
22
+
23
+ .u-fade-enter,
24
+ .u-fade-leave-to {
25
+ opacity: 0
26
+ }
27
+
28
+ .u-fade-zoom-enter,
29
+ .u-fade-zoom-leave-to {
30
+ transform: $u-zoom-scale;
31
+ opacity: 0;
32
+ }
33
+
34
+ .u-fade-zoom-enter-active,
35
+ .u-fade-zoom-leave-active {
36
+ transition-property: transform, opacity;
37
+ }
38
+
39
+ .u-fade-down-enter-active,
40
+ .u-fade-down-leave-active,
41
+ .u-fade-left-enter-active,
42
+ .u-fade-left-leave-active,
43
+ .u-fade-right-enter-active,
44
+ .u-fade-right-leave-active,
45
+ .u-fade-up-enter-active,
46
+ .u-fade-up-leave-active {
47
+ transition-property: opacity, transform;
48
+ }
49
+
50
+ .u-fade-up-enter,
51
+ .u-fade-up-leave-to {
52
+ transform: translate3d(0, 100%, 0);
53
+ opacity: 0
54
+ }
55
+
56
+ .u-fade-down-enter,
57
+ .u-fade-down-leave-to {
58
+ transform: translate3d(0, -100%, 0);
59
+ opacity: 0
60
+ }
61
+
62
+ .u-fade-left-enter,
63
+ .u-fade-left-leave-to {
64
+ transform: translate3d(-100%, 0, 0);
65
+ opacity: 0
66
+ }
67
+
68
+ .u-fade-right-enter,
69
+ .u-fade-right-leave-to {
70
+ transform: translate3d(100%, 0, 0);
71
+ opacity: 0
72
+ }
73
+
74
+ .u-slide-down-enter-active,
75
+ .u-slide-down-leave-active,
76
+ .u-slide-left-enter-active,
77
+ .u-slide-left-leave-active,
78
+ .u-slide-right-enter-active,
79
+ .u-slide-right-leave-active,
80
+ .u-slide-up-enter-active,
81
+ .u-slide-up-leave-active {
82
+ transition-property: transform;
83
+ }
84
+
85
+ .u-slide-up-enter,
86
+ .u-slide-up-leave-to {
87
+ transform: translate3d(0, 100%, 0)
88
+ }
89
+
90
+ .u-slide-down-enter,
91
+ .u-slide-down-leave-to {
92
+ transform: translate3d(0, -100%, 0)
93
+ }
94
+
95
+ .u-slide-left-enter,
96
+ .u-slide-left-leave-to {
97
+ transform: translate3d(-100%, 0, 0)
98
+ }
99
+
100
+ .u-slide-right-enter,
101
+ .u-slide-right-leave-to {
102
+ transform: translate3d(100%, 0, 0)
103
+ }
104
+
105
+ .u-zoom-enter-active,
106
+ .u-zoom-leave-active {
107
+ transition-property: transform
108
+ }
109
+
110
+ .u-zoom-enter,
111
+ .u-zoom-leave-to {
112
+ transform: $u-zoom-scale
113
+ }
@@ -0,0 +1,10 @@
1
+ import IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ show: false,
5
+ mode: "fade",
6
+ duration: 300,
7
+ timingFunction: "ease-out"
8
+ };
9
+
10
+ export default defaultProps;