| | |
| | | import React from 'react'; |
| | | import { Footer, Question, SelectLang, AvatarDropdown, AvatarName, Brightness, LayoutSwitch } from '@/components'; |
| | | import { Footer, Question, SelectLang, AvatarDropdown, AvatarName, Brightness, LayoutSwitch, FullScreen } from '@/components'; |
| | | import { LinkOutlined } from '@ant-design/icons'; |
| | | import { SettingDrawer } from '@ant-design/pro-components'; |
| | | import { history, Link } from '@umijs/max'; |
| | |
| | | import { getRemoteMenu, getRoutersInfo, getUserInfo, setRemoteMenu, patchRouteWithRemoteMenus } from './services/route'; |
| | | import { getToken, setToken } from '@/utils/token-util' |
| | | import { TOKEN_HEADER_NAME, TOKEN_STORE_NAME } from '@/config/setting'; |
| | | import { API_BASE_URL } from '@/config/setting' |
| | | import { API_BASE_URL, API_TIMEOUT } from '@/config/setting' |
| | | import { message } from 'antd'; |
| | | |
| | | import logo from '../public/img/logo.png' |
| | |
| | | // 优先级 layout > config > defaultSetting |
| | | export const layout = ({ initialState, setInitialState }) => { |
| | | const [darkMode, setDarkMode] = React.useState(() => { |
| | | return JSON.parse(localStorage.getItem('darkMode')) || true; |
| | | const storedValue = localStorage.getItem('darkMode'); |
| | | return storedValue !== null ? JSON.parse(storedValue) : false; |
| | | }); |
| | | |
| | | const [layoutMode, setLayoutMode] = React.useState(() => { |
| | | return JSON.parse(localStorage.getItem('layoutMode')) || true; |
| | | const storedValue = localStorage.getItem('layoutMode'); |
| | | return storedValue !== null ? JSON.parse(storedValue) : true; |
| | | }); |
| | | |
| | | const [fullScreen, setFullScreen] = React.useState(false); |
| | | |
| | | React.useEffect(() => { |
| | | localStorage.setItem('darkMode', JSON.stringify(darkMode)); |
| | |
| | | |
| | | return { |
| | | actionsRender: () => [ |
| | | // <Question key="doc" />, |
| | | <SelectLang key="SelectLang" />, |
| | | <FullScreen fullScreen={fullScreen} setFullScreen={setFullScreen} />, |
| | | <LayoutSwitch layoutMode={layoutMode} setLayoutMode={setLayoutMode} />, |
| | | <Brightness darkMode={darkMode} setDarkMode={setDarkMode} />, |
| | | // <Question key="doc" />, |
| | | // <SelectLang key="SelectLang" /> |
| | | ], |
| | | avatarProps: { |
| | | src: initialState?.currentUser?.avatar, |
| | |
| | | export const request = { |
| | | baseURL: API_BASE_URL, |
| | | ...errorConfig, |
| | | timeout: 60000, |
| | | timeout: API_TIMEOUT * 1000, |
| | | // 前置守卫 |
| | | requestInterceptors: [ |
| | | (url, options) => { |