Settings and api preload

This commit is contained in:
Kekskurse 2019-12-02 17:14:49 +01:00
parent 97be00a3b6
commit f7bd710fc0
2 changed files with 9 additions and 0 deletions

View File

@ -13,6 +13,9 @@ export default {
}, },
getAPIUrl () { getAPIUrl () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(localStorage.getItem("apiURL")) {
resolve();
}
axios.get('/apiurl') axios.get('/apiurl')
.then(function (response) { .then(function (response) {
// handle success // handle success

View File

@ -71,12 +71,18 @@ export default new Vuex.Store({
actions: { actions: {
getSettings: function (context) { getSettings: function (context) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(localStorage.getItem("settings")) {
context.commit('setSettings', localStorage.getItem("settings"))
resolve();
}
ServerService.getPublicSettings().then((res) => { ServerService.getPublicSettings().then((res) => {
localStorage.setItem("settings", res.data.data)
context.commit('setSettings', res.data.data) context.commit('setSettings', res.data.data)
resolve() resolve()
}).catch((res) => { }).catch((res) => {
context.commit('setError') context.commit('setError')
}); });
}) })
}, },
checkAccount: function(context) { checkAccount: function(context) {