@hlw-uni/mp-vue 2.1.98 → 2.2.1

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
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("@dcloudio/uni-app"), require("pinia")) : typeof define === "function" && define.amd ? define(["exports", "vue", "@dcloudio/uni-app", "pinia"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.HlwUniVue = {}, global.vue, global.uniApp, global.pinia));
3
- })(this, function(exports2, vue, uniApp, pinia) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("pinia"), require("@dcloudio/uni-app")) : typeof define === "function" && define.amd ? define(["exports", "vue", "pinia", "@dcloudio/uni-app"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.HlwUniVue = {}, global.vue, global.pinia, global.uniApp));
3
+ })(this, function(exports2, vue, pinia, uniApp) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => {
@@ -98,31 +98,6 @@ var __publicField = (obj, key, value) => {
98
98
  function useTheme() {
99
99
  const store = useThemeStore();
100
100
  const theme = vue.computed(() => store.theme);
101
- const updateNavbarColor = (targetTheme) => {
102
- const isDarkTheme = ["mono-theme", "color-theme"].includes(targetTheme);
103
- uni.setNavigationBarColor({
104
- frontColor: isDarkTheme ? "#ffffff" : "#000000",
105
- backgroundColor: isDarkTheme ? "#3b82f6" : "#ffffff",
106
- fail: () => {
107
- }
108
- });
109
- };
110
- vue.watch(
111
- theme,
112
- (newTheme) => {
113
- updateNavbarColor(newTheme);
114
- }
115
- );
116
- vue.onMounted(() => {
117
- updateNavbarColor(store.theme);
118
- });
119
- try {
120
- uniApp.onShow(() => {
121
- updateNavbarColor(store.theme);
122
- });
123
- } catch (e) {
124
- }
125
- updateNavbarColor(store.theme);
126
101
  const fontSize = vue.computed(() => store.fontSize);
127
102
  const fontSizeClass = vue.computed(() => {
128
103
  const found = fontSizePresets.find((p) => p.id === store.fontSize);
package/dist/index.mjs CHANGED
@@ -4,9 +4,9 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { computed, watch, onMounted, ref, onBeforeUpdate, onUnmounted, createSSRApp } from "vue";
8
- import { onShow, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
7
+ import { computed, ref, onBeforeUpdate, onUnmounted, createSSRApp } from "vue";
9
8
  import { defineStore } from "pinia";
9
+ import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
10
10
  const themePresets = [
11
11
  {
12
12
  id: "white-theme",
@@ -97,31 +97,6 @@ const useThemeStore = defineStore("theme", {
97
97
  function useTheme() {
98
98
  const store = useThemeStore();
99
99
  const theme = computed(() => store.theme);
100
- const updateNavbarColor = (targetTheme) => {
101
- const isDarkTheme = ["mono-theme", "color-theme"].includes(targetTheme);
102
- uni.setNavigationBarColor({
103
- frontColor: isDarkTheme ? "#ffffff" : "#000000",
104
- backgroundColor: isDarkTheme ? "#3b82f6" : "#ffffff",
105
- fail: () => {
106
- }
107
- });
108
- };
109
- watch(
110
- theme,
111
- (newTheme) => {
112
- updateNavbarColor(newTheme);
113
- }
114
- );
115
- onMounted(() => {
116
- updateNavbarColor(store.theme);
117
- });
118
- try {
119
- onShow(() => {
120
- updateNavbarColor(store.theme);
121
- });
122
- } catch (e) {
123
- }
124
- updateNavbarColor(store.theme);
125
100
  const fontSize = computed(() => store.fontSize);
126
101
  const fontSizeClass = computed(() => {
127
102
  const found = fontSizePresets.find((p) => p.id === store.fontSize);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-vue",
3
- "version": "2.1.98",
3
+ "version": "2.2.01",
4
4
  "description": "hlw-uni 小程序运行时 — Vue 组件 + composables + theme + http + 工具集(合并自原 mp-core)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -86,8 +86,8 @@ const top = computed(() => {
86
86
  try {
87
87
  const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
88
88
  if (menuButtonInfo && menuButtonInfo.bottom > 0) {
89
- // 胶囊底部高度 + 16px 作为气泡定位的顶部基准,保证指向绝对精确且避开胶囊
90
- return `${menuButtonInfo.bottom + 16}px`;
89
+ // 胶囊底部高度 + 6px 作为气泡定位的顶部基准,使箭头离胶囊更近
90
+ return `${menuButtonInfo.bottom + 6}px`;
91
91
  }
92
92
  } catch (e) {
93
93
  // 跨端环境不支持或报错时,执行安全降级计算
@@ -23,7 +23,7 @@
23
23
  * @props
24
24
  * title - 导航栏标题文字
25
25
  * isBack - 是否显示返回按钮,默认 false;点击自动回退或回到首页
26
- * isBar - 是否占用状态栏高度,默认 false
26
+ * isBar - 是否占用状态栏高度,默认 true
27
27
  *
28
28
  * @example
29
29
  * ```vue
@@ -41,7 +41,7 @@ const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
41
41
  const props = defineProps({
42
42
  isBar: {
43
43
  type: Boolean,
44
- default: false,
44
+ default: true,
45
45
  },
46
46
  title: {
47
47
  type: String,
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <view :class="[theme, fontSizeClass, fontFamilyClass]">
3
- <hlw-nav-bar v-if="props.isBar" :is-back="props.isBack" :title="title" :is-bar="props.isBar"></hlw-nav-bar>
3
+ <hlw-nav-bar v-if="props.isNav" :is-back="props.isBack" :title="title" :is-bar="props.isBar"></hlw-nav-bar>
4
4
  <slot></slot>
5
- <view class="h-[50rpx]"></view>
5
+ <view class="h-[60rpx]"></view>
6
6
  </view>
7
7
  </template>
8
8
 
@@ -14,13 +14,14 @@
14
14
  * 可以快捷集成自定义导航栏(HlwNavBar),保持整个页面结构的一致性。
15
15
  *
16
16
  * @props
17
- * isBar - 是否显示并使用自定义导航栏,默认 false
18
- * title - 自定义导航栏标题文字(在 isBar 为 true 时生效)
19
- * isBack - 是否显示自定义导航栏的返回键(在 isBar 为 true 时生效),默认 false
17
+ * isNav - 是否显示自定义导航栏,默认 false
18
+ * isBar - 是否占用状态栏高度,默认 true
19
+ * title - 自定义导航栏标题文字
20
+ * isBack - 是否显示自定义导航栏的返回键,默认 false
20
21
  *
21
22
  * @example
22
23
  * ```vue
23
- * <hlw-page is-bar is-back title="个人中心">
24
+ * <hlw-page is-nav is-back title="个人中心">
24
25
  * <view>页面内容...</view>
25
26
  * </hlw-page>
26
27
  * ```
@@ -31,10 +32,14 @@ import { ref } from "vue";
31
32
  const { theme, fontSizeClass, fontFamilyClass } = useTheme();
32
33
 
33
34
  const props = defineProps({
34
- isBar: {
35
+ isNav: {
35
36
  type: Boolean,
36
37
  default: false,
37
38
  },
39
+ isBar: {
40
+ type: Boolean,
41
+ default: true,
42
+ },
38
43
  title: {
39
44
  type: String,
40
45
  default: "",
@@ -1,6 +1,5 @@
1
- import { computed, watch, onMounted } from "vue";
1
+ import { computed } from "vue";
2
2
  import type { ComputedRef } from "vue";
3
- import { onShow } from "@dcloudio/uni-app";
4
3
  import {
5
4
  useThemeStore,
6
5
  themePresets,
@@ -28,41 +27,6 @@ export function useTheme() {
28
27
 
29
28
  // 主题
30
29
  const theme: ComputedRef<string> = computed(() => store.theme);
31
-
32
- // 辅助方法:设置系统状态栏/导航栏前景色(mono-theme 和 color-theme 设为白色,其余为黑色)
33
- const updateNavbarColor = (targetTheme: string) => {
34
- const isDarkTheme = ["mono-theme", "color-theme"].includes(targetTheme);
35
- uni.setNavigationBarColor({
36
- frontColor: isDarkTheme ? "#ffffff" : "#000000",
37
- backgroundColor: isDarkTheme ? "#3b82f6" : "#ffffff",
38
- fail: () => {}
39
- });
40
- };
41
-
42
- // 1. 监控主题属性改变时,动态刷新
43
- watch(
44
- theme,
45
- (newTheme) => {
46
- updateNavbarColor(newTheme);
47
- }
48
- );
49
-
50
- // 2. 组件/页面挂载完成时,执行一次设定
51
- onMounted(() => {
52
- updateNavbarColor(store.theme);
53
- });
54
-
55
- // 3. 页面显示或回退时,强行重刷前景色(try-catch 规避非 Page 的报错)
56
- try {
57
- onShow(() => {
58
- updateNavbarColor(store.theme);
59
- });
60
- } catch (e) {
61
- // 忽略非 Page 组件的绑定失败
62
- }
63
-
64
- // 4. 在 setup 初始化同步阶段以最快速度设定一次,尽可能规避生命周期滞后导致的闪烁
65
- updateNavbarColor(store.theme);
66
30
 
67
31
  // 字体大小
68
32
  const fontSize: ComputedRef<string> = computed(() => store.fontSize);