全局lint优化
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import Mock from 'mockjs';
|
||||
|
||||
|
||||
const List = [];
|
||||
const count = 20;
|
||||
import Mock from 'mockjs'
|
||||
|
||||
const List = []
|
||||
const count = 20
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
List.push(Mock.mock({
|
||||
@@ -13,7 +11,7 @@ for (let i = 0; i < count; i++) {
|
||||
author: '@cname',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
}));
|
||||
}))
|
||||
}
|
||||
|
||||
export default {
|
||||
@@ -34,4 +32,4 @@ export default {
|
||||
tags: [],
|
||||
title: ''
|
||||
})
|
||||
};
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import Mock from 'mockjs';
|
||||
import { param2Obj } from 'utils';
|
||||
import Mock from 'mockjs'
|
||||
import { param2Obj } from 'utils'
|
||||
|
||||
const List = [];
|
||||
const count = 100;
|
||||
const List = []
|
||||
const count = 100
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
List.push(Mock.mock({
|
||||
@@ -16,23 +16,23 @@ for (let i = 0; i < count; i++) {
|
||||
'type|1': ['CN', 'US', 'JP', 'EU'],
|
||||
'status|1': ['published', 'draft', 'deleted'],
|
||||
pageviews: '@integer(300, 5000)'
|
||||
}));
|
||||
}))
|
||||
}
|
||||
|
||||
export default {
|
||||
getList: config => {
|
||||
const { importance, type, title, page, limit, sort } = param2Obj(config.url);
|
||||
const { importance, type, title, page, limit, sort } = param2Obj(config.url)
|
||||
let mockList = List.filter(item => {
|
||||
if (importance && item.importance !== +importance) return false;
|
||||
if (type && item.type !== type) return false;
|
||||
if (title && item.title.indexOf(title) < 0) return false;
|
||||
return true;
|
||||
});
|
||||
if (importance && item.importance !== +importance) return false
|
||||
if (type && item.type !== type) return false
|
||||
if (title && item.title.indexOf(title) < 0) return false
|
||||
return true
|
||||
})
|
||||
if (sort === '-id') {
|
||||
mockList = mockList.reverse()
|
||||
}
|
||||
|
||||
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1));
|
||||
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
|
||||
return {
|
||||
total: mockList.length,
|
||||
items: pageList
|
||||
@@ -41,4 +41,4 @@ export default {
|
||||
getPv: () => ({
|
||||
pvData: [{ key: 'PC网站', pv: 1024 }, { key: 'mobile网站', pv: 1024 }, { key: 'ios', pv: 1024 }, { key: 'android', pv: 1024 }]
|
||||
})
|
||||
};
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { param2Obj } from 'utils';
|
||||
import { param2Obj } from 'utils'
|
||||
|
||||
const userMap = {
|
||||
admin: {
|
||||
@@ -26,16 +26,16 @@ const userMap = {
|
||||
|
||||
export default {
|
||||
loginByUsername: config => {
|
||||
const { username } = JSON.parse(config.body);
|
||||
return userMap[username];
|
||||
const { username } = JSON.parse(config.body)
|
||||
return userMap[username]
|
||||
},
|
||||
getInfo: config => {
|
||||
const { token } = param2Obj(config.url);
|
||||
const { token } = param2Obj(config.url)
|
||||
if (userMap[token]) {
|
||||
return userMap[token];
|
||||
return userMap[token]
|
||||
} else {
|
||||
return Promise.reject('error');
|
||||
return Promise.reject('error')
|
||||
}
|
||||
},
|
||||
logout: () => 'success'
|
||||
};
|
||||
}
|
||||
|
@@ -1,24 +1,24 @@
|
||||
import Mock from 'mockjs';
|
||||
import { param2Obj } from 'utils';
|
||||
import Mock from 'mockjs'
|
||||
import { param2Obj } from 'utils'
|
||||
|
||||
const NameList = [];
|
||||
const count = 100;
|
||||
const NameList = []
|
||||
const count = 100
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
NameList.push(Mock.mock({
|
||||
name: '@first'
|
||||
}));
|
||||
}))
|
||||
}
|
||||
NameList.push({ name: 'mockPan' })
|
||||
|
||||
export default {
|
||||
searchUser: config => {
|
||||
const { name } = param2Obj(config.url);
|
||||
const { name } = param2Obj(config.url)
|
||||
const mockNameList = NameList.filter(item => {
|
||||
const lowerCaseName = item.name.toLowerCase()
|
||||
if (name && lowerCaseName.indexOf(name.toLowerCase()) < 0) return false;
|
||||
return true;
|
||||
});
|
||||
if (name && lowerCaseName.indexOf(name.toLowerCase()) < 0) return false
|
||||
return true
|
||||
})
|
||||
return { items: mockNameList }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user