CN-128 perf: 优化图表加载动画

This commit is contained in:
chenjinsong
2021-09-07 11:38:06 +08:00
parent 49d7fdb1d1
commit 3c47b8d613
9 changed files with 44 additions and 20 deletions

View File

@@ -19,3 +19,14 @@
font-weight:900; font-weight:900;
} }
} }
.chart__loading {
display: flex;
justify-content: center;
align-items: center;
background-color: #fefefe;
i {
font-size: 30px;
color: #aaa;
}
}

View File

@@ -9,9 +9,12 @@
<slot name="operations"></slot> <slot name="operations"></slot>
</div> </div>
</div> </div>
<div class="cn-chart__body" v-loading="loading"> <div class="cn-chart__body" v-show="!loading">
<slot></slot> <slot></slot>
</div> </div>
<div class="cn-chart__body chart__loading" v-show="loading">
<i class="el-icon-loading"></i>
</div>
<div class="cn-chart__footer"> <div class="cn-chart__footer">
<slot name="footer"></slot> <slot name="footer"></slot>
</div> </div>

View File

@@ -1,10 +1,13 @@
<template> <template>
<div class="cn-chart cn-chart__single-value chart-header-position" :class="singleValueClass(type)" > <div class="cn-chart cn-chart__single-value chart-header-position" :class="singleValueClass(type)">
<slot name="chartErrorInfo"></slot> <slot name="chartErrorInfo"></slot>
<div class="single-value-icon__box" > <div class="single-value-icon__box" >
<div class="single-value__icon"><i :class="icon"></i></div> <div class="single-value__icon"><i :class="icon"></i></div>
</div> </div>
<div class="single-value__content" v-if="type === 51"> <div class="single-value__content chart__loading" style="height: 100%; width: 100%;" v-if="loading">
<i class="el-icon-loading"></i>
</div>
<div class="single-value__content" v-if="type === 51" v-show="!loading">
<div class="content__data"> <div class="content__data">
<slot name="data"></slot> <slot name="data"></slot>
</div> </div>
@@ -12,7 +15,7 @@
<slot name="title"></slot> <slot name="title"></slot>
</div> </div>
</div> </div>
<div class="single-value__content" v-if="type === 52"> <div class="single-value__content" v-if="type === 52" v-show="!loading">
<div class="content__title"> <div class="content__title">
<slot name="title"></slot> <slot name="title"></slot>
</div> </div>
@@ -23,7 +26,7 @@
<slot name="chart"></slot> <slot name="chart"></slot>
</div> </div>
</div> </div>
<div class="single-value__content" v-if="type === 53"> <div class="single-value__content" v-if="type === 53" v-show="!loading">
<div class="content__title"></div> <div class="content__title"></div>
<div class="content__data"></div> <div class="content__data"></div>
</div> </div>
@@ -35,7 +38,8 @@ export default {
name: 'ChartSingleValue', name: 'ChartSingleValue',
props: { props: {
type: Number, type: Number,
icon: String icon: String,
loading: Boolean
}, },
computed: { computed: {
singleValueClass () { singleValueClass () {

View File

@@ -9,7 +9,10 @@
<slot name="operations"></slot> <slot name="operations"></slot>
</div> </div>
</div> </div>
<div class="cn-chart__body" v-loading="loading" v-no-data="noData"> <div class="cn-chart__body chart__loading" v-show="loading">
<i class="el-icon-loading"></i>
</div>
<div class="cn-chart__body" v-show="!loading" v-no-data="noData">
<el-table <el-table
style="width: 100%" style="width: 100%"
tooltip-effect="light" tooltip-effect="light"

View File

@@ -9,9 +9,12 @@
<slot name="operations"></slot> <slot name="operations"></slot>
</div> </div>
</div> </div>
<div class="cn-chart__body" :class="{'pie-with-table': isPieWithTable}" v-loading="loading" v-no-data="noData"> <div class="cn-chart__body" :class="{'pie-with-table': isPieWithTable}" v-no-data="noData" v-show="!loading">
<slot></slot> <slot></slot>
</div> </div>
<div class="cn-chart__body chart__loading" v-show="loading">
<i class="el-icon-loading"></i>
</div>
<div class="cn-chart__footer" v-if="layout.indexOf(layoutConstant.FOOTER) > -1 && !noData" :class="{'pie-with-table': isPieWithTable}" v-loading="loading"> <div class="cn-chart__footer" v-if="layout.indexOf(layoutConstant.FOOTER) > -1 && !noData" :class="{'pie-with-table': isPieWithTable}" v-loading="loading">
<slot name="footer"></slot> <slot name="footer"></slot>
</div> </div>

View File

@@ -38,7 +38,7 @@ export const panelTypeAndRouteMapping = {
trafficSummary: 1, trafficSummary: 1,
networkAppPerformance: 2, networkAppPerformance: 2,
dnsServiceInsights: 3, dnsServiceInsights: 3,
ipEntityDetail: 4,//此为clientIP ipEntityDetail: 4, // 此为clientIP
domainEntityDetail: 5, domainEntityDetail: 5,
appEntityDetail: 6, appEntityDetail: 6,
serverIpEntityDetail: 7 serverIpEntityDetail: 7

View File

@@ -99,7 +99,7 @@
:type="chartInfo.type" :type="chartInfo.type"
:style="computePosition" :style="computePosition"
:icon="singleValue.icon" :icon="singleValue.icon"
v-loading="loading" :loading="loading"
> >
<template #chartErrorInfo> <template #chartErrorInfo>
<chart-error <chart-error

View File

@@ -69,7 +69,7 @@ export default {
tabTitle () { tabTitle () {
let title let title
switch (this.typeName) { switch (this.typeName) {
case 'ipEntityDetail':{//client IP case 'ipEntityDetail': { // client IP
title = this.$t('entities.ipDetail') title = this.$t('entities.ipDetail')
break break
} }
@@ -119,14 +119,14 @@ export default {
this.$emit('goBack') this.$emit('goBack')
}, },
async changeTab (label) { async changeTab (label) {
let routePath; let routePath
if(label=='clientIP'){ if (label == 'clientIP') {
routePath = 'ipEntityDetail'; routePath = 'ipEntityDetail'
}else if(label=='serverIP'){ } else if (label == 'serverIP') {
routePath = 'serverIpEntityDetail'; routePath = 'serverIpEntityDetail'
} }
this.panelType = panelTypeAndRouteMapping[routePath]; this.panelType = panelTypeAndRouteMapping[routePath]
await this.init(); await this.init()
}, },
async init () { async init () {
const panels = await getPanelList({ type: this.panelType }) const panels = await getPanelList({ type: this.panelType })

View File

@@ -53,7 +53,7 @@ import galaxyProxyBox from '@/components/rightBox/settings/GalaxyProxyBox'
import galaxyProxyTable from '@/components/table/settings/GalaxyProxyTable' import galaxyProxyTable from '@/components/table/settings/GalaxyProxyTable'
import dataListMixin from '@/mixins/dataList' import dataListMixin from '@/mixins/dataList'
import { api } from '@/utils/api' import { api } from '@/utils/api'
import {get} from "@/utils/http"; import { get } from '@/utils/http'
export default { export default {
name: 'GalaxyProxy', name: 'GalaxyProxy',
@@ -92,4 +92,4 @@ export default {
<style> <style>
</style> </style>