feat: 原生对话框、ErrorBoundary、配置生效、交互打磨

- handleBrowse 改用 @tauri-apps/plugin-dialog 原生目录选择
- handleImport 清理临时 DOM 元素(add input.remove())
- config/default.json 实际导入生效(maxHistory、path 长度限制)
- app-store.ts 长度检查改用配置值
- 删除 AppShell 中与 store 重复的长度检查
- 新增 ErrorBoundary 组件避免单异常白屏
- StatusBar 加载失败时显示重试按钮
- 取消按钮检查 isModified 未保存提示
- lib.rs 注册 tauri-plugin-dialog
- tsconfig 添加 resolveJsonModule
- CLAUDE.md 添加 cargo test 运行时说明

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 00:33:57 +08:00
parent bfd114d80f
commit 3a21891f84
11 changed files with 79 additions and 45 deletions
+33
View File
@@ -0,0 +1,33 @@
import { Component, type ReactNode } from 'react';
interface Props { children: ReactNode; }
interface State { hasError: boolean; error: string; }
export class ErrorBoundary extends Component<Props, State> {
state: State = { hasError: false, error: '' };
static getDerivedStateFromError(e: Error): State {
return { hasError: true, error: e.message };
}
render() {
if (this.state.hasError) {
return (
<div className="flex items-center justify-center h-screen" style={{ backgroundColor: 'var(--app-bg)', color: 'var(--app-fg)' }}>
<div className="text-center space-y-4">
<h2 className="text-xl font-bold"></h2>
<p className="text-sm opacity-70">{this.state.error}</p>
<button
className="px-4 py-2 rounded border"
onClick={() => this.setState({ hasError: false })}
style={{ borderColor: 'var(--app-border)' }}
>
</button>
</div>
</div>
);
}
return this.props.children;
}
}