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