uview-pro 0.4.10 → 0.4.12

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,22 +1,58 @@
1
- ## 0.4.102025-12-26
1
+ ## 0.4.122026-01-04
2
2
 
3
- ### 🚀 Chore | 构建/工程依赖/工具
3
+ ### ♻️ Code Refactoring | 代码重构
4
4
 
5
- - **contributors:** 更新贡献者映射配置 ([d496b21](https://github.com/anyup/uView-Pro/commit/d496b21d85bede68fefc9ffd752e31ecde14735a))
5
+ - **u-action-sheet:** 优化u-action-sheet组件的类型定义 ([bc5e474](https://github.com/anyup/uView-Pro/commit/bc5e474e7117e20495504ff0e2397a147595033c))
6
+ - **zIndex:** 统一组件z-index值配置 ([ae1da98](https://github.com/anyup/uView-Pro/commit/ae1da986d307e5b4855fa32e5b2995fdb7be69e8))
6
7
 
7
8
  ### 🐛 Bug Fixes | Bug 修复
8
9
 
9
- - **u-popup:** 修复u-popup设置mode=center,点击遮罩层无法关闭的问题 ([3896019](https://github.com/anyup/uView-Pro/commit/389601965933d9e1dc74d32c370c4e858df86595))
10
- - **u-upload:** 优化u-upload组件在多个平台的样式兼容性 ([bfb60b5](https://github.com/anyup/uView-Pro/commit/bfb60b5c2f431d14425eceed9c9e5c248e7cfa29))
10
+ - **form:** 修复field实例销毁时没有正常移除问题 ([57bfd3b](https://github.com/anyup/uView-Pro/commit/57bfd3bf9315d74c416869cd5a8c41562231166a))
11
11
 
12
12
  ### ✨ Features | 新功能
13
13
 
14
- - **u-tabbar:** 增强u-tabbar组件能力,支持文字和图标显示隐藏配置功能 ([29f3394](https://github.com/anyup/uView-Pro/commit/29f3394d7e8a5e2a818e397ffe97420855970333))
14
+ - **u-tabbar:** 新增z-index属性支持自定义层级 ([c75d45f](https://github.com/anyup/uView-Pro/commit/c75d45f45e237453d0248124cdbe5bb797edb117))
15
+ - **u-modal:** 增加u-modal基础属性支持和自定义样式功能 ([201231e](https://github.com/anyup/uView-Pro/commit/201231ee2e0c25c605f12f582650b048e83213de))
16
+ - **components:** 增加u-pagination和u-picker自定义样式支持 ([eb22265](https://github.com/anyup/uView-Pro/commit/eb222657540179fcf8359133df83da89c10b09b8))
15
17
 
16
18
  ### 👥 Contributors
17
19
 
18
- <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
20
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a> <a href="https://github.com/yoshinosk"><img src="https://github.com/yoshinosk.png?size=40" width="40" height="40" alt="yoshinosk" title="yoshinosk"/></a> <a href="https://github.com/liujiayii"><img src="https://github.com/liujiayii.png?size=40" width="40" height="40" alt="liujiayii" title="liujiayii"/></a>
19
21
 
22
+ ## 0.4.11(2025-12-30)
23
+
24
+ ### 📦‍ Build System | 打包构建
25
+
26
+ - 添加edgeone.json配置 ([ed7ba7d](https://github.com/anyup/uView-Pro/commit/ed7ba7d94dbfa791264a624a03938dc6ac58c0bb))
27
+
28
+ ### 🐛 Bug Fixes | Bug 修复
29
+
30
+ - **theme:** 修复运行时设置 color 与 theme 主题色不同步问题 ([1dcf56a](https://github.com/anyup/uView-Pro/commit/1dcf56a232f5b046e0dce5eb58ec90fb46ce19d5))
31
+ - **u-top-tips:** 修复顶部提示组件zindex显示问题,避免影响其他组件的层级显示 ([91391a8](https://github.com/anyup/uView-Pro/commit/91391a8ca10d505936c0b45488af0a3145cab335))
32
+
33
+ ### 👥 Contributors
34
+
35
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
36
+
37
+ ## 0.4.10(2025-12-26)
38
+
39
+ ### 🚀 Chore | 构建/工程依赖/工具
40
+
41
+ - **contributors:** 更新贡献者映射配置 ([d496b21](https://github.com/anyup/uView-Pro/commit/d496b21d85bede68fefc9ffd752e31ecde14735a))
42
+
43
+ ### 🐛 Bug Fixes | Bug 修复
44
+
45
+ - **u-popup:** 修复u-popup设置mode=center,点击遮罩层无法关闭的问题 ([3896019](https://github.com/anyup/uView-Pro/commit/389601965933d9e1dc74d32c370c4e858df86595))
46
+ - **u-upload:** 优化u-upload组件在多个平台的样式兼容性 ([bfb60b5](https://github.com/anyup/uView-Pro/commit/bfb60b5c2f431d14425eceed9c9e5c248e7cfa29))
47
+
48
+ ### ✨ Features | 新功能
49
+
50
+ - **u-tabbar:** 增强u-tabbar组件能力,支持文字和图标显示隐藏配置功能 ([29f3394](https://github.com/anyup/uView-Pro/commit/29f3394d7e8a5e2a818e397ffe97420855970333))
51
+
52
+ ### 👥 Contributors
53
+
54
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
55
+
20
56
  ## 0.4.9(2025-12-24)
21
57
 
22
58
  ### 📝 Documentation | 文档
@@ -87,7 +87,10 @@ onMounted(() => {
87
87
  watch(
88
88
  () => props.themes,
89
89
  val => {
90
- if (val && val.length) {
90
+ // 如果传入的 themes 来自于 configProvider 自身(常见于模板中使用 useTheme() 直接透传),
91
+ // 那么对其做深度监听会在我们内部更新主题对象时触发该回调,进而再次调用 init 导致循环更新。
92
+ // 为避免该情况,先做简单保护:当传入对象正是 configProvider.themesRef.value 时不重复初始化。
93
+ if (val && val.length && val !== configProvider.themesRef.value) {
91
94
  configProvider.init(val, props.currentTheme as any);
92
95
  }
93
96
  },
@@ -121,7 +121,7 @@ defineExpose({
121
121
  if (!fields.value.includes(field)) fields.value.push(field);
122
122
  },
123
123
  removeField(field: any) {
124
- fields.value = fields.value.filter(f => f !== field);
124
+ fields.value = fields.value.filter(f => f.prop !== field.prop)
125
125
  },
126
126
  fields,
127
127
  rules,
@@ -58,6 +58,7 @@ export default {
58
58
  <script setup lang="ts">
59
59
  import { KeyboardProps } from './types';
60
60
  import { computed } from 'vue';
61
+ import { $u } from '../..';
61
62
 
62
63
  /**
63
64
  * keyboard 键盘
@@ -86,7 +87,7 @@ import { computed } from 'vue';
86
87
  const props = defineProps(KeyboardProps);
87
88
  const emit = defineEmits(['change', 'update:modelValue', 'confirm', 'cancel', 'backspace']);
88
89
 
89
- const uZIndex = computed(() => (props.zIndex ? props.zIndex : 1075));
90
+ const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.popup));
90
91
 
91
92
  const popupValue = computed({
92
93
  get: () => props.modelValue,
@@ -1,11 +1,13 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { getColor } from '../../';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * u-modal 组件 props 类型定义
6
7
  * @description 弹窗模态框,支持多种样式和交互
7
8
  */
8
9
  export const ModalProps = {
10
+ ...baseProps,
9
11
  /** 是否显示模态框 */
10
12
  modelValue: {
11
13
  type: Boolean,
@@ -11,8 +11,9 @@
11
11
  :border-radius="borderRadius"
12
12
  @close="popupClose"
13
13
  :negative-top="negativeTop"
14
+ :custom-class="customClass"
14
15
  >
15
- <view class="u-model">
16
+ <view class="u-model" :style="$u.toStyle(customStyle)">
16
17
  <view v-if="showTitle" class="u-model__title u-line-1" :style="[titleStyle]">{{ title }}</view>
17
18
  <view class="u-model__content">
18
19
  <view :style="[contentStyle]" v-if="slots.default">
@@ -68,6 +69,7 @@ export default {
68
69
 
69
70
  <script setup lang="ts">
70
71
  import { ref, computed, watch, useSlots } from 'vue';
72
+ import { $u } from '../..';
71
73
  import { ModalProps } from './types';
72
74
 
73
75
  /**
@@ -113,7 +115,7 @@ const cancelBtnStyle = computed(() => {
113
115
  const confirmBtnStyle = computed(() => {
114
116
  return Object.assign({ color: props.confirmColor }, props.confirmStyle);
115
117
  });
116
- const uZIndex = computed(() => (props.zIndex ? props.zIndex : 10075));
118
+ const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.popup));
117
119
 
118
120
  const popupValue = computed({
119
121
  get: () => props.modelValue,
@@ -1,4 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import zIndex from '../../libs/config/zIndex';
2
3
 
3
4
  /**
4
5
  * u-navbar 组件 props 类型定义
@@ -88,7 +89,7 @@ export const NavbarProps = {
88
89
  /** 固定在顶部时的z-index值 */
89
90
  zIndex: {
90
91
  type: [String, Number] as PropType<string | number>,
91
- default: ''
92
+ default: zIndex.navbar
92
93
  },
93
94
  /** 自定义返回逻辑方法 */
94
95
  customBack: {
@@ -1,4 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import zIndex from '../../libs/config/zIndex';
2
3
 
3
4
  /**
4
5
  * u-no-network 组件 props 类型定义
@@ -13,7 +14,7 @@ export const NoNetworkProps = {
13
14
  /** 一个z-index值,用于设置没有网络这个组件的层次 */
14
15
  zIndex: {
15
16
  type: [Number, String] as PropType<number | string>,
16
- default: ''
17
+ default: zIndex.noNetwork
17
18
  },
18
19
  /** 没有网络的图片提示 */
19
20
  image: {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="u-pagination">
2
+ <view class="u-pagination" :style="$u.toStyle(customStyle)" :class="customClass">
3
3
  <u-button
4
4
  custom-class="custom-class"
5
5
  shape="circle"
@@ -51,6 +51,7 @@ export default {
51
51
  import { computed } from 'vue';
52
52
  import { type PaginationEmits, PaginationProps } from './types.ts';
53
53
  import type { PaginationDirection } from '../../types/global';
54
+ import { $u } from '../../';
54
55
 
55
56
  const props = defineProps(PaginationProps);
56
57
  const emit = defineEmits<PaginationEmits>();
@@ -1,6 +1,8 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { PickerMode, PickerParams } from '../../types/global';
3
3
  import { getColor } from '../../';
4
+ import zIndex from '../../libs/config/zIndex';
5
+ import { baseProps } from '../common/props';
4
6
 
5
7
  const defaultParams: PickerParams = {
6
8
  year: true,
@@ -19,6 +21,7 @@ const defaultParams: PickerParams = {
19
21
  * @description 支持时间、地区、单列、多列等多种模式
20
22
  */
21
23
  export const PickerProps = {
24
+ ...baseProps,
22
25
  /** picker中需要显示的参数 */
23
26
  params: {
24
27
  type: Object as PropType<PickerParams>,
@@ -107,7 +110,7 @@ export const PickerProps = {
107
110
  /** 弹出的z-index值 */
108
111
  zIndex: {
109
112
  type: [String, Number] as PropType<number | string>,
110
- default: 0
113
+ default: zIndex.popup
111
114
  },
112
115
  /** 顶部标题 */
113
116
  title: {
@@ -8,8 +8,9 @@
8
8
  :safeAreaInsetBottom="safeAreaInsetBottom"
9
9
  @close="close"
10
10
  :z-index="uZIndex"
11
+ :custom-class="customClass"
11
12
  >
12
- <view class="u-datetime-picker">
13
+ <view class="u-datetime-picker" :style="$u.toStyle(customStyle)">
13
14
  <view class="u-picker-header" @touchmove.stop.prevent="">
14
15
  <view
15
16
  class="u-btn-picker u-btn-picker--tips"
@@ -156,6 +157,7 @@ import provinces from '../../libs/util/province';
156
157
  import citys from '../../libs/util/city';
157
158
  import areas from '../../libs/util/area';
158
159
  import { PickerProps } from './types';
160
+ import { $u } from '../..';
159
161
 
160
162
  /**
161
163
  * picker picker弹出选择器
@@ -274,7 +276,7 @@ const regionChange = computed(() => `${province.value}-${city.value}`);
274
276
 
275
277
  const yearAndMonth = computed(() => `${year.value}-${month.value}`);
276
278
  // 如果用户有传递z-index值,优先使用
277
- const uZIndex = computed(() => (props.zIndex ? props.zIndex : 1075));
279
+ const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.popup));
278
280
 
279
281
  // 当外部的默认值被动态修改时,如果 preserveSelection 为 false,应把外部值视为新的 saved 值并在打开时生效
280
282
  watch(
@@ -1,10 +1,7 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { PopupCloseIconPos, PopupMode } from '../../types/global';
3
3
  import { baseProps } from '../common/props';
4
-
5
- /**
6
- * PopupMode 弹窗弹出方向类型
7
- */
4
+ import zIndex from '../../libs/config/zIndex';
8
5
 
9
6
  /**
10
7
  * PopupProps 弹窗 props 类型定义
@@ -33,7 +30,7 @@ export const PopupProps = {
33
30
  /** 圆角 */
34
31
  borderRadius: { type: [Number, String] as PropType<number | string>, default: 0 },
35
32
  /** 弹窗z-index */
36
- zIndex: { type: [Number, String] as PropType<number | string>, default: '' },
33
+ zIndex: { type: [Number, String] as PropType<number | string>, default: zIndex.popup },
37
34
  /** 是否显示关闭图标 */
38
35
  closeable: { type: Boolean, default: false },
39
36
  /** 关闭图标的名称,只能uView的内置图标 */
@@ -2,7 +2,7 @@
2
2
  <view
3
3
  v-if="visibleSync"
4
4
  class="u-drawer"
5
- :style="$u.toStyle({ zIndex: Number(uZindex) - 1 }, customStyle)"
5
+ :style="$u.toStyle({ zIndex: Number(uZIndex) - 1 }, customStyle)"
6
6
  :class="customClass"
7
7
  hover-stop-propagation
8
8
  >
@@ -10,7 +10,7 @@
10
10
  :duration="duration"
11
11
  :custom-style="maskCustomStyle"
12
12
  :maskClickAble="maskCloseAble"
13
- :z-index="Number(uZindex) - 2"
13
+ :z-index="Number(uZIndex) - 2"
14
14
  :show="showDrawer && mask"
15
15
  @click="maskClick"
16
16
  ></u-mask>
@@ -124,7 +124,7 @@ const style = computed(() => {
124
124
  };
125
125
  }
126
126
  // 如果用户设置了borderRadius值,添加弹窗的圆角
127
- style.zIndex = uZindex.value;
127
+ style.zIndex = uZIndex.value;
128
128
  if (props.borderRadius) {
129
129
  switch (props.mode) {
130
130
  case 'left':
@@ -155,7 +155,7 @@ const centerStyle = computed(() => {
155
155
 
156
156
  // 中部弹出的模式,如果没有设置高度,就用auto值,由内容撑开高度
157
157
  style.height = props.height ? getUnitValue(props.height) : 'auto';
158
- style.zIndex = uZindex.value;
158
+ style.zIndex = uZIndex.value;
159
159
  style.marginTop = `-${$u.addUnit(props.negativeTop)}`;
160
160
  if (props.borderRadius) {
161
161
  style.borderRadius = `${props.borderRadius}rpx`;
@@ -166,7 +166,7 @@ const centerStyle = computed(() => {
166
166
  });
167
167
 
168
168
  // 计算整理后的z-index值
169
- const uZindex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.popup));
169
+ const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.popup));
170
170
 
171
171
  watch(
172
172
  () => props.modelValue,
@@ -130,7 +130,7 @@ const columnNum = ref(0);
130
130
  // 列是否还在滑动中,微信小程序如果在滑动中就点确定,结果可能不准确
131
131
  const moving = ref(false);
132
132
  // 如果用户有传递z-index值,优先使用
133
- const uZIndex = computed(() => (props.zIndex ? props.zIndex : 10075));
133
+ const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.popup));
134
134
 
135
135
  const popupValue = computed({
136
136
  get: () => props.modelValue,
@@ -1,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { baseProps } from '../common/props';
3
+ import zIndex from '../../libs/config/zIndex';
3
4
 
4
5
  /**
5
6
  * StickyProps 吸顶组件 props 类型定义
@@ -18,7 +19,7 @@ export const StickyProps = {
18
19
  /** 吸顶区域的背景颜色 */
19
20
  bgColor: { type: String, default: 'var(--u-bg-white)' },
20
21
  /** z-index值 */
21
- zIndex: { type: [Number, String] as PropType<number | string>, default: '' }
22
+ zIndex: { type: [Number, String] as PropType<number | string>, default: zIndex.sticky }
22
23
  };
23
24
 
24
25
  export type StickyProps = ExtractPropTypes<typeof StickyProps>;
@@ -1,6 +1,7 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { baseProps } from '../common/props';
3
3
  import type { TabbarItem } from '../../types/global';
4
+ import zIndex from '../../libs/config/zIndex';
4
5
 
5
6
  /**
6
7
  * TabbarProps 底部导航栏 props 类型定义
@@ -35,7 +36,9 @@ export const TabbarProps = {
35
36
  /** 是否显示顶部横线 */
36
37
  borderTop: { type: Boolean, default: true },
37
38
  /** 是否隐藏原生tabbar */
38
- hideTabBar: { type: Boolean, default: true }
39
+ hideTabBar: { type: Boolean, default: true },
40
+ /** z-index层级 */
41
+ zIndex: { type: [String, Number] as PropType<string | number>, default: zIndex.tabbar }
39
42
  };
40
43
 
41
44
  export type TabbarProps = ExtractPropTypes<typeof TabbarProps>;
@@ -8,7 +8,7 @@
8
8
  >
9
9
  <view
10
10
  class="u-tabbar__content safe-area-inset-bottom"
11
- :style="{ height: $u.addUnit(props.height), backgroundColor: props.bgColor }"
11
+ :style="{ height: $u.addUnit(props.height), backgroundColor: props.bgColor, zIndex: uZIndex }"
12
12
  :class="{ 'u-border-top': props.borderTop }"
13
13
  >
14
14
  <view
@@ -110,6 +110,9 @@ const props = defineProps(TabbarProps);
110
110
 
111
111
  const emit = defineEmits<{ (e: 'change', index: number): void; (e: 'update:modelValue', index: number): void }>();
112
112
 
113
+ // 计算z-index值
114
+ const uZIndex = computed(() => props?.zIndex ?? $u.zIndex.tabbar);
115
+
113
116
  // 由于安卓太菜了,通过css居中凸起按钮的外层元素有误差,故通过js计算将其居中
114
117
  const midButtonLeft = ref('50%');
115
118
  const pageUrl = ref(''); // 当前页面URL
@@ -1,6 +1,7 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { ThemeType, ToastPosition } from '../../types/global';
3
3
  import { baseProps } from '../common/props';
4
+ import zIndex from '../../libs/config/zIndex';
4
5
 
5
6
  /**
6
7
  * ToastProps toast props 类型定义
@@ -9,7 +10,7 @@ import { baseProps } from '../common/props';
9
10
  export const ToastProps = {
10
11
  ...baseProps,
11
12
  /** 层级 z-index */
12
- zIndex: { type: [Number, String] as PropType<number | string>, default: '' },
13
+ zIndex: { type: [Number, String] as PropType<number | string>, default: zIndex.toast },
13
14
  /** 提示类型,success/warning/error/loading 等 */
14
15
  type: { type: String as PropType<ThemeType | 'default'>, default: '' },
15
16
  /** 显示时长,单位ms */
@@ -1,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { baseProps } from '../common/props';
3
+ import zIndex from '../../libs/config/zIndex';
3
4
 
4
5
  /**
5
6
  * TopTipsProps top-tips props 类型定义
@@ -10,7 +11,7 @@ export const TopTipsProps = {
10
11
  /** 导航栏高度,用于提示的初始化 */
11
12
  navbarHeight: { type: [Number, String] as PropType<number | string>, default: 0 },
12
13
  /** z-index值 */
13
- zIndex: { type: [Number, String] as PropType<number | string>, default: '' }
14
+ zIndex: { type: [Number, String] as PropType<number | string>, default: zIndex.topTips }
14
15
  };
15
16
 
16
17
  export type TopTipsProps = ExtractPropTypes<typeof TopTipsProps>;
@@ -61,7 +61,7 @@ const uNavbarHeight = computed(() => {
61
61
 
62
62
  const tipStyle = computed(() => ({
63
63
  top: Number(uNavbarHeight.value) + 'px',
64
- zIndex: uZIndex.value
64
+ zIndex: isShow.value ? uZIndex.value : -1
65
65
  }));
66
66
 
67
67
  /**
@@ -0,0 +1,9 @@
1
+ import { reactive } from 'vue';
2
+ import { lightPalette } from './theme-tokens';
3
+ import type { ThemeColor } from '../../types/global';
4
+
5
+ // 使用 reactive 包装颜色对象,使其在运行时可被响应式读取与更新
6
+ // 这个对象会被 configProvider 在主题切换时更新
7
+ export const color = reactive<ThemeColor>({ ...lightPalette });
8
+
9
+ export default color;
@@ -1,7 +1,7 @@
1
1
  import type { Theme, ThemeColor } from '../../types/global';
2
2
  import config from './config';
3
3
 
4
- const lightPalette: ThemeColor = {
4
+ export const lightPalette: ThemeColor = {
5
5
  primary: '#2979ff',
6
6
  primaryDark: '#2b85e4',
7
7
  primaryDisabled: '#a0cfff',
@@ -39,7 +39,7 @@ const lightPalette: ThemeColor = {
39
39
  bgBlack: '#000000'
40
40
  };
41
41
 
42
- const darkPalette: ThemeColor = {
42
+ export const darkPalette: ThemeColor = {
43
43
  primary: '#8ab4ff',
44
44
  primaryDark: '#5f8dff',
45
45
  primaryDisabled: '#3d4f74',
@@ -1,37 +1,30 @@
1
- // uniapp在H5中各API的z-index值如下:
2
- /**
3
- * actionsheet: 999
4
- * modal: 999
5
- * navigate: 998
6
- * tabbar: 998
7
- * toast: 999
8
- */
9
-
10
1
  /**
11
2
  * 组件库 z-index 配置项类型定义
12
3
  */
13
4
  export interface ZIndexConfig {
14
5
  toast: number;
15
6
  noNetwork: number;
16
- /** popup包含popup,actionsheet,keyboard,picker的值 */
7
+ /** popup包含popup,actionSheet,keyboard,picker的值 */
17
8
  popup: number;
18
9
  mask: number;
19
10
  navbar: number;
20
11
  topTips: number;
21
12
  sticky: number;
22
13
  indexListSticky: number;
14
+ tabbar: number;
23
15
  }
24
16
 
25
17
  const zIndex: ZIndexConfig = {
26
18
  toast: 10090,
27
19
  noNetwork: 10080,
28
- // popup包含popup,actionsheet,keyboard,picker的值
20
+ // popup包含popup,actionSheet,keyboard,picker的值
29
21
  popup: 10075,
30
22
  mask: 10070,
31
23
  navbar: 980,
32
24
  topTips: 975,
33
25
  sticky: 970,
34
- indexListSticky: 965
26
+ indexListSticky: 965,
27
+ tabbar: 998
35
28
  };
36
29
 
37
30
  export default zIndex;
@@ -1,48 +1,7 @@
1
- import { reactive } from 'vue';
2
1
  import type { ColorType, ThemeColor } from '../../types/global';
3
-
4
- // 默认颜色值(作为初始值)
5
- const defaultColor: ThemeColor = {
6
- primary: '#2979ff',
7
- primaryDark: '#2b85e4',
8
- primaryDisabled: '#a0cfff',
9
- primaryLight: '#ecf5ff',
10
- success: '#19be6b',
11
- successDark: '#18b566',
12
- successDisabled: '#71d5a1',
13
- successLight: '#dbf1e1',
14
- warning: '#ff9900',
15
- warningDark: '#f29100',
16
- warningDisabled: '#fcbd71',
17
- warningLight: '#fdf6ec',
18
- error: '#fa3534',
19
- errorDark: '#dd6161',
20
- errorDisabled: '#fab6b6',
21
- errorLight: '#fef0f0',
22
- info: '#909399',
23
- infoDark: '#82848a',
24
- infoDisabled: '#c8c9cc',
25
- infoLight: '#f4f4f5',
26
- whiteColor: '#ffffff',
27
- blackColor: '#000000',
28
- mainColor: '#303133',
29
- contentColor: '#606266',
30
- tipsColor: '#909399',
31
- lightColor: '#c0c4cc',
32
- borderColor: '#dcdfe6',
33
- dividerColor: '#e4e7ed',
34
- maskColor: 'rgba(0, 0, 0, 0.4)',
35
- shadowColor: 'rgba(0, 0, 0, 0.1)',
36
- bgColor: '#f3f4f6',
37
- bgWhite: '#ffffff',
38
- bgGrayLight: '#f5f7fa',
39
- bgGrayDark: '#2f343c',
40
- bgBlack: '#000000'
41
- };
42
-
43
- // 使用 reactive 包装颜色对象,使其在运行时可被响应式读取与更新
44
- // 这个对象会被 configProvider 在主题切换时更新
45
- export const color = reactive<ThemeColor>({ ...defaultColor });
2
+ import { color } from '../config/color';
3
+ import { lightPalette } from '../config/theme-tokens';
4
+ import configProvider from '../util/config-provider';
46
5
 
47
6
  /**
48
7
  * 获取颜色值(响应式)
@@ -51,27 +10,17 @@ export const color = reactive<ThemeColor>({ ...defaultColor });
51
10
  * @returns 颜色值
52
11
  */
53
12
  export function getColor(name: ColorType): string {
54
- // // 优先从 configProvider 获取当前主题颜色
55
- // const currentTheme = configProvider.getCurrentTheme();
56
- // if (currentTheme) {
57
- // const isDark = configProvider.isInDarkMode();
58
- // const palette =
59
- // isDark && currentTheme.darkColor && Object.keys(currentTheme.darkColor).length
60
- // ? currentTheme.darkColor
61
- // : currentTheme.color || {};
62
-
63
- // if (palette[name]) {
64
- // return palette[name] as string;
65
- // }
66
- // }
67
-
68
13
  // 从响应式 color 对象获取(会被 configProvider 更新)
69
14
  if (color[name]) {
70
15
  return color[name] as string;
71
16
  }
72
17
 
73
18
  // 兜底返回默认值
74
- return defaultColor[name] || '';
19
+ return lightPalette[name] || '';
20
+ }
21
+
22
+ export function setColor(theme: Partial<ThemeColor> | undefined) {
23
+ configProvider.setThemeColor(theme);
75
24
  }
76
25
 
77
26
  export default color;
package/libs/index.ts CHANGED
@@ -11,9 +11,8 @@ import colorGradients from './function/colorGradient';
11
11
  // 生成全局唯一guid字符串
12
12
  import guid from './function/guid';
13
13
  // 主题相关颜色,info|success|warning|primary|default|error,此颜色已在uview.scss中定义,但是为js中也能使用,故也定义一份
14
- import color from './function/color';
15
- import { getColor } from './function/color';
16
- import type { ThemeColor } from '../types/global';
14
+ import { color } from './config/color';
15
+ import { getColor, setColor } from './function/color';
17
16
  // 根据type获取图标名称
18
17
  import type2icon from './function/type2icon';
19
18
  // 打乱数组的顺序
@@ -244,25 +243,6 @@ export function kebabCase(word: string): string {
244
243
  return newWord;
245
244
  }
246
245
 
247
- /**
248
- * 运行时设置主题颜色(就地合并到 reactive 的 $u.color)
249
- * @param theme Partial<ThemeColor>
250
- */
251
- function setColor(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
-
266
246
  export {
267
247
  queryParams,
268
248
  route,
@@ -271,6 +251,7 @@ export {
271
251
  guid,
272
252
  color,
273
253
  getColor,
254
+ setColor,
274
255
  sys,
275
256
  os,
276
257
  type2icon,
@@ -290,8 +271,7 @@ export {
290
271
  clipboard,
291
272
  config,
292
273
  zIndex,
293
- mitt,
294
- setColor
274
+ mitt
295
275
  };
296
276
 
297
277
  export const $u = {
@@ -305,6 +285,7 @@ export const $u = {
305
285
  guid,
306
286
  color,
307
287
  getColor,
288
+ setColor,
308
289
  sys,
309
290
  os,
310
291
  type2icon,
@@ -333,8 +314,7 @@ export const $u = {
333
314
  formatName,
334
315
  addStyle,
335
316
  toStyle,
336
- kebabCase,
337
- setColor
317
+ kebabCase
338
318
  };
339
319
 
340
320
  // 颜色相关方法单独导出
@@ -4,9 +4,9 @@
4
4
 
5
5
  import { ref } from 'vue';
6
6
  import type { DarkMode, Theme, ThemeColor } from '../../types/global';
7
- import { config, setColor } from '..';
7
+ import config from '../config/config';
8
8
  import { defaultThemes } from '../config/theme-tokens';
9
- import { color as reactiveColor } from '../function/color';
9
+ import { color as reactiveColor } from '../config/color';
10
10
  import { getSystemDarkMode as getNativeSystemDarkMode } from './system-theme';
11
11
 
12
12
  declare const uni: any;
@@ -213,6 +213,39 @@ export class ConfigProvider {
213
213
  if (this.debug) console.log('[ConfigProvider] setTheme ->', themeName);
214
214
  }
215
215
 
216
+ /**
217
+ * 运行时更新当前主题颜色并应用(不持久化)
218
+ * @param colors 主题颜色键值,支持部分更新
219
+ */
220
+ public setThemeColor(colors: Partial<ThemeColor>) {
221
+ if (!colors || Object.keys(colors).length === 0) return;
222
+ if (!this.currentThemeRef.value) {
223
+ console.warn('[ConfigProvider] setThemeColor called but no current theme');
224
+ return;
225
+ }
226
+
227
+ const mode = this.getActiveMode();
228
+
229
+ if (mode === 'dark') {
230
+ const existing = this.currentThemeRef.value.darkColor || {};
231
+ this.currentThemeRef.value.darkColor = {
232
+ ...existing,
233
+ ...colors
234
+ };
235
+ } else {
236
+ const existing = this.currentThemeRef.value.color || {};
237
+ this.currentThemeRef.value.color = {
238
+ ...existing,
239
+ ...colors
240
+ };
241
+ }
242
+
243
+ // 重新应用当前主题以同步运行时 color、CSS 变量等
244
+ this.applyTheme(this.currentThemeRef.value);
245
+
246
+ if (this.debug) console.log('[ConfigProvider] setThemeColor ->', colors);
247
+ }
248
+
216
249
  /**
217
250
  * 获取当前暗黑模式设置
218
251
  */
@@ -406,10 +439,8 @@ export class ConfigProvider {
406
439
  });
407
440
 
408
441
  // 同步到 uni.$u.color(如果存在)
409
- if (typeof uni !== 'undefined' && uni?.$u?.setColor) {
410
- uni.$u.setColor(mergedPalette);
411
- } else {
412
- setColor(mergedPalette);
442
+ if (typeof uni !== 'undefined' && uni?.$u?.color) {
443
+ uni.$u.color = reactiveColor;
413
444
  }
414
445
  } catch (e) {
415
446
  if (this.debug) console.warn('[ConfigProvider] sync runtime theme failed', e);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
- "displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的80+精选UI组件库,支持多主题,暗黑模式",
5
- "version": "0.4.10",
6
- "description": "uView Pro,是全面支持Vue3+TS的uni-app生态框架,80+精选组件,支持安卓,iOS,鸿蒙,各小程序平台,支持多主题,一键暗黑模式",
4
+ "displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的高质量UI组件库,支持多主题、暗黑模式",
5
+ "version": "0.4.12",
6
+ "description": "uView Pro是基于Vue3+TS的多平台UI框架,提供80+高质量组件、便捷工具和常用模板,支持多主题与暗黑模式,支持H5/APP/鸿蒙/小程序等多端开发。已在华为鸿蒙应用商店上架,欢迎体验!",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",
9
9
  "browser": "index.ts",
package/types/global.d.ts CHANGED
@@ -21,7 +21,7 @@ export type ActionSheetItem = {
21
21
  text: string;
22
22
  subText?: string;
23
23
  color?: string;
24
- fontSize?: string;
24
+ fontSize?: string | number;
25
25
  disabled?: boolean;
26
26
  };
27
27
 
@@ -29,7 +29,7 @@ export type ActionSheetItem = {
29
29
  export type ActionSheetTips = {
30
30
  text: string;
31
31
  color?: string;
32
- fontSize?: string;
32
+ fontSize?: string | number;
33
33
  };
34
34
 
35
35
  // avatar-cropper 裁剪矩形框的样式