feat: 全局更改tabbar、首页、分享页UI重构

This commit is contained in:
2026-06-01 15:50:19 +08:00
parent aa0a289f27
commit c2388e1396
22 changed files with 852 additions and 461 deletions
+87 -5
View File
@@ -7,6 +7,8 @@
v-if="navbar === 'normal'"
:title="title"
:showLeftButton="showLeftButton"
:bg="navBarColors.bg"
:color="navBarColors.color"
@clickLeft="onClickLeft"
:index="props.index"
/>
@@ -14,6 +16,10 @@
v-if="navbar === 'inner'"
:title="title"
:showLeftButton="showLeftButton"
:bg="navBarColors.bg"
:color="navBarColors.color"
:scrollbg="navBarColors.scrollbg"
:scrollColor="navBarColors.scrollColor"
@clickLeft="onClickLeft"
:index="props.index"
/>
@@ -21,13 +27,17 @@
v-if="navbar === 'transparent'"
:title="title"
:showLeftButton="showLeftButton"
:bg="navBarColors.bg"
:color="navBarColors.color"
:scrollbg="navBarColors.scrollbg"
:scrollColor="navBarColors.scrollColor"
@clickLeft="onClickLeft"
:index="props.index"
/>
<!-- 页面内容插槽 -->
<!-- :style="{ paddingTop: paddingTop + 'px' }" -->
<view class="pageCon" :style="{ paddingTop: paddingTop + 'px' }">
<view class="pageCon" :style="pageConStyle">
<!-- <view class="transparent_bg" style="z-index: 100;">
<image src="/static/transparent_bg.png" />
</view> -->
@@ -40,16 +50,21 @@
<!-- 全局快捷入口 -->
<s-menu-tools />
</view>
<cardTabber v-if="props.tabbar" :path="tabbarPath" />
</view>
</template>
<script setup lang="ts">
import { getCurrentInstance, ref, computed } from 'vue';
<script setup>
import { getCurrentInstance, ref, computed, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import innerNavbar from '@/components/card_navbar/inner-navbar';
import cardNavbar from '@/components/card_navbar/card_navbar';
import transparentNavbar from '@/components/card_navbar/transparent_navbar';
import cardTabber from '@/components/card_tabber/card_tabber.vue';
import sheep from '@/sheep';
const { proxy } = getCurrentInstance() as any;
const emits = defineEmits(['onClickLeft']);
const instance = getCurrentInstance();
const proxy = instance?.proxy;
const props = defineProps({
title: {
type: String,
@@ -126,6 +141,10 @@
type: String,
default: '2',
},
navPreset: {
type: String,
default: '',
},
index: {
type: Number,
default: 0,
@@ -140,6 +159,36 @@
let paddingTop = ref();
paddingTop.value = statusBarHeight + 44;
const tabbarPath = ref('');
const normalizePath = (p) => {
if (!p) return '';
return p.startsWith('/') ? p : `/${p}`;
};
const updateTabbarPath = () => {
if (typeof props.tabbar === 'string' && props.tabbar) {
tabbarPath.value = normalizePath(props.tabbar);
return;
}
const pages = getCurrentPages?.() || [];
const current = pages[pages.length - 1];
tabbarPath.value = normalizePath(current?.route || '');
};
onShow(() => updateTabbarPath());
watch(() => props.tabbar, () => updateTabbarPath(), { immediate: true });
const pageConStyle = computed(() => {
const style = {
paddingTop: paddingTop.value + 'px',
};
if (props.tabbar) {
style.paddingBottom = `calc(${uni.upx2px(100)}px + env(safe-area-inset-bottom))`;
}
return style;
});
const bgMain = computed(() => {
return {
background: `${props.bgStyle.backgroundColor || props.bgStyle.color} url(${sheep.$url.cdn(
@@ -147,9 +196,42 @@
)}) no-repeat top center / 100% auto`,
};
});
const navBarColors = computed(() => {
if (props.navPreset === 'light') {
return {
bg: '#ffffff',
color: '#333333',
scrollbg: '#ffffff',
scrollColor: '#333333',
};
}
if (props.navPreset === 'transparent') {
return {
bg: 'transparent',
color: '#333333',
scrollbg: '#ffffff',
scrollColor: '#333333',
};
}
if (props.navPreset === 'dark') {
return {
bg: '#000000',
color: '#ffffff',
scrollbg: '#000000',
scrollColor: '#ffffff',
};
}
return {
bg: undefined,
color: undefined,
scrollbg: undefined,
scrollColor: undefined,
};
});
const onClickLeft = () => {
console.log('返回2');
proxy.$emit('onClickLeft');
emits('onClickLeft');
};
</script>
<style scoped lang="scss">
+9 -2
View File
@@ -6,6 +6,7 @@
:bgStyle="{ color: props.color }"
:showLeftButton="props.showLeftButton"
:goLeft="props.goLeft"
:tabbar="props.tabbar"
@onClickLeft="onClickLeft"
>
<!-- <Agreement /> -->
@@ -24,7 +25,7 @@
</view>
</s-layout>
</template>
<script setup lang="ts">
<script setup>
// import Agreement from '@/components/agreement.vue';
import {
ref,
@@ -71,16 +72,22 @@
type: String,
default: 'inner',
},
tabbar: {
type: [String, Boolean],
default: '',
},
});
let height = ref(0);
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
const safeBottom = sysInfo.safeAreaInsets?.bottom || 0;
watch(
() => [props.height, props.heightShow],
(val) => {
if (!props.height) {
if (!props.heightShow) {
height.value = windowHeight - sysInfo.statusBarHeight - uni.upx2px(88);
const tabbarHeight = props.tabbar ? uni.upx2px(100) + safeBottom : 0;
height.value = windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) - tabbarHeight;
}
} else {
height.value = props.height;