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 8.6 kB

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