waibu-mpa 2.18.2 → 2.19.0
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-routes.js +13 -19
- package/lib/class/widget/page-end.js +2 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +5 -0
package/lib/build-routes.js
CHANGED
|
@@ -72,14 +72,11 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
|
|
|
72
72
|
|
|
73
73
|
async function addRoutes ({ appPrefix, prefix, mods, appCtx, cfg }) {
|
|
74
74
|
const { importModule } = this.app.bajo
|
|
75
|
-
const isRouteDisabled =
|
|
75
|
+
const { isRouteDisabled } = this.app.waibu
|
|
76
76
|
const reroutedPath = await importModule('waibu:/lib/webapp-scope/rerouted-path.js')
|
|
77
77
|
for (const mod of mods) {
|
|
78
|
-
const fullPath = `/${appPrefix}${mod.url}`
|
|
79
|
-
if (
|
|
80
|
-
this.log.warn('routeDisabled%s%s', `${prefix}${fullPath}`, mod.method)
|
|
81
|
-
continue
|
|
82
|
-
}
|
|
78
|
+
const fullPath = appPrefix === '' ? mod.url : `/${appPrefix}${mod.url}`
|
|
79
|
+
if (isRouteDisabled(`${prefix === '' ? '' : `/${prefix}`}${fullPath}`)) continue
|
|
83
80
|
const rpath = await reroutedPath.call(this, fullPath, cfg.rerouted)
|
|
84
81
|
if (rpath) {
|
|
85
82
|
this.log.warn('rerouted%s%s', `${prefix}${fullPath}`, `${prefix}${rpath}`)
|
|
@@ -128,22 +125,19 @@ async function buildRoutes (prefix) {
|
|
|
128
125
|
subRoutes = groupBy(subRoutes, 'ns')
|
|
129
126
|
for (const k in subRoutes) {
|
|
130
127
|
const items = subRoutes[k]
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const appCtx = appCtxs[ns]
|
|
134
|
-
if (!appCtx) throw this.error('cantHaveSubroutesWithoutContext%s', ns)
|
|
135
|
-
let appPrefix = getPluginPrefix(sns)
|
|
136
|
-
if (sns === me.ns || (sns === me.app.mainNs && cfg.mountMainAsRoot)) appPrefix = ''
|
|
137
|
-
await runHook(`${me.ns}.${k}:beforeBuildSubRoutes`, appCtx, appPrefix)
|
|
128
|
+
const appCtx = appCtxs[k]
|
|
129
|
+
if (!appCtx) throw this.error('cantHaveSubroutesWithoutContext%s', k)
|
|
138
130
|
for (const item of items) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
const
|
|
131
|
+
let appPrefix = getPluginPrefix(k)
|
|
132
|
+
if (item.sns === me.ns || (item.sns === me.app.mainNs && cfg.mountMainAsRoot)) appPrefix = ''
|
|
133
|
+
await runHook(`${me.ns}.${k}:beforeBuildSubRoutes`, appCtx, appPrefix)
|
|
134
|
+
const scope = this.app[item.sns]
|
|
135
|
+
const pathPrefix = `waibuMpa/extend/${item.ns}/route/`
|
|
136
|
+
const urlPrefix = getPluginPrefix(item.sns)
|
|
137
|
+
const mods = await build.call(scope, { appCtx, files: [item.file], pathPrefix, dir: item.dir, ns: item.ns, cfg, parent: me.ns, urlPrefix, subRoute: item.sns })
|
|
144
138
|
await addRoutes.call(me, { appPrefix, prefix, mods, appCtx, cfg })
|
|
139
|
+
await runHook(`${me.ns}.${k}:afterBuildSubRoutes`, appCtx, appPrefix)
|
|
145
140
|
}
|
|
146
|
-
await runHook(`${me.ns}.${k}:afterBuildSubRoutes`, appCtx, appPrefix)
|
|
147
141
|
}
|
|
148
142
|
}
|
|
149
143
|
|
|
@@ -11,7 +11,7 @@ async function pageEndFactory () {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
build = async () => {
|
|
14
|
-
const { get } = this.app.lib._
|
|
14
|
+
const { get, isEmpty } = this.app.lib._
|
|
15
15
|
const { groupAttrs } = this.app.waibuMpa
|
|
16
16
|
const { widget, locals, req } = this.component
|
|
17
17
|
|
|
@@ -23,7 +23,7 @@ async function pageEndFactory () {
|
|
|
23
23
|
let tc = ''
|
|
24
24
|
if (!this.params.attr.noToastContainer && widget.toastStack && widget.toast) {
|
|
25
25
|
const toasts = []
|
|
26
|
-
if (get(locals, 'error')) {
|
|
26
|
+
if (get(locals, 'error') && !isEmpty(get(locals, '_meta.flash'))) {
|
|
27
27
|
const details = get(locals.error, 'details', [])
|
|
28
28
|
const attr = {
|
|
29
29
|
border: 'side:all width:0',
|
package/package.json
CHANGED