抽取页面对象类
This commit is contained in:
25
bin/pages.js
25
bin/pages.js
@@ -1,16 +1,8 @@
|
|||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const {chalkTag, findPages, fsExtra, fs} = require("./tools");
|
const {chalkTag, findPages, fsExtra, fs} = require("./tools");
|
||||||
|
const PageBase = require("dvcp-wui/utils/PageBase");
|
||||||
let apps = {list: [], desc: "用于产品库主页面获取应用使用", type: "mp"}
|
let apps = {list: [], desc: "用于产品库主页面获取应用使用", type: "mp"}
|
||||||
const getFileInfo = (app, file) => {
|
const getFileInfo = (app, file) => {
|
||||||
let vue = fs.readFileSync(file).toString()
|
|
||||||
if (/appName/.test(vue)) {
|
|
||||||
let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1')
|
|
||||||
app.label = appName.replace(/(appName:|["'])/g, '')?.trim()
|
|
||||||
if (/customNavigation/.test(vue)) {
|
|
||||||
app.style = {navigationStyle: "custom"}
|
|
||||||
} else
|
|
||||||
app.style = {navigationBarTitleText: app.label}
|
|
||||||
}
|
|
||||||
if (/^App/.test(app.name)) {
|
if (/^App/.test(app.name)) {
|
||||||
let {name, label} = app,
|
let {name, label} = app,
|
||||||
path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/mods/$1/$2`)
|
path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/mods/$1/$2`)
|
||||||
@@ -56,30 +48,21 @@ const start = () => {
|
|||||||
Promise.all([
|
Promise.all([
|
||||||
findPages('src/components/pages', file => {
|
findPages('src/components/pages', file => {
|
||||||
if (/.+\\pages\\[^\\]+\.vue/g.test(file)) {
|
if (/.+\\pages\\[^\\]+\.vue/g.test(file)) {
|
||||||
let app = {
|
const app = new PageBase(file.replace(/^src\\components\\pages\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
||||||
path: file.replace(/^src\\components\\pages\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
|
||||||
}
|
|
||||||
getFileInfo(app, file)
|
getFileInfo(app, file)
|
||||||
return json.subPackages[1].pages.push(app)
|
return json.subPackages[1].pages.push(app)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
findPages('src/mods', file => {
|
findPages('src/mods', file => {
|
||||||
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||||
let app = {
|
const app = new PageBase(file.replace(/^src\\mods\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
||||||
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
|
||||||
path: file.replace(/^src\\mods\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
|
||||||
}
|
|
||||||
getFileInfo(app, file)
|
getFileInfo(app, file)
|
||||||
return json.subPackages[0].pages.push(app)
|
return json.subPackages[0].pages.push(app)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
findPages('src/project', file => {
|
findPages('src/project', file => {
|
||||||
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||||
let app = {
|
const app = new PageBase(file.replace(/^src\\project\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
||||||
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
|
||||||
path: file.replace(/^src\\project\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
|
||||||
}
|
|
||||||
console.log(app)
|
|
||||||
getFileInfo(app, file)
|
getFileInfo(app, file)
|
||||||
return json.subPackages[2].pages.push(app)
|
return json.subPackages[2].pages.push(app)
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/components/utils/PageBase.js
Normal file
35
src/components/utils/PageBase.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
export default class PageBase {
|
||||||
|
constructor(path, vue) {
|
||||||
|
this.path = path
|
||||||
|
this.name = path.replace(/.*\\([^\\]+).vue/g, '$1')
|
||||||
|
this.init(vue)
|
||||||
|
}
|
||||||
|
|
||||||
|
init(vue) {
|
||||||
|
if (/customNavigation/.test(vue)) {
|
||||||
|
this.style = {navigationStyle: "custom"}
|
||||||
|
} else {
|
||||||
|
this.style = {navigationBarTitleText: this.label}
|
||||||
|
//是否开启下拉刷新
|
||||||
|
if (/enablePullDownRefresh/.test(vue)) {
|
||||||
|
this.style.enablePullDownRefresh = true
|
||||||
|
}
|
||||||
|
//导航栏标题颜色及状态栏前景颜色,仅支持 black/white
|
||||||
|
if (/navigationBarTextStyle/.test(vue)) {
|
||||||
|
this.style.navigationBarTextStyle = vue.replace(/[\s\S]*(navigationBarTextStyle:.+),[\s\S]*/gm, '$1')
|
||||||
|
}
|
||||||
|
//导航栏背景颜色(同状态栏背景色)
|
||||||
|
if (/navigationBarBackgroundColor/.test(vue)) {
|
||||||
|
this.style.navigationBarBackgroundColor = vue.replace(/[\s\S]*(navigationBarBackgroundColor:.+),[\s\S]*/gm, '$1')
|
||||||
|
}
|
||||||
|
//下拉显示出来的窗口的背景色
|
||||||
|
if (/backgroundColor/.test(vue)) {
|
||||||
|
this.style.backgroundColor = vue.replace(/[\s\S]*(backgroundColor:.+),[\s\S]*/gm, '$1')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (/appName/.test(vue)) {
|
||||||
|
let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1')
|
||||||
|
this.label = appName.replace(/(appName:|["'])/g, '')?.trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user