update 更换树滚动条

This commit is contained in:
2021-05-26 18:09:25 +08:00
parent 249007c237
commit a8ecb30cab
2 changed files with 41 additions and 85 deletions

View File

@@ -27,28 +27,6 @@
} }
} }
} }
.swiper-container {
position: absolute;
top: @layout-header-height;
left: 0;
bottom: 0;
width: 100%;
.swiper-slide {
height: auto;
min-height: 100%;
}
.swiper-scrollbar {
transition: @animation-duration-slow opacity;
opacity: 0;
}
&:hover {
.swiper-scrollbar {
opacity: 1;
}
}
}
} }
&--bar { &--bar {
line-height: 20px; line-height: 20px;
@@ -66,4 +44,29 @@
} }
} }
} }
&--content {
position: absolute;
top: @layout-header-height;
left: 0;
bottom: 0;
overflow-y: auto;
width: 100%;
&::-webkit-scrollbar {
width: 5px;
height: 5px;
background-color: @white;
}
&::-webkit-scrollbar-thumb {
background-color: transparent;
}
&:hover::-webkit-scrollbar-thumb {
background-color: fade(@black, 30%);
}
&::-webkit-scrollbar-thumb:active {
background-color: fade(@black, 45%);
}
}
} }

View File

@@ -1,6 +1,4 @@
import Swiper from 'swiper' let timer
let timer, swiper
export default { export default {
props: { props: {
@@ -45,28 +43,6 @@ export default {
this.onLoadData() this.onLoadData()
}, },
mounted() {
const container = this.$refs.swiper,
scrollBar = container.querySelector('.swiper-scrollbar')
const swiperOptions = {
direction: 'vertical',
slidesPerView: 'auto',
freeMode: true,
scrollbar: {
el: scrollBar,
},
mousewheel: true,
}
swiper = new Swiper(container, swiperOptions)
window.addEventListener('resize', () => {
this.onUpdateSwiper()
})
},
methods: { methods: {
renderBreadcrumbItem() { renderBreadcrumbItem() {
@@ -114,10 +90,6 @@ export default {
this.expandedKeys = this.list.map(p => p.key) this.expandedKeys = this.list.map(p => p.key)
} }
this.data = data this.data = data
this.$nextTick(() => {
this.onUpdateSwiper()
})
}).finally(() => { }).finally(() => {
this.loading = false this.loading = false
}) })
@@ -130,7 +102,6 @@ export default {
onExpand(expandedKeys) { onExpand(expandedKeys) {
this.expandedKeys = expandedKeys this.expandedKeys = expandedKeys
this.autoExpandParent = false this.autoExpandParent = false
this.onUpdateSwiper()
}, },
onUnexpandAll() { onUnexpandAll() {
@@ -150,11 +121,6 @@ export default {
this.searchValue = value this.searchValue = value
this.expandedKeys = expandedKeys this.expandedKeys = expandedKeys
this.autoExpandParent = true this.autoExpandParent = true
this.$nextTick(() => {
this.onUpdateSwiper()
})
}, },
onSelect(selectedKeys) { onSelect(selectedKeys) {
@@ -167,14 +133,6 @@ export default {
this.$emit('select', selectedIds) this.$emit('select', selectedIds)
}, },
onUpdateSwiper() {
clearTimeout(timer)
timer = setTimeout(() => {
swiper.update()
swiper.update()
}, 300)
},
generateKey(data, level) { generateKey(data, level) {
const n = level || [0] const n = level || [0]
n.push(0) n.push(0)
@@ -267,26 +225,21 @@ export default {
<a-icon type="switcher" onClick={this.onUnexpandAll} /> <a-icon type="switcher" onClick={this.onUnexpandAll} />
</a-tooltip> </a-tooltip>
</div> </div>
<div class="swiper-container" ref="swiper"> <div class="yo-tree-layout--content">
<div class="swiper-wrapper"> <a-spin style={{ height: '100%' }} spinning={this.loading}>
<div class="swiper-slide"> <a-icon slot="indicator" type="loading" spin />
<a-spin style={{ height: '100%' }} spinning={this.loading}> {
<a-icon slot="indicator" type="loading" spin /> !this.loading && !this.list.length ?
{ <a-empty description={false} class="ant-list-empty-text">
!this.loading && !this.list.length ? <template slot="image">
<a-empty description={false} class="ant-list-empty-text"> <a-icon class="h3 mt-xl mb-md" type="smile" />
<template slot="image"> <p>暂无数据</p>
<a-icon class="h3 mt-xl mb-md" type="smile" /> </template>
<p>暂无数据</p> </a-empty>
</template> :
</a-empty> <a-tree {...{ props, on, scopedSlots }} />
: }
<a-tree {...{ props, on, scopedSlots }} /> </a-spin>
}
</a-spin>
</div>
</div>
<div class="swiper-scrollbar" />
</div> </div>
</a-layout-sider> </a-layout-sider>
<a-layout-content> <a-layout-content>