feat: login done merge main

pull/1472/head
yikai 2 years ago
commit 2863fc5089

@ -5,6 +5,7 @@
"dependencies": {
"@ahooksjs/use-url-state": "^3.5.1",
"@ant-design/icons": "^5.2.6",
"@tanem/react-nprogress": "^5.0.51",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
@ -14,6 +15,7 @@
"dayjs": "^1.11.9",
"i18next": "^23.5.1",
"i18next-browser-languagedetector": "^7.1.0",
"lodash": "^4.17.21",
"qs": "^6.11.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
@ -51,6 +53,7 @@
"@craco/craco": "^7.1.0",
"@types/http-errors": "^2.0.1",
"@types/jest": "^27.5.2",
"@types/lodash": "^4.14.198",
"@types/node": "^16.18.26",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",

@ -1,7 +1,7 @@
import { DefaultTheme } from 'styled-components';
export const lightDefaultTheme: DefaultTheme = {
primary: '#0d68a8',
primary: '#1890ff',
baseColor: {
// 前两个是固定的,用于,有颜色按钮 字体颜色等固定不会变的颜色值
bc1: '#fff',

@ -0,0 +1,18 @@
import useUrlState from '@ahooksjs/use-url-state';
export const useUrlSet = (options: { form: any }) => {
const { form } = options;
const [state, setState] = useUrlState({});
const setUrl = () => {
const params = form.getFieldsValue();
Object.keys(params).forEach(key => {
if (!params[key]) {
params[key] = undefined;
}
});
setState({ ...params });
};
return { setUrl };
};

@ -0,0 +1,5 @@
.tenant_wrapper {
.opreate_btn {
padding: 0px;
}
}

@ -0,0 +1,120 @@
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col } from 'antd';
import { SearchOutlined, EditOutlined } from '@ant-design/icons';
import React, { useState } from 'react';
import { fetchItemList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less';
const baseColumns = [
{
title: '序号',
dataIndex: 'index',
},
{
title: '租户',
dataIndex: 'tenantId',
},
{
title: '项目名称',
dataIndex: 'itemName',
},
{
title: '负责人',
dataIndex: 'owner',
},
{
title: '修改时间',
dataIndex: 'gmtModified',
},
];
const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false);
const [type, setType] = useState('add');
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchItemList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const actions = (type: string, item?: any) => {
switch (type) {
case 'add':
setEditVisible(true);
break;
case 'edit':
setEditVisible(true);
break;
case 'delete':
// handleDelete();
break;
default:
break;
}
};
const handleSearch = () => {
setUrl();
search.submit();
};
// const handleDelete = (item: any) => {
// Modal.confirm({
// title: `此操作将删除${item.tenantName}, 是否继续?`,
// onOk: () => {
// search.submit();
// },
// });
// };
return (
<div className={style.tenant_wrapper}>
<Form form={form} wrapperCol={{ span: 23 }}>
<Row>
<Col span={6}>
<Form.Item name="note">
<Input placeholder="项目" />
</Form.Item>
</Col>
<Col span={18}>
<Space>
<Button onClick={() => handleSearch()} type="primary" icon={<SearchOutlined />}>
</Button>
<Button onClick={() => setEditVisible(true)} type="primary" icon={<EditOutlined />}>
</Button>
</Space>
</Col>
</Row>
<Row>
<Col span={6}></Col>
<Col span={18}></Col>
</Row>
</Form>
<Table
{...tableProps}
bordered
rowKey="index"
columns={[
...baseColumns,
{
title: '操作',
key: 'action',
render: (text: string, record: any) => {
return (
<Space>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
</Space>
);
},
},
]}
/>
</div>
);
};
export default Tenant;

@ -0,0 +1,8 @@
import { lazy } from 'react';
import { IRouterList } from '@/typings';
const ItemManage = lazy(() => import('./index'));
const routerList: IRouterList[] = [{ path: '/item', component: () => <ItemManage /> }];
export default routerList;

@ -0,0 +1,75 @@
import request from '@/utils';
const fetchItemList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/item/query/page', {
method: 'POST',
headers: {
Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ',
cookie:
'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
body: {
...formData,
current: pageProps.current,
size: pageProps.pageSize,
desc: true,
},
});
if (res && res.success) {
return {
total: res.data.total,
list: res.data.records.map((item: any, index: number) => ({ index: index + 1, ...item })),
};
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchAddTenant = async (params: {
itemDesc: string; // 项目简介
itemId: string; // 项目
itemName: string; // 项目名称
owner: string; // 负责人
tenantId: string; // 租户
tenantDesc?: string;
tenantName?: string;
}) => {
const res = await request('/hippo4j/v1/cs/tenant/save', {
method: 'POST',
body: { ...params },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchDeleteItem = async (id: string) => {
const url = 'hippo4j/v1/cs/item/delete/prescription/' + id;
const res = await request(url, {
method: 'DELETE',
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchUpdateItem = async (id: string) => {
const res = await request('/hippo4j/v1/cs/item/update', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
export { fetchItemList, fetchAddTenant, fetchDeleteItem, fetchUpdateItem };

@ -0,0 +1,5 @@
.tenant_wrapper {
.opreate_btn {
padding: 0px;
}
}

@ -0,0 +1,120 @@
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal } from 'antd';
import { SearchOutlined, EditOutlined } from '@ant-design/icons';
import React, { useState } from 'react';
import { fetchTenantList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less';
const baseColumns = [
{
title: '序号',
dataIndex: 'id',
},
{
title: '租户',
dataIndex: 'tenantId',
},
{
title: '租户名称',
dataIndex: 'tenantName',
},
{
title: '负责人',
dataIndex: 'owner',
},
{
title: '修改时间',
dataIndex: 'gmtModified',
},
];
const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false);
const [type, setType] = useState('add');
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchTenantList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const actions = (type: string, item?: any) => {
switch (type) {
case 'add':
setEditVisible(true);
break;
case 'edit':
setEditVisible(true);
break;
case 'delete':
// handleDelete();
break;
default:
break;
}
};
const handleSearch = () => {
setUrl();
search.submit();
};
// const handleDelete = (item: any) => {
// Modal.confirm({
// title: `此操作将删除${item.tenantName}, 是否继续?`,
// onOk: () => {
// search.submit();
// },
// });
// };
return (
<div className={style.tenant_wrapper}>
<Form form={form} wrapperCol={{ span: 23 }}>
<Row>
<Col span={6}>
<Form.Item name="note">
<Input placeholder="租户" />
</Form.Item>
</Col>
<Col span={18}>
<Space>
<Button onClick={() => handleSearch()} type="primary" icon={<SearchOutlined />}>
</Button>
<Button onClick={() => setEditVisible(true)} type="primary" icon={<EditOutlined />}>
</Button>
</Space>
</Col>
</Row>
<Row>
<Col span={6}></Col>
<Col span={18}></Col>
</Row>
</Form>
<Table
{...tableProps}
bordered
rowKey="id"
columns={[
...baseColumns,
{
title: '操作',
key: 'action',
render: (text: string, record: any) => {
return (
<Space>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
</Space>
);
},
},
]}
/>
</div>
);
};
export default Tenant;

@ -0,0 +1,8 @@
import { lazy } from 'react';
import { IRouterList } from '@/typings';
const LogManage = lazy(() => import('./index'));
const routerList: IRouterList[] = [{ path: '/log', component: () => <LogManage /> }];
export default routerList;

@ -0,0 +1,79 @@
import request from '@/utils';
const fetchTenantList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/tenant/query/page', {
method: 'POST',
headers: {
Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ',
cookie:
'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
body: {
...formData,
current: pageProps.current,
size: pageProps.pageSize,
desc: true,
},
});
if (res && res.success) {
return {
total: res.data.total,
list: res.data.records,
};
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchAddTenant = async (id: string) => {
const res = await request('/hippo4j/v1/cs/tenant/save', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchDeleteTenant = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchUpdateTenant = async (id: string) => {
const res = await request('hippo4j/v1/cs/tenant/update', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchTenantDetail = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
export { fetchTenantList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };

@ -0,0 +1,5 @@
.tenant_wrapper {
.opreate_btn {
padding: 0px;
}
}

@ -1,16 +1,20 @@
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col } from 'antd';
import React, { useState } from 'react';
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal } from 'antd';
import { SearchOutlined, EditOutlined } from '@ant-design/icons';
import { useUrlSet } from '@/hooks/useUrlSet';
import { fetchTenantList } from './service';
import style from './index.module.less';
const baseColumns = [
{
title: '序号',
dataIndex: 'num',
dataIndex: 'id',
},
{
title: '租户',
dataIndex: 'tenant',
dataIndex: 'tenantId',
},
{
title: '租户名称',
@ -18,53 +22,78 @@ const baseColumns = [
},
{
title: '负责人',
dataIndex: 'creator',
dataIndex: 'owner',
},
{
title: '修改时间',
dataIndex: 'data',
dataIndex: 'gmtModified',
},
];
const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false);
const [type, setType] = useState('add');
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchTenantList, { form });
const actions = (type: string) => {
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const actions = (type: string, item?: any) => {
switch (type) {
case 'create':
case 'add':
setEditVisible(true);
break;
case 'edit':
setEditVisible(true);
break;
case 'delete':
// handleDelete();
break;
default:
break;
}
};
const handleSearch = () => {
setUrl();
search.submit();
};
// const handleDelete = (item: any) => {
// Modal.confirm({
// title: `此操作将删除${item.tenantName}, 是否继续?`,
// onOk: () => {
// search.submit();
// },
// });
// };
return (
<div>
<Form>
<div className={style.tenant_wrapper}>
<Form form={form} wrapperCol={{ span: 23 }}>
<Row>
<Col span={6}>
<Form.Item name="note" rules={[{ required: true }]}>
<Form.Item name="note">
<Input placeholder="租户" />
</Form.Item>
</Col>
<Col span={18}>
<Space>
<Button onClick={() => search.submit()}></Button>
<Button onClick={() => setEditVisible(true)}></Button>
<Button onClick={() => handleSearch()} type="primary" icon={<SearchOutlined />}>
</Button>
<Button onClick={() => setEditVisible(true)} type="primary" icon={<EditOutlined />}>
</Button>
</Space>
</Col>
</Row>
<Row>
<Col span={6}></Col>
<Col span={18}></Col>
</Row>
</Form>
<Table
{...tableProps}
rowKey="num"
bordered
rowKey="id"
columns={[
...baseColumns,
{
@ -73,8 +102,12 @@ const Tenant: React.FC = () => {
render: (text: string, record: any) => {
return (
<Space>
<Button onClick={() => actions('edit')}></Button>
<Button onClick={() => actions('edit')}></Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
</Space>
);
},

@ -3,44 +3,77 @@ import request from '@/utils';
const fetchTenantList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
) => {
// mock request
return {
total: 3,
list: [
{
num: '1',
tenant: 'admin',
tenantName: 'admin',
creator: 'admin',
data: 'admin',
): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/tenant/query/page', {
method: 'POST',
headers: {
Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ',
cookie:
'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
],
body: {
...formData,
current: pageProps.current,
size: pageProps.pageSize,
desc: true,
},
});
if (res && res.success) {
return {
total: res.data.total,
list: res.data.records,
};
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchAddTenant = async (id: string) => {
const res = await request('/hippo4j/v1/cs/tenant/save', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchDeleteTenant = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: {
...formData,
pageNum: pageProps.current,
pageSize: pageProps.pageSize,
},
params: { id },
});
if (res && res.success) {
return {
total: 3,
list: [
{
num: '1',
tenant: 'admin',
tenantName: 'admin',
creator: 'admin',
data: 'admin',
},
],
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchUpdateTenant = async (id: string) => {
const res = await request('hippo4j/v1/cs/tenant/update', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchTenantDetail = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '接口异常');
throw new Error(res.msg || '服务器开小差啦~');
};
export { fetchTenantList };
export { fetchTenantList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };

@ -0,0 +1,5 @@
.tenant_wrapper {
.opreate_btn {
padding: 0px;
}
}

@ -0,0 +1,120 @@
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col } from 'antd';
import { SearchOutlined, EditOutlined } from '@ant-design/icons';
import React, { useState } from 'react';
import { fetchUserList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less';
const baseColumns = [
{
title: '序号',
dataIndex: 'index',
},
{
title: '用户名',
dataIndex: 'userName',
},
{
title: '角色',
dataIndex: 'role',
},
{
title: '创建时间',
dataIndex: 'gmtCreate',
},
{
title: '修改时间',
dataIndex: 'gmtModified',
},
];
const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false);
const [type, setType] = useState('add');
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchUserList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const actions = (type: string, item?: any) => {
switch (type) {
case 'add':
setEditVisible(true);
break;
case 'edit':
setEditVisible(true);
break;
case 'delete':
// handleDelete();
break;
default:
break;
}
};
const handleSearch = () => {
setUrl();
search.submit();
};
// const handleDelete = (item: any) => {
// Modal.confirm({
// title: `此操作将删除${item.tenantName}, 是否继续?`,
// onOk: () => {
// search.submit();
// },
// });
// };
return (
<div className={style.tenant_wrapper}>
<Form form={form} wrapperCol={{ span: 23 }}>
<Row>
<Col span={6}>
<Form.Item name="note">
<Input placeholder="用户名" />
</Form.Item>
</Col>
<Col span={18}>
<Space>
<Button onClick={() => handleSearch()} type="primary" icon={<SearchOutlined />}>
</Button>
<Button onClick={() => setEditVisible(true)} type="primary" icon={<EditOutlined />}>
</Button>
</Space>
</Col>
</Row>
<Row>
<Col span={6}></Col>
<Col span={18}></Col>
</Row>
</Form>
<Table
{...tableProps}
bordered
rowKey="index"
columns={[
...baseColumns,
{
title: '操作',
key: 'action',
render: (text: string, record: any) => {
return (
<Space>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
</Space>
);
},
},
]}
/>
</div>
);
};
export default Tenant;

@ -0,0 +1,8 @@
import { lazy } from 'react';
import { IRouterList } from '@/typings';
const UserManage = lazy(() => import('./index'));
const routerList: IRouterList[] = [{ path: '/user', component: () => <UserManage /> }];
export default routerList;

@ -0,0 +1,78 @@
import request from '@/utils';
const fetchUserList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/auth/users/page', {
method: 'POST',
headers: {
Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ',
cookie:
'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
body: {
...formData,
current: pageProps.current,
size: pageProps.pageSize,
},
});
if (res && res.success) {
return {
total: res.data.total,
list: res.data.records.map((item: any, index: number) => ({ index: index + 1, ...item })),
};
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchAddTenant = async (id: string) => {
const res = await request('/hippo4j/v1/cs/tenant/save', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchDeleteTenant = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchUpdateTenant = async (id: string) => {
const res = await request('hippo4j/v1/cs/tenant/update', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchTenantDetail = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
export { fetchUserList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };

@ -4,6 +4,9 @@ import aboutRouter from '@/page/about/router';
import ThreadPoolRouter from '@/page/thread-pool/router';
import tenantRouter from '@/page/tenant/router';
import LoginRouter from '@/page/login/router';
// import itemRouter from '@/page/item/router';
// import userRouter from '@/page/user/router';
// import logRouter from '@/page/log/router';
const routerList: IRouterList[] = [...homeRouter, ...aboutRouter, ...tenantRouter, ...ThreadPoolRouter, ...LoginRouter];
export default routerList;

@ -35,6 +35,8 @@ import Cookie from 'js-cookie';
// return null;
// }
// }
import _ from 'lodash';
// is plain object
const TokenKey = 'Admin-Token';
const isPlainObject = (obj: { [key: string]: any }): boolean => {
@ -50,4 +52,31 @@ const setToken = (token: string) => {
Cookie.set(TokenKey, token);
};
export { isPlainObject, setToken };
/**
* @description object value
* @param obj
* @returns
*/
const filterEmptyField = (obj: { [key: string]: any }) => {
return _.omitBy(obj, isEmpty);
};
/**
* @description
* @param value
* @returns
*/
const isNilValue = (value: any) => {
return value === undefined || value === '' || value === null || Number.isNaN(value);
};
/**
* @description /
* @param value
* @returns
*/
const isEmpty = (value: any) => {
return typeof value === 'object' ? _.isEmpty(value) : isNilValue(value);
};
export { isPlainObject, isEmpty, filterEmptyField, setToken };

@ -106,6 +106,7 @@ function request<T>(url: string, config: RequestOptions): Promise<Response<T>> {
method = method.toUpperCase();
responseType = responseType.toUpperCase();
config = {
...config,
method,
credentials,
responseType,
@ -115,6 +116,7 @@ function request<T>(url: string, config: RequestOptions): Promise<Response<T>> {
} else {
config.body = null;
}
return fetch(url, config as any).then(function onfulfilled(response) {
let { status, statusText } = response;
console.log('status:::', status, response);

@ -1196,7 +1196,7 @@
resolved "https://registry.npmmirror.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==
"@babel/runtime@^7.10.1", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.16.7", "@babel/runtime@^7.18.0", "@babel/runtime@^7.18.3", "@babel/runtime@^7.19.4", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.10.1", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.16.7", "@babel/runtime@^7.18.0", "@babel/runtime@^7.18.3", "@babel/runtime@^7.19.4", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.15", "@babel/runtime@^7.22.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
version "7.22.15"
resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.22.15.tgz#38f46494ccf6cf020bd4eed7124b425e83e523b8"
integrity sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==
@ -2060,6 +2060,14 @@
"@svgr/plugin-svgo" "^5.5.0"
loader-utils "^2.0.0"
"@tanem/react-nprogress@^5.0.51":
version "5.0.51"
resolved "https://registry.npmmirror.com/@tanem/react-nprogress/-/react-nprogress-5.0.51.tgz#6cbdb52a0a27ecf845f61d809ef6fd45b063662d"
integrity sha512-YxNUCpznuBVA+PhjEzFmxaa1czXgU+5Ojchw5JBK7DQS6SHIgNudpFohWpNBWMu2KWByGJ2OLH2OwbM/XyP18Q==
dependencies:
"@babel/runtime" "^7.22.15"
hoist-non-react-statics "^3.3.2"
"@testing-library/dom@^8.5.0":
version "8.20.1"
resolved "https://registry.npmmirror.com/@testing-library/dom/-/dom-8.20.1.tgz#2e52a32e46fc88369eef7eef634ac2a192decd9f"
@ -2332,6 +2340,11 @@
resolved "https://registry.npmmirror.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
"@types/lodash@^4.14.198":
version "4.14.198"
resolved "https://registry.npmmirror.com/@types/lodash/-/lodash-4.14.198.tgz#4d27465257011aedc741a809f1269941fa2c5d4c"
integrity sha512-trNJ/vtMZYMLhfN45uLq4ShQSw0/S7xCTLLVM+WM1rmFpba/VS42jVUgaO3w/NOLiWR/09lnYk0yMaA/atdIsg==
"@types/mime@*":
version "3.0.1"
resolved "https://registry.npmmirror.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10"
@ -5598,6 +5611,13 @@ he@^1.2.0:
resolved "https://registry.npmmirror.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.npmmirror.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
dependencies:
react-is "^16.7.0"
hoopy@^0.1.4:
version "0.1.4"
resolved "https://registry.npmmirror.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d"
@ -8996,7 +9016,7 @@ react-i18next@^13.2.2:
"@babel/runtime" "^7.22.5"
html-parse-stringify "^3.0.1"
react-is@^16.12.0, react-is@^16.13.1:
react-is@^16.12.0, react-is@^16.13.1, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.npmmirror.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

@ -1,76 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/runtime@^7.21.0":
version "7.22.15"
resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.22.15.tgz#38f46494ccf6cf020bd4eed7124b425e83e523b8"
integrity sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==
dependencies:
regenerator-runtime "^0.14.0"
"@types/js-cookie@^2.x.x":
version "2.2.7"
resolved "https://registry.npmmirror.com/@types/js-cookie/-/js-cookie-2.2.7.tgz#226a9e31680835a6188e887f3988e60c04d3f6a3"
integrity sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA==
ahooks-v3-count@^1.0.0:
version "1.0.0"
resolved "https://registry.npmmirror.com/ahooks-v3-count/-/ahooks-v3-count-1.0.0.tgz#ddeb392e009ad6e748905b3cbf63a9fd8262ca80"
integrity sha512-V7uUvAwnimu6eh/PED4mCDjE7tokeZQLKlxg9lCTMPhN+NjsSbtdacByVlR1oluXQzD3MOw55wylDmQo4+S9ZQ==
ahooks@^3.7.8:
version "3.7.8"
resolved "https://registry.npmmirror.com/ahooks/-/ahooks-3.7.8.tgz#3fa3c491cd153e884a32b0c4192fc72cf84c4332"
integrity sha512-e/NMlQWoCjaUtncNFIZk3FG1ImSkV/JhScQSkTqnftakRwdfZWSw6zzoWSG9OMYqPNs2MguDYBUFFC6THelWXA==
dependencies:
"@babel/runtime" "^7.21.0"
"@types/js-cookie" "^2.x.x"
ahooks-v3-count "^1.0.0"
dayjs "^1.9.1"
intersection-observer "^0.12.0"
js-cookie "^2.x.x"
lodash "^4.17.21"
resize-observer-polyfill "^1.5.1"
screenfull "^5.0.0"
tslib "^2.4.1"
dayjs@^1.9.1:
version "1.11.9"
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.9.tgz#9ca491933fadd0a60a2c19f6c237c03517d71d1a"
integrity sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==
intersection-observer@^0.12.0:
version "0.12.2"
resolved "https://registry.npmmirror.com/intersection-observer/-/intersection-observer-0.12.2.tgz#4a45349cc0cd91916682b1f44c28d7ec737dc375"
integrity sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==
js-cookie@^2.x.x:
version "2.2.1"
resolved "https://registry.npmmirror.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
regenerator-runtime@^0.14.0:
version "0.14.0"
resolved "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45"
integrity sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==
resize-observer-polyfill@^1.5.1:
version "1.5.1"
resolved "https://registry.npmmirror.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
screenfull@^5.0.0:
version "5.2.0"
resolved "https://registry.npmmirror.com/screenfull/-/screenfull-5.2.0.tgz#6533d524d30621fc1283b9692146f3f13a93d1ba"
integrity sha512-9BakfsO2aUQN2K9Fdbj87RJIEZ82Q9IGim7FqM5OsebfoFC6ZHXgDq/KvniuLTPdeM8wY2o6Dj3WQ7KeQCj3cA==
tslib@^2.4.1:
version "2.6.2"
resolved "https://registry.npmmirror.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
Loading…
Cancel
Save