fix:修复licenseMange 无法正常下载的问题

This commit is contained in:
zhangyu
2023-10-20 18:09:48 +08:00
parent 25c7e314af
commit 3fa0f29648
2 changed files with 17 additions and 10 deletions

View File

@@ -167,16 +167,17 @@ export default {
} }
params.saId = this.obj.id params.saId = this.obj.id
axios.get('/license/downloadC2V', { responseType: 'blob', params: params }).then(res => { axios.get('/license/downloadC2V', { responseType: 'blob', params: params }).then(res => {
const filename = params.name ? params.name : (this.obj.name + '.csv')
if (window.navigator.msSaveOrOpenBlob) { if (window.navigator.msSaveOrOpenBlob) {
// 兼容ie11 // 兼容ie11
const blobObject = new Blob([res.data]) const blobObject = new Blob([res.data])
window.navigator.msSaveOrOpenBlob(blobObject, params.name) window.navigator.msSaveOrOpenBlob(blobObject, filename)
} else { } else {
const url = URL.createObjectURL(new Blob([res.data])) const url = URL.createObjectURL(new Blob([res.data]))
const a = document.createElement('a') const a = document.createElement('a')
document.body.appendChild(a) // 此处增加了将创建的添加到body当中 document.body.appendChild(a) // 此处增加了将创建的添加到body当中
a.href = url a.href = url
a.download = params.name a.download = filename
a.target = '_blank' a.target = '_blank'
a.click() a.click()
a.remove() // 将a标签移除 a.remove() // 将a标签移除

View File

@@ -415,13 +415,9 @@ export default {
if (!baseUrl || baseUrl == '/') { if (!baseUrl || baseUrl == '/') {
baseUrl = window.location.protocol + '//' + window.location.host baseUrl = window.location.protocol + '//' + window.location.host
} }
// let metadataOptions = await this.$get('prom/api/v1/metadata') const defaultHeaders = {
// console.log(metadataOptions) Authorization: localStorage.getItem('nz-token')
// metadataOptions = metadataOptions.data }
// let metricsdataOptions = await this.$get('prom//api/v1/label/__name__/values')
// console.log(metricsdataOptions)
// metricsdataOptions = metricsdataOptions.data
const promqlExtension = new PromQLExtension() const promqlExtension = new PromQLExtension()
.activateCompletion(true) .activateCompletion(true)
.activateLinter(true) .activateLinter(true)
@@ -430,7 +426,16 @@ export default {
newCompleteStrategy({ newCompleteStrategy({
remote: { remote: {
url: baseUrl + '/prom/', url: baseUrl + '/prom/',
fetchFn: self.fetchFn fetchFn: (resource, options = {}) => {
const params = options.body?.toString()
const search = params ? `?${params}` : ''
return fetch(resource + search, {
method: 'Get',
headers: new Headers(
defaultHeaders
)
})
}
}, },
maxMetricsMetadata: 99999 maxMetricsMetadata: 99999
}) })
@@ -462,6 +467,7 @@ export default {
})), })),
span: /^[a-zA-Z0-9_:]+$/ span: /^[a-zA-Z0-9_:]+$/
} }
// 过滤 非logs的函数
if (res !== null) { if (res !== null) {
historyItems.options = historyItems.options.concat(res.options) historyItems.options = historyItems.options.concat(res.options)
} }