Skip to content

fix(settings): avoid flashing the loading indicator when reopening settings - #9908

Merged
farion1231 merged 1 commit into
farion1231:mainfrom
fuyundev:codex/fix-settings-cache-flash
Nov 23, 2026
Merged

farion1231 merged 1 commit into
farion1231:mainfrom
fuyundev:codex/fix-settings-cache-flash

Conversation

@fuyundev

@fuyundev fuyundev commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Human Note / 本人说明

在 macOS 上使用 CC Switch 4.0.39 时,从「应用」进入「设置」,点击「返回」后再次进入。即使设置数据已经缓存,右侧仍会短暂显示加载图标,随后才出现「通用」表单。

Summary / 概述

从「应用」进入「设置」,返回后再进入,即使设置已经缓存在 React Query 中,仍会短暂显示加载图标。此前 useSettingsForm 把表单初值设为 null,直到首次渲染后的 effect 才填入缓存数据。

现在首帧直接使用经过规范化的缓存设置初始化表单。缓存为空时仍显示加载提示,后续查询返回新数据时继续同步表单。初始化和重置共用同一套字段默认值、目录清理和语言规范化逻辑。

Related Issue / 关联 Issue

Fixes #9907

Screenshots / 截图

在 macOS 安装版 4.0.39 中再次进入「设置」时截取的两帧。左图中「通用」标题已经出现,正文只有加载图标,右图中表单才出现。

再次进入设置时先显示加载图标,随后显示外观表单

Checklist / 检查清单

  • pnpm typecheck
  • pnpm format:check
  • pnpm test:unit(4,423 项通过,覆盖缓存命中的首次渲染和空缓存首次读取)
  • pnpm build:renderer

在隔离的 macOS WKWebView 中使用完整前端和模拟 Tauri IPC,重复「应用 → 设置 → 返回」6 次。修复前 6 次均将加载图标插入 DOM,修复后 6 次均直接显示表单。另用空缓存验证了首次打开仍显示加载提示,数据返回后正常显示表单。

本次改动仅涉及前端表单及其测试。实现与自动化验证使用了 Codex 辅助。

@github-actions github-actions Bot added the frontend Frontend (React/TypeScript) label Nov 23, 2026

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,感谢您的贡献!

@farion1231
farion1231 merged commit 721ca8e into farion1231:main Nov 23, 2026
10 checks passed
@farion1231

Copy link
Copy Markdown
Owner

已合并,感谢 @fuyundev!复现截图和 WKWebView 前后对比很有说服力,顺手把初始化和重置的规范化合成一份也让这块代码清爽了不少。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Frontend (React/TypeScript)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 重复进入设置页时,已有缓存仍短暂显示加载指示器

2 participants