CN-501 feat: 响应式方案实施

This commit is contained in:
@changcode
2022-04-25 15:29:44 +08:00
parent 01760c28a4
commit e90d6ea506
29 changed files with 230 additions and 91 deletions

View File

@@ -24,6 +24,7 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moment-timezone": "^0.5.33", "moment-timezone": "^0.5.33",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"postcss-plugin-px2rem": "^0.8.1",
"postcss-px2rem-exclude": "0.0.6", "postcss-px2rem-exclude": "0.0.6",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"sass-resources-loader": "^2.2.1", "sass-resources-loader": "^2.2.1",

View File

@@ -1,9 +1,11 @@
module.exports = { module.exports = {
plugins: { plugins: {
autoprefixer: {} autoprefixer: {},
/* 'postcss-px2rem-exclude': { 'postcss-plugin-px2rem': {
remUnit: 16, rootValue: 16,
exclude: /node_modules/i exclude: /node_modules/i,
} */ minPixelValue: 3,
selectorBlackList: ['.html', 'iconfont', '.ttf', '.css']
}
} }
} }

View File

@@ -14,15 +14,39 @@
<div id="app"></div> <div id="app"></div>
</body> </body>
<style> <style>
@media only screen and (min-width : 1224px) { @media only screen and (min-width: 800px) {
html { body,html{font-size: 12px !important;}
font-size: 12px !important; } /*>=800的设备*/
}
} @media only screen and (min-width: 1024px) {
@media only screen and (min-width : 1824px) { body,html{font-size: 12px !important;}
html { } /*>=1024的设备*/
font-size: 16px !important;
} @media only screen and (min-width: 1280px) {
} body,html{font-size: 12px !important;}
}/*>=1280的设备*/
@media only screen and (min-width: 1366px) {
body,html{font-size: 12px !important; }
}/*>=1366的设备*/
@media only screen and (min-width: 1440px) {
body,html{font-size: 12px !important;}
}/*>=1440的设备*/
@media only screen and (min-width: 1680px) {
body,html{font-size: 14px !important;}
}/*>=1680的设备*/
@media only screen and (min-width: 1920px) {
body,html{font-size: 16px !important;}
}/*>=1920的设备*/
@media only screen and (min-width: 2048px) {
body,html{font-size: 18px !important;}
}/*>=2048的设备*/
@media only screen and (min-width: 2560px) {
body,html{font-size: 22px !important;}
}/*>=2560的设备*/
</style> </style>
</html> </html>

View File

@@ -5,10 +5,12 @@
align-items: center; align-items: center;
margin-left: 33px; margin-left: 33px;
height: 100%; height: 100%;
.box__progress{ .box__progress {
display: block; display: block;
width: 76px; .el-progress-circle {
height: 76px; height: 80px !important;
width: 80px !important;
}
.el-progress__text span{ .el-progress__text span{
font-size: 16px; font-size: 16px;
} }

View File

@@ -10,7 +10,6 @@
.cn-chart__body { .cn-chart__body {
flex: auto; flex: auto;
display: flex; display: flex;
overflow: hidden auto;
.el-table { .el-table {
padding: 0 10px; padding: 0 10px;
@@ -37,16 +36,19 @@
height: calc(100% - 36px) !important; height: calc(100% - 36px) !important;
}*/ }*/
} }
.cn-chart__body.pie-with-table { //.cn-chart__body.pie-with-table {
flex-basis: 40%; // flex-basis: 60%;
} //}
.cn-chart__footer.pie-with-table { .cn-chart__footer.pie-with-table {
flex-basis: 60%;
padding: 10px 30px 30px; padding: 10px 30px 30px;
overflow: auto;
.pie-table .el-table__body-wrapper {
height: calc(100% - 40px) !important;
}
} }
} }
.pie-table { .pie-table {
font-size: 14px; font-size: 12px;
color: #333333; color: #333333;
font-weight: 500; font-weight: 500;

View File

@@ -44,14 +44,14 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex: 0 0 40%; flex: 0 0 100px;
} }
.single-value__icon { .single-value__icon {
display: flex; display: flex;
justify-content: center; justify-content: center;
width: 72px; width: 56px;
height: 72px; height: 56px;
background-color: $--chart-single-value-icon-background-color; background-color: $--chart-single-value-icon-background-color;
border-radius: 50%; border-radius: 50%;
@@ -66,12 +66,12 @@
.single-value__content { .single-value__content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-width: 60%; width: 200px;
padding-right: 10px; padding-right: 10px;
.content__data { .content__data {
padding-bottom: 7%; padding-bottom: 10px;
font-size: 20px; font-size: 18px;
color: #333333; color: #333333;
font-weight: bold; font-weight: bold;
} }
@@ -80,7 +80,7 @@
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
font-size: 16px; font-size: 14px;
color: #666666; color: #666666;
} }
@@ -105,10 +105,11 @@
justify-content: space-around; justify-content: space-around;
align-items: center; align-items: center;
height: 100%; height: 100%;
width: 100%; width: 90%;
margin: auto;
.single-value-icon__box { .single-value-icon__box {
flex: 0 0 80px; flex: 0 0 74px;
} }
.single-value__icon { .single-value__icon {
@@ -249,7 +250,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
height: 25%; height: 25%;
font-size: 24px; font-size: 18px;
color: #333333; color: #333333;
font-weight: bold; font-weight: bold;
} }
@@ -572,16 +573,15 @@
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
justify-content: right; justify-content: right;
margin-right:25px; margin: 0 22px 22px 0;
flex: 0 0 80; flex: 0 0 80;
margin-bottom: 25px;
} }
.single-value__icon { .single-value__icon {
display: flex; display: flex;
justify-content: center; justify-content: center;
width: 70px; width: 60px;
height: 70px; height: 60px;
background-color: $--chart-single-value-icon-background-color; background-color: $--chart-single-value-icon-background-color;
border-radius: 50%; border-radius: 50%;
@@ -601,7 +601,7 @@
margin-left:25px; margin-left:25px;
.content__data { .content__data {
margin-bottom: 7%; margin-bottom: 5%;
font-size: 22px; font-size: 22px;
color: #333333; color: #333333;
font-weight: bold; font-weight: bold;

View File

@@ -13,6 +13,7 @@
.el-table { .el-table {
padding: 0 10px; padding: 0 10px;
font-size: 14px;
.el-table__body-wrapper.is-scrolling-none { .el-table__body-wrapper.is-scrolling-none {
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;

View File

@@ -29,9 +29,8 @@
display: flex; display: flex;
justify-content:space-between; justify-content:space-between;
align-items:center; align-items:center;
padding: 10px 20px 10px 18px; padding: 0 18px;
flex: 0 0 40px; flex: 0 0 40px;
font-size: 16px; font-size: 16px;
color: $--color-text-primary; color: $--color-text-primary;
transition: all 0.2s; transition: all 0.2s;
@@ -170,7 +169,8 @@
} }
.option__select { .option__select {
.el-input__inner { .el-input__inner {
width: 80px; width: 92px;
text-align: center;
padding-right: 20px; padding-right: 20px;
border: none; border: none;
height: 100%; height: 100%;
@@ -335,6 +335,18 @@
&>.el-tabs__header { &>.el-tabs__header {
margin-bottom: 10px; margin-bottom: 10px;
} }
.el-tabs__nav.is-top {
.el-tabs__active-bar {
display: none;
}
.el-tabs__item.is-top {
padding: 0;
margin: 0 13px;
}
.el-tabs__item.is-top.is-active {
border-bottom: 2px solid #0091ff;
}
}
&>.el-tabs__content { &>.el-tabs__content {
height: calc(100% - 40px); height: calc(100% - 40px);
.el-tab-pane { .el-tab-pane {

View File

@@ -48,7 +48,7 @@
} }
.explorer-container { .explorer-container {
display: flex; display: flex;
overflow: hidden auto; overflow: hidden;
height: calc(100% - 120px); height: calc(100% - 120px);
position: relative; position: relative;
} }

View File

@@ -124,7 +124,7 @@ export default {
label: 'ID', label: 'ID',
prop: 'id', prop: 'id',
show: true, show: true,
width: 80, width: 110,
sortable: 'custom' sortable: 'custom'
}, { }, {
label: this.$t('config.chart.name'), label: this.$t('config.chart.name'),

View File

@@ -124,7 +124,7 @@ export default {
label: 'ID', label: 'ID',
prop: 'id', prop: 'id',
show: true, show: true,
width: 80, width: 100,
sortable: 'custom' sortable: 'custom'
}, { }, {
label: this.$t('overall.name'), label: this.$t('overall.name'),

View File

@@ -76,7 +76,7 @@ export default {
label: 'ID', label: 'ID',
prop: 'id', prop: 'id',
show: true, show: true,
width: 80, width: 100,
sortable: 'custom' sortable: 'custom'
}, },
{ {

View File

@@ -75,7 +75,7 @@ export default {
label: this.$t('config.operationlog.id'), label: this.$t('config.operationlog.id'),
prop: 'id', prop: 'id',
show: true, show: true,
width: 80 width: 100
}, { }, {
label: this.$t('config.operationlog.username'), label: this.$t('config.operationlog.username'),
prop: 'username', prop: 'username',

View File

@@ -85,7 +85,7 @@ export default {
label: 'ID', label: 'ID',
prop: 'id', prop: 'id',
show: true, show: true,
width: 80, width: 100,
sortable: 'custom' sortable: 'custom'
}, { }, {
label: this.$t('config.roles.name'), label: this.$t('config.roles.name'),

View File

@@ -103,7 +103,7 @@ export default {
label: 'ID', label: 'ID',
prop: 'id', prop: 'id',
show: true, show: true,
width: 80, width: 100,
sortable: 'custom' sortable: 'custom'
}, { }, {
label: this.$t('config.user.name'), label: this.$t('config.user.name'),

View File

@@ -26,6 +26,8 @@ import TimeRefresh from '@/components/common/TimeRange/TimeRefresh'
import PanelChartList from '@/views/charts/PanelChartList' import PanelChartList from '@/views/charts/PanelChartList'
const emitter = new bus() const emitter = new bus()
import 'lib-flexible'
const _ = require('lodash') // lodash工具 const _ = require('lodash') // lodash工具
/* dayjs.extend(utc) /* dayjs.extend(utc)

View File

@@ -81,6 +81,7 @@ import _ from 'lodash'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import DnsScreen from '@/views/charts/wholeScreenScroll/DnsScreen' import DnsScreen from '@/views/charts/wholeScreenScroll/DnsScreen'
import { wholeScreenRouterMapping } from '@/utils/constants' import { wholeScreenRouterMapping } from '@/utils/constants'
import { ref } from 'vue'
export default { export default {
name: 'PanelChartList', name: 'PanelChartList',
@@ -102,7 +103,6 @@ export default {
return { return {
gridLayoutLoading: false, gridLayoutLoading: false,
gridLayoutShow: false, gridLayoutShow: false,
rowHeight: 40,
copyDataList: [], // 所有的图表 copyDataList: [], // 所有的图表
normalCopyDataList: [], // 非整屏滚动的图表 normalCopyDataList: [], // 非整屏滚动的图表
noData: false, // no data noData: false, // no data
@@ -183,9 +183,29 @@ export default {
return item.y >= -1 return item.y >= -1
}) })
}, 100) }, 100)
},
chartHeightData (e) {
if (e.currentTarget.innerWidth < 1280) {
this.rowHeight = 25
} else if (e.currentTarget.innerWidth >= 1280 && e.currentTarget.innerWidth <= 1440) {
this.rowHeight = 25
} else if (e.currentTarget.innerWidth >= 1440 && e.currentTarget.innerWidth < 1920) {
this.rowHeight = 32.5
} else if (e.currentTarget.innerWidth >= 1920 && e.currentTarget.innerWidth <= 2048) {
this.rowHeight = 40
} else if (e.currentTarget.innerWidth >= 2048 && e.currentTarget.innerWidth <= 2560) {
this.rowHeight = 55
} else if (e.currentTarget.innerWidth > 2560) {
this.rowHeight = 55
}
} }
}, },
mounted () {
window.addEventListener('resize', this.$_.debounce(this.chartHeightData, 100))
},
beforeUnmount () {
window.removeEventListener('resize', this.chartHeightData)
},
computed: { computed: {
anchorPoint () { anchorPoint () {
return function (chart) { return function (chart) {
@@ -199,7 +219,23 @@ export default {
}, },
setup (props) { setup (props) {
const { currentRoute } = useRouter() const { currentRoute } = useRouter()
const htmlHeight = document.getElementsByTagName('html')[0].clientWidth
const rowHeight = ref(0)
if (htmlHeight < 1280) {
rowHeight.value = 25
} else if (htmlHeight >= 1280 && htmlHeight <= 1440) {
rowHeight.value = 25
} else if (htmlHeight >= 1440 && htmlHeight < 1920) {
rowHeight.value = 32.5
} else if (htmlHeight >= 1920 && htmlHeight <= 2048) {
rowHeight.value = 40
} else if (htmlHeight >= 2048 && htmlHeight <= 2560) {
rowHeight.value = 55
} else if (htmlHeight > 2560) {
rowHeight.value = 55
}
return { return {
rowHeight,
currentPath: currentRoute.value.path currentPath: currentRoute.value.path
} }
}, },

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="chart-drawing" :style="`height: calc(100% - ${statisticsHeight}px)`" :id="`chart${chartInfo.id}`"></div> <div class="chart-drawing" style="height: calc(100% - 17.5rem)" :id="`chart${chartInfo.id}`"></div>
<div class="cn-chart__footer"> <div class="cn-chart__footer">
<statistics-legend :data="statisticsData" :chart-info="chartInfo" @toggleLegend="toggleStatisticsLegend"></statistics-legend> <statistics-legend :data="statisticsData" :chart-info="chartInfo" @toggleLegend="toggleStatisticsLegend"></statistics-legend>
</div> </div>
@@ -19,8 +19,7 @@ export default {
mixins: [chartEchartMixin], mixins: [chartEchartMixin],
data () { data () {
return { return {
statisticsData: [], statisticsData: []
statisticsHeight: 280
} }
}, },
props: { props: {
@@ -29,13 +28,6 @@ export default {
components: { components: {
StatisticsLegend StatisticsLegend
}, },
mounted () {
// 动态计算统计信息的高度
if (this.chartData) {
const dataLen = this.chartData.length
this.statisticsHeight = (dataLen * 24) + 30 + 3 + 7 // 根据legend个数动态预留legend空间,7为其他
}
},
methods: { methods: {
initEcharts (id) { initEcharts (id) {
this.initDom(id) this.initDom(id)

View File

@@ -95,8 +95,17 @@ export default {
this.chartOption.series[0].data = protocols this.chartOption.series[0].data = protocols
this.chartOption.xAxis.data = protocols.map(p => p.name) this.chartOption.xAxis.data = protocols.map(p => p.name)
this.myChart.setOption(this.chartOption) this.myChart.setOption(this.chartOption)
},
resize () {
this.myChart.resize()
} }
}, },
mounted () {
window.addEventListener('resize', this.$_.debounce(this.resize, 200))
},
beforeUnmount () {
window.removeEventListener('resize', this.resize)
},
watch: { watch: {
chartData: { chartData: {
deep: true, deep: true,

View File

@@ -5,7 +5,6 @@
<el-progress <el-progress
type="circle" type="circle"
:color="chartInfo.params.color" :color="chartInfo.params.color"
width="76"
:percentage="Math.floor(($_.get(chartData, 'percent', '-') * 100) * 100) / 100" :percentage="Math.floor(($_.get(chartData, 'percent', '-') * 100) * 100) / 100"
/> />
</div> </div>

View File

@@ -105,8 +105,17 @@ export default {
this.chartOption.series[0].data = data this.chartOption.series[0].data = data
this.chartOption.series[0].links = link this.chartOption.series[0].links = link
this.myChart.setOption(this.chartOption) this.myChart.setOption(this.chartOption)
},
resize () {
this.myChart.resize()
} }
}, },
mounted () {
window.addEventListener('resize', this.$_.debounce(this.resize))
},
beforeUnmount () {
window.removeEventListener('resize', this.resize)
},
watch: { watch: {
chartData: { chartData: {
deep: true, deep: true,

View File

@@ -6,7 +6,7 @@
tooltip-effect="light" tooltip-effect="light"
:data="table.currentPageData" :data="table.currentPageData"
> >
<el-table-column v-if="table.currentPageData.length" type="index" label="#"> <el-table-column :width="60" v-if="table.currentPageData.length" type="index" label="#">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-for="(c, i) in table.tableColumns.common" v-for="(c, i) in table.tableColumns.common"

View File

@@ -39,8 +39,14 @@ export default {
}, },
reload () { reload () {
this.dataList = _.cloneDeep(this.dataList) this.dataList = _.cloneDeep(this.dataList)
},
resize () {
this.$forceUpdate()
} }
}, },
mounted () {
window.addEventListener('resize', this.$_.debounce(this.resize, 300))
},
setup (props) { setup (props) {
let activeTab = '' let activeTab = ''
if (!_.isEmpty(props.chartInfo.children)) { if (!_.isEmpty(props.chartInfo.children)) {

View File

@@ -77,6 +77,18 @@ export default {
return allZero return allZero
} }
}, },
chartResize () {
this.$store.getters.getChartList.forEach(chart => {
if (chart) {
chart.resize()
}
})
},
test () {
setTimeout(() => {
this.chartResize()
}, 400)
},
loadEchart (chartNum, refresh = false) { loadEchart (chartNum, refresh = false) {
this.$emit('showLoading', true) this.$emit('showLoading', true)
try { try {
@@ -86,14 +98,7 @@ export default {
this.myChart2.setOption(this.chartOption2, refresh) this.myChart2.setOption(this.chartOption2, refresh)
this.$store.commit('setChartList', this.$_.cloneDeep(this.myChart2)) this.$store.commit('setChartList', this.$_.cloneDeep(this.myChart2))
} }
const _this = this window.addEventListener('resize', this.$_.debounce(this.test, 400))
window.addEventListener('resize', function () {
_this.$store.getters.getChartList.forEach(chart => {
if (chart) {
chart.resize()
}
})
})
} finally { } finally {
setTimeout(() => { setTimeout(() => {
this.$emit('showLoading', false) this.$emit('showLoading', false)
@@ -101,6 +106,9 @@ export default {
} }
} }
}, },
beforeUnmount () {
window.removeEventListener('resize', this.test)
},
watch: { watch: {
chartData: { chartData: {
deep: true, deep: true,

View File

@@ -114,6 +114,7 @@ import { api, getData } from '@/utils/api'
import { reverseSortBy, sortBy, extensionEchartY } from '@/utils/tools' import { reverseSortBy, sortBy, extensionEchartY } from '@/utils/tools'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import DetectionNoData from '@/views/detections/DetectionNoData' import DetectionNoData from '@/views/detections/DetectionNoData'
import { shallowRef } from 'vue'
export default { export default {
name: 'Index', name: 'Index',
@@ -128,6 +129,7 @@ export default {
}, },
data () { data () {
return { return {
chartInit: [],
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
pageSize: defaultPageSize, pageSize: defaultPageSize,
@@ -285,7 +287,7 @@ export default {
// eventSeverityTrendOption.xAxis.data = dataMap.get('info').map(v => rTime(v[0])) // eventSeverityTrendOption.xAxis.data = dataMap.get('info').map(v => rTime(v[0]))
eventSeverityTrendOption.xAxis.data = xData eventSeverityTrendOption.xAxis.data = xData
const detectionChart = echarts.init(chartDom) const detectionChart = echarts.init(chartDom)
this.echartsResize(detectionChart) this.chartInit.push(shallowRef(detectionChart))
detectionChart.setOption(eventSeverityTrendOption) detectionChart.setOption(eventSeverityTrendOption)
// this.isEventSeverityNoData = false // this.isEventSeverityNoData = false
} else { } else {
@@ -312,7 +314,7 @@ export default {
}) })
const chartDom = document.getElementById(`eventSeverityPie${this.pageType}`) const chartDom = document.getElementById(`eventSeverityPie${this.pageType}`)
const detectionChart = echarts.init(chartDom) const detectionChart = echarts.init(chartDom)
this.echartsResize(detectionChart) this.chartInit.push(shallowRef(detectionChart))
detectionChart.setOption(eventSeverityOption) detectionChart.setOption(eventSeverityOption)
const vm = this const vm = this
detectionChart.off('click') detectionChart.off('click')
@@ -339,7 +341,7 @@ export default {
})) }))
const chartDom = document.getElementById(`detectionCategoryPer${this.pageType}`) const chartDom = document.getElementById(`detectionCategoryPer${this.pageType}`)
const detectionChart = echarts.init(chartDom) const detectionChart = echarts.init(chartDom)
this.echartsResize(detectionChart) this.chartInit.push(shallowRef(detectionChart))
const securityTypeOption = this.$_.cloneDeep(pieForSeverity) const securityTypeOption = this.$_.cloneDeep(pieForSeverity)
securityTypeOption.series[0].data = data.map(d => { securityTypeOption.series[0].data = data.map(d => {
return { value: d.count, name: d.eventType } return { value: d.count, name: d.eventType }
@@ -367,7 +369,7 @@ export default {
})) }))
const chartDom = document.getElementById(`detectionCategoryPer${this.pageType}`) const chartDom = document.getElementById(`detectionCategoryPer${this.pageType}`)
const detectionChart = echarts.init(chartDom) const detectionChart = echarts.init(chartDom)
this.echartsResize(detectionChart) this.chartInit.push(shallowRef(detectionChart))
const securityTypeOption = this.$_.cloneDeep(pieForSeverity) const securityTypeOption = this.$_.cloneDeep(pieForSeverity)
securityTypeOption.series[0].data = data.map(d => { securityTypeOption.series[0].data = data.map(d => {
return { value: d.count, name: d.securityType, itemStyle: { color: getAttackColor(d.securityType) } } return { value: d.count, name: d.securityType, itemStyle: { color: getAttackColor(d.securityType) } }
@@ -399,7 +401,7 @@ export default {
const chartDom = document.getElementById(`detectionActiveAttacker${this.pageType}`) const chartDom = document.getElementById(`detectionActiveAttacker${this.pageType}`)
const detectionChart = echarts.init(chartDom) const detectionChart = echarts.init(chartDom)
this.echartsResize(detectionChart) this.chartInit.push(shallowRef(detectionChart))
const offenderIpOption = this.$_.cloneDeep(activeAttackBar) const offenderIpOption = this.$_.cloneDeep(activeAttackBar)
data.sort(reverseSortBy('count')) data.sort(reverseSortBy('count'))
data = data.slice(0, 5) data = data.slice(0, 5)
@@ -455,7 +457,7 @@ export default {
if (!this.$_.isEmpty(data)) { if (!this.$_.isEmpty(data)) {
const chartDom = document.getElementById(`detectionActiveAttacker${this.pageType}`) const chartDom = document.getElementById(`detectionActiveAttacker${this.pageType}`)
const detectionChart = echarts.init(chartDom) const detectionChart = echarts.init(chartDom)
this.echartsResize(detectionChart) this.chartInit.push(shallowRef(detectionChart))
const option = this.$_.cloneDeep(activeAttackBar) const option = this.$_.cloneDeep(activeAttackBar)
data.sort(reverseSortBy('count')) data.sort(reverseSortBy('count'))
data = data.slice(0, 5) data = data.slice(0, 5)
@@ -603,15 +605,14 @@ export default {
wraps.scrollTop = 0 wraps.scrollTop = 0
}) })
}, },
echartsResize (detectionChart) { resize () {
window.addEventListener('resize', function () { this.chartInit.forEach(e => { e.value.resize() })
detectionChart.resize()
})
} }
}, },
mounted () { mounted () {
this.queryFilter() this.queryFilter()
this.queryList() this.queryList()
window.addEventListener('resize', this.$_.debounce(this.resize, 300))
}, },
watch: { watch: {
eventSeverityData: { eventSeverityData: {
@@ -729,7 +730,7 @@ export default {
} }
}, },
beforeUnmount () { beforeUnmount () {
window.removeEventListener('resize', function () {}) window.removeEventListener('resize', this.resize)
}, },
setup () { setup () {
const { params } = useRoute() const { params } = useRoute()

View File

@@ -72,6 +72,7 @@ export default {
}, },
methods: { methods: {
chartLoaded (chartList) { chartLoaded (chartList) {
this.chartList = chartList
this.anchorPoints = [] this.anchorPoints = []
let anchorPoints = [] let anchorPoints = []
const panelDom = document.querySelector('#detailWrapper') const panelDom = document.querySelector('#detailWrapper')
@@ -103,8 +104,17 @@ export default {
jumpToAnchor (anchor) { jumpToAnchor (anchor) {
this.top = anchor.top this.top = anchor.top
document.querySelector('#detailWrapper').scrollTop = this.top document.querySelector('#detailWrapper').scrollTop = this.top
},
resize () {
this.chartLoaded(this.chartList)
} }
}, },
mounted () {
window.addEventListener('resize', this.$_.debounce(this.resize, 200))
},
beforeUnmount () {
window.removeEventListener('resize', this.resize)
},
computed: { computed: {
iconClass () { iconClass () {
let className let className

View File

@@ -58,11 +58,11 @@
<div class="body__statics"> <div class="body__statics">
<div class="entity-statics-down"> <div class="entity-statics-down">
<i class="cn-icon cn-icon-fall entity-statics-icon"></i> <i class="cn-icon cn-icon-fall entity-statics-icon"></i>
{{entityData.bytesReceivedRate ? unitConvert(entityData.bytesReceivedRate, unitTypes.byte).join(' ') + 'ps' : '-'}} <span>{{entityData.bytesReceivedRate ? unitConvert(entityData.bytesReceivedRate, unitTypes.byte).join(' ') : '-'}}</span>
</div> </div>
<div class="entity-statics-up" > <div class="entity-statics-up" >
<i class="cn-icon cn-icon-rise"></i> <i class="cn-icon cn-icon-rise"></i>
{{entityData.bytesSentRate ? unitConvert(entityData.bytesSentRate, unitTypes.byte).join(' ') + 'ps' : '-'}} <span>{{entityData.bytesSentRate ? unitConvert(entityData.bytesSentRate, unitTypes.byte).join(' ') : '-'}}</span>
</div> </div>
<div class="body__detail" @click="showDetail">{{$t('overall.detail')}}></div> <div class="body__detail" @click="showDetail">{{$t('overall.detail')}}></div>
</div> </div>
@@ -94,11 +94,11 @@
</div> </div>
<div class="body__statics"> <div class="body__statics">
<div class="entity-statics-down"><i class="cn-icon cn-icon-fall entity-statics-icon"></i> <div class="entity-statics-down"><i class="cn-icon cn-icon-fall entity-statics-icon"></i>
{{entityData.bytesReceivedRate ? unitConvert(entityData.bytesReceivedRate, unitTypes.byte).join(' ') + 'ps' : '-'}} <span>{{entityData.bytesReceivedRate ? unitConvert(entityData.bytesReceivedRate, unitTypes.bps).join(' ') : '-'}}</span>
</div> </div>
<div class="entity-statics-up" > <div class="entity-statics-up" >
<i class="cn-icon cn-icon-rise"></i> <i class="cn-icon cn-icon-rise"></i>
{{entityData.bytesSentRate ? unitConvert(entityData.bytesSentRate, unitTypes.byte).join(' ') + 'ps' : '-'}} <span>{{entityData.bytesSentRate ? unitConvert(entityData.bytesSentRate, unitTypes.bps).join(' ') : '-'}}</span>
</div> </div>
<div class="body__detail" @click="showDetail">{{$t('overall.detail')}}></div> <div class="body__detail" @click="showDetail">{{$t('overall.detail')}}></div>
</div> </div>
@@ -129,8 +129,8 @@
<div class="body__drawing" :id="`entityListChart${entityData.appName}${listMode}`"></div> <div class="body__drawing" :id="`entityListChart${entityData.appName}${listMode}`"></div>
</div> </div>
<div class="body__statics"> <div class="body__statics">
<div class="entity-statics-down"><i class="cn-icon cn-icon-fall entity-statics-icon"></i>{{entityData.bytesReceivedRate ? unitConvert(entityData.bytesReceivedRate, unitTypes.byte).join(' ') + 'ps' : '-'}}</div> <div class="entity-statics-down"><i class="cn-icon cn-icon-fall entity-statics-icon"></i><span>{{entityData.bytesReceivedRate ? unitConvert(entityData.bytesReceivedRate, unitTypes.bps).join(' ') : '-'}}</span></div>
<div class="entity-statics-up" ><i class="cn-icon cn-icon-rise"></i>{{entityData.bytesSentRate ? unitConvert(entityData.bytesSentRate, unitTypes.byte).join(' ') + 'ps' : '-'}}</div> <div class="entity-statics-up" ><i class="cn-icon cn-icon-rise"></i><span>{{entityData.bytesSentRate ? unitConvert(entityData.bytesSentRate, unitTypes.bps).join(' ') : '-'}}</span></div>
<div class="body__detail" @click="showDetail">{{$t('overall.detail')}}></div> <div class="body__detail" @click="showDetail">{{$t('overall.detail')}}></div>
</div> </div>
</template> </template>

View File

@@ -4,6 +4,7 @@ import * as echarts from 'echarts'
import { entityListLineOption } from '@/views/charts/charts/chart-options' import { entityListLineOption } from '@/views/charts/charts/chart-options'
import { riskLevelMapping, unitTypes } from '@/utils/constants' import { riskLevelMapping, unitTypes } from '@/utils/constants'
import unitConvert from '@/utils/unit-convert' import unitConvert from '@/utils/unit-convert'
import { shallowRef } from 'vue'
export default { export default {
props: { props: {
@@ -26,7 +27,8 @@ export default {
receivedChart: null receivedChart: null
}, },
chartOption: null, chartOption: null,
queryParams: {} queryParams: {},
echartsArray: []
} }
}, },
computed: { computed: {
@@ -121,6 +123,7 @@ export default {
} }
} }
}) })
this.echartsArray.push(shallowRef(this.sentChart), shallowRef(this.receivedChart))
this.sentChart.setOption(this.chartOptionSent) this.sentChart.setOption(this.chartOptionSent)
this.receivedChart.setOption(this.chartOptionReceived) this.receivedChart.setOption(this.chartOptionReceived)
} }
@@ -312,6 +315,7 @@ export default {
] ]
} }
}) })
this.echartsArray.push(shallowRef(this.detectionChart))
this.detectionChart.setOption(this.chartDetectionQueryRate) this.detectionChart.setOption(this.chartDetectionQueryRate)
} }
}) })
@@ -333,6 +337,10 @@ export default {
}, 200) }, 200)
}) })
} }
},
resize () {
this.echartsArray.forEach(item => { item.value.resize() })
} }
}, },
setup () { setup () {
@@ -342,7 +350,11 @@ export default {
} }
}, },
mounted () { mounted () {
window.addEventListener('resize', this.$_.debounce(this.resize, 200))
this.chartOption = _.cloneDeep(entityListLineOption) this.chartOption = _.cloneDeep(entityListLineOption)
setTimeout(() => { this.queryEntityDetail() }) setTimeout(() => { this.queryEntityDetail() })
},
beforeUnmount () {
window.removeEventListener('resize', this.resize)
} }
} }

View File

@@ -6,6 +6,7 @@ import { entityListLineOption } from '@/views/charts/charts/chart-options'
import { riskLevelMapping, unitTypes } from '@/utils/constants' import { riskLevelMapping, unitTypes } from '@/utils/constants'
import { getSecond } from '@/utils/date-util' import { getSecond } from '@/utils/date-util'
import unitConvert from '@/utils/unit-convert' import unitConvert from '@/utils/unit-convert'
import { shallowRef } from 'vue'
export default { export default {
props: { props: {
@@ -19,7 +20,8 @@ export default {
trafficUrl: '', trafficUrl: '',
chartOption: null, chartOption: null,
unitTypes, unitTypes,
unitConvert unitConvert,
echartsArray: []
} }
}, },
computed: { computed: {
@@ -251,6 +253,7 @@ export default {
}) })
if (this.listMode === 'block') { if (this.listMode === 'block') {
const chart = echarts.init(document.getElementById(`entityListChart${this.entityName}${this.listMode}`)) const chart = echarts.init(document.getElementById(`entityListChart${this.entityName}${this.listMode}`))
this.echartsArray.push(shallowRef(chart))
chart.setOption({ chart.setOption({
...this.chartOption, ...this.chartOption,
series: [sentSeries, receivedSeries] series: [sentSeries, receivedSeries]
@@ -258,6 +261,7 @@ export default {
} else if (this.listMode === 'list') { } else if (this.listMode === 'list') {
const sentChart = echarts.init(document.getElementById(`entityDetailSend${this.entityName}${this.listMode}`)) const sentChart = echarts.init(document.getElementById(`entityDetailSend${this.entityName}${this.listMode}`))
const receivedChart = echarts.init(document.getElementById(`entityDetailReceived${this.entityName}${this.listMode}`)) const receivedChart = echarts.init(document.getElementById(`entityDetailReceived${this.entityName}${this.listMode}`))
this.echartsArray.push(shallowRef(sentChart), shallowRef(receivedChart))
sentChart.setOption({ sentChart.setOption({
...this.chartOption, ...this.chartOption,
series: [sentSeries] series: [sentSeries]
@@ -278,6 +282,9 @@ export default {
} catch (e) {} } catch (e) {}
}, 250) }, 250)
}) })
},
resize () {
this.echartsArray.forEach(item => { item.value.resize() })
} }
}, },
watch: { watch: {
@@ -306,6 +313,7 @@ export default {
} }
}, },
mounted () { mounted () {
window.addEventListener('resize', this.$_.debounce(this.resize, 200))
this.chartOption = _.cloneDeep(entityListLineOption) this.chartOption = _.cloneDeep(entityListLineOption)
this.entityData = _.cloneDeep(this.entity) this.entityData = _.cloneDeep(this.entity)
setTimeout(() => { setTimeout(() => {
@@ -313,5 +321,8 @@ export default {
this.queryEntityDetailTraffic() this.queryEntityDetailTraffic()
this.queryPerformance() this.queryPerformance()
}) })
},
beforeUnmount () {
window.removeEventListener('resize', this.resize)
} }
} }