waibu 1.0.6 → 1.0.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.
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
function getPluginPrefix (base) {
|
|
1
|
+
function getPluginPrefix (base, webApp = 'waibuMpa') {
|
|
2
2
|
const { get, trim } = this.app.bajo.lib._
|
|
3
|
-
|
|
3
|
+
let prefix = get(this, `app.${base}.config.waibu.prefix`, this.app[base].alias)
|
|
4
|
+
if (base === 'main') {
|
|
5
|
+
const cfg = this.app[webApp].config
|
|
6
|
+
if (cfg.mountMainAsRoot) prefix = ''
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
return trim(prefix, '/')
|
|
5
10
|
}
|
|
6
11
|
|
package/lib/app.js
CHANGED
|
@@ -28,6 +28,11 @@ export async function boot () {
|
|
|
28
28
|
const mods = await collect.call(this)
|
|
29
29
|
await runHook(`${this.name}:beforeAppBoot`)
|
|
30
30
|
for (const m of mods) {
|
|
31
|
+
const disabled = this.app[m.ns].config.disabled
|
|
32
|
+
if (Array.isArray(disabled) && disabled.length === 1 && ['*', 'all'].includes(disabled[0])) {
|
|
33
|
+
this.log.warn('All %s routes are disabled by config', m.ns)
|
|
34
|
+
continue
|
|
35
|
+
}
|
|
31
36
|
await runHook(`${this.name}.${m.ns}:beforeAppBoot`)
|
|
32
37
|
this.log.debug('Boot app: %s', m.ns)
|
|
33
38
|
await this.instance.register(async (ctx) => {
|
|
@@ -59,6 +59,7 @@ async function attachI18N (detector = [], req, reply) {
|
|
|
59
59
|
if (req.lang) opts.lng = req.lang
|
|
60
60
|
req.i18n = this.app.bajoI18N.instance.cloneInstance(opts)
|
|
61
61
|
req.t = (...args) => {
|
|
62
|
+
// console.log(args)
|
|
62
63
|
// const defNs = get(req, 'routeOptions.config.ns', this.name)
|
|
63
64
|
return translate.call(this.app[defNs], req.i18n, ...args)
|
|
64
65
|
}
|