|
@@ -67,22 +67,31 @@ const musicPlayer = useMusicPlayer()
|
|
|
const soundPlayer = useSoundPlayer()
|
|
|
const needResumeMusic = ref(false)
|
|
|
const needResumeSound = ref(false)
|
|
|
-onMounted(() => {
|
|
|
- if (musicPlayer.isPlay) {
|
|
|
- needResumeMusic.value = true
|
|
|
- musicPlayer.pause()
|
|
|
- }
|
|
|
- if (soundPlayer.isPlay) {
|
|
|
- needResumeSound.value = true
|
|
|
- soundPlayer.pause()
|
|
|
- }
|
|
|
+window.musicPlayer = musicPlayer
|
|
|
+window.soundPlayer = soundPlayer
|
|
|
+
|
|
|
+const isShowing = computed(() => {
|
|
|
+ return !!currentTag.value.hotspotType
|
|
|
})
|
|
|
-onUnmounted(() => {
|
|
|
- if (needResumeMusic.value) {
|
|
|
- musicPlayer.play()
|
|
|
- }
|
|
|
- if (needResumeSound.value) {
|
|
|
- soundPlayer.play()
|
|
|
+watch(isShowing, (v) => {
|
|
|
+ if (v) {
|
|
|
+ if (musicPlayer.isPlay) {
|
|
|
+ needResumeMusic.value = true
|
|
|
+ musicPlayer.pause()
|
|
|
+ }
|
|
|
+ if (soundPlayer.isPlay) {
|
|
|
+ needResumeSound.value = true
|
|
|
+ soundPlayer.pause()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (needResumeMusic.value) {
|
|
|
+ musicPlayer.play()
|
|
|
+ needResumeMusic.value = false
|
|
|
+ }
|
|
|
+ if (needResumeSound.value) {
|
|
|
+ soundPlayer.play()
|
|
|
+ needResumeSound.value = false
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
</script>
|