uview-pro 0.6.3 → 0.6.5

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 (38) hide show
  1. package/changelog.md +27 -0
  2. package/components/u-action-sheet/types.ts +2 -4
  3. package/components/u-action-sheet/u-action-sheet.vue +7 -2
  4. package/components/u-calendar/types.ts +4 -6
  5. package/components/u-calendar/u-calendar.vue +8 -3
  6. package/components/u-field/types.ts +2 -0
  7. package/components/u-field/u-field.vue +25 -6
  8. package/components/u-input/types.ts +6 -4
  9. package/components/u-input/u-input.vue +12 -5
  10. package/components/u-keyboard/types.ts +2 -5
  11. package/components/u-keyboard/u-keyboard.vue +6 -2
  12. package/components/u-link/types.ts +2 -4
  13. package/components/u-link/u-link.vue +9 -3
  14. package/components/u-loadmore/types.ts +1 -5
  15. package/components/u-loadmore/u-loadmore.vue +13 -4
  16. package/components/u-modal/types.ts +4 -6
  17. package/components/u-modal/u-modal.vue +20 -3
  18. package/components/u-no-network/types.ts +1 -4
  19. package/components/u-no-network/u-no-network.vue +4 -1
  20. package/components/u-pagination/types.ts +2 -5
  21. package/components/u-pagination/u-pagination.vue +9 -3
  22. package/components/u-picker/types.ts +3 -5
  23. package/components/u-picker/u-picker.vue +9 -3
  24. package/components/u-read-more/types.ts +3 -5
  25. package/components/u-read-more/u-read-more.vue +7 -2
  26. package/components/u-search/types.ts +65 -68
  27. package/components/u-search/u-search.vue +296 -291
  28. package/components/u-section/types.ts +1 -4
  29. package/components/u-section/u-section.vue +7 -2
  30. package/components/u-select/types.ts +3 -5
  31. package/components/u-select/u-select.vue +9 -4
  32. package/components/u-textarea/types.ts +2 -0
  33. package/components/u-textarea/u-textarea.vue +18 -2
  34. package/components/u-upload/types.ts +1 -4
  35. package/components/u-upload/u-upload.vue +1 -1
  36. package/components/u-verification-code/types.ts +3 -6
  37. package/components/u-verification-code/u-verification-code.vue +16 -9
  38. package/package.json +1 -1
package/changelog.md CHANGED
@@ -1,3 +1,30 @@
1
+ ## 0.6.5(2026-06-05)
2
+
3
+ ### 🐛 Bug Fixes | Bug 修复
4
+
5
+ - **locale:** 修复多个组件在多语言切换时不能实时更新的问题,统一默认值处理方式 ([86dbc61](https://github.com/anyup/uView-Pro/commit/86dbc61d4ffb9f70f2b98e11566b7ca90549a687))
6
+
7
+ ### ✨ Features | 新功能
8
+
9
+ - **demo:** 新增多语言切换图标到演示页面的头部 ([9dfd98e](https://github.com/anyup/uView-Pro/commit/9dfd98e5ef8e1e0d5a091cd256fefee2a3ae8064))
10
+ - **loadmore,verificationCode:** 优化loadmore和verificationCode组件的演示示例 ([cddfaf9](https://github.com/anyup/uView-Pro/commit/cddfaf94354ebf5fde954f0098e23a7debc5c550))
11
+
12
+ ### 👥 Contributors
13
+
14
+ <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
+
16
+ ## 0.6.4(2026-06-02)
17
+
18
+ ### ✨ Features | 新功能
19
+
20
+ - **u-input:** 新增readonly输入属性,支持设置输入框只读状态,新增禁用与只读示例页面及配置项(#160) ([6a92373](https://github.com/anyup/uView-Pro/commit/6a92373a6c8a1c2875b93d6dbb3985df34887c4e))
21
+ - **u-textarea:** 新增click事件支持,在只读/非禁用状态下可触发点击回调,更新演示页面(#160) ([a79dc57](https://github.com/anyup/uView-Pro/commit/a79dc57262bfb3909d2f35bbf26589906e9a4c8d))
22
+ - **u-field:** 新增readonly属性支持,设置后可点击但无法输入,调整disabled和readonly状态的遮罩逻辑与样式(#160) ([708f13b](https://github.com/anyup/uView-Pro/commit/708f13bb3601c0c77a0a75f1b4d1c148f28c7229))
23
+
24
+ ### 👥 Contributors
25
+
26
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
27
+
1
28
  ## 0.6.3(2026-05-28)
2
29
 
3
30
  ### 🐛 Bug Fixes | Bug 修复
@@ -1,8 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { ActionSheetItem, ActionSheetTips } from '../../types/global';
3
- import { getColor, useLocale } from '../../';
4
-
5
- const { t } = useLocale();
3
+ import { getColor } from '../../';
6
4
 
7
5
  /**
8
6
  * actionSheet 操作菜单
@@ -42,7 +40,7 @@ export const ActionSheetProps = {
42
40
  /** 弹出的z-index值 */
43
41
  zIndex: { type: [String, Number], default: 0 },
44
42
  /** 取消按钮的文字提示 */
45
- cancelText: { type: String, default: () => t('uActionSheet.cancelText') },
43
+ cancelText: { type: String, default: '' },
46
44
  /** 字体颜色 */
47
45
  color: { type: String, default: () => getColor('mainColor') },
48
46
  /** 字体大小 */
@@ -40,7 +40,7 @@
40
40
  v-if="cancelBtn"
41
41
  @tap="close"
42
42
  >
43
- {{ cancelText }}
43
+ {{ getCancelText }}
44
44
  </view>
45
45
  </u-popup>
46
46
  </template>
@@ -60,7 +60,7 @@ export default {
60
60
 
61
61
  <script setup lang="ts">
62
62
  import { computed } from 'vue';
63
- import { $u, useParent } from '../..';
63
+ import { $u, useParent, useLocale } from '../..';
64
64
  import { ActionSheetProps } from './types';
65
65
 
66
66
  /**
@@ -85,6 +85,8 @@ const props = defineProps(ActionSheetProps);
85
85
 
86
86
  const emit = defineEmits(['update:modelValue', 'click', 'close']);
87
87
 
88
+ const { t } = useLocale();
89
+
88
90
  useParent('u-action-sheet');
89
91
 
90
92
  const popupValue = computed({
@@ -92,6 +94,9 @@ const popupValue = computed({
92
94
  set: (val: boolean) => emit('update:modelValue', val)
93
95
  });
94
96
 
97
+ // 国际化计算属性
98
+ const getCancelText = computed(() => props.cancelText || t('uActionSheet.cancelText'));
99
+
95
100
  // 顶部提示的样式
96
101
  const tipsStyle = computed(() => {
97
102
  let style: Record<string, string> = {};
@@ -1,8 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { CalendarChangeDate, CalendarChangeRange, CalendarMode, ThemeType } from '../../types/global';
3
- import { getColor, useLocale } from '../../';
4
-
5
- const { t } = useLocale();
3
+ import { getColor } from '../../';
6
4
 
7
5
  /**
8
6
  * calendar 日历类型定义
@@ -58,9 +56,9 @@ export const CalendarProps = {
58
56
  /** 范围内日期字体颜色 */
59
57
  rangeColor: { type: String, default: () => getColor('primary') },
60
58
  /** mode=range时生效,起始日期自定义文案 */
61
- startText: { type: String, default: () => t('uCalendar.startText') },
59
+ startText: { type: String, default: '' },
62
60
  /** mode=range时生效,结束日期自定义文案 */
63
- endText: { type: String, default: () => t('uCalendar.endText') },
61
+ endText: { type: String, default: '' },
64
62
  /** 按钮样式类型 */
65
63
  btnType: { type: String as PropType<ThemeType>, default: 'primary' },
66
64
  /** 当前选中日期带选中效果 */
@@ -72,7 +70,7 @@ export const CalendarProps = {
72
70
  /** 是否显示右上角的关闭图标 */
73
71
  closeable: { type: Boolean, default: true },
74
72
  /** 顶部的提示文字 */
75
- toolTip: { type: String, default: () => t('uCalendar.toolTip') },
73
+ toolTip: { type: String, default: '' },
76
74
  /** 是否显示农历 */
77
75
  showLunar: { type: Boolean, default: false },
78
76
  /** 是否在页面中显示 */
@@ -18,7 +18,7 @@
18
18
  >
19
19
  <view class="u-calendar__header" v-if="!props.isPage">
20
20
  <view class="u-calendar__header__text" v-if="!slots.tooltip">
21
- {{ toolTip }}
21
+ {{ getToolTip }}
22
22
  </view>
23
23
  <slot v-else name="tooltip" />
24
24
  </view>
@@ -141,7 +141,7 @@
141
141
  class="u-calendar__content__item__lunar"
142
142
  :style="{ color: activeColor }"
143
143
  >
144
- {{ startText }}
144
+ {{ getStartText }}
145
145
  </view>
146
146
  <!-- 范围选择结束日期显示"结束" -->
147
147
  <view
@@ -152,7 +152,7 @@
152
152
  class="u-calendar__content__item__lunar"
153
153
  :style="{ color: activeColor }"
154
154
  >
155
- {{ endText }}
155
+ {{ getEndText }}
156
156
  </view>
157
157
  <!-- 节日名称 -->
158
158
  <view
@@ -347,6 +347,11 @@ const btnDisable = computed(() => {
347
347
  return disable;
348
348
  });
349
349
 
350
+ // 国际化计算属性
351
+ const getStartText = computed(() => props.startText || t('uCalendar.startText'));
352
+ const getEndText = computed(() => props.endText || t('uCalendar.endText'));
353
+ const getToolTip = computed(() => props.toolTip || t('uCalendar.toolTip'));
354
+
350
355
  watch([dataChange, lunarChange], () => {
351
356
  init();
352
357
  });
@@ -56,6 +56,8 @@ export const FieldProps = {
56
56
  type: { type: String as PropType<InputType>, default: 'text' },
57
57
  /** 是否不可输入(默认false) */
58
58
  disabled: { type: Boolean, default: false },
59
+ /** 是否只读,禁止输入但可点击,样式不变,可触发click事件(默认false) */
60
+ readonly: { type: Boolean, default: false },
59
61
  /** 最大输入长度,设置为 -1 的时候不限制最大长度(默认140) */
60
62
  maxlength: { type: [Number, String] as PropType<string | number>, default: 140 },
61
63
  /** 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done) */
@@ -1,7 +1,14 @@
1
1
  <template>
2
2
  <view
3
3
  class="u-field"
4
- :class="[{ 'u-border-top': props.borderTop, 'u-border-bottom': props.borderBottom }, customClass]"
4
+ :class="[
5
+ {
6
+ 'u-border-top': props.borderTop,
7
+ 'u-border-bottom': props.borderBottom,
8
+ 'u-field--disabled': props.disabled
9
+ },
10
+ customClass
11
+ ]"
5
12
  :style="$u.toStyle(customStyle)"
6
13
  >
7
14
  <view
@@ -40,6 +47,7 @@
40
47
  :placeholder="String(props.placeholder)"
41
48
  :placeholderStyle="props.placeholderStyle"
42
49
  :disabled="props.disabled"
50
+ :readonly="props.readonly"
43
51
  :maxlength="inputMaxlength"
44
52
  :focus="props.focus"
45
53
  :autoHeight="props.autoHeight"
@@ -48,7 +56,6 @@
48
56
  @blur="onBlur"
49
57
  @focus="onFocus"
50
58
  @confirm="onConfirm"
51
- @tap="fieldClick"
52
59
  />
53
60
  <!-- prettier-ignore -->
54
61
  <input
@@ -61,6 +68,7 @@
61
68
  :placeholder="String(props.placeholder)"
62
69
  :placeholderStyle="props.placeholderStyle"
63
70
  :disabled="props.disabled"
71
+ :readonly="props.readonly"
64
72
  :maxlength="inputMaxlength"
65
73
  :focus="props.focus"
66
74
  :confirmType="props.confirmType"
@@ -68,10 +76,9 @@
68
76
  @blur="onBlur"
69
77
  @input="onInput"
70
78
  @confirm="onConfirm"
71
- @tap="fieldClick"
72
79
  />
73
- <!-- 透明遮罩,只在disabled时显示,用于响应点击事件 -->
74
- <view v-if="props.disabled" class="u-field-disabled-overlay" @tap="fieldClick"></view>
80
+ <!-- 透明遮罩,在disabled或readonly时显示,用于捕获点击事件(原生input设置disabled会阻止点击冒泡) -->
81
+ <view v-if="props.readonly" class="u-field__readonly-overlay" @tap.stop="fieldClick"></view>
75
82
  </view>
76
83
  <u-icon
77
84
  v-if="props.clearable && inputValue !== '' && focused && !props.disabled"
@@ -256,6 +263,7 @@ function rightIconClick() {
256
263
  }
257
264
 
258
265
  function fieldClick() {
266
+ if (props.disabled) return;
259
267
  emit('click');
260
268
  }
261
269
  </script>
@@ -366,7 +374,7 @@ function fieldClick() {
366
374
  position: relative;
367
375
  }
368
376
 
369
- .u-field-disabled-overlay {
377
+ .u-field__readonly-overlay {
370
378
  position: absolute;
371
379
  top: 0;
372
380
  left: 0;
@@ -375,4 +383,15 @@ function fieldClick() {
375
383
  background-color: transparent;
376
384
  z-index: 1;
377
385
  }
386
+
387
+ .u-field--disabled {
388
+ background-color: $u-bg-gray-light;
389
+ }
390
+
391
+ .u-field--disabled .u-textarea-class,
392
+ .u-field--disabled .u-field__input-wrap {
393
+ background-color: transparent;
394
+ color: $u-light-color;
395
+ -webkit-text-fill-color: $u-light-color;
396
+ }
378
397
  </style>
@@ -1,8 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { InputAlign, InputConfirmType, InputType, SizeType } from '../../types/global';
3
- import { useLocale } from '../../';
4
-
5
- const { t } = useLocale();
6
3
 
7
4
  /**
8
5
  * u-input 组件 props 类型定义
@@ -43,13 +40,18 @@ export const InputProps = {
43
40
  /** placeholder显示值(默认 '请输入内容') */
44
41
  placeholder: {
45
42
  type: String,
46
- default: () => t('uInput.placeholder')
43
+ default: ''
47
44
  },
48
45
  /** 是否禁用输入框(默认false) */
49
46
  disabled: {
50
47
  type: Boolean,
51
48
  default: false
52
49
  },
50
+ /** 是否只读,禁止输入但可点击,样式不变,可触发click事件(默认false) */
51
+ readonly: {
52
+ type: Boolean,
53
+ default: false
54
+ },
53
55
  /** 输入框的最大可输入长度(默认140) */
54
56
  maxlength: {
55
57
  type: [Number, String] as PropType<number | string>,
@@ -21,9 +21,10 @@
21
21
  class="u-input__input u-input__textarea"
22
22
  :style="getStyle"
23
23
  :value="inputValue"
24
- :placeholder="placeholder"
24
+ :placeholder="getPlaceholder"
25
25
  :placeholderStyle="getPlaceholderStyle"
26
26
  :disabled="disabled"
27
+ :readonly="readonly"
27
28
  :maxlength="inputMaxlength"
28
29
  :fixed="fixed"
29
30
  :focus="focus"
@@ -46,9 +47,10 @@
46
47
  :style="getStyle"
47
48
  :value="inputValue"
48
49
  :password="type == 'password' && !showPassword"
49
- :placeholder="placeholder"
50
+ :placeholder="getPlaceholder"
50
51
  :placeholderStyle="getPlaceholderStyle"
51
52
  :disabled="disabled || type === 'select'"
53
+ :readonly="readonly"
52
54
  :maxlength="inputMaxlength"
53
55
  :focus="focus"
54
56
  :confirmType="confirmType"
@@ -62,7 +64,8 @@
62
64
  @input="handleInput"
63
65
  @confirm="onConfirm"
64
66
  />
65
- <view class="u-input__select-overlay" v-if="type === 'select'" @tap.stop="inputClick"></view>
67
+ <!-- 透明遮罩,在readonly时显示,用于捕获点击事件(原生input设置disabled会阻止点击冒泡) -->
68
+ <view v-if="readonly || type === 'select'" class="u-input__readonly-overlay" @tap.stop="inputClick"></view>
66
69
  <view class="u-input__right-icon u-flex">
67
70
  <view
68
71
  class="u-input__right-icon__clear u-input__right-icon__item"
@@ -123,13 +126,15 @@ export default {
123
126
 
124
127
  <script setup lang="ts">
125
128
  import { ref, computed, watch } from 'vue';
126
- import { $u, useChildren } from '../..';
129
+ import { $u, useChildren, useLocale } from '../..';
127
130
  import { InputProps } from './types';
128
131
  import type { SizeType } from '../../types/global';
129
132
 
130
133
  const props = defineProps(InputProps);
131
134
  const emit = defineEmits(['update:modelValue', 'input', 'blur', 'focus', 'confirm', 'click']);
132
135
 
136
+ const { t } = useLocale();
137
+
133
138
  const { emitToParent } = useChildren('u-input', 'u-form-item');
134
139
  const { parentExposed } = useChildren('u-input', 'u-form');
135
140
 
@@ -259,6 +264,8 @@ const getCursorSpacing = computed(() => Number(props.cursorSpacing));
259
264
  const uSelectionStart = computed(() => String(props.selectionStart));
260
265
  // 光标结束位置
261
266
  const uSelectionEnd = computed(() => String(props.selectionEnd));
267
+ // placeholder 国际化
268
+ const getPlaceholder = computed(() => props.placeholder || t('uInput.placeholder'));
262
269
 
263
270
  /**
264
271
  * change 事件
@@ -347,7 +354,7 @@ defineExpose({
347
354
  @include vue-flex;
348
355
  align-items: center;
349
356
 
350
- &__select-overlay {
357
+ &__readonly-overlay {
351
358
  position: absolute;
352
359
  inset: 0;
353
360
  z-index: 1;
@@ -1,7 +1,4 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
- import { useLocale } from '../../';
3
-
4
- const { t } = useLocale();
5
2
 
6
3
  /**
7
4
  * u-keyboard 组件 Props 类型定义
@@ -35,9 +32,9 @@ export const KeyboardProps = {
35
32
  /** z-index值 */
36
33
  zIndex: { type: [Number, String] as PropType<string | number>, default: '' },
37
34
  /** 取消按钮的文字 */
38
- cancelText: { type: String, default: () => t('uKeyboard.cancelText') },
35
+ cancelText: { type: String, default: '' },
39
36
  /** 确认按钮的文字 */
40
- confirmText: { type: String, default: () => t('uKeyboard.confirmText') }
37
+ confirmText: { type: String, default: '' }
41
38
  };
42
39
 
43
40
  export type KeyboardProps = ExtractPropTypes<typeof KeyboardProps>;
@@ -13,7 +13,7 @@
13
13
  <slot />
14
14
  <view class="u-tooltip" v-if="tooltip">
15
15
  <view class="u-tooltip-item u-tooltip-cancel" hover-class="u-tooltip-cancel-hover" @tap="onCancel">
16
- {{ cancelBtn ? cancelText : '' }}
16
+ {{ cancelBtn ? getCancelText : '' }}
17
17
  </view>
18
18
  <view v-if="showTips" class="u-tooltip-item u-tooltip-tips">
19
19
  {{
@@ -32,7 +32,7 @@
32
32
  class="u-tooltip-item u-tooltips-submit"
33
33
  hover-class="u-tooltips-submit-hover"
34
34
  >
35
- {{ confirmBtn ? confirmText : '' }}
35
+ {{ confirmBtn ? getConfirmText : '' }}
36
36
  </view>
37
37
  </view>
38
38
  <block v-if="mode == 'number' || mode == 'card'">
@@ -99,6 +99,10 @@ const { t } = useLocale();
99
99
 
100
100
  const uZIndex = computed(() => (props.zIndex ? props.zIndex : $u.zIndex.popup));
101
101
 
102
+ // 国际化计算属性
103
+ const getCancelText = computed(() => props.cancelText || t('uKeyboard.cancelText'));
104
+ const getConfirmText = computed(() => props.confirmText || t('uKeyboard.confirmText'));
105
+
102
106
  const popupValue = computed({
103
107
  get: () => props.modelValue,
104
108
  set: (val: boolean) => emit('update:modelValue', val)
@@ -1,7 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
- import { getColor, useLocale } from '../../';
3
-
4
- const { t } = useLocale();
2
+ import { getColor } from '../../';
5
3
 
6
4
  /**
7
5
  * u-link 组件 props 类型定义
@@ -31,7 +29,7 @@ export const LinkProps = {
31
29
  /** 小程序中复制到粘贴板的提示语 */
32
30
  mpTips: {
33
31
  type: String,
34
- default: () => t('uLink.mpTips')
32
+ default: ''
35
33
  },
36
34
  /** 下划线颜色 */
37
35
  lineColor: {
@@ -27,8 +27,9 @@ export default {
27
27
  </script>
28
28
 
29
29
  <script setup lang="ts">
30
- import { $u } from '../..';
30
+ import { $u, useLocale } from '../..';
31
31
  import { LinkProps } from './types';
32
+ import { computed } from 'vue';
32
33
 
33
34
  /**
34
35
  * link 超链接
@@ -45,6 +46,11 @@ import { LinkProps } from './types';
45
46
  const props = defineProps(LinkProps);
46
47
  const emit = defineEmits(['click']);
47
48
 
49
+ const { t } = useLocale();
50
+
51
+ // 国际化计算属性
52
+ const getMpTips = computed(() => props.mpTips || t('uLink.mpTips'));
53
+
48
54
  /**
49
55
  * 打开链接方法
50
56
  * 不同平台有不同表现形式
@@ -70,8 +76,8 @@ function openLink() {
70
76
  data: props.href,
71
77
  success: () => {
72
78
  uni.hideToast();
73
- if (typeof $u !== 'undefined' && $u.toast && props.mpTips) {
74
- $u.toast(props.mpTips);
79
+ if (typeof $u !== 'undefined' && $u.toast) {
80
+ $u.toast(getMpTips.value);
75
81
  }
76
82
  }
77
83
  });
@@ -53,11 +53,7 @@ export const LoadmoreProps = {
53
53
  /** 显示的文字 */
54
54
  loadText: {
55
55
  type: Object as PropType<LoadmoreText>,
56
- default: () => ({
57
- loadmore: t('uLoadmore.loadmore'),
58
- loading: t('uLoadmore.loading'),
59
- nomore: t('uLoadmore.nomore')
60
- })
56
+ default: () => ({})
61
57
  },
62
58
  /** 在“没有更多”状态下,是否显示粗点 */
63
59
  isDot: {
@@ -51,7 +51,7 @@ export default {
51
51
 
52
52
  <script setup lang="ts">
53
53
  import { ref, computed } from 'vue';
54
- import { $u } from '../..';
54
+ import { $u, useLocale } from '../..';
55
55
  import { LoadmoreProps } from './types';
56
56
 
57
57
  /**
@@ -73,6 +73,7 @@ import { LoadmoreProps } from './types';
73
73
  */
74
74
  const props = defineProps(LoadmoreProps);
75
75
  const emits = defineEmits(['loadmore']);
76
+ const { t } = useLocale();
76
77
 
77
78
  // 粗点
78
79
  const dotText = ref('●');
@@ -105,10 +106,18 @@ const flowerStyle = computed(() => {
105
106
  // 显示的提示文字
106
107
  const showText = computed(() => {
107
108
  let text = '';
108
- if (props.status === 'loadmore') text = props.loadText.loadmore;
109
- else if (props.status === 'loading') text = props.loadText.loading;
109
+ // 获取国际化默认值
110
+ const defaultLoadText = {
111
+ loadmore: t('uLoadmore.loadmore'),
112
+ loading: t('uLoadmore.loading'),
113
+ nomore: t('uLoadmore.nomore')
114
+ };
115
+ // 合并用户传入的值和默认值
116
+ const loadText = { ...defaultLoadText, ...props.loadText };
117
+ if (props.status === 'loadmore') text = loadText.loadmore;
118
+ else if (props.status === 'loading') text = loadText.loading;
110
119
  else if (props.status === 'nomore' && props.isDot) text = dotText.value;
111
- else text = props.loadText.nomore;
120
+ else text = loadText.nomore;
112
121
  return text;
113
122
  });
114
123
 
@@ -1,7 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
- import { getColor, useLocale } from '../../';
3
-
4
- const { t } = useLocale();
2
+ import { getColor } from '../../';
5
3
 
6
4
  /**
7
5
  * u-modal 组件 props 类型定义
@@ -31,7 +29,7 @@ export const ModalProps = {
31
29
  /** 标题 */
32
30
  title: {
33
31
  type: String,
34
- default: () => t('uModal.title')
32
+ default: ''
35
33
  },
36
34
  /** 弹窗宽度 */
37
35
  width: {
@@ -61,12 +59,12 @@ export const ModalProps = {
61
59
  /** 确认文案 */
62
60
  confirmText: {
63
61
  type: String,
64
- default: () => t('uModal.confirmText')
62
+ default: ''
65
63
  },
66
64
  /** 取消文案 */
67
65
  cancelText: {
68
66
  type: String,
69
- default: () => t('uModal.cancelText')
67
+ default: ''
70
68
  },
71
69
  /** 确认按钮颜色 */
72
70
  confirmColor: {
@@ -81,7 +81,7 @@ export default {
81
81
  <script setup lang="ts">
82
82
  import { ref, computed, watch, useSlots, onMounted, onBeforeUnmount } from 'vue';
83
83
  import { onPageHide, onPageShow } from '@dcloudio/uni-app';
84
- import { $u } from '../..';
84
+ import { $u, useLocale } from '../..';
85
85
  import { ModalProps } from './types';
86
86
  import {
87
87
  U_MODAL_EVENT_CLEAR_LOADING,
@@ -127,6 +127,9 @@ import {
127
127
  const props = defineProps(ModalProps);
128
128
  const emit = defineEmits(['update:modelValue', 'confirm', 'cancel']);
129
129
  const slots = useSlots();
130
+
131
+ const { t } = useLocale();
132
+
130
133
  // 是否已经初始化事件监听
131
134
  const isInit = ref(false);
132
135
  // 确认按钮是否正在加载中
@@ -191,6 +194,11 @@ const tempConfig = ref<Partial<ModalPayload>>({});
191
194
  // 函数式调用时的内部显示状态(用于 global 模式)
192
195
  const internalShow = ref(false);
193
196
 
197
+ // 国际化计算属性
198
+ const getTitle = computed(() => props.title || t('uModal.title'));
199
+ const getConfirmText = computed(() => props.confirmText || t('uModal.confirmText'));
200
+ const getCancelText = computed(() => props.cancelText || t('uModal.cancelText'));
201
+
194
202
  // 有效的配置(函数式调用时合并 tempConfig 和 props,v-model 时使用 props)
195
203
  const effectiveConfig = computed(() => {
196
204
  // 如果有临时配置(函数式调用),合并用户配置与 props 默认值
@@ -201,10 +209,19 @@ const effectiveConfig = computed(() => {
201
209
  result[key] = (tempConfig.value as Record<string, any>)[key] ?? (props as Record<string, any>)[key];
202
210
  }
203
211
  result.zIndex = tempConfig.value.zIndex ?? props.zIndex ?? $u.zIndex.popup;
212
+ // 处理国际化字段
213
+ result.title = result.title || t('uModal.title');
214
+ result.confirmText = result.confirmText || t('uModal.confirmText');
215
+ result.cancelText = result.cancelText || t('uModal.cancelText');
204
216
  return result;
205
217
  }
206
- // v-model 直接控制时使用 props
207
- return props;
218
+ // v-model 直接控制时使用 props,但处理国际化
219
+ return {
220
+ ...props,
221
+ title: getTitle.value,
222
+ confirmText: getConfirmText.value,
223
+ cancelText: getCancelText.value
224
+ };
208
225
  });
209
226
  // 取消按钮样式
210
227
  const cancelBtnStyle = computed(() => {
@@ -1,8 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import zIndex from '../../libs/config/zIndex';
3
- import { useLocale } from '../../';
4
-
5
- const { t } = useLocale();
6
3
 
7
4
  /**
8
5
  * u-no-network 组件 props 类型定义
@@ -12,7 +9,7 @@ export const NoNetworkProps = {
12
9
  /** 页面文字提示 */
13
10
  tips: {
14
11
  type: String,
15
- default: () => t('uNoNetwork.tips')
12
+ default: ''
16
13
  },
17
14
  /** 一个z-index值,用于设置没有网络这个组件的层次 */
18
15
  zIndex: {
@@ -3,7 +3,7 @@
3
3
  <view class="u-inner">
4
4
  <image class="u-error-icon" :src="image" mode="widthFix"></image>
5
5
  <view class="u-tips">
6
- {{ tips }}
6
+ {{ getTips }}
7
7
  </view>
8
8
  <!-- 只有APP平台,才能跳转设置页,因为需要调用plus环境 -->
9
9
  <!-- #ifdef APP-PLUS -->
@@ -55,6 +55,9 @@ const props = defineProps(NoNetworkProps);
55
55
 
56
56
  const { t } = useLocale();
57
57
 
58
+ // 国际化计算属性
59
+ const getTips = computed(() => props.tips || t('uNoNetwork.tips'));
60
+
58
61
  const isConnected = ref(true); // 是否有网络连接
59
62
  const networkType = ref<string>('none'); // 网络类型
60
63
  const isIOS = ref(false); // 是否iOS平台
@@ -1,9 +1,6 @@
1
1
  import type { PaginationChangePayload } from '../../types/global';
2
- import { useLocale } from '../../';
3
2
  import type { PropType } from 'vue';
4
3
 
5
- const { t } = useLocale();
6
-
7
4
  /**
8
5
  * pagination 分页类型定义
9
6
  * @description 供 u-pagination 组件 props 使用
@@ -21,9 +18,9 @@ export const PaginationProps = {
21
18
  default: ''
22
19
  },
23
20
  /** 左侧按钮文字 */
24
- prevText: { type: String, default: () => t('uPagination.prevText') },
21
+ prevText: { type: String, default: '' },
25
22
  /** 右侧按钮文字 */
26
- nextText: { type: String, default: () => t('uPagination.nextText') },
23
+ nextText: { type: String, default: '' },
27
24
  /** 总条目数 */
28
25
  total: Number,
29
26
  /** 每页数据量 */