Запилил хранилище данных, первая настройка

This commit is contained in:
saber-nyan 2019-05-03 18:25:35 +03:00
parent 9176d52b08
commit 6981a84e3f
No known key found for this signature in database
GPG Key ID: 7B069E9C295E6B4A
5 changed files with 50 additions and 12 deletions

21
package-lock.json generated
View File

@ -9480,6 +9480,11 @@
"jsonify": "~0.0.0" "jsonify": "~0.0.0"
} }
}, },
"shvl": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/shvl/-/shvl-1.3.1.tgz",
"integrity": "sha512-+rRPP46hloYUAEImJcqprUgXu+05Ikqr4h4V+w5i2zJy37nAqtkQKufs3+3S2fDq6JNRrHMIQhB/Vaex+jgAAw=="
},
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
@ -10884,6 +10889,22 @@
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.0.tgz", "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.0.tgz",
"integrity": "sha512-mdHeHT/7u4BncpUZMlxNaIdcN/HIt1GsGG5LKByArvYG/v6DvHcOxvDCts+7SRdCoIRGllK8IMZvQtQXLppDYg==" "integrity": "sha512-mdHeHT/7u4BncpUZMlxNaIdcN/HIt1GsGG5LKByArvYG/v6DvHcOxvDCts+7SRdCoIRGllK8IMZvQtQXLppDYg=="
}, },
"vuex-persistedstate": {
"version": "2.5.4",
"resolved": "https://registry.npmjs.org/vuex-persistedstate/-/vuex-persistedstate-2.5.4.tgz",
"integrity": "sha512-XYJhKIwO+ZVlTaXyxKxnplrJ88Fnvk5aDw753bxzRw5/yMKLQ6lq9CDCBex2fwZaQcLibhtgJOxGCHjy9GLSlQ==",
"requires": {
"deepmerge": "^2.1.0",
"shvl": "^1.3.0"
},
"dependencies": {
"deepmerge": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz",
"integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA=="
}
}
},
"watchpack": { "watchpack": {
"version": "1.6.0", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz",

View File

@ -14,7 +14,8 @@
"popper.js": "^1.15.0", "popper.js": "^1.15.0",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-router": "^3.0.3", "vue-router": "^3.0.3",
"vuex": "^3.0.1" "vuex": "^3.0.1",
"vuex-persistedstate": "^2.5.4"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^3.7.0", "@vue/cli-plugin-babel": "^3.7.0",

View File

@ -15,7 +15,7 @@ export default {
name: 'Packet', name: 'Packet',
props: ['id', 'content', 'timestamp',], props: ['id', 'content', 'timestamp',],
mounted() { mounted() {
const instance = new Hexdump(atob(this.$props.content), { new Hexdump(atob(this.$props.content), { // TODO: в настройки
container: 'hexdump-' + this.$props.id, container: 'hexdump-' + this.$props.id,
base: 'hex', base: 'hex',
width: 16, width: 16,
@ -34,7 +34,6 @@ export default {
stringNull: '.', stringNull: '.',
}, },
}); });
console.trace('created hexview', instance);
}, },
} }
</script> </script>

View File

@ -2,10 +2,15 @@
<div class="modal-mask"> <div class="modal-mask">
<div class="modal-wrapper"> <div class="modal-wrapper">
<div class="modal-container"> <div class="modal-container">
Test modal! <form>
<button @click="$emit('close')"> <div class="form-group">
Close <label for="inputApiUrl">URL бэкенда</label>
</button> <input type="url" class="form-control" id="inputApiUrl" placeholder="URL" v-model="apiUrl">
</div>
<button type="submit" @click.prevent="$emit('close')" class="btn btn-primary">
Close
</button>
</form>
</div> </div>
</div> </div>
</div> </div>
@ -27,6 +32,16 @@ export default {
beforeDestroy() { beforeDestroy() {
document.removeEventListener('keyup', this.$data.escapeKeyCallback); document.removeEventListener('keyup', this.$data.escapeKeyCallback);
}, },
computed: {
apiUrl: {
get() {
return this.$store.state.apiUrl;
},
set(value) {
this.$store.commit('setApiUrl', value);
},
},
},
} }
</script> </script>

View File

@ -1,16 +1,18 @@
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex); Vue.use(Vuex);
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
apiUrl: 'http://127.0.0.1/api',
}, },
mutations: { mutations: {
setApiUrl: (state, payload) => state.apiUrl = payload,
},
actions: {
}, },
// actions: {
// setApiUrl: async (injectee, payload) => injectee.commit('setApiUrl', payload),
// },
plugins: [createPersistedState(),],
}) })