waibu-maps 1.0.2 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-maps",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Maps for Waibu MPA",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  import control from './control.js'
2
+ import path from 'path'
2
3
  const prefix = 'clogo'
3
4
 
4
5
  async function controlLogo () {
@@ -11,7 +12,7 @@ async function controlLogo () {
11
12
  }
12
13
 
13
14
  async build () {
14
- const { fastGlob } = this.plugin.app.bajo.lib
15
+ const { fs, fastGlob } = this.plugin.app.bajo.lib
15
16
  const { routePath } = this.plugin.app.waibu
16
17
  const { jsonStringify, groupAttrs, attribsStringify } = this.plugin.app.waibuMpa
17
18
  const opts = { class: prefix }
@@ -19,9 +20,16 @@ async function controlLogo () {
19
20
  const group = groupAttrs(this.params.attr, ['img'])
20
21
  const img = group.img ?? {}
21
22
  let logo = 'waibu'
23
+ let logoAlt
22
24
  const files = await fastGlob(`${this.plugin.app.main.dir.pkg}/bajo/logo.*`)
23
- if (files.length > 0) logo = 'main'
25
+ if (files.length > 0) {
26
+ const dir = path.dirname(files[0])
27
+ const ext = path.extname(files[0])
28
+ logoAlt = fs.existsSync(`${dir}/logo-alt${ext}`)
29
+ logo = 'main'
30
+ }
24
31
  img.src = routePath(`waibuMpa:/logo/${logo}`)
32
+ if (logoAlt) img.srcHover = routePath(`waibuMpa:/logo/${logo}?type=alt`)
25
33
  let animate = '@mouseenter="$el.style.opacity = 1" @mouseleave="$el.style.opacity = 0.3" '
26
34
  if (this.params.attr.noAnimate) {
27
35
  animate = ''