diff --git a/src/components/rightBox/settings/ChartBox.vue b/src/components/rightBox/settings/ChartBox.vue index 046bf811..b8f54506 100644 --- a/src/components/rightBox/settings/ChartBox.vue +++ b/src/components/rightBox/settings/ChartBox.vue @@ -397,9 +397,9 @@ export default { }) }, async getChartData (value) { - await get(api.chart, { panelId: value }).then(response => { - if (response.code === 200) { - this.chartData = response.data.list + await axios.get(api.chart, { params: { panelId: value } }).then(response => { + if (response.status === 200) { + this.chartData = response.data.data.list } }) } diff --git a/src/utils/http.js b/src/utils/http.js index dcfb5262..d132a5f1 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -69,6 +69,13 @@ axios.interceptors.response.use( return response }, error => { + if (licenceErrorCode.indexOf(error.response.data.code) !== -1) { + localStorage.removeItem(storageKey.token) + window.location.href = '/' + } else if (accountErrorCode.indexOf(error.response.data.code) !== -1) { + localStorage.removeItem(storageKey.token) + window.location.href = '/' + } return Promise.reject(error) } ) diff --git a/src/views/charts2/charts/entityDetail/tabs/DomainNameResolution.vue b/src/views/charts2/charts/entityDetail/tabs/DomainNameResolution.vue index 6d6bccbf..634e58d9 100644 --- a/src/views/charts2/charts/entityDetail/tabs/DomainNameResolution.vue +++ b/src/views/charts2/charts/entityDetail/tabs/DomainNameResolution.vue @@ -142,13 +142,13 @@ export default { Promise.all([data1, data2, data3]).then(res => { const res0 = res[0].data const res1 = res[1].data - if (res0.code === 200 && res1.code === 200) { + if (res[0].status === 200 && res[1].status === 200) { this.isNoData = res0.data.result.length === 0 && res1.data.result.length === 0 } // app相关,显示ip、domain if (this.entity.entityType === 'app' && !this.isNoData) { - if (res0.code === 200) { + if (res[0].status === 200) { this.relatedIpList = res0.data.result this.handleShowDataNum(this.showRelatedIpListInfo, this.relatedIpList) } else { @@ -156,7 +156,7 @@ export default { this.errorMsg1 = this.errorMsgHandler(res0) } - if (res1.code === 200) { + if (res[1].status === 200) { this.relatedDomainList = res1.data.result this.handleShowDataNum(this.showRelatedDomainListInfo, this.relatedDomainList) } else { @@ -170,14 +170,14 @@ export default { // ip相关,显示app,domain if (this.entity.entityType === 'ip' && !this.isNoData) { - if (res0.code === 200) { + if (res[0].status === 200) { this.relatedAppList = res0.data.result this.handleShowDataNum(this.showRelatedAppListInfo, this.relatedAppList) } else { this.showError0 = true this.errorMsg0 = this.errorMsgHandler(res0) } - if (res1.code === 200) { + if (res[1].status === 200) { this.relatedDomainList = res1.data.result this.handleShowDataNum(this.showRelatedDomainListInfo, this.relatedDomainList) } else { @@ -192,11 +192,11 @@ export default { // domain相关,显示app,ip,domain if (this.entity.entityType === 'domain') { const res2 = res[2].data - if (res0.code === 200 && res1.code === 200 && res2.code === 200) { + if (res[0].status === 200 && res[1].status === 200 && res[2].status === 200) { this.isNoData = res0.data.result.length === 0 && res1.data.result.length === 0 && res2.data.result.length === 0 } - if (res0.code === 200) { + if (res[0].status === 200) { this.relatedAppList = res0.data.result this.handleShowDataNum(this.showRelatedAppListInfo, this.relatedAppList) } else { @@ -204,7 +204,7 @@ export default { this.errorMsg0 = this.errorMsgHandler(res0) } - if (res1.code === 200) { + if (res[1].status === 200) { this.relatedIpList = res1.data.result this.handleShowDataNum(this.showRelatedIpListInfo, this.relatedIpList) } else { @@ -212,7 +212,7 @@ export default { this.errorMsg1 = this.errorMsgHandler(res1) } - if (res2.code === 200) { + if (res[2].status === 200) { this.relatedDomainList = res2.data.result this.handleShowDataNum(this.showRelatedDomainListInfo, this.relatedDomainList) } else { @@ -222,7 +222,7 @@ export default { this.$emit('checkTag', entityDetailTabsName.relatedEntity, res0.data.result.length + res1.data.result.length + res2.data.result.length) } }).catch(e => { - console.log(e) + console.error(e) this.$emit('checkTag', entityDetailTabsName.relatedEntity, 0) this.showError0 = true this.showError1 = true diff --git a/src/views/charts2/charts/entityDetail/tabs/OpenPort.vue b/src/views/charts2/charts/entityDetail/tabs/OpenPort.vue index e910e42f..e11bd3ab 100644 --- a/src/views/charts2/charts/entityDetail/tabs/OpenPort.vue +++ b/src/views/charts2/charts/entityDetail/tabs/OpenPort.vue @@ -64,7 +64,7 @@ export default { const url = this.getUrlByEntityType(this.entity.entityType) axios.get(url, { params: params }).then(response => { const res = response.data - if (res.code === 200) { + if (response.status === 200) { this.isNoData = res.data.result.length === 0 this.$emit('checkTag', entityDetailTabsName.openPort, res.data.result.length) this.showError = false diff --git a/src/views/charts2/charts/entityDetail/tabs/PerformanceEvent.vue b/src/views/charts2/charts/entityDetail/tabs/PerformanceEvent.vue index a5d9b45f..4f743927 100644 --- a/src/views/charts2/charts/entityDetail/tabs/PerformanceEvent.vue +++ b/src/views/charts2/charts/entityDetail/tabs/PerformanceEvent.vue @@ -101,7 +101,7 @@ export default { axios.get(`${api.entity.performance}/${this.entityType}`, { params: params }).then(response => { const res = response.data - if (res.code === 200) { + if (response.status === 200) { this.isNoData = res.data.result.length === 0 this.$emit('checkTag', entityDetailTabsName.performanceEvent, res.data.result.length) this.showError = false diff --git a/src/views/charts2/charts/entityDetail/tabs/SecurityEvent.vue b/src/views/charts2/charts/entityDetail/tabs/SecurityEvent.vue index c7ab6b90..e8068e05 100644 --- a/src/views/charts2/charts/entityDetail/tabs/SecurityEvent.vue +++ b/src/views/charts2/charts/entityDetail/tabs/SecurityEvent.vue @@ -126,7 +126,7 @@ export default { axios.get(`${api.entity.security}/${this.entityType}`, { params: params }).then(response => { const res = response.data - if (res.code === 200) { + if (response.status === 200) { this.isNoData = res.data.result.length === 0 this.$emit('checkTag', entityDetailTabsName.securityEvent, res.data.result.length) this.showError = false diff --git a/src/views/charts2/charts/linkMonitor/LinkDirectionGrid.vue b/src/views/charts2/charts/linkMonitor/LinkDirectionGrid.vue index 84b58711..140ad1bd 100644 --- a/src/views/charts2/charts/linkMonitor/LinkDirectionGrid.vue +++ b/src/views/charts2/charts/linkMonitor/LinkDirectionGrid.vue @@ -69,11 +69,11 @@ export default { this.toggleLoading(true) Promise.all([dataRequest, nextHopRequest]).then(response => { - if (response[0] && response[1]) { + if (response[0].status === 200 && response[1].status === 200) { const res = [] res[0] = response[0].data res[1] = response[1].data - if (res[0].code === 200) { + if (response[0].status === 200) { this.isLinkShowError = false // 链路流量数据 const linkData = res[0].data.result @@ -147,7 +147,7 @@ export default { this.linkErrorMsg = this.errorMsgHandler(res[0]) } - if (res[1].code === 200) { + if (response[1].status === 200) { this.isNextShowError = false // 链路下一跳信息 diff --git a/src/views/charts2/charts/networkOverview/NetworkOverviewDdosDetection.vue b/src/views/charts2/charts/networkOverview/NetworkOverviewDdosDetection.vue index d2b8c1cf..65e51687 100644 --- a/src/views/charts2/charts/networkOverview/NetworkOverviewDdosDetection.vue +++ b/src/views/charts2/charts/networkOverview/NetworkOverviewDdosDetection.vue @@ -67,9 +67,9 @@ export default { endTime: this.timeFilter && this.timeFilter.endTime ? getSecond(this.timeFilter.endTime) : '' } this.toggleLoading(true) - axios.get(api.netWorkOverview.ddosEventAnalysis, { params: params }).then(res => { - res = res.data - if (res.code === 200) { + axios.get(api.netWorkOverview.ddosEventAnalysis, { params: params }).then(response => { + const res = response.data + if (response.status === 200) { this.showError = false this.isNoData = res.data.result.length === 0 this.ddosData = res.data.result[0] diff --git a/src/views/charts2/charts/npm/NpmAppCategoryScore.vue b/src/views/charts2/charts/npm/NpmAppCategoryScore.vue index d9e892c6..0114e481 100644 --- a/src/views/charts2/charts/npm/NpmAppCategoryScore.vue +++ b/src/views/charts2/charts/npm/NpmAppCategoryScore.vue @@ -198,7 +198,7 @@ export default { const lastCycleTrafficRequest = axios.get(api.npm.overview.appTrafficAnalysis, { params: { ...params, cycle: 1 } }) this.toggleLoading(true) Promise.all([currentTrafficRequest, lastCycleTrafficRequest]).then(res => { - if (res[0].data.code === 200 && res[1].data.code === 200) { + if (res[0].status === 200 && res[1].status === 200) { this.showError = false this.errorMsg = '' const prevData = res[1].data.data.result @@ -234,7 +234,7 @@ export default { let msg = '' res.forEach((r, i) => { - if (r.data.code === 200) { + if (r.status === 200) { tableData.forEach(t => { t[keyPre[i] + 'Score'] = r.data.data.result.find(d => d.appSubcategory === t.appSubcategory) }) @@ -273,7 +273,7 @@ export default { this.toggleLoading(false) this.showError = true this.errorMsg = '' - let msg = res[0].message + ', ' + res[1].message + let msg = res[0].data.message + ', ' + res[1].data.message if (msg.indexOf(',') === 0) { msg = msg.substring(1, msg.length) } diff --git a/src/views/charts2/charts/npm/NpmMap.vue b/src/views/charts2/charts/npm/NpmMap.vue index 566ec036..39a84459 100644 --- a/src/views/charts2/charts/npm/NpmMap.vue +++ b/src/views/charts2/charts/npm/NpmMap.vue @@ -123,7 +123,7 @@ export default { countryRegion: this.location } axios.get(api.npm.location.map, { params: params }).then(response => { - if (response.data.code === 200) { + if (response.status === 200) { const res = _.get(response, 'data.data.result', []).filter(r => r.countryRegion !== 'Unknown') if (res.length > 0) { // 计算分数 diff --git a/src/views/charts2/charts/npm/NpmRecentEvents.vue b/src/views/charts2/charts/npm/NpmRecentEvents.vue index 5fb2d789..0f0f4974 100644 --- a/src/views/charts2/charts/npm/NpmRecentEvents.vue +++ b/src/views/charts2/charts/npm/NpmRecentEvents.vue @@ -109,9 +109,9 @@ export default { } this.toggleLoading(true) - axios.get(url, { params: params }).then(res => { - res = res.data - if (res.code === 200) { + axios.get(url, { params: params }).then(response => { + const res = response.data + if (response.status === 200) { this.showError = false this.isNoData = res.data.result.length === 0 res.data.result.forEach(e => { diff --git a/src/views/detectionsNew/DetectionForm.vue b/src/views/detectionsNew/DetectionForm.vue index 8ec75071..86c0af61 100644 --- a/src/views/detectionsNew/DetectionForm.vue +++ b/src/views/detectionsNew/DetectionForm.vue @@ -206,7 +206,7 @@ export default { }) // axios.post('api', formObj).then(response => { - // if (response.data.code === 200) { + // if (response.status === 200) { // this.$message({ // duration: 2000, // type: 'success', diff --git a/src/views/detectionsNew/Index.vue b/src/views/detectionsNew/Index.vue index 378c9ab7..7d780234 100644 --- a/src/views/detectionsNew/Index.vue +++ b/src/views/detectionsNew/Index.vue @@ -208,7 +208,7 @@ export default { // todo 调用接口删除 // this.toggleLoading(true) // axios.delete(api.detection.delete + '?ruleIds=' + ids).then(response => { - // if (response.data.code === 200) { + // if (response.status === 200) { // this.delFlag = true // this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') }) // this.secondBatchDeleteObjs.forEach((item) => {