index.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import clsx from "clsx";
  2. import React from "react";
  3. import styles from "./index.module.scss";
  4. interface Props {
  5. level: number;
  6. className?: string;
  7. style?: React.CSSProperties;
  8. }
  9. interface IconItem {
  10. leve: number;
  11. src: string;
  12. color: string;
  13. textColor: string;
  14. textBackground: string;
  15. }
  16. export const vipImagesMap = new Map<number, IconItem>([
  17. [
  18. 1,
  19. {
  20. leve: 1,
  21. src: "/vip/1.webp",
  22. color: "#686868",
  23. textColor: "#485684",
  24. textBackground: "#d6dbf5,#8490b9",
  25. },
  26. ],
  27. [
  28. 2,
  29. {
  30. leve: 2,
  31. src: "/vip/2.webp",
  32. color: "#844C4F",
  33. textColor: "#3a7a85 ",
  34. textBackground: "#dbfcff,#9ed8e2",
  35. },
  36. ],
  37. [
  38. 3,
  39. {
  40. leve: 3,
  41. src: "/vip/3.webp",
  42. color: "#844C4F",
  43. textColor: "#574b88 ",
  44. textBackground: "#dee2ef ,#a499d2",
  45. },
  46. ],
  47. [
  48. 4,
  49. {
  50. leve: 4,
  51. src: "/vip/4.webp",
  52. color: "#844C4F",
  53. textColor: "#305975",
  54. textBackground: "#efffff,#46a0db",
  55. },
  56. ],
  57. [
  58. 5,
  59. {
  60. leve: 5,
  61. src: "/vip/5.webp",
  62. color: "#707386",
  63. textColor: "#573c7f",
  64. textBackground: "#e0d3f6,#916db8",
  65. },
  66. ],
  67. [
  68. 6,
  69. {
  70. leve: 6,
  71. src: "/vip/6.webp",
  72. color: "#707386",
  73. textColor: "#7d4345",
  74. textBackground: "#feede9,#d47175",
  75. },
  76. ],
  77. [
  78. 7,
  79. {
  80. leve: 7,
  81. src: "/vip/7.webp",
  82. color: "#707386",
  83. textColor: "#3b7e5c",
  84. textBackground: "#effcec,#62b58b",
  85. },
  86. ],
  87. [
  88. 8,
  89. {
  90. leve: 8,
  91. src: "/vip/8.webp",
  92. color: "#894622",
  93. textColor: "#355278",
  94. textBackground: "#ffffff,#5a8fd2",
  95. },
  96. ],
  97. [
  98. 9,
  99. {
  100. leve: 9,
  101. src: "/vip/9.webp",
  102. color: "#894622",
  103. textColor: "#473575",
  104. textBackground: "#f1f1ff,#795ac7",
  105. },
  106. ],
  107. [
  108. 10,
  109. {
  110. leve: 10,
  111. src: "/vip/10.webp",
  112. color: "#894622",
  113. textColor: "#664b45",
  114. textBackground: "#fff6ee,#fdd181",
  115. },
  116. ],
  117. ]);
  118. const VipIcon: React.FC<Props> = ({ level, className, style = {} }) => {
  119. const curVip: IconItem = React.useMemo(() => {
  120. return vipImagesMap.get(level || 1) as IconItem;
  121. }, [level]);
  122. return (
  123. <div style={style} className={clsx(className, styles.vipIcon)}>
  124. <img src={curVip.src} alt="" />
  125. </div>
  126. );
  127. };
  128. export default VipIcon;