commit.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <el-card shadow="hover" header="更新记录">
  3. <template #header>
  4. <el-icon style="display: inline; vertical-align: middle"> <ele-DocumentCopy /> </el-icon>
  5. <span> 更新记录 </span>
  6. <el-button type="primary" icon="ele-Refresh" round plain @click="refresh" style="float: right">更新记录</el-button>
  7. </template>
  8. <div class="commit" v-loading="state.loading">
  9. <el-timeline style="max-width: 600px" v-if="state.list.length > 0">
  10. <el-timeline-item v-for="(item, index) in state.list" :key="index" :timestamp="formatDate(new Date(item.commit.committer.date), 'YYYY-mm-dd HH:MM:SS')">
  11. <el-link style="white-space: pre-line; word-break: break-all" :href="item.html_url" target="_blank"> {{ item.commit.message }}</el-link>
  12. </el-timeline-item>
  13. </el-timeline>
  14. <el-empty v-else description="空"></el-empty>
  15. </div>
  16. </el-card>
  17. </template>
  18. <script lang="ts">
  19. export default {
  20. title: '更新记录',
  21. icon: 'ele-DocumentCopy',
  22. description: '当前项目更新记录',
  23. };
  24. </script>
  25. <script setup lang="ts" name="commit">
  26. import { reactive, onMounted } from 'vue';
  27. import { formatDate } from '/@/utils/formatTime';
  28. const state = reactive({
  29. loading: false,
  30. list: [] as any,
  31. });
  32. const getList = () => {
  33. axios({
  34. method: 'get',
  35. url: 'https://gitee.com/api/v5/repos/zuohuaijun/Admin.NET/commits',
  36. params: {
  37. page: 1,
  38. per_page: 10,
  39. },
  40. }).then((res: any) => {
  41. state.list = res.data;
  42. state.loading = false;
  43. });
  44. };
  45. const refresh = () => {
  46. state.loading = true;
  47. getList();
  48. };
  49. onMounted(() => {
  50. state.loading = true;
  51. getList();
  52. });
  53. </script>
  54. <style scoped>
  55. .progress {
  56. text-align: center;
  57. }
  58. .progress .percentage-value {
  59. font-size: 28px;
  60. }
  61. .progress .percentage-label {
  62. font-size: 12px;
  63. margin-top: 10px;
  64. }
  65. .commit {
  66. max-height: 500px;
  67. overflow: auto;
  68. }
  69. </style>