Browse Source

docs: contributors list add last updated time (#6871)

pull/6880/head
Konv Suu 1 year ago committed by GitHub
parent
commit
197a00f6ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      site/src/components/Contributors/index.vue

25
site/src/components/Contributors/index.vue

@ -2,16 +2,22 @@
import { ref, watchEffect } from 'vue'; import { ref, watchEffect } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { REPO_PATH } from './constants'; import { REPO_PATH } from './constants';
import dayjs from 'dayjs';
defineProps({ defineProps({
isZn: Boolean, isZn: Boolean,
}); });
const route = useRoute(); const route = useRoute();
const contributors = ref([]); const contributors = ref([]);
const lastCommitTime = ref(0);
const filterData = data => { const filterData = data => {
const arr = []; const arr = [];
data.forEach(item => { data.forEach(item => {
if (!!item.author?.login || !!item.author?.html_url || !!item.author?.avatar_url) { if (!!item.author?.login || !!item.author?.html_url || !!item.author?.avatar_url) {
lastCommitTime.value = Math.max(lastCommitTime.value, +new Date(item.commit.author.date));
arr.push({ arr.push({
login: item.author.login, login: item.author.login,
url: item.author.html_url, url: item.author.html_url,
@ -46,18 +52,33 @@ watchEffect(() => {
</script> </script>
<template> <template>
<div class="contributors-list">
<ul v-if="contributors.length > 0" class="acss-1ppw8kl"> <ul v-if="contributors.length > 0" class="acss-1ppw8kl">
<li v-for="item in contributors" :key="item.login"> <li v-for="item in contributors" :key="item.login">
<a-tooltip :title="`${isZn ? '文档贡献者:' : 'contribotors: '}${item.login}`"> <a-tooltip :title="`${isZn ? '文档贡献者:' : 'Contributor: '}${item.login}`">
<a :href="item.url" target="_blank"> <a :href="item.url" target="_blank">
<a-avatar :src="item.avatar" size="small" /> <a-avatar :src="item.avatar" size="small" />
</a> </a>
</a-tooltip> </a-tooltip>
</li> </li>
</ul> </ul>
<span>
{{ isZn ? '最后更新' : 'Last updated' }} : {{ dayjs(lastCommitTime).format('YYYY/MM/DD') }}
</span>
</div>
</template> </template>
<style scoped> <style scoped>
.contributors-list {
margin-top: 120px !important;
display: flex;
gap: 8px;
}
.contributors-list span {
color: var(--primary-color);
}
.acss-1ppw8kl { .acss-1ppw8kl {
display: -webkit-box; display: -webkit-box;
display: -webkit-flex; display: -webkit-flex;
@ -67,8 +88,8 @@ watchEffect(() => {
-webkit-flex-wrap: wrap; -webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap; -ms-flex-wrap: wrap;
flex-wrap: wrap; flex-wrap: wrap;
margin-top: 120px !important;
clear: both; clear: both;
flex: 1;
} }
.acss-1ppw8kl li { .acss-1ppw8kl li {

Loading…
Cancel
Save