feat: add logging for voice list retrieval from cache and fix loading option text

This commit is contained in:
zuoban
2025-08-12 14:09:04 +08:00
parent 66421eebec
commit 901bb4c3d1
2 changed files with 4 additions and 1 deletions

View File

@@ -117,6 +117,8 @@ func (c *Client) ListVoices(ctx context.Context, locale string) ([]models.Voice,
// 检查缓存是否有效 // 检查缓存是否有效
c.voicesCacheMu.RLock() c.voicesCacheMu.RLock()
if !c.voicesCacheExpiry.IsZero() && time.Now().Before(c.voicesCacheExpiry) && len(c.voicesCache) > 0 { if !c.voicesCacheExpiry.IsZero() && time.Now().Before(c.voicesCacheExpiry) && len(c.voicesCache) > 0 {
// 从缓存中获取
log.Println("ListVoices 从缓存中获取语音列表: ", len(c.voicesCache), "个", "剩余时间:", c.voicesCacheExpiry.Sub(time.Now()))
voices := c.voicesCache voices := c.voicesCache
c.voicesCacheMu.RUnlock() c.voicesCacheMu.RUnlock()
@@ -135,6 +137,7 @@ func (c *Client) ListVoices(ctx context.Context, locale string) ([]models.Voice,
c.voicesCacheMu.RUnlock() c.voicesCacheMu.RUnlock()
// 缓存无效需要从API获取 // 缓存无效需要从API获取
log.Println("ListVoices, 缓存未命中从API获取语音列表")
endpoint, err := c.getEndpoint(ctx) endpoint, err := c.getEndpoint(ctx)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -947,7 +947,7 @@
<label for="style" class="mb-1 font-semibold text-slate-700">风格:</label> <label for="style" class="mb-1 font-semibold text-slate-700">风格:</label>
<select id="style" <select id="style"
class="p-2 border border-slate-300 rounded-md bg-white/90 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition"> class="p-2 border border-slate-300 rounded-md bg-white/90 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
<option value="loading">加载<EFBFBD><EFBFBD><EFBFBD>...</option> <option value="loading">加载...</option>
</select> </select>
</div> </div>
</div> </div>