fix: 修复格式化工具破坏的单行 if/else 与闭包语法

格式化工具在展开单行语句时引入了 5 处语法错误,导致 dx serve 无法编译:

- comments.rs / trash.rs:on_select 的 `if checked { insert } else { remove }`
  丢失 else 分支,变为悬空语句 + 括号不匹配。
- trash.rs(3 处):`web_sys::window().and_then(|w| {...}).unwrap_or(false) {`
  展开闭包体时漏掉闭合 `)`,吞掉了 if 块的开括号。
- write.rs:封面图 `if cv.contains('?') {...} else {...}` 丢失 else,
  多出一个 `}`,导致 src 块括号失衡。

均还原为正确的多行 if/else 结构。验证:dx check 通过、cargo test 405 passed。
This commit is contained in:
xfy 2026-06-25 18:11:35 +08:00
parent 0398cc6c66
commit 9a00972be4
3 changed files with 13 additions and 16 deletions

View File

@ -287,7 +287,7 @@ pub fn AdminCommentsPage(page: i32) -> Element {
let mut s = selected_ids();
if checked {
s.insert(id);
}
} else {
s.remove(&id);
}
selected_ids.set(s);

View File

@ -340,12 +340,11 @@ pub fn TrashPage(page: i32) -> Element {
{
if web_sys::window()
.and_then(|w| {
w
.confirm_with_message(
"确定要彻底删除选中的文章吗?此操作不可恢复。",
)
.ok()
}
w.confirm_with_message(
"确定要彻底删除选中的文章吗?此操作不可恢复。",
)
.ok()
})
.unwrap_or(false)
{
let ids: Vec<i32> = selected_ids().iter().copied().collect();
@ -436,7 +435,7 @@ pub fn TrashPage(page: i32) -> Element {
let mut s = selected_ids();
if checked {
s.insert(id);
}
} else {
s.remove(&id);
}
selected_ids.set(s);
@ -489,12 +488,11 @@ pub fn TrashPage(page: i32) -> Element {
{
if web_sys::window()
.and_then(|w| {
w
.confirm_with_message(
"确定要清空回收站吗?所有已删除文章将被彻底移除,此操作不可恢复。",
)
.ok()
}
w.confirm_with_message(
"确定要清空回收站吗?所有已删除文章将被彻底移除,此操作不可恢复。",
)
.ok()
})
.unwrap_or(false)
{
spawn(async move {

View File

@ -549,8 +549,7 @@ fn write_editor(post_id: Option<i32>) -> Element {
let base = cv.split('?').next().unwrap_or(&cv);
if cv.contains('?') {
format!("{}&w=600", base)
}
}
} else {
format!("{}?w=600", base)
}
} else {