mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 17:10:07 +00:00
54 lines
1.3 KiB
Vue
54 lines
1.3 KiB
Vue
<template>
|
|
<IconTextButton
|
|
v-bind="$attrs"
|
|
type="transparent"
|
|
:label="
|
|
nodePacks.length > 1
|
|
? $t('manager.uninstallSelected')
|
|
: $t('manager.uninstall')
|
|
"
|
|
:border="true"
|
|
:size="size"
|
|
class="border-red-500"
|
|
@click="uninstallItems"
|
|
/>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import IconTextButton from '@/components/button/IconTextButton.vue'
|
|
import { useComfyManagerStore } from '@/stores/comfyManagerStore'
|
|
import { ButtonSize } from '@/types/buttonTypes'
|
|
import type { components } from '@/types/comfyRegistryTypes'
|
|
import { components as ManagerComponents } from '@/types/generatedManagerTypes'
|
|
|
|
type NodePack = components['schemas']['Node']
|
|
|
|
const { nodePacks, size } = defineProps<{
|
|
nodePacks: NodePack[]
|
|
size?: ButtonSize
|
|
}>()
|
|
|
|
const managerStore = useComfyManagerStore()
|
|
|
|
const createPayload = (
|
|
uninstallItem: NodePack
|
|
): ManagerComponents['schemas']['ManagerPackInfo'] => {
|
|
if (!uninstallItem.id) {
|
|
throw new Error('Node ID is required for uninstallation')
|
|
}
|
|
|
|
return {
|
|
id: uninstallItem.id,
|
|
version: uninstallItem.latest_version?.version || 'unknown'
|
|
}
|
|
}
|
|
|
|
const uninstallPack = (item: NodePack) =>
|
|
managerStore.uninstallPack(createPayload(item))
|
|
|
|
const uninstallItems = async () => {
|
|
if (!nodePacks?.length) return
|
|
await Promise.all(nodePacks.map(uninstallPack))
|
|
}
|
|
</script>
|