Improve patreon filebrowser

This commit is contained in:
2025-09-21 23:10:53 +02:00
parent 74cece07e1
commit 9be33db14f
2 changed files with 28 additions and 16 deletions

View File

@@ -24,6 +24,18 @@ class DownloadsPatreon extends Component
$this->resetPage(); $this->resetPage();
} }
public function clicked($downloadId)
{
$download = Downloads::find($downloadId);
if (!$download) {
return;
}
$download->count++;
$download->save();
cache()->forget("episode_{$download->episode->id}_download_{$download->type}");
}
public function render() public function render()
{ {
$orderby = 'created_at'; $orderby = 'created_at';

View File

@@ -67,9 +67,9 @@
<!-- Header --> <!-- Header -->
<div <div
class="flex bg-white/30 dark:bg-neutral-950/40 backdrop-blur font-medium dark:border-neutral-500 border-b rounded-tl-lg rounded-tr-lg"> class="flex bg-white/30 dark:bg-neutral-950/40 backdrop-blur font-medium dark:border-neutral-500 border-b rounded-tl-lg rounded-tr-lg">
<div class="flex-1 px-6 py-4">Title</div> <div class="flex-1 px-6 py-4 hidden sm:block">Title</div>
<div class="w-28 px-6 py-4">Size</div> <div class="w-28 px-6 py-4 hidden sm:block">Size</div>
<div class="w-32 px-6 py-4">Date</div> <div class="w-32 px-6 py-4 hidden sm:block">Date</div>
<div class="w-32 px-6 py-4">Download</div> <div class="w-32 px-6 py-4">Download</div>
</div> </div>
@@ -77,28 +77,28 @@
@foreach ($downloads as $download) @foreach ($downloads as $download)
@php @php
$title = explode('/', $download->url)[2]; $title = explode('/', $download->url)[2];
$bytes = $download->size;
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$power = $bytes > 0 ? floor(log($bytes, 1024)) : 0;
$fileSize = round($bytes / pow(1024, $power), 2) . ' ' . $units[$power];
@endphp @endphp
<div <div
class="flex items-center border-b bg-white/70 dark:bg-neutral-950/80 dark:border-zinc-700 hover:bg-white/80 dark:hover:bg-neutral-950/90"> class="flex flex-col sm:flex-row items-center border-b bg-white dark:bg-neutral-950 dark:border-zinc-700 hover:bg-zinc-100 dark:hover:bg-neutral-800">
<!-- Title --> <!-- Title -->
<div class="flex flex-1 items-center space-x-2 px-3 py-2"> <div class="flex flex-1 items-center space-x-2 px-3 py-2">
<span class="cursor-default"> {{ $title }}
{{ $title }}
</span>
</div> </div>
<!-- Size --> <!-- Size -->
<div class="w-28 whitespace-nowrap"> <div class="w-28 whitespace-nowrap flex">
{{ $fileSize }} <span class="block sm:hidden">
Size:
</span>
{{ $download->getFileSize() }}
</div> </div>
<!-- Date --> <!-- Date -->
<div class="w-32 whitespace-nowrap"> <div class="w-32 whitespace-nowrap flex">
<span class="block sm:hidden">
Date:
</span>
{{ $download->created_at->format('Y-m-d') }} {{ $download->created_at->format('Y-m-d') }}
</div> </div>
@@ -111,9 +111,9 @@
$file = \Illuminate\Support\Facades\Crypt::encryptString('hentai/'.$download->url); $file = \Illuminate\Support\Facades\Crypt::encryptString('hentai/'.$download->url);
$downloadURL = $dlpdomains[array_rand($dlpdomains)].'/download/'.$file.'/'.$expire; $downloadURL = $dlpdomains[array_rand($dlpdomains)].'/download/'.$file.'/'.$expire;
@endphp @endphp
<a href="{{ $downloadURL }}" download> <a href="{{ $downloadURL }}" wire:click="clicked({{ $download->id }})" download>
<button id="dl-{{ $download->id }}" <button id="dl-{{ $download->id }}"
class="group rounded-md bg-transparent border-[1px] border-white/20 shadow dark:text-white text-blac cursor-pointer flex justify-between items-center overflow-hidden transition-all w-[110px] h-[35px]"> class="group rounded-md bg-transparent border-[1px] border-white/20 shadow dark:text-white text-blac cursor-pointer flex justify-between items-center overflow-hidden transition-all w-[110px] h-[32px] mt-1 mb-1">
<div <div
class="relative w-12 h-[40px] bg-transparent dark:text-white text-black flex justify-center items-center transition-all"> class="relative w-12 h-[40px] bg-transparent dark:text-white text-black flex justify-center items-center transition-all">
<svg class="w-4 h-4 transition-all group-hover:-translate-y-1" <svg class="w-4 h-4 transition-all group-hover:-translate-y-1"