feat: add explorer sidebar, account menu and preview preferences
This commit is contained in:
1 parent
b87f8cb961
commit
fa1832dfa7
22 files changed
+929
-226
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<svg
|
||||
class="dicom-file-icon"
|
||||
viewBox="0 0 48 56"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
d="M8 2h21l13 13v37a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2Z"
|
||||
fill="currentColor"
|
||||
fill-opacity=".12"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<path
|
||||
d="M28 2v14h14"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
<text
|
||||
x="24"
|
||||
y="37"
|
||||
text-anchor="middle"
|
||||
fill="currentColor"
|
||||
font-family="system-ui, sans-serif"
|
||||
font-weight="700"
|
||||
font-size="10"
|
||||
>
|
||||
.dcm
|
||||
</text>
|
||||
</svg>
|
||||
</template>
|
||||
@@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<div
|
||||
class="item"
|
||||
ref="itemElement"
|
||||
:class="{ 'has-thumbnail': showThumbnail }"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:draggable="isDraggable"
|
||||
@@ -22,11 +24,14 @@
|
||||
:data-ext="getExtension(name).toLowerCase()"
|
||||
@contextmenu="contextMenu"
|
||||
>
|
||||
<div>
|
||||
<div class="file-symbol">
|
||||
<DicomIcon v-if="isDicom" />
|
||||
<img
|
||||
v-if="!readOnly && type === 'image' && isThumbsEnabled"
|
||||
v-lazy="thumbnailUrl"
|
||||
:alt="name"
|
||||
v-else-if="showThumbnail && thumbnailVisible && !thumbnailFailed"
|
||||
:src="thumbnailUrl"
|
||||
alt=""
|
||||
decoding="async"
|
||||
@error="thumbnailFailed = true"
|
||||
/>
|
||||
<i v-else class="material-icons"></i>
|
||||
</div>
|
||||
@@ -54,7 +59,8 @@ import { filesize } from "@/utils";
|
||||
import dayjs from "dayjs";
|
||||
import { files as api } from "@/api";
|
||||
import * as upload from "@/utils/upload";
|
||||
import { computed, inject, ref } from "vue";
|
||||
import { computed, inject, ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||
import DicomIcon from "./DicomIcon.vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
const touches = ref<number>(0);
|
||||
@@ -116,7 +122,52 @@ const thumbnailUrl = computed(() => {
|
||||
});
|
||||
|
||||
const isThumbsEnabled = computed(() => {
|
||||
return enableThumbs;
|
||||
return enableThumbs && !authStore.user?.hidePreviews;
|
||||
});
|
||||
const isDicom = computed(() => /\.(dcm|dicom)$/i.test(props.name));
|
||||
const showThumbnail = computed(
|
||||
() =>
|
||||
!props.readOnly &&
|
||||
!props.isDir &&
|
||||
props.type === "image" &&
|
||||
!isDicom.value &&
|
||||
isThumbsEnabled.value
|
||||
);
|
||||
const thumbnailFailed = ref(false),
|
||||
thumbnailVisible = ref(false);
|
||||
const itemElement = ref<HTMLElement>();
|
||||
let thumbnailObserver: IntersectionObserver | undefined;
|
||||
function observeThumbnail() {
|
||||
thumbnailObserver?.disconnect();
|
||||
if (!showThumbnail.value || !itemElement.value) return;
|
||||
if (typeof IntersectionObserver === "undefined") {
|
||||
thumbnailVisible.value = true;
|
||||
return;
|
||||
}
|
||||
thumbnailObserver = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (entries.some((entry) => entry.isIntersecting)) {
|
||||
thumbnailVisible.value = true;
|
||||
thumbnailObserver?.disconnect();
|
||||
}
|
||||
},
|
||||
{ rootMargin: "150px" }
|
||||
);
|
||||
thumbnailObserver.observe(itemElement.value);
|
||||
}
|
||||
watch(
|
||||
[thumbnailUrl, showThumbnail],
|
||||
() => {
|
||||
thumbnailFailed.value = false;
|
||||
thumbnailVisible.value = false;
|
||||
observeThumbnail();
|
||||
},
|
||||
{ flush: "post" }
|
||||
);
|
||||
onMounted(observeThumbnail);
|
||||
onBeforeUnmount(() => {
|
||||
thumbnailObserver?.disconnect();
|
||||
cancelLongPress();
|
||||
});
|
||||
|
||||
const humanSize = () => {
|
||||
|
||||
Reference in new issue
Block a user