fix: 部分页面补充loading效果

This commit is contained in:
@changcode
2022-10-13 16:56:06 +08:00
parent cdd3069070
commit 19a3dcfdf8
10 changed files with 26 additions and 16 deletions

View File

@@ -14,6 +14,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1; flex: 1;
position: relative;
padding: 20px 20px 0 20px; padding: 20px 20px 0 20px;
border-right: 1px solid #E2E5EC; border-right: 1px solid #E2E5EC;
.link-traffic-list-center:nth-of-type(1) { .link-traffic-list-center:nth-of-type(1) {

View File

@@ -238,7 +238,7 @@ export default {
computed: { computed: {
// 排除某些不需要loading的图表例如npm-tabs // 排除某些不需要loading的图表例如npm-tabs
disableLoading () { disableLoading () {
const disableChartTypes = [typeMapping.npm.npmTabs] const disableChartTypes = [typeMapping.npm.npmTabs, typeMapping.linkMonitor.linkTrafficLine]
return disableChartTypes.indexOf(this.chart.type) > -1 return disableChartTypes.indexOf(this.chart.type) > -1
} }
}, },

View File

@@ -120,7 +120,7 @@ export default {
startTime: getSecond(this.timeFilter.startTime), startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime) endTime: getSecond(this.timeFilter.endTime)
} }
this.toggleLoading(true)
get(api.dnsInsight.activeMaliciousDomain, params).then(res => { get(api.dnsInsight.activeMaliciousDomain, params).then(res => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data.result const data = res.data.result

View File

@@ -61,6 +61,7 @@ export default {
startTime: getSecond(this.timeFilter.startTime), startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime) endTime: getSecond(this.timeFilter.endTime)
} }
this.toggleLoading(true)
get(api.dnsInsight.eventChart, params).then(res => { get(api.dnsInsight.eventChart, params).then(res => {
const data = res.data.result const data = res.data.result
this.pieData = [] this.pieData = []

View File

@@ -83,8 +83,10 @@ export default {
} }
}, },
eventsByTypeData () { eventsByTypeData () {
this.toggleLoading(false)
if (this.series.length > 0) { if (this.series.length > 0) {
this.init() this.init()
this.toggleLoading(true)
} }
}, },
resize () { resize () {

View File

@@ -128,9 +128,11 @@ export default {
} }
}, },
eventsByTypeData () { eventsByTypeData () {
this.toggleLoading(false)
if (this.pieData.length > 0) { if (this.pieData.length > 0) {
this.chartData = this.pieData this.chartData = this.pieData
this.init() this.init()
this.toggleLoading(true)
} }
}, },
resize () { resize () {

View File

@@ -205,6 +205,7 @@ export default {
type: this.tableType, type: this.tableType,
severity: this.tableSeverity severity: this.tableSeverity
} }
this.toggleLoading(true)
get(api.dnsInsight.recentEvents, params).then(res => { get(api.dnsInsight.recentEvents, params).then(res => {
if (res.code === 200) { if (res.code === 200) {
if (!res.data.result || res.data.result.length === 0) { if (!res.data.result || res.data.result.length === 0) {

View File

@@ -27,12 +27,6 @@ export default {
data () { data () {
return { return {
} }
},
methods: {
},
mounted () {
this.toggleLoading(false)
} }
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<template> <template>
<div class="line network link-traffic"> <div class="line network link-traffic">
<loading :loading="loading"></loading>
<div class="line-header"> <div class="line-header">
<div class="line-header-left"> <div class="line-header-left">
<div class="line-value-active" v-if="lineTab"></div> <div class="line-value-active" v-if="lineTab"></div>
@@ -64,10 +65,12 @@ import ChartNoData from '@/views/charts/charts/ChartNoData'
import chartMixin from '@/views/charts2/chart-mixin' import chartMixin from '@/views/charts2/chart-mixin'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { overwriteUrl, urlParamsHandler } from '@/utils/tools' import { overwriteUrl, urlParamsHandler } from '@/utils/tools'
import Loading from '@/components/common/Loading'
export default { export default {
name: 'linkTrafficDrillDownLine', name: 'linkTrafficDrillDownLine',
components: { components: {
ChartNoData ChartNoData,
Loading
}, },
setup () { setup () {
const { query } = useRoute() const { query } = useRoute()
@@ -111,7 +114,8 @@ export default {
leftOffset: 0, leftOffset: 0,
sizes: [3, 4, 6, 8, 9, 10], sizes: [3, 4, 6, 8, 9, 10],
dynamicVariable: '', dynamicVariable: '',
showMarkLine: true showMarkLine: true,
loading: false
} }
}, },
watch: { watch: {
@@ -154,7 +158,7 @@ export default {
if (this.queryCondition) { if (this.queryCondition) {
params.q = this.queryCondition params.q = this.queryCondition
} }
this.toggleLoading(true) this.loading = true
get(api.linkMonitor.totalTrafficAnalysis, params).then((res) => { get(api.linkMonitor.totalTrafficAnalysis, params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.isNoData = res.data.result.length === 0 this.isNoData = res.data.result.length === 0
@@ -224,7 +228,7 @@ export default {
console.error(e) console.error(e)
this.isNoData = true this.isNoData = true
}).finally(() => { }).finally(() => {
this.toggleLoading(false) this.loading = false
}) })
}, },
echartsInit (echartsData) { echartsInit (echartsData) {

View File

@@ -1,5 +1,6 @@
<template> <template>
<div class="link-traffic-list"> <div class="link-traffic-list">
<loading :loading="loading"></loading>
<div class="link-traffic-list-center"> <div class="link-traffic-list-center">
<div class="link-traffic-list-center-label">{{$t('network.total')}}</div> <div class="link-traffic-list-center-label">{{$t('network.total')}}</div>
<div class="link-traffic-list-center-value">{{unitConvert(linkTrafficListData.totalBitsRate, unitTypes.bps).join('')}}</div> <div class="link-traffic-list-center-value">{{unitConvert(linkTrafficListData.totalBitsRate, unitTypes.bps).join('')}}</div>
@@ -46,7 +47,7 @@ import { ref } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { getSecond } from '@/utils/date-util' import { getSecond } from '@/utils/date-util'
import { computeScore } from '@/utils/tools' import { computeScore } from '@/utils/tools'
import Loading from '@/components/common/Loading'
export default { export default {
name: 'linkTrafficList', name: 'linkTrafficList',
mixins: [chartMixin], mixins: [chartMixin],
@@ -57,6 +58,9 @@ export default {
queryCondition queryCondition
} }
}, },
components: {
Loading
},
data () { data () {
return { return {
unitTypes, unitTypes,
@@ -64,7 +68,8 @@ export default {
timer: null, timer: null,
linkTrafficListData: {}, linkTrafficListData: {},
cnLinkInfo: JSON.parse(localStorage.getItem(storageKey.linkInfo)), cnLinkInfo: JSON.parse(localStorage.getItem(storageKey.linkInfo)),
bandWidth: 0 bandWidth: 0,
loading: false
} }
}, },
methods: { methods: {
@@ -76,7 +81,7 @@ export default {
if (this.queryCondition) { if (this.queryCondition) {
params.q = this.queryCondition params.q = this.queryCondition
} }
this.toggleLoading(true) this.loading = true
get(api.linkMonitor.networkAnalysis, params).then(res => { get(api.linkMonitor.networkAnalysis, params).then(res => {
if (res.code === 200) { if (res.code === 200) {
this.isNoData = res.data.result.length === 0 this.isNoData = res.data.result.length === 0
@@ -111,7 +116,7 @@ export default {
console.error(e) console.error(e)
this.isNoData = true this.isNoData = true
}).finally(() => { }).finally(() => {
this.toggleLoading(false) this.loading = false
}) })
} }
}, },