feat(redis): add auto-refresh countdown for key TTL display

* @
feat(redis): add auto-refresh countdown for Redis key TTL display

在 Redis 值查看器的 TTL 徽章旁增加自动刷新按钮,选中时显示 TTL 实时倒计时
(每秒递减),倒计时归零自动刷新数据,刷新按钮持续旋转。TTL 到期或网络异常
时自动关闭自动刷新避免死循环。

改动:
- RedisValueViewer.vue:新增 autoRefresh 状态、定时器与倒计时逻辑,模板增加
  Clock 切换按钮,RefreshCw 按钮支持 animate-spin 旋转
- load() 内复位倒计时;onBeforeUnmount 清理定时器

修复(review):
- #I01 TTL 到期/连接断开后自动关闭 autoRefresh 避免无限重试
- #C01 load() reject 增加 .catch() 处理 UnhandledPromiseRejection

i18n:zh-CN / zh-TW / en / ja / es / it / pt-BR 7 种语言补充 autoRefresh key
@

* @
test(redis): extract auto-refresh logic and add unit tests

将自动刷新核心决策逻辑提取为 lib/redis/redisAutoRefresh.ts 纯函数模块,
并编写 11 个单元测试覆盖状态机转换、TTL 显示计算和自动停止条件。

新增:
- lib/redis/redisAutoRefresh.ts:computeAutoRefreshTick / shouldStopAutoRefresh /
  computeDisplayTtl 纯函数
- lib/__tests__/redis/redisAutoRefresh.spec.ts:11 个测试用例

重构:
- RedisValueViewer.vue 改用提取后的纯函数,确保测试覆盖即实际运行逻辑
@
This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-07-08 15:37:27 +08:00
1 parent 73bd133886
commit a5359798dc
10 files changed
+190 -3

No files matched your search

+1
View File
@@ -1942,6 +1942,7 @@ export default {
loadedMembers: "{loaded} of {total} members loaded",
entries: "{count} entries",
noExpiry: "no expiry",
autoRefresh: "Auto-refresh countdown",
ttlDay: "{count}d",
columnType: "Type",
columnKey: "Key",
+1
View File
@@ -1874,6 +1874,7 @@ export default withEnglishFallback({
loadedMembers: "{loaded} de {total} miembros cargados",
entries: "{count} entradas",
noExpiry: "sin expiración",
autoRefresh: "Actualización automática",
ttlDay: "{count}d",
columnType: "Tipo",
columnKey: "Clave",
+1
View File
@@ -1872,6 +1872,7 @@ export default withEnglishFallback({
loadedMembers: "{loaded} di {total} membri caricati",
entries: "{count} voci",
noExpiry: "nessuna scadenza",
autoRefresh: "Aggiornamento automatico",
ttlDay: "{count}g",
columnType: "Tipo",
columnKey: "Chiave",
+1
View File
@@ -1872,6 +1872,7 @@ export default withEnglishFallback({
loadedMembers: "{loaded}/{total}メンバー読み込み完了",
entries: "{count}エントリ",
noExpiry: "期限なし",
autoRefresh: "自動更新(カウントダウン)",
ttlDay: "{count}日",
columnType: "型",
columnKey: "キー",
+1
View File
@@ -1873,6 +1873,7 @@ export default withEnglishFallback({
loadedMembers: "{loaded} de {total} membros carregados",
entries: "{count} entradas",
noExpiry: "sem expiração",
autoRefresh: "Atualização automática",
ttlDay: "{count}d",
columnType: "Tipo",
columnKey: "Chave",
+1
View File
@@ -1942,6 +1942,7 @@ export default withEnglishFallback({
loadedMembers: "已加载 {loaded} / 共 {total} 个成员",
entries: "{count} 条记录",
noExpiry: "永不过期",
autoRefresh: "自动刷新(倒计时)",
ttlDay: "{count}天",
columnType: "类型",
columnKey: "键",
+1
View File
@@ -1775,6 +1775,7 @@ export default withEnglishFallback({
loadedMembers: "已載入 {loaded} / 共 {total} 個成員",
entries: "{count} 筆項目",
noExpiry: "永不過期",
autoRefresh: "自動刷新(倒計時)",
ttlDay: "{count}天",
columnType: "類型",
columnKey: "鍵",