Skip to content

feat(frontend): settings 页接 /api/settings(13 设置 + 主题/语言持久化)— Stage 5 (Vue 重构)#507

Open
Cmochance wants to merge 1 commit into
feat/frontend-vue-stage4from
feat/frontend-vue-stage5
Open

feat(frontend): settings 页接 /api/settings(13 设置 + 主题/语言持久化)— Stage 5 (Vue 重构)#507
Cmochance wants to merge 1 commit into
feat/frontend-vue-stage4from
feat/frontend-vue-stage5

Conversation

@Cmochance

Copy link
Copy Markdown
Owner

Stage 5 of the Vue 3 frontend rewrite (stacked on #506). Wires the settings page to /api/settings.

内容

  • SettingsPage 从 stub 升级为综合页:13 项设置 + webFetchBackend + ports + updateUrl + theme/language 持久化
  • 默认值语义复刻旧 renderSettings(!==false / ===true);partial PUT 浅合并;乐观更新 + 失败回滚
  • App 启动从后端 hydrate theme/language(无 echo 回环);新增 api/settings.ts + stores/settings.ts

验证

  • build(vue-tsc + vite)绿;CSP 合规;本地 code-review 1 IMPORTANT(webFetchBackend 默认 auto)已修

⚠️ 删旧代码推迟

本 PR 不删 app.js/css/vendor —— 新前端尚有 4 个 stub 页(Dashboard/Guide/CodexSkin/Desktop)+ settings 三复杂子 UI(residual scan/snapshot/diagnostic)未迁,需保留旧代码作移植参考。删旧留作全部迁完后的最终清理。

合并策略

stacked,不单独 merge — 全部 stage 完成 + e2e 验收后逐个合并。

Refs MOC-254

SettingsPage 从 stub 升级为综合设置页,逐字复刻旧 renderSettings 的读写:
- 13 项设置(autoApplyOnStart/restoreCodexOnExit/autoUnlockCodexPlugins/autoWakeCodexPet/
  codexQuotaEnabled/codexNetworkAccess/exposeAllProviderModels/showGrayProviders/
  mcpCredentialsPortableStore + webFetchBackend + proxyPort/adminPort + updateUrl)
- 默认值语义复刻(!==false / ===true);partial PUT 浅合并;乐观更新 + 失败回滚
- theme/language 双向持久化(改后 PUT /api/settings);App 启动从后端 hydrate(无 echo)
- 新增 api/settings.ts + stores/settings.ts;webFetchBackend 默认 auto(对齐后端 schema)

注:删旧 app.js 推迟 — 新前端尚有 4 个 stub 页(Dashboard/Guide/CodexSkin/Desktop)
+ settings 三复杂子 UI(residual scan/snapshot/diagnostic)未迁,需保留旧代码作移植参考。

Refs MOC-254

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58cb1baca6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// 默认 auto(对齐后端 schema DEFAULT_WEB_FETCH_BACKEND + 旧前端;key 缺失时运行时实为 auto)
const webFetchBackend = computed<string>({
get: () => store.str('webFetchBackend', 'auto'),
set: (v) => void persist({ webFetchBackend: v }),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require Chrome checks before saving headless backend

When a user selects auto or headless on a machine without Chrome/headless-shell, this setter now immediately persists webFetchBackend and never runs the existing readiness flow; the old UI gated these choices through /api/system-proxy/status, /api/chrome/detect, and /api/chrome/ensure in frontend/js/app.js around the web-fetch handler, and the current i18n hint still promises first selection will detect/download Chrome. This can leave the saved backend unusable so web_fetch calls fail until the user manually changes the setting; add the same proxy/Chrome gate before calling persist.

Useful? React with 👍 / 👎.

Comment on lines +52 to +53
setAppearance(v)
void persist({ theme: v })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Roll back theme and locale after failed saves

If /api/settings rejects while saving the theme, setAppearance has already changed the DOM and localStorage before persist({ theme: v }); persist only rolls back the Pinia settings object and shows a toast, so the UI keeps showing a value that the backend did not save and the next hydrate can revert it. The language setter below has the same ordering via setLocale; either save first or restore the previous appearance/locale in the failure path.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant