PASSAGGIO A VITE !
AGG. 1.1.23
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
import axios from 'axios'
|
||||
import { boot } from 'quasar/wrappers'
|
||||
import axios, { type AxiosInstance } from 'axios';
|
||||
|
||||
declare module 'vue' {
|
||||
interface ComponentCustomProperties {
|
||||
$axios: AxiosInstance;
|
||||
$api: AxiosInstance;
|
||||
}
|
||||
}
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: process.env.MONGODB_HOST,
|
||||
baseURL: import.meta.env.VITE_MONGODB_HOST,
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
@@ -11,15 +18,13 @@ const api = axios.create({
|
||||
export default boot(({ app }) => {
|
||||
// for use inside Vue files (Options API) through this.$axios and this.$api
|
||||
|
||||
app.config.globalProperties.$axios = axios
|
||||
app.config.globalProperties.$axios = axios;
|
||||
// ^ ^ ^ this will allow you to use this.$axios (for Vue Options API form)
|
||||
// so you won't necessarily have to import axios in each vue file
|
||||
|
||||
app.config.globalProperties.$api = api
|
||||
app.config.globalProperties.$api = api;
|
||||
// ^ ^ ^ this will allow you to use this.$api (for Vue Options API form)
|
||||
// so you can easily perform requests against your app's API
|
||||
//
|
||||
})
|
||||
});
|
||||
|
||||
export { axios }
|
||||
// export { axios, api }
|
||||
export { api };
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
import { boot } from 'quasar/wrappers'
|
||||
|
||||
import { useGlobalStore } from '@src/store/globalStore';
|
||||
import { useUserStore } from '@src/store/UserStore';
|
||||
import { tools } from '@src/store/Modules/tools';
|
||||
|
||||
export default boot(({ app, router }) => {
|
||||
// ******************************************
|
||||
@@ -19,13 +21,19 @@ export default boot(({ app, router }) => {
|
||||
// the subsequent Middleware function.
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
console.log('beforeEach ROUTER')
|
||||
console.log('beforeEach ROUTER', from, to )
|
||||
// Execute your command before each navigation
|
||||
// executeCommand();
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
const userStore = useUserStore()
|
||||
try {
|
||||
globalStore.editOn = false
|
||||
if (userStore.isLogged && from.path !== to.path) {
|
||||
// console.log('globalStore.editOn = false (prima era = ', globalStore.editOn, ')')
|
||||
const pageKey = to.path
|
||||
// console.log('pagek=', pageKey)
|
||||
globalStore.editOn = tools.getCookie('edn_' + pageKey, '0') === '1'
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,33 +1,23 @@
|
||||
// @ts-ignore
|
||||
// import { createI18n } from 'vue-i18n/index'
|
||||
import { createI18n } from 'vue-i18n/dist/vue-i18n.esm-bundler.js'
|
||||
import messages from '../statics/i18n'
|
||||
import { boot } from 'quasar/wrappers'
|
||||
// you'll need to create the src/i18n/index.js file too
|
||||
import { boot } from 'quasar/wrappers';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import messages from '../statics/i18n.js';
|
||||
|
||||
// Definisci i tipi per i messaggi
|
||||
export type MessageLanguages = keyof typeof messages;
|
||||
export type MessageSchema = typeof messages;
|
||||
|
||||
|
||||
// Crea l'istanza di i18n
|
||||
const i18n = createI18n({
|
||||
locale: 'it',
|
||||
locale: 'it', // Lingua predefinita
|
||||
legacy: false, // Usa la Composition API
|
||||
messages,
|
||||
})
|
||||
});
|
||||
|
||||
export default ({ app }: { app: any }) => {
|
||||
// Set i18n instance on app
|
||||
app.use(i18n)
|
||||
}
|
||||
// Esporta l'istanza di i18n
|
||||
export { i18n };
|
||||
|
||||
export function useI18n() {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
const { t, te, tm, rt, d, n, ...globalApi } = i18n.global;
|
||||
|
||||
return {
|
||||
t: t.bind(i18n),
|
||||
te: te.bind(i18n),
|
||||
tm: tm.bind(i18n),
|
||||
rt: rt.bind(i18n),
|
||||
d: d.bind(i18n),
|
||||
n: n.bind(i18n),
|
||||
...globalApi,
|
||||
};
|
||||
}
|
||||
|
||||
export { i18n }
|
||||
// Usa i18n nel boot file di Quasar
|
||||
export default boot(({ app }) => {
|
||||
app.use(i18n);
|
||||
});
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// src/boot/vue-i18n.js
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { toolsext } from '@src/store/Modules/toolsext'
|
||||
import messages from '../statics/i18n'
|
||||
import { tools } from '../store/Modules/tools'
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
export default ({ app }: { app: any }) => {
|
||||
// Vue.config.lang = process.env.LANG_DEFAULT;
|
||||
|
||||
const pinia = createPinia()
|
||||
app.use(pinia)
|
||||
|
||||
let mylang = tools.getItemLS(toolsext.localStorage.lang)
|
||||
console.log(`LANG LocalStorage ${mylang}`)
|
||||
|
||||
if ((navigator)) {
|
||||
const mylangnav = navigator.language
|
||||
console.log(`LANG NAVIGATOR ${mylangnav}`)
|
||||
if (mylang === '') mylang = mylangnav
|
||||
}
|
||||
|
||||
mylang = toolsext.checkLangPassed(mylang)
|
||||
|
||||
app.config.globalProperties.lang = mylang
|
||||
|
||||
const i18n = createI18n({
|
||||
fallbackLocale: mylang,
|
||||
locale: 'en-US',
|
||||
messages,
|
||||
})
|
||||
|
||||
app.use(i18n)
|
||||
}
|
||||
Reference in New Issue
Block a user