downloader progress added to cover

This commit is contained in:
zurdi zurdo
2023-04-25 19:07:33 +02:00
parent 0f18c744cb
commit af3775413d
4 changed files with 18 additions and 3 deletions

View File

@@ -1,16 +1,17 @@
<script setup>
import ActionBar from '@/components/GameGallery/Card/ActionBar.vue'
import Cover from '@/components/GameGallery/Card/Cover.vue'
import { storeDownloader } from '@/stores/downloader.js'
// Props
const props = defineProps(['rom'])
const downloader = storeDownloader()
</script>
<template>
<v-hover v-slot="{isHovering, props}">
<!-- loader for v-card when downloading -->
<!-- loading="rommAccent1" -->
<v-card
:loading="downloader.value.includes(rom.file_name) ? 'rommAccent1': null"
v-bind="props"
:class="{'on-hover': isHovering}"
:elevation="isHovering ? 20 : 3">

View File

@@ -1,8 +1,11 @@
import JSZip from "jszip"
import { saveAs } from 'file-saver'
import { storeDownloader } from '@/stores/downloader.js'
const downloader = storeDownloader()
export async function downloadRom(rom, emitter, filesToDownload=[]) {
downloader.add(rom.file_name)
emitter.emit('snackbarScan', {'msg': "Downloading "+rom.file_name+"...", 'icon': 'mdi-download', 'color': 'green'})
if(rom.multi){
const zip = new JSZip()
@@ -27,6 +30,7 @@ export async function downloadRom(rom, emitter, filesToDownload=[]) {
var fileBlob = await file.blob()
saveAs(fileBlob, rom.file_name)
}
downloader.remove(rom.file_name)
}
export async function downloadSave(rom) { console.log("Downloading "+rom.file_name+" save file") }

View File

@@ -0,0 +1,10 @@
import { defineStore } from 'pinia'
export const storeDownloader = defineStore('downloader', {
state: () => ({ value: [] }),
actions: {
add(rom) { this.value.push(rom) },
remove(rom) { this.value.splice(this.value.indexOf(rom), 1) }
}
})

View File

@@ -1,6 +1,6 @@
<script setup>
import { ref } from 'vue'
import { storePlatforms } from '@/stores/platforms'
import { storePlatforms } from '@/stores/platforms.js'
import AppBar from '@/components/AppBar/Base.vue'
import { useDisplay } from "vuetify"