diff --git a/.env.development b/.env.development index 8f5856d..6d08777 100644 --- a/.env.development +++ b/.env.development @@ -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(). diff --git a/src/api/datax-job.js b/src/api/datax-job.js new file mode 100644 index 0000000..fa680b0 --- /dev/null +++ b/src/api/datax-job.js @@ -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 + }) +} diff --git a/src/api/datax-jobConfig.js b/src/api/datax-jobConfig.js new file mode 100644 index 0000000..11f5d9a --- /dev/null +++ b/src/api/datax-jobConfig.js @@ -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 + }) +} diff --git a/src/api/datax-plugin.js b/src/api/datax-plugin.js new file mode 100644 index 0000000..c538215 --- /dev/null +++ b/src/api/datax-plugin.js @@ -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 + }) +} diff --git a/src/router/index.js b/src/router/index.js index c923da9..1b1b222 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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 } diff --git a/src/utils/request.js b/src/utils/request.js index 2fb95ac..9e6501e 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -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', @@ -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 => { diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 1720ea8..058f46c 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,31 +1,11 @@ diff --git a/src/views/dashboard/index_copy.vue b/src/views/dashboard/index_copy.vue new file mode 100644 index 0000000..1720ea8 --- /dev/null +++ b/src/views/dashboard/index_copy.vue @@ -0,0 +1,31 @@ + + + diff --git a/src/views/datax/job/index.vue b/src/views/datax/job/index.vue new file mode 100644 index 0000000..34b4ed0 --- /dev/null +++ b/src/views/datax/job/index.vue @@ -0,0 +1,189 @@ + + + + + diff --git a/src/views/datax/jobConfig/index.vue b/src/views/datax/jobConfig/index.vue new file mode 100644 index 0000000..90d1a7c --- /dev/null +++ b/src/views/datax/jobConfig/index.vue @@ -0,0 +1,225 @@ + + + diff --git a/src/views/datax/jobLog/index.vue b/src/views/datax/jobLog/index.vue new file mode 100644 index 0000000..5e75c32 --- /dev/null +++ b/src/views/datax/jobLog/index.vue @@ -0,0 +1,254 @@ + + + diff --git a/src/views/datax/plugin/index.vue b/src/views/datax/plugin/index.vue new file mode 100644 index 0000000..edc4867 --- /dev/null +++ b/src/views/datax/plugin/index.vue @@ -0,0 +1,254 @@ + + + diff --git a/vue.config.js b/vue.config.js index 2b8bdd1..3d93261 100644 --- a/vue.config.js +++ b/vue.config.js @@ -6,11 +6,11 @@ function resolve(dir) { return path.join(__dirname, dir) } -const name = defaultSettings.title || 'Z-TOOLBOX' // page title +const name = defaultSettings.title || 'DATAX-ADMIN' // page title // If your port is set to 80, // use administrator privileges to execute the command line. // For example, Mac: sudo npm run -const port = 9666 // dev port +const port = 8081 // dev port // All configuration item explanations can be find in https://cli.vuejs.org/config/ module.exports = { @@ -34,8 +34,17 @@ module.exports = { errors: true }, proxy: { - // change xxx-api/login => mock/login // detail: https://cli.vuejs.org/config/#devserver-proxy + //代理 /dev-api/api 到 http://localhost:8066/api + [process.env.VUE_APP_API]: { + target: `http://localhost:8066/api`, + changeOrigin: true, + pathRewrite: { + ['^' + process.env.VUE_APP_API]: '' + } + }, + // mock 的代理 + // change xxx-api/login => mock/login [process.env.VUE_APP_BASE_API]: { target: `http://localhost:${port}/mock`, changeOrigin: true,