mirror of https://github.com/halo-dev/halo
feat: support download log file.
parent
a7419dcec7
commit
ece59a0a56
|
@ -22,13 +22,13 @@
|
||||||
help="* 需要加上 http://"
|
help="* 需要加上 http://"
|
||||||
>
|
>
|
||||||
<a-input v-model="link.url">
|
<a-input v-model="link.url">
|
||||||
<a
|
<!-- <a
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
slot="addonAfter"
|
slot="addonAfter"
|
||||||
@click="handleParseUrl"
|
@click="handleParseUrl"
|
||||||
>
|
>
|
||||||
<a-icon type="sync" />
|
<a-icon type="sync" />
|
||||||
</a>
|
</a> -->
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="Logo:">
|
<a-form-item label="Logo:">
|
||||||
|
|
|
@ -28,7 +28,10 @@
|
||||||
style="margin-right: 8px;"
|
style="margin-right: 8px;"
|
||||||
@click="()=>this.loadLogs()"
|
@click="()=>this.loadLogs()"
|
||||||
>刷新</a-button>
|
>刷新</a-button>
|
||||||
<a-button type="dashed" @click="handleDownloadLogFile()">下载</a-button>
|
<a-button
|
||||||
|
type="dashed"
|
||||||
|
@click="handleDownloadLogFile()"
|
||||||
|
>下载</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -36,6 +39,7 @@
|
||||||
import { codemirror } from 'vue-codemirror-lite'
|
import { codemirror } from 'vue-codemirror-lite'
|
||||||
import 'codemirror/mode/shell/shell.js'
|
import 'codemirror/mode/shell/shell.js'
|
||||||
import adminApi from '@/api/admin'
|
import adminApi from '@/api/admin'
|
||||||
|
import moment from 'moment'
|
||||||
export default {
|
export default {
|
||||||
name: 'RuntimeLogs',
|
name: 'RuntimeLogs',
|
||||||
components: {
|
components: {
|
||||||
|
@ -66,9 +70,27 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleDownloadLogFile() {
|
handleDownloadLogFile() {
|
||||||
adminApi.downloadLogFiles(this.logLines).then(response => {
|
const hide = this.$message.loading('下载中...', 0)
|
||||||
|
adminApi
|
||||||
|
.getLogFiles(this.logLines)
|
||||||
|
.then(response => {
|
||||||
|
var blob = new Blob([response.data.data])
|
||||||
|
var downloadElement = document.createElement('a')
|
||||||
|
var href = window.URL.createObjectURL(blob)
|
||||||
|
downloadElement.href = href
|
||||||
|
downloadElement.download = 'halo-log-' + moment(new Date(), 'YYYY-MM-DD-HH-mm-ss') + '.log'
|
||||||
|
document.body.appendChild(downloadElement)
|
||||||
|
downloadElement.click()
|
||||||
|
document.body.removeChild(downloadElement)
|
||||||
|
window.URL.revokeObjectURL(href)
|
||||||
this.$message.success('下载成功!')
|
this.$message.success('下载成功!')
|
||||||
})
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message.error('下载失败!')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hide()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleLinesChange(value) {
|
handleLinesChange(value) {
|
||||||
this.logLines = value
|
this.logLines = value
|
||||||
|
|
Loading…
Reference in New Issue