Merge Request #8

Merged
Created by Adam

Master

Assignee: None
Milestone: None

Merged by Adam

Commits (2)
1 participants
... ... @@ -27,12 +27,18 @@ for (let i = 0; i < count; i++) {
27 27 }))
28 28 }
29 29  
30   -export default [
31   - {
32   - url: '/vue-element-admin/article/list',
  30 +export default [{
  31 + url: '/yp/article/list',
33 32 type: 'get',
34 33 response: config => {
35   - const { importance, type, title, page = 1, limit = 20, sort } = config.query
  34 + const {
  35 + importance,
  36 + type,
  37 + title,
  38 + page = 1,
  39 + limit = 20,
  40 + sort
  41 + } = config.query
36 42  
37 43 let mockList = List.filter(item => {
38 44 if (importance && item.importance !== +importance) return false
... ... @@ -58,10 +64,12 @@ export default [
58 64 },
59 65  
60 66 {
61   - url: '/vue-element-admin/article/detail',
  67 + url: '/yp/article/detail',
62 68 type: 'get',
63 69 response: config => {
64   - const { id } = config.query
  70 + const {
  71 + id
  72 + } = config.query
65 73 for (const article of List) {
66 74 if (article.id === +id) {
67 75 return {
... ... @@ -74,17 +82,28 @@ export default [
74 82 },
75 83  
76 84 {
77   - url: '/vue-element-admin/article/pv',
  85 + url: '/yp/article/pv',
78 86 type: 'get',
79 87 response: _ => {
80 88 return {
81 89 code: 20000,
82 90 data: {
83   - pvData: [
84   - { key: 'PC', pv: 1024 },
85   - { key: 'mobile', pv: 1024 },
86   - { key: 'ios', pv: 1024 },
87   - { key: 'android', pv: 1024 }
  91 + pvData: [{
  92 + key: 'PC',
  93 + pv: 1024
  94 + },
  95 + {
  96 + key: 'mobile',
  97 + pv: 1024
  98 + },
  99 + {
  100 + key: 'ios',
  101 + pv: 1024
  102 + },
  103 + {
  104 + key: 'android',
  105 + pv: 1024
  106 + }
88 107 ]
89 108 }
90 109 }
... ... @@ -92,7 +111,7 @@ export default [
92 111 },
93 112  
94 113 {
95   - url: '/vue-element-admin/article/create',
  114 + url: '/yp/article/create',
96 115 type: 'post',
97 116 response: _ => {
98 117 return {
... ... @@ -103,7 +122,7 @@ export default [
103 122 },
104 123  
105 124 {
106   - url: '/vue-element-admin/article/update',
  125 + url: '/yp/article/update',
107 126 type: 'post',
108 127 response: _ => {
109 128 return {
... ... @@ -113,4 +132,3 @@ export default [
113 132 }
114 133 }
115 134 ]
116   -
... ...
mock/remote-search.js
... ... @@ -13,7 +13,7 @@ NameList.push({ name: 'mock-Pan' })
13 13 export default [
14 14 // username search
15 15 {
16   - url: '/vue-element-admin/search/user',
  16 + url: '/yp/search/user',
17 17 type: 'get',
18 18 response: config => {
19 19 const { name } = config.query
... ... @@ -30,7 +30,7 @@ export default [
30 30  
31 31 // transaction list
32 32 {
33   - url: '/vue-element-admin/transaction/list',
  33 + url: '/yp/transaction/list',
34 34 type: 'get',
35 35 response: _ => {
36 36 return {
... ...
mock/role/index.js
... ... @@ -12,33 +12,45 @@ const roles = [
12 12 routes: routes
13 13 },
14 14 {
15   - key: 'editor',
16   - name: 'editor',
17   - description: 'Normal Editor. Can see all pages except permission page',
  15 + key: 'assistant',
  16 + name: 'assistant',
  17 + description: 'assistant Administrator. Can see all pages except permission page',
18 18 routes: routes.filter(i => i.path !== '/permission')// just a mock
19 19 },
20 20 {
21   - key: 'visitor',
22   - name: 'visitor',
23   - description: 'Just a visitor. Can only see the home page and the document page',
24   - routes: [{
25   - path: '',
26   - redirect: 'dashboard',
27   - children: [
28   - {
29   - path: 'dashboard',
30   - name: 'Dashboard',
31   - meta: { title: 'dashboard', icon: 'dashboard' }
32   - }
33   - ]
34   - }]
35   - }
  21 + key: 'runner',
  22 + name: 'runner',
  23 + description: 'Normal runner. Can see runner pages except permission page',
  24 + routes: routes.filter(i => i.path !== '/permission')// just a mock
  25 + },
  26 + {
  27 + key: 'shoper',
  28 + name: 'shoper',
  29 + description: 'Normal shoper. Can see shoper pages except permission page',
  30 + routes: routes.filter(i => i.path !== '/permission')// just a mock
  31 + },
  32 + // {
  33 + // key: 'visitor',
  34 + // name: 'visitor',
  35 + // description: 'Just a visitor. Can only see the home page and the document page',
  36 + // routes: [{
  37 + // path: '',
  38 + // redirect: 'dashboard',
  39 + // children: [
  40 + // {
  41 + // path: 'dashboard',
  42 + // name: 'Dashboard',
  43 + // meta: { title: 'dashboard', icon: 'dashboard' }
  44 + // }
  45 + // ]
  46 + // }]
  47 + // }
36 48 ]
37 49  
38 50 export default [
39 51 // mock get all routes form server
40 52 {
41   - url: '/vue-element-admin/routes',
  53 + url: '/yp/routes',
42 54 type: 'get',
43 55 response: _ => {
44 56 return {
... ... @@ -50,7 +62,7 @@ export default [
50 62  
51 63 // mock get all roles form server
52 64 {
53   - url: '/vue-element-admin/roles',
  65 + url: '/yp/roles',
54 66 type: 'get',
55 67 response: _ => {
56 68 return {
... ... @@ -62,7 +74,7 @@ export default [
62 74  
63 75 // add role
64 76 {
65   - url: '/vue-element-admin/role',
  77 + url: '/yp/role',
66 78 type: 'post',
67 79 response: {
68 80 code: 20000,
... ... @@ -74,7 +86,7 @@ export default [
74 86  
75 87 // update role
76 88 {
77   - url: '/vue-element-admin/role/[A-Za-z0-9]',
  89 + url: '/yp/role/[A-Za-z0-9]',
78 90 type: 'put',
79 91 response: {
80 92 code: 20000,
... ... @@ -86,7 +98,7 @@ export default [
86 98  
87 99 // delete role
88 100 {
89   - url: '/vue-element-admin/role/[A-Za-z0-9]',
  101 + url: '/yp/role/[A-Za-z0-9]',
90 102 type: 'delete',
91 103 response: {
92 104 code: 20000,
... ...
mock/role/routes.js
... ... @@ -23,13 +23,23 @@ export const constantRoutes = [
23 23 hidden: true
24 24 },
25 25 {
  26 + path: '/401',
  27 + component: 'views/error-page/401',
  28 + hidden: true
  29 + },
  30 + {
  31 + path: '/403',
  32 + component: 'views/error-page/403',
  33 + hidden: true
  34 + },
  35 + {
26 36 path: '/404',
27 37 component: 'views/error-page/404',
28 38 hidden: true
29 39 },
30 40 {
31   - path: '/401',
32   - component: 'views/error-page/401',
  41 + path: '/500',
  42 + component: 'views/error-page/500',
33 43 hidden: true
34 44 },
35 45 {
... ... @@ -73,49 +83,55 @@ export const constantRoutes = [
73 83 ]
74 84  
75 85 export const asyncRoutes = [
76   - {
77   - path: '/permission',
78   - component: 'layout/Layout',
79   - redirect: '/permission/index',
80   - alwaysShow: true,
81   - meta: {
82   - title: 'permission',
83   - icon: 'lock',
84   - roles: ['admin', 'editor']
85   - },
86   - children: [
87   - {
88   - path: 'page',
89   - component: 'views/permission/page',
90   - name: 'PagePermission',
91   - meta: {
92   - title: 'pagePermission',
93   - roles: ['admin']
94   - }
95   - },
96   - {
97   - path: 'directive',
98   - component: 'views/permission/directive',
99   - name: 'DirectivePermission',
100   - meta: {
101   - title: 'directivePermission'
102   - }
103   - },
104   - {
105   - path: 'role',
106   - component: 'views/permission/role',
107   - name: 'RolePermission',
108   - meta: {
109   - title: 'rolePermission',
110   - roles: ['admin']
111   - }
112   - }
113   - ]
114   - },
  86 + // {
  87 + // path: '/permission',
  88 + // component: 'layout/Layout',
  89 + // redirect: '/permission/index',
  90 + // alwaysShow: true,
  91 + // meta: {
  92 + // title: 'permission',
  93 + // icon: 'lock',
  94 + // // roles: ['admin', 'assistant', 'runner', 'shoper']
  95 + // },
  96 + // children: [
  97 + // {
  98 + // path: 'page',
  99 + // component: 'views/permission/page',
  100 + // name: 'PagePermission',
  101 + // meta: {
  102 + // title: 'pagePermission',
  103 + // roles: ['admin','assistant']
  104 + // }
  105 + // },
  106 + // {
  107 + // path: 'directive',
  108 + // component: 'views/permission/directive',
  109 + // name: 'DirectivePermission',
  110 + // meta: {
  111 + // title: 'directivePermission',
  112 + // roles:['shoper']
  113 + // }
  114 + // },
  115 + // {
  116 + // path: 'role',
  117 + // component: 'views/permission/role',
  118 + // name: 'RolePermission',
  119 + // meta: {
  120 + // title: 'rolePermission',
  121 + // roles: ['runner']
  122 + // }
  123 + // }
  124 + // ]
  125 + // },
115 126  
116 127 {
117 128 path: '/icon',
118 129 component: 'layout/Layout',
  130 + meta: {
  131 + title: 'ddddd',
  132 + icon:'people',
  133 + roles: ['runner']
  134 + },
119 135 children: [
120 136 {
121 137 path: 'index',
... ... @@ -379,6 +395,12 @@ export const asyncRoutes = [
379 395 component: 'views/error-page/404',
380 396 name: 'Page404',
381 397 meta: { title: 'page404', noCache: true }
  398 + },
  399 + {
  400 + path: '500',
  401 + component: 'views/error-page/500',
  402 + name: 'Page500',
  403 + meta: { title: 'page500', noCache: true }
382 404 }
383 405 ]
384 406 },
... ...
1 1  
  2 +import Mock from 'mockjs'
  3 +
2 4 const tokens = {
3 5 admin: {
4 6 token: 'admin-token'
5 7 },
6   - editor: {
7   - token: 'editor-token'
  8 + assistant: {
  9 + token: 'assistant-token'
  10 + },
  11 + runner: {
  12 + token: 'runner-token'
  13 + },
  14 + shoper: {
  15 + token: 'shoper-token'
8 16 }
9 17 }
10 18  
... ... @@ -15,18 +23,60 @@ const users = {
15 23 avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
16 24 name: 'Super Admin'
17 25 },
18   - 'editor-token': {
19   - roles: ['editor'],
20   - introduction: 'I am an editor',
  26 + 'assistant-token': {
  27 + roles: ['assistant'],
  28 + introduction: 'I am an assistant',
  29 + avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  30 + name: 'Normal assistant'
  31 + },
  32 + 'runner-token': {
  33 + roles: ['runner'],
  34 + introduction: 'I am an runner',
  35 + avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  36 + name: 'Normal runner'
  37 + },
  38 + 'shoper-token': {
  39 + roles: ['shoper'],
  40 + introduction: 'I am an shoper',
21 41 avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
22   - name: 'Normal Editor'
  42 + name: 'Normal shoper'
23 43 }
24 44 }
25 45  
  46 +const List = []
  47 +const count = 100
  48 +
  49 +const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
  50 +const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
  51 +
  52 +for (let i = 0; i < count; i++) {
  53 + List.push(Mock.mock({
  54 + uid: '@increment',
  55 + create_time: +Mock.Random.date('T'),
  56 + nickname: '@first',
  57 + reviewer: '@first',
  58 + title: '@title(5, 10)',
  59 + openid:'@sentence(12,12)',
  60 + content_short: 'mock data',
  61 + content: baseContent,
  62 + forecast: '@float(0, 100, 2, 2)',
  63 + importance: '@integer(1, 3)',
  64 + 'type|1': ['CN', 'US', 'JP', 'EU'],
  65 + 'status|1': ['published', 'draft'],
  66 + display_time: '@datetime',
  67 + comment_disabled: true,
  68 + son_of_adv: '@integer(300, 5000)',//下线
  69 + souceof:'@integer(300, 5000)',//源自
  70 + image_uri,
  71 + 'roles|1': ['admin', 'assistant', 'shoper', 'runner'],
  72 + platforms: ['a-platform']//哪个平台
  73 + }))
  74 +}
  75 +
26 76 export default [
27 77 // user login
28 78 {
29   - url: '/vue-element-admin/user/login',
  79 + url: '/yp/user/login',
30 80 type: 'post',
31 81 response: config => {
32 82 const { username } = config.body
... ... @@ -49,7 +99,7 @@ export default [
49 99  
50 100 // get user info
51 101 {
52   - url: '/vue-element-admin/user/info\.*',
  102 + url: '/yp/user/info\.*',
53 103 type: 'get',
54 104 response: config => {
55 105 const { token } = config.query
... ... @@ -72,7 +122,29 @@ export default [
72 122  
73 123 // user logout
74 124 {
75   - url: '/vue-element-admin/user/logout',
  125 + url: '/yp/user/logout',