tweak mock

This commit is contained in:
Pan 2019-03-20 11:00:54 +08:00
parent d927d4172f
commit 7c33568883
6 changed files with 59 additions and 29 deletions

View File

@ -48,7 +48,7 @@ export default [
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
return {
code: '20000',
code: 20000,
data: {
total: mockList.length,
items: pageList
@ -65,7 +65,7 @@ export default [
for (const article of List) {
if (article.id === +id) {
return {
code: '20000',
code: 20000,
data: article
}
}
@ -78,7 +78,7 @@ export default [
type: 'get',
response: _ => {
return {
code: '20000',
code: 20000,
data: {
pvData: [
{ key: 'PC', pv: 1024 },
@ -96,7 +96,7 @@ export default [
type: 'post',
response: _ => {
return {
code: '20000',
code: 20000,
data: 'success'
}
}
@ -107,7 +107,7 @@ export default [
type: 'post',
response: _ => {
return {
code: '20000',
code: 20000,
data: 'success'
}
}

View File

@ -22,7 +22,7 @@ export default [
return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
})
return {
code: '20000',
code: 20000,
data: { items: mockNameList }
}
}
@ -34,7 +34,7 @@ export default [
type: 'get',
response: _ => {
return {
code: '20000',
code: 20000,
data: {
total: 20,
'items|20': [{

View File

@ -36,33 +36,63 @@ const roles = [
]
export default [
// mock get all routes form server
{
url: '/routes',
type: 'get',
response: routes
response: _ => {
return {
code: 20000,
data: routes
}
}
},
// mock get all roles form server
{
url: '/roles',
type: 'get',
response: roles
},
{
url: '/roles/add',
type: 'post',
response: Mock.mock('@integer(300, 5000)')
},
{
url: '/roles/update/\/[A-Za-z0-9]',
type: 'put',
response: {
data: 'success'
response: _ => {
return {
code: 20000,
data: roles
}
}
},
// add role
{
url: '/roles/delete/\/[A-Za-z0-9]',
url: '/role',
type: 'post',
response: {
code: 20000,
data: {
key: Mock.mock('@integer(300, 5000)')
}
}
},
// update role
{
url: '/role/[A-Za-z0-9]',
type: 'put',
response: {
code: 20000,
data: {
status: 'success'
}
}
},
// delete role
{
url: '/role/[A-Za-z0-9]',
type: 'delete',
response: {
data: 'success'
code: 20000,
data: {
status: 'success'
}
}
}
]

View File

@ -31,7 +31,7 @@ export default [
response: config => {
const { username } = config.body
return {
code: '20000',
code: 20000,
data: tokens[username]
}
}
@ -44,7 +44,7 @@ export default [
response: config => {
const { token } = config.query
return {
code: '20000',
code: 20000,
data: users[token]
}
}
@ -56,7 +56,7 @@ export default [
type: 'post',
response: _ => {
return {
code: '20000',
code: 20000,
data: 'success'
}
}

View File

@ -16,7 +16,7 @@ export function getRoles() {
export function addRole(data) {
return request({
url: '/roles/add',
url: '/role',
method: 'post',
data
})
@ -24,7 +24,7 @@ export function addRole(data) {
export function updateRole(id, data) {
return request({
url: `/roles/update/${id}`,
url: `/role/${id}`,
method: 'put',
data
})
@ -32,7 +32,7 @@ export function updateRole(id, data) {
export function deleteRole(id) {
return request({
url: `/roles/delete/${id}`,
url: `/role/${id}`,
method: 'delete'
})
}

View File

@ -230,7 +230,7 @@ export default {
}
} else {
const { data } = await addRole(this.role)
this.role.key = data
this.role.key = data.key
this.rolesList.push(this.role)
}