gitLog.vue 4.88 KB
<template>
  <div class="gitlog">
    <div class="branch">
      <a-select
        default-value="master"
        style="width: 120px"
        @change="handleChange"
      >
        <a-select-option v-for="(item,index) in branchs" :key="index+'branch'" :value="index"> {{ item.name}} </a-select-option>
      </a-select>
      <span class="current">当前分支:{{currentBranch.name}}</span>
    </div>
    <a-list item-layout="horizontal" :data-source="data">
      <a-list-item slot="renderItem" slot-scope="item">
        <a-list-item-meta :description="item.message">
          <span slot="title"
            >{{ item.title }}---{{ item.created_at | dateTime }} by author:
            {{ item.author }}
            <span class="author">{{ item.author_name }}</span></span
          >
          <a-avatar
            slot="avatar"
            src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
          />
        </a-list-item-meta>
      </a-list-item>
    </a-list>
  </div>
</template>

<script>
import moment from "moment";
export default {
  name: "",
  props: {},
  data() {
    return {
      data: [
        {
          id: "98285ed4f3df5ef58a01607651f61592248dd101",
          short_id: "98285ed4",
          title: "add:主题色加深色值调整",
          created_at: "2022-02-10T14:00:54.000+08:00",
          parent_ids: ["37efaa1ece09035aafd490a8e4d94931b23fedd2"],
          message: "add:主题色加深色值调整\n",
          author_name: "luyt",
          author_email: "q9OUYzI2",
          authored_date: "2022-02-10T14:00:54.000+08:00",
          committer_name: "luyt",
          committer_email: "q9OUYzI2",
          committed_date: "2022-02-10T14:00:54.000+08:00",
        },
      ],
      branchs: [
        {
          name: "SCRM-V1.0.2",
          commit: {
            id: "266eb49b58dbc3dfdf12e52395fb5de9edcbf47a",
            short_id: "266eb49b",
            title: "1.3.7",
            created_at: "2022-01-17T14:26:31.000+08:00",
            parent_ids: ["aa7f2e56c33073428325efb7deff5f25e1da9c80"],
            message: "1.3.7\n",
            author_name: "limin",
            author_email: "17653212@qq.com",
            authored_date: "2022-01-17T14:26:31.000+08:00",
            committer_name: "limin",
            committer_email: "17653212@qq.com",
            committed_date: "2022-01-17T14:26:31.000+08:00",
          },
          merged: true,
          protected: false,
          developers_can_push: false,
          developers_can_merge: false,
        },
        {
          name: "dev",
          commit: {
            id: "d51cb098bf2eae3295c336c9cf8000776e8e2a3a",
            short_id: "d51cb098",
            title: "add:修改table左对齐,金额右对齐",
            created_at: "2022-02-16T15:39:30.000+08:00",
            parent_ids: ["a423fa7e0afb347a2854ac03069dd19167d3acbb"],
            message: "add:修改table左对齐,金额右对齐\n",
            author_name: "luyt",
            author_email: "q9OUYzI2",
            authored_date: "2022-02-16T15:39:30.000+08:00",
            committer_name: "luyt",
            committer_email: "q9OUYzI2",
            committed_date: "2022-02-16T15:39:30.000+08:00",
          },
          merged: false,
          protected: false,
          developers_can_push: false,
          developers_can_merge: false,
        },
      ],
      currentBranch:   {
        "name": "master",
        "commit": {
            "id": "98285ed4f3df5ef58a01607651f61592248dd101",
            "short_id": "98285ed4",
            "title": "add:主题色加深色值调整",
            "created_at": "2022-02-10T14:00:54.000+08:00",
            "parent_ids": [
                "37efaa1ece09035aafd490a8e4d94931b23fedd2"
            ],
            "message": "add:主题色加深色值调整\n",
            "author_name": "luyt",
            "author_email": "q9OUYzI2",
            "authored_date": "2022-02-10T14:00:54.000+08:00",
            "committer_name": "luyt",
            "committer_email": "q9OUYzI2",
            "committed_date": "2022-02-10T14:00:54.000+08:00"
        },
        "merged": false,
        "protected": true,
        "developers_can_push": false,
        "developers_can_merge": false
    },
    };
  },
  filters: {
    dateTime(value) {
      if (!value) return;
      return moment(value).format("YYYY-MM-DD HH:MM:ss");
    },
  },
  created() {
    this.getBranchData()
  },
  mounted() {},
  methods: {
    handleChange(value) {
      this.currentBranch = this.branchs[value]
      // console.log('value: ', value);
    },
    defaultBranch(){

    },
    getBranchData(value) {
      console.log('value: ', value);
      this.api.gitLog.getBranches(173).then(res=>{
        console.log('res: ', res);
      })
    }
  },
  components: {},
  computed: {},
};
</script>
<style lang='scss'>
.gitlog {
  .branch {
    margin-bottom: 30px;
    .current {
      margin-left: 20px;
    }
  }
  .author {
    color: #008dff;
  }
}
</style>