广州矛调粤政易端
xusd
7 days ago d27794814b69d18aeb8ee96a46cae91d5613570c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-08-08 17:19:10
 * @LastEditTime: 2025-04-16 09:52:27
 * @LastEditors: lwh
 * @Version: 1.0.0
 * @Description: 导航栏页面
 */
import React from 'react';
import { MoreOutlined, LeftArrow2Outlined } from 'dd-icons';
import { useHistory, useLocation } from 'react-router-dom';
import './index.less';
import { getLocal, isDebug, showToast } from '../../utils/utility';
 
/**
 * title: string; 导航栏标题
 * leftContentVisible: bool; 是否显示导航栏左侧按钮
 * leftContentFunc: func; 导航栏左侧按钮方法
 * rightContentFunc: func; 导航栏右侧按钮方法
 * rightChildren: React.ReactNode; 导航栏右侧按钮内容
 * className: string, 导航栏背景颜色
 */
const NavBarPage = ({ children, title = '标题', leftContentVisible = true, leftContentFunc, rightContentFunc, rightChildren, className }) => {
    const history = useHistory();
 
    const location = useLocation();
 
    // 点击返回icon
    function handleClickBack() {
        if (!!leftContentFunc) {
            leftContentFunc();
        } else {
            // showToast({ content: '返回时提示' });
            history.goBack();
        }
    }
 
    return (
        <>
            <div className={`navBarPage-navbar ${className || ''}`}>
                {!!leftContentVisible && (
                    <div className="navBarPage-navbar-left" onClick={handleClickBack}>
                        <LeftArrow2Outlined />
                    </div>
                )}
                <div className="navBarPage-navbar-title">{title}</div>
                {!!rightContentFunc && (
                    <div onClick={rightContentFunc} className="navBarPage-navbar-right">
                        {rightChildren}
                    </div>
                )}
            </div>
            <div className="navBarPage-height" />
            {children}
        </>
    );
};
 
export default NavBarPage;