liveeditor import defect

pull/1792/head
Tuğçe Küçükoğlu 2021-11-18 09:49:20 +03:00
parent e81c0d1106
commit 20bf5b3026
1 changed files with 58 additions and 58 deletions

View File

@ -437,6 +437,64 @@ export default {
else { else {
element += `import ${name} from "./${name}.vue"`; 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'] = { _files['src/main.js'] = {
content: `import "primeflex/primeflex.css"; content: `import "primeflex/primeflex.css";
import "primevue/resources/themes/saga-blue/theme.css"; import "primevue/resources/themes/saga-blue/theme.css";
@ -668,64 +726,6 @@ app.mount("#app");
content: `${content} 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); return this.createSandboxParameters(sourceType, `${name}${extension}`, _files, extDependencies);