@hlw-uni/mp-vue 2.1.60 → 2.1.70
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/core/theme.d.ts +15 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +123 -2
- package/dist/index.mjs +123 -1
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/theme.d.ts +27 -0
- package/package.json +1 -1
- package/src/components/hlw-add-mini/index.vue +147 -77
- package/src/components/hlw-avatar/index.vue +28 -20
- package/src/components/hlw-card-header/index.vue +3 -0
- package/src/components/hlw-cell/index.vue +6 -0
- package/src/components/hlw-custom/hlw-custom.vue +6 -5
- package/src/components/hlw-menu/index.vue +9 -3
- package/src/components/hlw-nav-bar/index.vue +75 -15
- package/src/components/hlw-page/index.vue +94 -4
- package/src/core/theme.ts +54 -4
- package/src/index.ts +10 -3
- package/src/stores/index.ts +1 -0
- package/src/stores/theme.ts +126 -0
package/dist/core/theme.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { ComputedRef } from 'vue';
|
|
2
|
+
import { Store } from 'pinia';
|
|
2
3
|
|
|
4
|
+
export { themePresets, type ThemePreset, fontSizePresets, type FontSizePreset, fontFamilyPresets, type FontFamilyPreset } from '../stores/theme';
|
|
3
5
|
export declare function useTheme(): {
|
|
4
6
|
theme: ComputedRef<string>;
|
|
5
|
-
|
|
7
|
+
fontSize: ComputedRef<string>;
|
|
8
|
+
fontSizeClass: ComputedRef<string>;
|
|
9
|
+
setFontSize: (size: string) => void;
|
|
10
|
+
fontFamily: ComputedRef<string>;
|
|
11
|
+
fontFamilyClass: ComputedRef<string>;
|
|
12
|
+
setFontFamily: (font: string) => void;
|
|
13
|
+
store: Store<"theme", {
|
|
6
14
|
theme: string;
|
|
7
|
-
|
|
15
|
+
fontSize: string;
|
|
16
|
+
fontFamily: string;
|
|
17
|
+
}, {}, {
|
|
18
|
+
setFontSize(size: string): void;
|
|
19
|
+
setFontFamily(font: string): void;
|
|
20
|
+
}>;
|
|
8
21
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 2.0 起合并了原 @hlw-uni/mp-core 全部内容。
|
|
5
5
|
* 业务方一处 import,无需再分包:
|
|
6
|
-
* import { useMsg,
|
|
6
|
+
* import { useMsg, useTheme, ... } from "@hlw-uni/mp-vue";
|
|
7
7
|
*
|
|
8
8
|
* UI 组件(hlw-page / hlw-button / hlw-ad 等)走 easycom 自动注册,不在这里 export。
|
|
9
9
|
*/
|
|
10
10
|
export * from './composables';
|
|
11
|
+
export { useTheme, themePresets, type ThemePreset, fontFamilyPresets, type FontFamilyPreset, fontSizePresets, type FontSizePreset } from './core/theme';
|
|
11
12
|
export type { HlwMenuItem } from './components/hlw-menu/types';
|
|
12
13
|
export type { HlwPagingRef, HlwPagingInstance } from './components/hlw-paging/types';
|
|
13
14
|
export { useApp } from './app';
|
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")) : typeof define === "function" && define.amd ? define(["exports", "vue", "@dcloudio/uni-app"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.HlwUniVue = {}, global.vue, global.uniApp));
|
|
3
|
-
})(this, function(exports2, vue, uniApp) {
|
|
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) {
|
|
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) => {
|
|
@@ -969,6 +969,123 @@ var __publicField = (obj, key, value) => {
|
|
|
969
969
|
miniProgram: (appId, options) => navigate("miniprogram", appId, options)
|
|
970
970
|
};
|
|
971
971
|
}
|
|
972
|
+
const themePresets = [
|
|
973
|
+
{
|
|
974
|
+
id: "white-theme",
|
|
975
|
+
name: "白色主题",
|
|
976
|
+
color: "#ffffff"
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
id: "light-theme",
|
|
980
|
+
name: "简洁主题",
|
|
981
|
+
color: "var(--bg-page, #f8f8f8)"
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
id: "mono-theme",
|
|
985
|
+
name: "单色主题",
|
|
986
|
+
color: "var(--primary-color, #3b82f6)"
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
id: "color-theme",
|
|
990
|
+
name: "颜色主题",
|
|
991
|
+
color: "var(--primary-color, #3b82f6)"
|
|
992
|
+
}
|
|
993
|
+
];
|
|
994
|
+
const fontSizePresets = [
|
|
995
|
+
{
|
|
996
|
+
id: "small",
|
|
997
|
+
name: "较小",
|
|
998
|
+
class: "font-size-small"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
id: "standard",
|
|
1002
|
+
name: "标准",
|
|
1003
|
+
class: "font-size-standard"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
id: "large",
|
|
1007
|
+
name: "较大",
|
|
1008
|
+
class: "font-size-large"
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
id: "extra-large",
|
|
1012
|
+
name: "超大",
|
|
1013
|
+
class: "font-size-extra-large"
|
|
1014
|
+
}
|
|
1015
|
+
];
|
|
1016
|
+
const fontFamilyPresets = [
|
|
1017
|
+
{
|
|
1018
|
+
id: "system",
|
|
1019
|
+
name: "系统默认",
|
|
1020
|
+
class: "font-family-system"
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
id: "sans",
|
|
1024
|
+
name: "现代黑体",
|
|
1025
|
+
class: "font-family-sans"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
id: "serif",
|
|
1029
|
+
name: "经典宋体",
|
|
1030
|
+
class: "font-family-serif"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
id: "kaiti",
|
|
1034
|
+
name: "优雅楷体",
|
|
1035
|
+
class: "font-family-kaiti"
|
|
1036
|
+
}
|
|
1037
|
+
];
|
|
1038
|
+
const useThemeStore = pinia.defineStore("theme", {
|
|
1039
|
+
state: () => ({
|
|
1040
|
+
theme: "white-theme",
|
|
1041
|
+
fontSize: "standard",
|
|
1042
|
+
fontFamily: "system"
|
|
1043
|
+
}),
|
|
1044
|
+
getters: {},
|
|
1045
|
+
actions: {
|
|
1046
|
+
setFontSize(size) {
|
|
1047
|
+
if (["small", "standard", "large", "extra-large"].includes(size)) {
|
|
1048
|
+
this.fontSize = size;
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1051
|
+
setFontFamily(font) {
|
|
1052
|
+
if (["system", "sans", "serif", "kaiti"].includes(font)) {
|
|
1053
|
+
this.fontFamily = font;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
},
|
|
1057
|
+
unistorage: true
|
|
1058
|
+
});
|
|
1059
|
+
function useTheme() {
|
|
1060
|
+
const store = useThemeStore();
|
|
1061
|
+
const theme = vue.computed(() => store.theme);
|
|
1062
|
+
const fontSize = vue.computed(() => store.fontSize);
|
|
1063
|
+
const fontSizeClass = vue.computed(() => {
|
|
1064
|
+
const found = fontSizePresets.find((p) => p.id === store.fontSize);
|
|
1065
|
+
return found ? found.class : "font-size-standard";
|
|
1066
|
+
});
|
|
1067
|
+
const fontFamily = vue.computed(() => store.fontFamily);
|
|
1068
|
+
const fontFamilyClass = vue.computed(() => {
|
|
1069
|
+
const found = fontFamilyPresets.find((p) => p.id === store.fontFamily);
|
|
1070
|
+
return found ? found.class : "font-family-system";
|
|
1071
|
+
});
|
|
1072
|
+
function setFontSize(size) {
|
|
1073
|
+
store.setFontSize(size);
|
|
1074
|
+
}
|
|
1075
|
+
function setFontFamily(font) {
|
|
1076
|
+
store.setFontFamily(font);
|
|
1077
|
+
}
|
|
1078
|
+
return {
|
|
1079
|
+
theme,
|
|
1080
|
+
fontSize,
|
|
1081
|
+
fontSizeClass,
|
|
1082
|
+
setFontSize,
|
|
1083
|
+
fontFamily,
|
|
1084
|
+
fontFamilyClass,
|
|
1085
|
+
setFontFamily,
|
|
1086
|
+
store
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
972
1089
|
let _msg = null;
|
|
973
1090
|
let _utils = null;
|
|
974
1091
|
const hlw = {
|
|
@@ -1054,6 +1171,8 @@ var __publicField = (obj, key, value) => {
|
|
|
1054
1171
|
exports2.copy = copy;
|
|
1055
1172
|
exports2.cosAdapter = cosAdapter;
|
|
1056
1173
|
exports2.download = download;
|
|
1174
|
+
exports2.fontFamilyPresets = fontFamilyPresets;
|
|
1175
|
+
exports2.fontSizePresets = fontSizePresets;
|
|
1057
1176
|
exports2.getAdapter = getAdapter;
|
|
1058
1177
|
exports2.hlw = hlw;
|
|
1059
1178
|
exports2.ossAdapter = ossAdapter;
|
|
@@ -1064,6 +1183,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1064
1183
|
exports2.saveVideoFile = saveVideoFile;
|
|
1065
1184
|
exports2.saveVideoUrl = saveVideoUrl;
|
|
1066
1185
|
exports2.signText = signText;
|
|
1186
|
+
exports2.themePresets = themePresets;
|
|
1067
1187
|
exports2.toBoolean = toBoolean;
|
|
1068
1188
|
exports2.toNumber = toNumber;
|
|
1069
1189
|
exports2.toQuery = toQuery;
|
|
@@ -1075,6 +1195,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1075
1195
|
exports2.useRefs = useRefs;
|
|
1076
1196
|
exports2.useRequest = useRequest;
|
|
1077
1197
|
exports2.useShare = useShare;
|
|
1198
|
+
exports2.useTheme = useTheme;
|
|
1078
1199
|
exports2.useUpload = useUpload;
|
|
1079
1200
|
exports2.useUtils = useUtils;
|
|
1080
1201
|
exports2.vCopy = vCopy;
|
package/dist/index.mjs
CHANGED
|
@@ -4,8 +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 { ref, onBeforeUpdate, onUnmounted, createSSRApp } from "vue";
|
|
7
|
+
import { ref, onBeforeUpdate, onUnmounted, computed, createSSRApp } from "vue";
|
|
8
8
|
import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
|
|
9
|
+
import { defineStore } from "pinia";
|
|
9
10
|
const cosAdapter = {
|
|
10
11
|
name: "cos",
|
|
11
12
|
/**
|
|
@@ -967,6 +968,123 @@ function useNavigate() {
|
|
|
967
968
|
miniProgram: (appId, options) => navigate("miniprogram", appId, options)
|
|
968
969
|
};
|
|
969
970
|
}
|
|
971
|
+
const themePresets = [
|
|
972
|
+
{
|
|
973
|
+
id: "white-theme",
|
|
974
|
+
name: "白色主题",
|
|
975
|
+
color: "#ffffff"
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
id: "light-theme",
|
|
979
|
+
name: "简洁主题",
|
|
980
|
+
color: "var(--bg-page, #f8f8f8)"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
id: "mono-theme",
|
|
984
|
+
name: "单色主题",
|
|
985
|
+
color: "var(--primary-color, #3b82f6)"
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
id: "color-theme",
|
|
989
|
+
name: "颜色主题",
|
|
990
|
+
color: "var(--primary-color, #3b82f6)"
|
|
991
|
+
}
|
|
992
|
+
];
|
|
993
|
+
const fontSizePresets = [
|
|
994
|
+
{
|
|
995
|
+
id: "small",
|
|
996
|
+
name: "较小",
|
|
997
|
+
class: "font-size-small"
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
id: "standard",
|
|
1001
|
+
name: "标准",
|
|
1002
|
+
class: "font-size-standard"
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
id: "large",
|
|
1006
|
+
name: "较大",
|
|
1007
|
+
class: "font-size-large"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
id: "extra-large",
|
|
1011
|
+
name: "超大",
|
|
1012
|
+
class: "font-size-extra-large"
|
|
1013
|
+
}
|
|
1014
|
+
];
|
|
1015
|
+
const fontFamilyPresets = [
|
|
1016
|
+
{
|
|
1017
|
+
id: "system",
|
|
1018
|
+
name: "系统默认",
|
|
1019
|
+
class: "font-family-system"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
id: "sans",
|
|
1023
|
+
name: "现代黑体",
|
|
1024
|
+
class: "font-family-sans"
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
id: "serif",
|
|
1028
|
+
name: "经典宋体",
|
|
1029
|
+
class: "font-family-serif"
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
id: "kaiti",
|
|
1033
|
+
name: "优雅楷体",
|
|
1034
|
+
class: "font-family-kaiti"
|
|
1035
|
+
}
|
|
1036
|
+
];
|
|
1037
|
+
const useThemeStore = defineStore("theme", {
|
|
1038
|
+
state: () => ({
|
|
1039
|
+
theme: "white-theme",
|
|
1040
|
+
fontSize: "standard",
|
|
1041
|
+
fontFamily: "system"
|
|
1042
|
+
}),
|
|
1043
|
+
getters: {},
|
|
1044
|
+
actions: {
|
|
1045
|
+
setFontSize(size) {
|
|
1046
|
+
if (["small", "standard", "large", "extra-large"].includes(size)) {
|
|
1047
|
+
this.fontSize = size;
|
|
1048
|
+
}
|
|
1049
|
+
},
|
|
1050
|
+
setFontFamily(font) {
|
|
1051
|
+
if (["system", "sans", "serif", "kaiti"].includes(font)) {
|
|
1052
|
+
this.fontFamily = font;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
unistorage: true
|
|
1057
|
+
});
|
|
1058
|
+
function useTheme() {
|
|
1059
|
+
const store = useThemeStore();
|
|
1060
|
+
const theme = computed(() => store.theme);
|
|
1061
|
+
const fontSize = computed(() => store.fontSize);
|
|
1062
|
+
const fontSizeClass = computed(() => {
|
|
1063
|
+
const found = fontSizePresets.find((p) => p.id === store.fontSize);
|
|
1064
|
+
return found ? found.class : "font-size-standard";
|
|
1065
|
+
});
|
|
1066
|
+
const fontFamily = computed(() => store.fontFamily);
|
|
1067
|
+
const fontFamilyClass = computed(() => {
|
|
1068
|
+
const found = fontFamilyPresets.find((p) => p.id === store.fontFamily);
|
|
1069
|
+
return found ? found.class : "font-family-system";
|
|
1070
|
+
});
|
|
1071
|
+
function setFontSize(size) {
|
|
1072
|
+
store.setFontSize(size);
|
|
1073
|
+
}
|
|
1074
|
+
function setFontFamily(font) {
|
|
1075
|
+
store.setFontFamily(font);
|
|
1076
|
+
}
|
|
1077
|
+
return {
|
|
1078
|
+
theme,
|
|
1079
|
+
fontSize,
|
|
1080
|
+
fontSizeClass,
|
|
1081
|
+
setFontSize,
|
|
1082
|
+
fontFamily,
|
|
1083
|
+
fontFamilyClass,
|
|
1084
|
+
setFontFamily,
|
|
1085
|
+
store
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
970
1088
|
let _msg = null;
|
|
971
1089
|
let _utils = null;
|
|
972
1090
|
const hlw = {
|
|
@@ -1053,6 +1171,8 @@ export {
|
|
|
1053
1171
|
copy,
|
|
1054
1172
|
cosAdapter,
|
|
1055
1173
|
download,
|
|
1174
|
+
fontFamilyPresets,
|
|
1175
|
+
fontSizePresets,
|
|
1056
1176
|
getAdapter,
|
|
1057
1177
|
hlw,
|
|
1058
1178
|
ossAdapter,
|
|
@@ -1063,6 +1183,7 @@ export {
|
|
|
1063
1183
|
saveVideoFile,
|
|
1064
1184
|
saveVideoUrl,
|
|
1065
1185
|
signText,
|
|
1186
|
+
themePresets,
|
|
1066
1187
|
toBoolean,
|
|
1067
1188
|
toNumber,
|
|
1068
1189
|
toQuery,
|
|
@@ -1074,6 +1195,7 @@ export {
|
|
|
1074
1195
|
useRefs,
|
|
1075
1196
|
useRequest,
|
|
1076
1197
|
useShare,
|
|
1198
|
+
useTheme,
|
|
1077
1199
|
useUpload,
|
|
1078
1200
|
useUtils,
|
|
1079
1201
|
vCopy,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './theme';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StoreDefinition } from 'pinia';
|
|
2
|
+
export interface ThemePreset {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
color: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const themePresets: ThemePreset[];
|
|
8
|
+
export interface FontSizePreset {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
class: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const fontSizePresets: FontSizePreset[];
|
|
14
|
+
export interface FontFamilyPreset {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
class: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const fontFamilyPresets: FontFamilyPreset[];
|
|
20
|
+
export declare const useThemeStore: StoreDefinition<"theme", {
|
|
21
|
+
theme: string;
|
|
22
|
+
fontSize: string;
|
|
23
|
+
fontFamily: string;
|
|
24
|
+
}, {}, {
|
|
25
|
+
setFontSize(size: string): void;
|
|
26
|
+
setFontFamily(font: string): void;
|
|
27
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,137 +1,207 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
<view v-if="props.show" class="hlw-add-mini" :style="{ top }">
|
|
3
|
+
<view class="hlw-add-mini__arrow" :style="arrowStyle" />
|
|
4
|
+
<view class="hlw-add-mini__content">
|
|
5
|
+
<view class="hlw-add-mini__text">
|
|
6
|
+
<view class="hlw-add-mini__title">{{ props.title }}</view>
|
|
7
|
+
<view v-if="props.desc" class="hlw-add-mini__desc">{{ props.desc }}</view>
|
|
8
|
+
</view>
|
|
9
|
+
<view class="hlw-add-mini__close" @tap="close">×</view>
|
|
10
|
+
</view>
|
|
11
|
+
</view>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script setup lang="ts">
|
|
15
15
|
/**
|
|
16
16
|
* HlwAddMini - 添加小程序提示气泡组件
|
|
17
|
-
*
|
|
17
|
+
*
|
|
18
18
|
* 用于提示用户点击右上角将当前小程序“添加到我的小程序”中,以提升用户留存。
|
|
19
19
|
* 会根据是否为自定义导航栏(custom),自动调整气泡浮动位置(避开胶囊按钮与状态栏)。
|
|
20
20
|
*/
|
|
21
|
-
import { computed } from "vue";
|
|
21
|
+
import { computed, ref, onMounted } from "vue";
|
|
22
22
|
import { useDevice } from "../../composables/device";
|
|
23
23
|
|
|
24
24
|
defineOptions({ name: "HlwAddMini" });
|
|
25
25
|
|
|
26
26
|
interface Props {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/** 气泡副标题/描述文字 */
|
|
34
|
-
desc?: string;
|
|
27
|
+
/** 是否显示提示气泡 */
|
|
28
|
+
show?: boolean;
|
|
29
|
+
/** 气泡主标题文字 */
|
|
30
|
+
title?: string;
|
|
31
|
+
/** 气泡副标题/描述文字 */
|
|
32
|
+
desc?: string;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
const props = withDefaults(defineProps<Props>(), {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
desc: "点击右上角 ··· 添加",
|
|
36
|
+
show: false,
|
|
37
|
+
title: "添加到我的小程序",
|
|
38
|
+
desc: "点击右上角 ··· 添加",
|
|
42
39
|
});
|
|
43
40
|
|
|
44
41
|
const emit = defineEmits<{
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
/** 点击关闭按钮时触发 */
|
|
43
|
+
close: [];
|
|
47
44
|
}>();
|
|
48
45
|
|
|
49
46
|
// 从 useDevice 获取缓存的设备系统信息,规避在 computed 中频繁调用同步系统 API 的性能问题
|
|
50
47
|
const { info } = useDevice();
|
|
51
48
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
)
|
|
49
|
+
const isCustomNav = ref(false);
|
|
50
|
+
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
// 1. 全局配置探测(针对全局自定义导航样式,可立即识别,免去生命周期时序竞态问题)
|
|
53
|
+
try {
|
|
54
|
+
if (typeof __wxConfig !== "undefined") {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
const globalStyle = __wxConfig.globalStyle?.navigationStyle || __wxConfig.global?.window?.navigationStyle;
|
|
57
|
+
if (globalStyle === "custom") {
|
|
58
|
+
isCustomNav.value = true;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
// 容错
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 2. 延迟探测(避开组件挂载时 getCurrentPages 尚未完全初始化的竞态,并且使用非破坏性读取)
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
try {
|
|
69
|
+
const pages = getCurrentPages();
|
|
70
|
+
if (pages && pages.length > 0) {
|
|
71
|
+
const page = pages[pages.length - 1];
|
|
72
|
+
// @ts-ignore - 微信小程序原生属性或 uni-app 底层元数据配置
|
|
73
|
+
const style = page.__wxConfig?.navigationStyle || page?.$page?.meta?.navigationStyle;
|
|
74
|
+
if (style === "custom") {
|
|
75
|
+
isCustomNav.value = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
// 容错
|
|
80
|
+
}
|
|
81
|
+
}, 100);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const top = computed(() => {
|
|
85
|
+
if (isCustomNav.value) {
|
|
86
|
+
try {
|
|
87
|
+
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
|
88
|
+
if (menuButtonInfo && menuButtonInfo.bottom > 0) {
|
|
89
|
+
// 胶囊底部高度 + 16px 作为气泡定位的顶部基准,保证指向绝对精确且避开胶囊
|
|
90
|
+
return `${menuButtonInfo.bottom + 16}px`;
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
// 跨端环境不支持或报错时,执行安全降级计算
|
|
94
|
+
}
|
|
95
|
+
return `${info.status_bar_height + 50}px`;
|
|
96
|
+
}
|
|
97
|
+
return "12px";
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const arrowStyle = computed(() => {
|
|
101
|
+
try {
|
|
102
|
+
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
|
103
|
+
if (menuButtonInfo && menuButtonInfo.width > 0) {
|
|
104
|
+
// 胶囊左边缘 + 胶囊宽度的 28% (即三点按钮的中心点)
|
|
105
|
+
const dotsCenterX = menuButtonInfo.left + menuButtonInfo.width * 0.28;
|
|
106
|
+
// 屏幕宽度 - 胶囊三点中心点 = 三点中心点到屏幕右边缘的像素距离
|
|
107
|
+
const arrowRightPx = info.window_width - dotsCenterX;
|
|
108
|
+
// 气泡右边缘到屏幕右边缘的像素距离 (22rpx)
|
|
109
|
+
const bubbleRightPx = uni.upx2px(22);
|
|
110
|
+
// 箭头相对于气泡右侧边缘的像素偏移 (再减去箭头自身半宽 12rpx 对应的 px 像素)
|
|
111
|
+
const arrowHalfWidthPx = uni.upx2px(12);
|
|
112
|
+
const rightOffset = arrowRightPx - bubbleRightPx - arrowHalfWidthPx;
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
right: `${rightOffset}px`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
} catch (e) {
|
|
119
|
+
// 容错降级
|
|
120
|
+
}
|
|
121
|
+
return {};
|
|
122
|
+
});
|
|
55
123
|
|
|
56
124
|
/**
|
|
57
125
|
* 触发关闭气泡事件。
|
|
58
126
|
*/
|
|
59
127
|
function close() {
|
|
60
|
-
|
|
128
|
+
emit("close");
|
|
61
129
|
}
|
|
62
130
|
</script>
|
|
63
131
|
|
|
64
132
|
<style lang="scss" scoped>
|
|
65
133
|
.hlw-add-mini {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
134
|
+
position: fixed;
|
|
135
|
+
right: 22rpx;
|
|
136
|
+
z-index: 99999;
|
|
137
|
+
width: 340rpx;
|
|
138
|
+
animation: hlw-add-mini-in 0.22s ease-out both;
|
|
71
139
|
}
|
|
72
140
|
|
|
73
141
|
.hlw-add-mini__arrow {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
142
|
+
position: absolute;
|
|
143
|
+
right: 92rpx;
|
|
144
|
+
top: -13rpx;
|
|
145
|
+
width: 0;
|
|
146
|
+
height: 0;
|
|
147
|
+
z-index: 99999;
|
|
148
|
+
border-left: 12rpx solid transparent;
|
|
149
|
+
border-right: 12rpx solid transparent;
|
|
150
|
+
border-bottom: 14rpx solid rgba(17, 24, 39, 0.82);
|
|
81
151
|
}
|
|
82
152
|
|
|
83
153
|
.hlw-add-mini__content {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
gap: 12rpx;
|
|
157
|
+
padding: 16rpx 14rpx 16rpx 20rpx;
|
|
158
|
+
border-radius: 14rpx;
|
|
159
|
+
background: rgba(17, 24, 39, 0.82);
|
|
160
|
+
box-shadow: 0 12rpx 34rpx rgba(15, 23, 42, 0.22);
|
|
91
161
|
}
|
|
92
162
|
|
|
93
163
|
.hlw-add-mini__text {
|
|
94
|
-
|
|
95
|
-
|
|
164
|
+
flex: 1;
|
|
165
|
+
min-width: 0;
|
|
96
166
|
}
|
|
97
167
|
|
|
98
168
|
.hlw-add-mini__title {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
169
|
+
color: #ffffff;
|
|
170
|
+
font-size: 25rpx;
|
|
171
|
+
font-weight: 400;
|
|
172
|
+
line-height: 1.3;
|
|
103
173
|
letter-spacing: 1rpx;
|
|
104
174
|
}
|
|
105
175
|
|
|
106
176
|
.hlw-add-mini__desc {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
177
|
+
margin-top: 4rpx;
|
|
178
|
+
color: rgba(255, 255, 255, 0.72);
|
|
179
|
+
font-size: 21rpx;
|
|
180
|
+
line-height: 1.3;
|
|
111
181
|
letter-spacing: 1rpx;
|
|
112
182
|
}
|
|
113
183
|
|
|
114
184
|
.hlw-add-mini__close {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
185
|
+
display: flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
justify-content: center;
|
|
188
|
+
flex-shrink: 0;
|
|
189
|
+
width: 36rpx;
|
|
190
|
+
height: 36rpx;
|
|
191
|
+
color: rgba(255, 255, 255, 0.72);
|
|
192
|
+
font-size: 30rpx;
|
|
193
|
+
line-height: 1;
|
|
124
194
|
}
|
|
125
195
|
|
|
126
196
|
@keyframes hlw-add-mini-in {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
197
|
+
0% {
|
|
198
|
+
opacity: 0;
|
|
199
|
+
transform: translateY(-8rpx);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
100% {
|
|
203
|
+
opacity: 1;
|
|
204
|
+
transform: translateY(0);
|
|
205
|
+
}
|
|
136
206
|
}
|
|
137
207
|
</style>
|