refactor: 全面代码质量提升 — StringList→string[], strict 模式, 死代码清理

架构重构:
- StringList 类替换为不可变 string[](消除 dataVersion hack,Zustand 自然检测变化)
- UndoRedoManager.undo/redo 返回新数组而非原地修改
- 删除 dataVersion 字段和 _bumpVersion()
- 启用 TypeScript strict 模式

死代码清理:
- 删除 string-list.ts, string-list.test.ts, use-path-validation.ts
- Rust AppError 保留供未来使用

功能修复:
- importFromJson 添加 try/catch
- handleClean 使用真实格式验证替代 () => true
- savePaths 保存前调用 backup_registry,处理部分保存失败
- importFromJson 校验非 object 类型输入

i18n 完善:
- MergePreview/StatusBar 硬编码中文 → t() 调用
- 新增 merge.* 和 status.* 翻译键

Rust 改进:
- registry.rs 抽取 load_paths/save_paths 通用函数,消除重复
- registry 新增 6 个单元测试(split/join/roundtrip)
- backup.rs 时间戳加毫秒防覆盖,回退路径改为 home_dir

元数据:
- package.json 名称→patheditor, 版本→4.0.0
- 新增 CHANGELOG.md
- 移除 UndoRedoButtons 废弃注释
- tsconfig 添加 strict:true

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 00:26:27 +08:00
parent 2ceec54790
commit bfd114d80f
21 changed files with 410 additions and 836 deletions
+6 -4
View File
@@ -1,7 +1,9 @@
import { useAppStore } from '@/store/app-store';
import { useThemeStore } from '@/store/theme-store';
import { useTranslation } from 'react-i18next';
export function StatusBar() {
const { t } = useTranslation();
const statusMessage = useAppStore((s) => s.statusMessage);
const isLoading = useAppStore((s) => s.isLoading);
const isAdmin = useAppStore((s) => s.isAdmin);
@@ -17,11 +19,11 @@ export function StatusBar() {
color: 'var(--app-fg)',
}}
>
<span>{isLoading ? '加载中...' : statusMessage}</span>
<span>{isLoading ? t('status.loading') : statusMessage}</span>
<div className="flex gap-3">
{isModified && <span className="text-yellow-500"> </span>}
{!isAdmin && <span className="text-yellow-500"></span>}
<span style={{ opacity: 0.5 }}>{isDark ? '深色' : '浅色'}</span>
{isModified && <span className="text-yellow-500"> {t('status.modified')}</span>}
{!isAdmin && <span className="text-yellow-500">{t('status.readonly_label')}</span>}
<span style={{ opacity: 0.5 }}>{isDark ? t('status.dark') : t('status.light')}</span>
</div>
</footer>
);