Skip to content

Commit

Permalink
将之前的页面迁移到新的模板中;修改proxy,实现调取远程接口与mock;
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhongfa committed Jul 12, 2019
1 parent 0da8218 commit 6bb978b
Show file tree
Hide file tree
Showing 13 changed files with 1,120 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ENV = 'development'
# base api
VUE_APP_BASE_API = '/dev-api'

# no mock api
VUE_APP_API = '/dev-api/api'

# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().
Expand Down
19 changes: 19 additions & 0 deletions src/api/datax-job.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import request from '@/utils/request'

// 任务管理

export function runJob(data) {
return request({
url: '/api/runJob',
method: 'post',
data
})
}

export function runJobLog(data) {
return request({
url: '/api/runJobLog',
method: 'post',
data
})
}
50 changes: 50 additions & 0 deletions src/api/datax-jobConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import request from '@/utils/request'

// 抽取任务

export function paged(params) {
return request({
url: '/api/jobConfig',
method: 'get',
params
})
}

export function fetch(params) {
return request({
url: '/api/jobConfig/' + params,
method: 'get'
})
}

export function updated(data) {
return request({
url: '/api/jobConfig/',
method: 'put',
data
})
}

export function created(data) {
return request({
url: '/api/jobConfig/',
method: 'post',
data
})
}

export function deleted(data) {
return request({
url: '/api/jobConfig/',
method: 'delete',
params: data
})
}

export function viewJobLog(params) {
return request({
url: '/api/viewJobLog',
method: 'get',
params
})
}
42 changes: 42 additions & 0 deletions src/api/datax-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import request from '@/utils/request'

// datax插件api

export function getList(params) {
return request({
url: '/api/dataxPlugin',
method: 'get',
params
})
}

export function fetchPlugin(params) {
return request({
url: '/api/dataxPlugin/' + params,
method: 'get'
})
}

export function updatePlugin(data) {
return request({
url: '/api/dataxPlugin/',
method: 'put',
data
})
}

export function createPlugin(data) {
return request({
url: '/api/dataxPlugin/',
method: 'post',
data
})
}

export function deletePlugin(data) {
return request({
url: '/api/dataxPlugin/',
method: 'delete',
params: data
})
}
27 changes: 27 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,33 @@ export const asyncRoutes = [
}
]
},
{
path: '/datax',
component: Layout,
redirect: '/datax/job',
name: 'Example',
meta: { title: 'datax', icon: 'example' },
children: [
{
path: 'job',
name: '同步任务',
component: () => import('@/views/datax/job/index'),
meta: { title: '同步任务', icon: 'table', affix: true }
},
{
path: 'plugin',
name: 'DataxPlugin',
component: () => import('@/views/datax/plugin/index'),
meta: { title: '插件查看', icon: 'table' }
},
{
path: 'jobConfig',
name: 'jobConfig',
component: () => import('@/views/datax/jobConfig/index'),
meta: { title: '作业配置', icon: 'table' }
}
]
},
toolRouter,
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
Expand Down
14 changes: 11 additions & 3 deletions src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ service.interceptors.response.use(
*/
response => {
const res = response.data

// if the custom code is not 20000, it is judged as an error.
if (res.code !== 20000) {
if (res.code !== 20000 && res.code !== 0) {
Message({
message: res.message || 'Error',
type: 'error',
Expand All @@ -68,7 +67,16 @@ service.interceptors.response.use(
}
return Promise.reject(new Error(res.message || 'Error'))
} else {
return res
const { data } = response
const { code } = data
// 状态码为0表示api成功
if (code === 0) {
const { data: res } = data
return res
} else {
// 返回数据
return res
}
}
},
error => {
Expand Down
26 changes: 3 additions & 23 deletions src/views/dashboard/index.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
<template>
<div class="dashboard-container">
<component :is="currentRole" />
<div class="app-container">
nothing here
</div>
</template>

<script>
import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import editorDashboard from './editor'
export default {
name: 'Dashboard',
components: { adminDashboard, editorDashboard },
data() {
return {
currentRole: 'adminDashboard'
}
},
computed: {
...mapGetters([
'roles'
])
},
created() {
if (!this.roles.includes('admin')) {
this.currentRole = 'editorDashboard'
}
}
name: 'Dashboard'
}
</script>
31 changes: 31 additions & 0 deletions src/views/dashboard/index_copy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<div class="dashboard-container">
<component :is="currentRole" />
</div>
</template>

<script>
import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import editorDashboard from './editor'
export default {
name: 'Dashboard',
components: { adminDashboard, editorDashboard },
data() {
return {
currentRole: 'adminDashboard'
}
},
computed: {
...mapGetters([
'roles'
])
},
created() {
if (!this.roles.includes('admin')) {
this.currentRole = 'editorDashboard'
}
}
}
</script>
Loading

0 comments on commit 6bb978b

Please sign in to comment.