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.8 kB

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