waibu 1.1.14 → 1.1.15

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.
@@ -11,18 +11,20 @@ function buildHomesMenu (req) {
11
11
  }
12
12
 
13
13
  function buildPagesMenu (req) {
14
- const { orderBy } = this.lib._
14
+ const { find, orderBy, merge } = this.lib._
15
15
  const all = [{ icon: 'house', href: '/', level: 1 }]
16
16
  for (const ns of this.app.bajo.pluginNames) {
17
17
  const items = []
18
18
  const pages = this.app[ns].getConfig('waibuMpa.pages', { defValue: [] })
19
19
  if (pages.length === 0) continue
20
20
  for (const page of pages) {
21
+ const existing = find(all, { title: page.title })
21
22
  page.level = page.level ?? 1000
22
23
  if (page.visible === 'auth' && !req.user) continue
23
24
  if (page.visible === 'anon' && req.user) continue
24
25
  if (!page.children) {
25
- items.push(page)
26
+ if (existing) merge(existing, page)
27
+ else items.push(page)
26
28
  continue
27
29
  }
28
30
  const children = []
@@ -33,7 +35,8 @@ function buildPagesMenu (req) {
33
35
  }
34
36
  if (children.length > 0) {
35
37
  page.children = children
36
- items.push(page)
38
+ if (existing) existing.children.push(...page.children)
39
+ else items.push(page)
37
40
  }
38
41
  }
39
42
  all.push(...items)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {