Skip to content

Commit cc6c8ed

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 18c5e2a + 10264b1 commit cc6c8ed

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

adminforth/spa/src/afcl/Dropzone.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,20 @@
4646

4747
<div
4848
v-else
49-
class="flex items-center justify-center py-1 flex-wrap gap-2 w-full gap-2 mt-1 mb-4 px-4"
49+
class="flex items-center justify-center py-1 flex-wrap gap-2 w-full mt-1 mb-4 px-4"
5050
>
5151
<template v-for="(file, index) in selectedFiles" :key="index">
5252
<div
5353
class="text-sm text-lightDropzoneIcon dark:text-darkDropzoneIcon bg-lightDropzoneBackgroundHover dark:bg-darkDropzoneBackgroundHover rounded-md
5454
flex items-center gap-1 px-2 py-1 group"
5555
>
5656
<IconFileSolid class="w-4 h-4 flex-shrink-0" />
57-
<span class="truncate max-w-[200px]">{{ file.name }}</span>
57+
<span
58+
class="truncate max-w-[200px]"
59+
:title="file.name"
60+
>
61+
{{ shortenFileName(file.name) }}
62+
</span>
5863
<span class="text-xs">({{ humanifySize(file.size) }})</span>
5964
<button
6065
type="button"
@@ -123,6 +128,19 @@ const selectedFiles: Ref<{
123128
124129
const storedFiles: Ref<File[]> = ref([]);
125130
131+
function shortenFileName(name: string, maxLength = 24) {
132+
if (name.length <= maxLength) return name;
133+
134+
const lastDotIndex = name.lastIndexOf('.');
135+
const hasExtension = lastDotIndex > 0 && lastDotIndex < name.length - 1;
136+
const extension = hasExtension ? name.slice(lastDotIndex + 1) : '';
137+
const baseName = hasExtension ? name.slice(0, lastDotIndex) : name;
138+
139+
const startName = baseName.slice(0, 12);
140+
const endName = baseName.split('').reverse().slice(0, 4).reverse().join('');
141+
return hasExtension ? `${startName}...${endName}.${extension}` : `${startName}...${endName}`;
142+
}
143+
126144
watch(() => props.modelValue, (files) => {
127145
if (files && files.length > 0) {
128146
selectedFiles.value = Array.from(files).map(file => ({

0 commit comments

Comments
 (0)