这节课我们将一起来掌握app.config.json文件如何解析
解析app-config.json 的文件内容
整个JSON 文件的内容比较多, 但在这个JSON文件中 对我们有用的信息只有 3个节点 分别是
pages
global
tabBar
- 解压不同的微信小程序JSON文件中比较有用的节点 还会包含
subPackages
(分包的内容后面有单独章节描述) - 目前我们只需要将
pages
global
tabBar
这几个节点分别解析出来就可以还原微信小程序的app.json
文件 - 对于
tabBar
这个配置项中iconData
与selectedIconData
配置项在小程序源文件中对应的名称应该是iconPath
与selectedIconPath
- 对于前者
iconData
与selectedIconData
的内容是 base64 的图片内容 , 而后者中的 iconPath 与 SelectedIconPath 是文件路径, 这里我们需要逐一对文件进行对比 并还原出图片的原路径信息 - 最后就是
tabBar
的页面路径 是不包含.html
后缀的 , 这里也需要替换掉哦
{
"entryPagePath": "pages/index/index.html",
"pages": [
"pages/index/index",
"pages/noteSearch/index",
"pages/searchBook/index",
"pages/addBook/index",
"pages/noteTree/index",
"pages/noteDetail/index",
"pages/my/home/index",
"pages/my/log/index",
"pages/my/about/index",
"pages/my/backup/index",
"pages/t-canvas-html/index",
"pages/noteCalendar/index"
],
"page": {
"pages/index/index.html": {
"window": {
"usingComponents": {
"cu-custom": "/colorui/components/cu-custom",
"i-toast": "../../dist/iview/toast/index",
"van-loading": "../../dist/vant/loading/index",
"l-slide-view": "../../dist/lin/slide-view/index"
},
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "",
"navigationBarTextStyle": "black",
"navigationStyle": "custom"
}
},
"pages/noteSearch/index.html": {
"window": {
"usingComponents": {
}, "navigationBarTitleText": "笔记搜索" }
},
"pages/searchBook/index.html": {
"window": {
"usingComponents": {
"cu-custom": "/colorui/components/cu-custom",
"i-toast": "../../dist/iview/toast/index",
"van-loading": "../../dist/vant/loading/index"
},
"navigationBarTitleText": "搜索书籍"
}
},
"pages/addBook/index.html": {
"window": {
"usingComponents": {
"i-toast": "../../dist/iview/toast/index" },
"navigationBarTitleText": "添加一本书"
}
},
"pages/noteTree/index.html": {
"window": {
"usingComponents": {
"i-toast": "../../dist/iview/toast/index",
"van-loading": "../../dist/vant/loading/index",
"wxml-to-canvas": "../../miniprogram_npm/wxml-to-canvas/index",
"l-slide-view": "../../dist/lin/slide-view/index",
"wux-swipe-action": "../../dist/wuxui/swipe-action/index",
"wux-swipe-action-group": "../../dist/wuxui/swipe-action-group/index",
"van-dialog": "../../dist/vant/dialog/index"
},
"navigationBarTitleText": "笔记树"
}
},
"pages/noteDetail/index.html": {
"window": {
"usingComponents": {
"i-toast": "../../dist/iview/toast/index" },
"navigationBarTitleText": "笔记详情"
}
},
"pages/my/home/index.html": {
"window": {
"usingComponents": {
"van-dialog": "../../../dist/vant/dialog/index" },
"navigationBarTitleText": "我的中心"
}