fix: 尝试修复不识别$t的问题

This commit is contained in:
刘洪洪
2023-10-09 16:30:11 +08:00
parent 8cc6edbdd4
commit a47e04fae2
3 changed files with 37 additions and 19 deletions

View File

@@ -15,42 +15,42 @@ _this.$t = _this.t
export const dataForNpmTrafficLine = { export const dataForNpmTrafficLine = {
tabs: [ tabs: [
{ {
name: _this.$t('network.total'), name: 'network.total',
show: true, show: true,
positioning: 0, positioning: 0,
data: [], data: [],
unitType: 'number' unitType: 'number'
}, },
{ {
name: _this.$t('network.inbound'), name: 'network.inbound',
show: true, show: true,
positioning: 1, positioning: 1,
data: [], data: [],
unitType: 'number' unitType: 'number'
}, },
{ {
name: _this.$t('network.outbound'), name: 'network.outbound',
show: true, show: true,
positioning: 2, positioning: 2,
data: [], data: [],
unitType: 'number' unitType: 'number'
}, },
{ {
name: _this.$t('network.internal'), name: 'network.internal',
show: true, show: true,
positioning: 3, positioning: 3,
data: [], data: [],
unitType: 'number' unitType: 'number'
}, },
{ {
name: _this.$t('network.through'), name: 'network.through',
show: true, show: true,
positioning: 4, positioning: 4,
data: [], data: [],
unitType: 'number' unitType: 'number'
}, },
{ {
name: _this.$t('network.other'), name: 'network.other',
show: true, show: true,
positioning: 5, positioning: 5,
data: [], data: [],
@@ -58,21 +58,21 @@ export const dataForNpmTrafficLine = {
} }
], ],
npmQuantity: [ npmQuantity: [
{ name: _this.$t('networkAppPerformance.tcpConnectionEstablishLatency'), show: true, positioning: 0, data: [], unitType: unitTypes.time, index: 0 }, { name: 'networkAppPerformance.tcpConnectionEstablishLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time, index: 0 },
{ name: _this.$t('networkAppPerformance.httpResponse'), show: true, positioning: 0, data: [], unitType: unitTypes.time, index: 1 }, { name: 'networkAppPerformance.httpResponse', show: true, positioning: 0, data: [], unitType: unitTypes.time, index: 1 },
{ name: _this.$t('networkAppPerformance.sslResponseLatency'), show: true, positioning: 0, data: [], unitType: unitTypes.time, index: 2 }, { name: 'networkAppPerformance.sslResponseLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time, index: 2 },
{ name: _this.$t('networkAppPerformance.packetLoss'), show: true, positioning: 0, data: [], unitType: unitTypes.percent, index: 3 }, { name: 'networkAppPerformance.packetLoss', show: true, positioning: 0, data: [], unitType: unitTypes.percent, index: 3 },
{ name: _this.$t('overall.packetRetrans'), show: true, positioning: 0, data: [], unitType: unitTypes.percent, index: 4 } { name: 'overall.packetRetrans', show: true, positioning: 0, data: [], unitType: unitTypes.percent, index: 4 }
], ],
metricOptions: [ metricOptions: [
/* { value: 'Bits/s', label: 'Bits/s' }, /* { value: 'Bits/s', label: 'Bits/s' },
{ value: 'Packets/s', label: 'Packets/s' }, { value: 'Packets/s', label: 'Packets/s' },
{ value: 'Sessions/s', label: 'Sessions/s' }, */ { value: 'Sessions/s', label: 'Sessions/s' }, */
{ value: 'establishLatencyMs', label: _this.$t('networkAppPerformance.tcpConnectionEstablishLatency') }, { value: 'establishLatencyMs', label: 'networkAppPerformance.tcpConnectionEstablishLatency' },
{ value: 'httpResponseLatency', label: _this.$t('networkAppPerformance.httpResponse') }, { value: 'httpResponseLatency', label: 'networkAppPerformance.httpResponse' },
{ value: 'sslConLatency', label: _this.$t('networkAppPerformance.sslResponseLatency') }, { value: 'sslConLatency', label: 'networkAppPerformance.sslResponseLatency' },
{ value: 'tcpLostlenPercent', label: _this.$t('networkAppPerformance.packetLoss') }, { value: 'tcpLostlenPercent', label: 'networkAppPerformance.packetLoss' },
{ value: 'pktRetransPercent', label: _this.$t('overall.packetRetrans') } { value: 'pktRetransPercent', label: 'overall.packetRetrans' }
] ]
} }
@@ -175,9 +175,9 @@ export const dataForLinkTrafficLine = {
export const dataForNpmLine = { export const dataForNpmLine = {
chartOptionLineData: [ chartOptionLineData: [
{ legend: _this.$t('network.total'), index: 0, invertTab: true, show: false, color: '#749F4D' }, { legend: 'network.total', index: 0, invertTab: true, show: false, color: '#749F4D' },
{ legend: _this.$t('network.inbound'), index: 1, invertTab: true, show: false, color: '#98709B' }, { legend: 'network.inbound', index: 1, invertTab: true, show: false, color: '#98709B' },
{ legend: _this.$t('network.outbound'), index: 2, invertTab: true, show: false, color: '#E5A219' } { legend: 'network.outbound', index: 2, invertTab: true, show: false, color: '#E5A219' }
], ],
npmLineColor: [ npmLineColor: [
{ legend: '', color: '#749F4D' }, { legend: '', color: '#749F4D' },

View File

@@ -324,9 +324,15 @@ export default {
case 5: case 5:
return api.npm.location.packetsRetrains return api.npm.location.packetsRetrains
} }
},
initI18n () {
dataForNpmLine.chartOptionLineData.forEach(item => {
item.legend = this.$t(item.legend)
})
} }
}, },
mounted () { mounted () {
this.initI18n()
if (this.chart) { if (this.chart) {
this.chartData = _.cloneDeep(this.chart) this.chartData = _.cloneDeep(this.chart)
} }

View File

@@ -458,9 +458,21 @@ export default {
} }
this.$store.commit('setRangeEchartsData', rangeObj) this.$store.commit('setRangeEchartsData', rangeObj)
} }
},
initI18n () {
dataForNpmTrafficLine.tabs.forEach(item => {
item.name = this.$t(item.name)
})
dataForNpmTrafficLine.npmQuantity.forEach(item => {
item.name = this.$t(item.name)
})
dataForNpmTrafficLine.metricOptions.forEach(item => {
item.label = this.$t(item.label)
})
} }
}, },
mounted () { mounted () {
this.initI18n()
if (this.chart) { if (this.chart) {
this.chartData = _.cloneDeep(this.chart) this.chartData = _.cloneDeep(this.chart)
} }