-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBreadCrumbs.vue
41 lines (40 loc) · 1.02 KB
/
BreadCrumbs.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<template>
<div v-if="breadcrumbs.length > 1" class="breadcrumbs flex overflow-x-scroll whitespace-nowrap">
<span
v-for="(breadcrumb, index) in breadcrumbs"
:key="index"
class="my-1"
:class="{active: breadcrumb.active }"
@click="$store.dispatch('app/selectFolder', { path: breadcrumb.link })"
>
{{ breadcrumb.name }}
</span>
</div>
</template>
<script>
export default {
name: 'BreadCrumbs',
computed: {
breadcrumbs () {
const breadcrumbs = [{
name: 'Home',
link: '/',
active: false
}]
if (this.$route.query.folder) {
if (this.$route.query.folder !== '/') {
const segments = this.$route.query.folder.split('/')
for (let i = 0; i < segments.length; i++) {
breadcrumbs.push({
name: segments[i],
link: segments.slice(0, i + 1).join('/'),
active: (i === segments.length - 1)
})
}
}
}
return breadcrumbs
}
}
}
</script>