From cb1f842fc970cad1aacdcd6cbb272d23ffc68b53 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Tue, 7 Jan 2025 16:54:08 +0100 Subject: [PATCH] fix #69 --- public/site/plugins/helpers/index.php | 5 +- .../project/virtual-sample/Interactive360.vue | 13 +++++ .../project/virtual-sample/VirtualSample.vue | 47 ++++++++++++++----- src/stores/virtualSample.js | 2 + 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/public/site/plugins/helpers/index.php b/public/site/plugins/helpers/index.php index 616dbc2..d460123 100644 --- a/public/site/plugins/helpers/index.php +++ b/public/site/plugins/helpers/index.php @@ -8,6 +8,7 @@ function getFileData($file) { 'quality' => 80, 'format' => 'webp' ])->url(), + 'source' => $file->url(), 'parent' => [ "title" => (string) $file->parent()->title(), "uri" => $file->parent()->uri() @@ -28,10 +29,10 @@ function getFileData($file) { $data['tags'] = $file->tags()->split(); }; - if($file->comments()->exists()) { + if ($file->comments()->exists()) { $data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : []; $data['cover'] = $file->cover()->exists() && $file->cover()->isNotEmpty() ? $file->cover()->toFile()->resize(576)->url() : false; - } + } return $data; } \ No newline at end of file diff --git a/src/components/project/virtual-sample/Interactive360.vue b/src/components/project/virtual-sample/Interactive360.vue index fd74ada..a590c92 100644 --- a/src/components/project/virtual-sample/Interactive360.vue +++ b/src/components/project/virtual-sample/Interactive360.vue @@ -43,6 +43,7 @@ const { activeTrack } = defineProps({ // Helper const { openedFile } = storeToRefs(useDialogStore()); const virtualSampleStore = useVirtualSampleStore(); +const { isDownloadTriggered } = storeToRefs(useVirtualSampleStore()); const isHelperHidden = ref(localStorage.getItem("isHelperHidden")); localStorage.setItem("isHelperHidden", true); @@ -187,4 +188,16 @@ function preloadImages() { image.src = imageUrl; }); } + +// Download image +watch(isDownloadTriggered, (newValue) => { + if (!newValue) return; + + const downloadNode = document.createElement("a"); + downloadNode.setAttribute("href", currentFile.value.source); + downloadNode.setAttribute("download", ""); + document.body.appendChild(downloadNode); + downloadNode.click(); + document.body.removeChild(downloadNode); +}); diff --git a/src/components/project/virtual-sample/VirtualSample.vue b/src/components/project/virtual-sample/VirtualSample.vue index 7a01def..6deeefd 100644 --- a/src/components/project/virtual-sample/VirtualSample.vue +++ b/src/components/project/virtual-sample/VirtualSample.vue @@ -44,18 +44,15 @@