调整低代码生成路径
This commit is contained in:
@@ -4,7 +4,7 @@ const {checkJson} = require("./index");
|
|||||||
/**
|
/**
|
||||||
* 生成入口页
|
* 生成入口页
|
||||||
*/
|
*/
|
||||||
const genHome = app => {
|
const genHome = (app, dest) => {
|
||||||
return readFile('./tpl/AppEntry.vue').then(data => {
|
return readFile('./tpl/AppEntry.vue').then(data => {
|
||||||
let file = data.toString(),
|
let file = data.toString(),
|
||||||
content = file.replace(/@appName/g, app.appName)
|
content = file.replace(/@appName/g, app.appName)
|
||||||
@@ -15,13 +15,13 @@ const genHome = app => {
|
|||||||
props.length > 0 && (dicts = props.map(e => `'${e}'`).toString())
|
props.length > 0 && (dicts = props.map(e => `'${e}'`).toString())
|
||||||
}
|
}
|
||||||
content = content.replace(/@dicts/g, dicts)
|
content = content.replace(/@dicts/g, dicts)
|
||||||
return fse.outputFileSync(`./zips/${app.id}/${app.appName}.vue`, content)
|
return fse.outputFileSync(`${dest}/${app.appName}.vue`, content)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 生成列表页
|
* 生成列表页
|
||||||
*/
|
*/
|
||||||
const genList = app => {
|
const genList = (app, dest) => {
|
||||||
return readFile('./tpl/list.vue').then(data => {
|
return readFile('./tpl/list.vue').then(data => {
|
||||||
let file = data.toString(),
|
let file = data.toString(),
|
||||||
content = file.replace(/@rightCode/g, app.rightCode)
|
content = file.replace(/@rightCode/g, app.rightCode)
|
||||||
@@ -65,13 +65,13 @@ const genList = app => {
|
|||||||
.replace(/@searchProps/g, searchProps)
|
.replace(/@searchProps/g, searchProps)
|
||||||
.replace(/@btns/g, btns)
|
.replace(/@btns/g, btns)
|
||||||
.replace(/@tableBtns/g, tableBtns)
|
.replace(/@tableBtns/g, tableBtns)
|
||||||
return fse.outputFileSync(`./zips/${app.id}/list.vue`, content)
|
return fse.outputFileSync(`${dest}/list.vue`, content)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 生成新增/编辑页
|
* 生成新增/编辑页
|
||||||
*/
|
*/
|
||||||
const genAdd = app => {
|
const genAdd = (app, dest) => {
|
||||||
return readFile('./tpl/add.vue').then(data => {
|
return readFile('./tpl/add.vue').then(data => {
|
||||||
let file = data.toString(),
|
let file = data.toString(),
|
||||||
content = file.replace(/@rightCode/g, app.rightCode)
|
content = file.replace(/@rightCode/g, app.rightCode)
|
||||||
@@ -92,7 +92,7 @@ const genAdd = app => {
|
|||||||
}
|
}
|
||||||
content = content.replace(/@content/g, domain)
|
content = content.replace(/@content/g, domain)
|
||||||
.replace(/@rules/g, rules)
|
.replace(/@rules/g, rules)
|
||||||
return fse.outputFileSync(`./zips/${app.id}/add.vue`, content)
|
return fse.outputFileSync(`${dest}/add.vue`, content)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const getComp = e => {
|
const getComp = e => {
|
||||||
@@ -149,9 +149,8 @@ const getComp = e => {
|
|||||||
}
|
}
|
||||||
const generate = (app, dest) => {
|
const generate = (app, dest) => {
|
||||||
fse.emptydirSync(dest)
|
fse.emptydirSync(dest)
|
||||||
fse.emptydirSync(`./zips/${app.id}`)
|
let tasks = [genHome(app, dest), genList(app, dest)]
|
||||||
let tasks = [genHome(app), genList(app)]
|
app.detailType == 0 && tasks.push(genAdd(app, dest))
|
||||||
app.detailType == 0 && tasks.push(genAdd(app))
|
|
||||||
return Promise.all(tasks)
|
return Promise.all(tasks)
|
||||||
}
|
}
|
||||||
module.exports = generate
|
module.exports = generate
|
||||||
|
|||||||
Reference in New Issue
Block a user