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.8 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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> {{ data.TotalContributorCountShow }}</span>
  69. <span class="contributors-avatar">
  70. <a :href="item.UserName ? `/${item.UserName}` : `mailto:${item.Email}`" class="avatar-c"
  71. v-for="(item, index) in data.Contributors" :key="index">
  72. <img class="avatar" v-show="item.UserName" :src="item.RelAvatarLink">
  73. <span class="avatar" v-show="!item.UserName" :style="{ backgroundColor: item.bgColor }">
  74. {{ item.Email[0].toLocaleUpperCase() }}</span>
  75. </a>
  76. </span>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </template>
  82. <script>
  83. import relativeTime from 'dayjs/plugin/relativeTime';
  84. import localizedFormat from 'dayjs/plugin/localizedFormat';
  85. import 'dayjs/locale/zh-cn';
  86. import 'dayjs/locale/en';
  87. import dayjs from 'dayjs';
  88. import { lang } from '~/langs';
  89. dayjs.locale(lang == 'zh-CN' ? 'zh-cn' : 'en');
  90. dayjs.extend(relativeTime);
  91. dayjs.extend(localizedFormat);
  92. export default {
  93. name: "ReposItem",
  94. props: {
  95. data: { type: Object, default: () => ({}) },
  96. topic: { type: String, default: '' }
  97. },
  98. components: {},
  99. data() {
  100. return {
  101. contributors: [],
  102. };
  103. },
  104. methods: {
  105. calcFromNow(unix) {
  106. return dayjs(unix * 1000).fromNow();
  107. },
  108. dateFormat(unix) {
  109. return lang == 'zh-CN' ? dayjs(unix * 1000).format('YYYY年MM月DD日 HH时mm分ss秒') :
  110. dayjs(unix * 1000).format('ddd, D MMM YYYY HH:mm:ss [CST]');
  111. }
  112. },
  113. mounted() { },
  114. };
  115. </script>
  116. <style scoped lang="less">
  117. .item {
  118. width: 100%;
  119. border-color: rgba(157, 197, 226, 0.4);
  120. border-width: 1px;
  121. border-style: solid;
  122. box-shadow: rgb(157 197 226 / 20%) 0px 5px 10px 0px;
  123. border-radius: 15px;
  124. font-size: 14px;
  125. padding: 20px 26px 10px 26px;
  126. margin-bottom: 40px;
  127. }
  128. .item-top {
  129. display: flex;
  130. }
  131. .item-top .avatar {
  132. width: 38px;
  133. height: 38px;
  134. margin-right: 10px;
  135. }
  136. .content {
  137. flex: 1;
  138. overflow: hidden;
  139. }
  140. .content .title {
  141. display: flex;
  142. align-items: center;
  143. height: 30px;
  144. margin: 4px 0 8px;
  145. }
  146. .content .title-l {
  147. flex: 1;
  148. overflow: hidden;
  149. width: 100%;
  150. text-overflow: ellipsis;
  151. white-space: nowrap;
  152. }
  153. .content .title-1 {
  154. font-size: 18px;
  155. color: rgba(16, 16, 16, 0.6);
  156. }
  157. .content .title-2 {
  158. font-size: 18px;
  159. color: rgba(16, 16, 16, 1);
  160. font-weight: bold;
  161. }
  162. .content .title-r {
  163. width: 240px;
  164. display: flex;
  165. align-items: center;
  166. font-size: 12px;
  167. font-weight: bold;
  168. color: rgb(26, 40, 51, 0.9);
  169. justify-content: flex-end;
  170. }
  171. .content .t-item {
  172. margin-left: 12px;
  173. display: flex;
  174. align-items: center;
  175. }
  176. .content .t-item i {
  177. margin-right: 4px;
  178. }
  179. .content .descr {
  180. font-size: 14px;
  181. color: rgba(16, 16, 16, 0.8);
  182. margin-bottom: 12px;
  183. overflow: hidden;
  184. text-overflow: ellipsis;
  185. word-break: break-all;
  186. display: -webkit-box;
  187. -webkit-box-orient: vertical;
  188. -webkit-line-clamp: 6;
  189. max-height: 120px;
  190. white-space: break-spaces;
  191. }
  192. .content .tags {
  193. margin-bottom: 16px;
  194. overflow: hidden;
  195. text-overflow: ellipsis;
  196. white-space: nowrap;
  197. }
  198. .content .tag {
  199. color: rgba(16, 16, 16, 0.8);
  200. border-radius: 4px;
  201. font-size: 14px;
  202. background: rgba(232, 232, 232, 0.6);
  203. padding: 2px 6px;
  204. margin-right: 8px;
  205. &.tag-focus {
  206. color: red;
  207. }
  208. }
  209. .content .repo-datas {
  210. display: flex;
  211. align-items: center;
  212. margin: 24px 0;
  213. }
  214. .content .repo-datas-item {
  215. display: flex;
  216. align-items: center;
  217. margin-right: 24px;
  218. }
  219. .content .repo-datas-item i {
  220. color: rgba(2, 107, 251, 0.54);
  221. margin-right: 4px;
  222. font-size: 16px;
  223. }
  224. .content .repo-datas-item .label {
  225. color: rgba(2, 107, 251, 0.54);
  226. margin-right: 4px;
  227. }
  228. .content .repo-datas-item .value {
  229. font-weight: bold;
  230. }
  231. .item-bottom {
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. border-top: 1px solid rgba(157, 197, 226, 0.2);
  236. padding-top: 10px;
  237. font-size: 12px;
  238. color: rgba(16, 16, 16, 0.6);
  239. }
  240. .item-bottom .contributors {
  241. display: flex;
  242. align-items: center;
  243. }
  244. .item-bottom .contributors-avatar {
  245. display: flex;
  246. align-items: center;
  247. margin-left: 16px;
  248. .avatar-c {
  249. img[src=""],
  250. img:not([src]) {
  251. // opacity: 0;
  252. }
  253. }
  254. }
  255. .item-bottom .avatar {
  256. display: block;
  257. width: 25px;
  258. height: 25px;
  259. margin-left: -6px;
  260. border-radius: 100%;
  261. border: 1px solid white;
  262. font-size: 16px;
  263. line-height: 24px;
  264. text-align: center;
  265. color: white;
  266. background-color: white;
  267. font-weight: bold;
  268. }
  269. </style>