From 27bbc74eaa5bacbb4ac406e5e82ce189b57f2e2e Mon Sep 17 00:00:00 2001 From: AskaEth Date: Thu, 5 Nov 2026 00:57:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(packui):=20M113=20=E6=94=B6=E5=8F=A3=20?= =?UTF-8?q?=E2=80=94=E2=80=94=20=E5=AF=BC=E5=87=BA=E7=9A=84=E3=80=8CSave?= =?UTF-8?q?=20to=E3=80=8D=E5=AD=97=E6=AE=B5=E5=BD=A2=E7=8A=B6=E4=B8=8E?= =?UTF-8?q?=E3=80=8C=E6=B2=A1=E8=BF=9B=E5=8C=85=E3=80=8D=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E6=89=BF=E8=AF=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 复审看图挑出的两处,只改这两处,其余不动。 1. **Save to 字段**:原来是 `label("Save to (empty = suggested)")` + 空值,看起来像「这句提示就是字段值」, 与上面 Pack name / Version 的「标签在上、值在下」不一致。改成短标签 `Save to` + 占位 `empty = suggested path`(新增 `PackExportOutputPlaceholder` 一个键)。 2. **`Not in the pack (listed one by one)` 与 `...and 6 more files` 自相矛盾**:13 条没进包的其实全列了, 但紧随其后的「还有 6 个」说的是**内联样例**的截断,两句挨着会被读成一件事。 改法:「没进包」标题带真实计数(`Not in the pack: {count}`),内联样例加自己的标题 `Copied into overrides/ (first {shown}):`,截断那句改成 `…and {count} more files (not shown here)` —— 谁被截断、截了几条,写在它自己的那一块里。 `tolerable_title` 因此改成收 `String`(计数是运行时 format 出来的),`golden.rs` 同步三个键。 门禁:`cargo fmt --all --check` 通过;`cargo test -p unlucky-app-iced --lib -j 2` 504 passed / 0 failed(TEST_EXIT=0);`cargo check -p unlucky-app-iced --all-targets` 零 warning。 出图:`04-export-light.png` / `04-export-dark.png` 已重出(其余 8 张未受影响、未改动)。 --- .../src/pages/content/packui/view/export.rs | 26 ++++++++++++++++--- .../src/pages/content/packui/view/parts.rs | 13 +++++----- .../src/pages/content/packui/view/report.rs | 4 +-- crates/i18n/src/catalog/content.rs | 19 +++++++++++--- crates/i18n/src/catalog/golden.rs | 8 +++--- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/crates/app-iced/src/pages/content/packui/view/export.rs b/crates/app-iced/src/pages/content/packui/view/export.rs index 82c92f4..5906da0 100644 --- a/crates/app-iced/src/pages/content/packui/view/export.rs +++ b/crates/app-iced/src/pages/content/packui/view/export.rs @@ -101,9 +101,12 @@ pub(super) fn export_block<'a>( Field::new(export.version.as_str()).label(catalog.text(Key::PackExportVersion)), move |text| intent(PackMessage::SetExportVersion(text)), )); + // 标签在上、占位在下:**别让占位文字看起来像已填的值**(复审提过这张图的观感) block = block.push(text_field( ui, - Field::new(export.output.as_str()).label(catalog.text(Key::PackExportOutput)), + Field::new(export.output.as_str()) + .label(catalog.text(Key::PackExportOutput)) + .placeholder(catalog.text(Key::PackExportOutputPlaceholder)), move |text| intent(PackMessage::SetOutput(text)), )); block = block.push( @@ -224,10 +227,14 @@ pub(super) fn preview_block<'a>( .width(Length::Fill); if !preview.skipped.is_empty() { + // 标题写成「Not in the pack: 13」而不是「逐条列出」:13 条**确实**全列出来了, + // 但下面那个「…还有 N 个(这里不展开)」说的是**内联样例**,两句挨着容易被读成矛盾 block = block.push(tolerable_title( ui, - catalog, - catalog.text(Key::PackPreviewSkippedTitle), + catalog.render( + Key::PackPreviewSkippedTitle, + &[("count", &preview.skipped.len().to_string())], + ), )); block = block.push(rows_block(ui, catalog, &preview.skipped)); } @@ -235,6 +242,19 @@ pub(super) fn preview_block<'a>( // 样例 + 已知损失一起套有界滚动:预检是「摊开给你看」的块,条目多时它会把 // 「确认写盘」顶出屏幕(出图时实测到了) let mut extras = column![].spacing(ui.space(Space::X1)).width(Length::Fill); + if !preview.inline_sample.is_empty() { + // 给样例一句自己的标题 + 说明只列前几条(截断要说出来) + extras = extras.push(frame::text_role_owned( + ui, + TypeRole::LabelMedium, + false, + catalog.render( + Key::PackPreviewInlineTitle, + &[("shown", &preview.inline_sample.len().to_string())], + ), + ui.color(Role::OnSurfaceVariant), + )); + } for path in &preview.inline_sample { extras = extras.push(frame::text_role( ui, diff --git a/crates/app-iced/src/pages/content/packui/view/parts.rs b/crates/app-iced/src/pages/content/packui/view/parts.rs index c3c6e23..a0e5156 100644 --- a/crates/app-iced/src/pages/content/packui/view/parts.rs +++ b/crates/app-iced/src/pages/content/packui/view/parts.rs @@ -41,15 +41,14 @@ pub(super) fn marker_box<'a>( .into() } -pub(super) fn tolerable_title<'a>( - ui: &'a Ui, - catalog: Catalog, - title: &'a str, -) -> Element<'a, PageMessage> { - let _ = catalog; +/// 容忍域的标题(`Warn` 图标 + 三级色)。 +/// +/// 收 `String` 而不是 `&str`:标题要带计数(`Not in the pack: 13`),而计数是运行时 `format!` +/// 出来的,借用不出去。 +pub(super) fn tolerable_title(ui: &Ui, title: String) -> Element<'_, PageMessage> { row![ frame::glyph(IconKind::Warn, ui.color(Role::Tertiary), frame::ICON_PX), - frame::text_role( + frame::text_role_owned( ui, TypeRole::LabelLarge, true, diff --git a/crates/app-iced/src/pages/content/packui/view/report.rs b/crates/app-iced/src/pages/content/packui/view/report.rs index fb09ff3..5615444 100644 --- a/crates/app-iced/src/pages/content/packui/view/report.rs +++ b/crates/app-iced/src/pages/content/packui/view/report.rs @@ -118,7 +118,7 @@ pub(super) fn report_block<'a>( if let Some(title) = &report.missing_title { block = block.push( column![ - tolerable_title(ui, catalog, title.as_str()), + tolerable_title(ui, title.clone()), bounded( ui, rows_block(ui, catalog, &report.missing), @@ -138,7 +138,7 @@ pub(super) fn report_block<'a>( if let Some(title) = &report.conflicts_title { block = block.push( column![ - tolerable_title(ui, catalog, title.as_str()), + tolerable_title(ui, title.clone()), bounded( ui, column( diff --git a/crates/i18n/src/catalog/content.rs b/crates/i18n/src/catalog/content.rs index 7d13e0a..7711093 100644 --- a/crates/i18n/src/catalog/content.rs +++ b/crates/i18n/src/catalog/content.rs @@ -173,7 +173,11 @@ macro_rules! content_entries { PackExportFormat => ("Format", "格式"), PackExportName => ("Pack name", "包名"), PackExportVersion => ("Version", "版本"), - PackExportOutput => ("Save to (empty = suggested)", "保存到(留空 = 自动)"), + PackExportOutput => ("Save to", "保存到"), + PackExportOutputPlaceholder => ( + "empty = suggested path", + "留空 = 自动给一个路径" + ), PackExportPrecheck => ("Dry run", "预检"), PackExportConfirm => ("Write the pack", "确认写盘"), PackExportAbort => ("Back", "返回"), @@ -196,13 +200,20 @@ macro_rules! content_entries { "{bytes} copied into overrides/", "{bytes} 会原样拷进 overrides/" ), + PackPreviewInlineTitle => ( + "Copied into overrides/ (first {shown}):", + "原样拷进 overrides/(只列前 {shown} 个):" + ), PackPreviewSkippedTitle => ( - "Not in the pack (listed one by one)", - "没进包(逐条列出)" + "Not in the pack: {count}", + "没进包:{count} 项" ), PackPreviewNotes => ("Known losses", "已知损失"), PackPreviewTarget => ("Will be written to {path}", "将写到 {path}"), - PackPreviewMore => ("…and {count} more files", "…还有 {count} 个文件"), + PackPreviewMore => ( + "…and {count} more files (not shown here)", + "…还有 {count} 个文件(这里不展开)" + ), PackPreviewComplete => ("Nothing is left out", "没有遗漏任何文件"), PackPreviewIncomplete => ( "Some files will not be in the pack", diff --git a/crates/i18n/src/catalog/golden.rs b/crates/i18n/src/catalog/golden.rs index 992a40c..8db20a0 100644 --- a/crates/i18n/src/catalog/golden.rs +++ b/crates/i18n/src/catalog/golden.rs @@ -272,7 +272,8 @@ pub(super) const GOLDEN: &[(&str, &str, &str)] = &[ ("PackExportFormat", "Format", "格式"), ("PackExportName", "Pack name", "包名"), ("PackExportVersion", "Version", "版本"), - ("PackExportOutput", "Save to (empty = suggested)", "保存到(留空 = 自动)"), + ("PackExportOutput", "Save to", "保存到"), + ("PackExportOutputPlaceholder", "empty = suggested path", "留空 = 自动给一个路径"), ("PackExportPrecheck", "Dry run", "预检"), ("PackExportConfirm", "Write the pack", "确认写盘"), ("PackExportAbort", "Back", "返回"), @@ -283,10 +284,11 @@ pub(super) const GOLDEN: &[(&str, &str, &str)] = &[ ("PackPreviewHead", "Will inline {inline} files · cannot export: {skipped}", "将内联 {inline} 个文件 · 无法导出 {skipped} 项"), ("PackPreviewRemote", "{count} files can be referenced remotely", "{count} 个文件可走远程引用"), ("PackPreviewInlineBytes", "{bytes} copied into overrides/", "{bytes} 会原样拷进 overrides/"), - ("PackPreviewSkippedTitle", "Not in the pack (listed one by one)", "没进包(逐条列出)"), + ("PackPreviewInlineTitle", "Copied into overrides/ (first {shown}):", "原样拷进 overrides/(只列前 {shown} 个):"), + ("PackPreviewSkippedTitle", "Not in the pack: {count}", "没进包:{count} 项"), ("PackPreviewNotes", "Known losses", "已知损失"), ("PackPreviewTarget", "Will be written to {path}", "将写到 {path}"), - ("PackPreviewMore", "…and {count} more files", "…还有 {count} 个文件"), + ("PackPreviewMore", "…and {count} more files (not shown here)", "…还有 {count} 个文件(这里不展开)"), ("PackPreviewComplete", "Nothing is left out", "没有遗漏任何文件"), ("PackPreviewIncomplete", "Some files will not be in the pack", "有文件不会进包"), ("PackReasonModrinthSha1", "Modrinth match (SHA-1)", "Modrinth 命中(SHA-1)"),