fix(theme): locales selector not rendering correctly on mobile, close #640 (#641)

This commit is contained in:
pengzhanbo 2025-07-08 14:26:51 +08:00 committed by GitHub
parent 534683817e
commit 57d08bd501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View File

@ -9,14 +9,14 @@ const { currentLang, localeLinks } = useLangs()
<template>
<VPFlyout
v-if="localeLinks.length && currentLang.label"
v-if="localeLinks.length && currentLang.text"
class="vp-navbar-translations"
icon="vpi-languages"
:label="theme.selectLanguageText || 'Change Language'"
>
<div class="items">
<p class="title">
{{ currentLang.label }}
{{ currentLang.text }}
</p>
<template v-for="locale in localeLinks" :key="locale.link">

View File

@ -16,13 +16,13 @@ function toggle() {
<template>
<div
v-if="localeLinks.length && currentLang.label"
v-if="localeLinks.length && currentLang.text"
class="vp-nav-screen-translations"
:class="{ open: isOpen }"
>
<button class="title" @click="toggle">
<span class="vpi-languages icon lang" />
{{ currentLang.label }}
{{ currentLang.text }}
<span class="vpi-chevron-down icon chevron" />
</button>
@ -31,7 +31,7 @@ function toggle() {
<ul class="list">
<li v-for="locale in localeLinks" :key="locale.link" class="item">
<VPLink class="link" :href="locale.link">
{{ locale.label }}
{{ locale.text }}
</VPLink>
</li>
</ul>

View File

@ -8,7 +8,7 @@ import { useBlogPageData } from './page.js'
import { useThemeData } from './theme-data.js'
interface Lang {
label?: string
text?: string
link: string
}
@ -32,7 +32,7 @@ export function useLangs({
const currentLang = computed(() => {
const link = routeLocale.value
return {
label: theme.value.locales?.[link]?.selectLanguageName,
text: theme.value.locales?.[link]?.selectLanguageName,
link,
}
})
@ -67,7 +67,7 @@ export function useLangs({
const localeLinks = computed(() =>
Object.entries(theme.value.locales || {}).flatMap(([key, locale]) =>
removeCurrent && currentLang.value.label === locale.selectLanguageName
removeCurrent && currentLang.value.text === locale.selectLanguageName
? []
: {
text: locale.selectLanguageName,