Skip to content

fix: scratch-pad require() 改为顶层 import + 保存错误处理优化#458

Merged
ErlichLiu merged 1 commit into
mainfrom
fix/scratch-pad-review-optimizations
May 15, 2026
Merged

fix: scratch-pad require() 改为顶层 import + 保存错误处理优化#458
ErlichLiu merged 1 commit into
mainfrom
fix/scratch-pad-review-optimizations

Conversation

@ErlichLiu

Copy link
Copy Markdown
Collaborator

概述

针对 PR #425 (scratch-pad) 的代码审查优化,修复 3 个问题:

变更清单

  1. ipc.ts — require() 改为顶层 import

    • readFileSync / writeFileSync 加入现有 node:fs 顶层导入
    • writeFile 新增 node:fs/promises 顶层导入
    • 移除 handler 内 3 处 require() 调用,与文件顶部已有的 node:fs import 风格一致
  2. ScratchPadView.tsx — 补全 useEffect 依赖数组

    • content 在闭包内被引用,加入 [loaded, editor, content] 依赖
  3. main.tsx — 保存失败时检查返回值

    • saveScratchPad 返回 boolean,现检查 okconsole.error

测试方法

  • 启动 Proma,Scratch Pad 正常加载和保存
  • 编辑器内容修改后关闭窗口,重新打开内容完整保留

🤖 Generated with Claude Code

…handling

- ipc.ts: replace require('node:fs') / require('node:fs/promises') with
  top-level imports for readFileSync, writeFileSync, writeFile,
  consistent with existing node:fs imports
- ScratchPadView.tsx: add missing `content` to useEffect dependency array
- main.tsx: check saveScratchPad return value and log on failure

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ErlichLiu ErlichLiu merged commit 89a2dfe into main May 15, 2026
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