Skip to content

Commit f77d8a7

Browse files
robsinzKelementz916DanielGaran02anthonyHerrRoderickXii
authored
Rob/pinia (#8)
* Dev to Master (updated ReadMe + save functionality base changes and updates) (#3) * Updated dependencies (#1) * update to dependencies up til @quasar/app-webpack - able to build, not able to run on electron * updated quasar -> need to update electron next * updated electron 29 * updated dependencies v2 * updated pinia * vue router update * updated kc2.1 * updated 2.2 after updated npm * updated to fs-extra * updated ts * updated vue devtools * updated tsconfig * updated eslint webpack * updated eslint plugin vue * updated all eslint * finalized base dependencies * Updated readMe (still needs updating), fixed save functionality (#2) * updated readMe Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Kevin Can <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Rob Sinzieri <[email protected]> Co-authored-by: Roderick de Leon <[email protected]> * updated readme1.1 * updated readme 1.2 * github changes * updated readme * updated save * fixed save function and fs writefilesync now moved to electron main Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Kevin Can <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Rob Sinzieri <[email protected]> Co-authored-by: Roderick de Leon <[email protected]> * fixed save * added dynamic support for crypto --------- Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Rob Sinzieri <[email protected]> Co-authored-by: Roderick de Leon <[email protected]> * updated readMe --------- Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Rob Sinzieri <[email protected]> Co-authored-by: Roderick de Leon <[email protected]> * added composition api functionality Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Kevin Can <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Rob Sinzieri <[email protected]> Co-authored-by: Roderick de Leon <[email protected]> * updated CodeSnippet --------- Co-authored-by: Kevin Can <[email protected]> Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Roderick de Leon <[email protected]>
1 parent 1e61960 commit f77d8a7

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

src/components/right-sidebar/CodeSnippet.vue

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,7 @@ const createBoilerComposition = (componentName: string, children: string[]) => {
605605
const activeComp = componentMap.value[activeComponent.value] as Component;
606606
// if (checked.value === false) {
607607
if (activeComp.actions.length || activeComp.state.length) {
608-
imports += "import { ";
609-
if (activeComp.actions.length && activeComp.state.length) {
610-
imports += "mapState, mapActions";
611-
} else if (activeComp.state.length) imports += "mapState";
612-
else imports += "mapActions";
613-
imports += ` } from "pinia";\nimport { /* store */} from '/* ./store */'`; // changed from 'vuex' pinia
608+
imports += `import { /* useStore */ } from '/* ./store */';\n`; // changed from 'vuex' pinia
614609
}
615610
// }
616611
// if Typescript toggle is on, import defineComponent
@@ -624,7 +619,7 @@ const createBoilerComposition = (componentName: string, children: string[]) => {
624619
});
625620
626621
// add components section
627-
let childrenComponentNames = "";
622+
let childrenComponentNames = "\n";
628623
children.forEach((name) => {
629624
childrenComponentNames += ` ${name},\n`;
630625
});
@@ -640,6 +635,7 @@ const createBoilerComposition = (componentName: string, children: string[]) => {
640635
//data += " }\n";
641636
data += " },\n";
642637
}
638+
643639
644640
const htmlBinding = componentMap.value[activeComponent.value].htmlList;
645641
@@ -664,38 +660,45 @@ const createBoilerComposition = (componentName: string, children: string[]) => {
664660
)} } from 'vuetensils/src/components';\n`;
665661
}
666662
/*------------- setup() function -------------*/
667-
data += " setup() {\n return {\n";
663+
data = " setup() {"
664+
if(activeComp.state.length || activeComp.actions.length){
665+
data += " \n const /* testStore */ = useStore(); ";
666+
}
668667
htmlBinding.forEach((el) => {
669668
if (el.binding !== "") {
670669
data += ` ${el.binding}: "PLACEHOLDER FOR VALUE", `;
671670
data += "\n";
672671
}
673672
});
674-
data += ` }`;
675-
data += ` \n }, \n `;
673+
674+
let returnStatement = "";
675+
676+
if (activeComp.state.length || activeComp.actions.length) {
677+
returnStatement = "\n return { \n";
678+
}
679+
676680
677681
// if true add computed section and populate with state
678682
let computed = "";
679683
if (activeComp.state.length) {
680-
// data += " data: {";
681-
// computed += "\n ...mapState(/* store */, ["; `${activeComp.state}`
684+
const currState =
682685
activeComp.state.forEach((state) => {
683-
data += `\n /* store*/.${state}, `;
686+
data += `\n const ${state} = computed(() => /* testStore */.${state}); `;
687+
returnStatement += ` ${state}, \n`
688+
684689
});
685-
computed += "\n ]),\n";
686-
computed += " },\n";
690+
// line 22
687691
}
688692
693+
data += '\n };'
694+
689695
// if true add methods section and populate with actions
690696
let methods = "";
691697
if (activeComp.actions.length) {
692-
methods += " methods: {";
693-
methods += "\n ...mapActions(/* store */, [";
694698
activeComp.actions.forEach((action) => {
695-
methods += `\n /*store*/.${action}, `;
699+
methods += `\n const ${action} = () => /* testStore */.${action}();`;
700+
returnStatement += ` ${action}, \n`
696701
});
697-
methods += "\n ]),\n";
698-
methods += " },\n";
699702
}
700703
701704
let htmlArray = componentMap.value[componentName].htmlList;
@@ -747,16 +750,20 @@ const createBoilerComposition = (componentName: string, children: string[]) => {
747750
componentName +
748751
"'";
749752
}
750-
output += ",\n components: {\n";
753+
output += ",\n components: {";
751754
output += childrenComponentNames + " },\n";
752755
output += data;
753756
output += computed;
754757
output += methods;
755758
756759
if (exportAsTypescript.value === "on") {
757760
output += "});\n<\/script>\n\n<style scoped>\n</style>";
761+
} else if (activeComp.state.length || activeComp.actions.length) {
762+
output += ` \n}; \n ${returnStatement} };
763+
\n<\/script>\n\n<style scoped>\n${styleString}</style > `;
758764
} else {
759-
output += `}; \n <\/script>\n\n<style scoped>\n${styleString}</style > `;
765+
output += ` \n}; \n
766+
\n<\/script>\n\n<style scoped>\n${styleString}</style > `;
760767
}
761768
762769
return output;

0 commit comments

Comments
 (0)