()
| 3034 | } |
| 3035 | |
| 3036 | function updateCooldownDisplays() { |
| 3037 | let needsRefresh = false; |
| 3038 | |
| 3039 | // 检查模型级冷却是否过期 |
| 3040 | for (const credInfo of Object.values(AppState.creds.data)) { |
| 3041 | if (credInfo.model_cooldowns && Object.keys(credInfo.model_cooldowns).length > 0) { |
| 3042 | const currentTime = Date.now() / 1000; |
| 3043 | const hasExpiredCooldowns = Object.entries(credInfo.model_cooldowns).some(([, until]) => until <= currentTime); |
| 3044 | |
| 3045 | if (hasExpiredCooldowns) { |
| 3046 | needsRefresh = true; |
| 3047 | break; |
| 3048 | } |
| 3049 | } |
| 3050 | } |
| 3051 | |
| 3052 | if (needsRefresh) { |
| 3053 | AppState.creds.renderList(); |
| 3054 | return; |
| 3055 | } |
| 3056 | |
| 3057 | // 更新模型级冷却的显示 |
| 3058 | document.querySelectorAll('.cooldown-badge').forEach(badge => { |
| 3059 | const card = badge.closest('.cred-card'); |
| 3060 | const filenameEl = card?.querySelector('.cred-filename'); |
| 3061 | if (!filenameEl) return; |
| 3062 | |
| 3063 | const filename = filenameEl.textContent; |
| 3064 | const credInfo = Object.values(AppState.creds.data).find(c => c.filename === filename); |
| 3065 | |
| 3066 | if (credInfo && credInfo.model_cooldowns) { |
| 3067 | const currentTime = Date.now() / 1000; |
| 3068 | const titleMatch = badge.getAttribute('title')?.match(/模型: (.+)/); |
| 3069 | if (titleMatch) { |
| 3070 | const model = titleMatch[1]; |
| 3071 | const cooldownUntil = credInfo.model_cooldowns[model]; |
| 3072 | if (cooldownUntil) { |
| 3073 | const remaining = Math.max(0, Math.floor(cooldownUntil - currentTime)); |
| 3074 | if (remaining > 0) { |
| 3075 | const shortModel = model.replace('gemini-', '').replace('-exp', '') |
| 3076 | .replace('2.0-', '2-').replace('1.5-', '1.5-'); |
| 3077 | const timeDisplay = formatCooldownTime(remaining).replace(/s$/, '').replace(/ /g, ''); |
| 3078 | badge.innerHTML = `⏰ ${shortModel}: ${timeDisplay}`; |
| 3079 | } |
| 3080 | } |
| 3081 | } |
| 3082 | } |
| 3083 | }); |
| 3084 | } |
| 3085 | |
| 3086 | // ===================================================================== |
| 3087 | // 版本信息管理 |
no test coverage detected