feat: 重写为 Tauri + React + TypeScript (v4.0)

完全移除旧 C+IUP 代码,改用 Tauri 2.x + React 19 + TypeScript + Rust 技术栈重写。
功能与 v3.1 完全等价:

- React 前端:Tailwind CSS 4、Zustand 状态管理、i18next 国际化
- Rust 后端:winreg 注册表读写、Win32 API FFI 调用
- 核心逻辑:StringList、UndoRedoManager、PathManager、Import/Export
- 深色模式、中英文切换、键盘快捷键、合并预览
- 66 个 Vitest 单元测试

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 18:32:54 +08:00
parent cdcfd8e0a7
commit 48129a8908
2545 changed files with 12608 additions and 142894 deletions
+60
View File
@@ -0,0 +1,60 @@
import { useEffect } from 'react';
import { useAppStore } from '@/store/app-store';
interface KeyboardActions {
onNew: () => void;
onSave: () => void;
onDelete: () => void;
onUndo: () => void;
onRedo: () => void;
}
/**
* 全局键盘快捷键
* Ctrl+N 新建, Ctrl+S 保存, Ctrl+Z 撤销, Ctrl+Y 重做, Delete 删除
*/
export function useKeyboard(actions: KeyboardActions) {
const isAdmin = useAppStore((s) => s.isAdmin);
useEffect(() => {
const handler = (e: KeyboardEvent) => {
// 如果焦点在输入框中,只响应 Escape
const tag = (e.target as HTMLElement)?.tagName;
const isInput = tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
if (isInput) {
if (e.key === 'Escape') {
(e.target as HTMLElement).blur();
}
return;
}
if (!isAdmin) return;
const ctrl = e.ctrlKey || e.metaKey;
if (ctrl && e.key === 'z') {
e.preventDefault();
actions.onUndo();
} else if (ctrl && e.key === 'y') {
e.preventDefault();
actions.onRedo();
} else if (ctrl && e.key === 'n') {
e.preventDefault();
actions.onNew();
} else if (ctrl && e.key === 's') {
e.preventDefault();
actions.onSave();
} else if (e.key === 'Delete' || e.key === 'Backspace') {
e.preventDefault();
actions.onDelete();
} else if (e.key === 'F1') {
e.preventDefault();
// 帮助由 AppShell 处理
}
};
window.addEventListener('keydown', handler);
return () => window.removeEventListener('keydown', handler);
}, [isAdmin, actions]);
}