fix: 修复审查发现的 4 个高优先级问题

- plan: getTodayTarget 补 customPlans 参数,timer/index 调用点传值,修复自定义计划每日目标失效
- leaderboard: fetchRank 加请求序列号丢弃过期响应,修复快速切换周期竞态
- leaderboard 云函数:遍历记录加防御(r.date/duration/数组校验),避免单条脏数据崩溃全榜
- tts: _upload cloudPath 补 volume/speed,避免不同音量语速音频互相覆盖

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liucheng
2026-07-25 14:48:09 +08:00
parent c1e0c78861
commit b47a48259e
6 changed files with 24 additions and 11 deletions
+4 -3
View File
@@ -61,8 +61,9 @@ const _synthesize = async (text, promptKey, opts) => {
return Buffer.from(res.Audio, 'base64')
}
const _upload = async (key, buffer, voiceType) => {
const cloudPath = `${CACHE_DIR}/${key}-${voiceType || 'default'}.mp3`
const _upload = async (key, buffer, voiceType, volume, speed) => {
// cloudPath 含 volume/speed,避免不同音量/语速的音频互相覆盖(缓存碰撞)
const cloudPath = `${CACHE_DIR}/${key}-${voiceType || 'default'}-v${volume != null ? volume : 0}-s${speed != null ? speed : 0}.mp3`
// uploadFile returns the canonical fileID (e.g. "cloud://env.xxx/...").
// We must use THAT — not the relative cloudPath we passed in — when
// calling getTempFileURL. A self-constructed fileID is invalid.
@@ -94,7 +95,7 @@ exports.main = async (event) => {
// Slow path: synthesize + upload + return fresh fileID for caching
try {
const buffer = await _synthesize(text, promptKey, { voiceType, volume, speed })
const newFileID = await _upload(promptKey, buffer, voiceType)
const newFileID = await _upload(promptKey, buffer, voiceType, volume, speed)
const urlRes = await cloud.getTempFileURL({ fileList: [newFileID] })
const url = urlRes.fileList[0].tempFileURL
if (!url) {