feat: init
This commit is contained in:
22
src/hooks/locale.ts
Normal file
22
src/hooks/locale.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
export default function useLocale() {
|
||||
const i18 = useI18n()
|
||||
const currentLocale = computed(() => {
|
||||
return i18.locale.value
|
||||
})
|
||||
const changeLocale = (value: string) => {
|
||||
if (i18.locale.value === value) {
|
||||
return
|
||||
}
|
||||
i18.locale.value = value
|
||||
localStorage.setItem('arco-locale', value)
|
||||
Message.success(i18.t('navbar.action.locale'))
|
||||
}
|
||||
return {
|
||||
currentLocale,
|
||||
changeLocale,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user