feat: add package creator
This commit is contained in:
@ -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"
|
||||
|
Reference in New Issue
Block a user