自动化页面标题,页面文件参数为appName
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
const fsExtra = require('fs-extra')
|
const fsExtra = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const vueLoader = require('vue-template-compiler')
|
||||||
/**
|
/**
|
||||||
* 将函数封装成promise
|
* 将函数封装成promise
|
||||||
*/
|
*/
|
||||||
@@ -70,10 +71,16 @@ const start = () => {
|
|||||||
}
|
}
|
||||||
findApp('src/apps', file => {
|
findApp('src/apps', file => {
|
||||||
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||||
|
let vue = vueLoader.parseComponent(fs.readFileSync(file)?.toString())
|
||||||
let app = {
|
let app = {
|
||||||
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
||||||
path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
||||||
}
|
}
|
||||||
|
if (/appName/.test(vue.script.content)) {
|
||||||
|
let appName = vue.script.content.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1'),
|
||||||
|
title = appName.replace(/(appName:|["'])/g, '')
|
||||||
|
app.style = {navigationBarTitleText: title}
|
||||||
|
}
|
||||||
json.pages.push(app)
|
json.pages.push(app)
|
||||||
}
|
}
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user