mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 21:28:06 +00:00
feat: save lang to localStorage
This commit is contained in:
parent
91fac552e0
commit
281f9fe0bc
5 changed files with 67 additions and 50 deletions
|
|
@ -9,18 +9,18 @@
|
|||
/></button-icon>
|
||||
</div>
|
||||
<div class="navigation-links">
|
||||
<router-link to="/" :class="{ active: this.$route.name === 'home' }"
|
||||
>{{ $t('nav.home') }}</router-link
|
||||
>
|
||||
<router-link to="/" :class="{ active: this.$route.name === 'home' }">{{
|
||||
$t("nav.home")
|
||||
}}</router-link>
|
||||
<router-link
|
||||
to="/explore"
|
||||
:class="{ active: this.$route.name === 'explore' }"
|
||||
>{{ $t('nav.explore') }}</router-link
|
||||
>{{ $t("nav.explore") }}</router-link
|
||||
>
|
||||
<router-link
|
||||
to="/library"
|
||||
:class="{ active: this.$route.name === 'library' }"
|
||||
>{{ $t('nav.library') }}</router-link
|
||||
>{{ $t("nav.library") }}</router-link
|
||||
>
|
||||
</div>
|
||||
<div class="right-part">
|
||||
|
|
@ -42,8 +42,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="locale-changer" @click="changeLang">
|
||||
<svg-icon icon-class="translation" class="translation"
|
||||
/>
|
||||
<svg-icon icon-class="translation" class="translation" />
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
@ -55,13 +54,13 @@ import ButtonIcon from "@/components/ButtonIcon.vue";
|
|||
export default {
|
||||
name: "Navbar",
|
||||
components: {
|
||||
ButtonIcon,
|
||||
ButtonIcon
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
inputFocus: false,
|
||||
keywords: "",
|
||||
langs: ['zh-CN', 'en']
|
||||
langs: ["zh-CN", "en"]
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -71,19 +70,27 @@ export default {
|
|||
},
|
||||
goToSearchPage() {
|
||||
if (!this.keywords) return;
|
||||
if (this.$route.name === 'search' && this.$route.query.keywords === this.keywords) return;
|
||||
if (
|
||||
this.$route.name === "search" &&
|
||||
this.$route.query.keywords === this.keywords
|
||||
)
|
||||
return;
|
||||
this.$router.push({
|
||||
name: "search",
|
||||
query: { keywords: this.keywords },
|
||||
query: { keywords: this.keywords }
|
||||
});
|
||||
},
|
||||
changeLang() {
|
||||
let lang = "";
|
||||
if (this.$i18n.locale === "zh-CN") {
|
||||
return this.$i18n.locale = "en";
|
||||
lang = "en";
|
||||
} else {
|
||||
lang = "zh-CN";
|
||||
}
|
||||
this.$i18n.locale = "zh-CN";
|
||||
this.$i18n.locale = lang;
|
||||
this.$store.commit("changeLang", lang);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
@ -215,6 +222,4 @@ nav {
|
|||
width: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue