|
|
|
@ -221,11 +221,22 @@ export default { |
|
|
|
displayCourseList() { |
|
|
|
return this.isReversed ? [...this.courseList].reverse() : this.courseList; |
|
|
|
}, |
|
|
|
|
|
|
|
// 从Vuex获取音色列表 |
|
|
|
voiceList() { |
|
|
|
return this.$store.state.voiceList; |
|
|
|
}, |
|
|
|
|
|
|
|
// 从Vuex获取默认音色ID |
|
|
|
defaultVoiceId() { |
|
|
|
return this.$store.state.defaultVoiceId; |
|
|
|
}, |
|
|
|
|
|
|
|
// 判断当前页面是否为文字类型 |
|
|
|
isTextPage() { |
|
|
|
// 如果是卡片页面(type为'1'),不显示音频控制栏 |
|
|
|
if (this.currentPageType === '1') { |
|
|
|
return false; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
const currentPageData = this.bookPages[this.currentPage - 1]; |
|
|
|
@ -1183,15 +1194,37 @@ export default { |
|
|
|
|
|
|
|
// 获取音色列表 拿第一个做默认的音色id |
|
|
|
async getVoiceList() { |
|
|
|
const voiceRes = await this.$api.music.list() |
|
|
|
if (voiceRes.code === 200) { |
|
|
|
// console.log('音色列表API返回:', voiceRes.result); |
|
|
|
// console.log('第一个音色数据:', voiceRes.result[0]); |
|
|
|
this.voiceId = Number(voiceRes.result[0].voiceType) |
|
|
|
// console.log('获取默认音色ID:', this.voiceId, '类型:', typeof this.voiceId); |
|
|
|
|
|
|
|
// 优先从Vuex获取音色列表 |
|
|
|
if (this.voiceList && this.voiceList.length > 0) { |
|
|
|
console.log('从Vuex获取音色列表:', this.voiceList); |
|
|
|
this.voiceId = this.defaultVoiceId || Number(this.voiceList[0].voiceType); |
|
|
|
console.log('使用Vuex中的默认音色ID:', this.voiceId); |
|
|
|
|
|
|
|
// 同步默认音色设置到audioManager |
|
|
|
audioManager.setGlobalVoiceId(this.voiceId); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 如果Vuex中没有数据,则从API获取(兜底方案) |
|
|
|
console.log('Vuex中无音色数据,从API获取...'); |
|
|
|
try { |
|
|
|
const voiceRes = await this.$api.music.list() |
|
|
|
if (voiceRes.code === 200) { |
|
|
|
console.log('音色列表API返回:', voiceRes.result); |
|
|
|
|
|
|
|
// 更新Vuex中的音色列表 |
|
|
|
this.$store.commit('setVoiceList', voiceRes.result); |
|
|
|
|
|
|
|
this.voiceId = Number(voiceRes.result[0].voiceType) |
|
|
|
console.log('获取默认音色ID:', this.voiceId, '类型:', typeof this.voiceId); |
|
|
|
|
|
|
|
// 同步默认音色设置到audioManager |
|
|
|
audioManager.setGlobalVoiceId(this.voiceId); |
|
|
|
} else { |
|
|
|
console.error('获取音色列表失败:', voiceRes); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('获取音色列表异常:', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
toggleNavbar() { |
|
|
|
|