63 lines
2.2 KiB
JavaScript
63 lines
2.2 KiB
JavaScript
const {chalkTag, findPages, fsExtra, fs} = require("./tools");
|
|
const PageBase = require("./PageBase");
|
|
const start = () => {
|
|
chalkTag.info('开始生成pages.json...')
|
|
let json = {
|
|
easycom: {
|
|
autoscan: true,
|
|
custom: {
|
|
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
|
|
}
|
|
},
|
|
pages: [
|
|
{path: 'pages/home', style: {navigationBarTitleText: "buy-lite"}},
|
|
],
|
|
subPackages: [
|
|
{root: "mods/", pages: []},
|
|
{root: "components/pages/", pages: []},
|
|
],
|
|
tabBar: {
|
|
// position: "top",
|
|
color: "#ddd",
|
|
selectedColor: "#92ACD1",
|
|
fontSize: "12px",
|
|
list: [
|
|
{text: "店铺", pagePath: "pages/home", iconPath: "static/tabbar/home.png", selectedIconPath: "static/tabbar/home-s.png"},
|
|
{text: "购物车", pagePath: "pages/AppCart", iconPath: "static/tabbar/cart.png", selectedIconPath: "static/tabbar/cart-s.png"},
|
|
{text: "我的", pagePath: "pages/AppMine", iconPath: "static/tabbar/mine.png", selectedIconPath: "static/tabbar/mine-s.png"},
|
|
]
|
|
},
|
|
globalStyle: {
|
|
pageOrientation: "auto",
|
|
navigationBarTextStyle: "white",
|
|
navigationBarBackgroundColor: "#92ACD1"
|
|
}
|
|
}
|
|
Promise.all([
|
|
findPages('src/components/pages', file => {
|
|
if (/.+\\pages\\[^\\]+\.vue/g.test(file)) {
|
|
const app = new PageBase(file.replace(/^src\\components\\pages\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
|
return json.subPackages[1].pages.push(app)
|
|
}
|
|
}),
|
|
findPages('src/mods', file => {
|
|
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
|
const app = new PageBase(file.replace(/^src\\mods\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
|
return json.subPackages[0].pages.push(app)
|
|
}
|
|
}),
|
|
findPages('src/pages', file => {
|
|
if (/.+\\App[^\\]+\.vue/g.test(file)) {
|
|
const app = new PageBase(file.replace(/^src\\pages\\(.*).vue/g, 'pages/$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
|
return json.pages.push(app)
|
|
}
|
|
}),
|
|
]).then(() => {
|
|
fsExtra.outputJson('src/pages.json', json, () => {
|
|
chalkTag.done('生成pages.json')
|
|
})
|
|
})
|
|
}
|
|
|
|
start();
|