|
|
@ -1,18 +1,18 @@ |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<a-card title="目录列表" hoverable :bordered="false"> |
|
|
|
<div class="catalogue" v-for="anchor in titles" :style="{ padding: `4px 0 4px ${anchor.indent * 20}px` }" |
|
|
|
@click="handleAnchorClick(anchor)" :key="anchor.lineIndex"> |
|
|
|
<a style="cursor: pointer">{{ anchor.title }}</a> |
|
|
|
</div> |
|
|
|
@click="handleAnchorClick(anchor)" @mouseover="handleMouseOver" @mouseleave="handleMouseLeave" |
|
|
|
:key="anchor.lineIndex"> |
|
|
|
<a class="link">{{ anchor.title }}</a> |
|
|
|
</div> |
|
|
|
</a-card> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import { computed } from 'vue'; |
|
|
|
import { computed,ref } from 'vue'; |
|
|
|
import { useContentStore } from '@/stores/index'; |
|
|
|
|
|
|
|
const store = useContentStore(); |
|
|
|
|
|
|
|
const titles = computed(() => store.titles); |
|
|
|
|
|
|
|
const handleAnchorClick = (anchor: { title: string; lineIndex: string }) => { |
|
|
@ -32,11 +32,23 @@ |
|
|
|
observer.observe(container, { childList: true, subtree: true }); |
|
|
|
} |
|
|
|
}; |
|
|
|
const handleMouseOver = (event: any) => { |
|
|
|
const target = event.currentTarget as HTMLElement; |
|
|
|
target.style.backgroundColor = '#f0f0f0'; |
|
|
|
target.style.color = '#bd5b5b'; |
|
|
|
} |
|
|
|
|
|
|
|
const handleMouseLeave = (event: any) => { |
|
|
|
const target = event.currentTarget as HTMLElement; |
|
|
|
target.style.backgroundColor = '' |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
.catalogue { |
|
|
|
|
|
|
|
.link{ |
|
|
|
cursor: pointer; |
|
|
|
color: rgb(115, 78, 34); |
|
|
|
/* background-color: #bd5b5b; */ |
|
|
|
} |
|
|
|
</style> |
|
|
|
|