CustomLayout.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. "可可智慧教育平台": "可可智慧教育平台"
  37. }
  38. </i18n>
  39. <i18n locale="en-US">
  40. {
  41. "帮助中心": "Help Center",
  42. "可可智慧教育平台": "CocoClass"
  43. }
  44. </i18n>
  45. <style scoped lang="scss">
  46. .content-before {
  47. color: #2e5aa8;
  48. font-size: 16px;
  49. font-weight: 600;
  50. line-height: 24px;
  51. margin-left: 14px;
  52. }
  53. .content-after {
  54. color: #2e5aa8;
  55. padding: 4px 12px;
  56. display: flex;
  57. align-items: center;
  58. gap: 8px;
  59. border: 1.5px solid #2e5aa8;
  60. border-radius: 100px;
  61. &__arrow {
  62. padding: 2px;
  63. background: #2e5aa8;
  64. border-radius: 50%;
  65. }
  66. }
  67. </style>