File tree Expand file tree Collapse file tree 5 files changed +429
-272
lines changed Expand file tree Collapse file tree 5 files changed +429
-272
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,16 @@ const chokidar = require('chokidar')
2
2
const bodyParser = require ( 'body-parser' )
3
3
const chalk = require ( 'chalk' )
4
4
const path = require ( 'path' )
5
- const Mock = require ( 'mockjs' )
6
5
const fs = require ( 'fs' )
7
6
8
7
const mockDir = path . join ( process . cwd ( ) , 'mock' )
9
8
10
- const responseFake = ( url , type , respond ) => {
9
+ const responseFake = ( url , type , response ) => {
11
10
return {
12
11
url : new RegExp ( `${ process . env . VUE_APP_BASE_API } ${ url } $` ) ,
13
12
// url: new RegExp(`/mock${url}$`),
14
13
type : type || 'get' ,
15
- response ( req , res ) {
16
- res . json ( Mock . mock ( respond instanceof Function ? respond ( req , res ) : respond ) )
17
- }
14
+ response
18
15
}
19
16
}
20
17
Original file line number Diff line number Diff line change @@ -15,17 +15,17 @@ module.exports = [
15
15
{
16
16
url : '/table/list' ,
17
17
type : 'get' ,
18
- response : config => {
18
+ response : ( req , res ) => {
19
19
const items = data . items
20
- return {
20
+ res . send ( {
21
21
data : {
22
22
total : items . length ,
23
23
items : items
24
24
} ,
25
25
code : 200 ,
26
26
msg : "成功" ,
27
27
success : true
28
- }
28
+ } )
29
29
}
30
30
}
31
31
]
Original file line number Diff line number Diff line change @@ -19,51 +19,45 @@ module.exports = [
19
19
{
20
20
url : '/session/login' ,
21
21
type : 'post' ,
22
- response : config => {
23
- const { mobile } = config . body
22
+ response : ( req , res ) => {
23
+ const { mobile } = req . body
24
24
const token = users [ mobile ]
25
-
26
- // mock error
27
- if ( ! token ) {
28
- return {
29
- code : 60204 ,
30
- message : 'Account and password are incorrect.'
31
- }
32
- }
33
-
34
- return {
25
+ res . send ( token ? {
35
26
code : 200 ,
36
27
data : token ,
37
28
msg : '成功' ,
38
29
success : true
39
- }
30
+ } : {
31
+ code : 60204 ,
32
+ message : 'Account and password are incorrect.'
33
+ } )
40
34
}
41
35
} ,
42
36
43
37
// user logout
44
38
{
45
39
url : '/session/logout' ,
46
40
type : 'post' ,
47
- response : _ => {
48
- return {
41
+ response : ( req , res ) => {
42
+ res . send ( {
49
43
code : 200 ,
50
44
data : true ,
51
45
msg : '成功' ,
52
46
success : true
53
- }
47
+ } )
54
48
}
55
49
} ,
56
50
57
51
{
58
52
url : '/session/sendCode' ,
59
53
type : 'post' ,
60
- response : _ => {
61
- return {
54
+ response : ( req , res ) => {
55
+ res . send ( {
62
56
code : 200 ,
63
57
data : true ,
64
58
msg : '成功' ,
65
59
success : true
66
- }
60
+ } )
67
61
}
68
62
}
69
63
]
Original file line number Diff line number Diff line change 39
39
"@vue/cli-plugin-eslint" : " ^4.1.0" ,
40
40
"@vue/cli-plugin-router" : " ^4.1.0" ,
41
41
"@vue/cli-plugin-vuex" : " ^4.1.0" ,
42
- "@vue/cli-service" : " ^4.1.0 " ,
42
+ "@vue/cli-service" : " ^4.4.4 " ,
43
43
"@vue/eslint-config-standard" : " ^4.0.0" ,
44
44
"babel-eslint" : " ^10.0.3" ,
45
45
"chalk" : " ^3.0.0" ,
You can’t perform that action at this time.
0 commit comments