|
@@ -190,7 +190,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, computed, onMounted, onUnmounted } from 'vue';
|
|
|
|
|
|
|
+import { ref, computed, onMounted, onUnmounted, onShow } from 'vue';
|
|
|
import { useAudioStore } from '../../store/audio';
|
|
import { useAudioStore } from '../../store/audio';
|
|
|
import { get, put, getFullUrl } from '../../utils/request';
|
|
import { get, put, getFullUrl } from '../../utils/request';
|
|
|
import type { AudioItem } from '../../types';
|
|
import type { AudioItem } from '../../types';
|
|
@@ -323,6 +323,21 @@ onMounted(async () => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+// 页面显示时刷新音频状态
|
|
|
|
|
+onShow(() => {
|
|
|
|
|
+ // 刷新 store 中的当前音频信息
|
|
|
|
|
+ if (audioStore.currentAudio) {
|
|
|
|
|
+ audio.value = audioStore.currentAudio;
|
|
|
|
|
+ // 同步进度条
|
|
|
|
|
+ if (audioStore.currentTime > 0) {
|
|
|
|
|
+ currentTime.value = audioStore.currentTime;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (audioStore.duration > 0) {
|
|
|
|
|
+ duration.value = audioStore.duration;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
// 页面卸载
|
|
// 页面卸载
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
|
// 清除睡眠定时器
|
|
// 清除睡眠定时器
|