Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 18, 2021
2 parents ad89485 + 20bf5b3 commit b5a99ff
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions src/views/liveeditor/LiveEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,64 @@ export default {
else {
element += `import ${name} from "./${name}.vue"`;
if (this.component) {
extImport += `import ${this.component} from 'primevue/${this.component.toLowerCase()}';`
extElement += `app.component('${this.component}', ${this.component});`;
}
if (pages) {
let routes = [], routeImports = '';
pages.forEach((page, i) => {
_files[`src/components/${page.tabName}.vue`] = {
'content': `${page.content.replace('<\\/script>', '<\/script>')}`
}
let route = '';
routeImports += `import ${page.tabName} from './components/${page.tabName}.vue';
`;
if(i === 0) {
route += `{
path: "/",
component: ${page.tabName}
}`;
}
else {
route += `{
path: "/${page.tabName.slice(0, -4).toLowerCase()}",
component: ${page.tabName}
}`;
}
routes.push(route);
})
_files['src/router.js'] = {
'content': `import { createRouter, createWebHistory } from "vue-router";
${routeImports}
export const router = createRouter({
history: createWebHistory(),
routes: [
${routes}
]
});
`
}
}
else {
_files[`src/router.js`] = {
content: `import { createRouter, createWebHistory } from "vue-router";
${element}
export const router = createRouter({
history: createWebHistory(),
routes: [{ path: "/", component: ${name} }]
});`
}
}
_files['src/main.js'] = {
content: `import "primeflex/primeflex.css";
import "primevue/resources/themes/saga-blue/theme.css";
Expand Down Expand Up @@ -668,64 +726,6 @@ app.mount("#app");
content: `${content}
`
}
if (this.component) {
extImport += `import ${this.component} from 'primevue/${this.component.toLowerCase()}';`
extElement += `app.component('${this.component}', ${this.component});`;
}
if (pages) {
let routes = [], routeImports = '';
pages.forEach((page, i) => {
_files[`src/components/${page.tabName}.vue`] = {
'content': `${page.content.replace('<\\/script>', '<\/script>')}`
}
let route = '';
routeImports += `import ${page.tabName} from './components/${page.tabName}.vue';
`;
if(i === 0) {
route += `{
path: "/",
component: ${page.tabName}
}`;
}
else {
route += `{
path: "/${page.tabName.slice(0, -4).toLowerCase()}",
component: ${page.tabName}
}`;
}
routes.push(route);
})
_files['src/router.js'] = {
'content': `import { createRouter, createWebHistory } from "vue-router";
${routeImports}
export const router = createRouter({
history: createWebHistory(),
routes: [
${routes}
]
});
`
}
}
else {
_files[`src/router.js`] = {
content: `import { createRouter, createWebHistory } from "vue-router";
${element}
export const router = createRouter({
history: createWebHistory(),
routes: [{ path: "/", component: ${name} }]
});`
}
}
}
return this.createSandboxParameters(sourceType, `${name}${extension}`, _files, extDependencies);
Expand Down

0 comments on commit b5a99ff

Please sign in to comment.