blob: 55b93db026304675df61d63e4c26b5f1ecd48231 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<template>
<div id="test-flex-col">
<div v-if="isDirectory">
<strong>Directory: {{currentItem.path}}</strong>
<div v-for="(item, index) in currentItem.properties.items" :key="item.path">
<router-link :to="item.path">Thumbnail: {{index}}-{{item.path}}</router-link>
</div>
</div>
<div v-if="isImage">Image: {{currentItem.path}}</div>
</div>
</template>
<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";
@Component
export default class Root extends Vue {
@Prop(String) readonly pathMatch!: string;
get isDirectory(): boolean {
return this.checkType("directory");
}
get isImage(): boolean {
return this.checkType("image");
}
get currentItem(): Gallery.Item | null {
const galleryItems = this.$galleryStore.galleryItems;
if (galleryItems) return this.searchCurrentItem(galleryItems, this.pathMatch);
return null;
}
// ---
private searchCurrentItem(item: Gallery.Item, currentPath: string): Gallery.Item | null {
if (currentPath === item.path) return item;
if (item.properties.type === "directory" && currentPath.startsWith(item.path)) {
const itemFound = item.properties.items
.map(item => this.searchCurrentItem(item, currentPath))
.find(item => Boolean(item));
return itemFound || null;
}
return null;
}
private checkType(type: string): boolean {
return (this.currentItem && this.currentItem.properties.type === type) || false;
}
}
</script>
<style lang="scss">
#test-flex-col {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
|