refactor: P0-P5 全面架构重构

P1 thiserror 类型化错误:
新增 core/src/error.rs QrError 枚举, 全链 String -> QrError,
包括 EmptyInput/InvalidVersion/DataTooLong/DecodeFail 等 8 种变体

P2 text_builder Tauri 统一:
新增 build_qr_text Tauri command, 删除前端 qrText.ts,
所有 mode 组件改为 invoke 调用 Rust 端构建文本

P3 QrConfig 颜色字段移除:
从 QrConfig/QrCode 移除 fg_color/bg_color,
改为 to_svg/to_image_bytes 参数传递

P4 前端 4 项合并:
Context 拆分为 StateContext+DispatchContext (H10),
新建 useModeForm 通用 hook (M11),
VCardMode grid-cols-2 网格布局 (M13),
persistHistory/loadHistory 迁至 utils/storage.ts (L9)

P5 算法优化:
MaskedView 懒计算替代 8 次 Matrix 克隆 (H9),
encoding_rs 精确 Kanji Shift JIS 映射 (H12)

验证: cargo check+clippy 通过, 81+24+7 全部测试通过
This commit is contained in:
2026-06-21 15:09:10 +08:00
parent 8298cd4c9c
commit cd75141037
46 changed files with 1283 additions and 1028 deletions
+4 -3
View File
@@ -1,6 +1,6 @@
//! QRGen 自定义配置:强制指定版本、模块大小
//!
//! 运行: `cargo run --example custom_config`
/// QRGen 自定义配置:强制指定版本、模块大小
///
/// 运行: `cargo run --example custom_config`
use qr_core::qr::{QrCode, QrConfig, VersionMode};
use qr_core::version::EcLevel;
@@ -11,6 +11,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
level: EcLevel::Q,
version: VersionMode::Fixed(10),
margin: 4,
..Default::default()
};
let qr = QrCode::encode("固定版本 10 的 QR 码", config)?;