From 03eb160d6641d9f8248b30e9fc1f91fc53f0ba82 Mon Sep 17 00:00:00 2001 From: Manuel Saelices Date: Thu, 4 Apr 2019 13:53:02 +0200 Subject: [PATCH] Better support for Vuex --- meta.js | 3 ++- template/app/main.js | 3 +++ template/app/main.ts | 4 ++++ template/app/store.js | 16 ++++++++++++++++ template/app/store.ts | 16 ++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 template/app/store.js create mode 100644 template/app/store.ts diff --git a/meta.js b/meta.js index 0121395..7b3eb5d 100644 --- a/meta.js +++ b/meta.js @@ -158,7 +158,8 @@ module.exports = { 'app/types/**/*': '!inPlace && lang == "typescript"', 'app/router/**/*': '!inPlace && router', 'app/components/Home.vue': '!inPlace && router', - 'app/store/**/*': '!inPlace && store', + 'app/store.js': '!inPlace && store && lang == "javascript"', + 'app/store.ts': '!inPlace && store && lang == "typescript"', 'app/components/Counter.vue': '!inPlace && store', }, complete(data, {logger, chalk}) { diff --git a/template/app/main.js b/template/app/main.js index aa0d0ec..665ee6f 100644 --- a/template/app/main.js +++ b/template/app/main.js @@ -1,5 +1,7 @@ import Vue from 'nativescript-vue' import App from './components/App' +{{#store}}import store from './store';{{/store}} + {{#devtools}}import VueDevtools from 'nativescript-vue-devtools' if(TNS_ENV !== 'production') { @@ -14,5 +16,6 @@ Vue.registerElement('RadSideDrawer', () => require('nativescript-ui-sidedrawer') {{/if_eq}} new Vue({ + {{#store}}store,{{/store}} render: h => h('frame', [h(App)]) }).$start() diff --git a/template/app/main.ts b/template/app/main.ts index 95bfa41..27db147 100644 --- a/template/app/main.ts +++ b/template/app/main.ts @@ -1,11 +1,14 @@ import Vue from 'nativescript-vue'; import App from './components/App.vue'; +{{#store}}import store from './store';{{/store}} + {{#devtools}}import VueDevtools from 'nativescript-vue-devtools'; if(TNS_ENV !== 'production') { Vue.use(VueDevtools); } {{/devtools}} + // Prints Vue logs when --env.production is *NOT* set while building Vue.config.silent = (TNS_ENV === 'production'); @@ -17,5 +20,6 @@ Vue.registerElement( {{/if_eq}} new Vue({ +{{#store}}store,{{/store}} render: h => h('frame', [h(App)]) }).$start(); diff --git a/template/app/store.js b/template/app/store.js new file mode 100644 index 0000000..ce737b9 --- /dev/null +++ b/template/app/store.js @@ -0,0 +1,16 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; + +Vue.use(Vuex); + +export default new Vuex.Store({ + state: { + + }, + mutations: { + + }, + actions: { + + } +}); diff --git a/template/app/store.ts b/template/app/store.ts new file mode 100644 index 0000000..ce737b9 --- /dev/null +++ b/template/app/store.ts @@ -0,0 +1,16 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; + +Vue.use(Vuex); + +export default new Vuex.Store({ + state: { + + }, + mutations: { + + }, + actions: { + + } +});