mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-21 06:53:47 +00:00
@@ -30,6 +30,7 @@ let usersListData = global[dataKey]
|
||||
module.exports = {
|
||||
|
||||
'GET /api/users' (req, res) {
|
||||
console.log(req, res)
|
||||
const page = qs.parse(req.query)
|
||||
const pageSize = page.pageSize || 10
|
||||
const currentPage = page.page || 1
|
||||
|
||||
@@ -59,8 +59,8 @@ class DataTable extends React.Component {
|
||||
const { fetch: { url, data, dataKey } } = this.props
|
||||
const { fetchData } = this.state
|
||||
this.setState({ loading: true })
|
||||
request(url, {
|
||||
result: 10,
|
||||
this.promise = request({
|
||||
url,
|
||||
data: {
|
||||
...data,
|
||||
...fetchData,
|
||||
|
||||
@@ -88,6 +88,10 @@ body {
|
||||
.ant-select-dropdown-menu-item {
|
||||
padding: 12px 16px !important;
|
||||
}
|
||||
|
||||
.margin-right {
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
@media (min-width: 1600px) {
|
||||
.ant-col-xl-48 {
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
width: 100%;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
||||
:global {
|
||||
.recharts-responsive-container {
|
||||
width: e("calc(100% + 56px)")!important;
|
||||
margin-left: -32px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
@@ -11,10 +18,3 @@
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
:global {
|
||||
.recharts-responsive-container {
|
||||
width: e("calc(100% + 56px)")!important;
|
||||
margin-left: -32px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,11 @@ const requestOptions = [
|
||||
id: 10,
|
||||
}),
|
||||
},
|
||||
{
|
||||
url: `${location.origin}/api/test`,
|
||||
desc: 'intercept request by mock.js',
|
||||
method: 'get',
|
||||
},
|
||||
{
|
||||
url: `${config.baseURL}/admin/order`,
|
||||
desc: 'cross-domain request, but match config.baseURL(./src/utils/config.js)',
|
||||
|
||||
@@ -7,4 +7,7 @@ module.exports = {
|
||||
needLogin: true,
|
||||
iconFontUrl: '//at.alicdn.com/t/font_c4y7asse3q1cq5mi.js',
|
||||
baseURL: 'http://47.92.30.98:7001/api',
|
||||
crossDomains: [
|
||||
'http://www.zuimeitianqi.com',
|
||||
],
|
||||
}
|
||||
|
||||
+13
-6
@@ -10,7 +10,7 @@ const fetch = (options) => {
|
||||
} = options
|
||||
switch (method.toLowerCase()) {
|
||||
case 'get':
|
||||
return axios.get(url, data)
|
||||
return axios.get(`${url}${options.data ? `?${qs.stringify(options.data)}` : ''}`)
|
||||
case 'delete':
|
||||
return axios.delete(url, { data })
|
||||
case 'head':
|
||||
@@ -28,17 +28,24 @@ const fetch = (options) => {
|
||||
|
||||
export default function request (options) {
|
||||
if (options.url.indexOf('//') > -1) {
|
||||
const origin = `${options.url.split('//')[0]}//${options.url.split('//')[1].split('/')[0]}`
|
||||
if (window.location.origin !== origin && config.baseURL.indexOf(origin) < 0) {
|
||||
if (config.crossDomains && config.crossDomains.indexOf(`${options.url.split('//')[0]}//${options.url.split('//')[1].split('/')[0]}`) > -1) {
|
||||
options.isCross = true
|
||||
options.url = `http://query.yahooapis.com/v1/public/yql?q=select * from json where url='${options.url}?${qs.stringify(options.data)}'&format=json`
|
||||
delete options.data
|
||||
}
|
||||
}
|
||||
|
||||
return fetch(options).then((response) => {
|
||||
return response.data
|
||||
const { statusText, status } = response
|
||||
let data = options.isCross ? response.data.query.results.json : response.data
|
||||
return {
|
||||
code: 0,
|
||||
status,
|
||||
message: statusText,
|
||||
...data,
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
return Promise.reject(error)
|
||||
const { response = { statusText: 'Network Error' } } = error
|
||||
return { code: 1, message: response.statusText }
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user