1- /* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */ /*
2- eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */ /*
3- eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */ /*
4- eslint-disable no-unused-vars */ /* eslint-disable no-useless-escape */ /*
5- eslint-disable no-useless-escape */
61<!--
72Description:
83 Displays Export Project button and allows users to export project
@@ -22,14 +17,13 @@ Description:
2217 </q-btn >
2318</template >
2419
25-
2620<script >
2721import { useExportComponent } from " ../composables/useExportComponent.js" ;
2822import { mapState } from " vuex" ;
2923const { fs , ipcRenderer } = window ;
3024
3125export default {
32- name: " ExportMenu " ,
26+ name: " ExportProjectComponent " ,
3327 methods: {
3428 useExportComponentBound (){
3529 useExportComponent .bind (this )();
@@ -367,13 +361,14 @@ export default {
367361 // creates main.js boilerplate
368362 createMainFile (location ) {
369363 let str = ` import { createApp } from 'vue';` ;
364+ str += ` \n import store from './store'`
370365 str += ` \n import App from './App.vue';` ;
371- str += ` \n import router from './router';` ;
372- // str += `\n\n import './index.css'`
373- str += ` \n\n const app = createApp(App);` ;
374- // str += `\n\trouter,
366+ str += ` \n import router from './router';\n ` ;
367+ str += ` \n const app = createApp(App);` ;
375368 str += ` \n app.use(router);` ;
376- str += ` \n app.mount('#app');` ;
369+ str += ` \n app.use(store)` ;
370+ str += ` \n app.mount('#app');` ;
371+
377372 // if using typescript, export with .ts extension
378373 if (this .exportAsTypescript === " on" ) {
379374 fs .writeFileSync (path .join (location, " src" , " main.ts" ), str);
@@ -445,6 +440,50 @@ export default {
445440 return ;
446441 }
447442 },
443+ createStore (location ) {
444+ let str = ` import { createStore } from 'vuex';\n ` ;
445+ str += ` \n const store = createStore({` ;
446+ str += ` \n\t state () {` ;
447+ str += ` \n\t\t return {` ;
448+ if (! this .userState .length ){
449+ str += ` \n\t\t\t //placeholder for state`
450+ }
451+ for (let i = 0 ; i < this .userState .length ; i++ ){
452+ str+= ` \n\t\t\t ${ this .userState [i]} : "PLACEHOLDER FOR VALUE",`
453+ if (i === this .userState .length - 1 ){str = str .slice (0 , - 1 )}
454+ }
455+ str += ` \n\t\t }` ;
456+ str += ` \n\t },` ;
457+ str += ` \n\t mutations: {` ;
458+ if (! this .userActions .length ){
459+ str += ` \n\t\t\t //placeholder for mutations`
460+ }
461+ for (let i = 0 ; i < this .userActions .length ; i++ ){
462+ str += ` \n\t\t ${ this .userActions [i]} (state) {` ;
463+ str += ` \n\t\t\t //placeholder for your mutation` ;
464+ str += ` \n\t\t },` ;
465+ if (i === this .userActions .length - 1 ){str = str .slice (0 , - 1 )}
466+ }
467+ str += ` \n\t },` ;
468+ str += ` \n\t actions: {` ;
469+ if (! this .userActions .length ){
470+ str += ` \n\t\t\t //placeholder for actions`
471+ }
472+ for (let i = 0 ; i < this .userActions .length ; i++ ){
473+ str += ` \n\t\t ${ this .userActions [i]} () {` ;
474+ str += ` \n\t\t\t store.commit('${ this .userActions [i]} ')` ;
475+ str += ` \n\t\t },` ;
476+ if (i === this .userActions .length - 1 ){str = str .slice (0 , - 1 )}
477+ }
478+ str += ` \n\t }` ;
479+ str += ' \n })\n ' ;
480+ str += ` \n export default store;`
481+ if (this .exportAsTypescript === " on" ) {
482+ fs .writeFileSync (path .join (location, " src" , " store" , " index.ts" ), str);
483+ } else {
484+ fs .writeFileSync (path .join (location, " src" , " store" , " index.js" ), str);
485+ }
486+ },
448487 // create package.json file
449488 createPackage (location ) {
450489 let str = ` {` ;
@@ -493,6 +532,7 @@ export default {
493532 fs .mkdirSync (path .join (data, " src" , " components" ));
494533 fs .mkdirSync (path .join (data, " src" , " views" ));
495534 fs .mkdirSync (path .join (data, " src" , " router" ));
535+ fs .mkdirSync (path .join (data, " src" , " store" ));
496536 }
497537 // creating basic boilerplate for vue app
498538 this .createIndexFile (data);
@@ -503,6 +543,7 @@ export default {
503543 this .createTSViteConfig (data);
504544 this .createTSDeclaration (data);
505545 this .createPackage (data);
546+ this .createStore (data);
506547 // exports images to the /assets folder
507548 // eslint-disable-next-line no-unused-vars
508549 for (let [routeImage, imageLocation] of Object .entries (this .imagePath )) {
@@ -545,7 +586,7 @@ export default {
545586 },
546587 },
547588 computed: {
548- ... mapState ([" componentMap" , " imagePath" , " routes" , " exportAsTypescript" , " activeComponent" ]),
589+ ... mapState ([" componentMap" , " imagePath" , " routes" , " exportAsTypescript" , " activeComponent" , " userState " , " userActions " ]),
549590 },
550591};
551592< / script>
0 commit comments