-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
对AppFooter.vue组件进行了重构,添加了动态key和路由监听功能,以及根据Frontmatter隐藏GitChangelog的逻辑。
- Loading branch information
Showing
1 changed file
with
19 additions
and
3 deletions.
There are no files selected for viewing
22 changes: 19 additions & 3 deletions
22
packages/vitepress-theme-project-trans/src/components/AppFooter.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
<script setup lang="ts"> | ||
import { NolebaseGitChangelog } from '@nolebase/vitepress-plugin-git-changelog/client' | ||
import { ref, watch } from 'vue'; | ||
import { NolebaseGitChangelog } from '@nolebase/vitepress-plugin-git-changelog/client'; | ||
import { useRoute } from 'vitepress'; | ||
const route = useRoute(); | ||
// 定义一个 ref 来存储动态 key | ||
const componentKey = ref(0); | ||
const frontmatter = ref({}); | ||
// 监听路由变化,更新 key 和 frontmatter | ||
watch(() => route.path, () => { | ||
componentKey.value += 1; | ||
// 获取 Frontmatter | ||
frontmatter.value = route.data?.frontmatter || {}; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="vp-doc"> | ||
<div :key="componentKey" class="vp-doc"> | ||
<h2 id="意见反馈"> | ||
意见反馈 | ||
</h2> | ||
<AppSBox /> | ||
<NolebaseGitChangelog /> | ||
<!-- 仅在 Frontmatter 中未设置 hideChangelog 时渲染 GitChangelog --> | ||
<NolebaseGitChangelog v-if="!frontmatter.hideChangelog" /> | ||
</div> | ||
</template> |