No configuration setup. Wordpress compatible.

This commit is contained in:
HenriT
2021-08-30 20:33:49 +03:00
parent e4e0c6cfb2
commit f3e7706506
4 changed files with 16 additions and 14 deletions

View File

@ -1,3 +1,8 @@
// const wordpress = window.name ? JSON.parse(window.name) : { front_url: '', api_url: '', nonce: '' };
export default {
storageType: 'local'
storageType: 'local',
// locales_url: wordpress.front_url,
// api_url: wordpress.api_url,
// api_nonce: wordpress.nonce,
};

View File

@ -4,6 +4,7 @@ import VueI18Next from '@panter/vue-i18next';
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import app from '@/main';
import config from '@/config/app.config';
Vue.use(VueI18Next);
@ -11,16 +12,11 @@ i18next
.use(LanguageDetector)
.use(Backend);
const path = window.name
? JSON.parse(window.name).front_url
: `${window.location.origin}${process.env.BASE_URL}`;
const initialized = i18next.init({
fallbackLng: 'en',
whitelist: ['en', 'fr', 'et', 'fa', 'bn', 'es'],
backend: {
loadPath: `${path}/locales/{{lng}}/{{ns}}.json`,
loadPath: config.locales_url || `${window.location.origin}${process.env.BASE_URL}/locales/{{lng}}/{{ns}}.json`,
},
detection: {
order: ['querystring', 'path', 'localStorage', 'navigator'],

View File

@ -1,14 +1,13 @@
import axios from 'axios';
import app from '@/main';
import config from '@/config/app.config';
import NotificationService from '@/services/notification.service';
import { removeVuexORMFlags } from '@/utils/helpers';
const config = window.name ? JSON.parse(window.name) : { front_url: '', api_url: '', nonce: '' };
const http = axios.create({
baseURL: config.api_url,
baseURL: config.api_url || '',
headers: {
'X-WP-Nonce': config.nonce,
'X-WP-Nonce': config.nonce || '',
},
});

View File

@ -7,11 +7,13 @@ class DataService {
adapter = null;
constructor() {
if (config.storageType === 'local') {
const type = config.storageType || 'local';
if (type === 'local') {
this.adapter = local;
} else if (config.storageType === 'http') {
} else if (type === 'http') {
this.adapter = http;
} else if (config.storageType === 'wordpress') {
} else if (type === 'wordpress') {
this.adapter = wordpress;
}
}