waibu 1.2.6 → 1.2.8
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
CHANGED
|
@@ -5,7 +5,7 @@ async function buildHomesMenu (req) {
|
|
|
5
5
|
for (const ns of this.app.bajo.pluginNames) {
|
|
6
6
|
let home = get(this, `app.${ns}.config.waibuMpa.home`)
|
|
7
7
|
const homeHandler = get(this, `app.${ns}.config.waibuMpa.homeHandler`)
|
|
8
|
-
if (homeHandler) home = await callHandler(homeHandler)
|
|
8
|
+
if (homeHandler) home = await callHandler(this.app[ns], homeHandler)
|
|
9
9
|
if (!home) continue
|
|
10
10
|
const item = { href: home, ns, title: get(this, `app.${ns}.config.waibu.title`, this.app[ns].title) }
|
|
11
11
|
if (!find(routes, { href: home })) routes.push(item)
|
|
@@ -15,13 +15,14 @@ async function buildHomesMenu (req) {
|
|
|
15
15
|
|
|
16
16
|
async function buildPagesMenu (req) {
|
|
17
17
|
const { find, orderBy, merge, isString } = this.lib._
|
|
18
|
-
const { callHandler } = this.app.bajo
|
|
18
|
+
const { callHandler, runHook } = this.app.bajo
|
|
19
19
|
const all = [{ icon: 'house', href: '/', level: 1 }]
|
|
20
20
|
for (const ns of this.app.bajo.pluginNames) {
|
|
21
21
|
const items = []
|
|
22
22
|
let pages = this.app[ns].getConfig('waibuMpa.menuHandler', { defValue: [] })
|
|
23
|
-
if (isString(pages)) pages = await callHandler(pages, req)
|
|
23
|
+
if (isString(pages)) pages = await callHandler(this.app[ns], pages, req)
|
|
24
24
|
if (pages.length === 0) continue
|
|
25
|
+
await runHook(`${this.name}.${ns}:afterBuildPagesMenu`, pages, req)
|
|
25
26
|
for (const page of pages) {
|
|
26
27
|
const existing = find(all, { title: page.title })
|
|
27
28
|
page.level = page.level ?? 1000
|
|
@@ -55,6 +55,7 @@ async function attachIntl (detector = [], req, reply) {
|
|
|
55
55
|
req.t = (text, ...args) => {
|
|
56
56
|
args.push({ lang: req.lang })
|
|
57
57
|
return this.app[defNs].print.write(text, ...args)
|
|
58
|
+
// return result.replaceAll("'", ''').replaceAll('"', '"')
|
|
58
59
|
}
|
|
59
60
|
req.format = (value, type = 'auto', opts = {}) => {
|
|
60
61
|
opts.lang = opts.lang ?? req.lang
|