CustomLayout.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script setup lang="ts">
  2. import { watchEffect, computed } from "vue";
  3. import DefaultTheme from "vitepress/theme";
  4. import { useI18n } from "vue-i18n";
  5. import { useData, withBase } from "vitepress";
  6. import i18n from "@/plugins/i18n";
  7. const Layout = DefaultTheme.Layout;
  8. const { lang, localeIndex } = useData();
  9. const { t } = useI18n();
  10. watchEffect(() => {
  11. i18n.global.locale.value = lang.value;
  12. });
  13. const docsLink = computed(() => {
  14. return withBase( `/${localeIndex.value === 'root' ? '' : localeIndex.value + '/'}docs` )
  15. })
  16. </script>
  17. <template>
  18. <Layout>
  19. <template #nav-bar-content-before>
  20. <a :href="docsLink" class="content-before">{{ t("帮助中心") }}</a>
  21. </template>
  22. <template #nav-bar-content-after>
  23. <a :href="docsLink" class="content-after">{{ t("CocoClass") }}</a>
  24. </template>
  25. </Layout>
  26. </template>
  27. <i18n locale="zh-HK">
  28. {
  29. "帮助中心": "幫助中心"
  30. }
  31. </i18n>
  32. <style scoped>
  33. .content-before {
  34. color: #2e5aa8;
  35. font-size: 16px;
  36. font-weight: 600;
  37. line-height: 24px;
  38. margin-left: 14px;
  39. }
  40. .content-after {
  41. color: #2e5aa8;
  42. /* TODO */
  43. }
  44. </style>