workin
This commit is contained in:
parent
e1192ee506
commit
10ef24ffe0
@ -25,11 +25,16 @@ interface Media {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['select-media']);
|
||||||
const folders = ref<Folder[]>([]);
|
const folders = ref<Folder[]>([]);
|
||||||
|
|
||||||
|
const selectMedia = (media: Media) => {
|
||||||
|
emit('select-media', media);
|
||||||
|
};
|
||||||
const media = ref<Media[]>([]);
|
const media = ref<Media[]>([]);
|
||||||
const selectedFolder = ref<string | null>(null);
|
const selectedFolder = ref<string | null>(null);
|
||||||
const currentPage = ref(1);
|
const currentPage = ref(1);
|
||||||
const totalPages = ref(1);
|
const totalMedia = ref(0);
|
||||||
|
|
||||||
const loadFolders = async () => {
|
const loadFolders = async () => {
|
||||||
try {
|
try {
|
||||||
@ -48,7 +53,7 @@ const loadMedia = async (folderId: string, page: number = 1) => {
|
|||||||
const response: any = await fetchMediaByFolder(folderId, page);
|
const response: any = await fetchMediaByFolder(folderId, page);
|
||||||
media.value = response.data;
|
media.value = response.data;
|
||||||
currentPage.value = response.currentPage;
|
currentPage.value = response.currentPage;
|
||||||
totalPages.value = response.lastPage;
|
totalMedia.value = response.count;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to fetch media for folder ${folderId}`, error);
|
console.error(`Failed to fetch media for folder ${folderId}`, error);
|
||||||
}
|
}
|
||||||
@ -75,7 +80,7 @@ onMounted(() => {
|
|||||||
<h1 class="text-2xl font-bold mb-4">Media Browser</h1>
|
<h1 class="text-2xl font-bold mb-4">Media Browser</h1>
|
||||||
<ResizablePanelGroup direction="horizontal" class="flex-grow rounded-lg border">
|
<ResizablePanelGroup direction="horizontal" class="flex-grow rounded-lg border">
|
||||||
<ResizablePanel :default-size="25">
|
<ResizablePanel :default-size="25">
|
||||||
<div class="flex h-full items-start justify-center p-6">
|
<div class="h-full overflow-y-auto p-6">
|
||||||
<FolderTree :folders="folders" :selected-folder-id="selectedFolder" @select-folder="selectFolder" />
|
<FolderTree :folders="folders" :selected-folder-id="selectedFolder" @select-folder="selectFolder" />
|
||||||
</div>
|
</div>
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
@ -83,12 +88,12 @@ onMounted(() => {
|
|||||||
<ResizablePanel :default-size="75">
|
<ResizablePanel :default-size="75">
|
||||||
<div class="flex flex-col h-full p-6">
|
<div class="flex flex-col h-full p-6">
|
||||||
<div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4 flex-grow">
|
<div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4 flex-grow">
|
||||||
<div v-for="item in media" :key="item.uuid" class="aspect-square bg-gray-100 rounded-lg overflow-hidden">
|
<div v-for="item in media" :key="item.uuid" class="aspect-square bg-gray-100 rounded-lg overflow-hidden cursor-pointer" @click="selectMedia(item)">
|
||||||
<img :src="item.url" :alt="item.name" class="w-full h-full object-cover" />
|
<img :src="item.url" :alt="item.name" class="w-full h-full object-cover" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4 flex justify-center">
|
<div class="mt-4 flex justify-center">
|
||||||
<Pagination v-if="totalPages > 1" :total="totalPages" :sibling-count="1" show-edges :default-page="currentPage" @update:page="onPageChange">
|
<Pagination v-if="totalMedia > 12" :items-per-page="12" :total="totalMedia" :sibling-count="1" show-edges :default-page="currentPage" @update:page="onPageChange">
|
||||||
<PaginationContent v-slot="{ items }" class="flex items-center gap-1">
|
<PaginationContent v-slot="{ items }" class="flex items-center gap-1">
|
||||||
<PaginationPrevious />
|
<PaginationPrevious />
|
||||||
<template v-for="(page, index) in items">
|
<template v-for="(page, index) in items">
|
||||||
|
|||||||
@ -23,7 +23,14 @@ interface Folder {
|
|||||||
uuid: string
|
uuid: string
|
||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
|
const dialogOpen = ref(false);
|
||||||
const uploadProgress = ref(0);
|
const uploadProgress = ref(0);
|
||||||
|
|
||||||
|
const handleMediaSelect = (media: any) => {
|
||||||
|
theModel.value.default = media.uuid;
|
||||||
|
theModel.value.url = media.url;
|
||||||
|
dialogOpen.value = false;
|
||||||
|
};
|
||||||
const isDragging = ref(false);
|
const isDragging = ref(false);
|
||||||
const directories = ref<Folder[]>([]);
|
const directories = ref<Folder[]>([]);
|
||||||
const selectedDirectory = ref<string>('');
|
const selectedDirectory = ref<string>('');
|
||||||
@ -89,12 +96,12 @@ const handleFile = async (file: File) => {
|
|||||||
<div>
|
<div>
|
||||||
<label>{{ $t('id') }}</label>
|
<label>{{ $t('id') }}</label>
|
||||||
<Input v-model="theModel!.id" />
|
<Input v-model="theModel!.id" />
|
||||||
<Dialog>
|
<Dialog v-model:open="dialogOpen">
|
||||||
<DialogTrigger as-child>
|
<DialogTrigger as-child>
|
||||||
<Button class="my-2 w-full">Mediabrowser</Button>
|
<Button class="my-2 w-full">Mediabrowser</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent class="sm:max-w-5xl max-h-[80vh] overflow-y-auto">
|
<DialogContent class="sm:max-w-5xl max-h-[80vh] overflow-y-auto">
|
||||||
<MediaBrowser />
|
<MediaBrowser @select-media="handleMediaSelect" />
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export default defineConfig({
|
|||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
configure: (proxy) => {
|
configure: (proxy) => {
|
||||||
proxy.on('proxyReq', (proxyReq) => {
|
proxy.on('proxyReq', (proxyReq) => {
|
||||||
proxyReq.setHeader('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTM5NTU4MzMsImV4cCI6MTc1Mzk1OTQzMywicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU0hPUF9PUEVSQVRPUiIsIlJPTEVfVVNFUiIsIlJPTEVfV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Y4heS7uDOAsTuY1KhhiusCPp9zXhCne3HoygK5EQPQ72u9LkMghpuGjStBVAPECaxoxufSfoKYAmBl7D3bcowZ8rfx2fKRwWl0vDWO7Vj9uu2cf3HrRzNl4zrbJMk0xtrQjPs5zF5j1AFSnd2OpYU7j3od5GPZqmQPZofd-vhbO85eMyDpaucJ7UMsef8G1Gq0TO6CBh1Hg7hqCXVX_nDKhhNz4Hi26DqK6GjX8a4AkJFeyfCxictYsAvIQsEmhL8oP52WcXdRV3Tqr2RwaSw');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user