uview-pro 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 0.3.9(2025-11-05)
2
+
3
+ ### 🐛 Bug Fixes | Bug 修复
4
+
5
+ - **types:** 修正组件声明文件中uLoadmore的命名大小写问题 ([eb69b18](https://github.com/anyup/uView-Pro/commit/eb69b18d969dac13a75375501018edc4f3097e33))
6
+ - **loadmore:** 修复 u-loadmore 组件使用类型声明报错问题 ([92facfd](https://github.com/anyup/uView-Pro/commit/92facfdb5b2b57bcd634d93412c90661c5f6e59d))
7
+
8
+ ### ✨ Features | 新功能
9
+
10
+ - **theme:** 新增本地主题文件支持 ([a989314](https://github.com/anyup/uView-Pro/commit/a989314a7b691e94ed81e524100e70d6e9a22a12))
11
+ - **theme:** 实现运行时主题变更功能,新增 setTheme 函数 ([12765d0](https://github.com/anyup/uView-Pro/commit/12765d07244a9d6ca49c4dd34d81f66a61c87c6d))
12
+
13
+ ### 👥 Contributors
14
+
15
+ <a href="https://github.com/liujiayii"><img src="https://github.com/liujiayii.png?size=40" width="40" height="40" alt="liujiayii" title="liujiayii"/></a> <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
16
+
1
17
  ## 0.3.8(2025-11-04)
2
18
 
3
19
  ### 📦‍ Build System | 打包构建
@@ -34,7 +34,7 @@ export const ActionSheetProps = {
34
34
  /** 取消按钮的文字提示 */
35
35
  cancelText: { type: String, default: '取消' },
36
36
  /** 字体颜色 */
37
- color: { type: String, default: $u.color.mainColor },
37
+ color: { type: String, default: () => $u.color.mainColor },
38
38
  /** 字体大小 */
39
39
  fontSize: { type: [String, Number], default: '32rpx' },
40
40
  /** 是否异步关闭 */
@@ -15,7 +15,7 @@ export const ActionSheetItemProps = {
15
15
  /** 边距 */
16
16
  padding: { type: [Number, String] as PropType<number | string>, default: '34rpx 0' },
17
17
  /** 字体颜色 */
18
- color: { type: String, default: $u.color.mainColor },
18
+ color: { type: String, default: () => $u.color.mainColor },
19
19
  /** 字体大小 */
20
20
  fontSize: { type: [String, Number], default: '32rpx' },
21
21
  /** 是否禁用 */
@@ -40,13 +40,13 @@ export const CalendarProps = {
40
40
  /** 默认日期字体颜色 */
41
41
  color: { type: String, default: '#303133' },
42
42
  /** 选中|起始结束日期背景色 */
43
- activeBgColor: { type: String, default: $u.color.primary },
43
+ activeBgColor: { type: String, default: () => $u.color.primary },
44
44
  /** 选中|起始结束日期字体颜色 */
45
45
  activeColor: { type: String, default: '#ffffff' },
46
46
  /** 范围内日期背景色 */
47
47
  rangeBgColor: { type: String, default: 'rgba(41,121,255,0.13)' },
48
48
  /** 范围内日期字体颜色 */
49
- rangeColor: { type: String, default: $u.color.primary },
49
+ rangeColor: { type: String, default: () => $u.color.primary },
50
50
  /** mode=range时生效,起始日期自定义文案 */
51
51
  startText: { type: String, default: '开始' },
52
52
  /** mode=range时生效,结束日期自定义文案 */
@@ -21,7 +21,7 @@ export const CheckboxGroupProps = {
21
21
  /** 形状,square为方形,circle为原型 */
22
22
  shape: { type: String as PropType<Shape>, default: 'square' },
23
23
  /** 选中状态下的颜色 */
24
- activeColor: { type: String, default: $u.color.primary },
24
+ activeColor: { type: String, default: () => $u.color.primary },
25
25
  /** 组件的整体大小 */
26
26
  size: { type: [String, Number], default: 34 },
27
27
  /** 每个checkbox占u-checkbox-group的宽度 */
@@ -9,9 +9,9 @@ import { $u } from '../../';
9
9
  export const DropdownProps = {
10
10
  ...baseProps,
11
11
  /** 菜单标题和选项的激活态颜色 */
12
- activeColor: { type: String, default: $u.color.primary },
12
+ activeColor: { type: String, default: () => $u.color.primary },
13
13
  /** 菜单标题和选项的未激活态颜色 */
14
- inactiveColor: { type: String, default: $u.color.contentColor },
14
+ inactiveColor: { type: String, default: () => $u.color.contentColor },
15
15
  /** 点击遮罩是否关闭菜单 */
16
16
  closeOnClickMask: { type: Boolean, default: true },
17
17
  /** 点击当前激活项标题是否关闭菜单 */
@@ -34,7 +34,7 @@ export const IndexListProps = {
34
34
  /** 锚点和右边索引字符高亮颜色 */
35
35
  activeColor: {
36
36
  type: String,
37
- default: $u.color.primary
37
+ default: () => $u.color.primary
38
38
  }
39
39
  };
40
40
 
@@ -9,7 +9,7 @@ export const LinkProps = {
9
9
  /** 文字颜色 */
10
10
  color: {
11
11
  type: String,
12
- default: $u.color.primary
12
+ default: () => $u.color.primary
13
13
  },
14
14
  /** 字体大小,单位rpx */
15
15
  fontSize: {
@@ -50,12 +50,12 @@ export const MessageInputProps = {
50
50
  /** 激活样式 */
51
51
  activeColor: {
52
52
  type: String,
53
- default: $u.color.primary
53
+ default: () => $u.color.primary
54
54
  },
55
55
  /** 未激活的样式 */
56
56
  inactiveColor: {
57
57
  type: String,
58
- default: $u.color.contentColor
58
+ default: () => $u.color.contentColor
59
59
  },
60
60
  /** 输入框的大小,单位rpx,宽等于高 */
61
61
  width: {
@@ -59,12 +59,12 @@ export const ModalProps = {
59
59
  /** 确认按钮颜色 */
60
60
  confirmColor: {
61
61
  type: String,
62
- default: $u.color.primary
62
+ default: () => $u.color.primary
63
63
  },
64
64
  /** 取消文字颜色 */
65
65
  cancelColor: {
66
66
  type: String,
67
- default: $u.color.contentColor
67
+ default: () => $u.color.contentColor
68
68
  },
69
69
  /** 圆角值 */
70
70
  borderRadius: {
@@ -62,12 +62,12 @@ export const PickerProps = {
62
62
  /** "取消"按钮的颜色 */
63
63
  cancelColor: {
64
64
  type: String,
65
- default: $u.color.contentColor
65
+ default: () => $u.color.contentColor
66
66
  },
67
67
  /** "确定"按钮的颜色 */
68
68
  confirmColor: {
69
69
  type: String,
70
- default: $u.color.primary
70
+ default: () => $u.color.primary
71
71
  },
72
72
  /** 默认显示的时间,2025-07-02 || 2025-07-02 13:01:00 || 2025/07/02 */
73
73
  defaultTime: {
@@ -14,7 +14,7 @@ export const RadioGroupProps = {
14
14
  /** 匹配某一个radio组件,如果某个radio的name值等于此值,那么这个radio就被会选中 */
15
15
  modelValue: { type: [String, Number] as PropType<string | number>, default: '' },
16
16
  /** 选中状态下的颜色 */
17
- activeColor: { type: String, default: $u.color.primary },
17
+ activeColor: { type: String, default: () => $u.color.primary },
18
18
  /** 组件的整体大小 */
19
19
  size: { type: [String, Number] as PropType<number | string>, default: 34 },
20
20
  /** 是否禁止点击提示语选中复选框 */
@@ -17,7 +17,7 @@ export const ReadMoreProps = {
17
17
  /** 展开时的提示文字 */
18
18
  openText: { type: String, default: '收起' },
19
19
  /** 提示的文字颜色 */
20
- color: { type: String, default: $u.color.primary },
20
+ color: { type: String, default: () => $u.color.primary },
21
21
  /** 提示文字的大小 */
22
22
  fontSize: { type: [String, Number] as PropType<number | string>, default: 28 },
23
23
  /** 是否显示阴影 */
@@ -16,9 +16,9 @@ export const SelectProps = {
16
16
  /** 通过双向绑定控制组件的弹出与收起 */
17
17
  modelValue: { type: Boolean, default: false },
18
18
  /** "取消"按钮的颜色 */
19
- cancelColor: { type: String, default: $u.color.contentColor },
19
+ cancelColor: { type: String, default: () => $u.color.contentColor },
20
20
  /** "确定"按钮的颜色 */
21
- confirmColor: { type: String, default: $u.color.primary },
21
+ confirmColor: { type: String, default: () => $u.color.primary },
22
22
  /** 弹出的z-index值 */
23
23
  zIndex: { type: [String, Number] as PropType<string | number>, default: 0 },
24
24
  /** 是否开启底部安全区适配 */
@@ -23,9 +23,9 @@ export const SliderProps = {
23
23
  /** 滑块条高度,单位rpx */
24
24
  height: { type: [Number, String] as PropType<number | string>, default: 6 },
25
25
  /** 进度条的激活部分颜色 */
26
- activeColor: { type: String, default: $u.color.primary },
26
+ activeColor: { type: String, default: () => $u.color.primary },
27
27
  /** 进度条的背景颜色 */
28
- inactiveColor: { type: String, default: $u.color.lightColor },
28
+ inactiveColor: { type: String, default: () => $u.color.lightColor },
29
29
  /** 滑块的背景颜色 */
30
30
  blockColor: { type: String, default: '#ffffff' },
31
31
  /** 用户对滑块的自定义颜色 */
@@ -15,9 +15,9 @@ export const StepProps = {
15
15
  /** 主题类型, primary|success|info|warning|error */
16
16
  type: { type: String as PropType<ThemeType>, default: 'primary' },
17
17
  /** 激活步骤的颜色 */
18
- activeColor: { type: String, default: $u.color.primary },
18
+ activeColor: { type: String, default: () => $u.color.primary },
19
19
  /** 未激活的颜色 */
20
- unActiveColor: { type: String, default: $u.color.info },
20
+ unActiveColor: { type: String, default: () => $u.color.info },
21
21
  /** 自定义图标 */
22
22
  icon: { type: String, default: 'checkmark' },
23
23
  /** 标题 */
@@ -19,9 +19,9 @@ export const StepsProps = {
19
19
  /** 当前哪一步是激活的 */
20
20
  current: { type: [Number, String] as PropType<number | string>, default: 0 },
21
21
  /** 激活步骤的颜色 */
22
- activeColor: { type: String, default: $u.color.primary },
22
+ activeColor: { type: String, default: () => $u.color.primary },
23
23
  /** 未激活的颜色 */
24
- unActiveColor: { type: String, default: $u.color.info },
24
+ unActiveColor: { type: String, default: () => $u.color.info },
25
25
  /** 自定义图标 */
26
26
  icon: { type: String, default: 'checkmark' },
27
27
  /** step的排列方向,row-横向,column-竖向 */
@@ -15,7 +15,7 @@ export const SwitchProps = {
15
15
  /** 开关尺寸,单位rpx */
16
16
  size: { type: [Number, String] as PropType<number | string>, default: 50 },
17
17
  /** 打开时的颜色 */
18
- activeColor: { type: String, default: $u.color.primary },
18
+ activeColor: { type: String, default: () => $u.color.primary },
19
19
  /** 关闭时的颜色 */
20
20
  inactiveColor: { type: String, default: '#ffffff' },
21
21
  /** v-model 绑定值,是否选中 */
@@ -22,9 +22,9 @@ export const TabsProps = {
22
22
  /** 过渡动画时长, 单位s */
23
23
  duration: { type: [String, Number] as PropType<number | string>, default: 0.5 },
24
24
  /** 选中项的主题颜色 */
25
- activeColor: { type: String, default: $u.color.primary },
25
+ activeColor: { type: String, default: () => $u.color.primary },
26
26
  /** 未选中项的颜色 */
27
- inactiveColor: { type: String, default: $u.color.mainColor },
27
+ inactiveColor: { type: String, default: () => $u.color.mainColor },
28
28
  /** 菜单底部移动的bar的宽度,单位rpx */
29
29
  barWidth: { type: [String, Number] as PropType<number | string>, default: 40 },
30
30
  /** 移动bar的高度 */
@@ -22,9 +22,9 @@ export const TabsSwiperProps = {
22
22
  /** tabs组件外部swiper的宽度,单位rpx */
23
23
  swiperWidth: { type: [String, Number] as PropType<number | string>, default: 750 },
24
24
  /** 滑块和激活tab文字的颜色 */
25
- activeColor: { type: String, default: $u.color.primary },
25
+ activeColor: { type: String, default: () => $u.color.primary },
26
26
  /** tabs文字颜色 */
27
- inactiveColor: { type: String, default: $u.color.mainColor },
27
+ inactiveColor: { type: String, default: () => $u.color.mainColor },
28
28
  /** 滑块宽度,单位rpx */
29
29
  barWidth: { type: [Number, String] as PropType<number | string>, default: 40 },
30
30
  /** 滑块高度,单位rpx */
package/index.ts CHANGED
@@ -15,9 +15,9 @@ declare const uni: {
15
15
  const install = (app: any, options?: UViewProOptions): void => {
16
16
  uni.$u = $u;
17
17
  if (options) {
18
- // 配置主题
18
+ // 配置主题:使用 $u.setTheme 以就地更新 reactive $u.color
19
19
  if (options.theme) {
20
- $u.color = $u.deepMerge($u.color, options.theme);
20
+ $u.setTheme?.(options.theme);
21
21
  }
22
22
  // 设置调试模式
23
23
  logger
@@ -1,6 +1,8 @@
1
- import type { ThemeColor } from '../../types/global';
1
+ import type { ColorType, ThemeColor } from '../../types/global';
2
+ import { reactive } from 'vue';
2
3
 
3
- const color: ThemeColor = {
4
+ // 使用 reactive 包装颜色对象,使其在运行时可被响应式读取与更新
5
+ const color: ThemeColor = reactive({
4
6
  primary: '#2979ff',
5
7
  primaryDark: '#2b85e4',
6
8
  primaryDisabled: '#a0cfff',
@@ -32,6 +34,10 @@ const color: ThemeColor = {
32
34
  tipsColor: '#909399',
33
35
  lightColor: '#c0c4cc',
34
36
  borderColor: '#e4e7ed'
35
- };
37
+ });
38
+
39
+ export function getColor(name: ColorType) {
40
+ return (color as any)[name] || '';
41
+ }
36
42
 
37
43
  export default color;
package/libs/index.ts CHANGED
@@ -12,6 +12,8 @@ import colorGradients from './function/colorGradient';
12
12
  import guid from './function/guid';
13
13
  // 主题相关颜色,info|success|warning|primary|default|error,此颜色已在uview.scss中定义,但是为js中也能使用,故也定义一份
14
14
  import color from './function/color';
15
+ import { getColor } from './function/color';
16
+ import type { ThemeColor } from '../types/global';
15
17
  // 根据type获取图标名称
16
18
  import type2icon from './function/type2icon';
17
19
  // 打乱数组的顺序
@@ -242,6 +244,25 @@ export function kebabCase(word: string): string {
242
244
  return newWord;
243
245
  }
244
246
 
247
+ /**
248
+ * 运行时设置主题颜色(就地合并到 reactive 的 $u.color)
249
+ * @param theme Partial<ThemeColor>
250
+ */
251
+ function setTheme(theme: Partial<ThemeColor> | undefined) {
252
+ if (!theme) return;
253
+ try {
254
+ const merged = deepMerge($u.color, theme);
255
+ Object.keys(merged).forEach(k => {
256
+ $u.color[k] = (merged as any)[k];
257
+ });
258
+ } catch (e) {
259
+ // 兜底:直接 assign
260
+ Object.keys(theme).forEach(k => {
261
+ $u.color[k] = (theme as any)[k];
262
+ });
263
+ }
264
+ }
265
+
245
266
  export {
246
267
  queryParams,
247
268
  route,
@@ -249,6 +270,7 @@ export {
249
270
  timeFrom,
250
271
  guid,
251
272
  color,
273
+ getColor,
252
274
  sys,
253
275
  os,
254
276
  type2icon,
@@ -268,7 +290,8 @@ export {
268
290
  clipboard,
269
291
  config,
270
292
  zIndex,
271
- mitt
293
+ mitt,
294
+ setTheme
272
295
  };
273
296
 
274
297
  export const $u = {
@@ -281,6 +304,7 @@ export const $u = {
281
304
  colorToRgba: colorGradients.colorToRgba,
282
305
  guid,
283
306
  color,
307
+ getColor,
284
308
  sys,
285
309
  os,
286
310
  type2icon,
@@ -309,7 +333,8 @@ export const $u = {
309
333
  formatName,
310
334
  addStyle,
311
335
  toStyle,
312
- kebabCase
336
+ kebabCase,
337
+ setTheme
313
338
  };
314
339
 
315
340
  // 颜色相关方法单独导出
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
4
  "displayName": "【Vue3重构版】uView Pro|基于Vue3+TS全面重构的80+精选UI组件库",
5
- "version": "0.3.8",
5
+ "version": "0.3.9",
6
6
  "description": "uView Pro,是全面支持Vue3的uni-app生态框架,80+精选组件已使用TypeScript重构,已全面支持uni-app Vue3.0",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",
@@ -44,7 +44,7 @@ declare module 'vue' {
44
44
  uLine: (typeof import('../components/u-line/u-line.vue'))['default'];
45
45
  uLineProgress: (typeof import('../components/u-line-progress/u-line-progress.vue'))['default'];
46
46
  uLink: (typeof import('../components/u-link/u-link.vue'))['default'];
47
- uLoadMore: (typeof import('../components/u-loadmore/u-loadmore.vue'))['default'];
47
+ uLoadmore: (typeof import('../components/u-loadmore/u-loadmore.vue'))['default'];
48
48
  uLoading: (typeof import('../components/u-loading/u-loading.vue'))['default'];
49
49
  uLoadingPopup: (typeof import('../components/u-loading-popup/u-loading-popup.vue'))['default'];
50
50
  uMask: (typeof import('../components/u-mask/u-mask.vue'))['default'];
package/types/global.d.ts CHANGED
@@ -305,35 +305,36 @@ export type FabDirection = 'top' | 'bottom' | 'left' | 'right';
305
305
  // fab 组件 gap
306
306
  export type FabGap = Partial<Record<'top' | 'left' | 'right' | 'bottom', number>>;
307
307
 
308
+ export type ColorType =
309
+ | 'primary'
310
+ | 'primaryDark'
311
+ | 'primaryDisabled'
312
+ | 'primaryLight'
313
+ | 'bgColor'
314
+ | 'info'
315
+ | 'infoDark'
316
+ | 'infoDisabled'
317
+ | 'infoLight'
318
+ | 'warning'
319
+ | 'warningDark'
320
+ | 'warningDisabled'
321
+ | 'warningLight'
322
+ | 'error'
323
+ | 'errorDark'
324
+ | 'errorDisabled'
325
+ | 'errorLight'
326
+ | 'success'
327
+ | 'successDark'
328
+ | 'successDisabled'
329
+ | 'successLight'
330
+ | 'mainColor'
331
+ | 'contentColor'
332
+ | 'tipsColor'
333
+ | 'lightColor'
334
+ | 'borderColor';
335
+
308
336
  // 自定义主题色
309
- export type ThemeColor = Partial<{
310
- primary: string;
311
- primaryDark: string;
312
- primaryDisabled: string;
313
- primaryLight: string;
314
- bgColor: string;
315
- info: string;
316
- infoDark: string;
317
- infoDisabled: string;
318
- infoLight: string;
319
- warning: string;
320
- warningDark: string;
321
- warningDisabled: string;
322
- warningLight: string;
323
- error: string;
324
- errorDark: string;
325
- errorDisabled: string;
326
- errorLight: string;
327
- success: string;
328
- successDark: string;
329
- successDisabled: string;
330
- successLight: string;
331
- mainColor: string;
332
- contentColor: string;
333
- tipsColor: string;
334
- lightColor: string;
335
- borderColor: string;
336
- }>;
337
+ export type ThemeColor = Partial<Record<ColorType, string>>;
337
338
 
338
339
  export type LogConfig = Partial<{
339
340
  debug?: boolean;