Commit c9673388 by 周志凯

feat: add system api

1 parent 18790a5d
...@@ -53,10 +53,12 @@ ...@@ -53,10 +53,12 @@
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^8.3.5", "@commitlint/cli": "^8.3.5",
"antd": "^4.3.1", "antd": "^4.3.1",
"axios": "^0.19.2",
"commitlint-config-cz": "^0.13.1", "commitlint-config-cz": "^0.13.1",
"conventional-changelog": "^3.1.21", "conventional-changelog": "^3.1.21",
"customize-cra": "^1.0.0", "customize-cra": "^1.0.0",
"cz-customizable": "^6.2.0", "cz-customizable": "^6.2.0",
"http-proxy-middleware": "^1.0.4",
"husky": "^4.2.5", "husky": "^4.2.5",
"less": "^3.11.2", "less": "^3.11.2",
"less-loader": "^6.1.0", "less-loader": "^6.1.0",
......
import React, { FC } from 'react'; import React, { FC } from 'react';
import { HashRouter as Router, Route } from 'react-router-dom'; import { BrowserRouter as Router, Route } from 'react-router-dom';
import PageLayout from './layouts/PageLayout'; import PageLayout from './layouts/PageLayout';
import Login from './pages/Login'; import Login from './pages/Login';
......
import axios from 'axios';
import { message as $message } from 'antd';
const Service = axios.create({
baseURL: '/api',
timeout: 6000,
});
Service.interceptors.request.use(
config => {
const aToken = sessionStorage.getItem('aToken') || 'bearer 07a2814e-edc2-4ced-b675-469ec3e08242';
aToken && (config.headers.Authorization = aToken);
return config;
},
error => {
Promise.reject(error);
}
);
Service.interceptors.response.use(
(response: any) => {
const res = response.data;
if (res.code === 0 || res.success) {
return Promise.resolve(res);
} else {
// if (res.code === 400 || res.code === 401) {
$message.error(res.message);
// return
// } else {
return Promise.reject(res.message);
// }
}
},
error => {
Promise.reject(error);
}
);
export default Service;
import request from './request';
const SystemApiUrl = '/oauthSystems/';
interface queryParameter {
page?: number
pageSize?: number
}
interface createData {
name: string
description: string
}
/**
* 获取系统列表
*/
export const getSystemList = (query?: queryParameter) => {
return request({
url: SystemApiUrl,
method: 'get',
params: query
})
}
/**
* 添加系统列表
*/
export const createSystem = (data: createData) => {
return request({
url: SystemApiUrl,
method: 'post',
data
})
}
/**
* 删除系统
*/
export const deleteSystem = (id: string) => {
return request({
url: SystemApiUrl,
method: 'delete'
})
}
...@@ -4,4 +4,8 @@ ...@@ -4,4 +4,8 @@
background: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.3);
margin: 16px 28px 16px 0; margin: 16px 28px 16px 0;
float: left; float: left;
}
\ No newline at end of file \ No newline at end of file
}
.site-layout-background {
background: #fff;
}
import React, { FC } from 'react'; import React, { FC, useState, useEffect, useCallback } from 'react';
import { Button, Table } from "antd";
import { ColumnProps } from "antd/es/table";
import { getSystemList } from "../../api/system.api";
interface SystemTableProp {
key: string
systemName: string
systemId: number
createTime: string | Date
}
const columns:ColumnProps<SystemTableProp>[] = [
{
title: '系统ID',
dataIndex: 'systemId',
key: 'systemId',
align: 'center',
},
{
title: '系统名称',
dataIndex: 'systemName',
key: 'systemName',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
},
];
const data: SystemTableProp[] = [
{
key: '1',
systemName: 'John Brown',
systemId: 32,
createTime: '2020-05-27 12:47:33',
},
{
key: '2',
systemName: 'Jim Green',
systemId: 32,
createTime: '2020-05-27 12:47:33',
},
{
key: '3',
systemName: 'Joe Black',
systemId: 32,
createTime: '2020-05-27 12:47:33',
},
];
interface SystemSettingProp {} interface SystemSettingProp {}
const SystemSetting: FC<SystemSettingProp> = () => (<div>SystemSetting</div>) const SystemSetting: FC<SystemSettingProp> = () => {
const initData = useCallback(async () => {
try {
const data = await getSystemList()
console.log('initData', data)
} catch (error) {
console.error(error)
}
}, [])
useEffect(() => {
initData()
}, [initData])
return (
<div>
<Button type="primary">添加系统</Button>
<Table columns={columns} dataSource={data} />
</div>
)
}
export default SystemSetting; export default SystemSetting;
...@@ -23,19 +23,19 @@ const routes: RouteListProp[] = [ ...@@ -23,19 +23,19 @@ const routes: RouteListProp[] = [
{ {
name: '系统设置', name: '系统设置',
key: 'SystemSetting', key: 'SystemSetting',
path: 'system-setting', path: '/system-setting',
component: SystemSetting component: SystemSetting
}, },
{ {
name: '菜单管理', name: '菜单管理',
key: 'MenuManage', key: 'MenuManage',
path: 'menu-manage', path: '/menu-manage',
component: MenuManage component: MenuManage
}, },
{ {
name: '应用设置', name: '应用设置',
key: 'AppSetting', key: 'AppSetting',
path: 'app-setting', path: '/app-setting',
component: AppSetting component: AppSetting
} }
] ]
......
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = (app) => {
app.use(
createProxyMiddleware('/api', {
target: `http://192.168.9.115:8080`,
changeOrigin: true
})
)
}
...@@ -1526,6 +1526,12 @@ ...@@ -1526,6 +1526,12 @@
version "4.7.6" version "4.7.6"
resolved "https://registry.npm.taobao.org/@types/history/download/@types/history-4.7.6.tgz#ed8fc802c45b8e8f54419c2d054e55c9ea344356" resolved "https://registry.npm.taobao.org/@types/history/download/@types/history-4.7.6.tgz#ed8fc802c45b8e8f54419c2d054e55c9ea344356"
"@types/http-proxy@^1.17.4":
version "1.17.4"
resolved "https://registry.npm.taobao.org/@types/http-proxy/download/@types/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b"
dependencies:
"@types/node" "*"
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0":
version "2.0.2" version "2.0.2"
resolved "https://registry.npm.taobao.org/@types/istanbul-lib-coverage/download/@types/istanbul-lib-coverage-2.0.2.tgz#79d7a78bad4219f4c03d6557a1c72d9ca6ba62d5" resolved "https://registry.npm.taobao.org/@types/istanbul-lib-coverage/download/@types/istanbul-lib-coverage-2.0.2.tgz#79d7a78bad4219f4c03d6557a1c72d9ca6ba62d5"
...@@ -2228,6 +2234,12 @@ aws4@^1.8.0: ...@@ -2228,6 +2234,12 @@ aws4@^1.8.0:
version "1.10.0" version "1.10.0"
resolved "https://registry.npm.taobao.org/aws4/download/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2" resolved "https://registry.npm.taobao.org/aws4/download/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2"
axios@^0.19.2:
version "0.19.2"
resolved "https://registry.npm.taobao.org/axios/download/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
dependencies:
follow-redirects "1.5.10"
axobject-query@^2.0.2: axobject-query@^2.0.2:
version "2.1.2" version "2.1.2"
resolved "https://registry.npm.taobao.org/axobject-query/download/axobject-query-2.1.2.tgz#2bdffc0371e643e5f03ba99065d5179b9ca79799" resolved "https://registry.npm.taobao.org/axobject-query/download/axobject-query-2.1.2.tgz#2bdffc0371e643e5f03ba99065d5179b9ca79799"
...@@ -2492,7 +2504,7 @@ braces@^2.3.1, braces@^2.3.2: ...@@ -2492,7 +2504,7 @@ braces@^2.3.1, braces@^2.3.2:
split-string "^3.0.2" split-string "^3.0.2"
to-regex "^3.0.1" to-regex "^3.0.1"
braces@~3.0.2: braces@^3.0.1, braces@~3.0.2:
version "3.0.2" version "3.0.2"
resolved "https://registry.npm.taobao.org/braces/download/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" resolved "https://registry.npm.taobao.org/braces/download/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
dependencies: dependencies:
...@@ -3671,6 +3683,12 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9: ...@@ -3671,6 +3683,12 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
dependencies: dependencies:
ms "2.0.0" ms "2.0.0"
debug@=3.1.0:
version "3.1.0"
resolved "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
ms "2.0.0"
debug@^3.0.0, debug@^3.1.1, debug@^3.2.5: debug@^3.0.0, debug@^3.1.1, debug@^3.2.5:
version "3.2.6" version "3.2.6"
resolved "https://registry.npm.taobao.org/debug/download/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" resolved "https://registry.npm.taobao.org/debug/download/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
...@@ -4641,6 +4659,12 @@ flush-write-stream@^1.0.0: ...@@ -4641,6 +4659,12 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3" inherits "^2.0.3"
readable-stream "^2.3.6" readable-stream "^2.3.6"
follow-redirects@1.5.10:
version "1.5.10"
resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.10.tgz?cache=0&sync_timestamp=1585479417937&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
dependencies:
debug "=3.1.0"
follow-redirects@^1.0.0: follow-redirects@^1.0.0:
version "1.11.0" version "1.11.0"
resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.11.0.tgz?cache=0&sync_timestamp=1585479417937&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.11.0.tgz#afa14f08ba12a52963140fe43212658897bc0ecb" resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.11.0.tgz?cache=0&sync_timestamp=1585479417937&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.11.0.tgz#afa14f08ba12a52963140fe43212658897bc0ecb"
...@@ -5210,7 +5234,17 @@ http-proxy-middleware@0.19.1: ...@@ -5210,7 +5234,17 @@ http-proxy-middleware@0.19.1:
lodash "^4.17.11" lodash "^4.17.11"
micromatch "^3.1.10" micromatch "^3.1.10"
http-proxy@^1.17.0: http-proxy-middleware@^1.0.4:
version "1.0.4"
resolved "https://registry.npm.taobao.org/http-proxy-middleware/download/http-proxy-middleware-1.0.4.tgz?cache=0&sync_timestamp=1589915518285&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhttp-proxy-middleware%2Fdownload%2Fhttp-proxy-middleware-1.0.4.tgz#425ea177986a0cda34f9c81ec961c719adb6c2a9"
dependencies:
"@types/http-proxy" "^1.17.4"
http-proxy "^1.18.1"
is-glob "^4.0.1"
lodash "^4.17.15"
micromatch "^4.0.2"
http-proxy@^1.17.0, http-proxy@^1.18.1:
version "1.18.1" version "1.18.1"
resolved "https://registry.npm.taobao.org/http-proxy/download/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" resolved "https://registry.npm.taobao.org/http-proxy/download/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549"
dependencies: dependencies:
...@@ -6786,6 +6820,13 @@ micromatch@^3.1.10, micromatch@^3.1.4: ...@@ -6786,6 +6820,13 @@ micromatch@^3.1.10, micromatch@^3.1.4:
snapdragon "^0.8.1" snapdragon "^0.8.1"
to-regex "^3.0.2" to-regex "^3.0.2"
micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.npm.taobao.org/micromatch/download/micromatch-4.0.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmicromatch%2Fdownload%2Fmicromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"
miller-rabin@^4.0.0: miller-rabin@^4.0.0:
version "4.0.1" version "4.0.1"
resolved "https://registry.npm.taobao.org/miller-rabin/download/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" resolved "https://registry.npm.taobao.org/miller-rabin/download/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
...@@ -7592,7 +7633,7 @@ performance-now@^2.1.0: ...@@ -7592,7 +7633,7 @@ performance-now@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
picomatch@^2.0.4, picomatch@^2.2.1: picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1:
version "2.2.2" version "2.2.2"
resolved "https://registry.npm.taobao.org/picomatch/download/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" resolved "https://registry.npm.taobao.org/picomatch/download/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!