feat(store): add vuex store

This commit is contained in:
Tykayn 2021-01-15 15:38:10 +01:00 committed by tykayn
parent 2f818d63d1
commit 7ac64350e5
5 changed files with 43 additions and 50 deletions

View File

@ -3,25 +3,15 @@
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt-ts",
"build": "nuxt-ts build",
"start": "nuxt-ts start",
"lint": "yarn lint:js && yarn lint:style",
"dev": "nuxt-ts",
"generate": "nuxt-ts generate",
"lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .",
"lint:style": "stylelint **/*.{vue,css} --ignore-path .gitignore",
"lint": "yarn lint:js && yarn lint:style",
"start": "nuxt-ts start",
"test": "jest"
},
"lint-staged": {
"*.{js,vue}": "eslint",
"*.{css,vue}": "stylelint"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"dependencies": {
"@nuxt/typescript-runtime": "^2.0.0",
"@nuxtjs/axios": "^5.12.2",
@ -30,6 +20,7 @@
"nuxt-buefy": "^0.4.3",
"nuxt-i18n": "^6.16.0",
"vue-i18n": "^9.0.0-beta.12",
"vuex": "^3.4.0",
"xml-parser": "^1.2.1",
"xml2js": "^0.4.23"
},
@ -42,6 +33,7 @@
"@nuxtjs/eslint-config-typescript": "^3.0.0",
"@nuxtjs/eslint-module": "^2.0.0",
"@nuxtjs/stylelint-module": "^4.0.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/test-utils": "^1.1.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
@ -59,5 +51,15 @@
"stylelint-config-standard": "^20.0.0",
"ts-jest": "^26.4.1",
"vue-jest": "^3.0.4"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,vue}": "eslint",
"*.{css,vue}": "stylelint"
}
}

22
src/store/index.js Normal file
View File

@ -0,0 +1,22 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
isFetching: false,
searchQuery: '',
select: {},
searchResults: [],
hours: [],
osm_data: {},
},
mutations: {
increment: (state) => {
state.count++
},
},
actions: {},
modules: {},
})

View File

@ -1,10 +0,0 @@
# STORE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Vuex Store files.
Vuex Store option is implemented in the Nuxt.js framework.
Creating a file in this directory automatically activates the option in the framework.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).

View File

@ -1,26 +0,0 @@
export const state = () => ({
counter: 0,
list: [],
formConfig: {},
})
export const mutations = {
increment(state: any) {
state.counter++
},
add(state: any, text: any) {
state.list.push({
text,
done: false,
})
},
remove(state: any, { todo }: any) {
state.list.splice(state.list.indexOf(todo), 1)
},
toggle(state: any, todo: any) {
todo.done = !todo.done
},
setFormField(state: any, { field }: any) {
state.formConfig[state.formConfig.indexOf(field)] = field
},
}

View File

@ -2291,6 +2291,11 @@
"@vue/babel-plugin-transform-vue-jsx" "^1.2.1"
camelcase "^5.0.0"
"@vue/cli-plugin-vuex@~4.5.0":
version "4.5.10"
resolved "https://registry.yarnpkg.com/@vue/cli-plugin-vuex/-/cli-plugin-vuex-4.5.10.tgz#bad1fc538d09df0e67454594f707782d63667f39"
integrity sha512-Z5pnL3Eg2uwkKqP09NoM46/rwQCJ1j/1cZMgO4JF817O9n5AsFgV456UE6lK2cVCvIfvt7+S3HLrSPZUsYNQjQ==
"@vue/component-compiler-utils@^3.1.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@vue/component-compiler-utils/-/component-compiler-utils-3.2.0.tgz#8f85182ceed28e9b3c75313de669f83166d11e5d"
@ -12039,7 +12044,7 @@ vue@^2.6.12:
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.12.tgz#f5ebd4fa6bd2869403e29a896aed4904456c9123"
integrity sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg==
vuex@^3.6.0:
vuex@^3.4.0, vuex@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.6.0.tgz#95efa56a58f7607c135b053350833a09e01aa813"
integrity sha512-W74OO2vCJPs9/YjNjW8lLbj+jzT24waTo2KShI8jLvJW8OaIkgb3wuAMA7D+ZiUxDOx3ubwSZTaJBip9G8a3aQ==