fix: 废弃http.js的封装请求方法
This commit is contained in:
@@ -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'))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
|
||||
@@ -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(() => {
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(() => {
|
||||
})
|
||||
|
||||
@@ -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(() => {})
|
||||
|
||||
Reference in New Issue
Block a user