mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
boot code
This commit is contained in:
parent
9ebdb00579
commit
d1e1314dcf
0
frontend/src/boot/.gitkeep
Normal file
0
frontend/src/boot/.gitkeep
Normal file
34
frontend/src/boot/axios.js
vendored
Normal file
34
frontend/src/boot/axios.js
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import {boot} from 'quasar/wrappers'
|
||||||
|
import axios from 'axios'
|
||||||
|
import {setupCache} from 'axios-cache-adapter'
|
||||||
|
|
||||||
|
const cache = setupCache({
|
||||||
|
maxAge: 15 * 60 * 1000,
|
||||||
|
exclude: { query: false }
|
||||||
|
})
|
||||||
|
|
||||||
|
// Be careful when using SSR for cross-request state pollution
|
||||||
|
// due to creating a Singleton instance here;
|
||||||
|
// If any client changes this (global) instance, it might be a
|
||||||
|
// good idea to move this instance creation inside of the
|
||||||
|
// "export default () => {}" function below (which runs individually
|
||||||
|
// for each client)
|
||||||
|
|
||||||
|
const url = process.env.DEBUGGING ? 'https://firefly.sd.home' : '/';
|
||||||
|
const api = axios.create({baseURL: url, withCredentials: true, adapter: cache.adapter});
|
||||||
|
|
||||||
|
export default boot(({app}) => {
|
||||||
|
// for use inside Vue files (Options API) through this.$axios and this.$api
|
||||||
|
axios.defaults.withCredentials = true;
|
||||||
|
axios.defaults.baseURL = url;
|
||||||
|
|
||||||
|
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
|
||||||
|
// ^ ^ ^ 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 {api}
|
13
frontend/src/boot/i18n.js
vendored
Normal file
13
frontend/src/boot/i18n.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { boot } from 'quasar/wrappers'
|
||||||
|
import { createI18n } from 'vue-i18n'
|
||||||
|
import messages from 'src/i18n'
|
||||||
|
|
||||||
|
export default boot(({ app }) => {
|
||||||
|
const i18n = createI18n({
|
||||||
|
locale: 'en-US',
|
||||||
|
messages
|
||||||
|
})
|
||||||
|
|
||||||
|
// Set i18n instance on app
|
||||||
|
app.use(i18n)
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user