icons.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. export default {
  2. emits: ['click'],
  3. props: {
  4. // 图标大小
  5. size: {
  6. type: Number,
  7. default: 24
  8. },
  9. // 线段粗细
  10. strokeWidth: {
  11. type: Number,
  12. default: 4
  13. },
  14. // 图标风格(颜色)
  15. theme: {
  16. type: String,
  17. default: "outline"
  18. },
  19. // 图标颜色["外部描边颜色","外部填充颜色","内部描边颜色","内部填充颜色"]
  20. fill: {
  21. type: Array,
  22. default: () => {
  23. return ["#000000"]
  24. }
  25. },
  26. // 端点类型
  27. strokeLinecap: {
  28. type: String,
  29. default: "round"
  30. },
  31. // 拐点类型
  32. strokeLinejoin: {
  33. type: String,
  34. default: "round"
  35. }
  36. },
  37. methods: {
  38. onClick() {
  39. this.$emit("click");
  40. },
  41. /**
  42. * 获取当前颜色
  43. */
  44. currentColor(index, defaultColor) {
  45. const isExistence = this.fill.length >= (index + 1) ? true : false;
  46. return isExistence ? this.fill[index] : defaultColor;
  47. },
  48. /**
  49. * 多色
  50. */
  51. multiColor() {
  52. return [this.currentColor(0, "#000000"), this.currentColor(1, "#2F88FF"), this.currentColor(2, "#FFFFFF"),
  53. this.currentColor(3, "#43CCF8")
  54. ];
  55. },
  56. /**
  57. * 双色
  58. */
  59. twoTone() {
  60. return [this.currentColor(0, "#000000"), this.currentColor(1, "#2F88FF"), this.currentColor(0, "#000000"),
  61. this.currentColor(1, "#2F88FF")
  62. ];
  63. },
  64. /**
  65. * 填充
  66. */
  67. filled() {
  68. return [this.currentColor(0, "#000000"), this.currentColor(0, "#000000"), "#FFFFFF", "#FFFFFF"];
  69. },
  70. /**
  71. * 线性
  72. */
  73. outline() {
  74. return [this.currentColor(0, "#000000"), "none", this.currentColor(0, "#000000"), "none"];
  75. },
  76. /**
  77. * 根据主题取色彩
  78. */
  79. colors(index) {
  80. if (this.theme == "filled") {
  81. return this.filled()[index]
  82. } else if (this.theme == "two-tone") {
  83. return this.twoTone()[index]
  84. } else if (this.theme == "multi-color") {
  85. return this.multiColor()[index]
  86. } else {
  87. return this.outline()[index]
  88. };
  89. }
  90. }
  91. }