2021-03-03 12:25:59 +00:00
|
|
|
<template>
|
|
|
|
<div class="breadcrumbs">
|
2021-03-21 11:51:58 +00:00
|
|
|
<component
|
|
|
|
:is="element"
|
|
|
|
:to="base || ''"
|
|
|
|
:aria-label="$t('files.home')"
|
|
|
|
:title="$t('files.home')"
|
|
|
|
>
|
2021-03-03 12:25:59 +00:00
|
|
|
<i class="material-icons">home</i>
|
|
|
|
</component>
|
|
|
|
|
|
|
|
<span v-for="(link, index) in items" :key="index">
|
2024-02-10 00:13:02 +00:00
|
|
|
<span class="chevron"><i class="material-icons">keyboard_arrow_right</i></span>
|
2021-03-03 12:25:59 +00:00
|
|
|
<component :is="element" :to="link.url">{{ link.name }}</component>
|
|
|
|
</span>
|
2024-02-10 00:13:02 +00:00
|
|
|
<action style="display: contents" v-if="showShare" icon="share" show="share" />
|
2024-09-16 21:01:16 +00:00
|
|
|
<div v-if="isCardView">
|
2024-08-24 22:02:33 +00:00
|
|
|
Size:
|
|
|
|
<input
|
|
|
|
v-model="gallerySize"
|
|
|
|
type="range"
|
|
|
|
id="gallary-size"
|
|
|
|
name="gallary-size"
|
|
|
|
:value="gallerySize"
|
|
|
|
min="0"
|
|
|
|
max="10"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-03-03 12:25:59 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-08-24 22:02:33 +00:00
|
|
|
import { state, mutations, getters } from "@/store"; // Import mutations as well
|
2024-09-16 21:01:16 +00:00
|
|
|
import Action from "@/components/Action.vue";
|
2024-02-10 00:13:02 +00:00
|
|
|
|
2021-03-03 12:25:59 +00:00
|
|
|
export default {
|
2021-03-21 11:51:58 +00:00
|
|
|
name: "breadcrumbs",
|
2024-02-10 00:13:02 +00:00
|
|
|
components: {
|
|
|
|
Action,
|
|
|
|
},
|
2024-08-24 22:02:33 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
gallerySize: state.user.gallerySize,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
gallerySize(newValue) {
|
|
|
|
this.gallerySize = parseInt(newValue, 0); // Update the user object
|
|
|
|
mutations.setGallerySize(this.gallerySize);
|
|
|
|
},
|
|
|
|
},
|
2021-03-21 11:51:58 +00:00
|
|
|
props: ["base", "noLink"],
|
2021-03-03 12:25:59 +00:00
|
|
|
computed: {
|
2024-09-16 21:01:16 +00:00
|
|
|
isCardView() {
|
|
|
|
return getters.isCardView();
|
2024-08-24 22:02:33 +00:00
|
|
|
},
|
2021-03-21 11:51:58 +00:00
|
|
|
items() {
|
2024-07-30 17:45:27 +00:00
|
|
|
const relativePath = state.route.path.replace(this.base, "");
|
2021-03-21 11:51:58 +00:00
|
|
|
let parts = relativePath.split("/");
|
2021-03-03 12:25:59 +00:00
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
if (parts[0] === "") {
|
|
|
|
parts.shift();
|
2021-03-03 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
if (parts[parts.length - 1] === "") {
|
|
|
|
parts.pop();
|
2021-03-03 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
let breadcrumbs = [];
|
2021-03-03 12:25:59 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < parts.length; i++) {
|
|
|
|
if (i === 0) {
|
2021-03-21 11:51:58 +00:00
|
|
|
breadcrumbs.push({
|
|
|
|
name: decodeURIComponent(parts[i]),
|
|
|
|
url: this.base + "/" + parts[i] + "/",
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
breadcrumbs.push({
|
|
|
|
name: decodeURIComponent(parts[i]),
|
|
|
|
url: breadcrumbs[i - 1].url + parts[i] + "/",
|
|
|
|
});
|
2021-03-03 12:25:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (breadcrumbs.length > 3) {
|
|
|
|
while (breadcrumbs.length !== 4) {
|
2021-03-21 11:51:58 +00:00
|
|
|
breadcrumbs.shift();
|
2021-03-03 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
breadcrumbs[0].name = "...";
|
2021-03-03 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
return breadcrumbs;
|
2021-03-03 12:25:59 +00:00
|
|
|
},
|
2021-03-21 11:51:58 +00:00
|
|
|
element() {
|
2021-03-03 12:25:59 +00:00
|
|
|
if (this.noLink !== undefined) {
|
2021-03-21 11:51:58 +00:00
|
|
|
return "span";
|
2021-03-03 12:25:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
return "router-link";
|
|
|
|
},
|
2024-02-10 00:13:02 +00:00
|
|
|
showShare() {
|
2024-07-30 17:45:27 +00:00
|
|
|
// Ensure user properties are accessed safely
|
|
|
|
if (state.route.path.startsWith("/share")) {
|
|
|
|
return false;
|
2024-02-10 00:13:02 +00:00
|
|
|
}
|
2024-07-30 17:45:27 +00:00
|
|
|
return state.user?.perm && state.user?.perm.share; // Access from state directly
|
|
|
|
},
|
|
|
|
},
|
2024-09-16 21:01:16 +00:00
|
|
|
methods: { },
|
2021-03-21 11:51:58 +00:00
|
|
|
};
|
2021-03-03 12:25:59 +00:00
|
|
|
</script>
|