u-icon.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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)
  12. return this.src!;
  13. if (this.name != null) {
  14. const key = (this.active == true ? `${this.name!}-active` : this.name!) as string;
  15. const iconFromKey = iconMap[key] as string | null;
  16. if (iconFromKey != null)
  17. return iconFromKey;
  18. const iconFromName = iconMap[this.name!] as string | null;
  19. if (iconFromName != null)
  20. return iconFromName;
  21. return '';
  22. }
  23. return '';
  24. }
  25. },
  26. methods: {
  27. handleClick() {
  28. this.$emit('click');
  29. }
  30. }
  31. });
  32. export default __sfc__;
  33. function GenComponentsUIconUIconRender(this: InstanceType<typeof __sfc__>): any | null {
  34. const _ctx = this;
  35. const _cache = this.$.renderCache;
  36. return _cE("image", _uM({
  37. class: "u-icon-img",
  38. src: _ctx.resolvedSrc,
  39. style: _nS(_uM({ width: (_ctx.size ?? 0) + 'px', height: (_ctx.size ?? 0) + 'px' })),
  40. mode: "aspectFit",
  41. onClick: _ctx.handleClick
  42. }), null, 12 /* STYLE, PROPS */, ["src", "onClick"]);
  43. }
  44. export type UIconComponentPublicInstance = InstanceType<typeof __sfc__>;
  45. const GenComponentsUIconUIconStyles = [];
  46. //# sourceMappingURL=u-icon.vue.map