parent
e6ddd0c5cc
commit
986e0ad583
@ -1,7 +1,7 @@
|
||||
{
|
||||
"/js/vue/Authentication/app.js": "/js/vue/Authentication/app.js?id=46a300281c838d8eb317",
|
||||
"/js/vue/Home/app.js": "/js/vue/Home/app.js?id=3b00321087e86fb5e1bf",
|
||||
"/js/vue/Modules/CRM/app.js": "/js/vue/Modules/CRM/app.js?id=10e1114fa9d3880bcd52",
|
||||
"/js/vue/Modules/Reservation/app.js": "/js/vue/Modules/Reservation/app.js?id=2619184b0d853d8273c1",
|
||||
"/js/vue/User/app.js": "/js/vue/User/app.js?id=03d4dbc997cf4190dd65"
|
||||
"/js/vue/Authentication/app.js": "/js/vue/Authentication/app.js?id=70376fdc43efc4b13789",
|
||||
"/js/vue/Home/app.js": "/js/vue/Home/app.js?id=aa9935664046e6bbb8aa",
|
||||
"/js/vue/Modules/CRM/app.js": "/js/vue/Modules/CRM/app.js?id=69daf7bd7d44517ffaaf",
|
||||
"/js/vue/Modules/Reservation/app.js": "/js/vue/Modules/Reservation/app.js?id=8a8b1f6e787ca9a75d5b",
|
||||
"/js/vue/User/app.js": "/js/vue/User/app.js?id=815ce96ae40cc8c7560c"
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
import axiosApi from '@Global/utils/api/request/axiosApi'
|
||||
import apolloApi from '@Global/utils/api/request/apolloApi'
|
||||
|
||||
export const api = (url) => {
|
||||
let apiClass;
|
||||
if (url['type'] == 'apollo') {
|
||||
apiClass = new apolloApi (url);
|
||||
} else if (url['type'] == 'axios') {
|
||||
apiClass = new axiosApi (url);
|
||||
} else {
|
||||
throw 'parameter "' + url['type'] + '" must be axios or apollo.';
|
||||
}
|
||||
|
||||
return apiClass.init();
|
||||
}
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
$_api: api
|
||||
},
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import { mapActions, mapGetters } from "vuex";
|
||||
const modal = {
|
||||
methods: {
|
||||
...mapActions("modal", ["openModal", "closeModal", "dialog"]),
|
||||
$_openModal(options) {
|
||||
this.openModal(options);
|
||||
},
|
||||
$_closeModal(options) {
|
||||
this.closeModal(options);
|
||||
},
|
||||
$_dialog(options) {
|
||||
this.dialog(options);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export { modal };
|
@ -0,0 +1,4 @@
|
||||
export default {
|
||||
getCurrentModule: state => state.current_module,
|
||||
getCurrentModuleInfo: state => state.current_module_info,
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
export default {
|
||||
SET_CURRENT_MODULE(state, module) {
|
||||
state.current_module = module;
|
||||
},
|
||||
SET_CURRENT_MODULE_INFO(state, moduleInfo) {
|
||||
state.current_module_info = moduleInfo;
|
||||
}
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
export default {
|
||||
current_module: "",
|
||||
current_module_info: {
|
||||
name: ""
|
||||
}
|
||||
};
|
@ -1,26 +0,0 @@
|
||||
import { ApolloClient } from 'apollo-client';
|
||||
import { createHttpLink } from 'apollo-link-http';
|
||||
import { setContext } from 'apollo-link-context';
|
||||
import { InMemoryCache } from 'apollo-cache-inmemory';
|
||||
import { TokenService } from "@Global/services/storage.services";
|
||||
|
||||
const httpLink = createHttpLink({
|
||||
uri: '/graphql',
|
||||
});
|
||||
|
||||
|
||||
const authLink = setContext((_, { headers }) => {
|
||||
// return the headers to the context so httpLink can read them
|
||||
return {
|
||||
headers: {
|
||||
...headers,
|
||||
authorization: TokenService.getToken() ? `Bearer ${TokenService.getToken()}` : "",
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default new ApolloClient({
|
||||
link: authLink.concat(httpLink),
|
||||
cache: new InMemoryCache(),
|
||||
});
|
||||
|
@ -1,41 +0,0 @@
|
||||
import apollo from "@Global/utils/api/init/apollo";
|
||||
|
||||
export default class apolloApi {
|
||||
|
||||
constructor(urlObj) {
|
||||
this.staticMethods = ["query", "mutate"];
|
||||
|
||||
this.method = urlObj.method;
|
||||
this.gql = urlObj.gql;
|
||||
this.variables = urlObj.data;
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.checkMethod()) {
|
||||
return this[this.method]();
|
||||
}
|
||||
}
|
||||
|
||||
checkMethod() {
|
||||
return this.staticMethods.includes(this.method);
|
||||
}
|
||||
|
||||
query() {
|
||||
let query = this.gql;
|
||||
let variables = this.variables;
|
||||
|
||||
return apollo.query({
|
||||
query,
|
||||
variables
|
||||
});
|
||||
}
|
||||
|
||||
mutate() {
|
||||
const mutation = this.gql;
|
||||
const variables = this.variables;
|
||||
return apollo.mutate({
|
||||
mutation,
|
||||
variables
|
||||
});
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
import axios from "axios";
|
||||
import { urlGenerator } from '@Global/services/url.service.js';
|
||||
|
||||
export default class axiosApi {
|
||||
|
||||
constructor(urlObj) {
|
||||
this.staticMethods = ["get", "post", "put", "delete"];
|
||||
this.baseURL = '/';
|
||||
|
||||
this.method = urlObj.method;
|
||||
this.url = urlGenerator(urlObj.url, urlObj.data);
|
||||
console.log(this.url);
|
||||
|
||||
this.data = urlObj.data;
|
||||
}
|
||||
|
||||
init() {
|
||||
axios.defaults.baseURL = this.baseURL;
|
||||
|
||||
if (this.checkMethod()) {
|
||||
return this[this.method]();
|
||||
}
|
||||
}
|
||||
|
||||
checkMethod() {
|
||||
return this.staticMethods.includes(this.method);
|
||||
}
|
||||
|
||||
get() {
|
||||
const params = this.data;
|
||||
return axios.get(this.url, {
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
post() {
|
||||
return axios.post(this.url, this.data);
|
||||
}
|
||||
|
||||
put() {
|
||||
const data = this.data;
|
||||
data['_method'] = 'put';
|
||||
return axios.put(this.url, data);
|
||||
}
|
||||
|
||||
delete() {
|
||||
const data = this.data;
|
||||
data['_method'] = 'delete';
|
||||
return axios.put(this.url, data);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue