CN-53 perf: 单值图相关

This commit is contained in:
chenjinsong
2021-07-13 18:38:32 +08:00
parent f3c232965c
commit 7bbc943a96
5 changed files with 42 additions and 17 deletions

View File

@@ -106,6 +106,12 @@
font-size: 16px; font-size: 16px;
color: #666666; color: #666666;
} }
.single-value__unit {
font-weight: normal;
padding-left: 10px;
color: #666;
font-size: 20px;
}
} }
} }
&>.cn-chart__single-value.cn-chart__single-value--icon-right { &>.cn-chart__single-value.cn-chart__single-value--icon-right {

View File

@@ -26,45 +26,45 @@
<template v-if="entityType === 'ip'"> <template v-if="entityType === 'ip'">
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('common.country')}}:</span> <span class="body__row-label">{{$t('common.country')}}:</span>
<span class="body__row-value">{{d.country || '-'}}</span> <div class="body__row-value" :title="d.country">{{d.country || '-'}}</div>
</div> </div>
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('common.region')}}:</span> <span class="body__row-label">{{$t('common.region')}}:</span>
<span class="body__row-value">{{d.region || '-'}}</span> <div class="body__row-value" :title="d.region">{{d.region || '-'}}</div>
</div> </div>
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('entities.asn')}}:</span> <span class="body__row-label">{{$t('entities.asn')}}:</span>
<span class="body__row-value">{{d.asn || '-'}}</span> <div class="body__row-value" :title="d.asn">{{d.asn || '-'}}</div>
</div> </div>
<div class="body__detail">{{$t('common.detail')}}</div> <div class="body__detail">{{$t('common.detail')}}</div>
</template> </template>
<template v-else-if="entityType === 'domain'"> <template v-else-if="entityType === 'domain'">
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('entities.categoryGroup')}}:</span> <span class="body__row-label">{{$t('entities.categoryGroup')}}:</span>
<span class="body__row-value">{{d.categoryGroup || '-'}}</span> <div class="body__row-value" :title="d.categoryGroup">{{d.categoryGroup || '-'}}</div>
</div> </div>
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('entities.categoryName')}}:</span> <span class="body__row-label">{{$t('entities.categoryName')}}:</span>
<span class="body__row-value">{{d.categoryName || '-'}}</span> <div class="body__row-value" :title="d.categoryName">{{d.categoryName || '-'}}</div>
</div> </div>
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('entities.creditScore')}}:</span> <span class="body__row-label">{{$t('entities.creditScore')}}:</span>
<span class="body__row-value">{{d.reputationScore || '-'}}</span> <div class="body__row-value" :title="d.reputationScore">{{d.reputationScore || '-'}}</div>
</div> </div>
<div class="body__detail">{{$t('common.detail')}}</div> <div class="body__detail">{{$t('common.detail')}}</div>
</template> </template>
<template v-else-if="entityType === 'app'"> <template v-else-if="entityType === 'app'">
<div class="body__row"> <div class="body__row">
<span class="body__row-label">APP ID:</span> <span class="body__row-label">APP ID:</span>
<span class="body__row-value">{{d.appId || '-'}}</span> <div class="body__row-value" :title="d.appId">{{d.appId || '-'}}</div>
</div> </div>
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('entities.category')}}:</span> <span class="body__row-label">{{$t('entities.category')}}:</span>
<span class="body__row-value">{{d.appCategory || '-'}}</span> <div class="body__row-value" :title="d.appCategory">{{d.appCategory || '-'}}</div>
</div> </div>
<div class="body__row"> <div class="body__row">
<span class="body__row-label">{{$t('entities.subcategory')}}:</span> <span class="body__row-label">{{$t('entities.subcategory')}}:</span>
<span class="body__row-value">{{d.appSubategory || '-'}}</span> <div class="body__row-value" :title="d.appSubategory">{{d.appSubategory || '-'}}</div>
</div> </div>
<div class="body__detail">{{$t('common.detail')}}</div> <div class="body__detail">{{$t('common.detail')}}</div>
</template> </template>

View File

@@ -70,18 +70,27 @@
} }
} }
.cn-entity__body { .cn-entity__body {
overflow: hidden;
.body__row { .body__row {
display: flex;
padding: 0 0 0 20px; padding: 0 0 0 20px;
color: #666; color: #666;
.body__row-label { .body__row-label {
padding-right: 15px; padding-right: 15px;
} }
.body__row-value {
width: calc(100% - 150px);
overflow: hidden;
text-overflow: ellipsis;
}
} }
.body__detail { .body__detail {
padding: 10px 0 0 20px; padding: 10px 0 0 20px;
color: $--color-primary; color: $--color-primary;
cursor: pointer; cursor: pointer;
} }
} }
} }

View File

@@ -83,7 +83,10 @@
:icon="singleValue.icon" :icon="singleValue.icon"
> >
<template #title><span :title="chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name">{{chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name}}</span></template> <template #title><span :title="chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name">{{chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name}}</span></template>
<template #data>{{singleValue.value}}</template> <template #data>
<span>{{handleSingleValue(singleValue.value)}}</span>
<span v-if="chartInfo.params && chartInfo.params.unit" class="single-value__unit">{{chartInfo.params.unit}}</span>
</template>
</single-value> </single-value>
<!-- 表格 --> <!-- 表格 -->
<chart-table <chart-table
@@ -217,7 +220,7 @@ export default {
}, },
methods: { methods: {
initChart () { initChart () {
const chartParams = this.chartInfo.params ? JSON.parse(this.chartInfo.params) : null // 图表参数 const chartParams = this.chartInfo.params
if (this.isMap) { if (this.isMap) {
const { chart, polygonSeries } = this.initMap(`chart${this.chartInfo.id}`) const { chart, polygonSeries } = this.initMap(`chart${this.chartInfo.id}`)
this.myChart = chart this.myChart = chart
@@ -284,7 +287,7 @@ export default {
} }
}, },
loadMap (polygonSeries) { loadMap (polygonSeries) {
const chartParams = this.chartInfo.params ? JSON.parse(this.chartInfo.params) : null // 图表参数 const chartParams = this.chartInfo.params
const queryParams = { startTime: parseInt(this.startTime / 1000), endTime: parseInt(this.endTime / 1000), country: '', region: '' } // 统计数据的查询参数 const queryParams = { startTime: parseInt(this.startTime / 1000), endTime: parseInt(this.endTime / 1000), country: '', region: '' } // 统计数据的查询参数
get(replaceUrlPlaceholder(chartParams.url, queryParams)).then(response => { get(replaceUrlPlaceholder(chartParams.url, queryParams)).then(response => {
if (response.code === 200) { if (response.code === 200) {
@@ -518,6 +521,11 @@ export default {
gridColumn, gridColumn,
gridRow gridRow
} }
},
handleSingleValue () {
return function (value) {
return Number(value) < 0.01 ? '< 0.01' : this.$_.round(value, 2)
}
} }
}, },
mounted () { mounted () {
@@ -537,6 +545,7 @@ export default {
setup (props) { setup (props) {
const chartInfo = JSON.parse(JSON.stringify(props.chart)) const chartInfo = JSON.parse(JSON.stringify(props.chart))
chartInfo.category = getTypeCategory(props.chart.type) chartInfo.category = getTypeCategory(props.chart.type)
chartInfo.params = chartInfo.params ? JSON.parse(chartInfo.params) : null
return { return {
chartInfo, chartInfo,
layoutConstant, layoutConstant,

View File

@@ -90,11 +90,8 @@ export default {
default: break default: break
} }
const data = await this.loadFilterData(this.filterType, key) const data = await this.loadFilterData(this.filterType, key)
if (this.$_.isEmpty(data)) { this.filterData[index].data = this.$_.concat(this.filterData[index].data, data)
this.filterData[index].hasnotMore = true this.filterData[index].hasnotMore = this.$_.isEmpty(data) || data.length < 10
} else {
this.filterData[index].data = this.$_.concat(this.filterData[index].data, data)
}
}, },
async loadFilterData (filterType, key) { async loadFilterData (filterType, key) {
let data let data
@@ -174,6 +171,7 @@ export default {
Promise.all(requests).then(responses => { Promise.all(requests).then(responses => {
data.forEach((d, i) => { data.forEach((d, i) => {
d.data = responses[i] d.data = responses[i]
d.hasnotMore = this.$_.isEmpty(responses[i]) || responses[i].length < 10
}) })
this.filterData = data this.filterData = data
}) })
@@ -222,6 +220,7 @@ export default {
key: 'country', key: 'country',
childrenKey: 'region', childrenKey: 'region',
data: country, data: country,
hasnotMore: this.$_.isEmpty(country) || country.length < 10,
filterType: this.filterType, filterType: this.filterType,
loadFilter loadFilter
}) })
@@ -229,9 +228,11 @@ export default {
title: this.$t('entities.asn'), title: this.$t('entities.asn'),
key: 'asn', key: 'asn',
data: asn, data: asn,
hasnotMore: this.$_.isEmpty(asn) || asn.length < 10,
filterType: this.filterType, filterType: this.filterType,
loadFilter loadFilter
}) })
console.info(this.filterData)
}, },
setup () { setup () {
const filterType = ref(Object.keys(entityType)[0]) const filterType = ref(Object.keys(entityType)[0])