waibu-mpa 1.2.8 → 1.2.10
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/class/component.js +2 -1
- package/package.json +1 -1
- package/waibuMpa/route/logo/@id.js +9 -12
package/lib/class/component.js
CHANGED
|
@@ -251,8 +251,9 @@ class Component {
|
|
|
251
251
|
* @returns {string} The built URL.
|
|
252
252
|
*/
|
|
253
253
|
buildUrl = ({ exclude, prefix, base, url, params = {}, prettyUrl }) => {
|
|
254
|
+
const { isEmpty } = this.plugin.lib._
|
|
254
255
|
const { buildUrl } = this.plugin.app.waibuMpa
|
|
255
|
-
url = url ?? this.req.referer
|
|
256
|
+
url = url ?? (isEmpty(this.req.referer) ? this.req.url : this.req.referer)
|
|
256
257
|
return buildUrl({ exclude, prefix, base, url, params, prettyUrl })
|
|
257
258
|
}
|
|
258
259
|
|
package/package.json
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
async function logo (req, reply) {
|
|
4
|
-
const { importPkg } = this.app.bajo
|
|
5
|
-
const mime = await importPkg('waibu:mime')
|
|
1
|
+
async function resolveFile (req) {
|
|
6
2
|
const { getPlugin } = this.app.bajo
|
|
7
3
|
const { camelCase } = this.lib._
|
|
8
|
-
const { fastGlob
|
|
4
|
+
const { fastGlob } = this.lib
|
|
9
5
|
const id = camelCase(req.params.id)
|
|
10
6
|
const plugin = getPlugin(id)
|
|
11
7
|
let type = ''
|
|
12
8
|
if (req.query.type) type = `-${req.query.type}`
|
|
13
9
|
const files = await fastGlob(`${plugin.dir.pkg}/logo${type}.*`)
|
|
14
10
|
if (files.length === 0) throw this.error('_notFound')
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
return files[0]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function logo (req, reply) {
|
|
15
|
+
const { importModule } = this.app.bajo
|
|
16
|
+
const handler = await importModule('waibu:/lib/handle-download.js')
|
|
17
|
+
return await handler.call(this, resolveFile, req, reply)
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
export default logo
|