Update i18n
This commit is contained in:
parent
959bb1867c
commit
5d751fe9dd
@ -1,15 +1,15 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { sStorage } from '@/utils'
|
||||
import { lStorage } from '@/utils'
|
||||
|
||||
import messages from './messages'
|
||||
|
||||
const currentLocale = sStorage.get('locale')
|
||||
const currentLocale = lStorage.get('locale')
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
globalInjection: true,
|
||||
locale: currentLocale || 'en',
|
||||
fallbackLocale: 'en',
|
||||
locale: currentLocale || 'cn',
|
||||
fallbackLocale: 'cn',
|
||||
messages: messages,
|
||||
})
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
<script setup>
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useAppStore } from '@/store'
|
||||
import { router } from '~/src/router'
|
||||
|
||||
const store = useAppStore()
|
||||
const { availableLocales, t } = useI18n()
|
||||
@ -26,5 +27,7 @@ const options = computed(() => {
|
||||
|
||||
const handleChangeLocale = (value) => {
|
||||
store.setLocale(value)
|
||||
// reload page
|
||||
router.go()
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { useDark } from '@vueuse/core'
|
||||
import { sStorage } from '@/utils'
|
||||
import { lStorage } from '@/utils'
|
||||
import i18n from '~/i18n'
|
||||
|
||||
const currentLocale = sStorage.get('locale')
|
||||
const currentLocale = lStorage.get('locale')
|
||||
const { locale } = i18n.global
|
||||
|
||||
const isDark = useDark()
|
||||
@ -54,7 +54,7 @@ export const useAppStore = defineStore('app', {
|
||||
setLocale(newLocale) {
|
||||
this.locale = newLocale
|
||||
locale.value = newLocale
|
||||
sStorage.set('locale', newLocale)
|
||||
lStorage.set('locale', newLocale)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { sStorage } from '@/utils'
|
||||
import { lStorage } from '@/utils'
|
||||
|
||||
export const activeTag = sStorage.get('activeTag')
|
||||
export const tags = sStorage.get('tags')
|
||||
export const activeTag = lStorage.get('activeTag')
|
||||
export const tags = lStorage.get('tags')
|
||||
|
||||
export const WITHOUT_TAG_PATHS = ['/404', '/login']
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { activeTag, tags, WITHOUT_TAG_PATHS } from './helpers'
|
||||
import { router } from '@/router'
|
||||
import { sStorage } from '@/utils'
|
||||
import { lStorage } from '@/utils'
|
||||
|
||||
export const useTagsStore = defineStore('tag', {
|
||||
state() {
|
||||
@ -18,11 +18,11 @@ export const useTagsStore = defineStore('tag', {
|
||||
actions: {
|
||||
setActiveTag(path) {
|
||||
this.activeTag = path
|
||||
sStorage.set('activeTag', path)
|
||||
lStorage.set('activeTag', path)
|
||||
},
|
||||
setTags(tags) {
|
||||
this.tags = tags
|
||||
sStorage.set('tags', tags)
|
||||
lStorage.set('tags', tags)
|
||||
},
|
||||
addTag(tag = {}) {
|
||||
this.setActiveTag(tag.path)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user