Browse Source

优化http请求

daxiongYang 7 years ago
parent
commit
2c5f864d4f
46 changed files with 544 additions and 885 deletions
  1. 0 19
      src/api/index.js
  2. 0 26
      src/api/modules/common.js
  3. 0 49
      src/api/modules/config.js
  4. 0 31
      src/api/modules/log.js
  5. 0 67
      src/api/modules/menu.js
  6. 0 44
      src/api/modules/oss.js
  7. 0 58
      src/api/modules/role.js
  8. 0 76
      src/api/modules/schedule.js
  9. 0 58
      src/api/modules/user.js
  10. 0 33
      src/api/request.js
  11. 0 21
      src/api/requestParam.js
  12. 0 8
      src/api/requestUrl.js
  13. 1 1
      src/assets/scss/index.scss
  14. 4 3
      src/main.js
  15. 2 2
      src/mock/index.js
  16. 1 1
      src/mock/modules/common.js
  17. 14 15
      src/router/index.js
  18. 75 0
      src/utils/http.js
  19. 0 0
      src/views/common/404.vue
  20. 0 0
      src/views/common/home.vue
  21. 11 9
      src/views/login/index.vue
  22. 0 0
      src/views/common/theme.vue
  23. 0 118
      src/views/layout/content-tabs.vue
  24. 0 92
      src/views/layout/index.vue
  25. 8 6
      src/views/layout/update-password.vue
  26. 6 3
      src/views/layout/navbar.vue
  27. 5 2
      src/views/layout/sidebar.vue
  28. 177 0
      src/views/main.vue
  29. 18 13
      src/views/schedule/add-or-update.vue
  30. 14 8
      src/views/schedule/log.vue
  31. 31 13
      src/views/schedule/index.vue
  32. 15 9
      src/views/oss/index.vue
  33. 10 3
      src/views/oss/config.vue
  34. 1 2
      src/views/oss/upload.vue
  35. 15 10
      src/views/config/add-or-update.vue
  36. 15 9
      src/views/config/index.vue
  37. 9 7
      src/views/log/index.vue
  38. 24 15
      src/views/menu/add-or-update.vue
  39. 11 4
      src/views/menu/index.vue
  40. 20 11
      src/views/role/add-or-update.vue
  41. 15 9
      src/views/role/index.vue
  42. 24 15
      src/views/user/add-or-update.vue
  43. 15 9
      src/views/user/index.vue
  44. 0 3
      src/views/sql/index.vue
  45. 2 2
      static/config/index.js
  46. 1 1
      static/config/init.js

+ 0 - 19
src/api/index.js

@ -1,19 +0,0 @@
1
import * as common from './modules/common'
2
import * as user from './modules/user'
3
import * as role from './modules/role'
4
import * as menu from './modules/menu'
5
import * as log from './modules/log'
6
import * as config from './modules/config'
7
import * as oss from './modules/oss'
8
import * as schedule from './modules/schedule'
9
10
export default {
11
  common,     // 公共
12
  user,       // 管理员管理
13
  role,       // 角色管理
14
  menu,       // 菜单管理
15
  log,        // 系统日志
16
  config,     // 参数管理
17
  oss,        // 文件服务
18
  schedule    // 定时任务
19
}

+ 0 - 26
src/api/modules/common.js

@ -1,26 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
5
// 获取验证码
6
export function captcha (uuid) {
7
  return requestUrl(`/captcha.jpg?uuid=${uuid}`)
8
}
9
10
// 登录
11
export function login (params) {
12
  return request({
13
    url: requestUrl('/sys/login'),
14
    method: 'post',
15
    data: requestParam(params)
16
  })
17
}
18
19
// 退出
20
export function logout () {
21
  return request({
22
    url: requestUrl('/sys/logout'),
23
    method: 'post',
24
    data: requestParam()
25
  })
26
}

+ 0 - 49
src/api/modules/config.js

@ -1,49 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
import isInteger from 'lodash/isInteger'
5
6
// 获取参数列表
7
export function list (params) {
8
  return request({
9
    url: requestUrl('/sys/config/list'),
10
    method: 'get',
11
    params: requestParam(params, 'get')
12
  })
13
}
14
15
// 获取参数信息
16
export function info (id) {
17
  return request({
18
    url: requestUrl('/sys/config/info' + (isInteger(id) ? `/${id}` : '')),
19
    method: 'get',
20
    params: requestParam({}, 'get')
21
  })
22
}
23
24
// 添加参数
25
export function add (params) {
26
  return request({
27
    url: requestUrl('/sys/config/save'),
28
    method: 'post',
29
    data: requestParam(params)
30
  })
31
}
32
33
// 修改参数
34
export function update (params) {
35
  return request({
36
    url: requestUrl('/sys/config/update'),
37
    method: 'post',
38
    data: requestParam(params)
39
  })
40
}
41
42
// 删除参数
43
export function del (params) {
44
  return request({
45
    url: requestUrl('/sys/config/delete'),
46
    method: 'post',
47
    data: requestParam(params, 'post', false)
48
  })
49
}

+ 0 - 31
src/api/modules/log.js

@ -1,31 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
import isInteger from 'lodash/isInteger'
5
6
// 获取日志列表
7
export function list (params) {
8
  return request({
9
    url: requestUrl('/sys/log/list'),
10
    method: 'get',
11
    params: requestParam(params, 'get')
12
  })
13
}
14
15
// 获取定时任务日志列表
16
export function scheduleList (params) {
17
  return request({
18
    url: requestUrl('/sys/scheduleLog/list'),
19
    method: 'get',
20
    params: requestParam(params, 'get')
21
  })
22
}
23
24
// 获取定时任务日志信息
25
export function scheduleInfo (id) {
26
  return request({
27
    url: requestUrl('/sys/scheduleLog/info' + (isInteger(id) ? `/${id}` : '')),
28
    method: 'get',
29
    params: requestParam({}, 'get')
30
  })
31
}

+ 0 - 67
src/api/modules/menu.js

@ -1,67 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
import isInteger from 'lodash/isInteger'
5
6
// 获取导航菜单列表 / 权限
7
export function nav () {
8
  return request({
9
    url: requestUrl('/sys/menu/nav'),
10
    method: 'get',
11
    params: requestParam({}, 'get')
12
  })
13
}
14
15
// 获取菜单列表
16
export function list () {
17
  return request({
18
    url: requestUrl('/sys/menu/list'),
19
    method: 'get',
20
    params: requestParam({}, 'get')
21
  })
22
}
23
24
// 获取上级菜单
25
export function select () {
26
  return request({
27
    url: requestUrl('/sys/menu/select'),
28
    method: 'get',
29
    params: requestParam({}, 'get')
30
  })
31
}
32
33
// 获取菜单信息
34
export function info (id) {
35
  return request({
36
    url: requestUrl('/sys/menu/info' + (isInteger(id) ? `/${id}` : '')),
37
    method: 'get',
38
    params: requestParam({}, 'get')
39
  })
40
}
41
42
// 添加菜单
43
export function add (params) {
44
  return request({
45
    url: requestUrl('/sys/menu/save'),
46
    method: 'post',
47
    data: requestParam(params)
48
  })
49
}
50
51
// 修改菜单
52
export function update (params) {
53
  return request({
54
    url: requestUrl('/sys/menu/update'),
55
    method: 'post',
56
    data: requestParam(params)
57
  })
58
}
59
60
// 删除菜单
61
export function del (id) {
62
  return request({
63
    url: requestUrl('/sys/menu/delete' + (isInteger(id) ? `/${id}` : '')),
64
    method: 'post',
65
    data: requestParam()
66
  })
67
}

+ 0 - 44
src/api/modules/oss.js

@ -1,44 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
5
// 获取文件列表
6
export function list (params) {
7
  return request({
8
    url: requestUrl('/sys/oss/list'),
9
    method: 'get',
10
    params: requestParam(params, 'get')
11
  })
12
}
13
14
// 获取云存储配置信息
15
export function config () {
16
  return request({
17
    url: requestUrl('/sys/oss/config'),
18
    method: 'get',
19
    params: requestParam({}, 'get')
20
  })
21
}
22
23
// 保存云存储配置信息
24
export function addConfig (params) {
25
  return request({
26
    url: requestUrl('/sys/oss/saveConfig'),
27
    method: 'post',
28
    data: requestParam(params)
29
  })
30
}
31
32
// 上传文件
33
export function upload (token) {
34
  return requestUrl(`/sys/oss/upload?token=${token}`)
35
}
36
37
// 删除文件
38
export function del (params) {
39
  return request({
40
    url: requestUrl('/sys/oss/delete'),
41
    method: 'post',
42
    data: requestParam(params, 'post', false)
43
  })
44
}

+ 0 - 58
src/api/modules/role.js

@ -1,58 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
import isInteger from 'lodash/isInteger'
5
6
// 获取角色列表
7
export function list (params) {
8
  return request({
9
    url: requestUrl('/sys/role/list'),
10
    method: 'get',
11
    params: requestParam(params, 'get')
12
  })
13
}
14
15
// 获取角色列表, 根据当前用户
16
export function select () {
17
  return request({
18
    url: requestUrl('/sys/role/select'),
19
    method: 'get',
20
    params: requestParam({}, 'get')
21
  })
22
}
23
24
// 获取角色信息
25
export function info (id) {
26
  return request({
27
    url: requestUrl('/sys/role/info' + (isInteger(id) ? `/${id}` : '')),
28
    method: 'get',
29
    params: requestParam({}, 'get')
30
  })
31
}
32
33
// 添加角色
34
export function add (params) {
35
  return request({
36
    url: requestUrl('/sys/role/save'),
37
    method: 'post',
38
    data: requestParam(params)
39
  })
40
}
41
42
// 修改角色
43
export function update (params) {
44
  return request({
45
    url: requestUrl('/sys/role/update'),
46
    method: 'post',
47
    data: requestParam(params)
48
  })
49
}
50
51
// 删除角色
52
export function del (params) {
53
  return request({
54
    url: requestUrl('/sys/role/delete'),
55
    method: 'post',
56
    data: requestParam(params, 'post', false)
57
  })
58
}

+ 0 - 76
src/api/modules/schedule.js

@ -1,76 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
import isInteger from 'lodash/isInteger'
5
6
// 获取定时任务列表
7
export function list (params) {
8
  return request({
9
    url: requestUrl('/sys/schedule/list'),
10
    method: 'get',
11
    params: requestParam(params, 'get')
12
  })
13
}
14
15
// 获取定时任务信息
16
export function info (id) {
17
  return request({
18
    url: requestUrl('/sys/schedule/info' + (isInteger(id) ? `/${id}` : '')),
19
    method: 'get',
20
    params: requestParam({}, 'get')
21
  })
22
}
23
24
// 添加定时任务
25
export function add (params) {
26
  return request({
27
    url: requestUrl('/sys/schedule/save'),
28
    method: 'post',
29
    data: requestParam(params)
30
  })
31
}
32
33
// 修改定时任务
34
export function update (params) {
35
  return request({
36
    url: requestUrl('/sys/schedule/update'),
37
    method: 'post',
38
    data: requestParam(params)
39
  })
40
}
41
42
// 删除定时任务
43
export function del (params) {
44
  return request({
45
    url: requestUrl('/sys/schedule/delete'),
46
    method: 'post',
47
    data: requestParam(params, 'post', false)
48
  })
49
}
50
51
// 运行定时任务
52
export function run (params) {
53
  return request({
54
    url: requestUrl('/sys/schedule/run'),
55
    method: 'post',
56
    data: requestParam(params, 'post', false)
57
  })
58
}
59
60
// 暂停定时任务
61
export function pause (params) {
62
  return request({
63
    url: requestUrl('/sys/schedule/pause'),
64
    method: 'post',
65
    data: requestParam(params, 'post', false)
66
  })
67
}
68
69
// 恢复定时任务
70
export function resume (params) {
71
  return request({
72
    url: requestUrl('/sys/schedule/resume'),
73
    method: 'post',
74
    data: requestParam(params, 'post', false)
75
  })
76
}

+ 0 - 58
src/api/modules/user.js

@ -1,58 +0,0 @@
1
import request from '../request'
2
import requestUrl from '../requestUrl'
3
import requestParam from '../requestParam'
4
import isInteger from 'lodash/isInteger'
5
6
// 获取用户列表
7
export function list (params) {
8
  return request({
9
    url: requestUrl('/sys/user/list'),
10
    method: 'get',
11
    params: requestParam(params, 'get')
12
  })
13
}
14
15
// 获取用户信息
16
export function info (id) {
17
  return request({
18
    url: requestUrl('/sys/user/info' + (isInteger(id) ? `/${id}` : '')),
19
    method: 'get',
20
    params: requestParam({}, 'get')
21
  })
22
}
23
24
// 修改密码
25
export function updatePassword (params) {
26
  return request({
27
    url: requestUrl('/sys/user/password'),
28
    method: 'post',
29
    data: requestParam(params)
30
  })
31
}
32
33
// 添加用户
34
export function add (params) {
35
  return request({
36
    url: requestUrl('/sys/user/save'),
37
    method: 'post',
38
    data: requestParam(params)
39
  })
40
}
41
42
// 修改用户
43
export function update (params) {
44
  return request({
45
    url: requestUrl('/sys/user/update'),
46
    method: 'post',
47
    data: requestParam(params)
48
  })
49
}
50
51
// 删除用户
52
export function del (params) {
53
  return request({
54
    url: requestUrl('/sys/user/delete'),
55
    method: 'post',
56
    data: requestParam(params, 'post', false)
57
  })
58
}

+ 0 - 33
src/api/request.js

@ -1,33 +0,0 @@
1
import Vue from 'vue'
2
import axios from 'axios'
3
import router from '@/router'
4
5
// 创建axios实例
6
const service = axios.create({
7
  timeout: 1000 * 30,
8
  withCredentials: true,
9
  headers: {
10
    'Content-Type': 'application/json; charset=utf-8'
11
  }
12
})
13
14
// request拦截器
15
service.interceptors.request.use(config => {
16
  config.headers['token'] = Vue.cookie.get('token')
17
  return config
18
}, error => {
19
  return Promise.reject(error)
20
})
21
22
// response拦截器
23
service.interceptors.response.use(response => {
24
  if (response.data && response.data.code === 401) { // 401, token失效
25
    Vue.cookie.delete('token')
26
    router.push({ name: 'login' })
27
  }
28
  return response
29
}, error => {
30
  return Promise.reject(error)
31
})
32
33
export default service

+ 0 - 21
src/api/requestParam.js

@ -1,21 +0,0 @@
1
import qs from 'qs'
2
import merge from 'lodash/merge'
3
4
/**
5
 * 请求参数统一处理/组装
6
 * @param {*} params 参数对象
7
 * @param {*} requestType 类型
8
 * @param {*} openDefultParams 是否开启默认参数?
9
 * @param {*} contentType 数据格式
10
 *  json: 'application/json; charset=utf-8'
11
 *  form: 'application/x-www-form-urlencoded; charset=utf-8'
12
 */
13
export default function (params, requestType = 'post', openDefultParams = true, contentType = 'json') {
14
  // 默认参数
15
  var defaults = {
16
    't': new Date().getTime()
17
  }
18
  params = openDefultParams ? merge(defaults, params) : params
19
  params = requestType === 'post' ? (contentType === 'json' ? JSON.stringify(params) : qs.stringify(params)) : params
20
  return params
21
}

+ 0 - 8
src/api/requestUrl.js

@ -1,8 +0,0 @@
1
/**
2
 * 请求地址统一处理/组装
3
 * @param {*} actionName action方法名称
4
 */
5
export default function (actionName) {
6
  // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
7
  return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
8
}

+ 1 - 1
src/assets/scss/index.scss

@ -1,4 +1,4 @@
1 1
@import "normalize";       // api: https://github.com/necolas/normalize.css/
2 2
@import "variables";       // 站点变量
3
@import "element-ui";      // element-ui主题定制, 开启(解开注释)后会增加编译时间(建议: 开发时/无此需求时, 请注释!) #待优化
3
// @import "element-ui";      // element-ui主题定制, 开启(解开注释)后会增加编译时间(建议: 开发时/无此需求时, 请注释!) #待优化
4 4
@import "base";

+ 4 - 3
src/main.js

@ -8,18 +8,19 @@ import VueCookie from 'vue-cookie'  // api: https://github.com/alfhen/vue-cookie
8 8
import '@/element-ui'               // api: https://github.com/ElemeFE/element
9 9
import '@/icons'                    // api: http://www.iconfont.cn/
10 10
import '@/assets/scss/index.scss'
11
import http from '@/utils/http'
11 12
import { isAuth } from '@/utils'
12 13
13 14
Vue.use(VueCookie)
14 15
Vue.config.productionTip = false
15 16
16
// 非生产环境, 适配mockjs模拟数据.        api: https://github.com/nuysoft/Mock
17
// 非生产环境, 适配mockjs模拟数据.         api: https://github.com/nuysoft/Mock
17 18
if (process.env.NODE_ENV !== 'production') {
18 19
  require('@/mock')
19 20
}
20 21
21
// 挂载权限方法
22
Vue.prototype.isAuth = isAuth
22
Vue.prototype.$http = http    // 挂载, ajax请求方法
23
Vue.prototype.isAuth = isAuth // 挂载, 权限方法
23 24
24 25
/* eslint-disable no-new */
25 26
new Vue({

+ 2 - 2
src/mock/index.js

@ -8,7 +8,7 @@ import * as config from './modules/config'
8 8
import * as oss from './modules/oss'
9 9
import * as schedule from './modules/schedule'
10 10
11
console.log('\n%c!<-------------------- 接口拦截, mock模拟数据 start -------------------->', 'color:red')
11
console.log('\n%c!<-------------------- 接口拦截, mock模拟数据 s -------------------->', 'color:red')
12 12
13 13
// tips
14 14
// 1. 关闭[业务模块集]拦截, create方法[第2个参数]设置. (默认开启)
@ -23,4 +23,4 @@ create(config, false)      // 参数管理
23 23
create(oss, false)         // 文件服务
24 24
create(schedule, false)    // 定时任务
25 25
26
console.log('%c!<-------------------- 接口拦截, mock模拟数据  end  -------------------->\n', 'color:red')
26
console.log('%c!<-------------------- 接口拦截, mock模拟数据 e -------------------->\n', 'color:red')

+ 1 - 1
src/mock/modules/common.js

@ -1,7 +1,7 @@
1 1
// 登录
2 2
export function login () {
3 3
  return {
4
    isOpen: false,
4
    // isOpen: false,
5 5
    url: '/sys/login',
6 6
    type: 'post',
7 7
    data: {

+ 14 - 15
src/router/index.js

@ -12,26 +12,25 @@ Vue.use(Router)
12 12
export default new Router({
13 13
  mode: 'hash',
14 14
  routes: [
15
    { path: '/404', component: _import('error/404'), name: '404', desc: '404未找到' },
16
    { path: '/login', component: _import('login/index'), name: 'login', desc: '登录' },
15
    { path: '/404', component: _import('common/404'), name: '404', desc: '404未找到' },
16
    { path: '/login', component: _import('common/login'), name: 'login', desc: '登录' },
17 17
    {
18 18
      path: '/',
19
      component: _import('layout/index'),
20
      name: 'layout',
19
      component: _import('main'),
20
      name: 'main',
21 21
      redirect: { name: 'home' },
22
      desc: '上左右整体布局',
22
      desc: '主入口整体布局',
23 23
      children: [
24 24
        // 通过isTab属性, 设定是否通过tab标签页展示内容
25
        { path: '/home', component: _import('home/index'), name: 'home', desc: '首页' },
26
        { path: '/layout-setting', component: _import('layout/setting'), name: 'setting', desc: '布局设置' },
27
        { path: '/user', component: _import('user/index'), name: 'user', desc: '管理员管理', meta: { isTab: true } },
28
        { path: '/role', component: _import('role/index'), name: 'role', desc: '角色管理', meta: { isTab: true } },
29
        { path: '/menu', component: _import('menu/index'), name: 'menu', desc: '菜单管理', meta: { isTab: true } },
30
        { path: '/sql', component: _import('sql/index'), name: 'sql', desc: 'SQL监控', meta: { isTab: true } },
31
        { path: '/schedule', component: _import('schedule/index'), name: 'schedule', desc: '定时任务', meta: { isTab: true } },
32
        { path: '/config', component: _import('config/index'), name: 'config', desc: '参数管理', meta: { isTab: true } },
33
        { path: '/oss', component: _import('oss/index'), name: 'oss', desc: '文件上传', meta: { isTab: true } },
34
        { path: '/log', component: _import('log/index'), name: 'log', desc: '系统日志', meta: { isTab: true } }
25
        { path: '/home', component: _import('common/home'), name: 'home', desc: '首页' },
26
        { path: '/theme', component: _import('common/theme'), name: 'theme', desc: '主题' },
27
        { path: '/job/schedule', component: _import('modules/job/schedule'), name: 'schedule', desc: '定时任务', meta: { isTab: true } },
28
        { path: '/oss', component: _import('modules/oss/index'), name: 'oss', desc: '文件上传', meta: { isTab: true } },
29
        { path: '/sys/config', component: _import('modules/sys/config'), name: 'config', desc: '参数管理', meta: { isTab: true } },
30
        { path: '/sys/log', component: _import('modules/sys/log'), name: 'log', desc: '系统日志', meta: { isTab: true } },
31
        { path: '/sys/menu', component: _import('modules/sys/menu'), name: 'menu', desc: '菜单管理', meta: { isTab: true } },
32
        { path: '/sys/role', component: _import('modules/sys/role'), name: 'role', desc: '角色管理', meta: { isTab: true } },
33
        { path: '/sys/user', component: _import('modules/sys/user'), name: 'user', desc: '管理员管理', meta: { isTab: true } }
35 34
      ],
36 35
      beforeEnter (to, from, next) {
37 36
        let token = Vue.cookie.get('token')

+ 75 - 0
src/utils/http.js

@ -0,0 +1,75 @@
1
import Vue from 'vue'
2
import axios from 'axios'
3
import router from '@/router'
4
import qs from 'qs'
5
import merge from 'lodash/merge'
6
7
const http = axios.create({
8
  timeout: 1000 * 30,
9
  withCredentials: true,
10
  headers: {
11
    'Content-Type': 'application/json; charset=utf-8'
12
  }
13
})
14
15
/**
16
 * 请求拦截
17
 */
18
http.interceptors.request.use(config => {
19
  config.headers['token'] = Vue.cookie.get('token') // 请求头带上token
20
  return config
21
}, error => {
22
  return Promise.reject(error)
23
})
24
25
/**
26
 * 响应拦截
27
 */
28
http.interceptors.response.use(response => {
29
  if (response.data && response.data.code === 401) { // 401, token失效
30
    Vue.cookie.delete('token')
31
    router.push({ name: 'login' })
32
  }
33
  return response
34
}, error => {
35
  return Promise.reject(error)
36
})
37
38
/**
39
 * 请求地址处理
40
 * @param {*} actionName action方法名称
41
 */
42
http.adornUrl = (actionName) => {
43
  // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
44
  return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
45
}
46
47
/**
48
 * get请求参数处理
49
 * @param {*} params 参数对象
50
 * @param {*} openDefultParams 是否开启默认参数?
51
 */
52
http.adornParams = (params = {}, openDefultParams = true) => {
53
  var defaults = {
54
    't': new Date().getTime()
55
  }
56
  return openDefultParams ? merge(defaults, params) : params
57
}
58
59
/**
60
 * post请求数据处理
61
 * @param {*} data 数据对象
62
 * @param {*} openDefultdata 是否开启默认数据?
63
 * @param {*} contentType 数据格式
64
 *  json: 'application/json; charset=utf-8'
65
 *  form: 'application/x-www-form-urlencoded; charset=utf-8'
66
 */
67
http.adornData = (data = {}, openDefultdata = true, contentType = 'json') => {
68
  var defaults = {
69
    't': new Date().getTime()
70
  }
71
  data = openDefultdata ? merge(defaults, data) : data
72
  return contentType === 'json' ? JSON.stringify(data) : qs.stringify(data)
73
}
74
75
export default http

src/views/error/404.vue → src/views/common/404.vue


src/views/home/index.vue → src/views/common/home.vue


+ 11 - 9
src/views/login/index.vue

@ -37,7 +37,6 @@
37 37
</template>
38 38
39 39
<script>
40
  import API from '@/api'
41 40
  import { getUUID } from '@/utils'
42 41
  export default {
43 42
    data () {
@ -70,13 +69,16 @@
70 69
      dataFormSubmit () {
71 70
        this.$refs['dataForm'].validate((valid) => {
72 71
          if (valid) {
73
            var params = {
74
              'username': this.dataForm.userName,
75
              'password': this.dataForm.password,
76
              'uuid': this.dataForm.uuid,
77
              'captcha': this.dataForm.captcha
78
            }
79
            API.common.login(params).then(({data}) => {
72
            this.$http({
73
              url: this.$http.adornUrl('/sys/login'),
74
              method: 'post',
75
              data: this.$http.adornData({
76
                'username': this.dataForm.userName,
77
                'password': this.dataForm.password,
78
                'uuid': this.dataForm.uuid,
79
                'captcha': this.dataForm.captcha
80
              })
81
            }).then(({data}) => {
80 82
              if (data && data.code === 0) {
81 83
                this.$cookie.set('token', data.token, { expires: `${data.expire || 0}s` })
82 84
                this.$router.replace({ name: 'home' })
@ -91,7 +93,7 @@
91 93
      // 获取验证码
92 94
      getCaptcha () {
93 95
        this.dataForm.uuid = getUUID()
94
        this.captchaPath = API.common.captcha(this.dataForm.uuid)
96
        this.captchaPath = this.$http.adornUrl(`/captcha.jpg?uuid=${this.dataForm.uuid}`)
95 97
      }
96 98
    }
97 99
  }

src/views/layout/setting.vue → src/views/common/theme.vue


+ 0 - 118
src/views/layout/content-tabs.vue

@ -1,118 +0,0 @@
1
<template>
2
  <el-tabs
3
    v-model="tabActiveName"
4
    :closable="true"
5
    @tab-click="selectedTabHandle"
6
    @tab-remove="removeTabHandle">
7
    <el-tab-pane
8
      v-for="item in $store.state.contentTabs"
9
      :key="item.name"
10
      :label="item.title"
11
      :name="item.name">
12
      <el-card :body-style="contentViewStyles(item)">
13
        <iframe
14
          v-if="item.type === 'iframe'"
15
          :src="getNestIframeUrl(item.url)"
16
          width="100%" height="100%" frameborder="0" scrolling="yes">
17
        </iframe>
18
        <keep-alive v-else>
19
          <router-view v-if="item.name === tabActiveName"></router-view>
20
        </keep-alive>
21
      </el-card>
22
    </el-tab-pane>
23
    
24
    <!-- tabs tools -->
25
    <el-dropdown class="site-tabs__tools" @command="toolsCommandHandle" :show-timeout="0">
26
      <i class="el-icon-arrow-down el-icon--right"></i>
27
      <el-dropdown-menu slot="dropdown">
28
        <el-dropdown-item command="closeCurrent">关闭当前标签页</el-dropdown-item>
29
        <el-dropdown-item command="closeOther">关闭其它标签页</el-dropdown-item>
30
        <el-dropdown-item command="closeAll">关闭全部标签页</el-dropdown-item>
31
        <el-dropdown-item command="refreshCurrent">刷新当前标签页</el-dropdown-item>
32
      </el-dropdown-menu>
33
    </el-dropdown>
34
  </el-tabs>
35
</template>
36
37
<script>
38
  import isEmpty from 'lodash/isEmpty'
39
  import { mapMutations } from 'vuex'
40
  export default {
41
    data () {
42
      return {
43
      }
44
    },
45
    computed: {
46
      tabActiveName: {
47
        get () {
48
          return this.$store.state.contentTabsActiveName
49
        },
50
        set (name) {
51
          this.UPDATE_CONTENT_TABS_ACTIVE_NAME({ name })
52
        }
53
      }
54
    },
55
    watch: {
56
      '$store.state.contentTabs' (tabs) {
57
        if (tabs.length <= 0) {
58
          this.UPDATE_MENU_NAV_ACTIVE_NAME({ name: '' })
59
          this.$router.push({ name: 'home' })
60
        }
61
      }
62
    },
63
    methods: {
64
      // tab内容容器显示高度
65
      contentViewStyles (tab) {
66
        var height = this.$store.state.documentClientHeight
67
        height -= 50 // site-topbar
68
        height -= 40 // el-tabs__header
69
        height -= 15 // el-tabs__header margin-bottom
70
        height -= 15 // el-tabs__content padding-bottom
71
        height -= 2  // el-card border-top border-bottom
72
        height += 'px'
73
        return [
74
          tab.type === 'iframe' ? { height } : { minHeight: height }
75
        ]
76
      },
77
      // 获取iframe嵌套地址
78
      getNestIframeUrl (url) {
79
        return window.SITE_CONFIG.nestIframeUrl + url
80
      },
81
      // 选中tab
82
      selectedTabHandle (tab) {
83
        tab = this.$store.state.contentTabs.filter(item => item.name === tab.name)
84
        if (!isEmpty(tab)) {
85
          this.$router.push({ name: tab[0].name })
86
        }
87
      },
88
      // 删除tab
89
      removeTabHandle (tabName) {
90
        var newTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName)
91
        // 当前选中tab被删除
92
        if (newTabs.length >= 1 && tabName === this.tabActiveName) {
93
          this.$router.push({ name: newTabs[newTabs.length - 1].name }, () => {
94
            this.tabActiveName = this.$route.name
95
          })
96
        }
97
        this.UPDATE_CONTENT_TABS(newTabs)
98
      },
99
      // 工具操作
100
      toolsCommandHandle (command) {
101
        if (command === 'closeCurrent') {
102
          this.removeTabHandle(this.tabActiveName)
103
        } else if (command === 'closeOther') {
104
          this.UPDATE_CONTENT_TABS(this.$store.state.contentTabs.filter(item => item.name === this.tabActiveName))
105
        } else if (command === 'closeAll') {
106
          this.DELETE_CONTENT_TABS()
107
        } else if (command === 'refreshCurrent') {
108
          var tempTabName = this.tabActiveName
109
          this.removeTabHandle(tempTabName)
110
          this.$nextTick(() => {
111
            this.$router.push({ name: tempTabName })
112
          })
113
        }
114
      },
115
      ...mapMutations(['UPDATE_MENU_NAV_ACTIVE_NAME', 'UPDATE_CONTENT_TABS', 'UPDATE_CONTENT_TABS_ACTIVE_NAME', 'DELETE_CONTENT_TABS'])
116
    }
117
  }
118
</script>

+ 0 - 92
src/views/layout/index.vue

@ -1,92 +0,0 @@
1
<template>
2
  <div class="site-wrapper" :class="siteWarpperClasses" v-loading.fullscreen.lock="loading" element-loading-text="拼命加载中">
3
    <template v-if="!loading">
4
      <navbar></navbar>
5
      <sidebar></sidebar>
6
      <div class="site-content__wrapper" :style="siteContentWarpperStyles">
7
        <main class="site-content" :class="{ 'site-content--tabs': routeIsTab }">
8
          <el-card v-if="!routeIsTab" :body-style="contentViewStyles">
9
            <keep-alive>
10
              <router-view></router-view>
11
            </keep-alive>
12
          </el-card>
13
          <!-- tab标签页, 内容展示方式 -->
14
          <content-tabs v-else></content-tabs>
15
        </main>
16
      </div>
17
    </template>
18
  </div>
19
</template>
20
21
<script>
22
  import Navbar from './navbar'
23
  import Sidebar from './sidebar'
24
  import ContentTabs from './content-tabs'
25
  import API from '@/api'
26
  import { mapMutations } from 'vuex'
27
  export default {
28
    data () {
29
      return {
30
        loading: true
31
      }
32
    },
33
    components: {
34
      Navbar,
35
      Sidebar,
36
      ContentTabs
37
    },
38
    computed: {
39
      siteWarpperClasses () {
40
        return [
41
          { 'site-sidebar--collapse': this.$store.state.sidebarCollapse }
42
        ]
43
      },
44
      siteContentWarpperStyles () {
45
        return [
46
          { 'minHeight': this.$store.state.documentClientHeight + 'px' }
47
        ]
48
      },
49
      routeIsTab () {
50
        return this.$route.meta && this.$route.meta.isTab
51
      },
52
      contentViewStyles () {
53
        var height = this.$store.state.documentClientHeight
54
        height -= 50 // site-topbar
55
        height -= 15 // site-content padding-top
56
        height -= 15 // site-content padding-bottom
57
        height -= 2  // el-card border-top border-bottom
58
        height += 'px'
59
        return [
60
          { minHeight: height }
61
        ]
62
      }
63
    },
64
    created () {
65
      this.getUserInfo()
66
    },
67
    mounted () {
68
      this.resetDocumentClientHeight()
69
      window.onresize = () => {
70
        this.resetDocumentClientHeight()
71
      }
72
    },
73
    methods: {
74
      // 重置窗口可视高度
75
      resetDocumentClientHeight () {
76
        this.UPDATE_DOCUMENT_CLIENT_HEIGHT({ height: document.documentElement['clientHeight'] })
77
      },
78
      // 获取当前管理员信息
79
      getUserInfo () {
80
        API.user.info().then(({data}) => {
81
          if (data && data.code === 0) {
82
            this.loading = false
83
            this.DELETE_CONTENT_TABS()
84
            this.UPDATE_USER_ID({ id: data.user.userId })
85
            this.UPDATE_USER_NAME({ name: data.user.username })
86
          }
87
        })
88
      },
89
      ...mapMutations(['UPDATE_DOCUMENT_CLIENT_HEIGHT', 'UPDATE_USER_ID', 'UPDATE_USER_NAME', 'DELETE_CONTENT_TABS'])
90
    }
91
  }
92
</script>

+ 8 - 6
src/views/layout/update-password.vue

@ -25,7 +25,6 @@
25 25
</template>
26 26
27 27
<script>
28
  import API from '@/api'
29 28
  import { mapMutations } from 'vuex'
30 29
  export default {
31 30
    data () {
@ -69,11 +68,14 @@
69 68
      dataFormSubmit () {
70 69
        this.$refs['dataForm'].validate((valid) => {
71 70
          if (valid) {
72
            var params = {
73
              'password': this.dataForm.password,
74
              'newPassword': this.dataForm.newPassword
75
            }
76
            API.user.updatePassword(params).then(({data}) => {
71
            this.$http({
72
              url: this.$http.adornUrl('/sys/user/password'),
73
              method: 'post',
74
              data: this.$http.adornData({
75
                'password': this.dataForm.password,
76
                'newPassword': this.dataForm.newPassword
77
              })
78
            }).then(({data}) => {
77 79
              if (data && data.code === 0) {
78 80
                this.$message({
79 81
                  message: '操作成功',

+ 6 - 3
src/views/layout/navbar.vue

@ -55,8 +55,7 @@
55 55
</template>
56 56
57 57
<script>
58
  import UpdatePassword from './update-password'
59
  import API from '@/api'
58
  import UpdatePassword from './main-navbar-update-password'
60 59
  import { mapMutations } from 'vuex'
61 60
  export default {
62 61
    data () {
@ -94,7 +93,11 @@
94 93
          cancelButtonText: '取消',
95 94
          type: 'warning'
96 95
        }).then(() => {
97
          API.common.logout().then(({data}) => {
96
          this.$http({
97
            url: this.$http.adornUrl('/sys/logout'),
98
            method: 'post',
99
            data: this.$http.adornData()
100
          }).then(({data}) => {
98 101
            if (data && data.code === 0) {
99 102
              this.DELETE_CONTENT_TABS()
100 103
              this.$cookie.delete('token')

+ 5 - 2
src/views/layout/sidebar.vue

@ -22,7 +22,6 @@
22 22
23 23
<script>
24 24
  import SubMenuNav from '@/components/sub-menu-nav'
25
  import API from '@/api'
26 25
  import { mapMutations } from 'vuex'
27 26
  import { getRouteNameByUrl } from '@/utils'
28 27
  import isEmpty from 'lodash/isEmpty'
@ -62,7 +61,11 @@
62 61
    methods: {
63 62
      // 获取菜单导航列表 / 权限
64 63
      getMenuNavList () {
65
        return API.menu.nav().then(({data}) => {
64
        return this.$http({
65
          url: this.$http.adornUrl('/sys/menu/nav'),
66
          method: 'get',
67
          params: this.$http.adornParams()
68
        }).then(({data}) => {
66 69
          if (data && data.code === 0) {
67 70
            this.UPDATE_MENU_NAV_LIST(data.menuList)
68 71
            sessionStorage.setItem('permissions', JSON.stringify(data.permissions || '[]'))

+ 177 - 0
src/views/main.vue

@ -0,0 +1,177 @@
1
<template>
2
  <div
3
    class="site-wrapper"
4
    :class="{ 'site-sidebar--collapse': this.$store.state.sidebarCollapse }"
5
    v-loading.fullscreen.lock="loading"
6
    element-loading-text="拼命加载中">
7
    <template v-if="!loading">
8
      <main-navbar />
9
      <main-sidebar />
10
      <div class="site-content__wrapper" :style="{ 'min-height': this.$store.state.documentClientHeight + 'px' }">
11
        <main class="site-content" :class="{ 'site-content--tabs': routeIsTab }">
12
          <!-- 标签页展示内容 s -->
13
          <el-tabs
14
            v-if="routeIsTab"
15
            v-model="tabActiveName"
16
            :closable="true"
17
            @tab-click="selectedTabHandle"
18
            @tab-remove="removeTabHandle">
19
            <!-- 标签页工具 s -->
20
            <el-dropdown class="site-tabs__tools" :show-timeout="0">
21
              <i class="el-icon-arrow-down el-icon--right"></i>
22
              <el-dropdown-menu slot="dropdown">
23
                <el-dropdown-item @click.native="tabsCloseCurrentHandle">关闭当前标签页</el-dropdown-item>
24
                <el-dropdown-item @click.native="tabsCloseOtherHandle">关闭其它标签页</el-dropdown-item>
25
                <el-dropdown-item @click.native="tabsCloseAllHandle">关闭全部标签页</el-dropdown-item>
26
                <el-dropdown-item @click.native="tabsRefreshCurrentHandle">刷新当前标签页</el-dropdown-item>
27
              </el-dropdown-menu>
28
            </el-dropdown>
29
            <!-- 标签页工具 e -->
30
            <el-tab-pane
31
              v-for="item in $store.state.contentTabs"
32
              :key="item.name"
33
              :label="item.title"
34
              :name="item.name">
35
              <el-card :style="siteContentViewHeight">
36
                <iframe
37
                  v-if="item.type === 'iframe'"
38
                  :src="getNestIframeUrl(item.url)"
39
                  width="100%" height="100%" frameborder="0" scrolling="yes">
40
                </iframe>
41
                <keep-alive v-else>
42
                  <router-view v-if="item.name === tabActiveName" />
43
                </keep-alive>
44
              </el-card>
45
            </el-tab-pane>
46
          </el-tabs>
47
          <!-- 标签页展示内容 e -->
48
          <el-card v-else :style="siteContentViewHeight">
49
            <keep-alive>
50
              <router-view />
51
            </keep-alive>
52
          </el-card>
53
        </main>
54
      </div>
55
    </template>
56
  </div>
57
</template>
58
59
<script>
60
  import MainNavbar from './main-navbar'
61
  import MainSidebar from './main-sidebar'
62
  import { mapMutations } from 'vuex'
63
  import isEmpty from 'lodash/isEmpty'
64
  export default {
65
    data () {
66
      return {
67
        loading: true
68
      }
69
    },
70
    components: {
71
      MainNavbar,
72
      MainSidebar
73
    },
74
    computed: {
75
      siteContentViewHeight () {
76
        var height = this.$store.state.documentClientHeight - 50 - 30 - 2
77
        if (this.routeIsTab) {
78
          height -= 40
79
          return this.$route.meta && this.$route.meta.isIframe ? { height: height + 'px' } : { minHeight: height + 'px' }
80
        }
81
        return { minHeight: height + 'px' }
82
      },
83
      routeIsTab () {
84
        return this.$route.meta && this.$route.meta.isTab
85
      },
86
      tabActiveName: {
87
        get () {
88
          return this.$store.state.contentTabsActiveName
89
        },
90
        set (name) {
91
          this.UPDATE_CONTENT_TABS_ACTIVE_NAME({ name })
92
        }
93
      }
94
    },
95
    watch: {
96
      '$store.state.contentTabs' (tabs) {
97
        if (tabs.length <= 0) {
98
          this.UPDATE_MENU_NAV_ACTIVE_NAME({ name: '' })
99
          this.$router.push({ name: 'home' })
100
        }
101
      }
102
    },
103
    created () {
104
      this.getUserInfo()
105
    },
106
    mounted () {
107
      this.resetDocumentClientHeight()
108
      window.onresize = () => {
109
        this.resetDocumentClientHeight()
110
      }
111
    },
112
    methods: {
113
      // 重置窗口可视高度
114
      resetDocumentClientHeight () {
115
        this.UPDATE_DOCUMENT_CLIENT_HEIGHT({ height: document.documentElement['clientHeight'] })
116
      },
117
      // 获取当前管理员信息
118
      getUserInfo () {
119
        this.$http({
120
          url: this.$http.adornUrl('/sys/user/info'),
121
          method: 'get',
122
          params: this.$http.adornParams()
123
        }).then(({data}) => {
124
          if (data && data.code === 0) {
125
            this.loading = false
126
            this.DELETE_CONTENT_TABS()
127
            this.UPDATE_USER_ID({ id: data.user.userId })
128
            this.UPDATE_USER_NAME({ name: data.user.username })
129
          }
130
        })
131
      },
132
      // 获取iframe嵌套地址
133
      getNestIframeUrl (url) {
134
        return window.SITE_CONFIG.nestIframeUrl + url
135
      },
136
      // tabs, 选中tab
137
      selectedTabHandle (tab) {
138
        tab = this.$store.state.contentTabs.filter(item => item.name === tab.name)
139
        if (!isEmpty(tab)) {
140
          this.$router.push({ name: tab[0].name })
141
        }
142
      },
143
      // tabs, 删除tab
144
      removeTabHandle (tabName) {
145
        var newTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName)
146
        // 当前选中tab被删除
147
        if (newTabs.length >= 1 && tabName === this.tabActiveName) {
148
          this.$router.push({ name: newTabs[newTabs.length - 1].name }, () => {
149
            this.tabActiveName = this.$route.name
150
          })
151
        }
152
        this.UPDATE_CONTENT_TABS(newTabs)
153
      },
154
      // tabs, 关闭当前
155
      tabsCloseCurrentHandle () {
156
        this.removeTabHandle(this.tabActiveName)
157
      },
158
      // tabs, 关闭其它
159
      tabsCloseOtherHandle () {
160
        this.UPDATE_CONTENT_TABS(this.$store.state.contentTabs.filter(item => item.name === this.tabActiveName))
161
      },
162
      // tabs, 关闭全部
163
      tabsCloseAllHandle () {
164
        this.DELETE_CONTENT_TABS()
165
      },
166
      // tabs, 刷新当前
167
      tabsRefreshCurrentHandle () {
168
        var tempTabName = this.tabActiveName
169
        this.removeTabHandle(tempTabName)
170
        this.$nextTick(() => {
171
          this.$router.push({ name: tempTabName })
172
        })
173
      },
174
      ...mapMutations(['UPDATE_DOCUMENT_CLIENT_HEIGHT', 'UPDATE_USER_ID', 'UPDATE_USER_NAME', 'UPDATE_CONTENT_TABS', 'UPDATE_CONTENT_TABS_ACTIVE_NAME', 'DELETE_CONTENT_TABS', 'UPDATE_MENU_NAV_ACTIVE_NAME'])
175
    }
176
  }
177
</script>

+ 18 - 13
src/views/schedule/add-or-update.vue

@ -28,7 +28,6 @@
28 28
</template>
29 29
30 30
<script>
31
  import API from '@/api'
32 31
  export default {
33 32
    data () {
34 33
      return {
@ -62,7 +61,11 @@
62 61
        this.$nextTick(() => {
63 62
          this.$refs['dataForm'].resetFields()
64 63
          if (this.dataForm.id) {
65
            API.schedule.info(this.dataForm.id).then(({data}) => {
64
            this.$http({
65
              url: this.$http.adornUrl(`/sys/schedule/info/${this.dataForm.id}`),
66
              method: 'get',
67
              params: this.$http.adornParams()
68
            }).then(({data}) => {
66 69
              if (data && data.code === 0) {
67 70
                this.dataForm.beanName = data.schedule.beanName
68 71
                this.dataForm.methodName = data.schedule.methodName
@ -79,17 +82,19 @@
79 82
      dataFormSubmit () {
80 83
        this.$refs['dataForm'].validate((valid) => {
81 84
          if (valid) {
82
            var params = {
83
              'jobId': this.dataForm.id || undefined,
84
              'beanName': this.dataForm.beanName,
85
              'methodName': this.dataForm.methodName,
86
              'params': this.dataForm.params,
87
              'cronExpression': this.dataForm.cronExpression,
88
              'remark': this.dataForm.remark,
89
              'status': !this.dataForm.id ? undefined : this.dataForm.status
90
            }
91
            var tick = !this.dataForm.id ? API.schedule.add(params) : API.schedule.update(params)
92
            tick.then(({data}) => {
85
            this.$http({
86
              url: this.$http.adornUrl(`/sys/schedule/${!this.dataForm.id ? 'save' : 'update'}`),
87
              method: 'post',
88
              data: this.$http.adornData({
89
                'jobId': this.dataForm.id || undefined,
90
                'beanName': this.dataForm.beanName,
91
                'methodName': this.dataForm.methodName,
92
                'params': this.dataForm.params,
93
                'cronExpression': this.dataForm.cronExpression,
94
                'remark': this.dataForm.remark,
95
                'status': !this.dataForm.id ? undefined : this.dataForm.status
96
              })
97
            }).then(({data}) => {
93 98
              if (data && data.code === 0) {
94 99
                this.$message({
95 100
                  message: '操作成功',

+ 14 - 8
src/views/schedule/log.vue

@ -87,7 +87,6 @@
87 87
</template>
88 88
89 89
<script>
90
  import API from '@/api'
91 90
  export default {
92 91
    data () {
93 92
      return {
@ -110,12 +109,15 @@
110 109
      // 获取数据列表
111 110
      getDataList () {
112 111
        this.dataListLoading = true
113
        var params = {
114
          page: this.pageIndex,
115
          limit: this.pageSize,
116
          jobId: this.dataForm.id
117
        }
118
        API.log.scheduleList(params).then(({data}) => {
112
        this.$http({
113
          url: this.$http.adornUrl('/sys/scheduleLog/list'),
114
          method: 'get',
115
          params: this.$http.adornParams({
116
            'page': this.pageIndex,
117
            'limit': this.pageSize,
118
            'jobId': this.dataForm.id
119
          })
120
        }).then(({data}) => {
119 121
          if (data && data.code === 0) {
120 122
            this.dataList = data.page.list
121 123
            this.totalPage = data.page.totalCount
@ -139,7 +141,11 @@
139 141
      },
140 142
      // 失败信息
141 143
      showErrorInfo (id) {
142
        API.log.scheduleInfo(id).then(({data}) => {
144
        this.$http({
145
          url: this.$http.adornUrl(`/sys/scheduleLog/info/${id}`),
146
          method: 'get',
147
          params: this.$http.adornParams()
148
        }).then(({data}) => {
143 149
          if (data && data.code === 0) {
144 150
            this.$alert(data.log.error)
145 151
          } else {

+ 31 - 13
src/views/schedule/index.vue

@ -105,9 +105,8 @@
105 105
</template>
106 106
107 107
<script>
108
  import API from '@/api'
109
  import AddOrUpdate from './add-or-update'
110
  import Log from './log'
108
  import AddOrUpdate from './schedule-add-or-update'
109
  import Log from './schedule-log'
111 110
  export default {
112 111
    data () {
113 112
      return {
@ -135,12 +134,15 @@
135 134
      // 获取数据列表
136 135
      getDataList () {
137 136
        this.dataListLoading = true
138
        var params = {
139
          page: this.pageIndex,
140
          limit: this.pageSize,
141
          beanName: this.dataForm.beanName
142
        }
143
        API.schedule.list(params).then(({data}) => {
137
        this.$http({
138
          url: this.$http.adornUrl('/sys/schedule/list'),
139
          method: 'get',
140
          params: this.$http.adornParams({
141
            'page': this.pageIndex,
142
            'limit': this.pageSize,
143
            'beanName': this.dataForm.beanName
144
          })
145
        }).then(({data}) => {
144 146
          if (data && data.code === 0) {
145 147
            this.dataList = data.page.list
146 148
            this.totalPage = data.page.totalCount
@ -183,7 +185,11 @@
183 185
          cancelButtonText: '取消',
184 186
          type: 'warning'
185 187
        }).then(() => {
186
          API.schedule.del(ids).then(({data}) => {
188
          this.$http({
189
            url: this.$http.adornUrl('/sys/schedule/delete'),
190
            method: 'post',
191
            data: this.$http.adornData(ids, false)
192
          }).then(({data}) => {
187 193
            if (data && data.code === 0) {
188 194
              this.$message({
189 195
                message: '操作成功',
@ -209,7 +215,11 @@
209 215
          cancelButtonText: '取消',
210 216
          type: 'warning'
211 217
        }).then(() => {
212
          API.schedule.pause(ids).then(({data}) => {
218
          this.$http({
219
            url: this.$http.adornUrl('/sys/schedule/pause'),
220
            method: 'post',
221
            data: this.$http.adornData(ids, false)
222
          }).then(({data}) => {
213 223
            if (data && data.code === 0) {
214 224
              this.$message({
215 225
                message: '操作成功',
@ -235,7 +245,11 @@
235 245
          cancelButtonText: '取消',
236 246
          type: 'warning'
237 247
        }).then(() => {
238
          API.schedule.resume(ids).then(({data}) => {
248
          this.$http({
249
            url: this.$http.adornUrl('/sys/schedule/resume'),
250
            method: 'post',
251
            data: this.$http.adornData(ids, false)
252
          }).then(({data}) => {
239 253
            if (data && data.code === 0) {
240 254
              this.$message({
241 255
                message: '操作成功',
@ -261,7 +275,11 @@
261 275
          cancelButtonText: '取消',
262 276
          type: 'warning'
263 277
        }).then(() => {
264
          API.schedule.run(ids).then(({data}) => {
278
          this.$http({
279
            url: this.$http.adornUrl('/sys/schedule/run'),
280
            method: 'post',
281
            data: this.$http.adornData(ids, false)
282
          }).then(({data}) => {
265 283
            if (data && data.code === 0) {
266 284
              this.$message({
267 285
                message: '操作成功',

+ 15 - 9
src/views/oss/index.vue

@ -67,9 +67,8 @@
67 67
</template>
68 68
69 69
<script>
70
  import API from '@/api'
71
  import Config from './config'
72
  import Upload from './upload'
70
  import Config from './oss-config'
71
  import Upload from './oss-upload'
73 72
  export default {
74 73
    data () {
75 74
      return {
@ -95,11 +94,14 @@
95 94
      // 获取数据列表
96 95
      getDataList () {
97 96
        this.dataListLoading = true
98
        var params = {
99
          page: this.pageIndex,
100
          limit: this.pageSize
101
        }
102
        API.oss.list(params).then(({data}) => {
97
        this.$http({
98
          url: this.$http.adornUrl('/sys/oss/list'),
99
          method: 'get',
100
          params: this.$http.adornParams({
101
            'page': this.pageIndex,
102
            'limit': this.pageSize
103
          })
104
        }).then(({data}) => {
103 105
          if (data && data.code === 0) {
104 106
            this.dataList = data.page.list
105 107
            this.totalPage = data.page.totalCount
@ -149,7 +151,11 @@
149 151
          cancelButtonText: '取消',
150 152
          type: 'warning'
151 153
        }).then(() => {
152
          API.oss.del(ids).then(({data}) => {
154
          this.$http({
155
            url: this.$http.adornUrl('/sys/oss/delete'),
156
            method: 'post',
157
            data: this.$http.adornData(ids, false)
158
          }).then(({data}) => {
153 159
            if (data && data.code === 0) {
154 160
              this.$message({
155 161
                message: '操作成功',

+ 10 - 3
src/views/oss/config.vue

@ -83,7 +83,6 @@
83 83
</template>
84 84
85 85
<script>
86
  import API from '@/api'
87 86
  export default {
88 87
    data () {
89 88
      return {
@ -95,7 +94,11 @@
95 94
    methods: {
96 95
      init (id) {
97 96
        this.visible = true
98
        API.oss.config().then(({data}) => {
97
        this.$http({
98
          url: this.$http.adornUrl('/sys/oss/config'),
99
          method: 'get',
100
          params: this.$http.adornParams()
101
        }).then(({data}) => {
99 102
          this.dataForm = data && data.code === 0 ? data.config : []
100 103
        })
101 104
      },
@ -103,7 +106,11 @@
103 106
      dataFormSubmit () {
104 107
        this.$refs['dataForm'].validate((valid) => {
105 108
          if (valid) {
106
            API.oss.addConfig(this.dataForm).then(({data}) => {
109
            this.$http({
110
              url: this.$http.adornUrl('/sys/oss/saveConfig'),
111
              method: 'post',
112
              data: this.$http.adornData(this.dataForm)
113
            }).then(({data}) => {
107 114
              if (data && data.code === 0) {
108 115
                this.$message({
109 116
                  message: '操作成功',

+ 1 - 2
src/views/oss/upload.vue

@ -20,7 +20,6 @@
20 20
</template>
21 21
22 22
<script>
23
  import API from '@/api'
24 23
  export default {
25 24
    data () {
26 25
      return {
@ -33,7 +32,7 @@
33 32
    },
34 33
    methods: {
35 34
      init (id) {
36
        this.url = API.oss.upload(this.$cookie.get('token'))
35
        this.url = this.$http.adornUrl(`/sys/oss/upload?token=${this.$cookie.get('token')}`)
37 36
        this.visible = true
38 37
      },
39 38
      // 上传之前

+ 15 - 10
src/views/config/add-or-update.vue

@ -22,7 +22,6 @@
22 22
</template>
23 23
24 24
<script>
25
  import API from '@/api'
26 25
  export default {
27 26
    data () {
28 27
      return {
@ -50,7 +49,11 @@
50 49
        this.$nextTick(() => {
51 50
          this.$refs['dataForm'].resetFields()
52 51
          if (this.dataForm.id) {
53
            API.config.info(this.dataForm.id).then(({data}) => {
52
            this.$http({
53
              url: this.$http.adornUrl(`/sys/config/info/${this.dataForm.id}`),
54
              method: 'get',
55
              params: this.$http.adornParams()
56
            }).then(({data}) => {
54 57
              if (data && data.code === 0) {
55 58
                this.dataForm.key = data.config.key
56 59
                this.dataForm.value = data.config.value
@ -64,14 +67,16 @@
64 67
      dataFormSubmit () {
65 68
        this.$refs['dataForm'].validate((valid) => {
66 69
          if (valid) {
67
            var params = {
68
              'id': this.dataForm.id || undefined,
69
              'key': this.dataForm.key,
70
              'value': this.dataForm.value,
71
              'remark': this.dataForm.remark
72
            }
73
            var tick = !this.dataForm.id ? API.config.add(params) : API.config.update(params)
74
            tick.then(({data}) => {
70
            this.$http({
71
              url: this.$http.adornUrl(`/sys/config/${!this.dataForm.id ? 'save' : 'update'}`),
72
              method: 'post',
73
              data: this.$http.adornData({
74
                'id': this.dataForm.id || undefined,
75
                'key': this.dataForm.key,
76
                'value': this.dataForm.value,
77
                'remark': this.dataForm.remark
78
              })
79
            }).then(({data}) => {
75 80
              if (data && data.code === 0) {
76 81
                this.$message({
77 82
                  message: '操作成功',

+ 15 - 9
src/views/config/index.vue

@ -74,8 +74,7 @@
74 74
</template>
75 75
76 76
<script>
77
  import API from '@/api'
78
  import AddOrUpdate from './add-or-update'
77
  import AddOrUpdate from './config-add-or-update'
79 78
  export default {
80 79
    data () {
81 80
      return {
@ -101,12 +100,15 @@
101 100
      // 获取数据列表
102 101
      getDataList () {
103 102
        this.dataListLoading = true
104
        var params = {
105
          page: this.pageIndex,
106
          limit: this.pageSize,
107
          key: this.dataForm.key
108
        }
109
        API.config.list(params).then(({data}) => {
103
        this.$http({
104
          url: this.$http.adornUrl('/sys/config/list'),
105
          method: 'get',
106
          params: this.$http.adornParams({
107
            'page': this.pageIndex,
108
            'limit': this.pageSize,
109
            'key': this.dataForm.key
110
          })
111
        }).then(({data}) => {
110 112
          if (data && data.code === 0) {
111 113
            this.dataList = data.page.list
112 114
            this.totalPage = data.page.totalCount
@ -149,7 +151,11 @@
149 151
          cancelButtonText: '取消',
150 152
          type: 'warning'
151 153
        }).then(() => {
152
          API.config.del(ids).then(({data}) => {
154
          this.$http({
155
            url: this.$http.adornUrl('/sys/config/delete'),
156
            method: 'post',
157
            data: this.$http.adornData(ids, false)
158
          }).then(({data}) => {
153 159
            if (data && data.code === 0) {
154 160
              this.$message({
155 161
                message: '操作成功',

+ 9 - 7
src/views/log/index.vue

@ -82,7 +82,6 @@
82 82
</template>
83 83
84 84
<script>
85
  import API from '@/api'
86 85
  export default {
87 86
    data () {
88 87
      return {
@ -104,12 +103,15 @@
104 103
      // 获取数据列表
105 104
      getDataList () {
106 105
        this.dataListLoading = true
107
        var params = {
108
          page: this.pageIndex,
109
          limit: this.pageSize,
110
          key: this.dataForm.key
111
        }
112
        API.log.list(params).then(({data}) => {
106
        this.$http({
107
          url: this.$http.adornUrl('/sys/log/list'),
108
          method: 'get',
109
          params: this.$http.adornParams({
110
            'page': this.pageIndex,
111
            'limit': this.pageSize,
112
            'key': this.dataForm.key
113
          })
114
        }).then(({data}) => {
113 115
          if (data && data.code === 0) {
114 116
            this.dataList = data.page.list
115 117
            this.totalPage = data.page.totalCount

+ 24 - 15
src/views/menu/add-or-update.vue

@ -76,7 +76,6 @@
76 76
</template>
77 77
78 78
<script>
79
  import API from '@/api'
80 79
  import { treeDataTranslate } from '@/utils'
81 80
  import Icon from '@/icons'
82 81
  export default {
@ -127,7 +126,11 @@
127 126
    methods: {
128 127
      init (id) {
129 128
        this.dataForm.id = id || 0
130
        API.menu.select().then(({data}) => {
129
        this.$http({
130
          url: this.$http.adornUrl('/sys/menu/select'),
131
          method: 'get',
132
          params: this.$http.adornParams()
133
        }).then(({data}) => {
131 134
          this.menuList = treeDataTranslate(data.menuList, 'menuId')
132 135
        }).then(() => {
133 136
          this.visible = true
@ -140,7 +143,11 @@
140 143
            this.menuListTreeSetCurrentNode()
141 144
          } else {
142 145
            // 修改
143
            API.menu.info(this.dataForm.id).then(({data}) => {
146
            this.$http({
147
              url: this.$http.adornUrl(`/sys/menu/info/${this.dataForm.id}`),
148
              method: 'get',
149
              params: this.$http.adornParams()
150
            }).then(({data}) => {
144 151
              this.dataForm.id = data.menu.menuId
145 152
              this.dataForm.type = data.menu.type
146 153
              this.dataForm.name = data.menu.name
@ -172,18 +179,20 @@
172 179
      dataFormSubmit () {
173 180
        this.$refs['dataForm'].validate((valid) => {
174 181
          if (valid) {
175
            var params = {
176
              'menuId': this.dataForm.id || undefined,
177
              'type': this.dataForm.type,
178
              'name': this.dataForm.name,
179
              'parentId': this.dataForm.parentId,
180
              'url': this.dataForm.url,
181
              'perms': this.dataForm.perms,
182
              'orderNum': this.dataForm.orderNum,
183
              'icon': this.dataForm.icon
184
            }
185
            var tick = !this.dataForm.id ? API.menu.add(params) : API.menu.update(params)
186
            tick.then(({data}) => {
182
            this.$http({
183
              url: this.$http.adornUrl(`/sys/menu/${!this.dataForm.id ? 'save' : 'update'}`),
184
              method: 'post',
185
              data: this.$http.adornData({
186
                'menuId': this.dataForm.id || undefined,
187
                'type': this.dataForm.type,
188
                'name': this.dataForm.name,
189
                'parentId': this.dataForm.parentId,
190
                'url': this.dataForm.url,
191
                'perms': this.dataForm.perms,
192
                'orderNum': this.dataForm.orderNum,
193
                'icon': this.dataForm.icon
194
              })
195
            }).then(({data}) => {
187 196
              if (data && data.code === 0) {
188 197
                this.$message({
189 198
                  message: '操作成功',

+ 11 - 4
src/views/menu/index.vue

@ -90,8 +90,7 @@
90 90
91 91
<script>
92 92
  import TableTreeColumn from '@/components/table-tree-column'
93
  import AddOrUpdate from './add-or-update'
94
  import API from '@/api'
93
  import AddOrUpdate from './menu-add-or-update'
95 94
  import { treeDataTranslate } from '@/utils'
96 95
  export default {
97 96
    data () {
@ -113,7 +112,11 @@
113 112
      // 获取数据列表
114 113
      getDataList () {
115 114
        this.dataListLoading = true
116
        API.menu.list().then(({data}) => {
115
        this.$http({
116
          url: this.$http.adornUrl('/sys/menu/list'),
117
          method: 'get',
118
          params: this.$http.adornParams()
119
        }).then(({data}) => {
117 120
          this.dataList = treeDataTranslate(data, 'menuId')
118 121
          this.dataListLoading = false
119 122
        })
@ -132,7 +135,11 @@
132 135
          cancelButtonText: '取消',
133 136
          type: 'warning'
134 137
        }).then(() => {
135
          API.menu.del(id).then(({data}) => {
138
          this.$http({
139
            url: this.$http.adornUrl(`/sys/menu/delete/${id}`),
140
            method: 'post',
141
            data: this.$http.adornData()
142
          }).then(({data}) => {
136 143
            if (data && data.code === 0) {
137 144
              this.$message({
138 145
                message: '操作成功',

+ 20 - 11
src/views/role/add-or-update.vue

@ -29,7 +29,6 @@
29 29
</template>
30 30
31 31
<script>
32
  import API from '@/api'
33 32
  import { treeDataTranslate } from '@/utils'
34 33
  export default {
35 34
    data () {
@ -56,7 +55,11 @@
56 55
    methods: {
57 56
      init (id) {
58 57
        this.dataForm.id = id || 0
59
        API.menu.list().then(({data}) => {
58
        this.$http({
59
          url: this.$http.adornUrl('/sys/role/list'),
60
          method: 'get',
61
          params: this.$http.adornParams()
62
        }).then(({data}) => {
60 63
          this.menuList = treeDataTranslate(data, 'menuId')
61 64
        }).then(() => {
62 65
          this.visible = true
@ -66,7 +69,11 @@
66 69
          })
67 70
        }).then(() => {
68 71
          if (this.dataForm.id) {
69
            API.role.info(this.dataForm.id).then(({data}) => {
72
            this.$http({
73
              url: this.$http.adornUrl(`/sys/role/info/${this.dataForm.id}`),
74
              method: 'get',
75
              params: this.$http.adornParams()
76
            }).then(({data}) => {
70 77
              if (data && data.code === 0) {
71 78
                this.dataForm.roleName = data.role.roleName
72 79
                this.dataForm.remark = data.role.remark
@ -84,14 +91,16 @@
84 91
      dataFormSubmit () {
85 92
        this.$refs['dataForm'].validate((valid) => {
86 93
          if (valid) {
87
            var params = {
88
              'roleId': this.dataForm.id || undefined,
89
              'roleName': this.dataForm.roleName,
90
              'remark': this.dataForm.remark,
91
              'menuIdList': [].concat(this.$refs.menuListTree.getCheckedKeys(), [this.tempKey], this.$refs.menuListTree.getHalfCheckedKeys())
92
            }
93
            var tick = !this.dataForm.id ? API.role.add(params) : API.role.update(params)
94
            tick.then(({data}) => {
94
            this.$http({
95
              url: this.$http.adornUrl(`/sys/role/${!this.dataForm.id ? 'save' : 'update'}`),
96
              method: 'post',
97
              data: this.$http.adornData({
98
                'roleId': this.dataForm.id || undefined,
99
                'roleName': this.dataForm.roleName,
100
                'remark': this.dataForm.remark,
101
                'menuIdList': [].concat(this.$refs.menuListTree.getCheckedKeys(), [this.tempKey], this.$refs.menuListTree.getHalfCheckedKeys())
102
              })
103
            }).then(({data}) => {
95 104
              if (data && data.code === 0) {
96 105
                this.$message({
97 106
                  message: '操作成功',

+ 15 - 9
src/views/role/index.vue

@ -75,8 +75,7 @@
75 75
</template>
76 76
77 77
<script>
78
  import AddOrUpdate from './add-or-update'
79
  import API from '@/api'
78
  import AddOrUpdate from './role-add-or-update'
80 79
  export default {
81 80
    data () {
82 81
      return {
@ -102,12 +101,15 @@
102 101
      // 获取数据列表
103 102
      getDataList () {
104 103
        this.dataListLoading = true
105
        var params = {
106
          page: this.pageIndex,
107
          limit: this.pageSize,
108
          roleName: this.dataForm.roleName
109
        }
110
        API.role.list(params).then(({data}) => {
104
        this.$http({
105
          url: this.$http.adornUrl('/sys/role/list'),
106
          method: 'get',
107
          params: this.$http.adornParams({
108
            'page': this.pageIndex,
109
            'limit': this.pageSize,
110
            'roleName': this.dataForm.roleName
111
          })
112
        }).then(({data}) => {
111 113
          if (data && data.code === 0) {
112 114
            this.dataList = data.page.list
113 115
            this.totalPage = data.page.totalCount
@ -150,7 +152,11 @@
150 152
          cancelButtonText: '取消',
151 153
          type: 'warning'
152 154
        }).then(() => {
153
          API.role.del(ids).then(({data}) => {
155
          this.$http({
156
            url: this.$http.adornUrl('/sys/role/delete'),
157
            method: 'post',
158
            data: this.$http.adornData(ids, false)
159
          }).then(({data}) => {
154 160
            if (data && data.code === 0) {
155 161
              this.$message({
156 162
                message: '操作成功',

+ 24 - 15
src/views/user/add-or-update.vue

@ -39,7 +39,6 @@
39 39
</template>
40 40
41 41
<script>
42
  import API from '@/api'
43 42
  import { isEmail, isMobile } from '@/utils/validate'
44 43
  export default {
45 44
    data () {
@ -111,7 +110,11 @@
111 110
    methods: {
112 111
      init (id) {
113 112
        this.dataForm.id = id || 0
114
        API.role.select().then(({data}) => {
113
        this.$http({
114
          url: this.$http.adornUrl('/sys/role/select'),
115
          method: 'get',
116
          params: this.$http.adornParams()
117
        }).then(({data}) => {
115 118
          this.roleList = data && data.code === 0 ? data.list : []
116 119
        }).then(() => {
117 120
          this.visible = true
@ -120,7 +123,11 @@
120 123
          })
121 124
        }).then(() => {
122 125
          if (this.dataForm.id) {
123
            API.user.info(this.dataForm.id).then(({data}) => {
126
            this.$http({
127
              url: this.$http.adornUrl(`/sys/user/info/${this.dataForm.id}`),
128
              method: 'get',
129
              params: this.$http.adornParams()
130
            }).then(({data}) => {
124 131
              if (data && data.code === 0) {
125 132
                this.dataForm.userName = data.user.username
126 133
                this.dataForm.salt = data.user.salt
@ -137,18 +144,20 @@
137 144
      dataFormSubmit () {
138 145
        this.$refs['dataForm'].validate((valid) => {
139 146
          if (valid) {
140
            var params = {
141
              'userId': this.dataForm.id || undefined,
142
              'username': this.dataForm.userName,
143
              'password': this.dataForm.password,
144
              'salt': this.dataForm.salt,
145
              'email': this.dataForm.email,
146
              'mobile': this.dataForm.mobile,
147
              'status': this.dataForm.status,
148
              'roleIdList': this.dataForm.roleIdList
149
            }
150
            var tick = !this.dataForm.id ? API.user.add(params) : API.user.update(params)
151
            tick.then(({data}) => {
147
            this.$http({
148
              url: this.$http.adornUrl(`/sys/user/${!this.dataForm.id ? 'save' : 'update'}`),
149
              method: 'post',
150
              data: this.$http.adornData({
151
                'userId': this.dataForm.id || undefined,
152
                'username': this.dataForm.userName,
153
                'password': this.dataForm.password,
154
                'salt': this.dataForm.salt,
155
                'email': this.dataForm.email,
156
                'mobile': this.dataForm.mobile,
157
                'status': this.dataForm.status,
158
                'roleIdList': this.dataForm.roleIdList
159
              })
160
            }).then(({data}) => {
152 161
              if (data && data.code === 0) {
153 162
                this.$message({
154 163
                  message: '操作成功',

+ 15 - 9
src/views/user/index.vue

@ -91,8 +91,7 @@
91 91
</template>
92 92
93 93
<script>
94
  import API from '@/api'
95
  import AddOrUpdate from './add-or-update'
94
  import AddOrUpdate from './user-add-or-update'
96 95
  export default {
97 96
    data () {
98 97
      return {
@ -118,12 +117,15 @@
118 117
      // 获取数据列表
119 118
      getDataList () {
120 119
        this.dataListLoading = true
121
        var params = {
122
          page: this.pageIndex,
123
          limit: this.pageSize,
124
          username: this.dataForm.userName
125
        }
126
        API.user.list(params).then(({data}) => {
120
        this.$http({
121
          url: this.$http.adornUrl('/sys/user/list'),
122
          method: 'get',
123
          params: this.$http.adornParams({
124
            'page': this.pageIndex,
125
            'limit': this.pageSize,
126
            'username': this.dataForm.userName
127
          })
128
        }).then(({data}) => {
127 129
          if (data && data.code === 0) {
128 130
            this.dataList = data.page.list
129 131
            this.totalPage = data.page.totalCount
@ -166,7 +168,11 @@
166 168
          cancelButtonText: '取消',
167 169
          type: 'warning'
168 170
        }).then(() => {
169
          API.user.del(userIds).then(({data}) => {
171
          this.$http({
172
            url: this.$http.adornUrl('/sys/user/delete'),
173
            method: 'post',
174
            data: this.$http.adornData(userIds, false)
175
          }).then(({data}) => {
170 176
            if (data && data.code === 0) {
171 177
              this.$message({
172 178
                message: '操作成功',

+ 0 - 3
src/views/sql/index.vue

@ -1,3 +0,0 @@
1
<template>
2
  <div>sql</div>
3
</template>

+ 2 - 2
static/config/index.js

@ -5,10 +5,10 @@
5 5
  window.SITE_CONFIG = {};
6 6
7 7
  // api接口请求地址
8
  window.SITE_CONFIG['baseUrl'] = 'http://demo.renren.io/renren-fast';
8
  window.SITE_CONFIG['baseUrl'] = 'http://dev.demo.renren.io/renren-fast';
9 9
10 10
  // 嵌套iframe地址
11
  window.SITE_CONFIG['nestIframeUrl'] = 'http://demo.renren.io/renren-fast';
11
  window.SITE_CONFIG['nestIframeUrl'] = 'http://dev.demo.renren.io/renren-fast';
12 12
  // 嵌套iframe路由名称列表
13 13
  window.SITE_CONFIG['nestIframeRouteNameList'] = ['sql'];
14 14

+ 1 - 1
static/config/init.js

@ -11,7 +11,7 @@
11 11
      window.SITE_CONFIG.cdnUrl + '/static/js/manifest.js',
12 12
      window.SITE_CONFIG.cdnUrl + '/static/js/vendor.js',
13 13
      window.SITE_CONFIG.cdnUrl + '/static/js/app.js',
14
      // window.SITE_CONFIG.cdnUrl + '/static/plugins/mock-1.0.0-beta3/mock-min.js'
14
      window.SITE_CONFIG.cdnUrl + '/static/plugins/mock-1.0.0-beta3/mock-min.js'
15 15
    ]
16 16
  };
17 17