This commit is contained in:
Liyas Thomas
2019-10-29 12:18:01 +05:30
14 changed files with 661 additions and 483 deletions

View File

@@ -1,3 +1,24 @@
export default {
import Vuex from 'vuex';
import state from './state';
import VuexPersist from 'vuex-persist'
}
export default {
install(Vue) {
Vue.use(Vuex);
const vuexLocalStorage = new VuexPersist({
key: 'vuex',
storage: window.localStorage,
reducer: ({ ...request }) => ({
...request
})
})
const store = new Vuex.Store({
state,
plugins: [vuexLocalStorage.plugin]
});
Vue.prototype.$store = store;
},
};

53
store/mutations.js Normal file
View File

@@ -0,0 +1,53 @@
export default {
setState(state, object){
state.request[object.attribute] = object.value
},
addHeaders(state, value) {
state.request.headers.push(value);
},
removeHeaders(state, index) {
state.request.headers.splice(index, 1)
},
setKeyHeader(state, object) {
state.request.headers[object.index].key = object.value
},
setValueHeader(state, object) {
state.request.headers[object.index].value = object.value
},
addParams(state, value) {
state.request.params.push(value);
},
removeParams(state, index) {
state.request.params.splice(index, 1)
},
setKeyParams(state, object) {
state.request.params[object.index].key = object.value
},
setValueParams(state, object) {
state.request.params[object.index].value = object.value
},
addBodyParams(state, value) {
state.request.bodyParams.push(value);
},
removeBodyParams(state, index) {
state.request.bodyParams.splice(index, 1)
},
setKeyBodyParams(state, object) {
state.request.bodyParams[object.index].key = object.value
},
setValueBodyParams(state, object) {
state.request.bodyParams[object.index].value = object.value
},
};

View File

@@ -31,7 +31,7 @@ export const SETTINGS_KEYS = [
* to emphasise the different sections.
* This setting allows that to be turned off.
*/
"DISABLE_FRAME_COLORS",
"FRAME_COLORS_ENABLED",
/**
* Whether or not requests should be proxied.
@@ -45,7 +45,13 @@ export const SETTINGS_KEYS = [
/**
* The security key of the proxy.
*/
"PROXY_KEY"
"PROXY_KEY",
/**
* An array of properties to exclude from the URL.
* e.g. 'auth'
*/
"URL_EXCLUDES"
];
export const state = () => ({

19
store/state.js Normal file
View File

@@ -0,0 +1,19 @@
export default {
request: {
method: 'GET',
url: 'https://reqres.in',
path: '/api/users',
label: '',
auth: 'None',
httpUser: '',
httpPassword: '',
bearerToken: '',
headers: [],
params: [],
bodyParams: [],
rawParams: '',
rawInput: false,
requestType: '',
contentType: '',
}
};