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

@@ -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(() => {
})