perf(voice): 语音本地文件缓存 + 预加载,消除播放延迟

- 新增本地文件缓存层:downloadFile + saveFileSync 存持久本地文件,跨重启命中即出声
- _resolveSrc 三层优先:本地文件 -> 云函数 audioUrl -> 下载存本地
- 新增 preload(),timer 页 onLoad 后台预载全部语音
- 文件被清理自动回退重下载,下载失败回退临时 url

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liucheng
2026-07-25 14:21:04 +08:00
parent e682f07892
commit 16924d31db
2 changed files with 90 additions and 3 deletions
+3
View File
@@ -40,6 +40,9 @@ Page({
onLoad(options) {
themeMod.applyThemeToPage(this)
this._init(options)
// 预载语音到本地缓存,训练开始时即可即时播放(仅语音引导开启时)
const s = storage.getSettings()
if (s.voiceGuide !== false) voice.preload()
// countUp: 数字从 0 滚到目标秒数
const target = this.data.duration
if (this._countUpTask) this._countUpTask.cancel()