feat: 全局更改tabbar、首页、分享页UI重构
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user