mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-25 17:42:25 +01:00
* 增加Docker开发环境
* 更新Dockerfile构建文件,升级NodeJS依赖版本。 * 遵循ESLint重新格式化代码,修复部分警告 * 登录Token失效增加登出提示 * 网络请求问题增加错误错误提示 * 升级UI依赖库
This commit is contained in:
@@ -36,20 +36,20 @@ const state = {
|
||||
}
|
||||
|
||||
const getters = {
|
||||
taskResultsColumns (state) {
|
||||
taskResultsColumns(state) {
|
||||
if (!state.taskResultsData || !state.taskResultsData.length) {
|
||||
return []
|
||||
}
|
||||
const keys = []
|
||||
const item = state.taskResultsData[0]
|
||||
for (const key in item) {
|
||||
if (item.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(item, key)) {
|
||||
keys.push(key)
|
||||
}
|
||||
}
|
||||
return keys
|
||||
},
|
||||
logData (state) {
|
||||
logData(state) {
|
||||
const data = state.taskLog
|
||||
.map((d, i) => {
|
||||
return {
|
||||
@@ -71,7 +71,7 @@ const getters = {
|
||||
}
|
||||
return data
|
||||
},
|
||||
errorLogData (state, getters) {
|
||||
errorLogData(state, getters) {
|
||||
const idxList = getters.logData.map(d => d._id)
|
||||
return state.errorLogData.map(d => {
|
||||
const idx = idxList.indexOf(d._id)
|
||||
@@ -82,82 +82,82 @@ const getters = {
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_TASK_FORM (state, value) {
|
||||
SET_TASK_FORM(state, value) {
|
||||
state.taskForm = value
|
||||
},
|
||||
SET_TASK_LIST (state, value) {
|
||||
SET_TASK_LIST(state, value) {
|
||||
state.taskList = value
|
||||
},
|
||||
SET_TASK_LOG (state, value) {
|
||||
SET_TASK_LOG(state, value) {
|
||||
state.taskLog = value
|
||||
},
|
||||
SET_TASK_LOG_TOTAL (state, value) {
|
||||
SET_TASK_LOG_TOTAL(state, value) {
|
||||
state.taskLogTotal = value
|
||||
},
|
||||
SET_CURRENT_LOG_INDEX (state, value) {
|
||||
SET_CURRENT_LOG_INDEX(state, value) {
|
||||
state.currentLogIndex = value
|
||||
},
|
||||
SET_TASK_RESULTS_DATA (state, value) {
|
||||
SET_TASK_RESULTS_DATA(state, value) {
|
||||
state.taskResultsData = value
|
||||
},
|
||||
SET_TASK_RESULTS_COLUMNS (state, value) {
|
||||
SET_TASK_RESULTS_COLUMNS(state, value) {
|
||||
state.taskResultsColumns = value
|
||||
},
|
||||
SET_PAGE_NUM (state, value) {
|
||||
SET_PAGE_NUM(state, value) {
|
||||
state.pageNum = value
|
||||
},
|
||||
SET_PAGE_SIZE (state, value) {
|
||||
SET_PAGE_SIZE(state, value) {
|
||||
state.pageSize = value
|
||||
},
|
||||
SET_TASK_LIST_TOTAL_COUNT (state, value) {
|
||||
SET_TASK_LIST_TOTAL_COUNT(state, value) {
|
||||
state.taskListTotalCount = value
|
||||
},
|
||||
SET_RESULTS_PAGE_NUM (state, value) {
|
||||
SET_RESULTS_PAGE_NUM(state, value) {
|
||||
state.resultsPageNum = value
|
||||
},
|
||||
SET_RESULTS_PAGE_SIZE (state, value) {
|
||||
SET_RESULTS_PAGE_SIZE(state, value) {
|
||||
state.resultsPageSize = value
|
||||
},
|
||||
SET_TASK_RESULTS_TOTAL_COUNT (state, value) {
|
||||
SET_TASK_RESULTS_TOTAL_COUNT(state, value) {
|
||||
state.taskResultsTotalCount = value
|
||||
},
|
||||
SET_LOG_KEYWORD (state, value) {
|
||||
SET_LOG_KEYWORD(state, value) {
|
||||
state.logKeyword = value
|
||||
},
|
||||
SET_ERROR_LOG_DATA (state, value) {
|
||||
SET_ERROR_LOG_DATA(state, value) {
|
||||
state.errorLogData = value
|
||||
},
|
||||
SET_TASK_LOG_PAGE (state, value) {
|
||||
SET_TASK_LOG_PAGE(state, value) {
|
||||
state.taskLogPage = value
|
||||
},
|
||||
SET_TASK_LOG_PAGE_SIZE (state, value) {
|
||||
SET_TASK_LOG_PAGE_SIZE(state, value) {
|
||||
state.taskLogPageSize = value
|
||||
},
|
||||
SET_IS_LOG_AUTO_SCROLL (state, value) {
|
||||
SET_IS_LOG_AUTO_SCROLL(state, value) {
|
||||
state.isLogAutoScroll = value
|
||||
},
|
||||
SET_IS_LOG_AUTO_FETCH (state, value) {
|
||||
SET_IS_LOG_AUTO_FETCH(state, value) {
|
||||
state.isLogAutoFetch = value
|
||||
},
|
||||
SET_IS_LOG_FETCH_LOADING (state, value) {
|
||||
SET_IS_LOG_FETCH_LOADING(state, value) {
|
||||
state.isLogFetchLoading = value
|
||||
},
|
||||
SET_ACTIVE_ERROR_LOG_ITEM (state, value) {
|
||||
SET_ACTIVE_ERROR_LOG_ITEM(state, value) {
|
||||
state.activeErrorLogItem = value
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
getTaskData ({ state, dispatch, commit }, id) {
|
||||
getTaskData({ state, dispatch, commit }, id) {
|
||||
return request.get(`/tasks/${id}`)
|
||||
.then(response => {
|
||||
let data = response.data.data
|
||||
const data = response.data.data
|
||||
commit('SET_TASK_FORM', data)
|
||||
dispatch('spider/getSpiderData', data.spider_id, { root: true })
|
||||
dispatch('node/getNodeData', data.node_id, { root: true })
|
||||
})
|
||||
},
|
||||
getTaskList ({ state, commit }) {
|
||||
getTaskList({ state, commit }) {
|
||||
return request.get('/tasks', {
|
||||
page_num: state.pageNum,
|
||||
page_size: state.pageSize,
|
||||
@@ -171,24 +171,24 @@ const actions = {
|
||||
commit('SET_TASK_LIST_TOTAL_COUNT', response.data.total)
|
||||
})
|
||||
},
|
||||
deleteTask ({ state, dispatch }, id) {
|
||||
deleteTask({ state, dispatch }, id) {
|
||||
return request.delete(`/tasks/${id}`)
|
||||
.then(() => {
|
||||
dispatch('getTaskList')
|
||||
})
|
||||
},
|
||||
deleteTaskMultiple ({ state }, ids) {
|
||||
deleteTaskMultiple({ state }, ids) {
|
||||
return request.delete(`/tasks`, {
|
||||
ids: ids
|
||||
})
|
||||
},
|
||||
restartTask ({ state, dispatch }, id) {
|
||||
restartTask({ state, dispatch }, id) {
|
||||
return request.post(`/tasks/${id}/restart`)
|
||||
.then(() => {
|
||||
dispatch('getTaskList')
|
||||
})
|
||||
},
|
||||
getTaskLog ({ state, commit }, { id, keyword }) {
|
||||
getTaskLog({ state, commit }, { id, keyword }) {
|
||||
return request.get(`/tasks/${id}/log`, {
|
||||
keyword,
|
||||
page_num: state.taskLogPage,
|
||||
@@ -199,18 +199,20 @@ const actions = {
|
||||
commit('SET_TASK_LOG_TOTAL', response.data.total || 0)
|
||||
|
||||
// auto switch to next page if not reaching the end
|
||||
if (state.isLogAutoScroll && state.taskLogTotal > (state.taskLogPage * state.taskLogPageSize)) {
|
||||
commit('SET_TASK_LOG_PAGE', Math.ceil(state.taskLogTotal / state.taskLogPageSize))
|
||||
if (state.isLogAutoScroll && state.taskLogTotal >
|
||||
(state.taskLogPage * state.taskLogPageSize)) {
|
||||
commit('SET_TASK_LOG_PAGE',
|
||||
Math.ceil(state.taskLogTotal / state.taskLogPageSize))
|
||||
}
|
||||
})
|
||||
},
|
||||
getTaskErrorLog ({ state, commit }, id) {
|
||||
getTaskErrorLog({ state, commit }, id) {
|
||||
return request.get(`/tasks/${id}/error-log`, {})
|
||||
.then(response => {
|
||||
commit('SET_ERROR_LOG_DATA', response.data.data || [])
|
||||
})
|
||||
},
|
||||
getTaskResults ({ state, commit }, id) {
|
||||
getTaskResults({ state, commit }, id) {
|
||||
return request.get(`/tasks/${id}/results`, {
|
||||
page_num: state.resultsPageNum,
|
||||
page_size: state.resultsPageSize
|
||||
@@ -221,10 +223,11 @@ const actions = {
|
||||
commit('SET_TASK_RESULTS_TOTAL_COUNT', response.data.total)
|
||||
})
|
||||
},
|
||||
async getTaskResultExcel ({ state, commit }, id) {
|
||||
const { data } = await request.request('GET', '/tasks/' + id + '/results/download', {}, {
|
||||
responseType: 'blob' // important
|
||||
})
|
||||
async getTaskResultExcel({ state, commit }, id) {
|
||||
const { data } = await request.request('GET',
|
||||
'/tasks/' + id + '/results/download', {}, {
|
||||
responseType: 'blob' // important
|
||||
})
|
||||
const downloadUrl = window.URL.createObjectURL(new Blob([data]))
|
||||
|
||||
const link = document.createElement('a')
|
||||
@@ -237,7 +240,7 @@ const actions = {
|
||||
link.click()
|
||||
link.remove()
|
||||
},
|
||||
cancelTask ({ state, dispatch }, id) {
|
||||
cancelTask({ state, dispatch }, id) {
|
||||
return new Promise(resolve => {
|
||||
request.post(`/tasks/${id}/cancel`)
|
||||
.then(res => {
|
||||
|
||||
Reference in New Issue
Block a user