|
@@ -35,15 +35,16 @@ import metasArticle from "./metas/metas-article.vue";
|
|
|
import metasImageText from "./metas/metas-imagetext.vue";
|
|
|
|
|
|
import {
|
|
|
- reactive,
|
|
|
+ computed,
|
|
|
defineEmits,
|
|
|
+ nextTick,
|
|
|
onBeforeMount,
|
|
|
onMounted,
|
|
|
+ onUnmounted,
|
|
|
+ reactive,
|
|
|
ref,
|
|
|
- watchEffect,
|
|
|
- computed,
|
|
|
watch,
|
|
|
- nextTick,
|
|
|
+ watchEffect,
|
|
|
} from "vue";
|
|
|
import { useStore } from "vuex";
|
|
|
const store = useStore();
|
|
@@ -56,6 +57,34 @@ const close = () => {
|
|
|
emit("close");
|
|
|
store.commit("tags/setCurrentTag", {});
|
|
|
};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 处理主页面的背景音乐和解说音乐
|
|
|
+ * 进入本页面时,如果正在播放背景音乐或解说音乐,则暂停播放,离开本页面时再恢复播放。
|
|
|
+ */
|
|
|
+import { useMusicPlayer,useSoundPlayer } from '@/utils/sound'
|
|
|
+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()
|
|
|
+ }
|
|
|
+})
|
|
|
+onUnmounted(() => {
|
|
|
+ if (needResumeMusic.value) {
|
|
|
+ musicPlayer.play()
|
|
|
+ }
|
|
|
+ if (needResumeSound.value) {
|
|
|
+ soundPlayer.play()
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|