@@ -27,48 +27,78 @@ for (let i = 0; i < count; i++) {
27
27
} ) )
28
28
}
29
29
30
- export default {
31
- '/article/list' : config => {
32
- const { importance, type, title, page = 1 , limit = 20 , sort } = config . query
30
+ export default [
31
+ {
32
+ url : '/article/list' ,
33
+ type : 'get' ,
34
+ response : config => {
35
+ const { importance, type, title, page = 1 , limit = 20 , sort } = config . query
33
36
34
- let mockList = List . filter ( item => {
35
- if ( importance && item . importance !== + importance ) return false
36
- if ( type && item . type !== type ) return false
37
- if ( title && item . title . indexOf ( title ) < 0 ) return false
38
- return true
39
- } )
37
+ let mockList = List . filter ( item => {
38
+ if ( importance && item . importance !== + importance ) return false
39
+ if ( type && item . type !== type ) return false
40
+ if ( title && item . title . indexOf ( title ) < 0 ) return false
41
+ return true
42
+ } )
40
43
41
- if ( sort === '-id' ) {
42
- mockList = mockList . reverse ( )
43
- }
44
+ if ( sort === '-id' ) {
45
+ mockList = mockList . reverse ( )
46
+ }
44
47
45
- const pageList = mockList . filter ( ( item , index ) => index < limit * page && index >= limit * ( page - 1 ) )
48
+ const pageList = mockList . filter ( ( item , index ) => index < limit * page && index >= limit * ( page - 1 ) )
46
49
47
- return {
48
- total : mockList . length ,
49
- items : pageList
50
+ return {
51
+ total : mockList . length ,
52
+ items : pageList
53
+ }
50
54
}
51
55
} ,
52
- '/article/detail' : config => {
53
- const { id } = config . query
54
- for ( const article of List ) {
55
- if ( article . id === + id ) {
56
- return article
56
+
57
+ {
58
+ url : '/article/detail' ,
59
+ type : 'get' ,
60
+ response : config => {
61
+ const { id } = config . query
62
+ for ( const article of List ) {
63
+ if ( article . id === + id ) {
64
+ return article
65
+ }
57
66
}
58
67
}
59
68
} ,
60
- '/article/pv' : {
61
- pvData : [
62
- { key : 'PC' , pv : 1024 } ,
63
- { key : 'mobile' , pv : 1024 } ,
64
- { key : 'ios' , pv : 1024 } ,
65
- { key : 'android' , pv : 1024 }
66
- ]
69
+
70
+ {
71
+ url : '/article/pv' ,
72
+ type : 'get' ,
73
+ response : _ => {
74
+ return { pvData : [
75
+ { key : 'PC' , pv : 1024 } ,
76
+ { key : 'mobile' , pv : 1024 } ,
77
+ { key : 'ios' , pv : 1024 } ,
78
+ { key : 'android' , pv : 1024 }
79
+ ]
80
+ }
81
+ }
67
82
} ,
68
- '/article/create' : {
69
- data : 'success'
83
+
84
+ {
85
+ url : '/article/create' ,
86
+ type : 'post' ,
87
+ response : _ => {
88
+ return {
89
+ data : 'success'
90
+ }
91
+ }
70
92
} ,
71
- '/article/update' : {
72
- data : 'success'
93
+
94
+ {
95
+ url : '/article/update' ,
96
+ type : 'post' ,
97
+ response : _ => {
98
+ return {
99
+ data : 'success'
100
+ }
101
+ }
73
102
}
74
- }
103
+ ]
104
+
0 commit comments