waibu 1.1.17 → 1.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/build-locals.js +7 -4
- package/lib/home.js +2 -1
- package/package.json +1 -1
- package/plugin/factory.js +1 -0
package/lib/build-locals.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
async function buildHomesMenu (req) {
|
|
2
|
+
const { callHandler } = this.app.bajo
|
|
2
3
|
const { get, find, orderBy } = this.lib._
|
|
3
4
|
const routes = []
|
|
4
5
|
for (const ns of this.app.bajo.pluginNames) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!
|
|
6
|
+
let home = get(this, `app.${ns}.config.waibuMpa.home`)
|
|
7
|
+
const homeHandler = get(this, `app.${ns}.config.waibuMpa.homeHandler`)
|
|
8
|
+
if (homeHandler) home = await callHandler(homeHandler)
|
|
9
|
+
if (!home) continue
|
|
10
|
+
const item = { href: home, ns, title: get(this, `app.${ns}.config.waibu.title`, this.app[ns].title) }
|
|
11
|
+
if (!find(routes, { href: home })) routes.push(item)
|
|
9
12
|
}
|
|
10
13
|
return orderBy(routes, ['title'])
|
|
11
14
|
}
|
package/lib/home.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
async function home () {
|
|
2
|
-
const { defaultsDeep } = this.app.bajo
|
|
2
|
+
const { defaultsDeep, callHandler } = this.app.bajo
|
|
3
3
|
const { isString, pick } = this.lib._
|
|
4
4
|
const config = this.getConfig()
|
|
5
5
|
if (config.home) {
|
|
6
6
|
if (isString(config.home)) config.home = { path: config.home }
|
|
7
|
+
if (config.home.pathHandler) config.home.path = await callHandler(config.home.pathHandler)
|
|
7
8
|
await this.instance.get('/', async function (req, reply) {
|
|
8
9
|
if (!config.home.forward) return reply.redirectTo(config.home.path)
|
|
9
10
|
const opts = defaultsDeep(pick(req, ['params', 'query']), pick(config.home, ['params', 'query']))
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -136,6 +136,7 @@ async function factory (pkgName) {
|
|
|
136
136
|
const { breakNsPath } = this.app.bajo
|
|
137
137
|
const { ns, subNs = '', path } = breakNsPath(route)
|
|
138
138
|
return find(this.routes, r => {
|
|
139
|
+
if (r.path.startsWith('*')) return false
|
|
139
140
|
r.config = r.config ?? {}
|
|
140
141
|
const match = outmatch(r.config.pathSrc ?? r.path, { separator: false })
|
|
141
142
|
if (!match(path)) return false
|