|
|
@ -1,27 +1,26 @@
|
|
|
|
import { Outlet, Link, useHref, useNavigate, NavLink } from 'react-router-dom';
|
|
|
|
import { Outlet, Link, useHref, useNavigate, NavLink } from 'react-router-dom'
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { Layout, Menu, ConfigProvider, theme, Dropdown, Space, Row, Col, Badge, Typography, Modal, Input, Button, App as AntApp } from 'antd';
|
|
|
|
import { Layout, Menu, ConfigProvider, theme, Dropdown, Space, Row, Col, Badge, App as AntApp } from 'antd'
|
|
|
|
import { DownOutlined } from '@ant-design/icons';
|
|
|
|
import { DownOutlined } from '@ant-design/icons'
|
|
|
|
import 'antd/dist/reset.css';
|
|
|
|
import 'antd/dist/reset.css'
|
|
|
|
import AppLogo from '@/assets/logo-gh.png';
|
|
|
|
import AppLogo from '@/assets/logo-gh.png'
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import { isEmpty } from '@/utils/commons'
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import zhLocale from 'antd/locale/zh_CN';
|
|
|
|
import zhLocale from 'antd/locale/zh_CN'
|
|
|
|
import enLocale from 'antd/locale/en_US';
|
|
|
|
import enLocale from 'antd/locale/en_US'
|
|
|
|
import 'dayjs/locale/zh-cn';
|
|
|
|
import 'dayjs/locale/zh-cn'
|
|
|
|
import ErrorBoundary from '@/components/ErrorBoundary';
|
|
|
|
import ErrorBoundary from '@/components/ErrorBoundary'
|
|
|
|
import { BUILD_VERSION, } from '@/config';
|
|
|
|
import { BUILD_VERSION, } from '@/config'
|
|
|
|
import useNoticeStore from '@/stores/Notice';
|
|
|
|
import useNoticeStore from '@/stores/Notice'
|
|
|
|
import useAuthStore from '@/stores/Auth';
|
|
|
|
import useAuthStore from '@/stores/Auth'
|
|
|
|
import { useThemeContext } from '@/stores/ThemeContext';
|
|
|
|
import { useThemeContext } from '@/stores/ThemeContext'
|
|
|
|
import { usingStorage } from '@/hooks/usingStorage';
|
|
|
|
import { usingStorage } from '@/hooks/usingStorage'
|
|
|
|
import { useDefaultLgc } from '@/i18n/LanguageSwitcher';
|
|
|
|
import { useDefaultLgc } from '@/i18n/LanguageSwitcher'
|
|
|
|
import { appendRequestParams } from '@/utils/request'
|
|
|
|
import { appendRequestParams } from '@/utils/request'
|
|
|
|
|
|
|
|
|
|
|
|
import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT } from '@/config';
|
|
|
|
import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT } from '@/config'
|
|
|
|
|
|
|
|
|
|
|
|
const { Header, Content, Footer } = Layout;
|
|
|
|
const { Header, Content, Footer } = Layout
|
|
|
|
const { Title } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
function App() {
|
|
|
|
|
|
|
|
|
|
|
@ -29,10 +28,8 @@ function App() {
|
|
|
|
|
|
|
|
|
|
|
|
const { colorPrimary } = useThemeContext()
|
|
|
|
const { colorPrimary } = useThemeContext()
|
|
|
|
|
|
|
|
|
|
|
|
const [password, setPassword] = useState('')
|
|
|
|
const [isPermitted, currentUser] = useAuthStore(
|
|
|
|
|
|
|
|
(state) => [state.isPermitted, state.currentUser])
|
|
|
|
const [authenticate, tokenTimeout, isPermitted, currentUser] = useAuthStore(
|
|
|
|
|
|
|
|
(state) => [state.authenticate, state.tokenTimeout, state.isPermitted, state.currentUser])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { loginToken } = usingStorage()
|
|
|
|
const { loginToken } = usingStorage()
|
|
|
|
|
|
|
|
|
|
|
@ -48,15 +45,6 @@ function App() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [href])
|
|
|
|
}, [href])
|
|
|
|
|
|
|
|
|
|
|
|
const onSubmit = () => {
|
|
|
|
|
|
|
|
authenticate(currentUser?.username, password)
|
|
|
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
|
|
|
console.error(ex)
|
|
|
|
|
|
|
|
alert(t('Validation.LoginFailed'))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
setPassword('')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const splitPath = href.split('/')
|
|
|
|
const splitPath = href.split('/')
|
|
|
|
let defaultPath = 'notice'
|
|
|
|
let defaultPath = 'notice'
|
|
|
|
|
|
|
|
|
|
|
@ -64,11 +52,11 @@ function App() {
|
|
|
|
defaultPath = splitPath[1]
|
|
|
|
defaultPath = splitPath[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { language } = useDefaultLgc();
|
|
|
|
const { language } = useDefaultLgc()
|
|
|
|
const [antdLng, setAntdLng] = useState(enLocale);
|
|
|
|
const [antdLng, setAntdLng] = useState(enLocale)
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
setAntdLng(i18n.language === 'en' ? enLocale : zhLocale);
|
|
|
|
setAntdLng(i18n.language === 'en' ? enLocale : zhLocale)
|
|
|
|
appendRequestParams('lgc', language);
|
|
|
|
appendRequestParams('lgc', language)
|
|
|
|
}, [i18n.language])
|
|
|
|
}, [i18n.language])
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -83,25 +71,6 @@ function App() {
|
|
|
|
}}>
|
|
|
|
}}>
|
|
|
|
<AntApp>
|
|
|
|
<AntApp>
|
|
|
|
<ErrorBoundary>
|
|
|
|
<ErrorBoundary>
|
|
|
|
<Modal
|
|
|
|
|
|
|
|
centered
|
|
|
|
|
|
|
|
closable={false}
|
|
|
|
|
|
|
|
maskClosable={false}
|
|
|
|
|
|
|
|
footer={null}
|
|
|
|
|
|
|
|
open={tokenTimeout}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Title level={3}>{t('LoginTimeout')}</Title>
|
|
|
|
|
|
|
|
<div>{t('LoginTimeoutTip')}</div>
|
|
|
|
|
|
|
|
<Space direction='horizontal'>
|
|
|
|
|
|
|
|
<Input.Password value={password}
|
|
|
|
|
|
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
|
|
|
|
|
|
onPressEnter={onSubmit}
|
|
|
|
|
|
|
|
addonBefore={currentUser?.username} />
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
onClick={onSubmit}
|
|
|
|
|
|
|
|
>{t('Submit')}</Button></Space>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
<Layout className='min-h-screen'>
|
|
|
|
<Layout className='min-h-screen'>
|
|
|
|
<Header className='sticky top-0 z-10 w-full'>
|
|
|
|
<Header className='sticky top-0 z-10 w-full'>
|
|
|
|
<Row gutter={{ md: 24 }} justify='end' align='middle'>
|
|
|
|
<Row gutter={{ md: 24 }} justify='end' align='middle'>
|
|
|
|