提交 77cce633 编写于 作者: KK's avatar KK

mock 数据调整

上级 9865b91f
...@@ -421,16 +421,16 @@ mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/fetch<#if (deds. ...@@ -421,16 +421,16 @@ mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/fetch<#if (deds.
let { headers } = config; let { headers } = config;
let xTotal = mockDatas.length; let xTotal = mockDatas.length;
let records: Array<any> = []; let records:any;
if (config.url.includes('page')) { if (config.url.includes('page')) {
let url = config.url; let url = config.url;
let xPage = url.split('page=')[1]; let xPage = url.split('page=')[1];
let xPerPage = url.split('size=')[1].split('&')[0]; let xPerPage = url.split('size=')[1].split('&')[0];
Object.assign(headers, { 'x-page': xPage + '', 'x-per-page': xPerPage + '', 'x-total': xTotal + '' }); Object.assign(headers, { 'x-page': xPage + '', 'x-per-page': xPerPage + '', 'x-total': xTotal + '' });
let start = xTotal - (xPage * xPerPage); let start = xTotal - (xPage * xPerPage);
records = mockDatas.slice(xPage * xPerPage, xPerPage); records = {records:mockDatas.slice(xPage * xPerPage, xPerPage)};
} else { } else {
records = [...mockDatas]; records = {records:[...mockDatas]};
} }
return [status, records, config.headers, config]; return [status, records, config.headers, config];
}); });
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册