uview-pro 0.3.16 → 0.4.2

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 (140) hide show
  1. package/changelog.md +82 -0
  2. package/components/u-action-sheet-item/u-action-sheet-item.vue +1 -1
  3. package/components/u-alert-tips/u-alert-tips.vue +2 -2
  4. package/components/u-avatar/u-avatar.vue +5 -5
  5. package/components/u-avatar-cropper/u-avatar-cropper.vue +5 -5
  6. package/components/u-avatar-cropper/weCropper.js +1 -1
  7. package/components/u-avatar-cropper/weCropper.ts +1 -1
  8. package/components/u-back-top/types.ts +1 -1
  9. package/components/u-back-top/u-back-top.vue +1 -1
  10. package/components/u-badge/u-badge.vue +1 -31
  11. package/components/u-button/types.ts +1 -1
  12. package/components/u-button/u-button.vue +45 -37
  13. package/components/u-calendar/types.ts +4 -4
  14. package/components/u-calendar/u-calendar.vue +8 -8
  15. package/components/u-car-keyboard/u-car-keyboard.vue +5 -5
  16. package/components/u-card/types.ts +2 -2
  17. package/components/u-card/u-card.vue +3 -3
  18. package/components/u-cell-group/u-cell-group.vue +1 -1
  19. package/components/u-cell-item/u-cell-item.vue +2 -2
  20. package/components/u-checkbox/u-checkbox.vue +7 -7
  21. package/components/u-circle-progress/types.ts +4 -3
  22. package/components/u-circle-progress/u-circle-progress.vue +3 -3
  23. package/components/u-city-select/u-city-select.vue +1 -1
  24. package/components/u-collapse/types.ts +2 -2
  25. package/components/u-collapse/u-collapse.vue +1 -1
  26. package/components/u-collapse-item/u-collapse-item.vue +1 -1
  27. package/components/u-column-notice/u-column-notice.vue +2 -2
  28. package/components/u-config-provider/types.ts +34 -0
  29. package/components/u-config-provider/u-config-provider.vue +141 -0
  30. package/components/u-count-down/types.ts +4 -4
  31. package/components/u-count-down/u-count-down.vue +4 -4
  32. package/components/u-count-to/types.ts +1 -1
  33. package/components/u-count-to/u-count-to.vue +1 -1
  34. package/components/u-divider/types.ts +3 -3
  35. package/components/u-divider/u-divider.vue +4 -4
  36. package/components/u-dropdown/u-dropdown.vue +3 -3
  37. package/components/u-empty/types.ts +2 -2
  38. package/components/u-empty/u-empty.vue +1 -1
  39. package/components/u-field/types.ts +3 -3
  40. package/components/u-field/u-field.vue +6 -6
  41. package/components/u-form-item/u-form-item.vue +1 -1
  42. package/components/u-full-screen/u-full-screen.vue +1 -1
  43. package/components/u-gap/u-gap.vue +2 -2
  44. package/components/u-grid-item/types.ts +1 -1
  45. package/components/u-grid-item/u-grid-item.vue +3 -3
  46. package/components/u-icon/types.ts +2 -2
  47. package/components/u-icon/u-icon.vue +2 -2
  48. package/components/u-image/types.ts +4 -2
  49. package/components/u-image/u-image.vue +7 -2
  50. package/components/u-index-anchor/u-index-anchor.vue +3 -3
  51. package/components/u-index-list/u-index-list.vue +1 -1
  52. package/components/u-input/types.ts +4 -4
  53. package/components/u-input/u-input.vue +7 -7
  54. package/components/u-keyboard/u-keyboard.vue +3 -3
  55. package/components/u-lazy-load/u-lazy-load.vue +1 -1
  56. package/components/u-line/types.ts +1 -1
  57. package/components/u-line/u-line.vue +1 -1
  58. package/components/u-line-progress/types.ts +2 -2
  59. package/components/u-line-progress/u-line-progress.vue +3 -3
  60. package/components/u-link/u-link.vue +1 -1
  61. package/components/u-loading/types.ts +1 -1
  62. package/components/u-loading/u-loading.vue +3 -3
  63. package/components/u-loading-popup/types.ts +1 -1
  64. package/components/u-loading-popup/u-loading-popup.vue +2 -2
  65. package/components/u-loadmore/types.ts +2 -2
  66. package/components/u-loadmore/u-loadmore.vue +6 -6
  67. package/components/u-message-input/u-message-input.vue +5 -5
  68. package/components/u-modal/u-modal.vue +2 -2
  69. package/components/u-navbar/types.ts +4 -4
  70. package/components/u-navbar/u-navbar.vue +27 -20
  71. package/components/u-no-network/u-no-network.vue +2 -2
  72. package/components/u-number-box/types.ts +4 -4
  73. package/components/u-number-box/u-number-box.vue +6 -6
  74. package/components/u-number-keyboard/u-number-keyboard.vue +2 -2
  75. package/components/u-picker/u-picker.vue +4 -4
  76. package/components/u-popup/types.ts +1 -1
  77. package/components/u-popup/u-popup.vue +6 -6
  78. package/components/u-radio/u-radio.vue +7 -7
  79. package/components/u-rate/types.ts +2 -2
  80. package/components/u-rate/u-rate.vue +2 -2
  81. package/components/u-read-more/types.ts +1 -1
  82. package/components/u-row-notice/u-row-notice.vue +2 -2
  83. package/components/u-search/types.ts +4 -4
  84. package/components/u-search/u-search.vue +4 -4
  85. package/components/u-section/types.ts +2 -2
  86. package/components/u-section/u-section.vue +2 -2
  87. package/components/u-select/u-select.vue +6 -6
  88. package/components/u-skeleton/types.ts +2 -2
  89. package/components/u-skeleton/u-skeleton.vue +2 -2
  90. package/components/u-slider/types.ts +1 -1
  91. package/components/u-slider/u-slider.vue +4 -4
  92. package/components/u-step/u-step.vue +4 -4
  93. package/components/u-steps/u-steps.vue +3 -3
  94. package/components/u-sticky/types.ts +1 -1
  95. package/components/u-sticky/u-sticky.vue +1 -1
  96. package/components/u-subsection/types.ts +4 -4
  97. package/components/u-subsection/u-subsection.vue +7 -7
  98. package/components/u-swipe-action/types.ts +1 -1
  99. package/components/u-swipe-action/u-swipe-action.vue +2 -2
  100. package/components/u-swiper/types.ts +1 -1
  101. package/components/u-swiper/u-swiper.vue +1 -1
  102. package/components/u-switch/types.ts +1 -1
  103. package/components/u-switch/u-switch.vue +5 -5
  104. package/components/u-tabbar/types.ts +5 -4
  105. package/components/u-tabbar/u-tabbar.vue +5 -5
  106. package/components/u-table/types.ts +3 -3
  107. package/components/u-table/u-table.vue +3 -3
  108. package/components/u-tabs/types.ts +1 -1
  109. package/components/u-tabs/u-tabs.vue +2 -2
  110. package/components/u-tabs-swiper/types.ts +1 -1
  111. package/components/u-tabs-swiper/u-tabs-swiper.vue +2 -2
  112. package/components/u-tag/u-tag.vue +12 -12
  113. package/components/u-text/types.ts +1 -1
  114. package/components/u-text/u-text.vue +1 -1
  115. package/components/u-textarea/types.ts +1 -1
  116. package/components/u-textarea/u-textarea.vue +6 -6
  117. package/components/u-time-line/u-time-line.vue +1 -1
  118. package/components/u-time-line-item/types.ts +1 -1
  119. package/components/u-time-line-item/u-time-line-item.vue +2 -3
  120. package/components/u-toast/u-toast.vue +8 -8
  121. package/components/u-top-tips/u-top-tips.vue +1 -1
  122. package/components/u-upload/types.ts +2 -2
  123. package/components/u-upload/u-upload.vue +1 -1
  124. package/index.scss +1 -0
  125. package/index.ts +42 -11
  126. package/libs/config/theme-tokens.ts +101 -0
  127. package/libs/css/style.theme.scss +31 -0
  128. package/libs/css/style.vue.scss +1 -1
  129. package/libs/function/clipboard.ts +6 -11
  130. package/libs/function/color.ts +53 -22
  131. package/libs/hooks/index.ts +2 -0
  132. package/libs/hooks/useColor.ts +61 -0
  133. package/libs/hooks/useTheme.ts +162 -0
  134. package/libs/index.ts +4 -3
  135. package/libs/util/config-provider.ts +580 -0
  136. package/libs/util/system-theme.ts +25 -0
  137. package/package.json +5 -5
  138. package/theme.scss +50 -34
  139. package/types/components.d.ts +1 -0
  140. package/types/global.d.ts +47 -2
@@ -57,7 +57,7 @@ import { SwipeActionProps } from './types';
57
57
  * swipeAction 左滑单元格
58
58
  * @description 该组件一般用于左滑唤出操作菜单的场景,用的最多的是左滑删除操作。
59
59
  * @tutorial https://uviewpro.cn/zh/components/swipeAction.html
60
- * @property {String} bg-color 整个组件背景颜色(默认#ffffff
60
+ * @property {String} bg-color 整个组件背景颜色(默认var(--u-bg-white)
61
61
  * @property {Array} options 数组形式,可以配置背景颜色和文字
62
62
  * @property {String|Number} index 标识符,点击时候用于区分点击了哪一个,用v-for循环时的index即可
63
63
  * @property {String|Number} btn-width 按钮宽度,单位rpx(默认180)
@@ -264,7 +264,7 @@ function contentClick() {
264
264
  .u-swipe-del {
265
265
  position: relative;
266
266
  font-size: 30rpx;
267
- color: #ffffff;
267
+ color: var(--u-white-color);
268
268
  }
269
269
 
270
270
  .u-btn-text {
@@ -39,7 +39,7 @@ export const SwiperProps = {
39
39
  /** 轮播项对象的图片字段名 */
40
40
  name: { type: String, default: 'image' },
41
41
  /** 轮播背景色 */
42
- bgColor: { type: String, default: '#f3f4f6' },
42
+ bgColor: { type: String, default: 'var(--u-bg-color)' },
43
43
  /** 当前激活项索引 */
44
44
  current: { type: [Number, String] as PropType<number | string>, default: 0 },
45
45
  /** 标题样式对象 */
@@ -115,7 +115,7 @@ import { $u } from '../..';
115
115
  * @property {Boolean} autoplay 是否自动播放(默认true)
116
116
  * @property {String|Number} interval 自动轮播时间间隔,单位ms(默认2500)
117
117
  * @property {Boolean} circular 是否衔接播放,见官网说明(默认true)
118
- * @property {String} bg-color 背景颜色(默认#f3f4f6
118
+ * @property {String} bg-color 背景颜色(默认var(--u-bg-color)
119
119
  * @property {String|Number} border-radius 轮播图圆角值,单位rpx(默认8)
120
120
  * @property {Object} title-style 自定义标题样式
121
121
  * @property {String|Number} effect3d-previous-margin mode = true模式的情况下,激活项与前后项之间的距离,单位rpx(默认50)
@@ -17,7 +17,7 @@ export const SwitchProps = {
17
17
  /** 打开时的颜色 */
18
18
  activeColor: { type: String, default: () => getColor('primary') },
19
19
  /** 关闭时的颜色 */
20
- inactiveColor: { type: String, default: '#ffffff' },
20
+ inactiveColor: { type: String, default: 'var(--u-white-color)' },
21
21
  /** v-model 绑定值,是否选中 */
22
22
  modelValue: { type: Boolean, default: false },
23
23
  /** 是否开启轻微震动反馈 */
@@ -43,11 +43,11 @@ import { SwitchProps } from './types';
43
43
  * @property {Boolean} disabled 是否禁用(默认false)
44
44
  * @property {String|Number} size 开关尺寸,单位rpx(默认50)
45
45
  * @property {String} active-color 打开时的背景色(默认主题色primary)
46
- * @property {String} inactive-color 关闭时的背景色(默认#ffffff
46
+ * @property {String} inactive-color 关闭时的背景色(默认var(--u-bg-white)
47
47
  * @property {Boolean|Number|String} active-value 打开选择器时通过change事件发出的值(默认true)
48
48
  * @property {Boolean|Number|String} inactive-value 关闭选择器时通过change事件发出的值(默认false)
49
49
  * @event {Function} change 在switch打开或关闭时触发
50
- * @example <u-switch v-model="checked" active-color="red" inactive-color="#eee"></u-switch>
50
+ * @example <u-switch v-model="checked" active-color="red" inactive-color="var(--u-divider-color)"></u-switch>
51
51
  */
52
52
  const props = defineProps(SwitchProps);
53
53
 
@@ -96,7 +96,7 @@ function onClick() {
96
96
  box-sizing: initial;
97
97
  width: 2em;
98
98
  height: 1em;
99
- background-color: #fff;
99
+ background-color: var(--u-bg-white);
100
100
  border: 1px solid rgba(0, 0, 0, 0.1);
101
101
  border-radius: 1em;
102
102
  transition: background-color 0.3s;
@@ -112,8 +112,8 @@ function onClick() {
112
112
  left: 0;
113
113
  border-radius: 100%;
114
114
  z-index: 1;
115
- background-color: #fff;
116
- background-color: #fff;
115
+ background-color: var(--u-bg-white);
116
+ background-color: var(--u-bg-white);
117
117
  box-shadow:
118
118
  0 3px 1px 0 rgba(0, 0, 0, 0.05),
119
119
  0 2px 2px 0 rgba(0, 0, 0, 0.1),
@@ -1,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { baseProps } from '../common/props';
3
+ import type { TabbarItem } from '../../types/global';
3
4
 
4
5
  /**
5
6
  * TabbarProps 底部导航栏 props 类型定义
@@ -12,7 +13,7 @@ export const TabbarProps = {
12
13
  /** v-model绑定当前激活项的值 */
13
14
  modelValue: { type: [String, Number] as PropType<string | number>, default: 0 },
14
15
  /** tabbar背景色 */
15
- bgColor: { type: String, default: '#ffffff' },
16
+ bgColor: { type: String, default: 'var(--u-bg-white)' },
16
17
  /** tabbar高度,单位任意,数值默认rpx */
17
18
  height: { type: [String, Number] as PropType<string | number>, default: '50px' },
18
19
  /** 非凸起图标的大小,单位任意,数值默认rpx */
@@ -20,13 +21,13 @@ export const TabbarProps = {
20
21
  /** 凸起图标的大小,单位任意,数值默认rpx */
21
22
  midButtonSize: { type: [String, Number] as PropType<string | number>, default: 90 },
22
23
  /** 激活时的颜色 */
23
- activeColor: { type: String, default: '#303133' },
24
+ activeColor: { type: String, default: 'var(--u-main-color)' },
24
25
  /** 未激活时的颜色 */
25
- inactiveColor: { type: String, default: '#606266' },
26
+ inactiveColor: { type: String, default: 'var(--u-content-color)' },
26
27
  /** 是否显示中部凸起按钮 */
27
28
  midButton: { type: Boolean, default: false },
28
29
  /** tabbar配置项数组 */
29
- list: { type: Array as PropType<any[]>, default: () => [] },
30
+ list: { type: Array as PropType<TabbarItem[]>, default: () => [] },
30
31
  /** 切换前回调,返回true或Promise */
31
32
  beforeSwitch: { type: Function as PropType<((index: number) => boolean | Promise<any>) | null>, default: null },
32
33
  /** 是否显示顶部横线 */
@@ -74,7 +74,7 @@ export default {
74
74
  </script>
75
75
 
76
76
  <script setup lang="ts">
77
- import { ref, computed, onMounted, getCurrentInstance } from 'vue';
77
+ import { ref, computed, onMounted } from 'vue';
78
78
  import { $u } from '../..';
79
79
  import { TabbarProps } from './types';
80
80
 
@@ -250,7 +250,7 @@ function getMidButtonLeft() {
250
250
  top: -48rpx;
251
251
  position: absolute;
252
252
  z-index: 4;
253
- background-color: #ffffff;
253
+ background-color: var(--u-bg-white);
254
254
  // 由于安卓的无能,导致只有3个tabbar item时,此css计算方式有误差
255
255
  // 故使用js计算的形式来定位,此处不注释,是因为js计算有延后,避免出现位置闪动
256
256
  left: 50%;
@@ -270,7 +270,7 @@ function getMidButtonLeft() {
270
270
  position: relative;
271
271
  &__button {
272
272
  position: absolute;
273
- top: 14rpx;
273
+ top: 8rpx;
274
274
  left: 50%;
275
275
  transform: translateX(-50%);
276
276
  }
@@ -279,7 +279,7 @@ function getMidButtonLeft() {
279
279
  font-size: 26rpx;
280
280
  line-height: 28rpx;
281
281
  position: absolute;
282
- bottom: 14rpx;
282
+ bottom: 8rpx;
283
283
  left: 50%;
284
284
  transform: translateX(-50%);
285
285
  width: 100%;
@@ -303,7 +303,7 @@ function getMidButtonLeft() {
303
303
  justify-content: center;
304
304
  align-items: center;
305
305
  position: absolute;
306
- background-color: #ffffff;
306
+ background-color: var(--u-bg-white);
307
307
  top: -40rpx;
308
308
  left: 50%;
309
309
  z-index: 6;
@@ -9,7 +9,7 @@ import { baseProps } from '../common/props';
9
9
  export const TableProps = {
10
10
  ...baseProps,
11
11
  /** 表格边框的颜色 */
12
- borderColor: { type: String, default: '#e4e7ed' },
12
+ borderColor: { type: String, default: 'var(--u-border-color)' },
13
13
  /** 单元格的内容对齐方式,作用类似css的text-align */
14
14
  align: { type: String as PropType<TextAlign>, default: 'center' },
15
15
  /** 单元格的内边距,同css的padding写法 */
@@ -17,11 +17,11 @@ export const TableProps = {
17
17
  /** 单元格字体大小,单位rpx */
18
18
  fontSize: { type: [String, Number] as PropType<number | string>, default: 28 },
19
19
  /** 单元格字体颜色 */
20
- color: { type: String, default: '#606266' },
20
+ color: { type: String, default: 'var(--u-content-color)' },
21
21
  /** th单元格的样式,对象形式(将th所需参数放在table组件,是为了避免每一个th组件要写一遍) */
22
22
  thStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
23
23
  /** 表格的背景颜色 */
24
- bgColor: { type: String, default: '#ffffff' }
24
+ bgColor: { type: String, default: 'var(--u-bg-white)' }
25
25
  };
26
26
 
27
27
  export type TableProps = ExtractPropTypes<typeof TableProps>;
@@ -26,12 +26,12 @@ import { $u } from '../..';
26
26
  * table 表格
27
27
  * @description 表格组件一般用于展示大量结构化数据的场景
28
28
  * @tutorial https://uviewpro.cn/zh/components/table.html
29
- * @property {String} border-color 表格边框的颜色(默认#e4e7ed
30
- * @property {String} bg-color 表格的背景颜色(默认#ffffff
29
+ * @property {String} border-color 表格边框的颜色(默认var(--u-border-color)
30
+ * @property {String} bg-color 表格的背景颜色(默认var(--u-bg-white)
31
31
  * @property {String} align 单元格的内容对齐方式,作用类似css的text-align(默认center)
32
32
  * @property {String} padding 单元格的内边距,同css的padding写法(默认10rpx 0)
33
33
  * @property {String | Number} font-size 单元格字体大小,单位rpx(默认28)
34
- * @property {String} color 单元格字体颜色(默认#606266
34
+ * @property {String} color 单元格字体颜色(默认var(--u-content-color)
35
35
  * @property {Object} th-style th单元格的样式,对象形式(将th所需参数放在table组件,是为了避免每一个th组件要写一遍)
36
36
  * @event {Function} click 点击组件时触发
37
37
  * @event {Function} close 点击关闭按钮时触发
@@ -32,7 +32,7 @@ export const TabsProps = {
32
32
  /** 单个tab的左右内边距之和,单位rpx */
33
33
  gutter: { type: [String, Number] as PropType<number | string>, default: 30 },
34
34
  /** 导航栏的背景颜色 */
35
- bgColor: { type: String, default: '#ffffff' },
35
+ bgColor: { type: String, default: 'var(--u-bg-white)' },
36
36
  /** 读取传入的数组对象的属性(tab名称) */
37
37
  name: { type: String, default: 'name' },
38
38
  /** 读取传入的数组对象的属性(徽标数) */
@@ -52,7 +52,7 @@ import { TabsProps } from './types';
52
52
  * @property {String|Number} font-size tab文字大小,单位rpx(默认30)
53
53
  * @property {String|Number} duration 滑块移动一次所需的时间,单位秒(默认0.5)
54
54
  * @property {String} active-color 滑块和激活tab文字的颜色(默认主题色primary)
55
- * @property {String} inactive-color tabs文字颜色(默认#303133
55
+ * @property {String} inactive-color tabs文字颜色(默认var(--u-main-color)
56
56
  * @property {String|Number} bar-width 滑块宽度,单位rpx(默认40)
57
57
  * @property {Object} active-item-style 活动tabs item的样式,对象形式
58
58
  * @property {Object} bar-style 底部滑块的样式,对象形式
@@ -60,7 +60,7 @@ import { TabsProps } from './types';
60
60
  * @property {String|Number} bar-height 滑块高度,单位rpx(默认6)
61
61
  * @property {String|Number} item-width 标签的宽度(默认auto)
62
62
  * @property {String|Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40)
63
- * @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff
63
+ * @property {String} bg-color tabs导航栏的背景颜色(默认var(--u-bg-white)
64
64
  * @property {String} name 组件内部读取的list参数中的属性名(tab名称),见官网说明(默认name)
65
65
  * @property {String} count 组件内部读取的list参数中的属性名(badge徽标数),同name属性的使用,见官网说明(默认count)
66
66
  * @property {Array} offset 设置badge徽标数的位置偏移,格式为 [x, y],也即设置的为top和right的值,单位rpx(默认[5, 20])
@@ -34,7 +34,7 @@ export const TabsSwiperProps = {
34
34
  /** z-index 层级 */
35
35
  zIndex: { type: [Number, String] as PropType<number | string>, default: 1 },
36
36
  /** tabs导航栏的背景颜色 */
37
- bgColor: { type: String, default: '#ffffff' },
37
+ bgColor: { type: String, default: 'var(--u-bg-white)' },
38
38
  /** 居中模式,window/组件宽度 */
39
39
  autoCenterMode: { type: String as unknown as PropType<TabsSwiperAutoCenterMode>, default: 'window' },
40
40
  /** 组件内部读取的list参数中的属性名(tab名称) */
@@ -55,14 +55,14 @@ import { $u } from '../..';
55
55
  * @property {String|Number} font-size tab文字大小,单位rpx(默认30)
56
56
  * @property {String|Number} swiper-width tabs组件外部swiper的宽度,默认为屏幕宽度,单位rpx(默认750)
57
57
  * @property {String} active-color 滑块和激活tab文字的颜色(默认主题色primary)
58
- * @property {String} inactive-color tabs文字颜色(默认#303133
58
+ * @property {String} inactive-color tabs文字颜色(默认var(--u-main-color)
59
59
  * @property {String|Number} bar-width 滑块宽度,单位rpx(默认40)
60
60
  * @property {String|Number} bar-height 滑块高度,单位rpx(默认6)
61
61
  * @property {Object} bar-style 底部滑块的样式,对象形式
62
62
  * @property {Object} active-item-style 活动tabs item的样式,对象形式
63
63
  * @property {Boolean} show-bar 是否显示底部的滑块(默认true)
64
64
  * @property {String|Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40)
65
- * @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff
65
+ * @property {String} bg-color tabs导航栏的背景颜色(默认var(--u-bg-white)
66
66
  * @property {String} name 组件内部读取的list参数中的属性名,见官网说明(默认name)
67
67
  * @property {String} count 组件内部读取的list参数中的属性名(badge徽标数),同name属性的使用,见官网说明(默认count)
68
68
  * @property {Array} offset 设置badge徽标数的位置偏移,格式为 [x, y],也即设置的为top和right的值,单位rpx(默认[5, 20])
@@ -96,7 +96,7 @@ const iconStyle = computed(() => {
96
96
  if (props.size === 'mini') style.fontSize = '20rpx';
97
97
  else style.fontSize = '22rpx';
98
98
  if (props.mode === 'plain' || props.mode === 'light') style.color = props.type;
99
- else if (props.mode === 'dark') style.color = '#ffffff';
99
+ else if (props.mode === 'dark') style.color = 'var(--u-white-color)';
100
100
  if (props.closeColor) style.color = props.closeColor;
101
101
  return style;
102
102
  });
@@ -110,7 +110,7 @@ const closeIconColor = computed(() => {
110
110
  // 最后如果上面的三者都不合适,就返回type值给图标获取颜色
111
111
  if (props.closeColor) return props.closeColor;
112
112
  else if (props.color) return props.color;
113
- else if (props.mode === 'dark') return '#ffffff';
113
+ else if (props.mode === 'dark') return 'var(--u-white-color)';
114
114
  else return props.type;
115
115
  });
116
116
 
@@ -186,55 +186,55 @@ function close() {
186
186
 
187
187
  .u-mode-dark-primary {
188
188
  background-color: $u-type-primary;
189
- color: #ffffff;
189
+ color: var(--u-white-color);
190
190
  }
191
191
 
192
192
  .u-mode-dark-success {
193
193
  background-color: $u-type-success;
194
- color: #ffffff;
194
+ color: var(--u-white-color);
195
195
  }
196
196
 
197
197
  .u-mode-dark-error {
198
198
  background-color: $u-type-error;
199
- color: #ffffff;
199
+ color: var(--u-white-color);
200
200
  }
201
201
 
202
202
  .u-mode-dark-warning {
203
203
  background-color: $u-type-warning;
204
- color: #ffffff;
204
+ color: var(--u-white-color);
205
205
  }
206
206
 
207
207
  .u-mode-dark-info {
208
208
  background-color: $u-type-info;
209
- color: #ffffff;
209
+ color: var(--u-white-color);
210
210
  }
211
211
 
212
212
  .u-mode-plain-primary {
213
- background-color: #ffffff;
213
+ background-color: var(--u-bg-white);
214
214
  color: $u-type-primary;
215
215
  border: 1px solid $u-type-primary;
216
216
  }
217
217
 
218
218
  .u-mode-plain-success {
219
- background-color: #ffffff;
219
+ background-color: var(--u-bg-white);
220
220
  color: $u-type-success;
221
221
  border: 1px solid $u-type-success;
222
222
  }
223
223
 
224
224
  .u-mode-plain-error {
225
- background-color: #ffffff;
225
+ background-color: var(--u-bg-white);
226
226
  color: $u-type-error;
227
227
  border: 1px solid $u-type-error;
228
228
  }
229
229
 
230
230
  .u-mode-plain-warning {
231
- background-color: #ffffff;
231
+ background-color: var(--u-bg-white);
232
232
  color: $u-type-warning;
233
233
  border: 1px solid $u-type-warning;
234
234
  }
235
235
 
236
236
  .u-mode-plain-info {
237
- background-color: #ffffff;
237
+ background-color: var(--u-bg-white);
238
238
  color: $u-type-info;
239
239
  border: 1px solid $u-type-info;
240
240
  }
@@ -31,7 +31,7 @@ export const TextProps = {
31
31
  /** 显示行数,超出省略号 */
32
32
  lines: { type: [String, Number] as PropType<string | number>, default: '' },
33
33
  /** 文本颜色 */
34
- color: { type: String, default: '#303133' },
34
+ color: { type: String, default: 'var(--u-main-color)' },
35
35
  /** 字体大小 */
36
36
  size: { type: [String, Number] as PropType<string | number>, default: 28 },
37
37
  /** 图标样式 */
@@ -102,7 +102,7 @@ import { $u } from '../../';
102
102
  * @property {Boolean} bold 是否粗体,默认normal(默认 false )
103
103
  * @property {Boolean} block 是否块状(默认 false )
104
104
  * @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
105
- * @property {String} color 文本颜色(默认 '#303133' )
105
+ * @property {String} color 文本颜色(默认 'var(--u-main-color)' )
106
106
  * @property {String | Number} size 字体大小(默认 15 )
107
107
  * @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '15px'} )
108
108
  * @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
@@ -5,7 +5,7 @@ const textarea = {
5
5
  value: '',
6
6
  placeholder: '',
7
7
  placeholderClass: 'input-placeholder',
8
- placeholderStyle: 'color: #c0c4cc',
8
+ placeholderStyle: 'color: var(--u-light-color)',
9
9
  height: '100rpx',
10
10
  confirmType: 'done',
11
11
  disabled: false,
@@ -42,7 +42,7 @@
42
42
  <text
43
43
  class="u-textarea__count"
44
44
  :style="{
45
- 'background-color': props.disabled ? 'transparent' : '#fff'
45
+ 'background-color': props.disabled ? 'transparent' : 'var(--u-bg-white)'
46
46
  }"
47
47
  v-if="props.count"
48
48
  >
@@ -54,7 +54,7 @@
54
54
  class="u-textarea__right-icon__clear u-textarea__right-icon__item"
55
55
  v-if="clearable && modelValue != '' && !disabled"
56
56
  >
57
- <u-icon size="32" name="close-circle-fill" color="#c0c4cc" @click="onClear" />
57
+ <u-icon size="32" name="close-circle-fill" color="var(--u-light-color)" @click="onClear" />
58
58
  </view>
59
59
  </view>
60
60
  </view>
@@ -285,14 +285,14 @@ defineExpose({
285
285
 
286
286
  .u-textarea {
287
287
  border-radius: 4px;
288
- background-color: #fff;
288
+ background-color: var(--u-bg-white);
289
289
  position: relative;
290
290
  @include flex;
291
291
  flex: 1;
292
292
 
293
293
  &--border {
294
294
  border-radius: 4px;
295
- border: 1px solid $u-form-item-border-color;
295
+ border: 1px solid $u-border-color;
296
296
  }
297
297
 
298
298
  &--error {
@@ -308,7 +308,7 @@ defineExpose({
308
308
  }
309
309
 
310
310
  &--disabled {
311
- background-color: #f5f7fa;
311
+ background-color: $u-bg-gray-light;
312
312
  }
313
313
 
314
314
  &__field {
@@ -324,7 +324,7 @@ defineExpose({
324
324
  bottom: 0;
325
325
  font-size: 12px;
326
326
  color: $u-tips-color;
327
- background-color: #ffffff;
327
+ background-color: var(--u-bg-white);
328
328
  padding: 1px 4px;
329
329
  border-radius: 10px;
330
330
  line-height: 16px;
@@ -46,7 +46,7 @@ const props = defineProps({ ...baseProps });
46
46
  top: 12rpx;
47
47
  width: 1px;
48
48
  bottom: 0;
49
- border-left: 1px solid #ddd;
49
+ border-left: 1px solid var(--u-divider-color);
50
50
  transform-origin: 0 0;
51
51
  transform: scaleX(0.5);
52
52
  }
@@ -8,7 +8,7 @@ import { baseProps } from '../common/props';
8
8
  export const TimeLineItemProps = {
9
9
  ...baseProps,
10
10
  /** 节点的背景颜色 */
11
- bgColor: { type: String, default: '#ffffff' },
11
+ bgColor: { type: String, default: 'var(--u-bg-white)' },
12
12
  /** 节点左边图标绝对定位的top值,单位rpx */
13
13
  nodeTop: { type: [String, Number] as PropType<string | number>, default: '' }
14
14
  };
@@ -31,14 +31,13 @@ import { $u } from '../../';
31
31
  * timeLineItem 时间轴Item
32
32
  * @description 时间轴组件一般用于物流信息展示,各种跟时间相关的记录等场景。(搭配u-time-line使用)
33
33
  * @tutorial https://uviewpro.cn/zh/components/timeLine.html
34
- * @property {String} bg-color 左边节点的背景颜色,一般通过slot内容自定义背景颜色即可(默认#ffffff
34
+ * @property {String} bg-color 左边节点的背景颜色,一般通过slot内容自定义背景颜色即可(默认var(--u-bg-white)
35
35
  * @property {String | Number} node-top 节点左边图标绝对定位的top值,单位rpx
36
36
  * @example <u-time-line-item node-top="2">...</u-time-line-item>
37
37
  */
38
38
 
39
39
  /**
40
40
  * 节点的背景颜色
41
- * @default "#ffffff"
42
41
  */
43
42
  const props = defineProps(TimeLineItemProps);
44
43
 
@@ -85,6 +84,6 @@ const nodeStyle = computed(() => {
85
84
  height: 16rpx;
86
85
  width: 16rpx;
87
86
  border-radius: 100rpx;
88
- background: #ddd;
87
+ background: var(--u-divider-color);
89
88
  }
90
89
  </style>
@@ -165,9 +165,9 @@ defineExpose<ToastExpose>({
165
165
  z-index: -1;
166
166
  transition: opacity 0.3s;
167
167
  text-align: center;
168
- color: #fff;
168
+ color: var(--u-white-color);
169
169
  border-radius: 8rpx;
170
- background: #585858;
170
+ background: var(--u-content-color);
171
171
  @include vue-flex;
172
172
  align-items: center;
173
173
  justify-content: center;
@@ -224,29 +224,29 @@ defineExpose<ToastExpose>({
224
224
  .u-type-success {
225
225
  color: $u-type-success;
226
226
  background-color: $u-type-success-light;
227
- border: 1px solid #bef5c8;
227
+ border: 1px solid var(--u-type-success-light);
228
228
  }
229
229
 
230
230
  .u-type-error {
231
231
  color: $u-type-error;
232
232
  background-color: $u-type-error-light;
233
- border: 1px solid #fde2e2;
233
+ border: 1px solid var(--u-type-error-light);
234
234
  }
235
235
 
236
236
  .u-type-warning {
237
237
  color: $u-type-warning;
238
238
  background-color: $u-type-warning-light;
239
- border: 1px solid #faecd8;
239
+ border: 1px solid var(--u-type-warning-light);
240
240
  }
241
241
 
242
242
  .u-type-info {
243
243
  color: $u-type-info;
244
244
  background-color: $u-type-info-light;
245
- border: 1px solid #ebeef5;
245
+ border: 1px solid var(--u-bg-gray-light);
246
246
  }
247
247
 
248
248
  .u-type-default {
249
- color: #fff;
250
- background-color: #585858;
249
+ color: var(--u-white-color);
250
+ background-color: var(--u-content-color);
251
251
  }
252
252
  </style>
@@ -96,7 +96,7 @@ view {
96
96
  position: fixed;
97
97
  z-index: 1;
98
98
  padding: 20rpx 30rpx;
99
- color: #ffffff;
99
+ color: var(--u-white-color);
100
100
  font-size: 28rpx;
101
101
  left: 0;
102
102
  right: 0;
@@ -21,11 +21,11 @@ export const UploadProps = {
21
21
  /** 是否显示上传进度 */
22
22
  showProgress: { type: Boolean, default: true },
23
23
  /** 删除按钮背景色 */
24
- delBgColor: { type: String, default: '#f56c6c' },
24
+ delBgColor: { type: String, default: 'var(--u-type-error)' },
25
25
  /** 删除按钮图标 */
26
26
  delIcon: { type: String, default: 'close' },
27
27
  /** 删除按钮颜色 */
28
- delColor: { type: String, default: '#fff' },
28
+ delColor: { type: String, default: 'var(--u-white-color)' },
29
29
  /** 图片裁剪模式 */
30
30
  imageMode: { type: String as PropType<ImgMode>, default: 'aspectFill' },
31
31
  /** 是否自定义上传按钮 */
@@ -553,7 +553,7 @@ defineExpose({ clear, reUpload, selectFile, upload, retry, remove, doPreviewImag
553
553
  }
554
554
 
555
555
  .u-error-btn {
556
- color: #ffffff;
556
+ color: var(--u-white-color);
557
557
  background-color: $u-type-error;
558
558
  font-size: 20rpx;
559
559
  padding: 4px 0;
package/index.scss CHANGED
@@ -1,4 +1,5 @@
1
1
  // 引入公共基础类
2
+ @import './libs/css/style.theme.scss';
2
3
  @import './libs/css/common.scss';
3
4
  @import './libs/css/color.scss';
4
5
 
package/index.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { $u, type RequestOptions } from './libs';
2
- import type { UViewProOptions } from './types/global';
1
+ import { $u, type RequestOptions, initTheme } from './libs';
2
+ import type { UViewProOptions, Theme } from './types/global';
3
3
  import { logger } from './libs/util/logger';
4
+ import { defaultThemes } from './libs/config/theme-tokens';
4
5
 
5
6
  declare const uni: {
6
7
  [key: string]: any;
@@ -13,16 +14,46 @@ declare const uni: {
13
14
 
14
15
  // $u挂载到uni对象上
15
16
  const install = (app: any, options?: UViewProOptions): void => {
16
- if (options) {
17
- // 配置主题:使用 $u.setTheme 以就地更新 reactive $u.color
18
- if (options.theme) {
19
- $u.setTheme?.(options.theme);
17
+ try {
18
+ if (options) {
19
+ // 配置主题:统一使用 useTheme 的 initTheme 初始化,避免重复初始化
20
+ if (options.theme) {
21
+ // 如果是数组,则为多主题配置
22
+ // 直接使用 useTheme 的 initTheme,它会智能处理重复初始化
23
+ if (Array.isArray(options.theme)) {
24
+ initTheme(options.theme);
25
+ } else {
26
+ // 兼容之前只有一套样式的情况,需要覆盖默认主题
27
+ // 获取默认主题(uviewpro)
28
+ const defaultTheme = defaultThemes[0];
29
+ if (defaultTheme) {
30
+ // 创建新主题对象,用用户的 theme 覆盖默认主题的 color
31
+ const mergedTheme: Theme = {
32
+ ...defaultTheme,
33
+ color: {
34
+ ...defaultTheme.color,
35
+ ...options.theme
36
+ }
37
+ };
38
+ // 初始化主题(只包含覆盖后的默认主题)
39
+ initTheme([mergedTheme], defaultTheme.name);
40
+ }
41
+ }
42
+ } else {
43
+ // 默认初始化系统主题
44
+ initTheme();
45
+ }
46
+ // 设置调试模式
47
+ logger
48
+ .setDebugMode(options?.log?.debug ?? false)
49
+ .setPrefix(options?.log?.prefix)
50
+ .setShowCallerInfo(options?.log?.showCallerInfo ?? true);
51
+ } else {
52
+ // 默认初始化系统主题
53
+ initTheme();
20
54
  }
21
- // 设置调试模式
22
- logger
23
- .setDebugMode(options?.log?.debug ?? true)
24
- .setPrefix(options?.log?.prefix)
25
- .setShowCallerInfo(options?.log?.showCallerInfo ?? true);
55
+ } catch (error) {
56
+ console.error('[install options] Error:', error);
26
57
  }
27
58
  uni.$u = $u;
28
59
  // 可扩展更多配置项