| | |
| | | import React from 'react'; |
| | | import { Footer, Question, SelectLang, AvatarDropdown, AvatarName, Brightness } from '@/components'; |
| | | import { Footer, Question, SelectLang, AvatarDropdown, AvatarName, Brightness, LayoutSwitch } from '@/components'; |
| | | import { LinkOutlined } from '@ant-design/icons'; |
| | | import { SettingDrawer } from '@ant-design/pro-components'; |
| | | import { history, Link } from '@umijs/max'; |
| | |
| | | return JSON.parse(localStorage.getItem('darkMode')) || true; |
| | | }); |
| | | |
| | | const [layoutMode, setLayoutMode] = React.useState(() => { |
| | | return JSON.parse(localStorage.getItem('layoutMode')) || true; |
| | | }); |
| | | |
| | | |
| | | React.useEffect(() => { |
| | | localStorage.setItem('darkMode', JSON.stringify(darkMode)); |
| | | }, [darkMode]); |
| | | localStorage.setItem('layoutMode', JSON.stringify(layoutMode)); |
| | | }, [darkMode, layoutMode]); |
| | | |
| | | return { |
| | | actionsRender: () => [ |
| | | <LayoutSwitch layoutMode={layoutMode} setLayoutMode={setLayoutMode} />, |
| | | <Brightness darkMode={darkMode} setDarkMode={setDarkMode} />, |
| | | // <Question key="doc" />, |
| | | // <SelectLang key="SelectLang" /> |
| | |
| | | ); |
| | | }, |
| | | ...initialState?.settings, |
| | | layout: 'top', // layout 的菜单模式,side:右侧导航,top:顶部导航 |
| | | layout: layoutMode ? 'top' : 'mix', // layout 的菜单模式,side:右侧导航,top:顶部导航 |
| | | // contentStyle: () => { // layout 的内容区 style |
| | | // return |
| | | // }, |
| | |
| | | import { QuestionCircleOutlined } from '@ant-design/icons'; |
| | | import { SelectLang as UmiSelectLang } from '@umijs/max'; |
| | | import React from 'react'; |
| | | import { MoonOutlined, BulbOutlined } from '@ant-design/icons'; |
| | | import { MoonOutlined, BulbOutlined, InsertRowAboveOutlined, InsertRowLeftOutlined } from '@ant-design/icons'; |
| | | |
| | | export const SelectLang = () => { |
| | | return ( |
| | |
| | | </div> |
| | | ); |
| | | }; |
| | | |
| | | export const LayoutSwitch = ({ layoutMode, setLayoutMode }) => { |
| | | const handleClick = () => { |
| | | setLayoutMode(!layoutMode); |
| | | }; |
| | | return ( |
| | | <div |
| | | style={{ |
| | | display: 'flex', |
| | | height: 26, |
| | | }} |
| | | onClick={handleClick} |
| | | > |
| | | {layoutMode ? <InsertRowAboveOutlined /> : <InsertRowLeftOutlined />} |
| | | </div> |
| | | ); |
| | | }; |
| | |
| | | * 布局组件 |
| | | */ |
| | | import Footer from './Footer'; |
| | | import { Question, SelectLang, Brightness } from './RightContent'; |
| | | import { Question, SelectLang, Brightness, LayoutSwitch } from './RightContent'; |
| | | import { AvatarDropdown, AvatarName } from './RightContent/AvatarDropdown'; |
| | | |
| | | export { Footer, Question, SelectLang, AvatarDropdown, AvatarName, Brightness }; |
| | | export { Footer, Question, SelectLang, AvatarDropdown, AvatarName, Brightness, LayoutSwitch }; |