fix: 前端 HIGH/MEDIUM — timer 清理 + 历史持久化 + Error Boundary + console 移除

This commit is contained in:
2026-06-17 09:03:38 +08:00
parent feb5ae709f
commit 91bdf9ecc3
15 changed files with 184 additions and 84 deletions
+9 -1
View File
@@ -29,6 +29,10 @@ struct AppState {
/// 编码 QR 码,返回 SVG + 元信息
#[tauri::command]
fn encode_qr(text: String, level: String, margin: u8) -> Result<QrResponse, String> {
if margin > 100 {
return Err("边距过大(最大 100".into());
}
let ec_level = match level.to_uppercase().as_str() {
"L" => EcLevel::L,
"M" => EcLevel::M,
@@ -58,6 +62,10 @@ fn encode_qr(text: String, level: String, margin: u8) -> Result<QrResponse, Stri
/// 导出 PNG bytes
#[tauri::command]
fn export_png(text: String, level: String, margin: u8, module_size: u8) -> Result<Vec<u8>, String> {
if margin > 100 {
return Err("边距过大(最大 100".into());
}
let ec_level = match level.to_uppercase().as_str() {
"L" => EcLevel::L,
"M" => EcLevel::M,
@@ -74,7 +82,7 @@ fn export_png(text: String, level: String, margin: u8, module_size: u8) -> Resul
let qr = QrCode::encode(&text, config).map_err(|e| format!("编码失败: {}", e))?;
Ok(qr.to_png_bytes(module_size))
qr.to_png_bytes(module_size).map_err(|e| format!("PNG 导出失败: {}", e))
}
/// 保存历史记录条目