mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
Merge pull request #197 from yaziming/0.4.x-develop
Some Improve Fronted Work.
This commit is contained in:
@@ -3,13 +3,13 @@ import router from '../router'
|
||||
|
||||
let baseUrl = process.env.VUE_APP_BASE_URL ? process.env.VUE_APP_BASE_URL : 'http://localhost:8000'
|
||||
|
||||
const request = (method, path, params, data, others = {}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = async (method, path, params, data, others = {}) => {
|
||||
try {
|
||||
const url = baseUrl + path
|
||||
const headers = {
|
||||
'Authorization': window.localStorage.getItem('token')
|
||||
}
|
||||
axios({
|
||||
const response = await axios({
|
||||
method,
|
||||
url,
|
||||
params,
|
||||
@@ -17,15 +17,37 @@ const request = (method, path, params, data, others = {}) => {
|
||||
headers,
|
||||
...others
|
||||
})
|
||||
.then(resolve)
|
||||
.catch(error => {
|
||||
console.log(error)
|
||||
if (error.response.status === 401) {
|
||||
router.push('/login')
|
||||
}
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
// console.log(response)
|
||||
return response
|
||||
} catch (e) {
|
||||
if (e.response.status === 401 && router.currentRoute.path !== '/login') {
|
||||
router.push('/login')
|
||||
}
|
||||
await Promise.reject(e)
|
||||
}
|
||||
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const url = baseUrl + path
|
||||
// const headers = {
|
||||
// 'Authorization': window.localStorage.getItem('token')
|
||||
// }
|
||||
// axios({
|
||||
// method,
|
||||
// url,
|
||||
// params,
|
||||
// data,
|
||||
// headers,
|
||||
// ...others
|
||||
// })
|
||||
// .then(resolve)
|
||||
// .catch(error => {
|
||||
// console.log(error)
|
||||
// if (error.response.status === 401) {
|
||||
// router.push('/login')
|
||||
// }
|
||||
// reject(error)
|
||||
// })
|
||||
// })
|
||||
}
|
||||
|
||||
const get = (path, params) => {
|
||||
|
||||
@@ -247,7 +247,7 @@ export default {
|
||||
'username already exists': '用户名已存在',
|
||||
'Deleted successfully': '成功删除',
|
||||
'Saved successfully': '成功保存',
|
||||
|
||||
'English': 'English',
|
||||
// 登录
|
||||
'Sign in': '登录',
|
||||
'Sign-in': '登录',
|
||||
@@ -266,5 +266,20 @@ export default {
|
||||
'admin': '管理用户',
|
||||
'Role': '角色',
|
||||
'Edit User': '更改用户',
|
||||
'Users': '用户'
|
||||
'Users': '用户',
|
||||
tagsView: {
|
||||
closeOthers: '关闭其他',
|
||||
close: '关闭',
|
||||
refresh: '刷新',
|
||||
closeAll: '关闭所有'
|
||||
},
|
||||
nodeList: {
|
||||
type: '节点类型'
|
||||
},
|
||||
schedules: {
|
||||
cron: 'Cron',
|
||||
add_cron: '生成Cron',
|
||||
// Cron Format: [second] [minute] [hour] [day of month] [month] [day of week]
|
||||
cron_format: 'Cron 格式: [秒] [分] [小时] [日] [月] [周]'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ export const constantRouterMap = [
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Node',
|
||||
path: '/nodes',
|
||||
component: Layout,
|
||||
meta: {
|
||||
@@ -76,7 +75,6 @@ export const constantRouterMap = [
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Spider',
|
||||
path: '/spiders',
|
||||
component: Layout,
|
||||
meta: {
|
||||
@@ -106,7 +104,6 @@ export const constantRouterMap = [
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
path: '/tasks',
|
||||
component: Layout,
|
||||
meta: {
|
||||
@@ -136,7 +133,6 @@ export const constantRouterMap = [
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Schedule',
|
||||
path: '/schedules',
|
||||
component: Layout,
|
||||
meta: {
|
||||
@@ -157,7 +153,6 @@ export const constantRouterMap = [
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Site',
|
||||
path: '/sites',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
@@ -178,7 +173,6 @@ export const constantRouterMap = [
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
path: '/users',
|
||||
component: Layout,
|
||||
meta: {
|
||||
|
||||
@@ -163,7 +163,7 @@ export default {
|
||||
columns: [
|
||||
{ name: 'name', label: 'Name', width: '220' },
|
||||
{ name: 'ip', label: 'IP', width: '160' },
|
||||
{ name: 'type', label: 'Type', width: '120' },
|
||||
{ name: 'type', label: 'nodeList.type', width: '120' },
|
||||
// { name: 'port', label: 'Port', width: '80' },
|
||||
{ name: 'status', label: 'Status', width: '120' },
|
||||
{ name: 'description', label: 'Description', width: 'auto' }
|
||||
|
||||
@@ -38,21 +38,21 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('Cron')" prop="cron" :rules="cronRules" required>
|
||||
<el-form-item :label="$t('schedules.cron')" prop="cron" :rules="cronRules" required>
|
||||
<template slot="label">
|
||||
<el-tooltip :content="$t('Cron Format: [second] [minute] [hour] [day of month] [month] [day of week]')"
|
||||
<el-tooltip :content="$t('schedules.cron_format')"
|
||||
placement="top">
|
||||
<span>
|
||||
{{$t('Cron')}}
|
||||
{{$t('schedules.cron')}}
|
||||
<i class="fa fa-exclamation-circle"></i>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<el-input style="width:calc(100% - 100px);padding-right:10px"
|
||||
v-model="scheduleForm.cron"
|
||||
:placeholder="$t('Cron')">
|
||||
:placeholder="$t('schedules.cron')">
|
||||
</el-input>
|
||||
<el-button size="small" style="width:100px" type="primary" @click="onShowCronDialog">{{$t('生成Cron')}}</el-button>
|
||||
<el-button size="small" style="width:100px" type="primary" @click="onShowCronDialog">{{$t('schedules.add_cron')}}</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('Execute Command')" prop="params">
|
||||
<el-input v-model="spider.cmd"
|
||||
@@ -156,7 +156,7 @@ export default {
|
||||
return {
|
||||
columns: [
|
||||
{ name: 'name', label: 'Name', width: '180' },
|
||||
{ name: 'cron', label: 'Cron', width: '120' },
|
||||
{ name: 'cron', label: 'schedules.cron', width: '120' },
|
||||
{ name: 'node_name', label: 'Node', width: '150' },
|
||||
{ name: 'spider_name', label: 'Spider', width: '150' },
|
||||
{ name: 'description', label: 'Description', width: 'auto' }
|
||||
|
||||
Reference in New Issue
Block a user