waibu-mpa 2.17.1 → 2.18.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.
@@ -3,7 +3,7 @@ import path from 'path'
3
3
  export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefix, subRoute }) {
4
4
  const { defaultsDeep, parseObject } = this.app.lib.aneka
5
5
  const { importModule, readJson } = this.app.bajo
6
- const { isFunction, isPlainObject, pick, last, camelCase, omit } = this.app.lib._
6
+ const { isFunction, isPlainObject, pick, last, camelCase, omit, trimEnd } = this.app.lib._
7
7
  const { titleize } = this.app.lib.aneka
8
8
  const { getPluginPrefix } = this.app.waibu
9
9
  const mergeRouteHooks = await importModule('waibu:/lib/webapp-scope/merge-route-hooks.js')
@@ -11,7 +11,9 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
11
11
  const me = this
12
12
  for (const f of files) {
13
13
  const ext = path.extname(f)
14
- const url = f.slice(0, f.length - ext.length).replace(`${dir}/extend/${pathPrefix}`, '').replaceAll('@', ':')
14
+ const urls = f.slice(0, f.length - ext.length).replace(`${dir}/extend/${pathPrefix}`, '').replaceAll('@', ':').split('/')
15
+ if (last(urls) === 'index') urls.pop()
16
+ const url = urls.join('/')
15
17
  let mod
16
18
  if (ext === '.js') mod = await importModule(f)
17
19
  else if (ext === '.json') mod = await readJson(f)
@@ -21,11 +23,10 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
21
23
  else if (isPlainObject(mod)) mod = [mod]
22
24
  for (let m of mod) {
23
25
  const mhandler = m.handler // parseObject has problem with function
24
- const murl = m.url
26
+ const murl = m.url // same as above
25
27
  m = parseObject(omit(m, ['handler', 'url'], { parseValue: true }))
26
- m.handler = mhandler
27
28
  m.url = murl
28
-
29
+ m.handler = mhandler
29
30
  m.url = m.url ?? url
30
31
  if (isFunction(m.url)) m.url = await m.url.call(this)
31
32
  if (m.redirect) {
@@ -45,6 +46,7 @@ export async function build ({ files, pathPrefix, dir, ns, cfg, parent, urlPrefi
45
46
  }
46
47
  }
47
48
  if (urlPrefix) m.url = `/${urlPrefix}/${m.url}`
49
+ m.url = trimEnd(m.url, '/')
48
50
  m.method = m.method ?? 'GET'
49
51
  await mergeRouteHooks.call(me, m)
50
52
  m.config = m.config ?? {}
@@ -26,6 +26,7 @@ async function widgetFactory () {
26
26
  this.formData = get(this, `component.locals.${this.params.attr.keyLocals ?? 'form'}`, {})
27
27
  this.oldData = get(this, `component.locals.${this.params.attr.keyOldData ?? 'oldData'}`, {})
28
28
  this.schema = get(this, `component.locals.${this.params.attr.keySchema ?? 'schema'}`, {})
29
+ if (this.schema.name) this.model = this.app.dobo.getModel(this.schema.name)
29
30
  }
30
31
 
31
32
  _parseBase64Attr = (text, defValue = {}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-mpa",
3
- "version": "2.17.1",
3
+ "version": "2.18.0",
4
4
  "description": "MPA support for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-06-03
4
+
5
+ - [2.18.0] Populate ```widget.model``` if available
6
+ - [2.18.0] If route's url ends with ```index```, rewrite url to use it's folder instead
7
+
3
8
  ## 2026-06-01
4
9
 
5
10
  - [2.17.1] Bug fix in ```component.buildTag()```