Skip to content

Commit

Permalink
Merge pull request #523 from terwer/dev
Browse files Browse the repository at this point in the history
fix: support lang
  • Loading branch information
terwer authored Nov 19, 2024
2 parents 64684b2 + 4607658 commit 0bb13d2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions components/static/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script setup lang="ts">
import { useStaticSettingStore } from "~/stores/useStaticSettingStore"
import { useI18n } from "vue-i18n"
const { locale } = useI18n()
const { getStaticSetting } = useStaticSettingStore()
const setting = await getStaticSetting()
await useStaticThemeMode()
Expand All @@ -10,6 +12,14 @@ const VNode = () =>
class: "",
innerHTML: setting.footer ?? "",
})
// lifecycles
onBeforeMount(() => {
// 设置默认语言
if (setting?.lang) {
locale.value = setting?.lang
}
})
</script>

<template>
Expand Down
4 changes: 3 additions & 1 deletion components/static/Outline.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div class="outline-title">
<a class="outline-title-link"> {{ "文档大纲" }} </a>
<a class="outline-title-link"> {{ t("static.outline") }} </a>
</div>
<div v-for="(item, index) in outlineData" :key="index">
<outline-item :item="item" :max-depth="maxDepth" :root-level="getRootLevel(item)" :is-root="true" />
Expand All @@ -23,6 +23,8 @@ const props = defineProps({
},
})
const { t } = useI18n()
const getRootLevel = () => {
if (props.outlineData.length === 0) return 1 // 如果数据为空,返回默认级别 1
Expand Down
2 changes: 2 additions & 0 deletions locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ export default {

"page.sidebar.expand.all": "Expand all",
"page.sidebar.collapse.all": "Collapse all",

"static.outline": "Document outline",
}
2 changes: 2 additions & 0 deletions locales/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,6 @@ export default {

"page.sidebar.expand.all": "展开全部",
"page.sidebar.collapse.all": "折叠全部",

"static.outline": "文档大纲",
}

0 comments on commit 0bb13d2

Please sign in to comment.