waibu 1.1.13 → 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.
- package/lib/build-locals.js +7 -3
- package/package.json +1 -1
- package/plugin/factory.js +6 -9
package/lib/build-locals.js
CHANGED
|
@@ -11,17 +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 })
|
|
22
|
+
page.level = page.level ?? 1000
|
|
21
23
|
if (page.visible === 'auth' && !req.user) continue
|
|
22
24
|
if (page.visible === 'anon' && req.user) continue
|
|
23
25
|
if (!page.children) {
|
|
24
|
-
|
|
26
|
+
if (existing) merge(existing, page)
|
|
27
|
+
else items.push(page)
|
|
25
28
|
continue
|
|
26
29
|
}
|
|
27
30
|
const children = []
|
|
@@ -32,7 +35,8 @@ function buildPagesMenu (req) {
|
|
|
32
35
|
}
|
|
33
36
|
if (children.length > 0) {
|
|
34
37
|
page.children = children
|
|
35
|
-
|
|
38
|
+
if (existing) existing.children.push(...page.children)
|
|
39
|
+
else items.push(page)
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
all.push(...items)
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -174,15 +174,12 @@ async function factory (pkgName) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
getPluginByPrefix = (prefix) => {
|
|
177
|
-
const { get } = this.lib._
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return plugin
|
|
177
|
+
const { get, find } = this.lib._
|
|
178
|
+
const item = find(this.app.waibu.routes, r => {
|
|
179
|
+
return get(r, 'config.prefix') === prefix
|
|
180
|
+
})
|
|
181
|
+
const ns = get(item, 'config.ns')
|
|
182
|
+
if (ns) return this.app[ns]
|
|
186
183
|
}
|
|
187
184
|
|
|
188
185
|
getPluginPrefix = (base, webApp = 'waibuMpa') => {
|