u-icon.vue.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { iconMap } from '@/common/icon-map';
  2. const __sfc__ = defineComponent({
  3. props: {
  4. name: String,
  5. src: String,
  6. size: Number,
  7. active: Boolean
  8. },
  9. computed: {
  10. resolvedSrc() : string {
  11. if (this.src != null) return this.src;
  12. if (this.name != null) {
  13. const key = (this.active == true ? `${this.name}-active` : this.name) as string;
  14. const iconFromKey = iconMap[key] as string | null;
  15. if (iconFromKey != null) return iconFromKey;
  16. const iconFromName = iconMap[this.name] as string | null;
  17. if (iconFromName != null) return iconFromName;
  18. return '';
  19. }
  20. return '';
  21. }
  22. },
  23. methods: {
  24. handleClick() {
  25. this.$emit('click');
  26. }
  27. }
  28. });
  29. export default __sfc__
  30. function GenComponentsUIconUIconRender(this: InstanceType<typeof __sfc__>): any | null {
  31. const _ctx = this
  32. const _cache = this.$.renderCache
  33. return _cE("image", _uM({
  34. class: "u-icon-img",
  35. src: _ctx.resolvedSrc,
  36. style: _nS(_uM({ width: (_ctx.size??0) + 'px', height: (_ctx.size??0) + 'px' })),
  37. mode: "aspectFit",
  38. onClick: _ctx.handleClick
  39. }), null, 12 /* STYLE, PROPS */, ["src", "onClick"])
  40. }
  41. export type UIconComponentPublicInstance = InstanceType<typeof __sfc__>;
  42. const GenComponentsUIconUIconStyles = []