mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-31 13:21:01 +08:00
添加国际化支持:引入 vue-i18n,更新多个组件以支持语言切换和文本翻译
This commit is contained in:
@@ -3,18 +3,20 @@ import VerticalNavSectionTitle from '@/@layouts/components/VerticalNavSectionTit
|
||||
import VerticalNavLayout from '@layouts/components/VerticalNavLayout.vue'
|
||||
import VerticalNavLink from '@layouts/components/VerticalNavLink.vue'
|
||||
import Footer from '@/layouts/components/Footer.vue'
|
||||
import NavbarThemeSwitcher from '@/layouts/components/NavbarThemeSwitcher.vue'
|
||||
import NavbarActions from '@/layouts/components/NavbarActions.vue'
|
||||
import UserNofification from '@/layouts/components/UserNotification.vue'
|
||||
import SearchBar from '@/layouts/components/SearchBar.vue'
|
||||
import ShortcutBar from '@/layouts/components/ShortcutBar.vue'
|
||||
import UserProfile from '@/layouts/components/UserProfile.vue'
|
||||
import { useUserStore } from '@/stores'
|
||||
import { SystemNavMenus } from '@/router/menu'
|
||||
import { getNavMenus } from '@/router/i18n-menu'
|
||||
import { NavMenu } from '@/@layouts/types'
|
||||
import { useDisplay } from 'vuetify'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const display = useDisplay()
|
||||
const appMode = inject('pwaMode')
|
||||
const { t } = useI18n()
|
||||
|
||||
// 用户 Store
|
||||
const userStore = useUserStore()
|
||||
@@ -39,7 +41,9 @@ const systemMenus = ref<NavMenu[]>([])
|
||||
|
||||
// 根据分类获取菜单列表
|
||||
const getMenuList = (header: string) => {
|
||||
return SystemNavMenus.filter((item: NavMenu) => item.header === header && (superUser || !item.admin))
|
||||
// 使用国际化菜单
|
||||
const menus = getNavMenus()
|
||||
return menus.filter((item: NavMenu) => item.header === header && (superUser || !item.admin))
|
||||
}
|
||||
|
||||
// 返回上一页
|
||||
@@ -49,11 +53,11 @@ function goBack() {
|
||||
|
||||
onMounted(() => {
|
||||
// 获取菜单列表
|
||||
startMenus.value = getMenuList('开始')
|
||||
discoveryMenus.value = getMenuList('发现')
|
||||
subscribeMenus.value = getMenuList('订阅')
|
||||
organizeMenus.value = getMenuList('整理')
|
||||
systemMenus.value = getMenuList('系统')
|
||||
startMenus.value = getMenuList(t('menu.start'))
|
||||
discoveryMenus.value = getMenuList(t('menu.discovery'))
|
||||
subscribeMenus.value = getMenuList(t('menu.subscribe'))
|
||||
organizeMenus.value = getMenuList(t('menu.organize'))
|
||||
systemMenus.value = getMenuList(t('menu.system'))
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -74,10 +78,10 @@ onMounted(() => {
|
||||
<SearchBar />
|
||||
<!-- 👉 Spacer -->
|
||||
<VSpacer />
|
||||
<!-- 👉 Theme & Language -->
|
||||
<NavbarActions />
|
||||
<!-- 👉 Shortcuts -->
|
||||
<ShortcutBar v-if="superUser" />
|
||||
<!-- 👉 Theme -->
|
||||
<NavbarThemeSwitcher />
|
||||
<!-- 👉 Notification -->
|
||||
<UserNofification />
|
||||
<!-- 👉 UserProfile -->
|
||||
@@ -91,7 +95,7 @@ onMounted(() => {
|
||||
<VerticalNavSectionTitle
|
||||
v-if="discoveryMenus.length > 0"
|
||||
:item="{
|
||||
heading: '发现',
|
||||
heading: t('menu.discovery'),
|
||||
}"
|
||||
/>
|
||||
<VerticalNavLink v-for="item in discoveryMenus" :item="item" />
|
||||
@@ -99,7 +103,7 @@ onMounted(() => {
|
||||
<VerticalNavSectionTitle
|
||||
v-if="subscribeMenus.length > 0"
|
||||
:item="{
|
||||
heading: '订阅',
|
||||
heading: t('menu.subscribe'),
|
||||
}"
|
||||
/>
|
||||
<VerticalNavLink v-for="item in subscribeMenus" :item="item" />
|
||||
@@ -107,7 +111,7 @@ onMounted(() => {
|
||||
<VerticalNavSectionTitle
|
||||
v-if="organizeMenus.length > 0"
|
||||
:item="{
|
||||
heading: '整理',
|
||||
heading: t('menu.organize'),
|
||||
}"
|
||||
/>
|
||||
<VerticalNavLink v-for="item in organizeMenus" :item="item" />
|
||||
@@ -115,7 +119,7 @@ onMounted(() => {
|
||||
<VerticalNavSectionTitle
|
||||
v-if="systemMenus.length > 0"
|
||||
:item="{
|
||||
heading: '系统',
|
||||
heading: t('menu.system'),
|
||||
}"
|
||||
/>
|
||||
<VerticalNavLink v-for="item in systemMenus" :item="item" />
|
||||
|
||||
Reference in New Issue
Block a user