32 lines
942 B
TypeScript
32 lines
942 B
TypeScript
import { View, Text } from '@tarojs/components';
|
|
import Taro from '@tarojs/taro';
|
|
|
|
type Props = {
|
|
title: string;
|
|
back?: boolean;
|
|
plain?: boolean;
|
|
actionText?: string;
|
|
onAction?: () => void;
|
|
};
|
|
|
|
/** 带顶部安全区(刘海/状态栏)适配的通用头部 */
|
|
export default function HqHeader({ title, back, plain, actionText, onAction }: Props) {
|
|
return (
|
|
<View className={`hq-header${plain ? ' hq-header--plain' : ''}`}>
|
|
<View className="hq-header__bar">
|
|
{back && (
|
|
<View className="hq-header__back" onClick={() => Taro.navigateBack()}>
|
|
<Text className="material-symbols-outlined">arrow_back_ios_new</Text>
|
|
</View>
|
|
)}
|
|
<Text className="hq-header__title">{title}</Text>
|
|
{actionText && (
|
|
<View className="hq-header__action" onClick={onAction}>
|
|
<Text>{actionText}</Text>
|
|
</View>
|
|
)}
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|