mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
新增 下载日志功能
This commit is contained in:
@@ -38,9 +38,17 @@
|
||||
v-for="(name,index) in names" :index="index" :label="name" :value="name">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-button type="primary" @click="showLog" size="small">查看日志</el-button>
|
||||
<el-popconfirm title="确定删除此站点信息吗?" @confirm="removeLog">
|
||||
<el-button type="danger" size="small" slot="reference">删除日志</el-button>
|
||||
<el-link type="success" size="small"
|
||||
icon="fas fa-download"
|
||||
:href="'{% url 'download_log_file' %}' + '?name=' + log">下载
|
||||
</el-link>
|
||||
<el-button type="primary" @click="showLog" size="small" icon="fas fa-eye">
|
||||
查看
|
||||
</el-button>
|
||||
<el-popconfirm title="确定删除日志吗?" @confirm="removeLog">
|
||||
<el-button type="danger" size="small" icon="fas fa-trash"
|
||||
slot="reference">删除
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
<el-container style="height: 780px; border: 1px solid #eee;margin-top: 5px;">
|
||||
@@ -138,6 +146,36 @@
|
||||
});
|
||||
})
|
||||
},
|
||||
downloadLog() {
|
||||
axios({
|
||||
method: "get",
|
||||
headers: {
|
||||
"content-type": "application/json", // 默认值
|
||||
Authorization: "Bearer " + sessionStorage.getItem("access_token"),
|
||||
},
|
||||
url: "{% url 'download_log_file' %}" + '?name=' + this.log,
|
||||
responseType: "blob",
|
||||
}).then(res => {
|
||||
console.log('日志文件', res)
|
||||
{#let data = res.data#}
|
||||
{#console.log(typeof res.data.data)#}
|
||||
if (res.headers['content-type'] === 'application/octet-stream;charset=utf-8') {
|
||||
return res.data
|
||||
} else {
|
||||
this.loading = false
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '删除日志文件失败!'
|
||||
});
|
||||
}
|
||||
}).catch(res => {
|
||||
console.log('删除日志文件失败', res)
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '删除日志文件失败!' + res
|
||||
});
|
||||
})
|
||||
},
|
||||
removeLog() {
|
||||
if (this.log == 'logs.log') {
|
||||
this.$message({
|
||||
|
||||
Reference in New Issue
Block a user