From 5861881073b0239619837fbda1424a55d4742808 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Sun, 1 Nov 2026 20:38:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app-iced):=20M75=20=E2=80=94=E2=80=94?= =?UTF-8?q?=20probe=20=E6=8B=86=E5=87=BA=20scan=20=E5=B7=A5=E5=85=B7=20+?= =?UTF-8?q?=20clippy=20=E5=85=A8=E7=BB=BF=20+=20=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E5=AD=97=E9=9D=A2/=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gallery/{probe,scan}.rs 拆分:像素扫描(连通块/外接框/顶行宽度)与判据分离, 后续四条家族线可以自带 probe 复用扫描逻辑 - probe 的实心块判据跳过字形割出的小碎片(area < 800),阈值写明原因 - app.rs / gallery::mod 的 clippy 修正(needless_lifetime / field_reassign_with_default / collapsible_if) - cargo test -p unlucky-app-iced 与 cargo clippy --all-targets -D warnings 已绿(见报告) --- crates/app-iced/src/components/gallery/probe.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/app-iced/src/components/gallery/probe.rs b/crates/app-iced/src/components/gallery/probe.rs index 5ee5f0b..8f30f2d 100644 --- a/crates/app-iced/src/components/gallery/probe.rs +++ b/crates/app-iced/src/components/gallery/probe.rs @@ -34,6 +34,17 @@ fn ui(flavor: SchemeFlavor) -> Ui { Ui::with_platform(flavor, Platform::Windows, FAMILIES) } +/// `ULL_GALLERY_SHOT` → 截图路径(相对路径按**工作区根**解释:`cargo test` 的 cwd 是 crate 目录)。 +fn shot_path() -> Option { + let raw = std::env::var_os("ULL_GALLERY_SHOT")?; + let path = std::path::PathBuf::from(raw); + if path.is_absolute() || path.exists() { + return Some(path); + } + let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../.."); + Some(root.join(path)) +} + /// 一条测试覆盖全部几何断言(每张图各跑一次)。 #[test] fn gallery_geometry_matches_the_tokens() { @@ -71,6 +82,10 @@ fn gallery_geometry_matches_the_tokens() { let mut label_button = None; for bbox in &primary { + // 字形(OnPrimary)会把实心块割出小碎片,只判「成块的」(40×40 = 1600) + if bbox.area() < 800 { + continue; + } assert!( (39..=41).contains(&bbox.height()), "实心块高 {}(参考 40,12b 1.1)@ {:?}",