|
|
@ -22,10 +22,16 @@ const props = defineProps<{ |
|
|
|
|
|
|
|
|
const emit = defineEmits<{ |
|
|
const emit = defineEmits<{ |
|
|
'update:visible': [v: boolean] |
|
|
'update:visible': [v: boolean] |
|
|
|
|
|
'favorite-toggled': [cardId: number, favorited: boolean] |
|
|
}>() |
|
|
}>() |
|
|
|
|
|
|
|
|
const { isFavorited, toggle, loadingIds } = useFavorite() |
|
|
const { isFavorited, toggle, loadingIds } = useFavorite() |
|
|
|
|
|
|
|
|
|
|
|
async function handleToggle(cardId: number) { |
|
|
|
|
|
const result = await toggle(cardId) |
|
|
|
|
|
emit('favorite-toggled', cardId, result) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const categoryName = computed(() => { |
|
|
const categoryName = computed(() => { |
|
|
if (!props.card?.categoryId) return null |
|
|
if (!props.card?.categoryId) return null |
|
|
function find(nodes: CategoryNode[]): string | null { |
|
|
function find(nodes: CategoryNode[]): string | null { |
|
|
@ -126,7 +132,7 @@ function formatDate(d?: string) { |
|
|
class="detail-fav-btn" |
|
|
class="detail-fav-btn" |
|
|
:class="{ favorited: isFavorited(card.id), loading: loadingIds.has(card.id) }" |
|
|
:class="{ favorited: isFavorited(card.id), loading: loadingIds.has(card.id) }" |
|
|
:disabled="loadingIds.has(card.id)" |
|
|
:disabled="loadingIds.has(card.id)" |
|
|
@click="toggle(card.id)" |
|
|
@click="handleToggle(card.id)" |
|
|
> |
|
|
> |
|
|
<Icon :name="isFavorited(card.id) ? 'ph:star-fill' : 'ph:star'" /> |
|
|
<Icon :name="isFavorited(card.id) ? 'ph:star-fill' : 'ph:star'" /> |
|
|
</button> |
|
|
</button> |
|
|
|