Skip to content

Commit

Permalink
fix: lyricHidden setting does not take effect
Browse files Browse the repository at this point in the history
  • Loading branch information
WRXinYue committed Mar 15, 2024
1 parent 72be20b commit f5c2b57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
7 changes: 4 additions & 3 deletions packages/valaxy-addon-meting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ export interface MetingOptions {
}
}
```

| Configuration Item | Description | Default Value |
| ------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------- |
| **lyricsLoadOnStart** (optional) | Specifies whether to hide the lyrics upon startup | `false` |
| **aplayerAutoHide** (optional) | Enables auto-hiding of the APlayer interface when not interacted with. Recommended for use with `aplayerVisibleAfterLoad` | `false` |
| **aplayerVisibleAfterLoad** (optional) | Determines whether the APlayer interface should be visible immediately after loading is complete | `false` |
| **animationIn** (optional) | Specifies whether to hide the lyrics upon startup | `false` |
| **autoHidden** (optional) | Enables auto-hiding of the APlayer interface when not interacted with. Recommended for use with `aplayerVisibleAfterLoad` | `false` |
| **lyricHidden** (optional) | Determines whether the APlayer interface should be visible immediately after loading is complete | `false` |

## props

Expand Down
34 changes: 15 additions & 19 deletions packages/valaxy-addon-meting/client/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,28 @@ import type { MetingOptions } from '../node/index'
import { onMetingLoad, onMetingLoadBefore } from './hook'

export function setupHiddenLyricHidingObserver() {
let observer: MutationObserver | null

onMounted(() => {
observer = new MutationObserver((mutations) => {
const lrcElement = document.querySelector('.aplayer-lrc .aplayer-lrc-contents .aplayer-lrc-current') as HTMLElement
const lrcButton = document.querySelector('.aplayer-icon-lrc') as HTMLElement
function removelrc() {
if (lrcElement) {
lrcElement.style.display = 'none'
if (lrcElement.textContent !== 'Loading') {
lrcButton.click()
lrcElement.style.display = ''
observer?.disconnect()
}
// This condition needs to be executed before onMounted
const observer = new MutationObserver((mutations) => {
const lrcElement = document.querySelector('.aplayer-lrc .aplayer-lrc-contents .aplayer-lrc-current') as HTMLElement
const lrcButton = document.querySelector('.aplayer-icon-lrc') as HTMLElement
function removelrc() {
if (lrcElement) {
lrcElement.style.display = 'none'
if (lrcElement.textContent !== 'Loading') {
lrcButton.click()
lrcElement.style.display = ''
observer?.disconnect()
}
}
mutations.forEach((_mutation) => {
removelrc()
})
}
mutations.forEach((_mutation) => {
removelrc()
})
observer.observe(document.body, { childList: true, subtree: true })
})
observer.observe(document.body, { childList: true, subtree: true })

onUnmounted(() => {
observer?.disconnect()
observer = null
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/valaxy-addon-meting/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "valaxy-addon-meting",
"global": true,
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"repository": {
"url": "https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-meting",
Expand Down

0 comments on commit f5c2b57

Please sign in to comment.