college-item-collect.vue 821 B

1234567891011121314151617181920212223242526
  1. <template>
  2. <view class="fx-col fx-cen-cen min-w-90" @click="handleToggle">
  3. <uv-icon size="19" :name="collected?'heart-fill':'heart'" color="var(--primary-color)"/>
  4. <text class="text-xs text-primary">{{ collected ? '已收藏' : '收藏' }}</text>
  5. </view>
  6. </template>
  7. <script setup>
  8. import {computed} from 'vue';
  9. import {createPropDefine} from "@/utils";
  10. import {useCollegeCollectionService} from "@/pages/college-library/components/useCollegeCollectionService";
  11. const props = defineProps({
  12. college: createPropDefine({}, Object)
  13. })
  14. const emits = defineEmits(['change'])
  15. const collegeRef = computed(() => props.college)
  16. const {collected, handleToggle, onChange} = useCollegeCollectionService(collegeRef)
  17. onChange((collected) => emits('change', collected))
  18. </script>
  19. <style scoped>
  20. </style>