mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-28 17:50:56 +01:00
Backend:
1.[improve]
使用gin提供的RouteGroup功能简化中间件逻辑
2.[break change]
移除Authorization Middleware中对登录注册下载特殊处理逻辑
3.[unsafe problem]
下载任务csv增加登录验证
Frontend:
1. 更改csv下载方式
2. task list页面table section 移除固定width设置,采用自适应,防止大屏空白断裂问题
This commit is contained in:
@@ -3,7 +3,7 @@ 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) => {
|
||||
const request = (method, path, params, data, others = {}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = baseUrl + path
|
||||
const headers = {
|
||||
@@ -14,7 +14,8 @@ const request = (method, path, params, data) => {
|
||||
url,
|
||||
params,
|
||||
data,
|
||||
headers
|
||||
headers,
|
||||
...others
|
||||
})
|
||||
.then(resolve)
|
||||
.catch(error => {
|
||||
|
||||
@@ -120,6 +120,22 @@ 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
|
||||
})
|
||||
const downloadUrl = window.URL.createObjectURL(new Blob([data]))
|
||||
|
||||
const link = document.createElement('a')
|
||||
|
||||
link.href = downloadUrl
|
||||
|
||||
link.setAttribute('download', 'data.csv') // any other extension
|
||||
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
},
|
||||
cancelTask ({ state, dispatch }, id) {
|
||||
return request.post(`/tasks/${id}/cancel`)
|
||||
.then(() => {
|
||||
|
||||
@@ -95,7 +95,7 @@ export default {
|
||||
this.$store.dispatch('task/getTaskResults', this.$route.params.id)
|
||||
},
|
||||
downloadCSV () {
|
||||
window.location.href = this.$request.baseUrl + '/tasks/' + this.$route.params.id + '/results/download'
|
||||
this.$store.dispatch('task/getTaskResultExcel', this.$route.params.id)
|
||||
this.$st.sendEv('任务详情-结果', '下载CSV')
|
||||
}
|
||||
},
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
:label="$t(col.label)"
|
||||
:sortable="col.sortable"
|
||||
:align="col.align"
|
||||
:width="col.width">
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<a href="javascript:" class="a-tag" @click="onClickSpider(scope.row)">{{scope.row[col.name]}}</a>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user