uview-pro 0.4.11 → 0.4.13

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,18 +1,59 @@
1
- ## 0.4.112025-12-30
1
+ ## 0.4.132026-01-06
2
2
 
3
- ### 📦‍ Build System | 打包构建
3
+ ### Features | 新功能
4
4
 
5
- - 添加edgeone.json配置 ([ed7ba7d](https://github.com/anyup/uView-Pro/commit/ed7ba7d94dbfa791264a624a03938dc6ac58c0bb))
5
+ - **theme:** 主题初始化时支持默认主题设置 ([f2b61f6](https://github.com/anyup/uView-Pro/commit/f2b61f6caa1c285753b2e02f97309aa55bb77cca))
6
+ - **theme:** 增强主题系统初始化配置,支持在初始化时设置默认主题和暗黑模式 ([d228d10](https://github.com/anyup/uView-Pro/commit/d228d100baf619799b1dc1c8e289e1e8c9a30699))
6
7
 
7
8
  ### 🐛 Bug Fixes | Bug 修复
8
9
 
9
- - **theme:** 修复运行时设置 color theme 主题色不同步问题 ([1dcf56a](https://github.com/anyup/uView-Pro/commit/1dcf56a232f5b046e0dce5eb58ec90fb46ce19d5))
10
- - **u-top-tips:** 修复顶部提示组件zindex显示问题,避免影响其他组件的层级显示 ([91391a8](https://github.com/anyup/uView-Pro/commit/91391a8ca10d505936c0b45488af0a3145cab335))
10
+ - **u-number-box:** 修复 u-number-box 步进器 disabled 时字体不显示问题 ([75b3a74](https://github.com/anyup/uView-Pro/commit/75b3a74e6e763dec1a1ee0d3b4d0a62d646ee389))
11
+ - **u-textarea:** 修复u-textarea组件设置props.border='none'无效的问题 ([c5a97ba](https://github.com/anyup/uView-Pro/commit/c5a97ba4c00d226c8c0fd9605660d2654dec9dc2))
12
+
13
+ ### ♻️ Code Refactoring | 代码重构
14
+
15
+ - **theme:** 调整u-bg-gray-light默认色值,优化演示示例 ([37d6bda](https://github.com/anyup/uView-Pro/commit/37d6bda939f5d7c54aec09960878f236dfa32bb2))
11
16
 
12
17
  ### 👥 Contributors
13
18
 
14
19
  <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
15
20
 
21
+ ## 0.4.12(2026-01-04)
22
+
23
+ ### ♻️ Code Refactoring | 代码重构
24
+
25
+ - **u-action-sheet:** 优化u-action-sheet组件的类型定义 ([bc5e474](https://github.com/anyup/uView-Pro/commit/bc5e474e7117e20495504ff0e2397a147595033c))
26
+ - **zIndex:** 统一组件z-index值配置 ([ae1da98](https://github.com/anyup/uView-Pro/commit/ae1da986d307e5b4855fa32e5b2995fdb7be69e8))
27
+
28
+ ### 🐛 Bug Fixes | Bug 修复
29
+
30
+ - **form:** 修复field实例销毁时没有正常移除问题 ([57bfd3b](https://github.com/anyup/uView-Pro/commit/57bfd3bf9315d74c416869cd5a8c41562231166a))
31
+
32
+ ### ✨ Features | 新功能
33
+
34
+ - **u-tabbar:** 新增z-index属性支持自定义层级 ([c75d45f](https://github.com/anyup/uView-Pro/commit/c75d45f45e237453d0248124cdbe5bb797edb117))
35
+ - **u-modal:** 增加u-modal基础属性支持和自定义样式功能 ([201231e](https://github.com/anyup/uView-Pro/commit/201231ee2e0c25c605f12f582650b048e83213de))
36
+ - **components:** 增加u-pagination和u-picker自定义样式支持 ([eb22265](https://github.com/anyup/uView-Pro/commit/eb222657540179fcf8359133df83da89c10b09b8))
37
+
38
+ ### 👥 Contributors
39
+
40
+ <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>
41
+
42
+ ## 0.4.11(2025-12-30)
43
+
44
+ ### 📦‍ Build System | 打包构建
45
+
46
+ - 添加edgeone.json配置 ([ed7ba7d](https://github.com/anyup/uView-Pro/commit/ed7ba7d94dbfa791264a624a03938dc6ac58c0bb))
47
+
48
+ ### 🐛 Bug Fixes | Bug 修复
49
+
50
+ - **theme:** 修复运行时设置 color 与 theme 主题色不同步问题 ([1dcf56a](https://github.com/anyup/uView-Pro/commit/1dcf56a232f5b046e0dce5eb58ec90fb46ce19d5))
51
+ - **u-top-tips:** 修复顶部提示组件zindex显示问题,避免影响其他组件的层级显示 ([91391a8](https://github.com/anyup/uView-Pro/commit/91391a8ca10d505936c0b45488af0a3145cab335))
52
+
53
+ ### 👥 Contributors
54
+
55
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
56
+
16
57
  ## 0.4.10(2025-12-26)
17
58
 
18
59
  ### 🚀 Chore | 构建/工程依赖/工具
@@ -13,7 +13,7 @@
13
13
  * - 组件/页面场景(推荐):使用 `useTheme()` 组合式函数在组件内部读取响应式 `currentTheme`、`themes`、`darkMode` 并通过 `setTheme()` 和 `setDarkMode()` 切换主题/模式。
14
14
  *
15
15
  * 该组件的行为:
16
- * - 如果在挂载时传入 `themes`,会调用 `configProvider.init(themes)`
16
+ * - 如果在挂载时传入 `themes`,会调用 `configProvider.initTheme(themes)`
17
17
  * - 如果传入 `currentTheme`,会优先设置当前主题
18
18
  * - 如果传入 `darkMode`,会设置当前的暗黑模式状态,同时在 document 上添加 `u-theme-dark` 或 `u-theme-light` 类名
19
19
  *
@@ -63,7 +63,7 @@ const bootstrapTheme = () => {
63
63
 
64
64
  // 未初始化,进行初始化
65
65
  if (props.themes && props.themes.length) {
66
- configProvider.init(props.themes, props.currentTheme as any);
66
+ configProvider.initTheme(props.themes, props.currentTheme as any);
67
67
  } else {
68
68
  // 使用 useTheme 的 initTheme,它会处理默认主题
69
69
  const { initTheme } = useTheme();
@@ -91,7 +91,7 @@ watch(
91
91
  // 那么对其做深度监听会在我们内部更新主题对象时触发该回调,进而再次调用 init 导致循环更新。
92
92
  // 为避免该情况,先做简单保护:当传入对象正是 configProvider.themesRef.value 时不重复初始化。
93
93
  if (val && val.length && val !== configProvider.themesRef.value) {
94
- configProvider.init(val, props.currentTheme as any);
94
+ configProvider.initTheme(val, props.currentTheme as any);
95
95
  }
96
96
  },
97
97
  { deep: true }
@@ -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: {
@@ -310,12 +310,12 @@ function handleChange(value: number, type: 'update:modelValue' | 'change' | 'blu
310
310
  }
311
311
 
312
312
  .u-icon-disabled {
313
- color: var(--u-bg-gray-light) !important;
313
+ color: var(--u-type-info-disabled) !important;
314
314
  background: var(--u-bg-gray-light) !important;
315
315
  }
316
316
 
317
317
  .u-input-disabled {
318
- color: var(--u-bg-gray-light) !important;
318
+ color: var(--u-type-info-disabled) !important;
319
319
  background-color: var(--u-bg-gray-light) !important;
320
320
  }
321
321
  </style>
@@ -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,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { baseProps } from '../common/props';
3
+ import type { TextareaBorder } from '../../types/global';
3
4
 
4
5
  const textarea = {
5
6
  value: '',
@@ -72,7 +73,7 @@ export const TextareaProps = {
72
73
  // 最大输入长度,设置为 -1 的时候不限制最大长度
73
74
  maxlength: { type: [String, Number] as PropType<string | number>, default: textarea.maxlength },
74
75
  // 边框类型,surround-四周边框,bottom-底部边框
75
- border: { type: [String, Boolean] as PropType<string | boolean>, default: textarea.border },
76
+ border: { type: [String, Boolean] as PropType<TextareaBorder | boolean>, default: textarea.border },
76
77
  // 用于处理或者过滤输入框内容的方法
77
78
  formatter: { type: Function as PropType<((val: any) => any) | null>, default: textarea.formatter },
78
79
  // 是否忽略组件内对文本合成系统事件的处理
@@ -165,7 +165,7 @@ watch(
165
165
  // 组件的类名
166
166
  const textareaClass = computed(() => {
167
167
  let classes: string[] = [];
168
- if (props.border) {
168
+ if (props.border && props.border !== 'none') {
169
169
  if (props.border === 'surround') {
170
170
  classes = classes.concat(['u-textarea--border', 'u-textarea--radius']);
171
171
  } else if (props.border === 'bottom') {
@@ -181,7 +181,7 @@ const textareaClass = computed(() => {
181
181
  // 组件的样式
182
182
  const textareaStyle = computed(() => {
183
183
  const style: Record<string, any> = {};
184
- if (props.border) {
184
+ if (props.border && props.border !== 'none') {
185
185
  style.padding = `${props.border ? 20 : 0}rpx`;
186
186
  }
187
187
  // #ifdef APP-NVUE
@@ -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>;
package/index.ts CHANGED
@@ -17,14 +17,19 @@ const install = (app: any, options?: UViewProOptions): void => {
17
17
  try {
18
18
  if (options) {
19
19
  // 配置主题:统一使用 useTheme 的 initTheme 初始化,避免重复初始化
20
- if (options.theme) {
21
- // 如果是数组,则为多主题配置
22
- // 直接使用 useTheme 的 initTheme,它会智能处理重复初始化
23
- if (Array.isArray(options.theme)) {
24
- initTheme(options.theme);
20
+ if (options?.theme) {
21
+ const optTheme = options.theme as any;
22
+ // 1.如果是数组,则为多主题配置
23
+ if (Array.isArray(optTheme)) {
24
+ initTheme(optTheme);
25
+ } else if (typeof optTheme === 'object' && optTheme.themes) {
26
+ // 2.如果为对象且有themes,则为多主题配置+设置默认主题
27
+ initTheme(optTheme.themes, {
28
+ defaultTheme: optTheme.defaultTheme,
29
+ defaultDarkMode: optTheme.defaultDarkMode
30
+ });
25
31
  } else {
26
- // 兼容之前只有一套样式的情况,需要覆盖默认主题
27
- // 获取默认主题(uviewpro)
32
+ // 3.兼容之前只有一套样式的情况,需要覆盖默认主题,默认系统主题(uviewpro)
28
33
  const defaultTheme = defaultThemes[0];
29
34
  if (defaultTheme) {
30
35
  // 创建新主题对象,用用户的 theme 覆盖默认主题的 color
@@ -32,7 +37,7 @@ const install = (app: any, options?: UViewProOptions): void => {
32
37
  ...defaultTheme,
33
38
  color: {
34
39
  ...defaultTheme.color,
35
- ...options.theme
40
+ ...optTheme
36
41
  }
37
42
  };
38
43
  // 初始化主题(只包含覆盖后的默认主题)
@@ -1,8 +1,7 @@
1
- // 此版本发布于2023-03-27
2
1
  /**
3
2
  * 组件库配置项类型定义
4
3
  */
5
-
4
+ import { reactive } from 'vue';
6
5
  import { version } from '../../package.json';
7
6
  import type { DarkMode } from '../../types/global';
8
7
 
@@ -19,9 +18,7 @@ export interface AppConfig {
19
18
  defaultDarkMode: DarkMode;
20
19
  }
21
20
 
22
- // const version: string = '1.8.8';
23
-
24
- const config: AppConfig = {
21
+ export const config = reactive<AppConfig>({
25
22
  v: version,
26
23
  version: version,
27
24
  // 主题名称
@@ -30,6 +27,6 @@ const config: AppConfig = {
30
27
  defaultTheme: 'uviewpro',
31
28
  // 默认为亮色模式
32
29
  defaultDarkMode: 'light'
33
- };
30
+ });
34
31
 
35
32
  export default config;
@@ -34,7 +34,7 @@ export const lightPalette: ThemeColor = {
34
34
  shadowColor: 'rgba(0, 0, 0, 0.1)',
35
35
  bgColor: '#f3f4f6',
36
36
  bgWhite: '#ffffff',
37
- bgGrayLight: '#f5f7fa',
37
+ bgGrayLight: '#f1f1f1',
38
38
  bgGrayDark: '#2f343c',
39
39
  bgBlack: '#000000'
40
40
  };
@@ -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;
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { DarkMode, Theme } from '../../types/global';
10
- import configProvider from '../util/config-provider';
10
+ import configProvider, { type DefaultThemeConfig } from '../util/config-provider';
11
11
  import { defaultThemes } from '../config/theme-tokens';
12
12
 
13
13
  const THEME_STORAGE_KEY = 'uview-pro-theme';
@@ -64,42 +64,44 @@ function getAvailableThemes() {
64
64
  /**
65
65
  * 初始化主题系统
66
66
  * @param themes 可选的主题列表,如果未提供则尝试从 uni.$u.themes 读取
67
- * @param defaultThemeName 可选的默认主题名
67
+ * @param defaultConfig 可选的默认主题配置,支持字符串(默认主题名)或对象({ defaultTheme?, defaultDarkMode? })
68
68
  */
69
- export function initTheme(themes?: any[], defaultThemeName?: string) {
69
+ export function initTheme(themes?: Theme[], defaultConfig?: string | DefaultThemeConfig) {
70
70
  // 如果有传入主题列表,使用传入的
71
71
  if (Array.isArray(themes) && themes.length > 0) {
72
- configProvider.init(themes, defaultThemeName);
72
+ configProvider.initTheme(themes, defaultConfig);
73
73
  return;
74
74
  }
75
75
 
76
- // 若已通过插件或其他方式完成初始化,则不再覆盖,最多按需切换默认主题
77
- const existingThemes = configProvider.getThemes();
78
- if (existingThemes.length > 0) {
79
- if (defaultThemeName) {
80
- configProvider.setTheme(defaultThemeName);
81
- } else if (!configProvider.getCurrentTheme()) {
82
- configProvider.setTheme(existingThemes[0].name);
83
- } else {
84
- // 触发一次 apply,便于初始化 CSS 变量
85
- configProvider.setTheme(configProvider.getCurrentTheme()!.name);
86
- }
87
- return;
88
- }
89
-
90
- // 初始化 configProvider(如果运行时提供了内置主题)
91
- try {
92
- const builtin = (typeof uni !== 'undefined' && (uni as any).$u && (uni as any).$u.themes) || [];
93
- if (Array.isArray(builtin) && builtin.length > 0) {
94
- configProvider.init(builtin as Theme[], defaultThemeName);
95
- return;
96
- }
97
- } catch (e) {
98
- // ignore
99
- }
76
+ // // 若已通过插件或其他方式完成初始化,则不再覆盖,最多按需切换默认主题
77
+ // const existingThemes = configProvider.getThemes();
78
+ // if (existingThemes.length > 0) {
79
+ // if (typeof defaultConfig === 'string') {
80
+ // configProvider.setTheme(defaultConfig);
81
+ // } else if (defaultConfig && typeof defaultConfig === 'object' && (defaultConfig as any).defaultTheme) {
82
+ // configProvider.setTheme(defaultConfig.defaultTheme);
83
+ // } else if (!configProvider.getCurrentTheme()) {
84
+ // configProvider.setTheme(existingThemes[0].name);
85
+ // } else {
86
+ // // 触发一次 apply,便于初始化 CSS 变量
87
+ // configProvider.setTheme(configProvider.getCurrentTheme()!.name);
88
+ // }
89
+ // return;
90
+ // }
91
+
92
+ // // 初始化 configProvider(如果运行时提供了内置主题)
93
+ // try {
94
+ // const builtin = (typeof uni !== 'undefined' && (uni as any).$u && (uni as any).$u.themes) || [];
95
+ // if (Array.isArray(builtin) && builtin.length > 0) {
96
+ // configProvider.initTheme(builtin as Theme[], defaultConfig);
97
+ // return;
98
+ // }
99
+ // } catch (e) {
100
+ // // ignore
101
+ // }
100
102
 
101
103
  // 回退到内置默认主题
102
- configProvider.init(defaultThemes as Theme[], defaultThemeName);
104
+ configProvider.initTheme(defaultThemes as Theme[], defaultConfig);
103
105
  }
104
106
 
105
107
  /**
@@ -33,6 +33,17 @@ const STRUCTURAL_TOKENS = new Set([
33
33
  'shadowColor'
34
34
  ]);
35
35
 
36
+ export type DefaultThemeConfig = {
37
+ /**
38
+ * 默认主题
39
+ */
40
+ defaultTheme?: string;
41
+ /**
42
+ * 默认暗黑模式
43
+ */
44
+ defaultDarkMode?: DarkMode;
45
+ };
46
+
36
47
  /**
37
48
  * ConfigProvider: 管理全局主题
38
49
  * - init(themes, defaultName): 初始化主题系统
@@ -141,28 +152,39 @@ export class ConfigProvider {
141
152
  /**
142
153
  * 初始化主题系统
143
154
  * @param themes 可用主题数组
144
- * @param defaultThemeName 可选默认主题名
155
+ * @param defaultTheme 可选默认主题名
145
156
  */
146
- init(themes?: Theme[], defaultThemeName?: string) {
157
+ initTheme(themes?: Theme[], defaultConfig?: string | DefaultThemeConfig) {
147
158
  const normalizedThemes = this.normalizeThemes(themes);
148
159
  if (!normalizedThemes.length) {
149
160
  console.warn('[ConfigProvider] init called with empty themes');
150
161
  return;
151
162
  }
152
163
 
164
+ // 配置默认主题
165
+ if (defaultConfig) {
166
+ if (typeof defaultConfig === 'string') {
167
+ config.defaultTheme = defaultConfig || config.defaultTheme;
168
+ } else if (typeof defaultConfig === 'object') {
169
+ const { defaultTheme, defaultDarkMode } = defaultConfig;
170
+ config.defaultTheme = defaultTheme || config.defaultTheme;
171
+ config.defaultDarkMode = defaultDarkMode || config.defaultDarkMode;
172
+ }
173
+ }
174
+
175
+ // 设置主题列表,响应式
153
176
  this.themesRef.value = normalizedThemes.slice();
154
177
 
155
178
  // 先尝试从 Storage 读取已保存主题名
156
179
  const saved = this.readStorage<string>(THEME_STORAGE_KEY);
157
-
158
- let initialName = saved || defaultThemeName || this.themesRef.value[0].name;
180
+ let initialName = saved || config.defaultTheme || this.themesRef.value[0].name;
159
181
  const found = this.themesRef.value.find(t => t.name === initialName) || this.themesRef.value[0];
160
182
 
183
+ // 设置当前主题,响应式
161
184
  this.currentThemeRef.value = found;
162
185
 
163
- // 尝试从 Storage 读取暗黑模式设置
164
- const savedDarkMode = this.readStorage<DarkMode>(DARK_MODE_STORAGE_KEY);
165
- this.darkModeRef.value = savedDarkMode || config.defaultDarkMode;
186
+ // 初始化暗黑模式设置
187
+ this.initDarkMode(config.defaultDarkMode);
166
188
 
167
189
  // 应用主题
168
190
  this.applyTheme(found);
@@ -173,6 +195,16 @@ export class ConfigProvider {
173
195
  return this;
174
196
  }
175
197
 
198
+ /**
199
+ * 初始化暗黑模式设置
200
+ * @param darkMode
201
+ */
202
+ initDarkMode(darkMode?: DarkMode) {
203
+ // 尝试从 Storage 读取暗黑模式设置
204
+ const savedDarkMode = this.readStorage<DarkMode>(DARK_MODE_STORAGE_KEY);
205
+ this.darkModeRef.value = savedDarkMode || darkMode || config.defaultDarkMode;
206
+ }
207
+
176
208
  /**
177
209
  * 获取所有可用主题
178
210
  */
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
4
  "displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的高质量UI组件库,支持多主题、暗黑模式",
5
- "version": "0.4.11",
6
- "description": "uView Pro 是为 Vue 3 + TypeScript 的 uni-app 生态量身打造的多平台 UI 框架。提供 80+ 高质量组件、丰富主题与暗黑模式、实用开发工具与模板,显著提升 H5/APP/鸿蒙/小程序 的多端开发效率,目前已在华为鸿蒙应用商店上线,欢迎体验。",
5
+ "version": "0.4.13",
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/theme.scss CHANGED
@@ -25,7 +25,7 @@ page {
25
25
  /* 背景色 */
26
26
  --u-bg-color: #f3f4f6;
27
27
  --u-bg-white: #ffffff;
28
- --u-bg-gray-light: #f5f7fa;
28
+ --u-bg-gray-light: #f1f1f1;
29
29
  --u-bg-gray-dark: #2f343c;
30
30
  --u-bg-black: #000000;
31
31
 
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 裁剪矩形框的样式
@@ -160,6 +160,8 @@ export type InputConfirmType = 'send' | 'search' | 'next' | 'go' | 'done';
160
160
 
161
161
  export type InputLabelPosition = 'left' | 'top';
162
162
 
163
+ export type TextareaBorder = 'surround' | 'none' | 'bottom';
164
+
163
165
  export type FormErrorType = 'message' | 'border' | 'border-bottom' | 'none' | 'toast';
164
166
 
165
167
  export type IconLabelPosition = 'left' | 'top' | 'right' | 'bottom';
@@ -372,6 +374,12 @@ export type Theme = {
372
374
  darkCss?: Record<string, string>;
373
375
  };
374
376
 
377
+ export type Themes = {
378
+ themes: Theme[];
379
+ defaultTheme?: string;
380
+ defaultDarkMode?: DarkMode;
381
+ };
382
+
375
383
  export type LogConfig = Partial<{
376
384
  debug?: boolean;
377
385
  prefix?: string;
@@ -379,7 +387,7 @@ export type LogConfig = Partial<{
379
387
  }>;
380
388
 
381
389
  export interface UViewProOptions {
382
- theme?: ThemeColor | Theme[];
390
+ theme?: ThemeColor | Theme[] | Themes;
383
391
  log?: LogConfig;
384
392
  // 可扩展更多配置项
385
393
  }