feat: 为文件夹插件导航栏添加滚动条以及鼠标滚轮相关事件处理

This commit is contained in:
539943419 committed 2024-12-25 22:42:12 +08:00
1 parent 8ef243f790
commit d19cce76d2
3 files changed
+152 -98

No files matched your search

@@ -8,9 +8,16 @@
class="container-top-colorfulBar"
:style="{ backgroundColor: props.color }"></div>
<div class="container-top-breadcrumb">
<div class="container-top-breadcrumb-container">
<!-- <n-scrollbar x-scrollable> -->
<n-breadcrumb separator=">" style="margin-left: 5px">
<n-scrollbar
ref="scrollbarRef"
:x-scrollable="true"
class="container-top-breadcrumb-scroll"
@wheel="handleWheel">
<div class="container-top-breadcrumb-container">
<n-breadcrumb
separator=">"
class="sb-nn"
style="margin-left: 5px">
<n-breadcrumb-item :clickable="false">
<n-icon size="18">
<CloudOutline />
@@ -23,8 +30,8 @@
<div>{{ dir.name }}</div>
</n-breadcrumb-item>
</n-breadcrumb>
<!-- </n-scrollbar> -->
</div>
</div>
</n-scrollbar>
</div>
<div class="container-top-tools">
<n-icon
@@ -52,7 +59,13 @@
</template>
<script setup lang="ts">
import { NBreadcrumbItem, NBreadcrumb, NIcon, NDropdown, NScrollbar } from 'naive-ui'
import {
NBreadcrumbItem,
NBreadcrumb,
NIcon,
NDropdown,
NScrollbar
} from 'naive-ui'
import {
CloudOutline,
ChevronBackOutline,
@@ -60,6 +73,7 @@ import {
EllipsisVertical
} from '@vicons/ionicons5'
import VirtualDirectory from '@/class/VirtualDirectory'
import { ref } from 'vue'
const props = defineProps<{
color: string
@@ -79,9 +93,28 @@ const emit = defineEmits<{
'set-current-directory': [virtualDirectory: VirtualDirectory]
}>()
const scrollbarRef = ref<InstanceType<typeof NScrollbar>>()
const handleClickBreadcrumbItem = (virtualDirectory: VirtualDirectory) => {
emit('set-current-directory', virtualDirectory)
}
const handleWheel = (event: WheelEvent) => {
event.preventDefault()
event.stopPropagation()
if (scrollbarRef.value) {
scrollbarRef.value.scrollBy({
left: event.deltaY,
behavior: "smooth"
})
}
}
defineExpose({
// @ts-ignore
scrollTo: (...args: any[]) => scrollbarRef.value?.scrollTo(...args)
// getRef: () => scrollbarRef.value
})
</script>
<style scoped lang="scss">
@@ -117,14 +150,15 @@ const handleClickBreadcrumbItem = (virtualDirectory: VirtualDirectory) => {
border-radius: 0 3px 3px 0;
.container-top-breadcrumb-container {
position: absolute;
height: 100%;
right: 0;
top: 0;
// position: absolute;
height: 21px;
// right: 0;
// top: 0;
min-width: 100%;
display: flex;
justify-content: flex-start;
align-items: center;
overflow: hidden;
}
}
@@ -164,3 +198,11 @@ const handleClickBreadcrumbItem = (virtualDirectory: VirtualDirectory) => {
}
}
</style>
<style lang="scss">
.container-top-breadcrumb-scroll {
.n-scrollbar-rail {
transform: translateY(5px);
}
}
</style>
@@ -7,6 +7,7 @@
<div class="miao-directory-item-container" ref="rootDomRef">
<!-- 顶部面包屑导航和工具栏 -->
<miao-directory-top
ref="miaoDirectoryTopRef"
:color="props.color"
:current-directory="currentDirectory"
@back="handleBack"
@@ -101,6 +102,7 @@ const searchText = ref<string>('')
const showDirs = ref<boolean>(true)
const showFiles = ref<boolean>(true)
const miaoDirectoryItemRef = ref()
const miaoDirectoryTopRef = ref<InstanceType<typeof miaoDirectoryTop>>()
const miaoAlertTip = ref<InstanceType<typeof miaoAlertTipProvider>>()
class SelectedItem {
@@ -297,6 +299,16 @@ const setCurrentDirectory = async (virtualDirectory: VirtualDirectory) => {
top: 0,
behavior: 'instant'
})
// miaoDirectoryTopRef.value &&
// miaoDirectoryTopRef.value.scrollTo({
// top: 0,
// behavior: 'instant'
// })
miaoDirectoryTopRef.value?.scrollTo({
top: 0,
left: 999,
behavior: 'instant'
})
})
}
currentDirectories.value[0] = virtualDirectory
+88 -88
View File
@@ -2,91 +2,91 @@
background-color: aliceblue;
}
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
vertical-align: baseline;
box-sizing: border-box;
}
// html,
// body,
// div,
// span,
// applet,
// object,
// iframe,
// h1,
// h2,
// h3,
// h4,
// h5,
// h6,
// p,
// blockquote,
// pre,
// a,
// abbr,
// acronym,
// address,
// big,
// cite,
// code,
// del,
// dfn,
// em,
// img,
// ins,
// kbd,
// q,
// s,
// samp,
// small,
// strike,
// strong,
// sub,
// sup,
// tt,
// var,
// b,
// u,
// i,
// center,
// dl,
// dt,
// dd,
// ol,
// ul,
// li,
// fieldset,
// form,
// label,
// legend,
// table,
// caption,
// tbody,
// tfoot,
// thead,
// tr,
// th,
// td,
// article,
// aside,
// canvas,
// details,
// embed,
// figure,
// figcaption,
// footer,
// header,
// hgroup,
// menu,
// nav,
// output,
// ruby,
// section,
// summary,
// time,
// mark,
// audio,
// video {
// margin: 0;
// padding: 0;
// border: 0;
// font-size: 100%;
// vertical-align: baseline;
// box-sizing: border-box;
// }