cwg-icon.vue 987 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <SvgIcon :color="curColor" :icon="props.name || props.icon" class="icon" :height="size" :width="size" />
  3. </template>
  4. <script setup>
  5. import { computed } from 'vue'
  6. import useGlobalStore from '@/stores/use-global-store'
  7. const globalStore = useGlobalStore()
  8. const isDark = computed(() => globalStore.theme === 'dark')
  9. import SvgIcon from "@/uni_modules/cwg-svg-icon/components/cwg-svg-icon/cwg-svg-icon.vue";
  10. import {
  11. ref,
  12. watch
  13. } from "vue";
  14. const props = defineProps({
  15. name: {
  16. type: String,
  17. required: ""
  18. }, // 图标名
  19. icon: {
  20. type: String,
  21. required: ""
  22. }, // 图标名
  23. size: {
  24. type: [Number, String],
  25. default: 24
  26. },
  27. color: {
  28. type: String,
  29. default: ""
  30. },
  31. darkColor: {
  32. type: String,
  33. default: ""
  34. }
  35. });
  36. const curColor = computed(() => {
  37. return props.color ? props.color : isDark.value ? '#fff' : '#000';
  38. });
  39. </script>
  40. <style scoped>
  41. .icon {
  42. display: inline-flex;
  43. align-items: center;
  44. justify-content: center;
  45. color: inherit;
  46. }
  47. </style>