uview-pro 0.6.9 → 0.6.10

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,14 +1,25 @@
1
- ## 0.6.9(2026-07-15
1
+ ## 0.6.10(2026-07-23
2
2
 
3
- ### 🐛 Bug Fixes | Bug 修复
3
+ ### ♻️ Code Refactoring | 代码重构
4
4
 
5
- - **u-input:** 新增clear事件并在清空时触发(#175) ([103fadc](https://github.com/anyup/uView-Pro/commit/103fadc3649a9555ccb97682d04005ff63cc02f9))
6
- - **u-input:** 修复input在readonly状态下在低版本安卓上无效的问题 ([fccacbd](https://github.com/anyup/uView-Pro/commit/fccacbda882b846af1445dfaf7868f2981e21cb5))
5
+ - **u-config-provider:** 优化暗黑模式和主题初始化逻辑 ([0c010db](https://github.com/anyup/uView-Pro/commit/0c010db5b83bf9514b856cba95a7ba8d9aa56dbf))
6
+ - **theme:** 简化初始化主题和多语言相关逻辑 ([ec5d64b](https://github.com/anyup/uView-Pro/commit/ec5d64b0c8e0b494ab21c8c4bf278cf1e2559317))
7
7
 
8
8
  ### 👥 Contributors
9
9
 
10
10
  <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
11
11
 
12
+ ## 0.6.9(2026-07-15)
13
+
14
+ ### 🐛 Bug Fixes | Bug 修复
15
+
16
+ - **u-input:** 新增clear事件并在清空时触发(#175) ([103fadc](https://github.com/anyup/uView-Pro/commit/103fadc3649a9555ccb97682d04005ff63cc02f9))
17
+ - **u-input:** 修复input在readonly状态下在低版本安卓上无效的问题 ([fccacbd](https://github.com/anyup/uView-Pro/commit/fccacbda882b846af1445dfaf7868f2981e21cb5))
18
+
19
+ ### 👥 Contributors
20
+
21
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
22
+
12
23
  ## 0.6.8(2026-07-03)
13
24
 
14
25
  ### 🐛 Bug Fixes | Bug 修复
@@ -1,6 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { config, configProvider } from '../../libs';
3
- import type { Theme } from '../../types/global';
3
+ import type { Theme, DarkMode } from '../../types/global';
4
4
 
5
5
  export const ConfigProviderProps = {
6
6
  /** 自定义根节点样式 */
@@ -20,8 +20,8 @@ export const ConfigProviderProps = {
20
20
  * - 'auto': 自动跟随系统设置
21
21
  */
22
22
  darkMode: {
23
- type: String as PropType<'light' | 'dark' | 'auto'>,
24
- default: () => config.defaultDarkMode
23
+ type: String as PropType<DarkMode>,
24
+ default: () => configProvider.getDarkMode()
25
25
  },
26
26
  /**
27
27
  * 当前主题名称(用于多主题切换)
@@ -42,50 +42,46 @@ const props = defineProps(ConfigProviderProps);
42
42
 
43
43
  const emit = defineEmits<{
44
44
  'theme-change': [themeName: string];
45
- 'mode-change': [mode: 'light' | 'dark'];
45
+ 'mode-change': [mode: string];
46
46
  }>();
47
47
 
48
- // 计算当前的主题模式(亮色/暗黑)
49
- const darkMode = computed(() => (configProvider.isInDarkMode() ? 'dark' : 'light'));
48
+ const { initTheme } = useTheme();
49
+ const { initLocales, setLocale, getLocales, getCurrentLocale } = useLocale();
50
50
 
51
51
  const bootstrapTheme = () => {
52
- // 如果已经初始化过主题,不再重复初始化,只更新 props 相关配置
53
- const existingThemes = configProvider.getThemes();
54
- if (existingThemes.length > 0) {
55
- // 已初始化,只更新当前主题和暗黑模式
56
- if (props.currentTheme) {
57
- configProvider.setTheme(props.currentTheme as string);
58
- }
59
- if (props.darkMode) {
60
- configProvider.setDarkMode(props.darkMode);
52
+ // 初始化主题
53
+ try {
54
+ // 如果已经初始化过主题,不再重复初始化,只更新 props 相关配置
55
+ const existingThemes = configProvider.getThemes();
56
+ if (existingThemes.length > 0) {
57
+ // 已初始化,只在值不同时才更新(避免覆盖用户之前的设置)
58
+ if (props.currentTheme && props.currentTheme !== configProvider.getCurrentTheme()?.name) {
59
+ configProvider.setTheme(props.currentTheme as string);
60
+ }
61
+ if (props.darkMode && props.darkMode !== configProvider.getDarkMode()) {
62
+ configProvider.setDarkMode(props.darkMode);
63
+ }
64
+ return;
61
65
  }
62
- return;
63
- }
64
-
65
- // 未初始化,进行初始化
66
- if (props.themes && props.themes.length) {
67
- configProvider.initTheme(props.themes, props.currentTheme as any);
68
- } else {
69
- // 使用 useTheme 的 initTheme,它会处理默认主题
70
- const { initTheme } = useTheme();
71
- initTheme(undefined, props.currentTheme as any);
72
- }
73
66
 
74
- if (props.currentTheme) {
75
- configProvider.setTheme(props.currentTheme as string);
76
- }
77
- if (props.darkMode) {
78
- configProvider.setDarkMode(props.darkMode);
67
+ // 未初始化,进行初始化
68
+ if (props.themes && props.themes.length) {
69
+ configProvider.initTheme(props.themes, props.currentTheme as any);
70
+ } else {
71
+ // 使用 useTheme 的 initTheme,它会处理默认主题
72
+ initTheme(undefined, props.currentTheme as any);
73
+ }
74
+ } catch (e) {
75
+ console.warn('[u-config-provider] init theme failed', e);
79
76
  }
80
77
  };
81
78
 
82
79
  const bootstrapLocale = () => {
83
80
  // 初始化国际化
84
81
  try {
85
- const { initLocales, setLocale, getLocales } = useLocale();
86
82
  const existingLocales = getLocales();
87
83
  if (existingLocales.length > 0) {
88
- if (props.currentLocale) {
84
+ if (props.currentLocale && props.currentLocale !== getCurrentLocale()?.name) {
89
85
  setLocale(props.currentLocale as string);
90
86
  }
91
87
  } else {
@@ -134,7 +130,6 @@ watch(
134
130
  val => {
135
131
  if (val && val !== configProvider.getDarkMode()) {
136
132
  configProvider.setDarkMode(val);
137
- emit('mode-change', darkMode.value);
138
133
  }
139
134
  }
140
135
  );
@@ -144,7 +139,6 @@ watch(
144
139
  () => props.locales,
145
140
  val => {
146
141
  if (val && val.length) {
147
- const { initLocales } = useLocale();
148
142
  initLocales(val, props.currentLocale as any);
149
143
  }
150
144
  },
@@ -155,7 +149,6 @@ watch(
155
149
  () => props.currentLocale,
156
150
  val => {
157
151
  if (val) {
158
- const { setLocale } = useLocale();
159
152
  setLocale(val);
160
153
  }
161
154
  }
@@ -175,9 +168,12 @@ watch(
175
168
  // 监听暗黑模式变更并触发事件
176
169
  watch(
177
170
  () => configProvider.darkModeRef.value,
178
- () => {
179
- emit('mode-change', darkMode.value);
180
- }
171
+ (val, oldVal) => {
172
+ if (val && val !== oldVal) {
173
+ emit('mode-change', val);
174
+ }
175
+ },
176
+ { immediate: true }
181
177
  );
182
178
 
183
179
  // 计算合并样式(作为局部 fallback),configProvider 已经会把变量注入到 document 上
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
4
  "displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的高质量UI组件库,支持多主题、暗黑模式、多语言",
5
- "version": "0.6.9",
5
+ "version": "0.6.10",
6
6
  "description": "uView Pro是基于Vue3+TS的多平台UI框架,提供80+高质量组件、便捷工具和常用模板,支持多主题、暗黑模式、多语言,支持H5/APP/鸿蒙/小程序多端开发。已在鸿蒙应用商店上架,欢迎体验!",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",