fix: 点击logo回到首页
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
}
|
||||
height: var(--header-height);
|
||||
padding: 16px;
|
||||
cursor: pointer;
|
||||
|
||||
.icon {
|
||||
display: flex;
|
||||
|
||||
@@ -3,7 +3,8 @@ import { useAppSelector } from '@/app/hooks';
|
||||
import { SettingOutlined } from '@ant-design/icons';
|
||||
import { Button, Image, Popover } from '@toco-design/components';
|
||||
import classNames from 'classnames';
|
||||
import { useMemo } from 'react';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import styles from './index.module.css';
|
||||
import { HeaderOnly, HeaderSider, SiderOnly } from './layouts';
|
||||
import Settings from './settings';
|
||||
@@ -22,6 +23,7 @@ type LayoutProps = {
|
||||
const Layout: React.FC<LayoutProps> = (props) => {
|
||||
const { type: typeProp } = props;
|
||||
const theme = useAppSelector((state) => state.common.theme);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const Component = useMemo(() => {
|
||||
const type = typeProp ?? LayoutType.Default;
|
||||
@@ -37,6 +39,10 @@ const Layout: React.FC<LayoutProps> = (props) => {
|
||||
return HeaderSider;
|
||||
}, [typeProp]);
|
||||
|
||||
const gotoHome = useCallback(() => {
|
||||
navigate('/');
|
||||
}, [navigate]);
|
||||
|
||||
return (
|
||||
<SuspenseLayout>
|
||||
<Component
|
||||
@@ -45,6 +51,7 @@ const Layout: React.FC<LayoutProps> = (props) => {
|
||||
logo={
|
||||
<div
|
||||
className={classNames(styles.logo, { dark: theme === Theme.DARK })}
|
||||
onClick={gotoHome}
|
||||
>
|
||||
<Image
|
||||
className={styles.icon}
|
||||
|
||||
Reference in New Issue
Block a user