lbq
13 小时以前 56ca28233a84c5aa3ca93cae266b2d008ea348e1
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
import * as React from 'react';
import { AppBar } from 'react-admin';
import { Box, useMediaQuery } from '@mui/material';
 
import Logo from './Logo';
import { AppBarToolbar } from './AppBarToolbar';
 
const CustomAppBar = () => {
    const isLargeEnough = useMediaQuery(theme =>
        theme.breakpoints.up('sm')
    );
    
    return (
        <AppBar
            color="secondary"
            toolbar={<AppBarToolbar />}
            sx={{
                // 隐藏最左侧的菜单按钮
                '& .RaAppBar-menuButton': {
                    display: 'none !important',
                },
                // 调整工具栏布局
                '& .RaAppBar-toolbar': {
                    paddingLeft: '4px !important', // 最小左边距
                    justifyContent: 'flex-start',
                    gap: 2, // 元素之间的间距
                }
            }}
        >
            {/* Logo 完全靠左 */}
            {isLargeEnough && (
                <Box sx={{ 
                    display: 'flex', 
                    alignItems: 'center',
                    minWidth: 'auto', // 不限制宽度
                }}>
                    <Logo />
                </Box>
            )}
            
            {/* 弹性空间将工具栏按钮推到右侧 */}
            <Box component="span" sx={{ flex: 1 }} />
        </AppBar>
    );
};
 
export default CustomAppBar;