From 7ac64350e5476507fffa66a781ab98c75ed5e4b3 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 15 Jan 2021 15:38:10 +0100 Subject: [PATCH] feat(store): add vuex store --- package.json | 28 +++++++++++++++------------- src/store/index.js | 22 ++++++++++++++++++++++ store/README.md | 10 ---------- store/index.ts | 26 -------------------------- yarn.lock | 7 ++++++- 5 files changed, 43 insertions(+), 50 deletions(-) create mode 100644 src/store/index.js delete mode 100644 store/README.md delete mode 100644 store/index.ts diff --git a/package.json b/package.json index ef5aeac..e0d930d 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..ca60177 --- /dev/null +++ b/src/store/index.js @@ -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: {}, +}) diff --git a/store/README.md b/store/README.md deleted file mode 100644 index 1972d27..0000000 --- a/store/README.md +++ /dev/null @@ -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). diff --git a/store/index.ts b/store/index.ts deleted file mode 100644 index 3d2260e..0000000 --- a/store/index.ts +++ /dev/null @@ -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 - }, -} diff --git a/yarn.lock b/yarn.lock index aae20b9..2943b45 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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==