Skip to content

Commit

Permalink
feat: Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanzhi33 committed Apr 5, 2024
1 parent a7d4e67 commit 5139d65
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const { t } = useI18n({
refreshSuccess: '数据刷新成功',
confirmLogin: '跳转到登录页面?',
confirmLogout: '确定要退出登录?',
logoutSuccess: '退出登录成功'
logoutSuccess: '退出登录成功',
changelog: "更新日志"
},
en: {
memberList: 'Member List',
Expand Down Expand Up @@ -67,7 +68,8 @@ const { t } = useI18n({
refreshSuccess: 'Get data successfully',
confirmLogin: 'Go to login page?',
confirmLogout: 'Are you sure to logout?',
logoutSuccess: 'Logout successfully'
logoutSuccess: 'Logout successfully',
changelog: "Changelog"
}
}
});
Expand Down Expand Up @@ -143,6 +145,7 @@ const logout = async () => {
}
const isSyncing = ref(false);
const isChangelog = ref(false);
</script>

Expand Down Expand Up @@ -206,7 +209,7 @@ const isSyncing = ref(false);
</Transition>
</div>

<List ref="mlist" :isPC :isAdmin :search :status :tag v-model:isSyncing="isSyncing" />
<List ref="mlist" :isPC :isAdmin :search :status :tag v-model:isSyncing="isSyncing" v-model:isChangelog="isChangelog" />
<div class="text-center page-nav"></div>
<div class="text-center mt-3">
<a href="https://beian.miit.gov.cn/" target="_blank">闽ICP备2023011626号-1</a> |
Expand All @@ -215,7 +218,8 @@ const isSyncing = ref(false);
Frontend by <a href="https://github.com/xuanzhi33">@xuanzhi33</a> |
Backend by <a href="https://github.com/BLxcwg666">@BLxcwg666</a> |
<a href="https://github.com/travellings-link/travellings-mlist" target="_blank"><i class="fa fa-github"></i> {{
t('sourceCode') }}</a>
t('sourceCode') }}</a> |
<a href="javascript:;" @click="isChangelog = true"><i class="fa fa-history"></i> {{ t('changelog') }}</a>
</div>
</div>
</div>
Expand Down
112 changes: 112 additions & 0 deletions src/components/Changelog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<script setup>
import { ref, onMounted, onUnmounted, watch, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import Modal from './Modal.vue';
const isOpen = defineModel();
const loading = ref(false);
const datetimeFormats = {
en: {
long: {
year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric'
}
},
zh: {
long: {
year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric'
}
}
}
const { t, d } = useI18n({
datetimeFormats,
messages: {
zh: {
close: "关闭",
changelog: "更新日志",
dataInfo: "仅显示最近的 5 条更新",
loading: "正在从 Github 获取数据...",
time: "时间",
change: "Git 提交",
commiter: "提交者",
sha: "提交 SHA",
seeAllFromGithub: "在 Github 查看更多"
},
en: {
close: "Close",
changelog: "Changelog",
dataInfo: "Only show the latest 5 updates",
loading: "Getting data from Github...",
time: "Time",
change: "Git Commit",
commiter: "Commiter",
sha: "Commit SHA",
seeAllFromGithub: "See more on Github"
}
}
});
const commitsApi = async () => {
const timestamp = new Date().getTime();
const res = await fetch("https://api.github.com/repos/travellings-link/travellings-mlist/commits?per_page=5&_t=" + timestamp);
return await res.json();
}
const changelogs = ref([]);
const getCommits = async () => {
loading.value = true;
changelogs.value = await commitsApi();
loading.value = false;
}
const ISOToTime = ISO => {
return new Date(ISO);
}
watch(isOpen, (val) => {
if (val) {
getCommits();
}
});
</script>

<template>
<Modal v-model="isOpen">

<h4 class="modal-title"> {{ t("changelog") }} </h4>

<div>{{ t("dataInfo") }}</div>
<table class="table mt-3">
<thead>
<th>{{ t("time") }}</th>
<th>{{ t("change") }}</th>
<th>{{ t("commiter") }}</th>
</thead>
<tbody>
<template v-if="loading">
<tr>
<td colspan="3" class="text-center">
<span class="spinner-border spinner-border-sm"></span>
{{ t("loading") }}
</td>
</tr>
</template>
<template v-else>
<tr v-for="item in changelogs">
<td>{{ d(ISOToTime(item.commit.author.date), "long") }}</td>
<td>{{ item.commit.message }}</td>
<td>{{ item.commit.author.name }}</td>
</tr>
</template>
</tbody>
</table>

<button type="button" class="btn btn-secondary" @click="isOpen = false">{{ t("close") }}</button>
<a class="btn btn-info" href="https://github.com/travellings-link/travellings-mlist/commits/main/" target="_blank">{{ t("seeAllFromGithub") }}</a>
</Modal>
</template>
10 changes: 8 additions & 2 deletions src/components/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import EditItem from './EditItem.vue';
import Report from './Report.vue';
import Sync from './Sync.vue';
import ApplyEdit from './ApplyEdit.vue';
import Changelog from './Changelog.vue';
const props = defineProps({
search: {
Expand Down Expand Up @@ -48,7 +49,8 @@ const { t } = useI18n({
delete: "删除",
edit: "编辑",
confirmDelete: "确定删除ID为 {id} 的站点 {name} 吗?",
deleteSuccess: "删除成功"
deleteSuccess: "删除成功",
changelog: "更新日志"
},
en: {
siteName: "Site Name",
Expand All @@ -66,7 +68,8 @@ const { t } = useI18n({
delete: "Delete",
edit: "Edit",
confirmDelete: "Delete site {name} with ID {id}?",
deleteSuccess: "Deleted successfully"
deleteSuccess: "Deleted successfully",
changelog: "Changelog"
}
}
});
Expand Down Expand Up @@ -207,6 +210,8 @@ const applyEditItem = item => {
applyingItem.value = item;
}
const isChangelog = defineModel("isChangelog");
</script>

<template>
Expand Down Expand Up @@ -303,4 +308,5 @@ const applyEditItem = item => {
<Report v-model="isReporting" :report-id="reportId" />
<Sync v-model="isSyncing" @get-data="getDataAndGoToEnd" />
<ApplyEdit v-model="isApplyEdit" :item="applyingItem" />
<Changelog v-model="isChangelog" />
</template>

2 comments on commit 5139d65

@linlinzzo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xuanzhi33 这个是类似操作日志吗

@xuanzhi33
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

就是git提交记录

Please sign in to comment.