feat: add package creator

This commit is contained in:
2025-04-28 16:44:04 +00:00
parent c59dbcc35c
commit f478ad9216
11 changed files with 302 additions and 50 deletions

View File

@ -1,7 +1,8 @@
<script setup lang="ts">
import { computed } from 'vue';
import { ref } from 'vue';
import Chip from 'primevue/chip';
import { convertFileSrc } from '@tauri-apps/api/core';
import { invoke } from '../invoke';
import { Feature, Package } from '../types';
import { hasFeature, needsUpdate } from '../util';
@ -14,23 +15,30 @@ const props = defineProps({
showIcon: Boolean,
});
const iconSrc = computed(() => {
const icon = props.pkg?.loc?.icon ?? props.pkg?.rmt?.icon;
const icon = ref('/no-icon.png');
if (icon === undefined) {
return '';
} else if (icon.startsWith('https://')) {
return icon;
(async () => {
const src = props.pkg?.loc?.icon ?? props.pkg?.rmt?.icon;
if (src === undefined) {
icon.value = '/no-icon.png';
} else if (src.startsWith('https://')) {
icon.value = src;
} else {
return convertFileSrc(icon);
const convt = convertFileSrc(src);
if (await invoke('file_exists', { path: src })) {
icon.value = convt;
} else {
icon.value = '/no-icon.png';
}
}
});
})();
</script>
<template>
<img
v-if="showIcon"
:src="iconSrc"
:src="icon"
class="self-center rounded-sm"
width="32px"
height="32px"