fix: 废弃http.js的封装请求方法

This commit is contained in:
chenjinsong
2023-08-25 10:18:20 +08:00
parent 7f91d75792
commit f4ba0040ea
33 changed files with 244 additions and 332 deletions

View File

@@ -43,7 +43,7 @@
<button :id="id+'-json-import-template'" class="el-button el-button--default el-button--small" @click="downloadTemplate">
<span>{{$t('overall.template')}}</span>
</button>
<button :id="id+'-json-import-add'" :class="{'cn-btn-disabled':prevent_opt.import}" :disabled="prevent_opt.import" class="cn-btn el-button el-button--default el-button--small" @click="importJson">
<button :id="id+'-json-import-add'" :class="{'cn-btn-disabled':blockOperation.import}" :disabled="blockOperation.import" class="cn-btn el-button el-button--default el-button--small" @click="importJson">
<span>{{$t('overall.import')}}</span>
</button>
<button :id="id+'-json-import-esc'" class="el-button el-button--default el-button--small" @click="closeDialog">
@@ -58,7 +58,6 @@
<script>
import axios from 'axios'
import { post } from '@/utils/http'
import { storageKey } from '@/utils/constants'
export default {
@@ -103,20 +102,20 @@ export default {
},
importJson () {
if (this.importFile && this.importFile.raw) {
this.prevent_opt.import = true
this.blockOperation.import = true
const form = new FormData()
form.append('file', this.importFile.raw)
if (this.paramsType) {
form.append('type', this.paramsType)
}
form.append('language', localStorage.getItem(storageKey.language) ? localStorage.getItem(storageKey.language) : 'en')
post(this.importUrl, form, { 'Content-Type': 'multipart/form-data' }).then(response => {
if (response.code == 200 && response.msg == 'success') {
axios.post(this.importUrl, form, { 'Content-Type': 'multipart/form-data' }).then(response => {
if (response.status === 200 && response.data.msg === 'success') {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.importSuccess') })
} else {
this.$message.error(response.msg)
}
this.prevent_opt.import = false
this.blockOperation.import = false
})
} else {
this.$message.error(this.$t('tip.noImportFile'))

View File

@@ -276,7 +276,7 @@ import rightBoxMixin from '@/mixins/right-box'
import { storageKey, report } from '@/utils/constants'
import { api } from '@/utils/api'
import _ from 'lodash'
import { get, post, put } from '@/utils/http'
import axios from 'axios'
import { dateFormat, getMillisecond } from '@/utils/date-util'
import { ref, getCurrentInstance } from 'vue'
import i18n from '@/i18n'
@@ -527,11 +527,11 @@ export default {
if (_.isArray(this.editObject.categoryParams) && !_.isEmpty(this.editObject.categoryParams)) {
this.editObject.categoryParams.forEach(param => {
if (!this.paramsOptions.some(p => p.key === param.key)) {
get(api.dict, { type: param.key, pageSize: -1 }).then(response => {
if (response.code === 200) {
axios.get(api.dict, { params: { type: param.key, pageSize: -1 } }).then(response => {
if (response.status === 200) {
this.paramsOptions.push({
key: param.key,
options: response.data.list.map(d => d.value)
options: response.data.data.list.map(d => d.value)
})
}
})
@@ -627,23 +627,23 @@ export default {
if (this.validateScheduleConfig(copyObject)) {
copyObject.config = JSON.stringify(copyObject.config)
if (copyObject.id) {
put(this.url, copyObject).then(res => {
axios.put(this.url, copyObject).then(res => {
this.blockOperation.save = false
if (res.code === 200) {
if (res.status === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(res.msg)
this.$message.error(res.data.message)
}
})
} else {
post(this.url, copyObject).then(res => {
axios.post(this.url, copyObject).then(res => {
this.blockOperation.save = false
if (res.code === 200) {
if (res.status === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(res.msg)
this.$message.error(res.data.message)
}
})
}

View File

@@ -132,7 +132,7 @@
<script>
import rightBoxMixin from '@/mixins/right-box'
import { get, post, put } from '@/utils/http'
import axios from 'axios'
import { panelTypeAndRouteMapping, storageKey } from '@/utils/constants'
import { api } from '@/utils/api'
import { VAceEditor } from 'vue3-ace-editor'
@@ -370,23 +370,23 @@ export default {
this.$refs.chartForm.validate((valid) => {
if (valid) {
if (this.editObject.id) {
put(this.url, this.editObject).then(res => {
axios.put(this.url, this.editObject).then(res => {
this.blockOperation.save = false
if (res.code === 200) {
if (res.status === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(res.msg || res.message)
this.$message.error(res.data.message)
}
})
} else {
post(this.url, this.editObject).then(res => {
axios.post(this.url, this.editObject).then(res => {
this.blockOperation.save = false
if (res.code === 200) {
if (res.status === 200) {
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
} else {
this.$message.error(res.msg || res.message)
this.$message.error(res.data.message)
}
})
}

View File

@@ -100,9 +100,8 @@
</template>
<script>
import { ref, defineComponent } from 'vue'
import { api } from '@/utils/api'
import { get, getForDebug, postForDebug } from '@/utils/http'
import { getForDebug, postForDebug } from '@/utils/http'
import axios from 'axios'
import { VAceEditor } from 'vue3-ace-editor'
import 'ace-builds/src-noconflict/mode-javascript'
@@ -234,9 +233,9 @@ export default {
},
async getGalaxyProxyData (value) {
await get(api.galaxyProxy + '?pageSize=-1').then(response => {
if (response.code === 200) {
this.galaxyProxyData = response.data.list
await axios.get(api.galaxyProxy + '?pageSize=-1').then(response => {
if (response.status === 200) {
this.galaxyProxyData = response.data.data.list
}
})
},

View File

@@ -60,7 +60,6 @@
<script>
import indexedDBUtils from '@/indexedDB'
import { storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
import { get } from '@/utils/http'
export default {
props: {
customTableTitle: Array, // 自定义的title

View File

@@ -73,7 +73,7 @@
<script>
import table from '@/mixins/table'
import { put } from '@/utils/http'
import axios from 'axios'
import { storageKey } from '@/utils/constants'
export default {
@@ -147,12 +147,12 @@ export default {
// if (!user.id){
// return
// }
put('sys/user', user).then(response => {
if (response.code === 200) {
axios.put('sys/user', user).then(response => {
if (response.status === 200) {
// this.rightBox.show = false
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
} else {
this.$message.error(response.msg)
this.$message.error(response.data.message)
}
this.$emit('reload')
})

View File

@@ -107,7 +107,7 @@
<script>
import { detectionRuleType } from '@/utils/constants'
import { switchStatus } from '@/utils/tools'
import { get } from '@/utils/http'
import axios from 'axios'
import { api } from '@/utils/api'
export default {
@@ -158,12 +158,12 @@ export default {
methods: {
switchStatus,
initData () {
get(api.detection.statistics, { pageSize: -1 }).then(response => {
if (response.code === 200) {
this.categoryList = response.data.categoryList || []
this.typeList = response.data.typeList || []
axios.get(api.detection.statistics, { params: { pageSize: -1 } }).then(response => {
if (response.status === 200) {
this.categoryList = response.data.data.categoryList || []
this.typeList = response.data.data.typeList || []
} else {
console.error(response)
console.error(response.data)
}
}).finally(() => {
})

View File

@@ -63,7 +63,7 @@
import unitConvert from '@/utils/unit-convert'
import { unitTypes } from '@/utils/constants'
import { dateFormatByAppearance } from '@/utils/date-util'
import { get } from '@/utils/http'
import axios from 'axios'
import { api } from '@/utils/api'
import Loading from '@/components/common/Loading'
import ChartError from '@/components/common/Error'
@@ -127,15 +127,15 @@ export default {
params.param = data
}
get(api.detection.create.topKeys, params).then(res => {
axios.get(api.detection.create.topKeys, { params }).then(res => {
this.tableTotal = 0
this.tableData = []
if (res.code === 200) {
this.tableTotal = res.data.total
this.tableData = res.data.list
if (res.status === 200) {
this.tableTotal = res.data.data.total
this.tableData = res.data.data.list
} else {
this.httpError(res)
this.httpError(res.data)
}
}).catch(err => {
this.httpError(err)

View File

@@ -213,7 +213,7 @@
</template>
<script>
import { get } from '@/utils/http'
import axios from 'axios'
import { api } from '@/utils/api'
import HistoryTopKeys from '@/components/table/detection/HistoryTopKeys'
import { eventSeverityColor, detectionRuleType } from '@/utils/constants'
@@ -341,15 +341,15 @@ export default {
},
methods: {
initData () {
get(api.detection.statistics, { pageSize: -1 }).then(response => {
if (response.code === 200) {
this.sourceList = response.data.sourceList || []
this.levelList = response.data.levelList || []
this.conditionList = response.data.conditionList || []
this.metricList = response.data.metricList || []
this.libraryList = response.data.libraryList || []
axios.get(api.detection.statistics, { params: { pageSize: -1 } }).then(response => {
if (response.status === 200) {
this.sourceList = response.data.data.sourceList || []
this.levelList = response.data.data.levelList || []
this.conditionList = response.data.data.conditionList || []
this.metricList = response.data.data.metricList || []
this.libraryList = response.data.data.libraryList || []
} else {
console.error(response)
console.error(response.data)
}
}).finally(() => {
})

View File

@@ -210,7 +210,7 @@
<script>
import table from '@/mixins/table'
import Loading from '@/components/common/Loading'
import { del, get } from '@/utils/http'
import axios from 'axios'
import { api } from '@/utils/api'
import { storageKey, report } from '@/utils/constants'
import { urlParamsHandler, overwriteUrl } from '@/utils/tools'
@@ -624,10 +624,10 @@ export default {
dropDownQueryChange (param) {
this.loadingDown = true
this.downDataList = []
get(api.reportJob, param).then(res => {
if (res.code === 200) {
this.downDataList = res.data.list
this.pageObj.total = res.data.total
axios.get(api.reportJob, { params: param }).then(res => {
if (res.status === 200) {
this.downDataList = res.data.data.list
this.pageObj.total = res.data.data.total
this.$nextTick(() => {
this.$refs.dataTable.doLayout()
})
@@ -640,10 +640,10 @@ export default {
})
},
dataConversionProcessing (param) {
get(api.reportJob, param).then(res => {
if (res.code === 200) {
this.downDataList = res.data.list
this.pageObj.total = res.data.total
axios.get(api.reportJob, { params: param }).then(res => {
if (res.status === 200) {
this.downDataList = res.data.data.list
this.pageObj.total = res.data.data.total
}
})
},
@@ -653,8 +653,8 @@ export default {
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).then(() => {
del(api.reportJob + '?ids=' + row.id).then(response => {
if (response.code === 200) {
axios.delete(api.reportJob + '?ids=' + row.id).then(response => {
if (response.status === 200) {
this.delFlag = true
this.$message({
duration: 2000,
@@ -664,7 +664,7 @@ export default {
this.dropDownQueryChange({ tempId: props.row.id })
this.$emit('reload')
} else {
this.$message.error(response.msg)
this.$message.error(response.data.message)
}
})
}).catch(() => {})

View File

@@ -1,11 +1,10 @@
import {get} from '@/utils/http'
import axios from 'axios'
import router from '@/router'
import {getWelcomeMenu, sortByOrderNum} from '@/permission'
import {ElMessage} from 'element-plus' // dependent on utc plugin
import {dbDrilldownTableConfig, storageKey} from '@/utils/constants'
import {getConfigVersion} from '@/utils/tools'
import {api} from '@/utils/api'
import { getWelcomeMenu, sortByOrderNum } from '@/permission'
import { ElMessage } from 'element-plus' // dependent on utc plugin
import { dbDrilldownTableConfig, storageKey } from '@/utils/constants'
import { getConfigVersion } from '@/utils/tools'
import { api } from '@/utils/api'
import indexedDBUtils from '@/indexedDB'
const user = {

View File

@@ -104,77 +104,3 @@ export function postForDebug (url, params, headers) {
})
})
}
export function get (url, params) {
return new Promise((resolve) => {
axios.get(url, {
params: params
}).then(response => {
resolve(response.data)
}).catch(err => {
if (err.response) {
resolve(err.response.data)
} else if (err.message) {
resolve(err.message)
}
})
})
}
export function post (url, params, headers) {
return new Promise(resolve => {
axios.post(url, params, { headers: headers }).then(response => {
resolve(response.data, response)
}).catch(err => {
if (err.response) {
resolve(err.response.data)
} else if (err.message) {
resolve(err.message)
}
})
})
}
export function put (url, params, headers) {
return new Promise((resolve) => {
axios.put(url, params, { headers: headers }).then(response => {
resolve(response.data, response)
}).catch(err => {
if (err.response) {
resolve(err.response.data)
console.error(err)
} else if (err.message) {
resolve(err.message)
}
})
})
}
export function patch (url, params, headers) {
return new Promise((resolve) => {
axios.patch(url, params, { headers: headers }).then(response => {
resolve(response.data, response)
}).catch(err => {
if (err.response) {
resolve(err.response.data)
console.error(err)
} else if (err.message) {
resolve(err.message)
}
})
})
}
export function del (url, params) {
return new Promise((resolve) => {
axios.delete(url, params).then(response => {
resolve(response.data, response)
}).catch(err => {
if (err.response) {
resolve(err.response.data)
} else if (err.message) {
resolve(err.message)
}
})
})
}

View File

@@ -88,7 +88,7 @@ import { tableTitleMapping, legendMapping } from '@/views/charts/charts/chart-ta
import { replaceUrlPlaceholder } from '@/utils/tools'
import { getNowTime, getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import axios from 'axios'
import { ref } from 'vue'
import _ from 'lodash'
@@ -215,17 +215,17 @@ export default {
}
if (requestUrl) {
get(replaceUrlPlaceholder(requestUrl, this.queryParams)).then(response => {
if (response.code === 200) {
if (Array.isArray(response.data.result)) {
response.data.result.forEach(item => {
axios.get(replaceUrlPlaceholder(requestUrl, { params: this.queryParams })).then(response => {
if (response.status === 200) {
if (Array.isArray(response.data.data.result)) {
response.data.data.result.forEach(item => {
if (item.legend && legendMapping[`${this.entity && this.entity.ip ? 'ip_' : ''}${item.legend}`]) {
item.legend = this.$t(legendMapping[`${this.entity && this.entity.ip ? 'ip_' : ''}${item.legend}`])
}
})
}
this.chartData = response.data.result
this.resultType = response.data.resultType
this.chartData = response.data.data.result
this.resultType = response.data.data.resultType
if (isEchartsWithStatistics(this.chartInfo.type)) {
const newArr = []
_.forEach(this.chartData, function (value, key) {
@@ -244,19 +244,18 @@ export default {
})
}
if (this.isTable) {
this.table.tableData = response.data.result
this.table.tableData = response.data.data.result
this.table.tableColumns = chartParams.columns
// this.table.tableColumns = this.getTableTitle(response.data.result)
this.table.currentPageData = this.getTargetPageData(1, this.table.pageSize, this.table.tableData)
} else if (this.isSingleValue) {
if (chartParams && chartParams.dataKey) {
if (response.data.result && (response.data.result[chartParams.dataKey] || response.data.result[chartParams.dataKey] === 0)) {
this.chartData = response.data.result[chartParams.dataKey]
} else if (response.data.result && (response.data.result[chartParams.dataKey + 'Value'] || response.data.result[chartParams.dataKey + 'Value'] === 0)) {
if (response.data.data.result && (response.data.data.result[chartParams.dataKey] || response.data.data.result[chartParams.dataKey] === 0)) {
this.chartData = response.data.data.result[chartParams.dataKey]
} else if (response.data.data.result && (response.data.data.result[chartParams.dataKey + 'Value'] || response.data.data.result[chartParams.dataKey + 'Value'] === 0)) {
this.chartData = {
value: response.data.result[chartParams.dataKey + 'Value'],
p50: response.data.result[chartParams.dataKey + 'P50'],
p90: response.data.result[chartParams.dataKey + 'P90']
value: response.data.data.result[chartParams.dataKey + 'Value'],
p50: response.data.data.result[chartParams.dataKey + 'P50'],
p90: response.data.data.result[chartParams.dataKey + 'P90']
}
} else {
this.chartData = null
@@ -267,7 +266,7 @@ export default {
} else {
this.isError = true
this.noData = true
this.errorInfo = response.msg || response.message || 'Unknown'
this.errorInfo = response.data.message || 'Unknown'
}
}).finally(() => {
if (this.needTimeout && this.firstRender) {

View File

@@ -81,7 +81,7 @@ import { getTypeCategory } from '@/views/charts/charts/tools'
import { urlParamsHandler, overwriteUrl, getDnsMapData, computeScore } from '@/utils/tools'
import ChartList from '@/views/charts2/ChartList'
import { useStore } from 'vuex'
import { get } from '@/utils/http'
import axios from 'axios'
export default {
name: 'Panel',
@@ -446,14 +446,14 @@ export default {
}
if ((type && condition) || type) {
params.type = params.type || type
get(url, params).then(res => {
if (res.code === 200) {
axios.get(url, { params }).then(res => {
if (res.status === 200) {
const data = {
establishLatencyMs: res.data.result.establishLatencyMsAvg || null,
httpResponseLatency: res.data.result.httpResponseLatencyAvg || null,
sslConLatency: res.data.result.sslConLatencyAvg || null,
tcpLostlenPercent: res.data.result.tcpLostlenPercentAvg || null,
pktRetransPercent: res.data.result.pktRetransPercentAvg || null
establishLatencyMs: res.data.data.result.establishLatencyMsAvg || null,
httpResponseLatency: res.data.data.result.httpResponseLatencyAvg || null,
sslConLatency: res.data.data.result.sslConLatencyAvg || null,
tcpLostlenPercent: res.data.data.result.tcpLostlenPercentAvg || null,
pktRetransPercent: res.data.data.result.pktRetransPercentAvg || null
}
this.score = computeScore(data)
}

View File

@@ -14,7 +14,7 @@
<script>
import { shallowRef } from 'vue'
import { get } from '@/utils/http'
import axios from 'axios'
import { api } from '@/utils/api'
import chartMixin from '@/views/charts2/chart-mixin'
import dnsEventChartByPie from './DnsEventChartByPie'
@@ -62,8 +62,8 @@ export default {
endTime: getSecond(this.timeFilter.endTime)
}
this.toggleLoading(true)
get(api.dnsInsight.eventChart, params).then(res => {
const data = res.data.result
axios.get(api.dnsInsight.eventChart, { params }).then(res => {
const data = res.data.data.result
this.pieData = []
if (data !== undefined && data.length > 0) {

View File

@@ -110,7 +110,7 @@
<script>
import { api } from '@/utils/api'
import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import axios from 'axios'
import chartMixin from '@/views/charts2/chart-mixin'
import { useRoute } from 'vue-router'
import { ref } from 'vue'
@@ -206,10 +206,10 @@ export default {
severity: this.tableSeverity
}
this.toggleLoading(true)
get(api.dnsInsight.recentEvents, params).then(res => {
if (res.code === 200) {
this.isNoData = res.data.result.length === 0
this.tableData = res.data.result
axios.get(api.dnsInsight.recentEvents, { params }).then(res => {
if (res.status === 200) {
this.isNoData = res.data.data.result.length === 0
this.tableData = res.data.data.result
this.tableData.forEach((t, index) => {
if (index > 5) {
t.type = 'Security Event'

View File

@@ -73,8 +73,8 @@ import { unitTypes, chartColor3, chartColor4 } from '@/utils/constants.js'
import { ref, shallowRef } from 'vue'
import { stackedLineTooltipFormatter } from '@/views/charts/charts/tools'
import _ from 'lodash'
import { get } from '@/utils/http'
import { api } from '@/utils/api'
import axios from 'axios'
import { getSecond } from '@/utils/date-util'
import ChartNoData from '@/views/charts/charts/ChartNoData'
import chartMixin from '@/views/charts2/chart-mixin'
@@ -165,20 +165,20 @@ export default {
const url = this.queryCondition ? api.dnsInsight.drilldownTrafficAnalysis : api.dnsInsight.totalTrafficAnalysis
get(url, params).then((res) => {
if (res.code === 200) {
axios.get(url, { params }).then(res => {
if (res.status === 200) {
this.showError = false
this.isNoData = res.data.result.length === 0
this.isNoData = res.data.data.result.length === 0
if (this.isNoData) {
this.lineTab = ''
this.tabs = _.cloneDeep(dataForDnsTrafficLine.tabs)
} else {
this.initData(res.data.result, val, active, show)
this.initData(res.data.data.result, val, active, show)
}
} else {
this.isNoData = false
this.showError = true
this.errorMsg = this.errorMsgHandler(res)
this.errorMsg = this.errorMsgHandler(res.data)
}
}).catch(e => {
console.error(e)

View File

@@ -125,7 +125,6 @@ import { storageKey, unitTypes, networkTable, operationType, curTabState } from
import * as echarts from 'echarts'
import { appListChartOption } from '@/views/charts2/charts/options/echartOption'
import { shallowRef } from 'vue'
import { put } from '@/utils/http'
import { api } from '@/utils/api'
import _ from 'lodash'
import { getSecond } from '@/utils/date-util'
@@ -565,8 +564,8 @@ export default {
// 保存变更并且在增、删app后根据当前app数量更改整体高度
saveChart (toSaveChart) {
return new Promise(resolve => {
put(api.chart, toSaveChart).then(res => {
if (res.code === 200) {
axios.put(api.chart, toSaveChart).then(res => {
if (res.status === 200) {
this.emitter.emit('reloadChartList')
resolve()
}

View File

@@ -292,15 +292,13 @@ import {
drillDownPanelTypeMapping,
commonErrorTip
} from '@/utils/constants'
import { get } from '@/utils/http'
import axios from 'axios'
import unitConvert, { valueToRangeValue } from '@/utils/unit-convert'
import { getChainRatio, computeScore, urlParamsHandler, overwriteUrl, readDrilldownTableConfigByUser, combineDrilldownTableWithUserConfig, getDnsMapData, handleSpecialValue, getConfigVersion } from '@/utils/tools'
import { getSecond } from '@/utils/date-util'
import chartMixin from '@/views/charts2/chart-mixin'
import _ from 'lodash'
import axios from 'axios'
import indexedDBUtils from '@/indexedDB'
import { useRoute } from 'vue-router'
export default {
name: 'NetworkOverviewTabs',
@@ -473,8 +471,6 @@ export default {
searchColumnWidth (columnType) {
if (columnType === 'dillDown') {
return '217px'
} else {
}
},
async initDropdownList (tabProp) {
@@ -503,9 +499,9 @@ export default {
if (!curTableInCode.url.drilldownList) {
return true
}
get(curTableInCode.url.drilldownList, params).then(async response => {
if (response.code === 200) {
this.tabSearchColumnValueListShow = response.data.result
axios.get(curTableInCode.url.drilldownList, { params }).then(async response => {
if (response.status === 200) {
this.tabSearchColumnValueListShow = response.data.data.result
if (this.$route.params.typeName === fromRoute.dnsServiceInsights) {
if (this.dnsQtypeMapData.size === 0) {
this.dnsQtypeMapData = await getDnsMapData('dnsQtype')
@@ -1624,7 +1620,7 @@ export default {
initSearchInfo () {
// 切换tab的时候需要清除之前tab选中的记录的样式和值
if (this.curTabProp) {
const currentValue = document.getElementById('tabSearchValue' + this.curTabProp).value
// const currentValue = document.getElementById('tabSearchValue' + this.curTabProp).value
// 清空记录选中样式
this.tabSearchColumnValueListShow.forEach(item => {
const selectedDom = document.getElementById(item + this.curTabProp)
@@ -1636,9 +1632,9 @@ export default {
}
this.curPageNum = 1
this.showSearchButton = false, // 搜索按钮是否显示
this.showSearchInput = false, // 搜索输入框是否显示
this.showSearchList = false, // 下拉列表是否显示
this.showSearchButton = false // 搜索按钮是否显示
this.showSearchInput = false // 搜索输入框是否显示
this.showSearchList = false // 下拉列表是否显示
this.showPopover = false// 下拉列表是否显示
this.dropDownValue = ''
this.tabSearchColumnValueListShow = []

View File

@@ -68,7 +68,7 @@
<script>
import { api } from '@/utils/api'
import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import axios from 'axios'
import chartMixin from '@/views/charts2/chart-mixin'
import ChartError from '@/components/common/Error'
@@ -150,19 +150,19 @@ export default {
limit: 10,
type: this.metric
}
get(api.npm.events.dimensionEvents, params).then(res => {
if (res.code === 200) {
axios.get(api.npm.events.dimensionEvents, { params }).then(res => {
if (res.status === 200) {
this.showError = false
if (!res.data.result || res.data.result.length === 0) {
if (!res.data.data.result || res.data.data.result.length === 0) {
this.isNoData = true
}
this.tableData = res.data.result
this.tableData = res.data.data.result
} else {
this.isNoData = false
this.showError = true
this.errorMsg = this.errorMsgHandler(res)
this.errorMsg = this.errorMsgHandler(res.data)
}
}).catch((e) => {
}).catch(e => {
this.isNoData = false
this.showError = true
this.errorMsg = this.errorMsgHandler(e)

View File

@@ -17,7 +17,7 @@ import { curTabState, storageKey, unitTypes } from '@/utils/constants'
import { valueToRangeValue } from '@/utils/unit-convert'
import { getSecond } from '@/utils/date-util'
import { api, getData } from '@/utils/api'
import { get } from '@/utils/http'
import axios from 'axios'
import chartMixin from '@/views/charts2/chart-mixin'
import { useRoute } from 'vue-router'
import ChartError from '@/components/common/Error'
@@ -105,18 +105,18 @@ export default {
params: res.map(r => `'${r.countryRegion}'`).join(',')
}
// 计算分数
const tcpRequest = get(api.npm.overview.mapTcp, subParams)
const httpRequest = get(api.npm.overview.mapHttp, subParams)
const sslRequest = get(api.npm.overview.mapSsl, subParams)
const tcpLostRequest = get(api.npm.overview.mapPacketLoss, subParams)
const packetRetransRequest = get(api.npm.overview.mapPacketRetrans, subParams)
const tcpRequest = axios.get(api.npm.overview.mapTcp, { params: subParams })
const httpRequest = axios.get(api.npm.overview.mapHttp, { params: subParams })
const sslRequest = axios.get(api.npm.overview.mapSsl, { params: subParams })
const tcpLostRequest = axios.get(api.npm.overview.mapPacketLoss, { params: subParams })
const packetRetransRequest = axios.get(api.npm.overview.mapPacketRetrans, { params: subParams })
Promise.all([tcpRequest, httpRequest, sslRequest, tcpLostRequest, packetRetransRequest]).then(res2 => {
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
const mapData = res
res2.forEach((r, i) => {
if (r.code === 200) {
if (r.status === 200) {
mapData.forEach(t => {
t[keyPre[i] + 'Score'] = r.data.result.find(d => d.countryRegion === t.countryRegion && d.superAdminArea === t.superAdminArea)
t[keyPre[i] + 'Score'] = r.data.data.result.find(d => d.countryRegion === t.countryRegion && d.superAdminArea === t.superAdminArea)
})
} else {
this.showError = true

View File

@@ -126,7 +126,7 @@ export default {
side: this.side
}
params.country = n || ''
params.countryRegion = n || ''
this.toggleLoading(true)
let url

View File

@@ -56,10 +56,10 @@ import { valueToRangeValue } from '@/utils/unit-convert'
import { getSecond } from '@/utils/date-util'
import { api } from '@/utils/api'
import axios from 'axios'
import { get } from '@/utils/http'
import chartMixin from '@/views/charts2/chart-mixin'
import ChartError from '@/components/common/Error'
import _ from 'lodash'
export default {
name: 'NpmMap',
components: { ChartError },
@@ -120,7 +120,7 @@ export default {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
side: this.trafficDirection.toLowerCase(),
country: this.location
countryRegion: this.location
}
axios.get(api.npm.location.map, { params: params }).then(response => {
if (response.data.code === 200) {
@@ -129,24 +129,23 @@ export default {
// 计算分数
this.showError = false
params.countryRegion = params.countryRegion ? `'${params.countryRegion}'` : ''
const tcpRequest = get(api.npm.location.mapTcp, params)
const httpRequest = get(api.npm.location.mapHttp, params)
const sslRequest = get(api.npm.location.mapSsl, params)
const tcpLostRequest = get(api.npm.location.mapPacketLoss, params)
const packetRetransRequest = get(api.npm.location.mapPacketRetrans, params)
const tcpRequest = axios.get(api.npm.location.mapTcp, { params })
const httpRequest = axios.get(api.npm.location.mapHttp, { params })
const sslRequest = axios.get(api.npm.location.mapSsl, { params })
const tcpLostRequest = axios.get(api.npm.location.mapPacketLoss, { params })
const packetRetransRequest = axios.get(api.npm.location.mapPacketRetrans, { params })
Promise.all([tcpRequest, httpRequest, sslRequest, tcpLostRequest, packetRetransRequest]).then(res2 => {
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
const mapData = res
let msg = ''
res2.forEach((r, i) => {
if (r.code === 200) {
if (r.status === 200) {
mapData.forEach(t => {
const find = r.data.result.find(d => d.countryRegion === t.countryRegion && t.superAdminArea === d.superAdminArea)
t[keyPre[i] + 'Score'] = find
t[keyPre[i] + 'Score'] = r.data.data.result.find(d => d.countryRegion === t.countryRegion && t.superAdminArea === d.superAdminArea)
})
} else {
this.showError = true
msg = msg + ',' + r.message
msg = msg + ',' + r.data.message
if (msg.indexOf(',') === 0) {
msg = msg.substring(1, msg.length)
}

View File

@@ -135,7 +135,7 @@ import {
pieForSeverity
} from '@/views/detections/options/detectionOptions'
import { api, getData } from '@/utils/api'
import { get } from '@/utils/http'
import axios from 'axios'
import { extensionEchartY, reverseSortBy } from '@/utils/tools'
import { useRoute } from 'vue-router'
import Loading from '@/components/common/Loading'
@@ -610,13 +610,13 @@ export default {
pageSize: this.pageObj.pageSize,
pageNo: this.pageObj.pageNo
}
get(api.detection[this.pageType].listBasic, params).then(response => {
if (response.code === 200) {
this.listData = response.data.result
axios.get(api.detection[this.pageType].listBasic, { params }).then(response => {
if (response.status === 200) {
this.listData = response.data.data.result
} else {
this.listData = []
console.error(response.message)
this.$message.error(response.message)
console.error(response.data.message)
this.$message.error(response.data.message)
}
})
getData(api.detection[this.pageType].listCount, params).then(data => {

View File

@@ -91,7 +91,7 @@
import { eventSeverityColor, unitTypes, riskLevelMapping } from '@/utils/constants'
import { api, getData } from '@/utils/api'
import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import axios from 'axios'
import * as echarts from 'echarts'
import { markRaw } from 'vue'
import { metricOption } from '@/views/detections/options/detectionOptions'
@@ -205,16 +205,18 @@ export default {
url = api.detection.performanceEvent.highDnsResponseTimeMetric
}
if (url) {
get(url, {
axios.get(url, {
params: {
appName: this.detection.appName,
startTime: this.searchStartTime,
endTime: this.searchEndTime,
eventType: this.detection.eventType
}
}).then((response) => {
if (response.code === 200) {
resolve(response.data.result[0])
if (response.status === 200) {
resolve(response.data.data.result[0])
} else {
reject(response)
reject(response.data)
}
})
} else {

View File

@@ -94,7 +94,7 @@
import { api, getData } from '@/utils/api'
import { eventSeverityColor, unitTypes, topDomain } from '@/utils/constants'
import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import axios from 'axios'
import * as echarts from 'echarts'
import { markRaw } from 'vue'
import { metricOption } from '@/views/detections/options/detectionOptions'
@@ -237,16 +237,18 @@ export default {
url = api.detection.performanceEvent.highDnsResponseTimeMetric
}
if (url) {
get(url, {
axios.get(url, {
params: {
domain: this.detection.domain,
startTime: this.searchStartTime,
endTime: this.searchEndTime,
eventType: this.detection.eventType
}
}).then((response) => {
if (response.code === 200) {
resolve(response.data.result[0])
if (response.status === 200) {
resolve(response.data.data.result[0])
} else {
reject(response)
reject(response.data)
}
})
} else {

View File

@@ -84,7 +84,7 @@
import { api, getData } from '@/utils/api'
import { unitTypes } from '@/utils/constants'
import { getSecond } from '@/utils/date-util'
import { get } from '@/utils/http'
import axios from 'axios'
import * as echarts from 'echarts'
import { markRaw } from 'vue'
import { metricOption } from '@/views/detections/options/detectionOptions'
@@ -198,16 +198,18 @@ export default {
url = api.detection.performanceEvent.highDnsResponseTimeMetric
}
if (url) {
get(url, {
axios.get(url, {
params: {
serverIp: this.detection.serverIp,
startTime: this.searchStartTime,
endTime: this.searchEndTime,
eventType: this.detection.eventType
}
}).then((response) => {
if (response.code === 200) {
resolve(response.data.result[0])
if (response.status === 200) {
resolve(response.data.data.result[0])
} else {
reject(response)
reject(response.data)
}
})
} else {

View File

@@ -268,7 +268,7 @@
</template>
<script>
import { get } from '@/utils/http'
import axios from 'axios'
import { api } from '@/utils/api'
import { getMillisecond } from '@/utils/date-util'
import { eventSeverityColor, unitTypes } from '@/utils/constants'
@@ -338,15 +338,17 @@ export default {
queryBasic () {
return new Promise((resolve, reject) => {
try {
get(api.detection.securityEvent.overviewBasic, {
axios.get(api.detection.securityEvent.overviewBasic, {
params: {
eventId: this.detection.eventId,
startTime: this.detection.startTime,
endTime: this.detection.endTime
}
}).then((response) => {
if (response.code === 200) {
resolve(response.data.result[0])
if (response.status === 200) {
resolve(response.data.data.result[0])
} else {
reject(response)
reject(response.data)
}
})
} catch (e) {
@@ -357,15 +359,17 @@ export default {
queryEvent () {
return new Promise((resolve, reject) => {
try {
get(api.detection.securityEvent.overviewEvent, {
axios.get(api.detection.securityEvent.overviewEvent, {
params: {
startTime: this.detection.startTime,
offenderIp: this.detection.offenderIp,
victimIp: this.detection.victimIp
}
}).then((response) => {
if (response.code === 200) {
resolve(response.data.result)
if (response.status === 200) {
resolve(response.data.data.result)
} else {
reject(response)
reject(response.data)
}
})
} catch (e) {

View File

@@ -41,7 +41,7 @@
</template>
<script>
import { get } from '@/utils/http'
import axios from 'axios'
import { api } from '@/utils/api'
export default {
@@ -88,31 +88,31 @@ export default {
if (params) {
searchParams = { ...searchParams, ...params }
}
get(this.url, searchParams).then(response => {
if (response.code === 200) {
if (response.data.statusList) {
axios.get(this.url, { params: searchParams }).then(response => {
if (response.status === 200) {
if (response.data.data.statusList) {
this.statusList = []
response.data.statusList.forEach(item => {
response.data.data.statusList.forEach(item => {
this.statusList.push({ status: item.status, label: this.switchStatus(item.status) })
this.checkStatus.push(item.status)
})
}
this.categoryList = response.data.categoryList
if (response.data.categoryList) {
response.data.categoryList.forEach(item => {
this.categoryList = response.data.data.categoryList
if (response.data.data.categoryList) {
response.data.data.categoryList.forEach(item => {
this.checkCategory.push(item.value)
})
}
this.typeList = response.data.typeList
if (response.data.typeList) {
response.data.typeList.forEach(item => {
this.typeList = response.data.data.typeList
if (response.data.data.typeList) {
response.data.data.typeList.forEach(item => {
this.checkType.push(item.value)
})
}
} else {
console.error(response)
console.error(response.data)
}
}).finally(() => {
// this.initTypeData()

View File

@@ -215,7 +215,7 @@ import { unitTypes } from '@/utils/constants'
import { valueToRangeValue } from '@/utils/unit-convert'
import Chart from '@/views/charts/Chart'
import _ from 'lodash'
import { get } from '@/utils/http'
import axios from 'axios'
import relatedServer from '@/mixins/relatedServer'
import { dateFormatByAppearance, getMillisecond } from '@/utils/date-util'
import Loading from '@/components/common/Loading'
@@ -336,9 +336,9 @@ export default {
},
chartGetMap () {
this.loadingMap = true
get((this.trafficUrlMap), this.getQueryParams()).then(response => {
if (response.code === 200) {
this.chartData = response.data.result
axios.get(this.trafficUrlMap, { params: this.getQueryParams() }).then(response => {
if (response.status === 200) {
this.chartData = response.data.data.result
}
this.loadingMap = false
})

View File

@@ -219,7 +219,7 @@ import { unitTypes } from '@/utils/constants'
import { valueToRangeValue } from '@/utils/unit-convert'
import Chart from '@/views/charts/Chart'
import _ from 'lodash'
import { get } from '@/utils/http'
import axios from 'axios'
import relatedServer from '@/mixins/relatedServer'
import { dateFormatByAppearance, getMillisecond } from '@/utils/date-util'
import Loading from '@/components/common/Loading'
@@ -341,26 +341,26 @@ export default {
},
chartGetMap () {
this.loadingMap = true
get(this.trafficUrlMap, this.getQueryParams()).then(response => {
if (response.code === 200) {
this.chartData = response.data.result
axios.get(this.trafficUrlMap, { params: this.getQueryParams() }).then(response => {
if (response.status === 200) {
this.chartData = response.data.data.result
}
this.loadingMap = false
})
},
getBasicProperties () {
get(this.basicProperties, this.getQueryParams()).then(response => {
if (response.code === 200) {
axios.get(this.basicProperties, { params: this.getQueryParams() }).then(response => {
if (response.status === 200) {
this.entityData = {
...this.entityData,
domainCategory: response.data.result.domainCategory,
domainCategoryGroup: response.data.result.domainCategoryGroup,
domainDescription: response.data.result.domainDescription,
domainReputationScore: response.data.result.domainReputationScore,
domainWhoisAddress: response.data.result.domainWhoisAddress,
domainWhoisOrg: response.data.result.domainWhoisOrg,
domainIcpCompanyName: response.data.result.domainIcpCompanyName,
domainIcpSiteLicense: response.data.result.domainIcpSiteLicense
domainCategory: response.data.data.result.domainCategory,
domainCategoryGroup: response.data.data.result.domainCategoryGroup,
domainDescription: response.data.data.result.domainDescription,
domainReputationScore: response.data.data.result.domainReputationScore,
domainWhoisAddress: response.data.data.result.domainWhoisAddress,
domainWhoisOrg: response.data.data.result.domainWhoisOrg,
domainIcpCompanyName: response.data.data.result.domainIcpCompanyName,
domainIcpSiteLicense: response.data.data.result.domainIcpSiteLicense
}
}
})

View File

@@ -252,7 +252,6 @@ import { unitTypes, countryNameIdMapping } from '@/utils/constants'
import { valueToRangeValue } from '@/utils/unit-convert'
import Chart from '@/views/charts/Chart'
import _ from 'lodash'
import { get } from '@/utils/http'
import relatedServer from '@/mixins/relatedServer'
import { dateFormatByAppearance, getMillisecond, getSecond } from '@/utils/date-util'
import Loading from '@/components/common/Loading'
@@ -422,9 +421,9 @@ export default {
},
chartGetMap () {
this.loadingMap = true
get((this.trafficUrlMap), this.getQueryParams()).then(response => {
if (response.code === 200) {
this.chartData = response.data.result
axios.get(this.trafficUrlMap, { params: this.getQueryParams() }).then(response => {
if (response.status === 200) {
this.chartData = response.data.data.result
}
this.loadingMap = false
})
@@ -441,7 +440,7 @@ export default {
}
axios.get(api.entity.entityList.ipRelatedPort, { params: params }).then(res => {
if (res.data.code === 200 && res.data.data.result.length) {
if (res.status === 200 && res.data.data.result.length) {
this.openPort = ''
res.data.data.result.forEach(item => {
this.openPort += item.port + '/' + item.l7Protocol + ','
@@ -485,11 +484,6 @@ export default {
</script>
<style lang="scss">
//.type-content {
// margin-bottom:15px;
// display:flex;
// flex-flow: row wrap;
// width:100%;
.data-item {
display: flex;
justify-content: center;

View File

@@ -82,7 +82,7 @@
</template>
<script>
import { get } from '@/utils/http'
import axios from 'axios'
import ReportTable from '@/components/table/report/ReportTable'
import cnDataList from '@/components/table/CnDataList'
import dataListMixin from '@/mixins/data-list'
@@ -220,9 +220,9 @@ export default {
methods: {
queryGetTempData () {
this.builtinLeftLoading = true
get(api.reportCategory, { pageSize: 999 }).then(res => {
if (res.code === 200) {
this.builtinReportLeftMenu = res.data.list.map(c => {
axios.get(api.reportCategory, { params: { pageSize: 999 } }).then(res => {
if (res.status === 200) {
this.builtinReportLeftMenu = res.data.data.list.map(c => {
return {
...c,
config: c.config ? JSON.parse(c.config) : {}
@@ -265,27 +265,20 @@ export default {
}
if (!this.isInit) {
get(listUrl, this.searchLabel).then(response => {
// this.tools.loading = false
// this.builtinRightLoading = false
// this.loading = false
if (response.code === 200) {
for (let i = 0; i < response.data.list.length; i++) {
response.data.list[i].status = response.data.list[i].status + ''
axios.get(listUrl, { params: this.searchLabel }).then(response => {
if (response.status === 200) {
for (let i = 0; i < response.data.data.list.length; i++) {
response.data.data.list[i].status = response.data.data.list[i].status + ''
}
this.$nextTick(() => {
this.tableData = response.data.list.map(item => {
this.tableData = response.data.data.list.map(item => {
return {
...item,
config: item.config ? JSON.parse(item.config) : {}
}
})
this.pageObj.total = response.data.total
if (!this.tableData || this.tableData.length === 0) {
this.isNoData = true
} else {
this.isNoData = false
}
this.pageObj.total = response.data.data.total
this.isNoData = !this.tableData || this.tableData.length === 0;
})
// TODO 回到顶部
} else {