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 */
6
1
<!--
7
2
Description:
8
3
Displays Export Project button and allows users to export project
@@ -22,14 +17,13 @@ Description:
22
17
</q-btn >
23
18
</template >
24
19
25
-
26
20
<script >
27
21
import { useExportComponent } from " ../composables/useExportComponent.js" ;
28
22
import { mapState } from " vuex" ;
29
23
const { fs , ipcRenderer } = window ;
30
24
31
25
export default {
32
- name: " ExportMenu " ,
26
+ name: " ExportProjectComponent " ,
33
27
methods: {
34
28
useExportComponentBound (){
35
29
useExportComponent .bind (this )();
@@ -367,13 +361,14 @@ export default {
367
361
// creates main.js boilerplate
368
362
createMainFile (location ) {
369
363
let str = ` import { createApp } from 'vue';` ;
364
+ str += ` \n import store from './store'`
370
365
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);` ;
375
368
str += ` \n app.use(router);` ;
376
- str += ` \n app.mount('#app');` ;
369
+ str += ` \n app.use(store)` ;
370
+ str += ` \n app.mount('#app');` ;
371
+
377
372
// if using typescript, export with .ts extension
378
373
if (this .exportAsTypescript === " on" ) {
379
374
fs .writeFileSync (path .join (location, " src" , " main.ts" ), str);
@@ -445,6 +440,50 @@ export default {
445
440
return ;
446
441
}
447
442
},
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
+ },
448
487
// create package.json file
449
488
createPackage (location ) {
450
489
let str = ` {` ;
@@ -493,6 +532,7 @@ export default {
493
532
fs .mkdirSync (path .join (data, " src" , " components" ));
494
533
fs .mkdirSync (path .join (data, " src" , " views" ));
495
534
fs .mkdirSync (path .join (data, " src" , " router" ));
535
+ fs .mkdirSync (path .join (data, " src" , " store" ));
496
536
}
497
537
// creating basic boilerplate for vue app
498
538
this .createIndexFile (data);
@@ -503,6 +543,7 @@ export default {
503
543
this .createTSViteConfig (data);
504
544
this .createTSDeclaration (data);
505
545
this .createPackage (data);
546
+ this .createStore (data);
506
547
// exports images to the /assets folder
507
548
// eslint-disable-next-line no-unused-vars
508
549
for (let [routeImage, imageLocation] of Object .entries (this .imagePath )) {
@@ -545,7 +586,7 @@ export default {
545
586
},
546
587
},
547
588
computed: {
548
- ... mapState ([" componentMap" , " imagePath" , " routes" , " exportAsTypescript" , " activeComponent" ]),
589
+ ... mapState ([" componentMap" , " imagePath" , " routes" , " exportAsTypescript" , " activeComponent" , " userState " , " userActions " ]),
549
590
},
550
591
};
551
592
< / script>
0 commit comments