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.

ReposItem.vue 7.4 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div>
  3. <div class="item">
  4. <div class="item-top">
  5. <img v-if="data.RelAvatarLink" class="avatar" :src="data.RelAvatarLink" />
  6. <img v-else class="avatar" :avatar="data.OwnerName" />
  7. <div class="content">
  8. <div class="title">
  9. <div class="title-l">
  10. <a :href="`/${data.OwnerName}/${data.Name}`" :title="`${data.OwnerName}/${data.Name}`">
  11. <span class="title-1">{{ data.OwnerName }}</span>
  12. <span class="title-1"> / </span>
  13. <span class="title-2" v-html="data.NameShow"></span>
  14. </a>
  15. </div>
  16. <span class="title-r">
  17. <span class="t-item" :title="$t('repos.watch')">
  18. <i class="ri-eye-line"></i>
  19. <span>{{ data.NumWatches }}</span>
  20. </span>
  21. <span class="t-item" :title="$t('repos.star')">
  22. <i class="ri-star-line"></i>
  23. <span>{{ data.NumStars }}</span>
  24. </span>
  25. <span class="t-item" :title="$t('repos.fork')">
  26. <svg class="svg octicon-repo-forked" width="12" height="12" aria-hidden="true">
  27. <use xlink:href="#octicon-repo-forked"></use>
  28. </svg>
  29. <span>{{ data.NumForks }}</span></span>
  30. </span>
  31. </div>
  32. <div class="descr" v-html="data.DescriptionShow"></div>
  33. <div class="tags" v-if="data.Topics">
  34. <a v-for="(item, index) in data.TopicsShow" :key="index" class="tag"
  35. :class="(item.topic.toLocaleLowerCase() == topic.toLocaleLowerCase() ? 'tag-focus' : '')"
  36. :href="`/explore/repos?q=&topic=${item.topic}&sort=hot`" v-html="item.topicShow"></a>
  37. </div>
  38. <div class="repo-datas">
  39. <span class="repo-datas-item" v-show="(data.DatasetCnt > 0)">
  40. <i class="ri-stack-line"></i>
  41. <span class="label">{{ $t('repos.dataset') }}:</span>
  42. <span class="value">{{ data.DatasetCnt }}</span>
  43. </span>
  44. <span class="repo-datas-item" v-show="(data.ModelCnt > 0)">
  45. <i class="ri-send-plane-2-line"></i>
  46. <span class="label">{{ $t('repos.model') }}:</span>
  47. <span class="value">{{ data.ModelCnt }}</span>
  48. </span>
  49. <span class="repo-datas-item" v-show="(data.AiTaskCnt > 0)">
  50. <i class="ri-order-play-line"></i>
  51. <span class="label">{{ $t('repos.aiTask') }}:</span>
  52. <span class="value">{{ data.AiTaskCnt }}</span>
  53. </span>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="item-bottom">
  58. <div>
  59. <span>{{ $t('repos.updated') }}</span>
  60. <el-tooltip effect="dark" :content="dateFormat(data.UpdatedUnix)" placement="top-start">
  61. <span>{{ calcFromNow(data.UpdatedUnix) }}</span>
  62. </el-tooltip>
  63. <span style="margin-left:8px;" v-if="data.PrimaryLanguage"><i class="color-icon"
  64. :style="{ backgroundColor: data.PrimaryLanguage.Color }"></i>{{ data.PrimaryLanguage.Language }}</span>
  65. </div>
  66. <div class="contributors">
  67. <span class="contributors-count">{{ $t('repos.contributors') }}&nbsp;</span>
  68. <span> 17+ </span>
  69. <span class="contributors-avatar">
  70. <img class="avatar" src="/user/avatar/Itx003/-1">
  71. <img class="avatar" src="/user/avatar/Itx003/-1">
  72. <img class="avatar" src="/user/avatar/Itx003/-1">
  73. <img class="avatar" src="/user/avatar/Itx003/-1">
  74. <img class="avatar" src="/user/avatar/Itx003/-1">
  75. </span>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import relativeTime from 'dayjs/plugin/relativeTime';
  83. import localizedFormat from 'dayjs/plugin/localizedFormat';
  84. import 'dayjs/locale/zh-cn';
  85. import 'dayjs/locale/en';
  86. import dayjs from 'dayjs';
  87. import { lang } from '~/langs';
  88. dayjs.locale(lang == 'zh-CN' ? 'zh-cn' : 'en');
  89. dayjs.extend(relativeTime);
  90. dayjs.extend(localizedFormat);
  91. export default {
  92. name: "ReposItem",
  93. props: {
  94. data: { type: Object, default: () => ({}) },
  95. topic: { type: String, default: '' }
  96. },
  97. components: {},
  98. data() {
  99. return {
  100. contributors: [],
  101. };
  102. },
  103. methods: {
  104. calcFromNow(unix) {
  105. return dayjs(unix * 1000).fromNow();
  106. },
  107. dateFormat(unix) {
  108. return lang == 'zh-CN' ? dayjs(unix * 1000).format('YYYY年MM月DD日 HH时mm分ss秒') :
  109. dayjs(unix * 1000).format('ddd, D MMM YYYY HH:mm:ss [CST]');
  110. }
  111. },
  112. mounted() { },
  113. };
  114. </script>
  115. <style scoped lang="less">
  116. .item {
  117. width: 100%;
  118. border-color: rgba(157, 197, 226, 0.4);
  119. border-width: 1px;
  120. border-style: solid;
  121. box-shadow: rgb(157 197 226 / 20%) 0px 5px 10px 0px;
  122. border-radius: 15px;
  123. font-size: 14px;
  124. padding: 20px 26px 10px 26px;
  125. margin-bottom: 40px;
  126. }
  127. .item-top {
  128. display: flex;
  129. }
  130. .item-top .avatar {
  131. width: 38px;
  132. height: 38px;
  133. margin-right: 10px;
  134. }
  135. .content {
  136. flex: 1;
  137. overflow: hidden;
  138. }
  139. .content .title {
  140. display: flex;
  141. align-items: center;
  142. height: 30px;
  143. margin: 4px 0 8px;
  144. }
  145. .content .title-l {
  146. flex: 1;
  147. overflow: hidden;
  148. width: 100%;
  149. text-overflow: ellipsis;
  150. white-space: nowrap;
  151. }
  152. .content .title-1 {
  153. font-size: 18px;
  154. color: rgba(16, 16, 16, 0.6);
  155. }
  156. .content .title-2 {
  157. font-size: 18px;
  158. color: rgba(16, 16, 16, 1);
  159. font-weight: bold;
  160. }
  161. .content .title-r {
  162. width: 240px;
  163. display: flex;
  164. align-items: center;
  165. font-size: 12px;
  166. font-weight: bold;
  167. color: rgb(26, 40, 51, 0.9);
  168. justify-content: flex-end;
  169. }
  170. .content .t-item {
  171. margin-left: 12px;
  172. display: flex;
  173. align-items: center;
  174. }
  175. .content .t-item i {
  176. margin-right: 4px;
  177. }
  178. .content .descr {
  179. font-size: 14px;
  180. color: rgba(16, 16, 16, 0.8);
  181. margin-bottom: 12px;
  182. overflow: hidden;
  183. text-overflow: ellipsis;
  184. word-break: break-all;
  185. display: -webkit-box;
  186. -webkit-box-orient: vertical;
  187. -webkit-line-clamp: 6;
  188. max-height: 120px;
  189. white-space: break-spaces;
  190. }
  191. .content .tags {
  192. margin-bottom: 16px;
  193. overflow: hidden;
  194. text-overflow: ellipsis;
  195. white-space: nowrap;
  196. }
  197. .content .tag {
  198. color: rgba(16, 16, 16, 0.8);
  199. border-radius: 4px;
  200. font-size: 14px;
  201. background: rgba(232, 232, 232, 0.6);
  202. padding: 2px 6px;
  203. margin-right: 8px;
  204. &.tag-focus {
  205. color: red;
  206. }
  207. }
  208. .content .repo-datas {
  209. display: flex;
  210. align-items: center;
  211. margin: 24px 0;
  212. }
  213. .content .repo-datas-item {
  214. display: flex;
  215. align-items: center;
  216. margin-right: 24px;
  217. }
  218. .content .repo-datas-item i {
  219. color: rgba(2, 107, 251, 0.54);
  220. margin-right: 4px;
  221. font-size: 16px;
  222. }
  223. .content .repo-datas-item .label {
  224. color: rgba(2, 107, 251, 0.54);
  225. margin-right: 4px;
  226. }
  227. .content .repo-datas-item .value {
  228. font-weight: bold;
  229. }
  230. .item-bottom {
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. border-top: 1px solid rgba(157, 197, 226, 0.2);
  235. padding-top: 10px;
  236. font-size: 12px;
  237. color: rgba(16, 16, 16, 0.6);
  238. }
  239. .item-bottom .contributors {
  240. display: flex;
  241. align-items: center;
  242. }
  243. .item-bottom .contributors-avatar {
  244. display: flex;
  245. align-items: center;
  246. margin-left: 16px;
  247. }
  248. .item-bottom .avatar {
  249. width: 25px;
  250. height: 25px;
  251. margin-left: -6px;
  252. border-radius: 100%;
  253. border: 1px solid white;
  254. }
  255. </style>