Client - fix type errors
This commit is contained in:
@ -6,6 +6,7 @@ import router from '@/router'
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import type { IRootActions, IRootState } from '@/store/modules/root/types'
|
||||
import type { TAppConfigForm } from '@/types/application'
|
||||
import type { TLanguage } from '@/types/locales'
|
||||
import { handleError } from '@/utils'
|
||||
|
||||
const { locale } = createI18n.global
|
||||
@ -91,7 +92,7 @@ export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
||||
},
|
||||
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE](
|
||||
context: ActionContext<IRootState, IRootState>,
|
||||
language: string
|
||||
language: TLanguage
|
||||
): void {
|
||||
document.querySelector('html')?.setAttribute('lang', language)
|
||||
context.commit(ROOT_STORE.MUTATIONS.UPDATE_LANG, language)
|
||||
|
@ -3,6 +3,7 @@ import type { MutationTree } from 'vuex'
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import type { IRootState, TRootMutations } from '@/store/modules/root/types'
|
||||
import type { TAppConfig, IAppStatistics } from '@/types/application'
|
||||
import type { TLanguage } from '@/types/locales'
|
||||
import { localeFromLanguage } from '@/utils/locales'
|
||||
|
||||
export const mutations: MutationTree<IRootState> & TRootMutations = {
|
||||
@ -40,7 +41,7 @@ export const mutations: MutationTree<IRootState> & TRootMutations = {
|
||||
) {
|
||||
state.application.statistics = statistics
|
||||
},
|
||||
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: IRootState, language: string) {
|
||||
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: IRootState, language: TLanguage) {
|
||||
state.language = language
|
||||
state.locale = localeFromLanguage[language]
|
||||
},
|
||||
|
@ -13,10 +13,11 @@ import type {
|
||||
IAppStatistics,
|
||||
TAppConfigForm,
|
||||
} from '@/types/application'
|
||||
import type { TLanguage } from '@/types/locales'
|
||||
|
||||
export interface IRootState {
|
||||
root: boolean
|
||||
language: string
|
||||
language: TLanguage
|
||||
locale: Locale
|
||||
errorMessages: string | string[] | null
|
||||
application: IApplication
|
||||
@ -39,7 +40,7 @@ export interface IRootActions {
|
||||
): void
|
||||
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE](
|
||||
context: ActionContext<IRootState, IRootState>,
|
||||
langauge: string
|
||||
language: TLanguage
|
||||
): void
|
||||
}
|
||||
|
||||
@ -54,7 +55,7 @@ export interface IRootGetters {
|
||||
state: IRootState
|
||||
): string | string[] | null
|
||||
|
||||
[ROOT_STORE.GETTERS.LANGUAGE](state: IRootState): string
|
||||
[ROOT_STORE.GETTERS.LANGUAGE](state: IRootState): TLanguage
|
||||
|
||||
[ROOT_STORE.GETTERS.LOCALE](state: IRootState): Locale
|
||||
}
|
||||
@ -81,7 +82,7 @@ export type TRootMutations<S = IRootState> = {
|
||||
state: S,
|
||||
statistics: IAppStatistics
|
||||
): void
|
||||
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: S, language: string): void
|
||||
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: S, language: TLanguage): void
|
||||
}
|
||||
|
||||
export type TRootStoreModule<S = IRootState> = Omit<
|
||||
|
Reference in New Issue
Block a user