fix: scratch-pad require() 改为顶层 import + 保存错误处理优化#458
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
针对 PR #425 (scratch-pad) 的代码审查优化,修复 3 个问题:
变更清单
ipc.ts —
require()改为顶层 importreadFileSync/writeFileSync加入现有node:fs顶层导入writeFile新增node:fs/promises顶层导入require()调用,与文件顶部已有的node:fsimport 风格一致ScratchPadView.tsx — 补全 useEffect 依赖数组
content在闭包内被引用,加入[loaded, editor, content]依赖main.tsx — 保存失败时检查返回值
saveScratchPad返回 boolean,现检查ok并console.error测试方法
🤖 Generated with Claude Code