forked from akanyan/STARTLINER
initial commit
This commit is contained in:
60
src/components/ModStoreEntry.vue
Normal file
60
src/components/ModStoreEntry.vue
Normal file
@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import Button from 'primevue/button';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { open } from '@tauri-apps/plugin-shell';
|
||||
import ModTitlecard from './ModTitlecard.vue';
|
||||
import { ModEntry } from '../types';
|
||||
|
||||
const emit = defineEmits(['updated']);
|
||||
const props = defineProps({
|
||||
mod: Object as () => ModEntry,
|
||||
isLocal: Boolean,
|
||||
});
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
const handlePackageButton = async () => {
|
||||
isLoading.value = true;
|
||||
if (!props.isLocal) {
|
||||
await invoke('download_package', { pkg: props.mod });
|
||||
} else {
|
||||
await invoke('delete_package', {
|
||||
namespace: props.mod?.namespace,
|
||||
name: props.mod?.name,
|
||||
});
|
||||
}
|
||||
await invoke('reload_packages');
|
||||
emit('updated');
|
||||
isLoading.value = false;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ModTitlecard :mod="mod" showNamespace />
|
||||
<Button
|
||||
rounded
|
||||
:icon="isLocal ? 'pi pi-trash' : 'pi pi-plus'"
|
||||
:severity="isLocal ? 'danger' : 'success'"
|
||||
aria-label="install"
|
||||
size="small"
|
||||
class="self-center"
|
||||
style="width: 2rem; height: 2rem"
|
||||
:loading="isLoading"
|
||||
v-on:click="handlePackageButton()"
|
||||
/>
|
||||
<Button
|
||||
rounded
|
||||
icon="pi pi-external-link"
|
||||
severity="info"
|
||||
aria-label="storepage"
|
||||
size="small"
|
||||
class="self-center ml-2"
|
||||
style="width: 2rem; height: 2rem"
|
||||
v-on:click="open(mod?.package_url ?? '')"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
@import 'primeicons/primeicons.css';
|
||||
</style>
|
Reference in New Issue
Block a user