Client - minor refacto
This commit is contained in:
@ -1,12 +1,15 @@
|
||||
import { ActionContext, ActionTree } from 'vuex'
|
||||
|
||||
import authApi from '@/api/authApi'
|
||||
import createI18n from '@/i18n'
|
||||
import router from '@/router'
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IRootActions, IRootState } from '@/store/modules/root/types'
|
||||
import { TAppConfigForm } from '@/types/application'
|
||||
import { handleError } from '@/utils'
|
||||
|
||||
const { locale } = createI18n.global
|
||||
|
||||
export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
||||
[ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
|
||||
context: ActionContext<IRootState, IRootState>
|
||||
@ -68,4 +71,12 @@ export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE](
|
||||
context: ActionContext<IRootState, IRootState>,
|
||||
language: string
|
||||
): void {
|
||||
document.querySelector('html')?.setAttribute('lang', language)
|
||||
context.commit(ROOT_STORE.MUTATIONS.UPDATE_LANG, language)
|
||||
locale.value = language
|
||||
},
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ export enum RootActions {
|
||||
GET_APPLICATION_CONFIG = 'GET_APPLICATION_CONFIG',
|
||||
GET_APPLICATION_STATS = 'GET_APPLICATION_STATS',
|
||||
UPDATE_APPLICATION_CONFIG = 'UPDATE_APPLICATION_CONFIG',
|
||||
UPDATE_APPLICATION_LANGUAGE = 'UPDATE_APPLICATION_LANGUAGE',
|
||||
}
|
||||
|
||||
export enum RootGetters {
|
||||
|
@ -34,6 +34,10 @@ export interface IRootActions {
|
||||
context: ActionContext<IRootState, IRootState>,
|
||||
payload: TAppConfigForm
|
||||
): void
|
||||
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE](
|
||||
context: ActionContext<IRootState, IRootState>,
|
||||
langauge: string
|
||||
): void
|
||||
}
|
||||
|
||||
export interface IRootGetters {
|
||||
|
Reference in New Issue
Block a user