You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

SearchBar.vue 5.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div>
  3. <div class="_repo_search">
  4. <div class="_repo_search_input_c">
  5. <div class="_repo_search_input">
  6. <input type="text" v-model="searchInputValue" placeholder="搜项目" />
  7. </div>
  8. <div class="_repo_search_btn">
  9. <svg xmlns="http://www.w3.org/2000/svg"
  10. class="styles__StyledSVGIconPathComponent-sc-16fsqc8-0 kdvdTY svg-icon-path-icon fill" viewBox="0 0 32 32"
  11. width="24" height="24">
  12. <defs data-reactroot="">
  13. <linearGradient id="ilac9fwnydq3lcx1,1,rs,1,f0dwf0xj,ezu9f0dw,f000,00lwrsktrs,rs1bhv8urs" x1="0" x2="100%"
  14. y1="0" y2="0"
  15. gradientTransform="matrix(-0.7069999999999999, -0.707, 0.707, -0.7069999999999999, 16, 38.624)"
  16. gradientUnits="userSpaceOnUse">
  17. <stop stop-color="#c9ffbf" stop-opacity="1" offset="0"></stop>
  18. <stop stop-color="#0ca451" stop-opacity="1" offset="1"></stop>
  19. </linearGradient>
  20. </defs>
  21. <g>
  22. <path fill="url(#ilac9fwnydq3lcx1,1,rs,1,f0dwf0xj,ezu9f0dw,f000,00lwrsktrs,rs1bhv8urs)"
  23. d="M14.667 2.667c6.624 0 12 5.376 12 12s-5.376 12-12 12-12-5.376-12-12 5.376-12 12-12zM14.667 24c5.156 0 9.333-4.177 9.333-9.333 0-5.157-4.177-9.333-9.333-9.333-5.157 0-9.333 4.176-9.333 9.333 0 5.156 4.176 9.333 9.333 9.333zM25.98 24.095l3.772 3.771-1.887 1.887-3.771-3.772 1.885-1.885z">
  24. </path>
  25. </g>
  26. </svg>
  27. <span style="margin-left:10px;">搜索</span>
  28. </div>
  29. </div>
  30. <div class="_repo_search_label">
  31. <a :href="`/explore/repos?q=&topic=${item}&sort=hot`"
  32. :style="{ backgroundColor: topicColors[index % topicColors.length] }" v-for="(item, index) in topics"
  33. :key="index">{{ item }}</a>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import { getPromoteData } from '~/apis/modules/common';
  40. // import { CLUSTERS, AI_CENTER, COMPUTER_RESOURCES, ACC_CARD_TYPE } from '~/const';
  41. const COLOR_LIST = [
  42. 'rgb(255, 104, 104)',
  43. 'rgb(22, 132, 252)',
  44. 'rgb(2, 202, 253)',
  45. 'rgb(164, 145, 215)',
  46. 'rgb(232, 64, 247)',
  47. 'rgb(245, 182, 110)',
  48. 'rgb(54, 187, 166)',
  49. 'rgb(123, 50, 178)'
  50. ];
  51. export default {
  52. name: "SearchBar",
  53. props: {
  54. // visible: { type: Boolean, default: false },
  55. },
  56. components: {},
  57. data() {
  58. return {
  59. searchInputValue: '',
  60. topicColors: COLOR_LIST,
  61. topics: [],
  62. };
  63. },
  64. methods: {
  65. xxx() {
  66. }
  67. },
  68. mounted() {
  69. getPromoteData('/repos/recommend_topics').then(res => {
  70. const data = res.data;
  71. try {
  72. const topics = JSON.parse(data);
  73. this.topics = topics;
  74. } catch (err) {
  75. console.log(err);
  76. }
  77. }).catch(err => {
  78. console.log(err);
  79. });
  80. },
  81. };
  82. </script>
  83. <style scoped lang="less">
  84. ._repo_search {
  85. margin: 54px 0;
  86. }
  87. ._repo_search_input_c {
  88. margin: 0 0 35px;
  89. display: flex;
  90. justify-content: center;
  91. align-items: center;
  92. }
  93. ._repo_search_input {
  94. display: flex;
  95. align-items: center;
  96. width: 437px;
  97. height: 41px;
  98. border-color: rgba(47, 9, 69, 0.64);
  99. border-width: 1px;
  100. border-style: solid;
  101. color: rgba(16, 16, 16, 0.5);
  102. border-radius: 20px;
  103. font-size: 14px;
  104. padding: 20px;
  105. text-align: left;
  106. line-height: 20px;
  107. background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(6.123233995736765e-17%2C%20-0.9999999999999999%2C%200.008802475794500678%2C%206.123233995736765e-17%2C%201%2C%201.003)%22%3E%3Cstop%20stop-color%3D%22%23eeeade%22%20stop-opacity%3D%220.2%22%20offset%3D%220.76%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23ece0e9%22%20stop-opacity%3D%221%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
  108. }
  109. ._repo_search_input input {
  110. width: 100%;
  111. height: 30px;
  112. border: none;
  113. background: transparent;
  114. outline: none;
  115. }
  116. ._repo_search_btn {
  117. margin-left: 10px;
  118. width: 110px;
  119. height: 40px;
  120. border-style: none;
  121. border-color: unset;
  122. color: rgb(255, 255, 255);
  123. border-radius: 21px;
  124. font-size: 14px;
  125. text-align: center;
  126. font-weight: normal;
  127. font-style: normal;
  128. background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(6.123233995736766e-17%2C%201%2C%20-0.17728531855955676%2C%206.123233995736766e-17%2C%201%2C%200)%22%3E%3Cstop%20stop-color%3D%22%232f0945%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23341a7b%22%20stop-opacity%3D%221%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
  129. display: flex;
  130. align-items: center;
  131. justify-content: center;
  132. cursor: pointer;
  133. }
  134. ._repo_search_label {
  135. display: flex;
  136. justify-content: center;
  137. flex-wrap: wrap;
  138. }
  139. ._repo_search_label a {
  140. background-color: rgb(2, 202, 253);
  141. color: rgb(255, 255, 255);
  142. border-radius: 5px;
  143. margin: 0 5px 10px 5px;
  144. padding: 5px 10px;
  145. cursor: pointer;
  146. font-size: 12px;
  147. }
  148. </style>