mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
Added Chinese version
Added Chinese version
This commit is contained in:
parent
d037338a23
commit
730a68b92a
466 changed files with 31255 additions and 0 deletions
38
zh-CN/src/components/FavoriteButton.vue
Normal file
38
zh-CN/src/components/FavoriteButton.vue
Normal file
|
@ -0,0 +1,38 @@
|
|||
<script setup lang="ts">
|
||||
import { useToolStore } from '@/tools/tools.store';
|
||||
import type { Tool } from '@/tools/tools.types';
|
||||
|
||||
const props = defineProps<{ tool: Tool }>();
|
||||
|
||||
const toolStore = useToolStore();
|
||||
|
||||
const { tool } = toRefs(props);
|
||||
|
||||
const isFavorite = computed(() => toolStore.isToolFavorite({ tool }));
|
||||
const buttonType = computed(() => (isFavorite.value ? 'primary' : 'default'));
|
||||
|
||||
function toggleFavorite(event: MouseEvent) {
|
||||
event.preventDefault();
|
||||
|
||||
if (toolStore.isToolFavorite({ tool })) {
|
||||
toolStore.removeToolFromFavorites({ tool });
|
||||
return;
|
||||
}
|
||||
|
||||
toolStore.addToolToFavorites({ tool });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-tooltip :tooltip="isFavorite ? $t('favoriteButton.remove') : $t('favoriteButton.add') ">
|
||||
<c-button
|
||||
variant="text"
|
||||
circle
|
||||
:type="buttonType"
|
||||
:style="{ opacity: isFavorite ? 1 : 0.2 }"
|
||||
@click="toggleFavorite"
|
||||
>
|
||||
<icon-mdi-heart />
|
||||
</c-button>
|
||||
</c-tooltip>
|
||||
</template>
|
Loading…
Add table
Add a link
Reference in a new issue