CustomLayout.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 { Right } from "@element-plus/icons-vue";
  7. import i18n from "@/plugins/i18n";
  8. const Layout = DefaultTheme.Layout;
  9. const { lang, localeIndex } = useData();
  10. const { t } = useI18n();
  11. watchEffect(() => {
  12. i18n.global.locale.value = lang.value;
  13. });
  14. const docsLink = computed(() => {
  15. return withBase(`/${localeIndex.value === "root" ? "" : localeIndex.value + "/"}docs`);
  16. });
  17. </script>
  18. <template>
  19. <Layout>
  20. <template #nav-bar-content-before>
  21. <a :href="docsLink" class="content-before">{{ t("帮助中心") }}</a>
  22. </template>
  23. <template #nav-bar-content-after>
  24. <a href="https://cloud.cocorobo.cn" class="content-after">
  25. {{ t("可可智慧教育平台") }}
  26. <el-icon color="white" size="18" class="content-after__arrow">
  27. <Right />
  28. </el-icon>
  29. </a>
  30. </template>
  31. </Layout>
  32. </template>
  33. <i18n locale="zh-HK">
  34. {
  35. "帮助中心": "幫助中心",
  36. "可可智慧教育平台": "CocoClass"
  37. }
  38. </i18n>
  39. <i18n locale="en-US">
  40. {
  41. "帮助中心": "Help Center",
  42. "可可智慧教育平台": "CocoClass"
  43. }
  44. </i18n>
  45. <style scoped lang="scss">
  46. @use '@/.vitepress/theme/screen' as *;
  47. .content-before {
  48. @include breakpoint(mobile) {
  49. font-size: 12px;
  50. margin: 0;
  51. }
  52. color: #2e5aa8;
  53. font-size: 16px;
  54. font-weight: 600;
  55. line-height: 24px;
  56. margin: 0 14px;
  57. }
  58. .content-after {
  59. @include breakpoint(mobile) {
  60. display: none;
  61. }
  62. color: #2e5aa8;
  63. padding: 4px 12px;
  64. display: flex;
  65. align-items: center;
  66. gap: 8px;
  67. border: 1.5px solid #2e5aa8;
  68. border-radius: 100px;
  69. &__arrow {
  70. padding: 2px;
  71. background: #2e5aa8;
  72. border-radius: 50%;
  73. }
  74. }
  75. </style>