|
@@ -172,11 +172,11 @@ const hasNext = computed(() => audioStore.hasNext);
|
|
|
let progressSaveTimer: number | null = null;
|
|
let progressSaveTimer: number | null = null;
|
|
|
|
|
|
|
|
// 页面加载时获取参数
|
|
// 页面加载时获取参数
|
|
|
-onLoad((options: any) => {
|
|
|
|
|
|
|
+onLoad(async (options: any) => {
|
|
|
audioId.value = options?.id || '';
|
|
audioId.value = options?.id || '';
|
|
|
|
|
|
|
|
if (audioId.value) {
|
|
if (audioId.value) {
|
|
|
- fetchAudioAndInit();
|
|
|
|
|
|
|
+ await fetchAudioAndInit();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -187,10 +187,24 @@ async function fetchAudioAndInit() {
|
|
|
await fetchPlaylist();
|
|
await fetchPlaylist();
|
|
|
// 获取历史播放进度
|
|
// 获取历史播放进度
|
|
|
await fetchPlayProgress();
|
|
await fetchPlayProgress();
|
|
|
|
|
+ // 获取用户偏好设置
|
|
|
|
|
+ await fetchUserPreferences();
|
|
|
// 开始自动保存进度
|
|
// 开始自动保存进度
|
|
|
startProgressAutoSave();
|
|
startProgressAutoSave();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取用户偏好设置
|
|
|
|
|
+async function fetchUserPreferences() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const result = await get<any>('/user/preferences');
|
|
|
|
|
+ if (result && result.playSpeed) {
|
|
|
|
|
+ audioStore.setPlayRate(result.playSpeed);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.log('获取用户偏好失败:', error);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 页面加载
|
|
// 页面加载
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
// 如果没有通过 onLoad 获取到 id,尝试从 URL 获取
|
|
// 如果没有通过 onLoad 获取到 id,尝试从 URL 获取
|
|
@@ -360,9 +374,16 @@ function playNext() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置播放速度
|
|
// 设置播放速度
|
|
|
-function handleSetRate(rate: number) {
|
|
|
|
|
|
|
+async function handleSetRate(rate: number) {
|
|
|
audioStore.setPlayRate(rate);
|
|
audioStore.setPlayRate(rate);
|
|
|
showRatePicker.value = false;
|
|
showRatePicker.value = false;
|
|
|
|
|
+
|
|
|
|
|
+ // 保存用户偏好
|
|
|
|
|
+ try {
|
|
|
|
|
+ await put('/user/preferences', { playSpeed: rate });
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.log('保存播放速度偏好失败:', error);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置定时关闭
|
|
// 设置定时关闭
|