fix: 修正npm-dashboard的tab的活动条的偏差
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
.el-tabs--top .el-tabs__item.is-top:nth-child(2) {
|
.el-tabs--top .el-tabs__item.is-top:nth-child(2) {
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
|
.el-tabs__nav-wrap::after {
|
||||||
|
height: 1px;
|
||||||
|
background-color: #E2E5EC;
|
||||||
|
}
|
||||||
.el-tabs--top .el-tabs__item {
|
.el-tabs--top .el-tabs__item {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
@@ -27,7 +31,7 @@
|
|||||||
&.is-active {
|
&.is-active {
|
||||||
.npm-tab__label {
|
.npm-tab__label {
|
||||||
color: #353636;
|
color: #353636;
|
||||||
box-shadow: 1px 0 0px 0px #E2E5EC, inset 1px 0 0 #E2E5EC;
|
box-shadow: 1px 0 0 0 #E2E5EC, inset 1px 0 0 #E2E5EC;
|
||||||
|
|
||||||
i {
|
i {
|
||||||
color: #046EC9;
|
color: #046EC9;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
></network-overview-tabs>
|
></network-overview-tabs>
|
||||||
<npm-tabs
|
<npm-tabs
|
||||||
v-else-if="chart.type === typeMapping.npm.npmTabs"
|
v-else-if="chart.type === typeMapping.npm.npmTabs"
|
||||||
@tabChange="index => $emit('tabChange', index)"
|
@tabChange="npmTabChange"
|
||||||
></npm-tabs>
|
></npm-tabs>
|
||||||
<npm-network-quantity
|
<npm-network-quantity
|
||||||
v-else-if="chart.type === typeMapping.npm.npmNetworkQuantity"
|
v-else-if="chart.type === typeMapping.npm.npmNetworkQuantity"
|
||||||
@@ -59,6 +59,11 @@ export default {
|
|||||||
loading: false,
|
loading: false,
|
||||||
isNoData: false
|
isNoData: false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
npmTabChange (index) {
|
||||||
|
this.$emit('npmTabChange', index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
v-if="item.type === typeMapping.npm.npmTabs || item.params.tabIndex === npmTabIndex"
|
v-if="item.type === typeMapping.npm.npmTabs || item.params.tabIndex === npmTabIndex"
|
||||||
:id="item.id"
|
:id="item.id"
|
||||||
:chart="item"
|
:chart="item"
|
||||||
@tabChange="index => { this.npmTabIndex = index }"
|
@npmTabChange="npmTabChange"
|
||||||
></chart>
|
></chart>
|
||||||
</template>
|
</template>
|
||||||
<chart
|
<chart
|
||||||
@@ -72,6 +72,11 @@ export default {
|
|||||||
this.layout = [...n]
|
this.layout = [...n]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
npmTabChange (index) {
|
||||||
|
this.npmTabIndex = parseInt(index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="npm-tabs">
|
<div class="npm-tabs">
|
||||||
<el-tabs @tab-change="tabChange">
|
<el-tabs v-model="currentTab" ref="elTabs">
|
||||||
<el-tab-pane>
|
<el-tab-pane>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="npm-tab__label">
|
<div class="npm-tab__label">
|
||||||
@@ -32,10 +32,24 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'NpmTabs',
|
name: 'NpmTabs',
|
||||||
methods: {
|
data () {
|
||||||
tabChange (index) {
|
return {
|
||||||
this.$emit('tabChange', index)
|
currentTab: 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
currentTab (n) {
|
||||||
|
this.$emit('tabChange', n)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
// 修正字体改变导致的active-bar宽度计算偏差
|
||||||
|
setTimeout(() => {
|
||||||
|
const activeTab = document.querySelector('.npm-tabs .el-tabs__item.is-active')
|
||||||
|
const activeTabStyle = window.getComputedStyle(activeTab)
|
||||||
|
const activeBar = document.querySelector('.npm-tabs .el-tabs__active-bar')
|
||||||
|
activeBar.style.width = `${parseFloat(activeTabStyle.width) - parseFloat(activeTabStyle.paddingLeft)}px`
|
||||||
|
}, 200)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user