fix: change router

dev
Dawn1Ocean 2024-03-31 21:21:22 +08:00
parent a0616d8fca
commit 6ea019a98f
9 changed files with 45 additions and 29 deletions

View File

@ -16,6 +16,8 @@ export default [
], ],
}, },
{ name: '查询表格', icon: 'table', path: '/list', component: './TableList' }, { name: '查询表格', icon: 'table', path: '/list', component: './TableList' },
{ name: '日志', icon: 'clockCircle', path: '/logs', component: './Logs' },
{ name: '关于我们', icon: 'thunderbolt', path: '/about', component: './About' },
{ path: '/', redirect: '/welcome' }, { path: '/', redirect: '/welcome' },
{ path: '*', layout: false, component: './404' }, { path: '*', layout: false, component: './404' },
]; ];

View File

@ -47,7 +47,7 @@
], ],
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.8.1", "@ant-design/icons": "^4.8.1",
"@ant-design/pro-components": "^2.6.48", "@ant-design/pro-components": "^2.7.0",
"@umijs/route-utils": "^2.2.2", "@umijs/route-utils": "^2.2.2",
"antd": "^5.13.2", "antd": "^5.13.2",
"antd-style": "^3.6.1", "antd-style": "^3.6.1",

View File

@ -1,4 +1,4 @@
import { AvatarDropdown, AvatarName, PageFooter, Question } from '@/components'; import { AvatarDropdown, AvatarName, PageFooter } from '@/components';
import { currentUser as queryCurrentUser } from '@/services/ant-design-pro/api'; import { currentUser as queryCurrentUser } from '@/services/ant-design-pro/api';
import { LinkOutlined } from '@ant-design/icons'; import { LinkOutlined } from '@ant-design/icons';
import type { Settings as LayoutSettings } from '@ant-design/pro-components'; import type { Settings as LayoutSettings } from '@ant-design/pro-components';
@ -49,7 +49,6 @@ export async function getInitialState(): Promise<{
// ProLayout 支持的api https://procomponents.ant.design/components/layout // ProLayout 支持的api https://procomponents.ant.design/components/layout
export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
return { return {
actionsRender: () => [<Question key="doc" />],
avatarProps: { avatarProps: {
src: initialState?.currentUser?.avatar, src: initialState?.currentUser?.avatar,
title: <AvatarName />, title: <AvatarName />,

View File

@ -1,18 +1,2 @@
import { QuestionCircleOutlined } from '@ant-design/icons';
import '@umijs/max'; import '@umijs/max';
export type SiderTheme = 'light' | 'dark'; export type SiderTheme = 'light' | 'dark';
export const Question = () => {
return (
<div
style={{
display: 'flex',
height: 26,
}}
onClick={() => {
window.open('https://pro.ant.design/docs/getting-started');
}}
>
<QuestionCircleOutlined />
</div>
);
};

View File

@ -0,0 +1,15 @@
import { Typography } from 'antd';
import React from 'react';
const { Title, Text } = Typography;
const Todo: React.FC = () => {
return (
<div>
<Title level={1}>...</Title>
<Text type={'secondary'}>{'// TODO'}</Text>
</div>
);
};
export default Todo;

View File

@ -6,6 +6,6 @@
* *
*/ */
import PageFooter from './Footer'; import PageFooter from './Footer';
import { Question } from './RightContent';
import { AvatarDropdown, AvatarName } from './RightContent/AvatarDropdown'; import { AvatarDropdown, AvatarName } from './RightContent/AvatarDropdown';
export { AvatarDropdown, AvatarName, PageFooter, Question }; import Todo from './Todo';
export { AvatarDropdown, AvatarName, PageFooter, Todo };

View File

View File

@ -0,0 +1,14 @@
import { Todo } from '@/components';
import { PageContainer } from '@ant-design/pro-components';
import { Card } from 'antd';
const Logs: React.FC = () => {
return (
<PageContainer>
<Card>
<Todo />
</Card>
</PageContainer>
);
};
export default Logs;

View File

@ -1,3 +1,4 @@
import Settings from '@/../config/defaultSettings';
import oidcLogo from '@/assets/oidc-logo.svg'; import oidcLogo from '@/assets/oidc-logo.svg';
import { PageFooter } from '@/components'; import { PageFooter } from '@/components';
import { login } from '@/services/ant-design-pro/api'; import { login } from '@/services/ant-design-pro/api';
@ -8,7 +9,6 @@ import { Alert, Button, Tabs, message } from 'antd';
import { createStyles } from 'antd-style'; import { createStyles } from 'antd-style';
import React, { CSSProperties, useState } from 'react'; import React, { CSSProperties, useState } from 'react';
import { flushSync } from 'react-dom'; import { flushSync } from 'react-dom';
import Settings from '../../../../config/defaultSettings';
const iconStyles: CSSProperties = { const iconStyles: CSSProperties = {
transform: 'translateY(-12%)', transform: 'translateY(-12%)',
@ -63,11 +63,6 @@ const LoginMessage: React.FC<{
/> />
); );
}; };
const generateLink = () => {
const preLink =
'https://auth.zjueva.net/connect/authorize?response_type=code&client_id=tea&redirect_uri=https://xms.zjueva.net/api/external_sign&scope=openid&state=';
return preLink + randomString(30);
};
const randomString = (length: number) => { const randomString = (length: number) => {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
@ -78,6 +73,13 @@ const randomString = (length: number) => {
} }
return randomStr; return randomStr;
}; };
const generateLink = () => {
const preLink =
'https://auth.zjueva.net/connect/authorize?response_type=code&client_id=ETA&redirect_uri=https://xms.zjueva.net/api/external_sign&scope=openid&state=';
return preLink + randomString(30);
};
const Login: React.FC = () => { const Login: React.FC = () => {
const [userLoginState, setUserLoginState] = useState<API.LoginResult>({}); const [userLoginState, setUserLoginState] = useState<API.LoginResult>({});
const [type, setType] = useState<string>('account'); const [type, setType] = useState<string>('account');
@ -87,7 +89,7 @@ const Login: React.FC = () => {
const userInfo = await initialState?.fetchUserInfo?.(); const userInfo = await initialState?.fetchUserInfo?.();
if (userInfo) { if (userInfo) {
flushSync(() => { flushSync(() => {
setInitialState((s) => ({ setInitialState((s: any) => ({
...s, ...s,
currentUser: userInfo, currentUser: userInfo,
})); }));
@ -143,7 +145,7 @@ const Login: React.FC = () => {
initialValues={{ initialValues={{
autoLogin: true, autoLogin: true,
}} }}
onFinish={async (values) => { onFinish={async (values: API.LoginParams) => {
await handleSubmit(values as API.LoginParams); await handleSubmit(values as API.LoginParams);
}} }}
> >