@@ -3,19 +3,35 @@ import { useStore } from "../../store/main.js";
3
3
import { vtIcons } from "src/store/state/icons" ;
4
4
import { Component , RouteComponentMap } from "../../../types" ;
5
5
6
- const store = useStore ( ) ; // template
7
- const componentMap = computed ( ( ) => store . componentMap ) ;
8
- const activeComponent = computed ( ( ) => store . activeComponent ) ;
9
- const activeComponentObj = computed ( ( ) => store . activeComponentObj ) ;
10
- const exportAsTypescript = computed ( ( ) => store . exportAsTypescript ) ;
11
- const activeRoute = computed ( ( ) => store . activeRoute ) ;
12
-
6
+ // const store = useStore(); // template
7
+ // const componentMap = computed(() => store.componentMap);
8
+ // const activeComponent = computed(() => store.activeComponent);
9
+ // const activeComponentObj = computed(() => store.activeComponentObj);
10
+ // const exportAsTypescript = computed(() => store.exportAsTypescript);
11
+ // const activeRoute = computed(() => store.activeRoute);
12
+ export function useComputedStore ( ) {
13
+ const store = useStore ( ) ;
14
+ const componentMap = computed ( ( ) => store . componentMap ) ;
15
+ const activeComponent = computed ( ( ) => store . activeComponent ) ;
16
+ const activeComponentObj = computed ( ( ) => store . activeComponentObj ) ;
17
+ const exportAsTypescript = computed ( ( ) => store . exportAsTypescript ) ;
18
+ const activeRoute = computed ( ( ) => store . activeRoute ) ;
19
+
20
+ return {
21
+ componentMap,
22
+ activeComponent,
23
+ activeComponentObj,
24
+ exportAsTypescript,
25
+ activeRoute
26
+ } ;
27
+ }
13
28
14
29
export const createBoilerOptions = ( componentName : string , children : string [ ] | {
15
30
[ key : string ] : RouteComponentMap | Component ;
16
31
App : RouteComponentMap ;
17
32
HomeView : RouteComponentMap ;
18
33
} ) => {
34
+ const { componentMap, activeComponent, exportAsTypescript, activeComponentObj } = useComputedStore ( ) ;
19
35
// add import mapstate and mapactions if they exist
20
36
let imports = "" ;
21
37
const activeComp = componentMap . value [ activeComponent . value ] as Component ;
@@ -69,7 +85,7 @@ export const createBoilerOptions = (componentName: string, children: string[] |
69
85
70
86
const vtComponents : string [ ] = [ ] ;
71
87
72
- htmlBinding . forEach ( ( el ) => {
88
+ htmlBinding . forEach ( ( el : { text : string } ) => {
73
89
if ( vuetensilsSet . has ( el . text ) ) {
74
90
// Add import statement for Vuetensils components
75
91
vtComponents . push ( el . text ) ;
@@ -83,7 +99,7 @@ export const createBoilerOptions = (componentName: string, children: string[] |
83
99
}
84
100
85
101
data += " data() {\n return {\n" ;
86
- htmlBinding . forEach ( ( el ) => {
102
+ htmlBinding . forEach ( ( el : { binding : string } ) => {
87
103
if ( el . binding !== "" ) {
88
104
data += ` ${ el . binding } : "PLACEHOLDER FOR VALUE", ` ;
89
105
data += "\n" ;
@@ -185,6 +201,7 @@ export const createBoilerComposition = (componentName: string, children: string[
185
201
App : RouteComponentMap ;
186
202
HomeView : RouteComponentMap ;
187
203
} ) => {
204
+ const { componentMap, activeComponent, activeComponentObj, exportAsTypescript } = useComputedStore ( ) ;
188
205
// add import mapstate and mapactions if they exist
189
206
let imports = "" ;
190
207
const activeComp = componentMap . value [ activeComponent . value ] as Component ;
@@ -234,7 +251,7 @@ export const createBoilerComposition = (componentName: string, children: string[
234
251
235
252
const vtComponents : string [ ] = [ ] ;
236
253
237
- htmlBinding . forEach ( ( el ) => {
254
+ htmlBinding . forEach ( ( el : { text : string } ) => {
238
255
if ( vuetensilsSet . has ( el . text ) ) {
239
256
// Add import statement for Vuetensils components
240
257
vtComponents . push ( el . text ) ;
@@ -251,7 +268,7 @@ data += " setup() {"
251
268
if ( activeComp . state . length || activeComp . actions . length ) {
252
269
data += " \n const /* testStore */ = useStore(); " ;
253
270
}
254
- htmlBinding . forEach ( ( el ) => {
271
+ htmlBinding . forEach ( ( el : { binding : string } ) => {
255
272
if ( el . binding !== "" ) {
256
273
data += ` ${ el . binding } : "PLACEHOLDER FOR VALUE", ` ;
257
274
data += "\n" ;
0 commit comments