@hlw-uni/mp-vue 2.1.34 → 2.1.36

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.
@@ -0,0 +1 @@
1
+ export declare function getErrorMessage(error: unknown): string;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * UI 组件(hlw-page / hlw-button / hlw-ad 等)走 easycom 自动注册,不在这里 export。
9
9
  */
10
10
  export * from './composables';
11
+ export { getErrorMessage } from './error';
11
12
  export type { HlwMenuItem } from './components/hlw-menu/types';
12
13
  export type { HlwPagingRef, HlwPagingInstance } from './components/hlw-paging/types';
13
14
  export { useThemeStore } from './stores/theme';
package/dist/index.js CHANGED
@@ -1501,6 +1501,13 @@ var __publicField = (obj, key, value) => {
1501
1501
  });
1502
1502
  return { themePageStyle };
1503
1503
  }
1504
+ function getErrorMessage(error) {
1505
+ if (error instanceof Error && error.message)
1506
+ return error.message;
1507
+ if (typeof error === "string" && error)
1508
+ return error;
1509
+ return "查询失败,请稍后重试";
1510
+ }
1504
1511
  let _msg = null;
1505
1512
  let _device = null;
1506
1513
  let _utils = null;
@@ -1943,6 +1950,7 @@ var __publicField = (obj, key, value) => {
1943
1950
  exports2.getCurrentThemeColor = getCurrentThemeColor;
1944
1951
  exports2.getCurrentThemeVars = getCurrentThemeVars;
1945
1952
  exports2.getCurrentTypographyVars = getCurrentTypographyVars;
1953
+ exports2.getErrorMessage = getErrorMessage;
1946
1954
  exports2.hlw = hlw;
1947
1955
  exports2.http = http;
1948
1956
  exports2.ossAdapter = ossAdapter;
package/dist/index.mjs CHANGED
@@ -1500,6 +1500,13 @@ function useThemePageStyle() {
1500
1500
  });
1501
1501
  return { themePageStyle };
1502
1502
  }
1503
+ function getErrorMessage(error) {
1504
+ if (error instanceof Error && error.message)
1505
+ return error.message;
1506
+ if (typeof error === "string" && error)
1507
+ return error;
1508
+ return "查询失败,请稍后重试";
1509
+ }
1503
1510
  let _msg = null;
1504
1511
  let _device = null;
1505
1512
  let _utils = null;
@@ -1943,6 +1950,7 @@ export {
1943
1950
  getCurrentThemeColor,
1944
1951
  getCurrentThemeVars,
1945
1952
  getCurrentTypographyVars,
1953
+ getErrorMessage,
1946
1954
  hlw,
1947
1955
  http,
1948
1956
  ossAdapter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-vue",
3
- "version": "2.1.34",
3
+ "version": "2.1.36",
4
4
  "description": "hlw-uni 小程序运行时 — Vue 组件 + composables + theme + http + 工具集(合并自原 mp-core)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -113,7 +113,6 @@ defineOptions({
113
113
  align-items: center;
114
114
  justify-content: center;
115
115
  color: var(--text-secondary, #475569);
116
- box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.12);
117
116
  }
118
117
 
119
118
  .hlw-back-top--hover {
@@ -425,18 +425,18 @@ defineOptions({
425
425
  /* 浮动触发按钮 */
426
426
  .trigger {
427
427
  position: fixed;
428
- right: 30rpx;
428
+ right: 32rpx;
429
429
  bottom: 40rpx;
430
430
  z-index: 100;
431
431
  width: 66rpx;
432
432
  height: 66rpx;
433
- background: #1e293b;
434
- color: #ffffff;
433
+ background: rgba(248, 250, 252, 0.96);
434
+ color: #64748b;
435
435
  border-radius: 50%;
436
+ border: 1rpx solid rgba(148, 163, 184, 0.32);
436
437
  display: flex;
437
438
  align-items: center;
438
439
  justify-content: center;
439
- box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.24);
440
440
  }
441
441
 
442
442
  .trigger--hover {
@@ -544,12 +544,11 @@ defineOptions({
544
544
  bottom: 50rpx;
545
545
  padding: 16rpx 26rpx;
546
546
  background: rgba(255, 255, 255, 0.96);
547
- border-radius: 10rpx;
547
+ border-radius: 16rpx;
548
548
  display: flex;
549
549
  flex-direction: column;
550
550
  gap: 12rpx;
551
551
  pointer-events: auto;
552
- box-shadow: 0 8rpx 32rpx rgba(15, 23, 42, 0.18);
553
552
  }
554
553
 
555
554
  /* 模式行 */
@@ -84,7 +84,7 @@ interface Props {
84
84
  borderColor?: string;
85
85
  /** 边框线型:solid(默认)/ dashed / dotted / double */
86
86
  borderStyle?: "solid" | "dashed" | "dotted" | "double";
87
- /** 边框宽度,CSS 长度值,默认 `1rpx` */
87
+ /** 边框宽度,CSS 长度值,默认 `0.5rpx` */
88
88
  borderWidth?: string;
89
89
  /** 圆角大小,对应 CSS 变量体系 */
90
90
  radius?: "none" | "sm" | "md" | "lg" | "xl";
@@ -169,29 +169,29 @@ const showDivider = computed(() => {
169
169
 
170
170
  /* 边框 — width / style / color 全部走 CSS 变量,未设置时回落 */
171
171
  &--bordered {
172
- border-width: var(--card-border-width, 1rpx);
172
+ border-width: var(--card-border-width, 0.5rpx);
173
173
  border-style: var(--card-border-style, solid);
174
174
  border-color: var(--card-border-color, #e2e8f0);
175
175
  }
176
176
 
177
177
  /* 边框 — 单边 */
178
178
  &--border-top {
179
- border-top-width: var(--card-border-width, 1rpx);
179
+ border-top-width: var(--card-border-width, 0.5rpx);
180
180
  border-top-style: var(--card-border-style, solid);
181
181
  border-top-color: var(--card-border-color, #e2e8f0);
182
182
  }
183
183
  &--border-right {
184
- border-right-width: var(--card-border-width, 1rpx);
184
+ border-right-width: var(--card-border-width, 0.5rpx);
185
185
  border-right-style: var(--card-border-style, solid);
186
186
  border-right-color: var(--card-border-color, #e2e8f0);
187
187
  }
188
188
  &--border-bottom {
189
- border-bottom-width: var(--card-border-width, 1rpx);
189
+ border-bottom-width: var(--card-border-width, 0.5rpx);
190
190
  border-bottom-style: var(--card-border-style, solid);
191
191
  border-bottom-color: var(--card-border-color, #e2e8f0);
192
192
  }
193
193
  &--border-left {
194
- border-left-width: var(--card-border-width, 1rpx);
194
+ border-left-width: var(--card-border-width, 0.5rpx);
195
195
  border-left-style: var(--card-border-style, solid);
196
196
  border-left-color: var(--card-border-color, #e2e8f0);
197
197
  }
@@ -1,16 +1,20 @@
1
1
  <template>
2
- <view class="hlw-card-header" :class="{ 'hlw-card-header--divider': divider }">
2
+ <view
3
+ class="hlw-card-header"
4
+ :class="{ 'hlw-card-header--divider': divider }"
5
+ :style="headerStyle"
6
+ >
3
7
  <view class="hlw-card-header__left">
4
8
  <slot name="left">
5
9
  <view v-if="icon" class="hlw-card-header__icon-box" :class="iconBoxClass">
6
10
  <text class="hlw-card-header__icon" :class="icon" />
7
11
  </view>
8
- <text v-if="title" class="hlw-card-header__title">{{ title }}</text>
12
+ <text v-if="title" class="hlw-card-header__title" :style="titleStyle">{{ title }}</text>
9
13
  </slot>
10
14
  </view>
11
15
  <view v-if="hasRight" class="hlw-card-header__right">
12
16
  <slot name="right">
13
- <text v-if="extra" class="hlw-card-header__extra">{{ extra }}</text>
17
+ <text v-if="descText" class="hlw-card-header__desc" :style="descStyle">{{ descText }}</text>
14
18
  </slot>
15
19
  </view>
16
20
  </view>
@@ -27,7 +31,7 @@ import { computed, useSlots } from "vue";
27
31
  * @example A. 直接当 <hlw-card> 的 default slot 子元素(注意把 hlw-card 的 padding 关掉,否则会双重 padding)
28
32
  * ```vue
29
33
  * <hlw-card :padding="false">
30
- * <hlw-card-header title="标题" icon="i-fa6-solid-heart-pulse text-rose-500" extra="副标题" />
34
+ * <hlw-card-header title="标题" icon="i-fa6-solid-heart-pulse text-rose-500" desc="副标题" />
31
35
  * <view style="padding: 24rpx 28rpx">body</view>
32
36
  * </hlw-card>
33
37
  * ```
@@ -36,7 +40,7 @@ import { computed, useSlots } from "vue";
36
40
  * ```vue
37
41
  * <hlw-card>
38
42
  * <template #header>
39
- * <hlw-card-header title="标题" icon="i-fa6-solid-star" extra="副标题" />
43
+ * <hlw-card-header title="标题" icon="i-fa6-solid-star" desc="副标题" />
40
44
  * </template>
41
45
  * body
42
46
  * </hlw-card>
@@ -54,22 +58,62 @@ interface Props {
54
58
  title?: string;
55
59
  /** 图标 class(iconify 或自定义),如 `"i-fa6-solid-heart-pulse text-rose-500"` */
56
60
  icon?: string;
57
- /** 右侧附加文字(无 right slot 时显示) */
61
+ /** 右侧描述文字(无 right slot 时显示) */
62
+ desc?: string;
63
+ /** @deprecated 请使用 desc */
58
64
  extra?: string;
65
+ /** 标题字号,支持 CSS 变量,如 `var(--font-md)` */
66
+ titleSize?: string;
67
+ /** 标题颜色 */
68
+ titleColor?: string;
69
+ /** 标题字重 */
70
+ titleWeight?: string | number;
71
+ /** 描述字号,支持 CSS 变量,如 `var(--font-xs)` */
72
+ descSize?: string;
73
+ /** 描述颜色 */
74
+ descColor?: string;
75
+ /** 描述字重 */
76
+ descWeight?: string | number;
59
77
  /** 是否在头部底部显示虚线分隔线,默认 false。线型由 CSS 变量 `--card-header-divider-style`(默认 dashed)控制 */
60
78
  divider?: boolean;
79
+ /** 头部背景色,如 `#f8fafc` / `rgba(248, 250, 252, 0.3)` */
80
+ bgColor?: string;
61
81
  }
62
82
 
63
83
  const props = withDefaults(defineProps<Props>(), {
64
84
  title: "",
65
85
  icon: "",
86
+ desc: "",
66
87
  extra: "",
88
+ titleSize: "var(--font-30)",
89
+ titleColor: "",
90
+ titleWeight: "",
91
+ descSize: "var(--font-sm)",
92
+ descColor: "",
93
+ descWeight: "",
67
94
  divider: false,
95
+ bgColor: "",
68
96
  });
69
97
 
70
98
  const slots = useSlots();
71
99
 
72
- const hasRight = computed(() => !!(slots.right || props.extra));
100
+ const descText = computed(() => props.desc || props.extra);
101
+
102
+ const hasRight = computed(() => !!(slots.right || descText.value));
103
+
104
+ const headerStyle = computed(() => (props.bgColor ? { backgroundColor: props.bgColor } : {}));
105
+
106
+ const titleStyle = computed(() => ({
107
+ fontSize: props.titleSize,
108
+ ...(props.titleColor ? { color: props.titleColor } : {}),
109
+ ...(props.titleWeight ? { fontWeight: String(props.titleWeight) } : {}),
110
+ }));
111
+
112
+ const descStyle = computed(() => ({
113
+ fontSize: props.descSize,
114
+ ...(props.descColor ? { color: props.descColor } : {}),
115
+ ...(props.descWeight ? { fontWeight: String(props.descWeight) } : {}),
116
+ }));
73
117
 
74
118
  const iconToneClass = computed(() => {
75
119
  const value = props.icon;
@@ -97,7 +141,7 @@ defineOptions({
97
141
  display: flex;
98
142
  align-items: center;
99
143
  justify-content: space-between;
100
- padding: 32rpx 24rpx;
144
+ padding: 26rpx 26rpx;
101
145
  box-sizing: border-box;
102
146
 
103
147
  }
@@ -162,22 +206,22 @@ defineOptions({
162
206
  }
163
207
 
164
208
  .hlw-card-header__icon {
165
- font-size: 20rpx;
209
+ font-size: var(--font-xs);
166
210
  }
167
211
 
168
212
  .hlw-card-header__title {
169
- font-size: 30rpx;
213
+ font-size: var(--font-base);
170
214
  font-weight: 500;
171
215
  color: var(--text-primary, #1e293b);
172
- letter-spacing: 1rpx;
216
+ letter-spacing: 1rpx;
173
217
  }
174
218
 
175
- .hlw-card-header__extra {
176
- padding: 4rpx 16rpx;
219
+ .hlw-card-header__desc {
220
+ padding: 8rpx 16rpx;
177
221
  border-radius: var(--radius-sm, 8rpx);
178
222
  background: rgba(241, 245, 249, 0.8);
179
223
  color: var(--text-muted, #64748b);
180
- font-size: 20rpx;
181
- font-weight: 400;
224
+ font-size: var(--font-sm);
225
+ letter-spacing: 3rpx;
182
226
  }
183
227
  </style>
package/src/error.ts ADDED
@@ -0,0 +1,5 @@
1
+ export function getErrorMessage(error: unknown): string {
2
+ if (error instanceof Error && error.message) return error.message;
3
+ if (typeof error === "string" && error) return error;
4
+ return "查询失败,请稍后重试";
5
+ }
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  // Composables / 工具 / Theme
12
12
  export * from "./composables";
13
+ export { getErrorMessage } from "./error";
13
14
 
14
15
  // 类型
15
16
  export type { HlwMenuItem } from "./components/hlw-menu/types";