fix: 将状态码判断字段从code换为http status

This commit is contained in:
chenjinsong
2023-08-27 20:34:24 +08:00
parent dc6b8e067c
commit 4a20d39fa2
13 changed files with 50 additions and 49 deletions

View File

@@ -263,17 +263,18 @@ export default {
}, },
uploadSuccess (response) { uploadSuccess (response) {
this.uploadLoading = false this.uploadLoading = false
this.uploaded = response.code === 200 this.uploaded = true
if (response.code === 200) { /* this.uploaded = response.code === 200
this.$message.success(this.$t('tip.success')) if (response.code === 200) { */
this.showAddUpdateDialog = false this.$message.success(this.$t('tip.success'))
axios.get(api.knowledgeBaseLog + '/' + this.updateKnowledge.knowledgeId, { params: { pageSize: 999 } }).then(res => { this.showAddUpdateDialog = false
this.updateHistoryList = res.data.data.list axios.get(api.knowledgeBaseLog + '/' + this.updateKnowledge.knowledgeId, { params: { pageSize: 999 } }).then(res => {
this.currentVersion = this.updateHistoryList[0].commitVersion + 1 this.updateHistoryList = res.data.data.list
}) this.currentVersion = this.updateHistoryList[0].commitVersion + 1
} else { })
/* } else {
this.$message.error(this.$t('tip.uploadFailed', { msg: response.message })) this.$message.error(this.$t('tip.uploadFailed', { msg: response.message }))
} } */
}, },
beforeUpload (file) { beforeUpload (file) {
this.uploadLoading = true this.uploadLoading = true

View File

@@ -108,7 +108,7 @@ export default {
let basicInfoError = '' let basicInfoError = ''
if (tagData) { if (tagData) {
const res = tagData.data const res = tagData.data
if (res.code === 200) { if (tagData.status === 200) {
Object.keys(res.data).forEach(k => { Object.keys(res.data).forEach(k => {
if (k !== 'userDefinedTags' && res.data[k]) { if (k !== 'userDefinedTags' && res.data[k]) {
Object.keys(res.data[k]).forEach(k2 => { Object.keys(res.data[k]).forEach(k2 => {
@@ -132,7 +132,7 @@ export default {
} }
if (basicInfoData) { if (basicInfoData) {
const res = basicInfoData.data const res = basicInfoData.data
if (res.code === 200) { if (basicInfoData.status === 200) {
switch (this.entity.entityType) { switch (this.entity.entityType) {
case 'ip': { case 'ip': {
if (res.data.asn) { if (res.data.asn) {

View File

@@ -223,7 +223,7 @@ export default {
axios.get(`${api.entity.throughput}/${this.entity.entityType}`, { params: params }).then(response => { axios.get(`${api.entity.throughput}/${this.entity.entityType}`, { params: params }).then(response => {
const res = response.data const res = response.data
if (res.code === 200) { if (response.status === 200) {
this.isNoData = res.data.result.length === 0 this.isNoData = res.data.result.length === 0
this.showError = false this.showError = false
if (this.isNoData) { if (this.isNoData) {

View File

@@ -120,7 +120,7 @@ export default {
const performance = axios.get(`${api.entity.performance}/${this.entityType}`, { params: params }) const performance = axios.get(`${api.entity.performance}/${this.entityType}`, { params: params })
Promise.all([informationAggregation, openPort, security, performance]).then(response => { Promise.all([informationAggregation, openPort, security, performance]).then(response => {
if (response[0].data.code === 200) { if (response[0].status === 200) {
const list = [] const list = []
response[0].data.data.result.forEach(r => { response[0].data.data.result.forEach(r => {
Object.keys(r).forEach(k => { Object.keys(r).forEach(k => {
@@ -148,13 +148,13 @@ export default {
this.initSetTag(entityDetailTabsName.informationAggregation, list.length) this.initSetTag(entityDetailTabsName.informationAggregation, list.length)
} }
if (response[1].data.code === 200) { if (response[1].status === 200) {
this.initSetTag(entityDetailTabsName.openPort, response[1].data.data.result.length) this.initSetTag(entityDetailTabsName.openPort, response[1].data.data.result.length)
} }
if (response[2].data.code === 200) { if (response[2].status === 200) {
this.initSetTag(entityDetailTabsName.securityEvent, response[2].data.data.result.length) this.initSetTag(entityDetailTabsName.securityEvent, response[2].data.data.result.length)
} }
if (response[3].data.code === 200) { if (response[3].status === 200) {
this.initSetTag(entityDetailTabsName.performanceEvent, response[3].data.data.result.length) this.initSetTag(entityDetailTabsName.performanceEvent, response[3].data.data.result.length)
} }
}) })
@@ -186,22 +186,22 @@ export default {
switch (this.entity.entityType) { switch (this.entity.entityType) {
case 'ip': { case 'ip': {
const len1 = res0.code === 200 ? res0.data.result.length : 0 const len1 = res[0].status === 200 ? res0.data.result.length : 0
const len2 = res1.code === 200 ? res1.data.result.length : 0 const len2 = res[1].status === 200 ? res1.data.result.length : 0
this.initSetTag(entityDetailTabsName.relatedEntity, len1 + len2) this.initSetTag(entityDetailTabsName.relatedEntity, len1 + len2)
break break
} }
case 'domain': { case 'domain': {
const res2 = res[2].data const res2 = res[2].data
const len1 = res0.code === 200 ? res0.data.result.length : 0 const len1 = res[0].status === 200 ? res0.data.result.length : 0
const len2 = res1.code === 200 ? res1.data.result.length : 0 const len2 = res[1].status === 200 ? res1.data.result.length : 0
const len3 = res2.code === 200 ? res2.data.result.length : 0 const len3 = res[2].status === 200 ? res2.data.result.length : 0
this.initSetTag(entityDetailTabsName.relatedEntity, len1 + len2 + len3) this.initSetTag(entityDetailTabsName.relatedEntity, len1 + len2 + len3)
break break
} }
case 'app': { case 'app': {
const len1 = res0.code === 200 ? res0.data.result.length : 0 const len1 = res[0].status === 200 ? res0.data.result.length : 0
const len2 = res1.code === 200 ? res1.data.result.length : 0 const len2 = res[1].status === 200 ? res1.data.result.length : 0
this.initSetTag(entityDetailTabsName.relatedEntity, len1 + len2) this.initSetTag(entityDetailTabsName.relatedEntity, len1 + len2)
break break
} }

View File

@@ -192,7 +192,7 @@ export default {
const res = [] const res = []
res[0] = response[0].data res[0] = response[0].data
res[1] = response[1].data res[1] = response[1].data
if (res[0].code === 200) { if (response[0].status === 200) {
this.showError1 = false this.showError1 = false
const linkData = res[0].data.result const linkData = res[0].data.result
@@ -252,7 +252,7 @@ export default {
this.errorMsg1 = this.errorMsgHandler(res[0]) this.errorMsg1 = this.errorMsgHandler(res[0])
} }
if (res[1].code === 200) { if (response[1].status === 200) {
this.showError2 = false this.showError2 = false
const nextHopData = res[1].data.result const nextHopData = res[1].data.result

View File

@@ -163,9 +163,9 @@ export default {
} }
} }
this.loading = true this.loading = true
axios.get(api.linkMonitor.totalTrafficAnalysis, { params: params }).then((res) => { axios.get(api.linkMonitor.totalTrafficAnalysis, { params: params }).then(response => {
res = res.data const res = response.data
if (res.code === 200) { if (response.status === 200) {
this.showError = false this.showError = false
this.isNoData = res.data.result.length === 0 this.isNoData = res.data.result.length === 0
if (this.isNoData) { if (this.isNoData) {

View File

@@ -112,9 +112,9 @@ export default {
url = n === 0 ? api.linkMonitor.quadrupleIngressAnalysis : api.linkMonitor.quadrupleEgressAnalysis url = n === 0 ? api.linkMonitor.quadrupleIngressAnalysis : api.linkMonitor.quadrupleEgressAnalysis
} }
this.toggleLoading(true) this.toggleLoading(true)
axios.get(url, { params: params }).then(res => { axios.get(url, { params }).then(response => {
res = res.data const res = response.data
if (res.code === 200) { if (response.status === 200) {
this.showError = false this.showError = false
if (n === 0) { if (n === 0) {
this.ingress = res.data.result.length === 0 this.ingress = res.data.result.length === 0

View File

@@ -142,9 +142,9 @@ export default {
} }
} }
this.loading = true this.loading = true
axios.get(api.linkMonitor.networkAnalysis, { params: params }).then(res => { axios.get(api.linkMonitor.networkAnalysis, { params: params }).then(response => {
res = res.data const res = response.data
if (res.code === 200) { if (response.status === 200) {
this.showError = false this.showError = false
this.isNoData = res.data.result.length === 0 this.isNoData = res.data.result.length === 0
const data = { const data = {

View File

@@ -263,7 +263,7 @@ export default {
} }
}) })
} }
if (res[0].data.code === 200 && res[1].data.code === 200) { if (res[0].status === 200 && res[1].status === 200) {
this.showError = false this.showError = false
const prevData = res[0].data.data.result const prevData = res[0].data.data.result
const data = res[1].data.data.result const data = res[1].data.data.result
@@ -468,9 +468,9 @@ export default {
} }
if (parseFloat(this.appTypeTab) === 0) { if (parseFloat(this.appTypeTab) === 0) {
params.type = 'overviewProvide' params.type = 'overviewProvide'
axios.get(api.dict, { params: params }).then(res => { axios.get(api.dict, { params: params }).then(response => {
res = res.data const res = response.data
if (res.code === 200 && res.data.list) { if (response.status === 200 && res.data.list) {
res.data.list = res.data.list.filter(l => !this.appData.some(pd => pd.type === 'provider' && pd.name === l.value)) res.data.list = res.data.list.filter(l => !this.appData.some(pd => pd.type === 'provider' && pd.name === l.value))
this.pageObj.pages = res.data.pages this.pageObj.pages = res.data.pages
res.data.list.forEach(t => { res.data.list.forEach(t => {
@@ -494,9 +494,9 @@ export default {
}) })
} else if (parseFloat(this.appTypeTab) === 1) { } else if (parseFloat(this.appTypeTab) === 1) {
params.type = 'overviewApp' params.type = 'overviewApp'
axios.get(api.dict, { params: params }).then(res => { axios.get(api.dict, { params: params }).then(response => {
res = res.data const res = response.data
if (res.code === 200) { if (response.status === 200) {
res.data.list = res.data.list.filter(l => !this.appData.some(pd => pd.type === 'app' && pd.name === l.value)) res.data.list = res.data.list.filter(l => !this.appData.some(pd => pd.type === 'app' && pd.name === l.value))
this.pageObj.pages = res.data.pages this.pageObj.pages = res.data.pages
res.data.list.forEach(t => { res.data.list.forEach(t => {

View File

@@ -174,7 +174,7 @@ export default {
axios.get(api.netWorkOverview.totalTrafficAnalysis, { params: params }).then(response => { axios.get(api.netWorkOverview.totalTrafficAnalysis, { params: params }).then(response => {
const res = response.data const res = response.data
if (res.code === 200) { if (response.status === 200) {
this.isNoData = res.data.result.length === 0 this.isNoData = res.data.result.length === 0
this.showError = false this.showError = false
if (this.isNoData) { if (this.isNoData) {

View File

@@ -444,7 +444,7 @@ export default {
} }
const requestUrl = this.getCurUrl() const requestUrl = this.getCurUrl()
axios.get(requestUrl, { params: queryParams }).then(response => { axios.get(requestUrl, { params: queryParams }).then(response => {
if (response.data.code === 200) { if (response.status === 200) {
this.showError = false this.showError = false
this.errorMsg = '' this.errorMsg = ''
this.chartData = response.data.data.result this.chartData = response.data.data.result
@@ -926,7 +926,7 @@ export default {
this.customTableTitles.forEach(tableColumn => { this.customTableTitles.forEach(tableColumn => {
if (tableColumn.columnType === tableColumnType.chainRatio && tableColumn.isInMainUrl && tableDataTmp && tableDataTmp.length > 0) { if (tableColumn.columnType === tableColumnType.chainRatio && tableColumn.isInMainUrl && tableDataTmp && tableDataTmp.length > 0) {
axios.get(self.gerCycleUrl(), { params: queryParams }).then(response => { axios.get(self.gerCycleUrl(), { params: queryParams }).then(response => {
if (response.data.code === 200) { if (response.status === 200) {
tableColumn.showError = false tableColumn.showError = false
tableColumn.errorMsg = '' tableColumn.errorMsg = ''
cycleTotalList = response.data.data.result cycleTotalList = response.data.data.result
@@ -992,7 +992,7 @@ export default {
this.customTableTitles.forEach(tableColumn => { this.customTableTitles.forEach(tableColumn => {
if (tableColumn.columnType === tableColumnType.chainRatio && !tableColumn.isInMainUrl) { if (tableColumn.columnType === tableColumnType.chainRatio && !tableColumn.isInMainUrl) {
axios.get(self.gerColumnUrl(tableColumn), { params: queryParams }).then(response => { axios.get(self.gerColumnUrl(tableColumn), { params: queryParams }).then(response => {
if (response.data.code === 200) { if (response.status === 200) {
if (!tableColumn.showError) { if (!tableColumn.showError) {
tableColumn.showError = false tableColumn.showError = false
tableColumn.errorMsg = '' tableColumn.errorMsg = ''
@@ -1032,7 +1032,7 @@ export default {
cycle: tableColumn.cycle cycle: tableColumn.cycle
} }
axios.get(self.gerColumnUrl(tableColumn), { params: queryCycleParams }).then(response => { axios.get(self.gerColumnUrl(tableColumn), { params: queryCycleParams }).then(response => {
if (response.data.code === 200) { if (response.status === 200) {
if (!tableColumn.showError) { if (!tableColumn.showError) {
tableColumn.showError = false tableColumn.showError = false
tableColumn.errorMsg = '' tableColumn.errorMsg = ''

View File

@@ -155,7 +155,7 @@ export default {
] ]
axios.get(`${api.detection.detail}/${this.drawerInfo.ruleId}`).then(res => { axios.get(`${api.detection.detail}/${this.drawerInfo.ruleId}`).then(res => {
if (res.data.code === 200) { if (res.status === 200) {
this.detailData = res.data.data this.detailData = res.data.data
} }
}).catch(err => { }).catch(err => {

View File

@@ -276,7 +276,7 @@ export default {
} }
axios.get(`${url}?resource=${this.entity.entityValue}`).then(responese => { axios.get(`${url}?resource=${this.entity.entityValue}`).then(responese => {
const res = responese.data const res = responese.data
if (res.code === 200) { if (responese.status === 200) {
Object.keys(res.data).forEach(k => { Object.keys(res.data).forEach(k => {
if (k !== 'userDefinedTags' && res.data[k]) { if (k !== 'userDefinedTags' && res.data[k]) {
Object.keys(res.data[k]).forEach(k2 => { Object.keys(res.data[k]).forEach(k2 => {