waibu-mpa 2.18.2 → 2.20.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/extend/waibuMpa/route/logo/@id.js +2 -3
- package/index.js +2 -3
- package/lib/build-routes.js +13 -19
- package/lib/class/widget/page-end.js +2 -2
- package/lib/class/widget.js +1 -1
- package/lib/favicon.js +4 -4
- package/package.json +1 -1
- package/wiki/CHANGES.md +9 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
async function resolveFile (req) {
|
|
2
|
-
const { getPlugin, getPluginDataDir } = this.app.bajo
|
|
3
2
|
const { camelCase } = this.app.lib._
|
|
4
3
|
const { fastGlob } = this.app.lib
|
|
5
4
|
const id = camelCase(req.params.id)
|
|
@@ -7,7 +6,7 @@ async function resolveFile (req) {
|
|
|
7
6
|
let files
|
|
8
7
|
if (req.query.type) type = `-${req.query.type}`
|
|
9
8
|
if (id !== 'main') {
|
|
10
|
-
const plugin = getPlugin(id)
|
|
9
|
+
const plugin = this.app.getPlugin(id)
|
|
11
10
|
files = await fastGlob(`${plugin.dir.pkg}/logo${type}.*`)
|
|
12
11
|
if (files.length > 0) return files[0]
|
|
13
12
|
throw this.error('_notFound')
|
|
@@ -16,7 +15,7 @@ async function resolveFile (req) {
|
|
|
16
15
|
files = await fastGlob(`${this.app.main.dir.pkg}/logo${type}.*`)
|
|
17
16
|
// 2. site attachment
|
|
18
17
|
if (files.length > 0) return files[0]
|
|
19
|
-
let dir = getPluginDataDir('dobo')
|
|
18
|
+
let dir = this.app.getPluginDataDir('dobo')
|
|
20
19
|
files = await fastGlob(`${dir}/attachment/SumbaSite/${req.site.id}/file/logo${type}.*`)
|
|
21
20
|
if (files.length > 0) return files[0]
|
|
22
21
|
// 3. theme
|
package/index.js
CHANGED
|
@@ -199,9 +199,8 @@ async function factory (pkgName) {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
getPluginTitle = (name, req) => {
|
|
202
|
-
const { getPlugin } = this.app.bajo
|
|
203
202
|
const { get } = this.app.lib._
|
|
204
|
-
const plugin = getPlugin(name, true)
|
|
203
|
+
const plugin = this.app.getPlugin(name, true)
|
|
205
204
|
if (!plugin) return
|
|
206
205
|
const text = get(plugin, 'config.waibuMpa.title', plugin.ns)
|
|
207
206
|
return this.t(text, { lang: req.lang })
|
|
@@ -216,7 +215,7 @@ async function factory (pkgName) {
|
|
|
216
215
|
getResource (name) {
|
|
217
216
|
const subNses = ['layout', 'template', 'partial']
|
|
218
217
|
const { ns, path, subNs, subSubNs, qs } = this.app.bajo.breakNsPath(name)
|
|
219
|
-
const plugin = this.app.
|
|
218
|
+
const plugin = this.app.getPlugin(ns)
|
|
220
219
|
const dir = `${plugin.dir.pkg}/extend/waibuMpa`
|
|
221
220
|
if (!subNses.includes(subNs)) throw this.error('unknownResource%s', name)
|
|
222
221
|
const fullPath = subSubNs ? `${dir}/${subSubNs}/${subNs}${path}` : `${dir}/${subNs}${path}`
|
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/lib/class/widget.js
CHANGED
|
@@ -14,7 +14,7 @@ async function widgetFactory () {
|
|
|
14
14
|
super(component.plugin)
|
|
15
15
|
const names = kebabCase(this.constructor.name).split('-')
|
|
16
16
|
const alias = names.length > 1 ? names[0] : 'wbs'
|
|
17
|
-
let plugin = this.app.
|
|
17
|
+
let plugin = this.app.getPlugin(alias, true)
|
|
18
18
|
if (!plugin) plugin = this.app.waibuBootstrap
|
|
19
19
|
this.plugin = plugin
|
|
20
20
|
this.app = plugin.app
|
package/lib/favicon.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
async function handleFavicon () {
|
|
2
2
|
if (!this.config.favicon) return
|
|
3
|
-
const {
|
|
3
|
+
const { importModule } = this.app.bajo
|
|
4
4
|
const { fs } = this.app.lib
|
|
5
5
|
const handleDownload = await importModule('waibu:/lib/handle-download.js')
|
|
6
6
|
const me = this
|
|
7
7
|
this.webAppCtx.get('/favicon.:ext', async function (req, reply) {
|
|
8
8
|
// 1. main favicon
|
|
9
|
-
let file = getPluginFile(`main:/favicon.${req.params.ext}`)
|
|
9
|
+
let file = me.app.getPluginFile(`main:/favicon.${req.params.ext}`)
|
|
10
10
|
if (!fs.existsSync(file)) {
|
|
11
|
-
const dir = getPluginDataDir('dobo')
|
|
11
|
+
const dir = me.app.getPluginDataDir('dobo')
|
|
12
12
|
// 2. site attachment
|
|
13
13
|
file = `${dir}/attachment/SumbaSite/${req.site.id}/file/favicon.${req.params.ext}`
|
|
14
14
|
}
|
|
@@ -18,7 +18,7 @@ async function handleFavicon () {
|
|
|
18
18
|
file = `${theme.plugin.dir.pkg}/extend/waibuStatic/asset/favicon.${req.params.ext}`
|
|
19
19
|
}
|
|
20
20
|
// 4. Default
|
|
21
|
-
if (!fs.existsSync(file)) file = getPluginFile('waibu:/favicon.png')
|
|
21
|
+
if (!fs.existsSync(file)) file = me.app.getPluginFile('waibu:/favicon.png')
|
|
22
22
|
reply.header('cache-control', 'max-age=86400')
|
|
23
23
|
return await handleDownload.call(me, file, req, reply)
|
|
24
24
|
})
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-06-12
|
|
4
|
+
|
|
5
|
+
- [2.20.0] Necessary updates to ```bajo@2.18.0``` specs
|
|
6
|
+
|
|
7
|
+
## 2026-06-10
|
|
8
|
+
|
|
9
|
+
- [2.19.0] Remove route redirects because now directly handled by ```waibu```
|
|
10
|
+
- [2.19.0] Bug fix in ```page-end``` widget
|
|
11
|
+
|
|
3
12
|
## 2026-06-05
|
|
4
13
|
|
|
5
14
|
- [2.18.2] Bug fix in ```error-handler.js```
|