修复 导航栏 高度的问题
This commit is contained in:
61
src/components/BackNavbar/index.scss
Normal file
61
src/components/BackNavbar/index.scss
Normal file
@@ -0,0 +1,61 @@
|
||||
.back-navbar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
background: #ffffff;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
.navbar-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 15px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
.navbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.back-button {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
|
||||
&:active {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.back-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-left: 2px solid #000000;
|
||||
border-bottom: 2px solid #000000;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-avatar {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.navbar-title {
|
||||
font-family: "PingFang SC";
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.019em;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
src/components/BackNavbar/index.tsx
Normal file
66
src/components/BackNavbar/index.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import React from 'react';
|
||||
import { View, Text, Image } from '@tarojs/components';
|
||||
import { getNavbarHeight } from '@/utils/getNavbarHeight';
|
||||
import { useUserInfo } from '@/store/userStore';
|
||||
import Taro from '@tarojs/taro';
|
||||
import './index.scss';
|
||||
|
||||
interface BackNavbarProps {
|
||||
title?: string;
|
||||
showAvatar?: boolean;
|
||||
showBackButton?: boolean;
|
||||
onBack?: () => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const BackNavbar: React.FC<BackNavbarProps> = ({
|
||||
title = '消息',
|
||||
showAvatar = true,
|
||||
showBackButton = false,
|
||||
onBack,
|
||||
className = ''
|
||||
}) => {
|
||||
const userInfo = useUserInfo();
|
||||
const { statusBarHeight, navBarHeight, totalHeight } = getNavbarHeight();
|
||||
|
||||
const handleBack = () => {
|
||||
if (onBack) {
|
||||
onBack();
|
||||
} else {
|
||||
Taro.navigateBack();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View
|
||||
className={`back-navbar ${className}`}
|
||||
style={{
|
||||
paddingTop: `${statusBarHeight}px`,
|
||||
height: `${totalHeight}px`
|
||||
}}
|
||||
>
|
||||
<View
|
||||
className="navbar-content"
|
||||
style={{ height: `${navBarHeight}px` }}
|
||||
>
|
||||
<View className="navbar-left">
|
||||
{showBackButton && (
|
||||
<View className="back-button" onClick={handleBack}>
|
||||
<View className="back-icon"></View>
|
||||
</View>
|
||||
)}
|
||||
{showAvatar && (
|
||||
<Image
|
||||
className="navbar-avatar"
|
||||
src={userInfo?.userInfo?.avatar_url}
|
||||
mode="aspectFill"
|
||||
/>
|
||||
)}
|
||||
<Text className="navbar-title">{title}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default BackNavbar;
|
||||
@@ -2,13 +2,14 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
justify-content: start;
|
||||
padding: 60px 16px;
|
||||
min-height: 400px;
|
||||
margin-top: 40px;
|
||||
|
||||
.empty-icon {
|
||||
width: 221px;
|
||||
height: 200px;
|
||||
width:132.7px;
|
||||
height: 120px;
|
||||
position: relative;
|
||||
border-radius: 20px;
|
||||
margin-bottom: 12px;
|
||||
|
||||
@@ -22,6 +22,7 @@ import GameManagePopup from './GameManagePopup';
|
||||
import FollowUserCard from './FollowUserCard/index';
|
||||
import Comments from "./Comments";
|
||||
import GeneralNavbar from "./GeneralNavbar";
|
||||
import BackNavbar from "./BackNavbar";
|
||||
import RadarChart from './Radar'
|
||||
import EmptyState from './EmptyState';
|
||||
import NTRPTestEntryCard from './NTRPTestEntryCard'
|
||||
@@ -52,6 +53,7 @@ export {
|
||||
FollowUserCard,
|
||||
Comments,
|
||||
GeneralNavbar,
|
||||
BackNavbar,
|
||||
RadarChart,
|
||||
EmptyState,
|
||||
NTRPTestEntryCard,
|
||||
|
||||
Reference in New Issue
Block a user