perf(theme): 优化 sidebar 数据解析
This commit is contained in:
parent
8e9ed082c9
commit
ba721e72f9
@ -52,7 +52,11 @@ watch(
|
||||
Sidebar Navigation
|
||||
</span>
|
||||
|
||||
<div v-for="item in sidebarGroups" :key="item.text" class="group">
|
||||
<div
|
||||
v-for="item in sidebarGroups"
|
||||
:key="item.text"
|
||||
class="group"
|
||||
>
|
||||
<SidebarItem :item="item" :depth="0" />
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@ -21,7 +21,7 @@ function setStyle(item: Element) {
|
||||
|
||||
if (!_transition) {
|
||||
const value = typeof window !== 'undefined' && window.getComputedStyle ? window.getComputedStyle(el).transition : ''
|
||||
_transition = value && !value.includes('all') ? `${value}, ` : ''
|
||||
_transition = value && !value.includes('all') ? `${value}, ` : ' '
|
||||
}
|
||||
|
||||
el.style.transition = `${_transition}transform ${props.duration}s ease-in-out ${props.delay}s, opacity ${props.duration}s ease-in-out ${props.delay}s`
|
||||
|
||||
@ -23,7 +23,26 @@ export function getSidebarList(path: string, notesData: NotesData) {
|
||||
const link = Object.keys(notesData).find(link =>
|
||||
path.startsWith(normalizePath(link)),
|
||||
)
|
||||
return link ? notesData[link] : []
|
||||
const sidebar = link ? notesData[link] : []
|
||||
|
||||
const groups: NotesSidebarItem[] = []
|
||||
|
||||
let lastGroupIndex: number = 0
|
||||
|
||||
for (const index in sidebar) {
|
||||
const item = sidebar[index]
|
||||
|
||||
if (item.items && item.items.length) {
|
||||
lastGroupIndex = groups.push(item)
|
||||
continue
|
||||
}
|
||||
|
||||
if (!groups[lastGroupIndex])
|
||||
groups.push({ items: [] })
|
||||
|
||||
groups[lastGroupIndex]!.items!.push(item)
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
export function getSidebarFirstLink(sidebar: NotesSidebarItem[]) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user