index.vue 4.9 KB
Newer Older
Mr.奇淼('s avatar
Mr.奇淼( 已提交
1
<template>
G
Granty1 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  <div>
    <el-row :gutter="10">
      <el-col :span="12">
        <el-card>
          <div slot="header">gin-vue-admin</div>
          <div>
            <el-row>
              <el-col :span="8" :offset="8">
                <a href="https://github.com/flipped-aurora/gin-vue-admin">
                  <img
                    class="org-img dom-center"
                    src="@/assets/logo.png"
                    alt="gin-vue-admin"
                  />
                </a>
              </el-col>
            </el-row>
            <el-row :gutter="10">
              <el-col :span="8">
                <a href="https://github.com/flipped-aurora/gin-vue-admin">
                  <img
                    class="dom-center"
                    src="https://img.shields.io/github/watchers/flipped-aurora/gin-vue-admin.svg?label=Watch"
                    alt=""
                  />
                </a>
              </el-col>
              <el-col :span="8">
                <a href="https://github.com/flipped-aurora/gin-vue-admin">
                  <img
                    class="dom-center"
                    src="https://img.shields.io/github/stars/flipped-aurora/gin-vue-admin.svg?style=social"
                    alt=""/></a
              ></el-col>
              <el-col :span="8">
                <a href="https://github.com/flipped-aurora/gin-vue-admin">
                  <img
                    class="dom-center"
                    src="https://img.shields.io/github/forks/flipped-aurora/gin-vue-admin.svg?label=Fork"
                    alt=""/></a
              ></el-col>
            </el-row>
          </div>
        </el-card>
        <el-card style="margin-top: 20px">
          <div slot="header">flipped-aurora团队</div>
          <div>
            <el-row>
              <el-col :span="8" :offset="8">
                <a href="https://github.com/flipped-aurora">
                  <img
G
Granty1 已提交
53
                    class="org-img dom-center"
G
Granty1 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
                    src="@/assets/flipped-aurora.png"
                    alt="flipped-aurora"
                  />
                </a>
              </el-col>
            </el-row>
            <el-row style="margin-left: 40px" :gutter="20">
              <template v-for="(item, index) in members">
                <el-col :span="8" :key="index">
                  <a :href="item.html_url">
                    <img class="avatar-img" :src="item.avatar_url" />
                    <a class="author-name" style="">{{ item.login }}</a>
                  </a>
                </el-col>
              </template>
            </el-row>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card>
          <div slot="header">
            提交记录
          </div>
          <div>
            <Timeline
              :timeline-items="dataTimeline"
              :message-when-no-items="messageWhenNoItems"
              :uniqueTimeline="true"
              :unique-year="true"
              :show-day-and-month="true"
              order="desc"
              dateLocale="zh-CN"
            />
          </div>
          <el-button class="load-more" @click="loadMore" type="text"
            >Load more</el-button
          >
        </el-card>
      </el-col>
    </el-row>
  </div>
Mr.奇淼('s avatar
Mr.奇淼( 已提交
96 97 98
</template>

<script>
G
Granty1 已提交
99 100
import { Commits, Members } from "@/api/github";
import Timeline from "timeline-vuejs";
Mr.奇淼('s avatar
Mr.奇淼( 已提交
101
export default {
G
Granty1 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
  name: "Test",
  components: {
    Timeline,
  },
  data() {
    return {
      messageWhenNoItems: "There arent commits",
      members: [],
      dataTimeline: [],
      page: 0,
    };
  },
  created() {
    this.loadCommits();
    this.loadMembers();
  },
  methods: {
    loadMore() {
      this.page++;
      this.loadCommits();
    },
    loadCommits() {
      Commits(this.page).then(({ data }) => {
        data.forEach((element) => {
          if (element.commit.message) {
            this.dataTimeline.push({
              from: new Date(element.commit.author.date),
              title: element.commit.author.name,
              showDayAndMonth: true,
              description: `<a style="color: #26191b" href="${element.html_url}">${element.commit.message}</a>`,
            });
          }
        });
      });
    },
    loadMembers() {
      Members().then(({ data }) => {
        this.members = data;
        this.members.sort();
      });
    },
  },
};
Mr.奇淼('s avatar
Mr.奇淼( 已提交
145 146 147
</script>

<style scoped>
G
Granty1 已提交
148 149 150
.load-more {
  margin-left: 120px;
}
Mr.奇淼('s avatar
Mr.奇淼( 已提交
151

G
Granty1 已提交
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
.avatar-img {
  float: left;
  height: 40px;
  width: 40px;
  border-radius: 50%;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  margin-top: 15px;
}

.org-img {
  height: 150px;
  width: 150px;
}

.author-name {
  float: left;
  line-height: 65px !important;
  margin-left: 10px;
  color: darkblue;
  line-height: 100px;
  font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
    "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
}

.dom-center {
  margin-left: 50%;
  transform: translateX(-50%);
}
</style>