@hlw-uni/mp-vue 1.0.8 → 1.0.9

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/dist/index.js CHANGED
@@ -169,10 +169,13 @@
169
169
  }
170
170
  });
171
171
  const index$4 = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-72364322"]]);
172
- const _hoisted_1$3 = { class: "header-title" };
172
+ const _hoisted_1$3 = {
173
+ key: 0,
174
+ class: "header-placeholder"
175
+ };
173
176
  const _hoisted_2$3 = {
174
177
  key: 0,
175
- class: "header-title"
178
+ class: "header-title header-title--center"
176
179
  };
177
180
  const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
178
181
  __name: "index",
@@ -180,7 +183,11 @@
180
183
  extraHeight: { default: 0 },
181
184
  bgClass: { default: "" },
182
185
  isBack: { type: Boolean, default: false },
183
- title: { default: "" }
186
+ title: { default: "" },
187
+ titleAlign: { default: "center" },
188
+ titleSize: { default: "26rpx" },
189
+ titleWeight: { default: 500 },
190
+ titleColor: { default: "" }
184
191
  },
185
192
  emits: ["back"],
186
193
  setup(__props, { emit: __emit }) {
@@ -211,6 +218,11 @@
211
218
  emit("back");
212
219
  uni.navigateBack({ delta: 1 });
213
220
  };
221
+ const titleStyle = vue.computed(() => ({
222
+ fontSize: props.titleSize,
223
+ fontWeight: String(props.titleWeight),
224
+ ...props.titleColor ? { color: props.titleColor } : {}
225
+ }));
214
226
  const slots = vue.useSlots();
215
227
  const hasBgSlot = vue.computed(() => !props.isBack && !!slots.bg);
216
228
  const statusBarHeight = vue.ref(getStatusBarHeight());
@@ -237,22 +249,36 @@
237
249
  vue.createElementVNode("view", {
238
250
  class: "header-back",
239
251
  onClick: handleBack
240
- }, [..._cache[0] || (_cache[0] = [
241
- vue.createElementVNode("text", { class: "iconfont icon-back" }, null, -1)
242
- ])]),
243
- vue.createElementVNode("view", _hoisted_1$3, [
244
- vue.createElementVNode("text", null, vue.toDisplayString(props.title), 1)
252
+ }, [
253
+ vue.renderSlot(_ctx.$slots, "back-icon", {}, () => [
254
+ _cache[0] || (_cache[0] = vue.createElementVNode("text", { class: "i-fa6-solid-chevron-left header-back-icon" }, null, -1))
255
+ ], true)
245
256
  ]),
246
- _cache[1] || (_cache[1] = vue.createElementVNode("view", { class: "header-placeholder" }, null, -1))
257
+ vue.createElementVNode("view", {
258
+ class: vue.normalizeClass(["header-title", props.titleAlign === "left" ? "header-title--left" : "header-title--center"])
259
+ }, [
260
+ vue.renderSlot(_ctx.$slots, "title", {}, () => [
261
+ vue.createElementVNode("text", {
262
+ class: "header-title-text",
263
+ style: vue.normalizeStyle(titleStyle.value)
264
+ }, vue.toDisplayString(props.title), 5)
265
+ ], true)
266
+ ], 2),
267
+ props.titleAlign === "center" ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_1$3)) : vue.createCommentVNode("", true)
247
268
  ], 64)) : vue.renderSlot(_ctx.$slots, "default", { key: 1 }, () => [
248
- props.title ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_2$3, vue.toDisplayString(props.title), 1)) : vue.createCommentVNode("", true)
269
+ props.title ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_2$3, [
270
+ vue.createElementVNode("text", {
271
+ class: "header-title-text",
272
+ style: vue.normalizeStyle(titleStyle.value)
273
+ }, vue.toDisplayString(props.title), 5)
274
+ ])) : vue.createCommentVNode("", true)
249
275
  ], true)
250
276
  ], 4)
251
277
  ], 4);
252
278
  };
253
279
  }
254
280
  });
255
- const index$3 = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-91cf6eee"]]);
281
+ const index$3 = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-312d1ac1"]]);
256
282
  const _hoisted_1$2 = { class: "hlw-loading" };
257
283
  const _hoisted_2$2 = {
258
284
  key: 0,
package/dist/index.mjs CHANGED
@@ -166,10 +166,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
166
166
  }
167
167
  });
168
168
  const index$4 = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-72364322"]]);
169
- const _hoisted_1$3 = { class: "header-title" };
169
+ const _hoisted_1$3 = {
170
+ key: 0,
171
+ class: "header-placeholder"
172
+ };
170
173
  const _hoisted_2$3 = {
171
174
  key: 0,
172
- class: "header-title"
175
+ class: "header-title header-title--center"
173
176
  };
174
177
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
175
178
  __name: "index",
@@ -177,7 +180,11 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
177
180
  extraHeight: { default: 0 },
178
181
  bgClass: { default: "" },
179
182
  isBack: { type: Boolean, default: false },
180
- title: { default: "" }
183
+ title: { default: "" },
184
+ titleAlign: { default: "center" },
185
+ titleSize: { default: "26rpx" },
186
+ titleWeight: { default: 500 },
187
+ titleColor: { default: "" }
181
188
  },
182
189
  emits: ["back"],
183
190
  setup(__props, { emit: __emit }) {
@@ -208,6 +215,11 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
208
215
  emit("back");
209
216
  uni.navigateBack({ delta: 1 });
210
217
  };
218
+ const titleStyle = computed(() => ({
219
+ fontSize: props.titleSize,
220
+ fontWeight: String(props.titleWeight),
221
+ ...props.titleColor ? { color: props.titleColor } : {}
222
+ }));
211
223
  const slots = useSlots();
212
224
  const hasBgSlot = computed(() => !props.isBack && !!slots.bg);
213
225
  const statusBarHeight = ref(getStatusBarHeight());
@@ -234,22 +246,36 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
234
246
  createElementVNode("view", {
235
247
  class: "header-back",
236
248
  onClick: handleBack
237
- }, [..._cache[0] || (_cache[0] = [
238
- createElementVNode("text", { class: "iconfont icon-back" }, null, -1)
239
- ])]),
240
- createElementVNode("view", _hoisted_1$3, [
241
- createElementVNode("text", null, toDisplayString(props.title), 1)
249
+ }, [
250
+ renderSlot(_ctx.$slots, "back-icon", {}, () => [
251
+ _cache[0] || (_cache[0] = createElementVNode("text", { class: "i-fa6-solid-chevron-left header-back-icon" }, null, -1))
252
+ ], true)
242
253
  ]),
243
- _cache[1] || (_cache[1] = createElementVNode("view", { class: "header-placeholder" }, null, -1))
254
+ createElementVNode("view", {
255
+ class: normalizeClass(["header-title", props.titleAlign === "left" ? "header-title--left" : "header-title--center"])
256
+ }, [
257
+ renderSlot(_ctx.$slots, "title", {}, () => [
258
+ createElementVNode("text", {
259
+ class: "header-title-text",
260
+ style: normalizeStyle(titleStyle.value)
261
+ }, toDisplayString(props.title), 5)
262
+ ], true)
263
+ ], 2),
264
+ props.titleAlign === "center" ? (openBlock(), createElementBlock("view", _hoisted_1$3)) : createCommentVNode("", true)
244
265
  ], 64)) : renderSlot(_ctx.$slots, "default", { key: 1 }, () => [
245
- props.title ? (openBlock(), createElementBlock("view", _hoisted_2$3, toDisplayString(props.title), 1)) : createCommentVNode("", true)
266
+ props.title ? (openBlock(), createElementBlock("view", _hoisted_2$3, [
267
+ createElementVNode("text", {
268
+ class: "header-title-text",
269
+ style: normalizeStyle(titleStyle.value)
270
+ }, toDisplayString(props.title), 5)
271
+ ])) : createCommentVNode("", true)
246
272
  ], true)
247
273
  ], 4)
248
274
  ], 4);
249
275
  };
250
276
  }
251
277
  });
252
- const index$3 = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-91cf6eee"]]);
278
+ const index$3 = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-312d1ac1"]]);
253
279
  const _hoisted_1$2 = { class: "hlw-loading" };
254
280
  const _hoisted_2$2 = {
255
281
  key: 0,
package/dist/style.css CHANGED
@@ -57,7 +57,7 @@
57
57
  font-size: 28rpx;
58
58
  color: #bbb;
59
59
  }
60
- .hlw-header[data-v-91cf6eee] {
60
+ .hlw-header[data-v-312d1ac1] {
61
61
  position: sticky;
62
62
  top: 0;
63
63
  z-index: 999;
@@ -65,21 +65,18 @@
65
65
  flex-direction: column;
66
66
  overflow: hidden;
67
67
  }
68
- .header-bg-layer[data-v-91cf6eee] {
68
+ .header-bg-layer[data-v-312d1ac1] {
69
69
  position: absolute;
70
- top: 0;
71
- left: 0;
72
- right: 0;
73
- bottom: 0;
70
+ inset: 0;
74
71
  z-index: 0;
75
72
  }
76
- .status-bar-spacer[data-v-91cf6eee] {
73
+ .status-bar-spacer[data-v-312d1ac1] {
77
74
  flex-shrink: 0;
78
75
  width: 100%;
79
76
  position: relative;
80
77
  z-index: 1;
81
78
  }
82
- .header-content-area[data-v-91cf6eee] {
79
+ .header-content-area[data-v-312d1ac1] {
83
80
  flex-shrink: 0;
84
81
  width: 100%;
85
82
  display: flex;
@@ -87,7 +84,7 @@
87
84
  position: relative;
88
85
  z-index: 1;
89
86
  }
90
- .header-back[data-v-91cf6eee] {
87
+ .header-back[data-v-312d1ac1] {
91
88
  width: 88rpx;
92
89
  height: 100%;
93
90
  display: flex;
@@ -95,22 +92,30 @@
95
92
  justify-content: center;
96
93
  flex-shrink: 0;
97
94
  }
98
- .header-back .iconfont[data-v-91cf6eee] {
99
- font-size: 40rpx;
95
+ .header-back-icon[data-v-312d1ac1] {
96
+ font-size: 36rpx;
100
97
  }
101
- .header-title[data-v-91cf6eee] {
98
+ .header-title[data-v-312d1ac1] {
102
99
  flex: 1;
103
100
  overflow: hidden;
101
+ }
102
+ .header-title--center[data-v-312d1ac1] {
103
+ text-align: center;
104
+ }
105
+ .header-title--left[data-v-312d1ac1] {
106
+ text-align: left;
107
+ padding-left: 4rpx;
108
+ }
109
+ .header-title-text[data-v-312d1ac1] {
110
+ display: block;
111
+ overflow: hidden;
104
112
  text-overflow: ellipsis;
105
113
  white-space: nowrap;
106
114
  letter-spacing: 1rpx;
107
- text-align: center;
108
- }
109
- .header-title text[data-v-91cf6eee] {
110
115
  font-size: 26rpx;
111
116
  font-weight: 500;
112
117
  }
113
- .header-placeholder[data-v-91cf6eee] {
118
+ .header-placeholder[data-v-312d1ac1] {
114
119
  width: 88rpx;
115
120
  flex-shrink: 0;
116
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-vue",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "hlw-uni Vue 组件库 — 供小程序业务方使用的 UI 组件集合",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -6,16 +6,31 @@
6
6
  <view class="status-bar-spacer" :style="{ height: statusBarHeight + 'px' }"></view>
7
7
  <view class="header-content-area" :style="{ height: NAV_BAR_CONTENT_HEIGHT + 'px' }">
8
8
  <template v-if="props.isBack">
9
+ <!-- 返回按钮 -->
9
10
  <view class="header-back" @click="handleBack">
10
- <text class="iconfont icon-back"></text>
11
+ <slot name="back-icon">
12
+ <text class="i-fa6-solid-chevron-left header-back-icon"></text>
13
+ </slot>
11
14
  </view>
12
- <view class="header-title">
13
- <text>{{ props.title }}</text>
15
+
16
+ <!-- 标题 -->
17
+ <view
18
+ class="header-title"
19
+ :class="props.titleAlign === 'left' ? 'header-title--left' : 'header-title--center'"
20
+ >
21
+ <slot name="title">
22
+ <text class="header-title-text" :style="titleStyle">{{ props.title }}</text>
23
+ </slot>
14
24
  </view>
15
- <view class="header-placeholder"></view>
25
+
26
+ <!-- 右侧占位(居中时保持对称) -->
27
+ <view v-if="props.titleAlign === 'center'" class="header-placeholder"></view>
16
28
  </template>
29
+
17
30
  <slot v-else>
18
- <view v-if="props.title" class="header-title">{{ props.title }}</view>
31
+ <view v-if="props.title" class="header-title header-title--center">
32
+ <text class="header-title-text" :style="titleStyle">{{ props.title }}</text>
33
+ </view>
19
34
  </slot>
20
35
  </view>
21
36
  </view>
@@ -51,6 +66,14 @@ interface Props {
51
66
  bgClass?: string;
52
67
  isBack?: boolean;
53
68
  title?: string;
69
+ /** 标题对齐方式,默认 center */
70
+ titleAlign?: "center" | "left";
71
+ /** 标题字号,默认 26rpx */
72
+ titleSize?: string;
73
+ /** 标题字重,默认 500 */
74
+ titleWeight?: string | number;
75
+ /** 标题颜色 */
76
+ titleColor?: string;
54
77
  }
55
78
 
56
79
  const props = withDefaults(defineProps<Props>(), {
@@ -58,6 +81,10 @@ const props = withDefaults(defineProps<Props>(), {
58
81
  bgClass: "",
59
82
  isBack: false,
60
83
  title: "",
84
+ titleAlign: "center",
85
+ titleSize: "26rpx",
86
+ titleWeight: 500,
87
+ titleColor: "",
61
88
  });
62
89
 
63
90
  const emit = defineEmits<{
@@ -69,6 +96,12 @@ const handleBack = () => {
69
96
  uni.navigateBack({ delta: 1 });
70
97
  };
71
98
 
99
+ const titleStyle = computed(() => ({
100
+ fontSize: props.titleSize,
101
+ fontWeight: String(props.titleWeight),
102
+ ...(props.titleColor ? { color: props.titleColor } : {}),
103
+ }));
104
+
72
105
  const slots = useSlots();
73
106
  const hasBgSlot = computed(() => !props.isBack && !!slots.bg);
74
107
  const statusBarHeight = ref(getStatusBarHeight());
@@ -87,10 +120,7 @@ const totalNavBarHeight = computed(() => statusBarHeight.value + NAV_BAR_CONTENT
87
120
 
88
121
  .header-bg-layer {
89
122
  position: absolute;
90
- top: 0;
91
- left: 0;
92
- right: 0;
93
- bottom: 0;
123
+ inset: 0;
94
124
  z-index: 0;
95
125
  }
96
126
 
@@ -117,24 +147,34 @@ const totalNavBarHeight = computed(() => statusBarHeight.value + NAV_BAR_CONTENT
117
147
  align-items: center;
118
148
  justify-content: center;
119
149
  flex-shrink: 0;
150
+ }
120
151
 
121
- .iconfont {
122
- font-size: 40rpx;
123
- }
152
+ .header-back-icon {
153
+ font-size: 36rpx;
124
154
  }
125
155
 
126
156
  .header-title {
127
157
  flex: 1;
128
158
  overflow: hidden;
159
+
160
+ &--center {
161
+ text-align: center;
162
+ }
163
+
164
+ &--left {
165
+ text-align: left;
166
+ padding-left: 4rpx;
167
+ }
168
+ }
169
+
170
+ .header-title-text {
171
+ display: block;
172
+ overflow: hidden;
129
173
  text-overflow: ellipsis;
130
174
  white-space: nowrap;
131
175
  letter-spacing: 1rpx;
132
- text-align: center;
133
-
134
- text {
135
- font-size: 26rpx;
136
- font-weight: 500;
137
- }
176
+ font-size: 26rpx;
177
+ font-weight: 500;
138
178
  }
139
179
 
140
180
  .header-placeholder {