mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[Axios] Error logger
This commit is contained in:
1 parent
886a44229f
commit
da63ed5ed2
1 file changed
+22
-9
@@ -1,8 +1,8 @@
|
|||||||
import { Language, Options } from "../types"
|
import { Language, Options } from "../types"
|
||||||
import { Ref, ref } from 'vue'
|
import { Ref, ref } from 'vue'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { createI18n, I18n as I18nType } from 'vue-i18n'
|
import { createI18n, I18n as I18nType } from 'vue-i18n'
|
||||||
import { Preferences } from '@capacitor/preferences'
|
import { Preferences } from '@capacitor/preferences'
|
||||||
|
|
||||||
|
|
||||||
export class I18n {
|
export class I18n {
|
||||||
@@ -15,10 +15,10 @@ export class I18n {
|
|||||||
|
|
||||||
constructor(properties: Options) {
|
constructor(properties: Options) {
|
||||||
this.availableLanguages = properties.languages || []
|
this.availableLanguages = properties.languages || []
|
||||||
this.defaultLanguage = properties.languages.find(language => language.value == properties.defaultLanguage)
|
this.defaultLanguage = properties.languages.find(language => language.value == properties.defaultLanguage)
|
||||||
this.languageKey = properties.languageKey || process.env.VUE_APP_PLATFORM + '_language' || 'w18n_language'
|
this.languageKey = properties.languageKey || process.env.VUE_APP_PLATFORM + '_language' || 'w18n_language'
|
||||||
|
|
||||||
this.vendorI18n = createI18n({
|
this.vendorI18n = createI18n({
|
||||||
legacy: true,
|
legacy: true,
|
||||||
fallbackLocale: this.defaultLanguage.value,
|
fallbackLocale: this.defaultLanguage.value,
|
||||||
messages: this._loadLocaleMessages(),
|
messages: this._loadLocaleMessages(),
|
||||||
@@ -26,7 +26,7 @@ export class I18n {
|
|||||||
postTranslation: this._postTranslation,
|
postTranslation: this._postTranslation,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.changeLanguage({title: "Slovenský", flag: "sk", value: "sk"})
|
this.changeLanguage({ title: "Slovenský", flag: "sk", value: "sk" })
|
||||||
this.initCurrentLanguage()
|
this.initCurrentLanguage()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +76,19 @@ export class I18n {
|
|||||||
|
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// axios.interceptors.response.use(
|
||||||
|
// (response) => {
|
||||||
|
// return response
|
||||||
|
// },
|
||||||
|
// (error) => {
|
||||||
|
// axios.post('https://logger.wezeo.dev/api/v1/log', {
|
||||||
|
// data: JSON.stringify(error)
|
||||||
|
// })
|
||||||
|
|
||||||
|
// return Promise.reject(error)
|
||||||
|
// }
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
public _loadLocaleMessages(path = '@/locales') {
|
public _loadLocaleMessages(path = '@/locales') {
|
||||||
@@ -91,7 +104,7 @@ export class I18n {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const messages: {[key: string]: {[key: string]: string}} = {}
|
const messages: { [key: string]: { [key: string]: string } } = {}
|
||||||
|
|
||||||
locales.keys().forEach((key) => {
|
locales.keys().forEach((key) => {
|
||||||
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
|
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
|
||||||
|
|||||||
Reference in new issue
Block a user