|
|
@ -1,12 +1,13 @@ |
|
|
|
<!-- 子菜单列表组件 --> |
|
|
|
<!-- 子菜单列表组件 --> |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
|
|
|
|
import type { ComponentPublicInstance, Ref } from 'vue' |
|
|
|
import { computed, inject, ref } from 'vue' |
|
|
|
import { computed, inject, ref } from 'vue' |
|
|
|
import type { Task } from './index.d' |
|
|
|
import type { Task } from './index.d' |
|
|
|
import { useTaskListStore } from '@/store/moules/taskListStore' |
|
|
|
import { useTaskListStore } from '@/store/moules/taskListStore' |
|
|
|
|
|
|
|
|
|
|
|
const taskListStore = useTaskListStore() |
|
|
|
const taskListStore = useTaskListStore() |
|
|
|
const sectionRefs = inject<Task>('sectionRefs') |
|
|
|
const sectionRefs = inject<Task<ComponentPublicInstance>>('sectionRefs') |
|
|
|
const taskContainer = inject('taskContainer') |
|
|
|
const taskContainer = inject<Ref<HTMLElement>>('taskContainer') |
|
|
|
const activeIndex = ref(0) |
|
|
|
const activeIndex = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
const list = computed(() => [ |
|
|
|
const list = computed(() => [ |
|
|
@ -35,9 +36,13 @@ const list = computed(() => [ |
|
|
|
function handleClick(index: number, task: string) { |
|
|
|
function handleClick(index: number, task: string) { |
|
|
|
activeIndex.value = index |
|
|
|
activeIndex.value = index |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sectionRefs) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const target = sectionRefs[task].value.$el.offsetTop - 40 |
|
|
|
const target = sectionRefs[task].value.$el.offsetTop - 40 |
|
|
|
|
|
|
|
|
|
|
|
taskContainer.value.scrollTo({ |
|
|
|
taskContainer?.value.scrollTo({ |
|
|
|
top: target, |
|
|
|
top: target, |
|
|
|
behavior: 'smooth', |
|
|
|
behavior: 'smooth', |
|
|
|
}) |
|
|
|
}) |
|
|
|