This commit is contained in:
张成
2025-11-14 22:54:36 +08:00
parent 6b560da897
commit 0adab95d34
16 changed files with 171 additions and 42 deletions

View File

@@ -19,7 +19,8 @@
.leftSection {
display: flex;
align-items: center;
min-width: 60px;
gap: 8px;
flex: 1;
}
.centerSection {
@@ -27,6 +28,10 @@
display: flex;
justify-content: center;
align-items: center;
position: absolute;
left: 0;
right: 0;
pointer-events: none;
}
.rightSection {
@@ -39,7 +44,8 @@
font-size: 18px;
font-weight: 600;
color: #333;
text-align: center;
text-align: left;
pointer-events: auto;
}
.backIcon {

View File

@@ -15,6 +15,7 @@ interface GeneralNavbarProps {
showLeft?: boolean
onBack?: () => void
className?: string
titlePosition?: 'left' | 'center' // 标题位置:左侧或居中
}
const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
@@ -22,11 +23,12 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
titleStyle,
titleClassName = '',
leftContent,
backgroundColor = '#FAFAFA',
backgroundColor = 'transparent',
showBack = true,
showLeft = true,
onBack,
className = ''
className = '',
titlePosition = 'left' // 默认标题在左侧
}) => {
const { statusNavbarHeightInfo } = useGlobalState() || {}
const { statusBarHeight = 0, navBarHeight = 44, totalHeight = 98 } = statusNavbarHeightInfo || {}
@@ -35,7 +37,7 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
if (onBack) {
onBack()
} else {
Taro.navigateBack()
(Taro as any).navigateBack()
}
}
@@ -82,20 +84,23 @@ const GeneralNavbar: React.FC<GeneralNavbarProps> = ({
style={{
height: `${totalHeight}px`,
paddingTop: `${statusBarHeight}px`,
backgroundColor: backgroundColor || '#FAFAFA'
backgroundColor: backgroundColor || 'transparent'
}}
>
<View className={styles.navbarContent} style={{ height: `${navBarHeight}px` }}>
<View className={styles.leftSection}>
{renderLeftContent()}
{titlePosition === 'left' && renderTitle()}
</View>
<View className={styles.centerSection}>
{renderTitle()}
</View>
{titlePosition === 'center' && (
<View className={styles.centerSection}>
{renderTitle()}
</View>
)}
<View className={styles.rightSection}>
{/* 右侧占位,保持标题居中 */}
{/* 右侧占位 */}
</View>
</View>
</View>