Skip to content

Commit

Permalink
refactor: 更新AppFooter.vue组件
Browse files Browse the repository at this point in the history
对AppFooter.vue组件进行了重构,添加了动态key和路由监听功能,以及根据Frontmatter隐藏GitChangelog的逻辑。
  • Loading branch information
Leetfs committed Sep 9, 2024
1 parent 4c72a9d commit a28d468
Showing 1 changed file with 19 additions and 3 deletions.
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>

0 comments on commit a28d468

Please sign in to comment.