waibu-mpa 2.1.3 → 2.1.5
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.
|
@@ -8,6 +8,8 @@ class Wmpa {
|
|
|
8
8
|
this.prefixMain = '<%= prefix.main %>'
|
|
9
9
|
this.accessTokenUrl = '<%= accessTokenUrl %>'
|
|
10
10
|
this.renderUrl = '<%= renderUrl %>'
|
|
11
|
+
this.theme = '<%= _meta.theme.name %>'
|
|
12
|
+
this.iconset = '<%= _meta.iconset.name %>'
|
|
11
13
|
this.apiPrefix = '<%= api.prefix %>'
|
|
12
14
|
this.apiExt = '<%= api.ext %>'
|
|
13
15
|
this.apiHeaderKey = '<%= api.headerKey %>'
|
|
@@ -101,14 +103,22 @@ class Wmpa {
|
|
|
101
103
|
fetchRender = async (body, qs = {}) => {
|
|
102
104
|
if (_.isArray(body)) body = body.join('\n')
|
|
103
105
|
let url = this.renderUrl + '?'
|
|
104
|
-
_.forOwn(qs, (v, k) => {
|
|
106
|
+
_.forOwn(_.omit(qs, ['theme', 'iconset']), (v, k) => {
|
|
105
107
|
url += '&' + k + '=' + v
|
|
106
108
|
})
|
|
107
|
-
const
|
|
109
|
+
const opts = {
|
|
108
110
|
method: 'POST',
|
|
109
|
-
headers: {
|
|
111
|
+
headers: {
|
|
112
|
+
'Content-Type': 'text/plain',
|
|
113
|
+
'X-Referer': window.location.href,
|
|
114
|
+
'X-Theme': this.theme,
|
|
115
|
+
'X-Iconset': this.iconset
|
|
116
|
+
},
|
|
110
117
|
body
|
|
111
|
-
}
|
|
118
|
+
}
|
|
119
|
+
if (qs.theme) opts.headers['X-Theme'] = qs.theme
|
|
120
|
+
if (qs.iconset) opts.headers['X-Iconset'] = qs.iconset
|
|
121
|
+
const resp = await fetch(url, opts)
|
|
112
122
|
if (!resp.ok) throw new Error('Response status: ' + resp.status)
|
|
113
123
|
return await resp.text()
|
|
114
124
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const component = {
|
|
2
2
|
method: 'POST',
|
|
3
3
|
handler: async function (req, reply) {
|
|
4
|
-
req.referer = req.headers['
|
|
4
|
+
req.referer = req.headers['x-referer']
|
|
5
5
|
const { ext = '.html' } = req.body
|
|
6
6
|
reply.header('Content-Type', `text/html; charset=${this.config.page.charset}`)
|
|
7
7
|
reply.header('Content-Language', req.lang)
|
|
8
|
-
const opts = { req, reply, partial: true, ext, theme: req.
|
|
8
|
+
const opts = { req, reply, partial: true, ext, theme: req.headers['x-theme'], iconset: req.headers['x-iconset'] }
|
|
9
9
|
return this.renderString(req.body, req.query, opts)
|
|
10
10
|
}
|
|
11
11
|
}
|
package/index.js
CHANGED
|
@@ -628,6 +628,18 @@ async function factory (pkgName) {
|
|
|
628
628
|
})
|
|
629
629
|
return attrs.join(' ')
|
|
630
630
|
}
|
|
631
|
+
|
|
632
|
+
getTheme = (name, nameOnly) => {
|
|
633
|
+
const theme = this.themes.find(item => item.name === name)
|
|
634
|
+
if (!theme) return theme
|
|
635
|
+
return nameOnly ? theme.name : theme
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
getIconset = (name, nameOnly) => {
|
|
639
|
+
const iconset = this.iconsets.find(item => item.name === name)
|
|
640
|
+
if (!iconset) return iconset
|
|
641
|
+
return nameOnly ? iconset.name : iconset
|
|
642
|
+
}
|
|
631
643
|
}
|
|
632
644
|
|
|
633
645
|
return WaibuMpa
|
|
@@ -9,7 +9,6 @@ async function injectElements (options) {
|
|
|
9
9
|
const { runHook } = this.app.bajo
|
|
10
10
|
const { get, isString, isFunction, isEmpty } = this.app.lib._
|
|
11
11
|
$('html').attr('lang', req.lang)
|
|
12
|
-
if (req.darkMode) $('body').attr('data-bs-theme', 'dark')
|
|
13
12
|
const rsc = {}
|
|
14
13
|
for (const tag of reply.ctags ?? []) {
|
|
15
14
|
let Builder = get(cmp, `widget.${tag}`)
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED