refactor: remove redundant files

mgy
Dawn1Ocean 2024-04-17 19:43:45 +08:00
parent f5c6f75779
commit de5150b385
9 changed files with 29 additions and 1308 deletions

View File

@ -67,31 +67,13 @@ module.exports = {
data: conclusionlist, data: conclusionlist,
}, },
'GET /api/currentUser': { 'GET /api/currentUser': {
success: true,
data: { data: {
name: 'Serati Ma', name: 'Serati Ma',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
userid: '00000001', userid: '00000001',
email: 'antdesign@alipay.com',
signature: '海纳百川,有容乃大',
title: '交互专家',
group: '蚂蚁金服某某某事业群某某平台部某某技术部UED', group: '蚂蚁金服某某某事业群某某平台部某某技术部UED',
tags: [ access: 'admin',
{ key: '0', label: '很有想法的' },
{ key: '1', label: '专注设计' },
{ key: '2', label: '辣~' },
{ key: '3', label: '大长腿' },
{ key: '4', label: '川妹子' },
{ key: '5', label: '海纳百川' },
],
notifyCount: 12,
unreadCount: 11,
country: 'China',
geographic: {
province: { label: '浙江省', key: '330000' },
city: { label: '杭州市', key: '330100' },
},
address: '西湖区工专路 77 号',
phone: '0752-268888888',
}, },
}, },
'POST /api/login/outLogin': { data: {}, success: true }, 'POST /api/login/outLogin': { data: {}, success: true },

View File

@ -1,5 +0,0 @@
export default {
'/api/auth_routes': {
'/form/advanced-form': { authority: ['admin', 'user'] },
},
};

View File

@ -42,76 +42,11 @@ export default {
name: 'Serati Ma', name: 'Serati Ma',
avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png', avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
userid: '00000001', userid: '00000001',
email: 'antdesign@alipay.com',
signature: '海纳百川,有容乃大',
title: '交互专家',
group: '蚂蚁金服某某某事业群某某平台部某某技术部UED', group: '蚂蚁金服某某某事业群某某平台部某某技术部UED',
tags: [
{
key: '0',
label: '很有想法的',
},
{
key: '1',
label: '专注设计',
},
{
key: '2',
label: '辣~',
},
{
key: '3',
label: '大长腿',
},
{
key: '4',
label: '川妹子',
},
{
key: '5',
label: '海纳百川',
},
],
notifyCount: 12,
unreadCount: 11,
country: 'China',
access: getAccess(), access: getAccess(),
geographic: {
province: {
label: '浙江省',
key: '330000',
},
city: {
label: '杭州市',
key: '330100',
},
},
address: '西湖区工专路 77 号',
phone: '0752-268888888',
}, },
}); });
}, },
// GET POST 可省略
'GET /api/users': [
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
},
{
key: '3',
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park',
},
],
'POST /api/login/account': async (req: Request, res: Response) => { 'POST /api/login/account': async (req: Request, res: Response) => {
const { password, username, type } = req.body; const { password, username, type } = req.body;
await waitTime(2000); await waitTime(2000);

24
models/user.ts 100644
View File

@ -0,0 +1,24 @@
import { useCallback, useState } from 'react';
export default () => {
const [user, setUser] = useState({});
const [token, setToken] = useState('');
const setUserData = useCallback(
(name: string, avatar: string, group: number, title: number, access: string) => {
setUser({
name: name,
avatar: avatar,
group: group,
title: title,
access: access,
});
},
[],
);
const setTokenStr = useCallback((token: string) => {
setToken(token);
}, []);
return { user, setUserData, token, setTokenStr };
};

View File

@ -1,3 +1,5 @@
import { API } from './services/typings';
/** /**
* @see https://umijs.org/docs/max/access#access * @see https://umijs.org/docs/max/access#access
* */ * */

File diff suppressed because it is too large Load Diff

View File

@ -1,96 +0,0 @@
import { TestBrowser } from '@@/testBrowser';
import { act, fireEvent, render } from '@testing-library/react';
import React from 'react';
// @ts-ignore
import { startMock } from '@@/requestRecordMock';
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
let server: {
close: () => void;
};
describe('Login Page', () => {
beforeAll(async () => {
server = await startMock({
port: 8000,
scene: 'login',
});
});
afterAll(() => {
server?.close();
});
it('should show login form', async () => {
const historyRef = React.createRef<any>();
const rootContainer = render(
<TestBrowser
historyRef={historyRef}
location={{
pathname: '/user/login',
}}
/>,
);
await rootContainer.findAllByText('Ant Design');
act(() => {
historyRef.current?.push('/user/login');
});
expect(rootContainer.baseElement?.querySelector('.ant-pro-form-login-desc')?.textContent).toBe(
'Ant Design is the most influential web design specification in Xihu district',
);
expect(rootContainer.asFragment()).toMatchSnapshot();
rootContainer.unmount();
});
it('should login success', async () => {
const historyRef = React.createRef<any>();
const rootContainer = render(
<TestBrowser
historyRef={historyRef}
location={{
pathname: '/user/login',
}}
/>,
);
await rootContainer.findAllByText('Ant Design');
const userNameInput = await rootContainer.findByPlaceholderText('Username: admin or user');
act(() => {
fireEvent.change(userNameInput, { target: { value: 'admin' } });
});
const passwordInput = await rootContainer.findByPlaceholderText('Password: ant.design');
act(() => {
fireEvent.change(passwordInput, { target: { value: 'ant.design' } });
});
await (await rootContainer.findByText('Login')).click();
// 等待接口返回结果
await waitTime(5000);
await rootContainer.findAllByText('Ant Design Pro');
expect(rootContainer.asFragment()).toMatchSnapshot();
await waitTime(2000);
rootContainer.unmount();
});
});

View File

@ -33,7 +33,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
}); });
} }
/** 获取首页信息 GET /admin/stat */ /** 获取首页信息 GET /admin/stats */
export async function getStat(options?: { [key: string]: any }) { export async function getStat(options?: { [key: string]: any }) {
return request<{ return request<{
data: API.Stat; data: API.Stat;

View File

@ -5,21 +5,8 @@ declare namespace API {
name?: string; name?: string;
avatar?: string; avatar?: string;
userid?: string; userid?: string;
email?: string;
signature?: string;
title?: string;
group?: string; group?: string;
tags?: { key?: string; label?: string }[];
notifyCount?: number;
unreadCount?: number;
country?: string;
access?: string; access?: string;
geographic?: {
province?: { label?: string; key?: string };
city?: { label?: string; key?: string };
};
address?: string;
phone?: string;
}; };
type LoginResult = { type LoginResult = {