waibu-mpa 1.2.13 → 1.2.15

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/index.js CHANGED
@@ -15,6 +15,9 @@ async function factory (pkgName) {
15
15
  waibu: {
16
16
  prefix: ''
17
17
  },
18
+ waibuAdmin: {
19
+ modelDisabled: ['session']
20
+ },
18
21
  mountMainAsRoot: true,
19
22
  page: {
20
23
  charset: 'utf-8',
@@ -183,7 +186,7 @@ async function factory (pkgName) {
183
186
  const { get } = this.lib._
184
187
  const plugin = getPlugin(name, true)
185
188
  if (!plugin) return
186
- return get(plugin, 'config.waibu.title', plugin.title ?? plugin.name)
189
+ return get(plugin, 'config.waibu.title', get(plugin, 'config.waibu.prefix', plugin.title, plugin.title ?? plugin.name))
187
190
  }
188
191
 
189
192
  getResource (name) {
@@ -18,7 +18,9 @@ async function parseAttrib ({ $, el, req } = {}) {
18
18
  (['href', 'src', 'action'].includes(key) || key.includes('-href')) &&
19
19
  !(val.slice(1, 3) === '%=' && val[val.length - 2] === '%')) {
20
20
  el.attribs['o' + key] = val
21
- el.attribs[key] = routePath(val)
21
+ try {
22
+ el.attribs[key] = routePath(val)
23
+ } catch (err) {}
22
24
  }
23
25
  // translate
24
26
  if (key.slice(0, 2) === 't:') {
@@ -1,14 +1,20 @@
1
+ const omitted = ['css', 'style', 'scripts', 'ns', 'appTitle', 'title', 'fullTitle']
2
+ const names = ['description', 'keywords', 'robots', 'viewport', 'author', 'publisher',
3
+ 'application-name', 'generator', 'referrer', 'theme-color', 'googlebot'
4
+ ]
5
+
1
6
  async function meta (options) {
2
7
  const { runHook } = this.app.bajo
3
- const { map, uniq, isArray, merge, kebabCase, keys, omit } = this.lib._
8
+ const { map, uniq, isArray, merge, kebabCase, keys, omit, get, isFunction } = this.lib._
9
+ const { sprintf } = this.lib
4
10
  const { $, theme, req, locals } = options ?? {}
5
11
  const { page = {} } = locals
6
12
  let items = []
7
13
  // meta
8
14
  const links = ['preconnect', 'dnsPrefetch']
9
- const omitted = ['css', 'style', 'scripts', 'ns', 'appTitle', 'title', 'fullTitle']
10
15
  for (const attr of keys(omit(locals.page, [...links, ...omitted]))) {
11
16
  if (!page[attr]) continue
17
+ if (!names.includes(attr)) continue
12
18
  items.push({
13
19
  name: attr,
14
20
  content: isArray(page[attr]) ? page[attr].join(', ') : page[attr]
@@ -31,7 +37,13 @@ async function meta (options) {
31
37
  return `<${tag} ${attrs} />`
32
38
  })
33
39
  $('head').prepend(uniq(items).join('\n'))
34
- $('head').append(`<title>${page.fullTitle ?? page.title}</title>`)
40
+ const mainTitle = get(this, 'app.main.config.waibu.title', 'Waibu App')
41
+ const formatter = get(this, 'app.waibu.pageTitleFormat', '%s : %s')
42
+ const title = page.fullTitle ?? page.title
43
+ let pageTitle
44
+ if (isFunction(formatter)) pageTitle = await formatter.call(this, title, mainTitle, locals)
45
+ else pageTitle = sprintf(formatter, title, mainTitle)
46
+ $('head').append(`<title>${pageTitle}</title>`)
35
47
  }
36
48
 
37
49
  export default meta
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-mpa",
3
- "version": "1.2.13",
3
+ "version": "1.2.15",
4
4
  "description": "MPA support for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,3 +1,5 @@
1
1
  {
2
- "disabled": ["create", "update"]
2
+ "common": {
3
+ "disabled": ["create", "update"]
4
+ }
3
5
  }
@@ -1,11 +0,0 @@
1
- [{
2
- "ns": "waibuMpa",
3
- "key": "theme",
4
- "value": "bootstrap",
5
- "siteId": "?:SumbaSite::alias:default"
6
- }, {
7
- "ns": "waibuMpa",
8
- "key": "iconset",
9
- "value": "bootstrap-icons",
10
- "siteId": "?:SumbaSite::alias:default"
11
- }]