2021-09-24 01:19:18 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { onMounted, ref } from 'vue'
|
|
|
|
import axios from 'axios'
|
|
|
|
import VPLink from '../common/vp-link.vue'
|
|
|
|
import VPMarkdown from '../common/vp-markdown.vue'
|
|
|
|
import { useLang } from '../../composables/lang'
|
|
|
|
import { useLocale } from '../../composables/locale'
|
|
|
|
import changelogLocale from '../../../i18n/component/changelog.json'
|
|
|
|
|
2021-10-22 12:35:41 +08:00
|
|
|
interface Release {
|
|
|
|
id: number
|
|
|
|
name: string
|
|
|
|
}
|
|
|
|
|
2021-09-24 01:19:18 +08:00
|
|
|
const loading = ref(true)
|
2021-10-22 12:35:41 +08:00
|
|
|
const releases = ref<Release[]>([])
|
2021-09-24 01:19:18 +08:00
|
|
|
const currentRelease = ref()
|
|
|
|
const changelog = useLocale(changelogLocale)
|
|
|
|
const lang = useLang()
|
|
|
|
|
|
|
|
const onVersionChange = (val) => {
|
|
|
|
const _releases = releases.value
|
|
|
|
currentRelease.value = _releases[_releases.findIndex((r) => r.name === val)]
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
try {
|
2021-10-22 12:35:41 +08:00
|
|
|
const { data } = await axios.get<Release[]>(
|
2021-09-24 01:19:18 +08:00
|
|
|
'https://api.github.com/repos/element-plus/element-plus/releases'
|
|
|
|
)
|
|
|
|
releases.value = data
|
|
|
|
currentRelease.value = data[0]
|
|
|
|
} catch (e) {
|
|
|
|
releases.value = []
|
|
|
|
currentRelease.value = undefined
|
|
|
|
// do something
|
|
|
|
} finally {
|
|
|
|
loading.value = false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="changelogs">
|
|
|
|
<ClientOnly>
|
|
|
|
<ElSkeleton :loading="loading">
|
|
|
|
<div class="changelog-versions">
|
|
|
|
<p>{{ changelog['select-version'] }}:</p>
|
|
|
|
<ElSelect
|
|
|
|
:model-value="currentRelease.name"
|
|
|
|
:placeholder="changelog['select-version']"
|
|
|
|
style="min-width: 200px"
|
|
|
|
@change="onVersionChange"
|
|
|
|
>
|
|
|
|
<ElOption
|
|
|
|
v-for="release in releases"
|
|
|
|
:key="release.id"
|
|
|
|
:value="release.name"
|
|
|
|
>
|
|
|
|
{{ release.name }}
|
|
|
|
</ElOption>
|
|
|
|
</ElSelect>
|
|
|
|
</div>
|
|
|
|
<ElCard v-if="currentRelease">
|
|
|
|
<template #header>
|
|
|
|
<div class="changelog-header">
|
|
|
|
<div class="changelog-meta">
|
|
|
|
<p class="changelog-by">
|
|
|
|
{{ changelog['published-by'] }}
|
|
|
|
<strong>{{ currentRelease.author.login }}</strong>
|
|
|
|
</p>
|
|
|
|
<p class="changelog-date">
|
|
|
|
{{
|
|
|
|
new Date(currentRelease.published_at).toLocaleString(lang)
|
|
|
|
}}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="operators">
|
|
|
|
<VPLink :href="currentRelease.html_url">
|
|
|
|
{{ changelog['open-link'] }}
|
|
|
|
</VPLink>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div>
|
|
|
|
<VPMarkdown :content="currentRelease.body" />
|
|
|
|
</div>
|
|
|
|
</ElCard>
|
|
|
|
</ElSkeleton>
|
|
|
|
</ClientOnly>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.changelog-versions {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2021-09-25 02:18:22 +08:00
|
|
|
justify-content: space-between;
|
2021-09-24 01:19:18 +08:00
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
|
|
|
p {
|
|
|
|
margin-right: 2rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.changelog-header {
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-start;
|
2021-09-25 02:18:22 +08:00
|
|
|
justify-content: space-between;
|
2021-09-24 01:19:18 +08:00
|
|
|
|
|
|
|
.changelog-meta {
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
flex-direction: column;
|
|
|
|
p {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.link-item {
|
|
|
|
line-height: 1.7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|