uview-pro 0.2.3 → 0.3.0

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 (184) hide show
  1. package/changelog.md +52 -0
  2. package/components/u-action-sheet/types.ts +2 -0
  3. package/components/u-action-sheet/u-action-sheet.vue +25 -7
  4. package/components/u-alert-tips/types.ts +2 -0
  5. package/components/u-alert-tips/u-alert-tips.vue +36 -10
  6. package/components/u-avatar/types.ts +2 -0
  7. package/components/u-avatar/u-avatar.vue +31 -7
  8. package/components/u-avatar-cropper/u-avatar-cropper.vue +13 -2
  9. package/components/u-avatar-cropper/weCropper.js +36 -8
  10. package/components/u-avatar-cropper/weCropper.ts +28 -7
  11. package/components/u-back-top/types.ts +2 -5
  12. package/components/u-back-top/u-back-top.vue +31 -16
  13. package/components/u-badge/types.ts +2 -0
  14. package/components/u-badge/u-badge.vue +33 -15
  15. package/components/u-button/types.ts +2 -2
  16. package/components/u-button/u-button.vue +34 -11
  17. package/components/u-calendar/types.ts +3 -1
  18. package/components/u-calendar/u-calendar.vue +172 -17
  19. package/components/u-car-keyboard/types.ts +2 -0
  20. package/components/u-car-keyboard/u-car-keyboard.vue +36 -8
  21. package/components/u-card/types.ts +2 -0
  22. package/components/u-card/u-card.vue +25 -10
  23. package/components/u-cell-group/types.ts +2 -0
  24. package/components/u-cell-group/u-cell-group.vue +15 -5
  25. package/components/u-cell-item/types.ts +2 -0
  26. package/components/u-cell-item/u-cell-item.vue +37 -13
  27. package/components/u-checkbox/types.ts +2 -0
  28. package/components/u-checkbox/u-checkbox.vue +9 -13
  29. package/components/u-checkbox-group/types.ts +2 -0
  30. package/components/u-checkbox-group/u-checkbox-group.vue +1 -1
  31. package/components/u-circle-progress/types.ts +2 -0
  32. package/components/u-circle-progress/u-circle-progress.vue +30 -11
  33. package/components/u-city-select/types.ts +2 -0
  34. package/components/u-city-select/u-city-select.vue +48 -8
  35. package/components/u-col/types.ts +2 -0
  36. package/components/u-col/u-col.vue +27 -8
  37. package/components/u-collapse/u-collapse.vue +8 -13
  38. package/components/u-collapse-item/u-collapse-item.vue +21 -42
  39. package/components/u-column-notice/types.ts +2 -0
  40. package/components/u-column-notice/u-column-notice.vue +54 -8
  41. package/components/u-count-down/types.ts +2 -0
  42. package/components/u-count-down/u-count-down.vue +39 -11
  43. package/components/u-count-to/types.ts +2 -0
  44. package/components/u-count-to/u-count-to.vue +34 -9
  45. package/components/u-divider/types.ts +2 -0
  46. package/components/u-divider/u-divider.vue +36 -12
  47. package/components/u-dropdown/types.ts +2 -0
  48. package/components/u-dropdown/u-dropdown.vue +64 -23
  49. package/components/u-dropdown-item/types.ts +2 -0
  50. package/components/u-dropdown-item/u-dropdown-item.vue +39 -42
  51. package/components/u-empty/types.ts +2 -0
  52. package/components/u-empty/u-empty.vue +20 -5
  53. package/components/u-field/types.ts +2 -0
  54. package/components/u-field/u-field.vue +41 -7
  55. package/components/u-form/types.ts +2 -0
  56. package/components/u-form/u-form.vue +25 -27
  57. package/components/u-form-item/types.ts +2 -0
  58. package/components/u-form-item/u-form-item.vue +104 -74
  59. package/components/u-full-screen/types.ts +2 -0
  60. package/components/u-full-screen/u-full-screen.vue +24 -3
  61. package/components/u-gap/types.ts +2 -0
  62. package/components/u-gap/u-gap.vue +15 -5
  63. package/components/u-grid/types.ts +2 -0
  64. package/components/u-grid/u-grid.vue +23 -25
  65. package/components/u-grid-item/types.ts +3 -3
  66. package/components/u-grid-item/u-grid-item.vue +43 -43
  67. package/components/u-icon/types.ts +0 -1
  68. package/components/u-icon/u-icon.vue +20 -5
  69. package/components/u-image/u-image.vue +23 -6
  70. package/components/u-index-anchor/types.ts +3 -3
  71. package/components/u-index-anchor/u-index-anchor.vue +18 -10
  72. package/components/u-index-list/u-index-list.vue +9 -12
  73. package/components/u-input/types.ts +2 -5
  74. package/components/u-input/u-input.vue +34 -10
  75. package/components/u-keyboard/u-keyboard.vue +26 -6
  76. package/components/u-lazy-load/u-lazy-load.vue +23 -10
  77. package/components/u-line/u-line.vue +13 -4
  78. package/components/u-line-progress/u-line-progress.vue +22 -5
  79. package/components/u-link/u-link.vue +13 -4
  80. package/components/u-loading/u-loading.vue +20 -5
  81. package/components/u-loading-popup/u-loading-popup.vue +14 -0
  82. package/components/u-loadmore/u-loadmore.vue +19 -3
  83. package/components/u-mask/types.ts +2 -5
  84. package/components/u-mask/u-mask.vue +21 -14
  85. package/components/u-message-input/u-message-input.vue +32 -6
  86. package/components/u-modal/u-modal.vue +21 -5
  87. package/components/u-navbar/u-navbar.vue +31 -6
  88. package/components/u-no-network/u-no-network.vue +16 -3
  89. package/components/u-notice-bar/u-notice-bar.vue +19 -4
  90. package/components/u-number-box/u-number-box.vue +13 -4
  91. package/components/u-number-keyboard/u-number-keyboard.vue +32 -10
  92. package/components/u-picker/u-picker.vue +62 -14
  93. package/components/u-popup/types.ts +2 -2
  94. package/components/u-popup/u-popup.vue +33 -7
  95. package/components/u-radio/types.ts +2 -0
  96. package/components/u-radio/u-radio.vue +45 -24
  97. package/components/u-radio-group/types.ts +2 -0
  98. package/components/u-radio-group/u-radio-group.vue +20 -22
  99. package/components/u-rate/types.ts +2 -0
  100. package/components/u-rate/u-rate.vue +20 -5
  101. package/components/u-read-more/types.ts +2 -0
  102. package/components/u-read-more/u-read-more.vue +30 -8
  103. package/components/u-root-portal/u-root-portal.vue +3 -1
  104. package/components/u-row/types.ts +2 -0
  105. package/components/u-row/u-row.vue +29 -11
  106. package/components/u-row-notice/types.ts +2 -0
  107. package/components/u-row-notice/u-row-notice.vue +51 -8
  108. package/components/u-safe-bottom/u-safe-bottom.vue +13 -2
  109. package/components/u-search/types.ts +2 -0
  110. package/components/u-search/u-search.vue +30 -7
  111. package/components/u-section/types.ts +2 -0
  112. package/components/u-section/u-section.vue +38 -13
  113. package/components/u-select/types.ts +2 -0
  114. package/components/u-select/u-select.vue +37 -10
  115. package/components/u-skeleton/types.ts +2 -0
  116. package/components/u-skeleton/u-skeleton.vue +32 -6
  117. package/components/u-slider/types.ts +2 -0
  118. package/components/u-slider/u-slider.vue +38 -21
  119. package/components/u-status-bar/u-status-bar.vue +13 -4
  120. package/components/u-steps/types.ts +2 -0
  121. package/components/u-steps/u-steps.vue +26 -5
  122. package/components/u-sticky/types.ts +2 -0
  123. package/components/u-sticky/u-sticky.vue +27 -8
  124. package/components/u-subsection/types.ts +2 -0
  125. package/components/u-subsection/u-subsection.vue +14 -3
  126. package/components/u-swipe-action/types.ts +2 -0
  127. package/components/u-swipe-action/u-swipe-action.vue +27 -4
  128. package/components/u-swiper/types.ts +2 -0
  129. package/components/u-swiper/u-swiper.vue +50 -8
  130. package/components/u-switch/types.ts +2 -0
  131. package/components/u-switch/u-switch.vue +19 -5
  132. package/components/u-tabbar/types.ts +2 -0
  133. package/components/u-tabbar/u-tabbar.vue +42 -7
  134. package/components/u-table/types.ts +2 -0
  135. package/components/u-table/u-table.vue +15 -3
  136. package/components/u-tabs/types.ts +2 -0
  137. package/components/u-tabs/u-tabs.vue +22 -4
  138. package/components/u-tabs-swiper/types.ts +2 -0
  139. package/components/u-tabs-swiper/u-tabs-swiper.vue +36 -6
  140. package/components/u-tag/types.ts +2 -0
  141. package/components/u-tag/u-tag.vue +31 -7
  142. package/components/u-td/types.ts +2 -0
  143. package/components/u-td/u-td.vue +14 -3
  144. package/components/u-text/types.ts +4 -1
  145. package/components/u-text/u-text.vue +22 -5
  146. package/components/u-th/types.ts +2 -0
  147. package/components/u-th/u-th.vue +14 -3
  148. package/components/u-time-line/u-time-line.vue +17 -3
  149. package/components/u-time-line-item/types.ts +2 -0
  150. package/components/u-time-line-item/u-time-line-item.vue +15 -3
  151. package/components/u-toast/types.ts +2 -0
  152. package/components/u-toast/u-toast.vue +15 -8
  153. package/components/u-top-tips/types.ts +2 -0
  154. package/components/u-top-tips/u-top-tips.vue +20 -3
  155. package/components/u-tr/types.ts +4 -1
  156. package/components/u-tr/u-tr.vue +17 -2
  157. package/components/u-upload/types.ts +10 -2
  158. package/components/u-upload/u-upload.vue +31 -8
  159. package/components/u-verification-code/types.ts +2 -0
  160. package/components/u-verification-code/u-verification-code.vue +15 -3
  161. package/components/u-waterfall/types.ts +2 -0
  162. package/components/u-waterfall/u-waterfall.vue +15 -3
  163. package/iconfont.css +2 -1
  164. package/libs/css/style.vue.scss +1 -1
  165. package/libs/function/$parent.ts +4 -1
  166. package/libs/function/colorGradient.ts +18 -4
  167. package/libs/function/deepMerge.ts +2 -1
  168. package/libs/function/getParent.ts +5 -1
  169. package/libs/function/md5.ts +17 -5
  170. package/libs/function/queryParams.ts +5 -1
  171. package/libs/function/test.ts +7 -3
  172. package/libs/function/timeFormat.ts +2 -1
  173. package/libs/function/type2icon.ts +4 -1
  174. package/libs/hooks/index.ts +2 -1
  175. package/libs/hooks/useCompRelation.ts +364 -0
  176. package/libs/hooks/useComponent.ts +485 -69
  177. package/libs/hooks/useEmitter.ts +4 -2
  178. package/libs/index.ts +56 -39
  179. package/libs/request/index.ts +24 -5
  180. package/libs/util/async-validator.d.ts +16 -3
  181. package/libs/util/emitter.ts +12 -2
  182. package/libs/util/mitt.ts +4 -1
  183. package/package.json +1 -1
  184. package/readme.md +6 -6
package/changelog.md CHANGED
@@ -1,3 +1,55 @@
1
+ ## 0.3.0(2025-10-12)
2
+
3
+ ### 📝 Documentation | 文档
4
+
5
+ - 更新开源捐赠图片 ([8eb0f00](https://github.com/anyup/uView-Pro/commit/8eb0f00ed5308cd1c3574b66dc752b050bbfcb70))
6
+ - update readme ([c93cdcb](https://github.com/anyup/uView-Pro/commit/c93cdcb1278040b8c5b6232b0d7928edad22af5d))
7
+
8
+ ### ✨ Features | 新功能
9
+
10
+ - **component-relation:** 添加组件关系管理 Hooks 工具,用于完全替换 provide/inject,全平台兼容 ([927be95](https://github.com/anyup/uView-Pro/commit/927be95e8b1c1bd5e05cf91c00888c314f6431e8))
11
+
12
+ ### ♻️ Code Refactoring | 代码重构
13
+
14
+ - **components:** 重构复选框checkbox和手风琴collapse组件,使用新版组件关系管理工具,优化兼容性 ([a6b2e86](https://github.com/anyup/uView-Pro/commit/a6b2e86394193a1ff5b58df045cba5518b322d38))
15
+ - **u-radio:** 修复单选框组件,兼容微信、头条小程序 ([6c409dc](https://github.com/anyup/uView-Pro/commit/6c409dc2c0ed116abcdde23a366c7f575fd56a24))
16
+ - **styles:** 优化 u-collapse-item 和 u-text 组件的样式合并逻辑 ([d4436c5](https://github.com/anyup/uView-Pro/commit/d4436c51dc2ddb27d70eeba4cad804504da40013))
17
+ - **layout:** 优化布局组件兼容性 ([285b7a7](https://github.com/anyup/uView-Pro/commit/285b7a73fcd9f8a21521be0d7e7a83690495dc4b))
18
+ - **u-form:** 重构表单组件的错误处理和样式,增强兼容性,支持多种小程序平台 ([587f87d](https://github.com/anyup/uView-Pro/commit/587f87d1b8d3dd6cd98e583b2640bef61bd8f119))
19
+ - **components:** 所有组件允许接受外部样式,允许样式穿透 ([e736e90](https://github.com/anyup/uView-Pro/commit/e736e9014e36c995ba434a56a6ccfee01c56ad35))
20
+ - **u-grid:** 重构宫格组件,支持自定义样式 ([d999ece](https://github.com/anyup/uView-Pro/commit/d999eceed2447ddc99a62a6bdcc57deaa1d1b515))
21
+ - **component-relation:** 优化子组件挂载时连接父组件的逻辑 ([2d038f2](https://github.com/anyup/uView-Pro/commit/2d038f2721e91db2f1773079341473505f2f6836))
22
+ - **u-dropdown:** 重构下拉菜单组件,兼容多平台 ([393caa5](https://github.com/anyup/uView-Pro/commit/393caa57910e9a63484e0c9e852c634fc15ef606))
23
+ - **components:** 优化部分组件中的 customStyle 属性及样式处理 ([3506a5a](https://github.com/anyup/uView-Pro/commit/3506a5a055a7a106311351b4b8b90127b019a061))
24
+ - **components:** 统一使用 customClass 和 customStyle 属性,统一处理组件样式和类名 ([d400997](https://github.com/anyup/uView-Pro/commit/d40099782b97011edc04c5040342b585b8f18fcd))
25
+
26
+ ### 🐛 Bug Fixes | Bug 修复
27
+
28
+ - **u-collapse:** 修复手风琴模式和非手风琴模式的处理回调时,index错误的问题 ([a5882eb](https://github.com/anyup/uView-Pro/commit/a5882eb17d87fee4e06448ecc353bf4237f25d52))
29
+
30
+ ## 0.2.4(2025-10-08)
31
+
32
+ ### 🐛 Bug Fixes | Bug 修复
33
+
34
+ - **i18n:** 修复切换中英文切换失效问题 ([d61d817](https://github.com/anyup/uView-Pro/commit/d61d81790aecd774435999c9ab8c3672a2df38ad))
35
+ - **style:** 修复文本溢出样式u-line-1生成错误问题 ([5d2bf3c](https://github.com/anyup/uView-Pro/commit/5d2bf3ca080f8c5bc9fe40bb1f421c28f7ee8017))
36
+
37
+ ### ✨ Features | 新功能
38
+
39
+ - **calendar:** 增加日历组件的页面显示模式 ([af13724](https://github.com/anyup/uView-Pro/commit/af137241e644a5f1e99b07e580c8d3aca9250e9e))
40
+
41
+ ### ♻️ Code Refactoring | 代码重构
42
+
43
+ - 优化代码格式和可读性 ([2e338d5](https://github.com/anyup/uView-Pro/commit/2e338d5cb2dbf3ce42f38c9581c04164b852f992))
44
+ - **useComponent:** 重构组件事件处理并添加热更新支持 ([80f7e5e](https://github.com/anyup/uView-Pro/commit/80f7e5efaa2b2ab1668969072cb6d18652d00cc2))
45
+ - **u-collapse:** 重构 u-collapse 组件中的事件处理逻辑 ([6aadfd1](https://github.com/anyup/uView-Pro/commit/6aadfd16d5aefd45f022c8da1612ba1921942f6e))
46
+ - **u-checkbox:** 优化复选框组件的父组件事件处理 ([3b597ea](https://github.com/anyup/uView-Pro/commit/3b597ea2833ca71e5752d097b2f07c143869f0d2))
47
+ - **hooks:** 优化 useComponent 以支持页面级别组件关系管理 ([429192f](https://github.com/anyup/uView-Pro/commit/429192f66ba59a26acb957acfc01d5f318d43fb6))
48
+
49
+ ### 📝 Documentation | 文档
50
+
51
+ - 更新微信交流群图片链接 ([e67588a](https://github.com/anyup/uView-Pro/commit/e67588ae392d5150ec4d271ce45e65fe32372460))
52
+
1
53
  ## 0.2.3(2025-10-06)
2
54
 
3
55
  ### 🐛 Bug Fixes | Bug 修复
@@ -1,11 +1,13 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { ActionSheetItem, ActionSheetTips } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * actionSheet 操作菜单
6
7
  * @description 本组件用于从底部弹出一个操作菜单,供用户选择并返回结果。本组件功能类似于uni的uni.showActionSheetAPI,配置更加灵活,所有平台都表现一致。
7
8
  */
8
9
  export const ActionSheetProps = {
10
+ ...baseProps,
9
11
  /** 点击遮罩是否可以关闭actionsheet */
10
12
  maskCloseAble: { type: Boolean, default: true },
11
13
  /** 按钮的文字数组,可以自定义颜色和字体大小,字体单位为rpx */
@@ -9,6 +9,8 @@
9
9
  :safeAreaInsetBottom="safeAreaInsetBottom"
10
10
  @close="popupClose"
11
11
  :z-index="uZIndex"
12
+ :custom-class="customClass"
13
+ :custom-style="customStyle"
12
14
  >
13
15
  <view class="u-tips u-border-bottom" v-if="tips.text" :style="[tipsStyle]">
14
16
  {{ tips.text }}
@@ -27,21 +29,37 @@
27
29
  </view>
28
30
  </block>
29
31
  <view class="u-gab" v-if="cancelBtn"> </view>
30
- <view @touchmove.stop.prevent class="u-actionsheet-cancel u-action-sheet-item" hover-class="u-hover-class" :hover-stay-time="150" v-if="cancelBtn" @tap="close">{{
31
- cancelText
32
- }}</view>
32
+ <view
33
+ @touchmove.stop.prevent
34
+ class="u-actionsheet-cancel u-action-sheet-item"
35
+ hover-class="u-hover-class"
36
+ :hover-stay-time="150"
37
+ v-if="cancelBtn"
38
+ @tap="close"
39
+ >
40
+ {{ cancelText }}
41
+ </view>
33
42
  </u-popup>
34
43
  </template>
35
44
 
45
+ <script lang="ts">
46
+ export default {
47
+ name: 'u-action-sheet',
48
+ options: {
49
+ addGlobalClass: true,
50
+ // #ifndef MP-TOUTIAO
51
+ virtualHost: true,
52
+ // #endif
53
+ styleIsolation: 'shared'
54
+ }
55
+ };
56
+ </script>
57
+
36
58
  <script setup lang="ts">
37
59
  import { computed } from 'vue';
38
60
  import { $u } from '../..';
39
61
  import { ActionSheetProps } from './types';
40
62
 
41
- defineOptions({
42
- name: 'u-action-sheet'
43
- });
44
-
45
63
  /**
46
64
  * actionSheet 操作菜单
47
65
  * @description 本组件用于从底部弹出一个操作菜单,供用户选择并返回结果。本组件功能类似于uni的uni.showActionSheetAPI,配置更加灵活,所有平台都表现一致。
@@ -1,11 +1,13 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { ThemeType } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * alertTips 警告提示
6
7
  * @description 警告提示,展现需要关注的信息
7
8
  */
8
9
  export const AlertTipsProps = {
10
+ ...baseProps,
9
11
  /** 显示文字 */
10
12
  title: { type: String, default: '' },
11
13
  /** 主题,success/warning/info/error */
@@ -2,14 +2,31 @@
2
2
  <view
3
3
  class="u-alert-tips"
4
4
  v-if="show"
5
- :class="[!show ? 'u-close-alert-tips' : '', type ? 'u-alert-tips--bg--' + type + '-light' : '', type ? 'u-alert-tips--border--' + type + '-disabled' : '']"
6
- :style="{
7
- backgroundColor: bgColor,
8
- borderColor: borderColor
9
- }"
5
+ :class="[
6
+ !show ? 'u-close-alert-tips' : '',
7
+ type ? 'u-alert-tips--bg--' + type + '-light' : '',
8
+ type ? 'u-alert-tips--border--' + type + '-disabled' : '',
9
+ customClass
10
+ ]"
11
+ :style="
12
+ $u.toStyle(
13
+ {
14
+ backgroundColor: bgColor,
15
+ borderColor: borderColor
16
+ },
17
+ customStyle
18
+ )
19
+ "
10
20
  >
11
21
  <view class="u-icon-wrap">
12
- <u-icon v-if="showIcon" :name="uIconName" :size="description ? 40 : 32" class="u-icon" :color="uIconType" :custom-style="iconStyle"></u-icon>
22
+ <u-icon
23
+ v-if="showIcon"
24
+ :name="uIconName"
25
+ :size="description ? 40 : 32"
26
+ class="u-icon"
27
+ :color="uIconType"
28
+ :custom-style="iconStyle"
29
+ ></u-icon>
13
30
  </view>
14
31
  <view class="u-alert-content" @tap.stop="onClick">
15
32
  <view class="u-alert-title" :style="uTitleStyle">
@@ -44,16 +61,25 @@
44
61
  </view>
45
62
  </template>
46
63
 
64
+ <script lang="ts">
65
+ export default {
66
+ name: 'u-alert-tips',
67
+ options: {
68
+ addGlobalClass: true,
69
+ // #ifndef MP-TOUTIAO
70
+ virtualHost: true,
71
+ // #endif
72
+ styleIsolation: 'shared'
73
+ }
74
+ };
75
+ </script>
76
+
47
77
  <script setup lang="ts">
48
78
  import uIcon from '../u-icon/u-icon.vue';
49
79
  import { computed } from 'vue';
50
80
  import { $u } from '../..';
51
81
  import { AlertTipsProps } from './types';
52
82
 
53
- defineOptions({
54
- name: 'u-alert-tips'
55
- });
56
-
57
83
  /**
58
84
  * alertTips 警告提示
59
85
  * @description 警告提示,展现需要关注的信息
@@ -1,8 +1,10 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { ImgMode } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  // u-avatar 组件 props
5
6
  export const AvatarProps = {
7
+ ...baseProps,
6
8
  /** 背景颜色 */
7
9
  bgColor: { type: String, default: 'transparent' },
8
10
  /** 头像路径 */
@@ -1,6 +1,13 @@
1
1
  <template>
2
- <view class="u-avatar" :style="wrapStyle" @tap="onClick">
3
- <image @error="onLoadError" :style="imgStyle" class="u-avatar__img" v-if="!uText && avatar" :src="avatar" :mode="imgMode"></image>
2
+ <view class="u-avatar" :class="customClass" :style="$u.toStyle(wrapStyle, customStyle)" @tap="onClick">
3
+ <image
4
+ @error="onLoadError"
5
+ :style="imgStyle"
6
+ class="u-avatar__img"
7
+ v-if="!uText && avatar"
8
+ :src="avatar"
9
+ :mode="imgMode"
10
+ ></image>
4
11
  <text class="u-line-1" v-else-if="uText" :style="{ fontSize: '38rpx' }">{{ uText }}</text>
5
12
  <slot v-else></slot>
6
13
  <view class="u-avatar__sex" v-if="showSex" :class="['u-avatar__sex--' + sexIcon]" :style="uSexStyle">
@@ -12,13 +19,23 @@
12
19
  </view>
13
20
  </template>
14
21
 
22
+ <script lang="ts">
23
+ export default {
24
+ name: 'u-avatar',
25
+ options: {
26
+ addGlobalClass: true,
27
+ // #ifndef MP-TOUTIAO
28
+ virtualHost: true,
29
+ // #endif
30
+ styleIsolation: 'shared'
31
+ }
32
+ };
33
+ </script>
34
+
15
35
  <script setup lang="ts">
16
36
  import { ref, computed, watch } from 'vue';
17
37
  import { AvatarProps } from './types';
18
-
19
- defineOptions({
20
- name: 'u-avatar'
21
- });
38
+ import { $u } from '../..';
22
39
 
23
40
  let base64Avatar =
24
41
  'data:image/jpg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAA8AAD/4QMraHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzYgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjREMEQwRkY0RjgwNDExRUE5OTY2RDgxODY3NkJFODMxIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjREMEQwRkY1RjgwNDExRUE5OTY2RDgxODY3NkJFODMxIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NEQwRDBGRjJGODA0MTFFQTk5NjZEODE4Njc2QkU4MzEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NEQwRDBGRjNGODA0MTFFQTk5NjZEODE4Njc2QkU4MzEiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7/7gAOQWRvYmUAZMAAAAAB/9sAhAAGBAQEBQQGBQUGCQYFBgkLCAYG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';
@@ -69,7 +86,14 @@ watch(
69
86
  */
70
87
  const wrapStyle = computed(() => {
71
88
  let style: Record<string, string> = {};
72
- style.height = props.size === 'large' ? '120rpx' : props.size === 'default' ? '90rpx' : props.size === 'mini' ? '70rpx' : props.size + 'rpx';
89
+ style.height =
90
+ props.size === 'large'
91
+ ? '120rpx'
92
+ : props.size === 'default'
93
+ ? '90rpx'
94
+ : props.size === 'mini'
95
+ ? '70rpx'
96
+ : props.size + 'rpx';
73
97
  style.width = style.height;
74
98
  style.flex = `0 0 ${style.height}`;
75
99
  style.backgroundColor = props.bgColor;
@@ -37,6 +37,19 @@
37
37
  </view>
38
38
  </template>
39
39
 
40
+ <script lang="ts">
41
+ export default {
42
+ name: 'u-avatar-cropper',
43
+ options: {
44
+ addGlobalClass: true,
45
+ // #ifndef MP-TOUTIAO
46
+ virtualHost: true,
47
+ // #endif
48
+ styleIsolation: 'shared'
49
+ }
50
+ };
51
+ </script>
52
+
40
53
  <script setup lang="ts">
41
54
  // @ts-nocheck
42
55
  import { ref, reactive, onMounted } from 'vue';
@@ -45,8 +58,6 @@ import { $u } from '../..';
45
58
  import WeCropper from './weCropper';
46
59
  import { AvatarCropperProps } from './types';
47
60
 
48
- defineOptions({ name: 'u-avatar-cropper' });
49
-
50
61
  /**
51
62
  * 裁剪矩形框的样式,其中可包含的属性为lineWidth-边框宽度(单位rpx),color: 边框颜色,
52
63
  * mask-遮罩颜色,一般设置为一个rgba的透明度,如"rgba(0, 0, 0, 0.35)"
@@ -240,7 +240,14 @@
240
240
  self.deviceRadio = windowWidth / 750;
241
241
  }
242
242
 
243
- var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
243
+ var commonjsGlobal =
244
+ typeof window !== 'undefined'
245
+ ? window
246
+ : typeof global !== 'undefined'
247
+ ? global
248
+ : typeof self !== 'undefined'
249
+ ? self
250
+ : {};
244
251
 
245
252
  function createCommonjsModule(fn, module) {
246
253
  return (
@@ -478,14 +485,22 @@
478
485
  buffer = a + b + c;
479
486
  // Turn the 24 bits into four chunks of 6 bits each, and append the
480
487
  // matching character for each of them to the output.
481
- output += TABLE.charAt((buffer >> 18) & 0x3f) + TABLE.charAt((buffer >> 12) & 0x3f) + TABLE.charAt((buffer >> 6) & 0x3f) + TABLE.charAt(buffer & 0x3f);
488
+ output +=
489
+ TABLE.charAt((buffer >> 18) & 0x3f) +
490
+ TABLE.charAt((buffer >> 12) & 0x3f) +
491
+ TABLE.charAt((buffer >> 6) & 0x3f) +
492
+ TABLE.charAt(buffer & 0x3f);
482
493
  }
483
494
 
484
495
  if (padding == 2) {
485
496
  a = input.charCodeAt(position) << 8;
486
497
  b = input.charCodeAt(++position);
487
498
  buffer = a + b;
488
- output += TABLE.charAt(buffer >> 10) + TABLE.charAt((buffer >> 4) & 0x3f) + TABLE.charAt((buffer << 2) & 0x3f) + '=';
499
+ output +=
500
+ TABLE.charAt(buffer >> 10) +
501
+ TABLE.charAt((buffer >> 4) & 0x3f) +
502
+ TABLE.charAt((buffer << 2) & 0x3f) +
503
+ '=';
489
504
  } else if (padding == 1) {
490
505
  buffer = input.charCodeAt(position);
491
506
  output += TABLE.charAt(buffer >> 2) + TABLE.charAt((buffer << 4) & 0x3f) + '==';
@@ -701,7 +716,10 @@
701
716
  var strPixelRow = '';
702
717
  for (var x = 0; x < biWidth; x++) {
703
718
  var iOffsetX = x << 2;
704
- strPixelRow += fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) + fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) + fromCharCode(aImgData[iOffsetY + iOffsetX]);
719
+ strPixelRow +=
720
+ fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) +
721
+ fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) +
722
+ fromCharCode(aImgData[iOffsetY + iOffsetX]);
705
723
  }
706
724
 
707
725
  for (var c = 0; c < iPadding; c++) {
@@ -881,7 +899,13 @@
881
899
  if (tools_10(customOptions) && customOptions.original) {
882
900
  // original mode
883
901
  task = function () {
884
- self.targetCtx.drawImage(self.croperTarget, self.imgLeft * pixelRatio, self.imgTop * pixelRatio, self.scaleWidth * pixelRatio, self.scaleHeight * pixelRatio);
902
+ self.targetCtx.drawImage(
903
+ self.croperTarget,
904
+ self.imgLeft * pixelRatio,
905
+ self.imgTop * pixelRatio,
906
+ self.scaleWidth * pixelRatio,
907
+ self.scaleHeight * pixelRatio
908
+ );
885
909
 
886
910
  canvasOptions = {
887
911
  canvasId: targetId,
@@ -905,7 +929,9 @@
905
929
  fn = customOptions;
906
930
  }
907
931
 
908
- var arg = canvasOptions.componentContext ? [canvasOptions, canvasOptions.componentContext] : [canvasOptions];
932
+ var arg = canvasOptions.componentContext
933
+ ? [canvasOptions, canvasOptions.componentContext]
934
+ : [canvasOptions];
909
935
 
910
936
  return canvasToTempFilePath.apply(null, arg);
911
937
  })
@@ -1094,9 +1120,11 @@
1094
1120
  * @param imgTop 图片左上角纵坐标值
1095
1121
  */
1096
1122
  self.outsideBound = function (imgLeft, imgTop) {
1097
- self.imgLeft = imgLeft >= x ? x : self.scaleWidth + imgLeft - x <= width ? x + width - self.scaleWidth : imgLeft;
1123
+ self.imgLeft =
1124
+ imgLeft >= x ? x : self.scaleWidth + imgLeft - x <= width ? x + width - self.scaleWidth : imgLeft;
1098
1125
 
1099
- self.imgTop = imgTop >= y ? y : self.scaleHeight + imgTop - y <= height ? y + height - self.scaleHeight : imgTop;
1126
+ self.imgTop =
1127
+ imgTop >= y ? y : self.scaleHeight + imgTop - y <= height ? y + height - self.scaleHeight : imgTop;
1100
1128
  };
1101
1129
 
1102
1130
  /**
@@ -482,14 +482,22 @@ var base64 = createCommonjsModule(function (module, exports) {
482
482
  buffer = a + b + c;
483
483
  // Turn the 24 bits into four chunks of 6 bits each, and append the
484
484
  // matching character for each of them to the output.
485
- output += TABLE.charAt((buffer >> 18) & 0x3f) + TABLE.charAt((buffer >> 12) & 0x3f) + TABLE.charAt((buffer >> 6) & 0x3f) + TABLE.charAt(buffer & 0x3f);
485
+ output +=
486
+ TABLE.charAt((buffer >> 18) & 0x3f) +
487
+ TABLE.charAt((buffer >> 12) & 0x3f) +
488
+ TABLE.charAt((buffer >> 6) & 0x3f) +
489
+ TABLE.charAt(buffer & 0x3f);
486
490
  }
487
491
 
488
492
  if (padding == 2) {
489
493
  a = input.charCodeAt(position) << 8;
490
494
  b = input.charCodeAt(++position);
491
495
  buffer = a + b;
492
- output += TABLE.charAt(buffer >> 10) + TABLE.charAt((buffer >> 4) & 0x3f) + TABLE.charAt((buffer << 2) & 0x3f) + '=';
496
+ output +=
497
+ TABLE.charAt(buffer >> 10) +
498
+ TABLE.charAt((buffer >> 4) & 0x3f) +
499
+ TABLE.charAt((buffer << 2) & 0x3f) +
500
+ '=';
493
501
  } else if (padding == 1) {
494
502
  buffer = input.charCodeAt(position);
495
503
  output += TABLE.charAt(buffer >> 2) + TABLE.charAt((buffer << 4) & 0x3f) + '==';
@@ -705,7 +713,10 @@ function genBitmapImage(oData: any) {
705
713
  var strPixelRow = '';
706
714
  for (var x = 0; x < biWidth; x++) {
707
715
  var iOffsetX = x << 2;
708
- strPixelRow += fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) + fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) + fromCharCode(aImgData[iOffsetY + iOffsetX]);
716
+ strPixelRow +=
717
+ fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) +
718
+ fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) +
719
+ fromCharCode(aImgData[iOffsetY + iOffsetX]);
709
720
  }
710
721
 
711
722
  for (var c = 0; c < iPadding; c++) {
@@ -885,7 +896,13 @@ function methods(this: any) {
885
896
  if (tools_10(customOptions) && customOptions.original) {
886
897
  // original mode
887
898
  task = function () {
888
- self.targetCtx.drawImage(self.croperTarget, self.imgLeft * pixelRatio, self.imgTop * pixelRatio, self.scaleWidth * pixelRatio, self.scaleHeight * pixelRatio);
899
+ self.targetCtx.drawImage(
900
+ self.croperTarget,
901
+ self.imgLeft * pixelRatio,
902
+ self.imgTop * pixelRatio,
903
+ self.scaleWidth * pixelRatio,
904
+ self.scaleHeight * pixelRatio
905
+ );
889
906
 
890
907
  canvasOptions = {
891
908
  canvasId: targetId,
@@ -909,7 +926,9 @@ function methods(this: any) {
909
926
  fn = customOptions;
910
927
  }
911
928
 
912
- var arg = canvasOptions.componentContext ? [canvasOptions, canvasOptions.componentContext] : [canvasOptions];
929
+ var arg = canvasOptions.componentContext
930
+ ? [canvasOptions, canvasOptions.componentContext]
931
+ : [canvasOptions];
913
932
 
914
933
  return canvasToTempFilePath.apply(null, arg);
915
934
  })
@@ -1098,9 +1117,11 @@ function cut(this: any) {
1098
1117
  * @param imgTop 图片左上角纵坐标值
1099
1118
  */
1100
1119
  self.outsideBound = function (imgLeft: any, imgTop: any) {
1101
- self.imgLeft = imgLeft >= x ? x : self.scaleWidth + imgLeft - x <= width ? x + width - self.scaleWidth : imgLeft;
1120
+ self.imgLeft =
1121
+ imgLeft >= x ? x : self.scaleWidth + imgLeft - x <= width ? x + width - self.scaleWidth : imgLeft;
1102
1122
 
1103
- self.imgTop = imgTop >= y ? y : self.scaleHeight + imgTop - y <= height ? y + height - self.scaleHeight : imgTop;
1123
+ self.imgTop =
1124
+ imgTop >= y ? y : self.scaleHeight + imgTop - y <= height ? y + height - self.scaleHeight : imgTop;
1104
1125
  };
1105
1126
 
1106
1127
  /**
@@ -1,8 +1,10 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { Shape } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  // u-back-top 组件 props
5
6
  export const BackTopProps = {
7
+ ...baseProps,
6
8
  /** 返回顶部的形状,circle-圆形,square-方形 */
7
9
  mode: { type: String as PropType<Shape>, default: 'circle' },
8
10
  /** 自定义图标 */
@@ -28,11 +30,6 @@ export const BackTopProps = {
28
30
  color: '#909399',
29
31
  fontSize: '38rpx'
30
32
  })
31
- },
32
- /** 整个组件的样式 */
33
- customStyle: {
34
- type: Object as PropType<Record<string, any>>,
35
- default: () => ({})
36
33
  }
37
34
  };
38
35
 
@@ -2,17 +2,19 @@
2
2
  <view
3
3
  @tap="backToTop"
4
4
  class="u-back-top"
5
- :class="['u-back-top--mode--' + mode]"
6
- :style="[
7
- {
8
- bottom: bottom + 'rpx',
9
- right: right + 'rpx',
10
- borderRadius: mode == 'circle' ? '10000rpx' : '8rpx',
11
- zIndex: uZIndex,
12
- opacity: opacity
13
- },
14
- customStyle
15
- ]"
5
+ :class="['u-back-top--mode--' + mode, customClass]"
6
+ :style="
7
+ $u.toStyle(
8
+ {
9
+ bottom: bottom + 'rpx',
10
+ right: right + 'rpx',
11
+ borderRadius: mode == 'circle' ? '10000rpx' : '8rpx',
12
+ zIndex: uZIndex,
13
+ opacity: opacity
14
+ },
15
+ customStyle
16
+ )
17
+ "
16
18
  >
17
19
  <view class="u-back-top__content" v-if="!slots.default">
18
20
  <u-icon @click="backToTop" :name="icon" :custom-style="iconStyle"></u-icon>
@@ -24,13 +26,23 @@
24
26
  </view>
25
27
  </template>
26
28
 
29
+ <script lang="ts">
30
+ export default {
31
+ name: 'u-back-top',
32
+ options: {
33
+ addGlobalClass: true,
34
+ // #ifndef MP-TOUTIAO
35
+ virtualHost: true,
36
+ // #endif
37
+ styleIsolation: 'shared'
38
+ }
39
+ };
40
+ </script>
41
+
27
42
  <script setup lang="ts">
28
43
  import { ref, computed, watch, useSlots } from 'vue';
29
44
  import { BackTopProps } from './types';
30
-
31
- defineOptions({
32
- name: 'u-back-top'
33
- });
45
+ import { $u } from '../../';
34
46
 
35
47
  /**
36
48
  * back-top 返回顶部按钮
@@ -63,7 +75,10 @@ const uZIndex = ref(-1);
63
75
  */
64
76
  const showBackTop = computed(() => {
65
77
  // uni.upx2px 用于将 rpx 转为 px
66
- return Number(props.scrollTop) > (typeof uni !== 'undefined' && uni.upx2px ? uni.upx2px(Number(props.top)) : Number(props.top));
78
+ return (
79
+ Number(props.scrollTop) >
80
+ (typeof uni !== 'undefined' && uni.upx2px ? uni.upx2px(Number(props.top)) : Number(props.top))
81
+ );
67
82
  // #else
68
83
  // return Number(props.scrollTop) > Number(props.top)
69
84
  });
@@ -1,5 +1,6 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { BadgeSize, ThemeType } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * badge 角标类型定义
@@ -7,6 +8,7 @@ import type { BadgeSize, ThemeType } from '../../types/global';
7
8
  */
8
9
 
9
10
  export const BadgeProps = {
11
+ ...baseProps,
10
12
  /** 使用预设的背景颜色 primary,warning,success,error,info */
11
13
  type: { type: String as PropType<ThemeType>, default: 'error' },
12
14
  /** Badge的尺寸,default, mini */
@@ -2,30 +2,48 @@
2
2
  <view
3
3
  v-if="show"
4
4
  class="u-badge"
5
- :class="[isDot ? 'u-badge-dot' : '', size === 'mini' ? 'u-badge-mini' : '', type ? 'u-badge--bg--' + type : '']"
6
- :style="[
7
- {
8
- top: (offset as number[])[0] + 'rpx',
9
- right: (offset as number[])[1] + 'rpx',
10
- fontSize: fontSize + 'rpx',
11
- position: absolute ? 'absolute' : 'static',
12
- color: color,
13
- backgroundColor: bgColor
14
- },
15
- boxStyle
5
+ :class="[
6
+ isDot ? 'u-badge-dot' : '',
7
+ size === 'mini' ? 'u-badge-mini' : '',
8
+ type ? 'u-badge--bg--' + type : '',
9
+ customClass
16
10
  ]"
11
+ :style="
12
+ $u.toStyle(
13
+ {
14
+ top: (offset as number[])[0] + 'rpx',
15
+ right: (offset as number[])[1] + 'rpx',
16
+ fontSize: fontSize + 'rpx',
17
+ position: absolute ? 'absolute' : 'static',
18
+ color: color,
19
+ backgroundColor: bgColor
20
+ },
21
+ boxStyle,
22
+ customStyle
23
+ )
24
+ "
17
25
  >
18
26
  {{ showText }}
19
27
  </view>
20
28
  </template>
21
29
 
30
+ <script lang="ts">
31
+ export default {
32
+ name: 'u-badge',
33
+ options: {
34
+ addGlobalClass: true,
35
+ // #ifndef MP-TOUTIAO
36
+ virtualHost: true,
37
+ // #endif
38
+ styleIsolation: 'shared'
39
+ }
40
+ };
41
+ </script>
42
+
22
43
  <script setup lang="ts">
23
44
  import { computed } from 'vue';
24
45
  import { BadgeProps } from './types';
25
-
26
- defineOptions({
27
- name: 'u-badge'
28
- });
46
+ import { $u } from '../..';
29
47
 
30
48
  /**
31
49
  * badge 角标