Parcourir la source

不开启mockjs

木星 il y a 4 semaines
Parent
commit
144fb10712

+ 1 - 1
.env.base

@@ -22,7 +22,7 @@ VITE_APP_TITLE='灵客管理后台'
22 22
 VITE_USE_ALL_ELEMENT_PLUS_STYLE=true
23 23
 
24 24
 # 是否开启mock
25
-VITE_USE_MOCK=true
25
+VITE_USE_MOCK=false
26 26
 
27 27
 # 是否使用在线图标
28 28
 VITE_USE_ONLINE_ICON=true

+ 1 - 1
.env.gitee

@@ -29,7 +29,7 @@ VITE_USE_BUNDLE_ANALYZER=false
29 29
 VITE_USE_ALL_ELEMENT_PLUS_STYLE=false
30 30
 
31 31
 # 是否开启mock
32
-VITE_USE_MOCK=true
32
+VITE_USE_MOCK=false
33 33
 
34 34
 # 是否切割css
35 35
 VITE_USE_CSS_SPLIT=true

+ 1 - 1
.env.pro

@@ -36,7 +36,7 @@ VITE_USE_BUNDLE_ANALYZER=true
36 36
 VITE_USE_ALL_ELEMENT_PLUS_STYLE=false
37 37
 
38 38
 # 是否开启mock
39
-VITE_USE_MOCK=true
39
+VITE_USE_MOCK=false
40 40
 
41 41
 # 是否切割css
42 42
 VITE_USE_CSS_SPLIT=true

+ 0 - 18
mock/_createProductionServer.ts

@@ -1,18 +0,0 @@
1
-import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'
2
-
3
-const modules = import.meta.glob('./**/*.mock.ts', {
4
-  import: 'default',
5
-  eager: true
6
-})
7
-
8
-const mockModules: any[] = []
9
-Object.keys(modules).forEach(async (key) => {
10
-  if (key.includes('_')) {
11
-    return
12
-  }
13
-  mockModules.push(...(modules[key] as any))
14
-})
15
-
16
-export function setupProdMockServer() {
17
-  createProdMockServer(mockModules)
18
-}

+ 0 - 150
mock/role/index.mock.ts

@@ -1,150 +0,0 @@
1
-/*
2
- * @Author: 半生瓜 1515706227@qq.com
3
- * @Date: 2024-04-21 17:20:21
4
- * @LastEditors: 半生瓜 1515706227@qq.com
5
- * @LastEditTime: 2024-05-07 15:55:12
6
- * @FilePath: \vue-element-plus-admin-mini\mock\role\index.mock.ts
7
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
- */
9
-import { MockMethod } from 'vite-plugin-mock'
10
-import { SUCCESS_CODE } from '@/constants'
11
-
12
-const timeout = 1000
13
-
14
-const adminList = [
15
-  {
16
-    path: '/Template',
17
-    component: '#',
18
-    redirect: '/Template/TemplateManage',
19
-    name: 'Template',
20
-    meta: {
21
-      title: 'router.level',
22
-    },
23
-    children: [
24
-      {
25
-        path: 'TemplateManage',
26
-        name: 'TemplateManage',
27
-        component: 'views/Template/TemplateManage',
28
-        meta: {
29
-          title: '模板管理',
30
-          icon: 'ant-design:dashboard-filled',
31
-        }
32
-      }
33
-    ]
34
-  },
35
-  {
36
-    path: '/Resource',
37
-    component: '#',
38
-    redirect: '/Resource/ResourceManage',
39
-    name: 'Resource',
40
-    meta: {
41
-      title: 'router.level'
42
-    },
43
-    children: [
44
-      {
45
-        path: 'ResourceManage',
46
-        name: 'ResourceManage',
47
-        component: 'views/Resource/ResourceManage',
48
-        meta: {
49
-          title: '资源管理',
50
-          icon: 'carbon:skill-level-advanced'   
51
-        }
52
-      }
53
-    ]
54
-  },
55
-  {
56
-    path: '/Audit',
57
-    component: '#',
58
-    redirect: '/Audit/AuditManage',
59
-    name: 'Audit',
60
-    meta: {
61
-      title: '审核管理',
62
-    },
63
-    children: [
64
-      {
65
-        path: 'AuditManage',
66
-        name: 'AuditManage',
67
-        component: 'views/Audit/AuditManage',
68
-        meta: {
69
-          icon: 'ri:function-fill',
70
-          title: '审核管理'
71
-        }
72
-      }
73
-    ]
74
-  },
75
-  {
76
-    path: '/Authority',
77
-    component: '#',
78
-    redirect: '/Authority/AuditManage',
79
-    name: 'Authority',
80
-    meta: {
81
-      title: '权限管理',
82
-      icon: 'eos-icons:role-binding',
83
-    },
84
-    children: [
85
-      {
86
-        path: 'User',
87
-        name: 'User',
88
-        component: 'views/Authority/User',
89
-        meta: {
90
-          title: '用户管理'
91
-        }
92
-      },
93
-      {
94
-        path: 'Role',
95
-        name: 'Role',
96
-        component: 'views/Authority/Role',
97
-        meta: {
98
-          title: '角色管理'
99
-        }
100
-      },
101
-    ]
102
-  },
103
-  {
104
-    path: '/System',
105
-    component: '#',
106
-    redirect: '/System/SystemSetting',
107
-    name: 'System',
108
-    meta: {
109
-      title: '系统设置',
110
-    },
111
-    children: [
112
-      {
113
-        path: 'SystemSetting',
114
-        name: 'SystemSetting',
115
-        component: 'views/System/SystemSetting',
116
-        meta: {
117
-          icon: 'ic:outline-webhook',
118
-          title: '系统设置'
119
-        }
120
-      }
121
-    ]
122
-  }
123
-]
124
-
125
-const testList: string[] = [
126
-  '/level',
127
-  '/zy',
128
-  '/zy/Menu12',
129
-  '/level/menu1',
130
-  '/level/menu1/menu1-1',
131
-  '/level/menu1/menu1-1/menu1-1-1',
132
-  '/level/menu1/menu1-2',
133
-  '/level/menu2'
134
-]
135
-
136
-export default [
137
-  // 列表接口
138
-  {
139
-    url: '/mock/role/list',
140
-    method: 'get',
141
-    timeout,
142
-    response: ({ query }) => {
143
-      const { roleName } = query
144
-      return {
145
-        code: SUCCESS_CODE,
146
-        data: roleName === 'admin' ? adminList : testList
147
-      }
148
-    }
149
-  }
150
-] as MockMethod[]

+ 0 - 249
mock/table/index.mock.ts

@@ -1,249 +0,0 @@
1
-import Mock from 'mockjs'
2
-import { SUCCESS_CODE } from '@/constants'
3
-import { toAnyString } from '@/utils'
4
-
5
-const timeout = 1000
6
-const count = 100
7
-
8
-const baseContent =
9
-  '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
10
-
11
-interface ListProps {
12
-  id: string
13
-  author: string
14
-  title: string
15
-  content: string
16
-  importance: number
17
-  display_time: any
18
-  pageviews: number
19
-  image_uri: string
20
-  video_uri?: string
21
-}
22
-
23
-interface TreeListProps {
24
-  id: string
25
-  author: string
26
-  title: string
27
-  content: string
28
-  importance: number
29
-  display_time: any
30
-  image_uri: string
31
-  pageviews: number
32
-  video_uri?: string
33
-  children?: TreeListProps[]
34
-}
35
-
36
-let List: ListProps[] = []
37
-
38
-for (let i = 0; i < count; i++) {
39
-  List.push(
40
-    Mock.mock({
41
-      id: toAnyString(),
42
-      // timestamp: +Mock.Random.date('T'),
43
-      author: '@first',
44
-      title: '@title(5, 10)',
45
-      content: baseContent,
46
-      importance: '@integer(1, 3)',
47
-      display_time: '@datetime',
48
-      pageviews: '@integer(100, 500)',
49
-      image_uri: Mock.Random.image('@integer(100, 500)x@integer(100, 500)'),
50
-      video_uri:
51
-        '//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
52
-    })
53
-  )
54
-}
55
-
56
-const treeList: TreeListProps[] = []
57
-
58
-for (let i = 0; i < count; i++) {
59
-  treeList.push(
60
-    Mock.mock({
61
-      id: toAnyString(),
62
-      // timestamp: +Mock.Random.date('T'),
63
-      author: '@first',
64
-      title: '@title(5, 10)',
65
-      content: baseContent,
66
-      importance: '@integer(1, 3)',
67
-      display_time: '@datetime',
68
-      pageviews: '@integer(300, 5000)',
69
-      image_uri: Mock.Random.image('@integer(100, 500)x@integer(100, 500)'),
70
-      // image_uri
71
-    })
72
-  )
73
-}
74
-
75
-const cardList = [
76
-  {
77
-    logo: 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png',
78
-    name: 'Alipay',
79
-    desc: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。'
80
-  },
81
-  {
82
-    logo: 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png',
83
-    name: 'Angular',
84
-    desc: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。'
85
-  },
86
-  {
87
-    logo: 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png',
88
-    name: 'Bootstrap',
89
-    desc: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。'
90
-  },
91
-  {
92
-    logo: 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png',
93
-    name: 'React',
94
-    desc: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。'
95
-  },
96
-  {
97
-    logo: 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png',
98
-    name: 'Vue',
99
-    desc: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。'
100
-  },
101
-  {
102
-    logo: 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png',
103
-    name: 'Webpack',
104
-    desc: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。'
105
-  }
106
-]
107
-
108
-export default [
109
-  // 树形列表接口
110
-  {
111
-    url: '/mock/example/treeList',
112
-    method: 'get',
113
-    timeout,
114
-    response: ({ query }) => {
115
-      const { title, pageIndex, pageSize } = query
116
-      const mockList = treeList.filter((item) => {
117
-        if (title && item.title.indexOf(title) < 0) return false
118
-        return true
119
-      })
120
-      const pageList = mockList.filter(
121
-        (_, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)
122
-      )
123
-      return {
124
-        code: SUCCESS_CODE,
125
-        data: {
126
-          total: mockList.length,
127
-          list: pageList
128
-        }
129
-      }
130
-    }
131
-  },
132
-  // 列表接口
133
-  {
134
-    url: '/mock/example/list',
135
-    method: 'get',
136
-    timeout,
137
-    response: ({ query }) => {
138
-      const { title, pageIndex, pageSize } = query
139
-      const mockList = List.filter((item) => {
140
-        if (title && item.title.indexOf(title) < 0) return false
141
-        return true
142
-      })
143
-      const pageList = mockList.filter(
144
-        (_, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)
145
-      )
146
-      return {
147
-        code: SUCCESS_CODE,
148
-        data: {
149
-          total: mockList.length,
150
-          list: pageList
151
-        }
152
-      }
153
-    }
154
-  },
155
-  // 保存接口
156
-  {
157
-    url: '/mock/example/save',
158
-    method: 'post',
159
-    timeout,
160
-    response: ({ body }) => {
161
-      if (!body.id) {
162
-        List = [
163
-          Object.assign(body, {
164
-            id: toAnyString()
165
-          })
166
-        ].concat(List)
167
-        return {
168
-          code: SUCCESS_CODE,
169
-          data: 'success'
170
-        }
171
-      } else {
172
-        List.map((item) => {
173
-          if (item.id === body.id) {
174
-            for (const key in item) {
175
-              item[key] = body[key]
176
-            }
177
-          }
178
-        })
179
-        return {
180
-          code: SUCCESS_CODE,
181
-          data: 'success'
182
-        }
183
-      }
184
-    }
185
-  },
186
-  // 详情接口
187
-  {
188
-    url: '/mock/example/detail',
189
-    method: 'get',
190
-    response: ({ query }) => {
191
-      const { id } = query
192
-      for (const example of List) {
193
-        if (example.id === id) {
194
-          return {
195
-            code: SUCCESS_CODE,
196
-            data: example
197
-          }
198
-        }
199
-      }
200
-    }
201
-  },
202
-  // 删除接口
203
-  {
204
-    url: '/mock/example/delete',
205
-    method: 'post',
206
-    response: ({ body }) => {
207
-      const ids = body.ids
208
-      if (!ids) {
209
-        return {
210
-          code: 500,
211
-          message: '请选择需要删除的数据'
212
-        }
213
-      } else {
214
-        let i = List.length
215
-        while (i--) {
216
-          if (ids.indexOf(List[i].id) !== -1) {
217
-            List.splice(i, 1)
218
-          }
219
-        }
220
-        return {
221
-          code: SUCCESS_CODE,
222
-          data: 'success'
223
-        }
224
-      }
225
-    }
226
-  },
227
-  {
228
-    url: '/mock/card/list',
229
-    method: 'get',
230
-    timeout,
231
-    response: ({ query }) => {
232
-      const { name, pageIndex, pageSize } = query
233
-      const mockList = cardList.filter((item) => {
234
-        if (name && item.name.indexOf(name) < 0) return false
235
-        return true
236
-      })
237
-      const pageList = mockList.filter(
238
-        (_, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)
239
-      )
240
-      return {
241
-        code: SUCCESS_CODE,
242
-        data: {
243
-          total: mockList.length,
244
-          list: pageList
245
-        }
246
-      }
247
-    }
248
-  }
249
-]

+ 0 - 90
mock/user/index.mock.ts

@@ -1,90 +0,0 @@
1
-import { SUCCESS_CODE } from '@/constants'
2
-
3
-const timeout = 1000
4
-
5
-const List: {
6
-  username: string
7
-  password: string
8
-  role: string
9
-  roleId: string
10
-  permissions: string | string[]
11
-}[] = [
12
-  {
13
-    username: 'admin',
14
-    password: 'admin',
15
-    role: 'admin',
16
-    roleId: '1',
17
-    permissions: ['*.*.*']
18
-  },
19
-  {
20
-    username: 'test',
21
-    password: 'test',
22
-    role: 'test',
23
-    roleId: '2',
24
-    permissions: ['example:dialog:create', 'example:dialog:delete']
25
-  }
26
-]
27
-
28
-export default [
29
-  // 列表接口
30
-  {
31
-    url: '/mock/user/list',
32
-    method: 'get',
33
-    response: ({ query }) => {
34
-      const { username, pageIndex, pageSize } = query
35
-
36
-      const mockList = List.filter((item) => {
37
-        if (username && item.username.indexOf(username) < 0) return false
38
-        return true
39
-      })
40
-      const pageList = mockList.filter(
41
-        (_, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)
42
-      )
43
-
44
-      return {
45
-        code: SUCCESS_CODE,
46
-        data: {
47
-          total: mockList.length,
48
-          list: pageList
49
-        }
50
-      }
51
-    }
52
-  },
53
-  // 登录接口
54
-  {
55
-    url: '/mock/user/login',
56
-    method: 'post',
57
-    timeout,
58
-    response: ({ body }) => {
59
-      const data = body
60
-      let hasUser = false
61
-      for (const user of List) {
62
-        if (user.username === data.username && user.password === data.password) {
63
-          hasUser = true
64
-          return {
65
-            code: SUCCESS_CODE,
66
-            data: user
67
-          }
68
-        }
69
-      }
70
-      if (!hasUser) {
71
-        return {
72
-          code: 500,
73
-          message: '账号或密码错误'
74
-        }
75
-      }
76
-    }
77
-  },
78
-  // 退出接口
79
-  {
80
-    url: '/mock/user/loginOut',
81
-    method: 'get',
82
-    timeout,
83
-    response: () => {
84
-      return {
85
-        code: SUCCESS_CODE,
86
-        data: null
87
-      }
88
-    }
89
-  }
90
-]

+ 0 - 24
src/api/System/index.ts

@@ -9,18 +9,6 @@
9 9
 import request from '@/axios'
10 10
 import type { TableData } from './types'
11 11
 
12
-export const getTableListApi = (params: any) => {
13
-  return request.get({ url: '/mock/example/list', params })
14
-}
15
-
16
-export const getCardTableListApi = (params: any) => {
17
-  return request.get({ url: '/mock/card/list', params })
18
-}
19
-
20
-export const getTreeTableListApi = (params: any) => {
21
-  return request.get({ url: '/mock/example/treeList', params })
22
-}
23
-
24 12
 //查询全部产品配置参数接口
25 13
 export const getSystem = () => {
26 14
   return request.post({ url: '/config/manage/all' })
@@ -47,15 +35,3 @@ export const saveSystem = (params: any) => {
47 35
 export const deleteBulletin = (params: any) => {
48 36
   return request.post({ url: '/bulletin/manage/delete', params })
49 37
 }
50
-
51
-export const saveTableApi = (data: Partial<TableData>): Promise<IResponse> => {
52
-  return request.post({ url: '/mock/example/save', data })
53
-}
54
-
55
-export const getTableDetApi = (id: string): Promise<IResponse<TableData>> => {
56
-  return request.get({ url: '/mock/example/detail', params: { id } })
57
-}
58
-
59
-export const delTableListApi = (ids: string[] | number[]): Promise<IResponse> => {
60
-  return request.post({ url: '/mock/example/delete', data: { ids } })
61
-}

+ 0 - 8
src/api/login/index.ts

@@ -17,18 +17,10 @@ export const loginApi = (data): Promise<IResponse> => {
17 17
   return request.post({ url: '/jwt/token', data })
18 18
 }
19 19
 
20
-export const loginOutApi = (): Promise<IResponse> => {
21
-  return request.get({ url: '/mock/user/loginOut' })
22
-}
23
-
24 20
 export const getAdminRoleApi = (): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
25 21
   return request.post({ url: '/user/authList' })
26 22
 }
27 23
 
28
-export const getTestRoleApi = (params: RoleParams): Promise<IResponse<string[]>> => {
29
-  return request.get({ url: '/mock/role/list2', params })
30
-}
31
-
32 24
 export const getRsaKey = (): Promise<IResponse> => {
33 25
   return request.post({ url: '/encrypt/rsaKey' })
34 26
 }

+ 2 - 9
src/views/Login/components/LoginForm.vue

@@ -12,14 +12,7 @@ import { Form, FormSchema } from '@/components/Form'
12 12
 import { useI18n } from '@/hooks/web/useI18n'
13 13
 import { ElCheckbox, ElLink, ElMessage } from 'element-plus'
14 14
 import { useForm } from '@/hooks/web/useForm'
15
-import {
16
-  loginApi,
17
-  getRsaKey,
18
-  getTestRoleApi,
19
-  getAdminRoleApi,
20
-  getRefreshToken,
21
-  getuesrinfo
22
-} from '@/api/login'
15
+import { loginApi, getRsaKey, getAdminRoleApi, getRefreshToken, getuesrinfo } from '@/api/login'
23 16
 import { useAppStore } from '@/store/modules/app'
24 17
 import { usePermissionStore } from '@/store/modules/permission'
25 18
 import { useRouter } from 'vue-router'
@@ -271,7 +264,7 @@ const getRole = async () => {
271 264
   const res =
272 265
     appStore.getDynamicRouter && appStore.getServerDynamicRouter
273 266
       ? await getAdminRoleApi()
274
-      : await getTestRoleApi(params)
267
+      : await getAdminRoleApi()
275 268
   if (res) {
276 269
     if (res.data.length > 0) {
277 270
       console.log('kankan....', res.data)