uodate liveeditor

pull/1143/head
Tuğçe Küçükoğlu 2021-03-23 10:46:22 +03:00
parent 0521d3ea08
commit ef8133e5e9
1 changed files with 27 additions and 27 deletions

View File

@ -34,7 +34,7 @@ export default {
type: Array, type: Array,
default: null default: null
}, },
components: { extPages: {
type: Array, type: Array,
default: null default: null
} }
@ -119,7 +119,7 @@ export default {
let extImport = ''; let extImport = '';
let extElement = ''; let extElement = '';
let content = this.sources[sourceType].content.replace('<\\/script>', '<\/script>'); let content = this.sources[sourceType].content.replace('<\\/script>', '<\/script>');
let pages = this.sources.pages ? this.sources.pages : ''; let pages = this.extPages ? this.extPages : '';
let _files = {}, element = ''; let _files = {}, element = '';
if(name === 'EditorDemo') { if(name === 'EditorDemo') {
@ -170,9 +170,15 @@ export default {
element += `import ${name} from "./${name}.vue"`; element += `import ${name} from "./${name}.vue"`;
_files['src/main.js'] = { _files['src/main.js'] = {
content: `import { createApp } from "vue"; content: `import "primeflex/primeflex.css";
import "primevue/resources/themes/saga-blue/theme.css";
import "primevue/resources/primevue.min.css";
import "primeicons/primeicons.css";
import "./index.css";
import { createApp } from "vue";
${element} ${element}
import router from "./router"; import { router } from "./router";
import PrimeVue from "primevue/config"; import PrimeVue from "primevue/config";
import AutoComplete from 'primevue/autocomplete'; import AutoComplete from 'primevue/autocomplete';
import Accordion from 'primevue/accordion'; import Accordion from 'primevue/accordion';
@ -263,12 +269,6 @@ import TreeTable from 'primevue/treetable';
import TriStateCheckbox from 'primevue/tristatecheckbox'; import TriStateCheckbox from 'primevue/tristatecheckbox';
${extImport} ${extImport}
import "primeflex/primeflex.css";
import "primevue/resources/themes/saga-blue/theme.css";
import "primevue/resources/primevue.min.css";
import "primeicons/primeicons.css";
import "./index.css";
const app = createApp(${name}); const app = createApp(${name});
app.use(PrimeVue, { ripple: true }); app.use(PrimeVue, { ripple: true });
@ -594,36 +594,26 @@ img.flag {
`, `,
} }
_files[`src/router.js`] = {
content: `import { createRouter, createWebHistory } from "vue-router";
${element}
export const router = createRouter({
history: createWebHistory(),
routes: [{ path: "/", component: ${name} }]
});`
}
if(pages) { if(pages) {
const routes = []; const routes = [];
pages.forEach((page, i) => { pages.forEach((page, i) => {
_files[`src/components/${page.name}.vue`] = { _files[`src/components/${page.tabName}.vue`] = {
'content': `${page.template.replace('<\\/script>', '<\/script>')}` 'content': `${page.content.replace('<\\/script>', '<\/script>')}`
} }
let route = ''; let route = '';
if(i === 0) { if(i === 0) {
route += `{ route += `{
path: "", path: "/",
component: () => import("./components/${page.name}.vue") component: () => import("./components/${page.tabName}.vue")
}`; }`;
} }
else { else {
route += `{ route += `{
path: "/${page.name.slice(0, -4).toLowerCase()}", path: "/${page.tabName.slice(0, -4).toLowerCase()}",
component: () => import("./components/${page.name}.vue") component: () => import("./components/${page.tabName}.vue")
}`; }`;
} }
@ -638,14 +628,24 @@ export const router = createRouter({
routes: [ routes: [
{ {
path: "/", path: "/",
component: () => import("./components/${name}.vue"), component: () => import("./${name}.vue"),
children: [${routes}] children: [${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(`${name}${extension}`, _files, extDependencies); return this.createSandboxParameters(`${name}${extension}`, _files, extDependencies);