waibu 1.1.10 → 1.1.12
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 +13 -1
- package/package.json +1 -1
- package/plugin/factory.js +3 -2
package/lib/build-locals.js
CHANGED
|
@@ -10,6 +10,16 @@ function buildHomesMenu () {
|
|
|
10
10
|
return orderBy(routes, ['title'])
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function buildPagesMenu () {
|
|
14
|
+
const { get, orderBy } = this.lib._
|
|
15
|
+
const all = [{ icon: 'house', href: '/', title: 'home', level: 1 }]
|
|
16
|
+
for (const ns of this.app.bajo.pluginNames) {
|
|
17
|
+
const pages = get(this, `app.${ns}.config.waibuMpa.pages`, [])
|
|
18
|
+
if (pages.length === 0) continue
|
|
19
|
+
all.push(...pages)
|
|
20
|
+
}
|
|
21
|
+
return orderBy(all, ['level', 'title'])
|
|
22
|
+
}
|
|
13
23
|
async function buildLocals ({ tpl, params = {}, opts = {} } = {}) {
|
|
14
24
|
const { runHook } = this.app.bajo
|
|
15
25
|
const { set, merge, pick, get, isEmpty, find } = this.lib._
|
|
@@ -17,7 +27,6 @@ async function buildLocals ({ tpl, params = {}, opts = {} } = {}) {
|
|
|
17
27
|
|
|
18
28
|
const appTitle = this.app.waibuMpa ? req.t(this.app.waibuMpa.getAppTitle(req.ns)) : ''
|
|
19
29
|
params.page = merge(params.page ?? {}, { ns: req.ns, appTitle })
|
|
20
|
-
set(params, 'menu.homes', buildHomesMenu.call(this))
|
|
21
30
|
|
|
22
31
|
const { site, user, lang, darkMode } = req
|
|
23
32
|
const theme = pick(find(this.themes, { name: req.theme }) ?? {}, ['name', 'framework'])
|
|
@@ -33,6 +42,7 @@ async function buildLocals ({ tpl, params = {}, opts = {} } = {}) {
|
|
|
33
42
|
_meta.template = tpl
|
|
34
43
|
_meta.hostHeader = req.headers.host
|
|
35
44
|
_meta.statusCode = 200
|
|
45
|
+
_meta.isAdmin = _meta.user && find(_meta.user.teams, { alias: 'administrator' })
|
|
36
46
|
if (params.error) {
|
|
37
47
|
if (params.error.statusCode) _meta.statusCode = params.error.statusCode
|
|
38
48
|
_meta.errorMessage = params.error.message
|
|
@@ -44,6 +54,8 @@ async function buildLocals ({ tpl, params = {}, opts = {} } = {}) {
|
|
|
44
54
|
if (this.app.bajo.config.env === 'dev') console.log(params.error)
|
|
45
55
|
}
|
|
46
56
|
if (reply && req.session && req.flash && !opts.partial) _meta.flash = reply.flash()
|
|
57
|
+
set(params, 'menu.homes', buildHomesMenu.call(this))
|
|
58
|
+
set(params, 'menu.pages', buildPagesMenu.call(this))
|
|
47
59
|
const merged = merge({}, params, { _meta })
|
|
48
60
|
await runHook(`${this.name}:afterBuildLocals`, merged, req)
|
|
49
61
|
if (!isEmpty(routeOpts.ns)) await runHook(`${this.name}.${routeOpts.ns}:afterBuildLocals`, merged, req)
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -22,7 +22,7 @@ async function factory (pkgName) {
|
|
|
22
22
|
this.dependencies = ['bajo-logger', 'bajo-extra']
|
|
23
23
|
this.config = {
|
|
24
24
|
server: {
|
|
25
|
-
host: '
|
|
25
|
+
host: '127.0.0.1',
|
|
26
26
|
port: 7771
|
|
27
27
|
},
|
|
28
28
|
factory: {
|
|
@@ -292,7 +292,8 @@ async function factory (pkgName) {
|
|
|
292
292
|
}
|
|
293
293
|
const message = await render(tpl[0], locals, opts)
|
|
294
294
|
if (tpl[1]) opts.messageText = await render(tpl[1], locals, opts)
|
|
295
|
-
|
|
295
|
+
const payload = { type: 'object', data: { to, cc, bcc, from, subject, message, conn, options: opts } }
|
|
296
|
+
await this.app.masohi.send({ payload, source: this.name }, false) // mail sent through worker
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
unescapeBlock = (content, start, end, startReplacer, endReplacer) => {
|