<template>
|
<NavBar v-bind="props">
|
<div
|
:class="['common-navigation-bar-wrapper', { dark: props.mode == 'dark' }]"
|
:style="barStyle"
|
>
|
<div
|
class="menu-btn-wrapper"
|
v-if="(!isLastPage || !isTabbarPage) && showLeftArrow"
|
@click="handleBack()"
|
>
|
<img class="menu-btn" :src="props.mode == 'dark' ? IconArrowWhite : IconArrow" />
|
</div>
|
<span class="common-navigation-bar-title">{{ title }}</span>
|
</div>
|
</NavBar>
|
</template>
|
|
<script setup lang="ts">
|
import NavBar from './NavBar.vue';
|
import { commonNavigationBarProps } from './commonNavigationBar';
|
import { useSystemStore } from '@/stores/modules/system';
|
import { CSSProperties } from 'vue';
|
import IconArrow from '@/assets/common/icon-navi-arrow.png';
|
import IconArrowWhite from '@/assets/common/icon-navi-arrow-white.png';
|
import Taro from '@tarojs/taro';
|
import { goBack } from '@/utils';
|
import { TabBarPageRouterForCheck } from '@/constants';
|
|
defineOptions({
|
name: 'CommonNavigationBar',
|
});
|
|
const systemStore = useSystemStore();
|
|
const props = defineProps(commonNavigationBarProps);
|
|
const router = Taro.useRouter();
|
|
const isLastPage = computed(() => {
|
const pages = Taro.getCurrentPages();
|
return pages.length <= 1;
|
});
|
|
const isTabbarPage = computed(() =>
|
Object.values(TabBarPageRouterForCheck).some((x) => x.toLowerCase() === router.path.toLowerCase())
|
);
|
|
const barStyle = computed(() => {
|
const distance = systemStore.menuButtonWidth + systemStore.menuButtonRightDistance + 4;
|
return {
|
paddingLeft: `${distance}px`,
|
paddingRight: `${distance}px`,
|
|
height: systemStore.navigationBarHeight + 'px',
|
} as CSSProperties;
|
});
|
|
function handleBack() {
|
if (props.backFn) {
|
props.backFn();
|
} else {
|
goBack();
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
@import '@/styles/common.scss';
|
|
.common-navigation-bar-wrapper {
|
width: 100%;
|
line-height: 1;
|
font-size: 32px;
|
color: boleGetCssVar('color', 'title-color');
|
min-width: 0;
|
position: relative;
|
align-items: center;
|
display: flex;
|
justify-content: center;
|
|
.common-navigation-bar-title {
|
@include ellipsis;
|
font-weight: 600;
|
}
|
|
&.dark {
|
color: #fff;
|
}
|
|
.menu-btn-wrapper {
|
padding: 20px;
|
padding-left: 0;
|
position: absolute;
|
left: boleGetCssVar('size', 'body-padding-h');
|
// top: -20px;
|
}
|
|
.menu-btn {
|
width: 20px;
|
height: 30px;
|
}
|
}
|
</style>
|