@hlw-uni/mp-vue 2.1.59 → 2.1.69
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/README.md +388 -213
- package/dist/composables/index.d.ts +0 -8
- package/dist/composables/request/service.d.ts +2 -6
- package/dist/core/index.d.ts +1 -0
- package/dist/core/theme.d.ts +21 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +113 -367
- package/dist/index.mjs +113 -367
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/theme.d.ts +26 -55
- 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 +181 -0
- package/src/components/hlw-page/index.vue +75 -105
- package/src/composables/index.ts +1 -31
- package/src/composables/request/service.ts +10 -3
- package/src/core/index.ts +1 -0
- package/src/core/theme.ts +62 -0
- package/src/env.d.ts +8 -0
- package/src/index.ts +10 -4
- package/src/stores/index.ts +1 -0
- package/src/stores/theme.ts +113 -101
- package/dist/composables/theme/appearance.d.ts +0 -55
- package/dist/composables/theme/font.d.ts +0 -32
- package/dist/composables/theme/index.d.ts +0 -46
- package/dist/composables/theme/palette.d.ts +0 -37
- package/dist/composables/theme/typography.d.ts +0 -41
- package/src/composables/theme/README.md +0 -131
- package/src/composables/theme/appearance.ts +0 -129
- package/src/composables/theme/font.ts +0 -95
- package/src/composables/theme/index.ts +0 -89
- package/src/composables/theme/palette.ts +0 -117
- package/src/composables/theme/typography.ts +0 -90
|
@@ -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>
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view :class="`hlw-avatar hlw-avatar--${size ?? 'medium'}`" :style="avatarStyle">
|
|
3
|
-
<image
|
|
4
|
-
v-if="src && !loadError"
|
|
5
|
-
class="hlw-avatar__image"
|
|
6
|
-
:src="src"
|
|
7
|
-
mode="aspectFill"
|
|
8
|
-
@error="loadError = true"
|
|
9
|
-
/>
|
|
3
|
+
<image v-if="src && !loadError" class="hlw-avatar__image" :src="src" mode="aspectFill" @error="loadError = true" />
|
|
10
4
|
<view v-else class="hlw-avatar__placeholder">
|
|
11
5
|
<text class="hlw-avatar__initial">{{ initial }}</text>
|
|
12
6
|
</view>
|
|
@@ -30,12 +24,12 @@
|
|
|
30
24
|
* <HlwAvatar src="/avatar.png" name="张三" size="large" />
|
|
31
25
|
* ```
|
|
32
26
|
*/
|
|
33
|
-
import { ref, computed } from
|
|
27
|
+
import { ref, computed } from "vue";
|
|
34
28
|
|
|
35
29
|
const props = defineProps<{
|
|
36
30
|
src?: string;
|
|
37
31
|
name?: string;
|
|
38
|
-
size?:
|
|
32
|
+
size?: "small" | "medium" | "large";
|
|
39
33
|
border?: number;
|
|
40
34
|
}>();
|
|
41
35
|
|
|
@@ -43,11 +37,11 @@ const loadError = ref(false);
|
|
|
43
37
|
const avatarStyle = computed(() => {
|
|
44
38
|
const border = Math.max(0, Number(props.border ?? 0));
|
|
45
39
|
return {
|
|
46
|
-
border: border > 0 ? `${border}px solid #fff` :
|
|
40
|
+
border: border > 0 ? `${border}px solid #fff` : "0",
|
|
47
41
|
};
|
|
48
42
|
});
|
|
49
43
|
const initial = computed(() => {
|
|
50
|
-
if (!props.name) return
|
|
44
|
+
if (!props.name) return "?";
|
|
51
45
|
return props.name.charAt(0).toUpperCase();
|
|
52
46
|
});
|
|
53
47
|
</script>
|
|
@@ -60,9 +54,18 @@ const initial = computed(() => {
|
|
|
60
54
|
flex-shrink: 0;
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
.hlw-avatar--small
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
.hlw-avatar--small {
|
|
58
|
+
width: 56rpx;
|
|
59
|
+
height: 56rpx;
|
|
60
|
+
}
|
|
61
|
+
.hlw-avatar--medium {
|
|
62
|
+
width: 80rpx;
|
|
63
|
+
height: 80rpx;
|
|
64
|
+
}
|
|
65
|
+
.hlw-avatar--large {
|
|
66
|
+
width: 120rpx;
|
|
67
|
+
height: 120rpx;
|
|
68
|
+
}
|
|
66
69
|
|
|
67
70
|
.hlw-avatar__image {
|
|
68
71
|
width: 100%;
|
|
@@ -72,18 +75,23 @@ const initial = computed(() => {
|
|
|
72
75
|
.hlw-avatar__placeholder {
|
|
73
76
|
width: 100%;
|
|
74
77
|
height: 100%;
|
|
75
|
-
background: #
|
|
78
|
+
background: #f1f5f9;
|
|
76
79
|
display: flex;
|
|
77
80
|
align-items: center;
|
|
78
81
|
justify-content: center;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
.hlw-avatar__initial {
|
|
82
|
-
color: #
|
|
83
|
-
font-weight: bold;
|
|
85
|
+
color: #94a3b8;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
.hlw-avatar--small
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
.hlw-avatar--small .hlw-avatar__initial {
|
|
89
|
+
font-size: var(--font-xs, 20rpx);
|
|
90
|
+
}
|
|
91
|
+
.hlw-avatar--medium .hlw-avatar__initial {
|
|
92
|
+
font-size: var(--font-base, 28rpx);
|
|
93
|
+
}
|
|
94
|
+
.hlw-avatar--large .hlw-avatar__initial {
|
|
95
|
+
font-size: var(--font-xl, 40rpx);
|
|
96
|
+
}
|
|
89
97
|
</style>
|
|
@@ -105,6 +105,12 @@ defineEmits<{ click: [] }>();
|
|
|
105
105
|
font-size: var(--font-lg, 36rpx);
|
|
106
106
|
color: var(--primary-color, #3b82f6);
|
|
107
107
|
flex-shrink: 0;
|
|
108
|
+
|
|
109
|
+
view {
|
|
110
|
+
width: var(--font-lg, 36rpx);
|
|
111
|
+
height: var(--font-lg, 36rpx);
|
|
112
|
+
display: inline-block;
|
|
113
|
+
}
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
.hlw-cell-body {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
:send-message-img="resolvedContact.img"
|
|
13
13
|
:show-message-card="resolvedContact.show"
|
|
14
14
|
>
|
|
15
|
-
<text class="
|
|
15
|
+
<text class="i-ri-customer-service-line contact-button-icon" />
|
|
16
16
|
<text class="contact-button-text">{{ resolvedBtnTitle }}</text>
|
|
17
17
|
</button>
|
|
18
18
|
</view>
|
|
@@ -64,7 +64,7 @@ const resolvedContact = computed(() => {
|
|
|
64
64
|
padding: var(--card-padding);
|
|
65
65
|
border: 1rpx solid var(--border-color-light);
|
|
66
66
|
border-radius: var(--card-radius);
|
|
67
|
-
background: linear-gradient(135deg, #ffffff 0%, rgba(
|
|
67
|
+
background: linear-gradient(135deg, #ffffff 0%, var(--primary-light, rgba(76, 68, 239, 0.05)) 100%);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
.contact-copy {
|
|
@@ -100,14 +100,15 @@ const resolvedContact = computed(() => {
|
|
|
100
100
|
flex-shrink: 0;
|
|
101
101
|
margin: 0;
|
|
102
102
|
border-radius: var(--radius-full);
|
|
103
|
-
background: #
|
|
103
|
+
background: var(--primary-color, #3b82f6);
|
|
104
104
|
color: #ffffff;
|
|
105
105
|
font: inherit;
|
|
106
106
|
line-height: 68rpx;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.contact-button
|
|
110
|
-
|
|
109
|
+
.contact-button-icon {
|
|
110
|
+
width: var(--font-sm);
|
|
111
|
+
height: var(--font-sm);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
.contact-button-text {
|
|
@@ -335,7 +335,10 @@ const handleGetPhoneNumber = (item: HlwMenuItem, event: unknown) => {
|
|
|
335
335
|
flex-shrink: 0;
|
|
336
336
|
|
|
337
337
|
text {
|
|
338
|
+
width: var(--hlw-menu-icon-size);
|
|
339
|
+
height: var(--hlw-menu-icon-size);
|
|
338
340
|
font-size: var(--hlw-menu-icon-size);
|
|
341
|
+
display: inline-block;
|
|
339
342
|
}
|
|
340
343
|
|
|
341
344
|
&--grid {
|
|
@@ -343,7 +346,10 @@ const handleGetPhoneNumber = (item: HlwMenuItem, event: unknown) => {
|
|
|
343
346
|
height: var(--hlw-menu-grid-icon-box-size);
|
|
344
347
|
border-radius: var(--radius-lg, 24rpx);
|
|
345
348
|
text {
|
|
349
|
+
width: var(--hlw-menu-grid-icon-size);
|
|
350
|
+
height: var(--hlw-menu-grid-icon-size);
|
|
346
351
|
font-size: var(--hlw-menu-grid-icon-size);
|
|
352
|
+
display: inline-block;
|
|
347
353
|
}
|
|
348
354
|
}
|
|
349
355
|
|
|
@@ -376,8 +382,8 @@ const handleGetPhoneNumber = (item: HlwMenuItem, event: unknown) => {
|
|
|
376
382
|
color: #f43f5e;
|
|
377
383
|
}
|
|
378
384
|
&--blue {
|
|
379
|
-
background:
|
|
380
|
-
color: #3b82f6;
|
|
385
|
+
background: var(--primary-light, rgba(76, 68, 239, 0.12));
|
|
386
|
+
color: var(--primary-color, #3b82f6);
|
|
381
387
|
}
|
|
382
388
|
&--red {
|
|
383
389
|
background: #fef2f2;
|
|
@@ -418,7 +424,7 @@ const handleGetPhoneNumber = (item: HlwMenuItem, event: unknown) => {
|
|
|
418
424
|
background: #f43f5e;
|
|
419
425
|
}
|
|
420
426
|
.hlw-menu-tag--blue {
|
|
421
|
-
background: #3b82f6;
|
|
427
|
+
background: var(--primary-color, #3b82f6);
|
|
422
428
|
}
|
|
423
429
|
|
|
424
430
|
.hlw-menu-tag-pulse {
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="navbar" :class="theme">
|
|
3
|
+
<view :style="bar_style"></view>
|
|
4
|
+
<view class="header" :style="{ height: header_height + 'px' }">
|
|
5
|
+
<view @tap="tapBack" class="left" v-if="props.isBack">
|
|
6
|
+
<text class="i-fa6-solid-chevron-left icon-left"></text>
|
|
7
|
+
</view>
|
|
8
|
+
<text class="title">{{ title }}</text>
|
|
9
|
+
</view>
|
|
10
|
+
<view class="status-bar" v-if="theme === 'color-theme'">
|
|
11
|
+
<view class="within"></view>
|
|
12
|
+
</view>
|
|
13
|
+
</view>
|
|
14
|
+
<view :style="{ height: navbar_height + 'px' }"></view>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script lang="ts" setup>
|
|
18
|
+
import { computed, ref } from "vue";
|
|
19
|
+
import { useTheme } from "@/core";
|
|
20
|
+
|
|
21
|
+
const { theme } = useTheme();
|
|
22
|
+
|
|
23
|
+
const statusBarHeight: number = uni.getSystemInfoSync()?.statusBarHeight || 0;
|
|
24
|
+
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
|
|
25
|
+
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
isBar: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
title: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "",
|
|
34
|
+
},
|
|
35
|
+
isBack: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const bar_style = computed(() => {
|
|
42
|
+
const style = {
|
|
43
|
+
height: statusBarHeight + "px",
|
|
44
|
+
};
|
|
45
|
+
return style;
|
|
46
|
+
});
|
|
47
|
+
let status_bar_height = 0;
|
|
48
|
+
if (props.isBar) {
|
|
49
|
+
status_bar_height = 15;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const header_height = ref<number>(menuButtonInfo.bottom - statusBarHeight + 6);
|
|
53
|
+
const navbar_height = ref(header_height.value + statusBarHeight);
|
|
54
|
+
const status_bar_height_style = `${status_bar_height}px`;
|
|
55
|
+
|
|
56
|
+
function tapBack() {
|
|
57
|
+
uni.navigateBack({
|
|
58
|
+
fail: (err) => {
|
|
59
|
+
uni.reLaunch({
|
|
60
|
+
url: "/pages/index/index",
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<style lang="scss" scoped>
|
|
68
|
+
.navbar {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
position: fixed;
|
|
72
|
+
width: 750rpx;
|
|
73
|
+
z-index: 999;
|
|
74
|
+
border-bottom: 1rpx solid rgba(226, 232, 240, 0);
|
|
75
|
+
transition:
|
|
76
|
+
background-color 0.2s ease,
|
|
77
|
+
border-bottom 0.2s ease;
|
|
78
|
+
|
|
79
|
+
/* 白色主题:白色导航栏,下方加一条灰色的细边框 */
|
|
80
|
+
&.white-theme {
|
|
81
|
+
background-color: var(--navbar-bg-color, #ffffff);
|
|
82
|
+
border-bottom: var(--navbar-border-bottom, 1rpx solid #e7e7e7);
|
|
83
|
+
|
|
84
|
+
.title {
|
|
85
|
+
color: var(--font-color, #303048);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.icon-left {
|
|
89
|
+
color: var(--font-color, #303048);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* 简洁主题:背景色与页面全局背景色一致,无明显界限,无边框 */
|
|
94
|
+
&.light-theme {
|
|
95
|
+
background-color: var(--bg-page, #f8f8f8);
|
|
96
|
+
border-bottom: 1rpx solid rgba(226, 232, 240, 0);
|
|
97
|
+
|
|
98
|
+
.title {
|
|
99
|
+
color: var(--font-color, #303048);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.icon-left {
|
|
103
|
+
color: var(--font-color, #303048);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* 单色主题:纯主题色导航栏,无边框,无圆角 */
|
|
108
|
+
&.mono-theme {
|
|
109
|
+
background-color: var(--primary-color, #3b82f6);
|
|
110
|
+
border-bottom: 1rpx solid rgba(226, 232, 240, 0);
|
|
111
|
+
|
|
112
|
+
.title {
|
|
113
|
+
color: #ffffff;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.icon-left {
|
|
117
|
+
color: #ffffff;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* 颜色主题:导航栏使用立体光影感的主题色渐变背景(反向:左上偏深,右下偏亮),下方带有白色圆角过渡 */
|
|
122
|
+
&.color-theme {
|
|
123
|
+
background: linear-gradient(135deg, rgba(0, 0, 0, 0.15) 0%, rgba(255, 255, 255, 0.15) 100%), var(--primary-color, #3b82f6);
|
|
124
|
+
border-bottom: 1rpx solid rgba(226, 232, 240, 0);
|
|
125
|
+
|
|
126
|
+
.title {
|
|
127
|
+
color: #ffffff;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.icon-left {
|
|
131
|
+
color: #ffffff;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.header {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: row;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
position: relative;
|
|
141
|
+
|
|
142
|
+
.left {
|
|
143
|
+
position: absolute;
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
left: 0rpx;
|
|
148
|
+
width: 100rpx;
|
|
149
|
+
height: 100%;
|
|
150
|
+
|
|
151
|
+
.icon-left {
|
|
152
|
+
font-size: 30rpx;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.title {
|
|
157
|
+
font-size: var(--navbar-font-size, 26rpx);
|
|
158
|
+
letter-spacing: 1rpx;
|
|
159
|
+
font-weight: normal;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.status-bar {
|
|
164
|
+
background-color: transparent;
|
|
165
|
+
height: v-bind(status_bar_height_style);
|
|
166
|
+
width: 750rpx;
|
|
167
|
+
position: relative;
|
|
168
|
+
|
|
169
|
+
.within {
|
|
170
|
+
position: absolute;
|
|
171
|
+
left: 0;
|
|
172
|
+
top: 0;
|
|
173
|
+
width: 750rpx;
|
|
174
|
+
height: calc(v-bind(status_bar_height_style) + 2rpx);
|
|
175
|
+
background-color: var(--bg-color, var(--bg-page, #f8f8f8));
|
|
176
|
+
border-top-left-radius: var(--status-bar-border, var(--card-radius, 32rpx));
|
|
177
|
+
border-top-right-radius: var(--status-bar-border, var(--card-radius, 32rpx));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
</style>
|