chore(wasm): 清理 wasm32 target 下残留的 clippy lint
这些 lint 在 server build(默认 --all-features)下被 cfg 剥离故未暴露,
仅 wasm32 web-only target 触发。逐项清理:
- footer.rs: 两处 redundant closure(web_sys::window 直接传函数引用、
sync_visible 直接传闭包)+ let _ = unit 绑定(scroll_to_*)。
- hooks/event_listener.rs: 复杂类型 Rc<RefCell<Option<(Closure,T)>>>
抽 type ListenerState<T> 别名。
- system.rs: 两处单模式 match { Ok=>.., _=>{} } 改 if let。
- write.rs: split(|c| matches!(c,...)) 改 split([char; N]) 数组模式。
- codemirror_bridge.rs: let _ = instance.destroy() 删 unit 绑定,
与 tiptap_bridge.rs 同处写法对齐。
wasm32 与 server 两 target clippy -D warnings 均通过。
This commit is contained in:
parent
fee5b7ba94
commit
65b15509a7
@ -179,7 +179,7 @@ pub mod wasm {
|
|||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// 销毁 JS 侧编辑器;随后 _on_change/_on_ready 字段按声明顺序释放,
|
// 销毁 JS 侧编辑器;随后 _on_change/_on_ready 字段按声明顺序释放,
|
||||||
// 释放 wasm-bindgen 函数表槽位。
|
// 释放 wasm-bindgen 函数表槽位。
|
||||||
let _ = self.instance.destroy();
|
self.instance.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,10 +42,10 @@ pub fn Footer() -> Element {
|
|||||||
// 因为 server 端该组件只跑一次 SSR)。
|
// 因为 server 端该组件只跑一次 SSR)。
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use_event_listener(
|
use_event_listener(
|
||||||
|| web_sys::window(),
|
web_sys::window,
|
||||||
"scroll",
|
"scroll",
|
||||||
// 滚动事件触发时复用同样的阈值判断。
|
// 滚动事件触发时复用同样的阈值判断。
|
||||||
move || sync_visible(),
|
sync_visible,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 挂载时根据当前滚动位置初始化一次按钮可见性。
|
// 挂载时根据当前滚动位置初始化一次按钮可见性。
|
||||||
@ -101,7 +101,7 @@ fn scroll_to_top() {
|
|||||||
let options = web_sys::ScrollToOptions::new();
|
let options = web_sys::ScrollToOptions::new();
|
||||||
options.set_top(0.0);
|
options.set_top(0.0);
|
||||||
options.set_behavior(web_sys::ScrollBehavior::Smooth);
|
options.set_behavior(web_sys::ScrollBehavior::Smooth);
|
||||||
let _ = window.scroll_to_with_scroll_to_options(&options);
|
window.scroll_to_with_scroll_to_options(&options);
|
||||||
|
|
||||||
if let Ok(history) = window.history() {
|
if let Ok(history) = window.history() {
|
||||||
let _ = history.replace_state_with_url(&wasm_bindgen::JsValue::NULL, "", Some(" "));
|
let _ = history.replace_state_with_url(&wasm_bindgen::JsValue::NULL, "", Some(" "));
|
||||||
|
|||||||
@ -42,8 +42,9 @@ where
|
|||||||
|
|
||||||
// 用 use_hook 持有 (Closure, target),在整个组件生命周期内复用;
|
// 用 use_hook 持有 (Closure, target),在整个组件生命周期内复用;
|
||||||
// use_drop 时 take 出来移除监听,防止泄漏。
|
// use_drop 时 take 出来移除监听,防止泄漏。
|
||||||
let state: Rc<RefCell<Option<(wasm_bindgen::prelude::Closure<dyn FnMut()>, T)>>> =
|
type ListenerState<T> =
|
||||||
use_hook(|| Rc::new(RefCell::new(None)));
|
Rc<RefCell<Option<(wasm_bindgen::prelude::Closure<dyn FnMut()>, T)>>>;
|
||||||
|
let state: ListenerState<T> = use_hook(|| Rc::new(RefCell::new(None)));
|
||||||
let state_for_drop = state.clone();
|
let state_for_drop = state.clone();
|
||||||
|
|
||||||
// use_effect 的回调是 FnMut(可能多次运行),但 acquire 是 FnOnce、handler 要
|
// use_effect 的回调是 FnMut(可能多次运行),但 acquire 是 FnOnce、handler 要
|
||||||
|
|||||||
@ -721,12 +721,9 @@ fn SqlConsoleTab() -> Element {
|
|||||||
opts.set_on_change(&on_change);
|
opts.set_on_change(&on_change);
|
||||||
opts.set_on_ready(&on_ready);
|
opts.set_on_ready(&on_ready);
|
||||||
|
|
||||||
match codemirror_bridge::get_module().create("sql-editor", &opts) {
|
if let Ok(Some(inst)) = codemirror_bridge::get_module().create("sql-editor", &opts) {
|
||||||
Ok(Some(inst)) => {
|
let handle = codemirror_bridge::EditorHandle::new(inst, on_change, on_ready);
|
||||||
let handle = codemirror_bridge::EditorHandle::new(inst, on_change, on_ready);
|
editor_handle.set(Some(handle));
|
||||||
editor_handle.set(Some(handle));
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 异步拉取 schema 注入补全
|
// 异步拉取 schema 注入补全
|
||||||
@ -1197,9 +1194,8 @@ fn BackupTab() -> Element {
|
|||||||
active_progress.set(Some(p));
|
active_progress.set(Some(p));
|
||||||
if done {
|
if done {
|
||||||
// 刷新列表(备份完成后新文件出现)并清理任务态
|
// 刷新列表(备份完成后新文件出现)并清理任务态
|
||||||
match list_backups().await {
|
if let Ok(list) = list_backups().await {
|
||||||
Ok(list) => backups_f.set(list),
|
backups_f.set(list);
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
active_task_id.set(None);
|
active_task_id.set(None);
|
||||||
busy_f.set(false);
|
busy_f.set(false);
|
||||||
|
|||||||
@ -297,7 +297,7 @@ fn write_editor(post_id: Option<i32>) -> Element {
|
|||||||
// 将逗号分隔的标签字符串转换为列表。
|
// 将逗号分隔的标签字符串转换为列表。
|
||||||
// 同时支持半角/全角逗号与分号,避免中文输入法下的全角标点被误并入单个标签。
|
// 同时支持半角/全角逗号与分号,避免中文输入法下的全角标点被误并入单个标签。
|
||||||
let tags_list: Vec<String> = tags()
|
let tags_list: Vec<String> = tags()
|
||||||
.split(|c| matches!(c, ',' | ',' | ';' | ';'))
|
.split([',', ',', ';', ';'])
|
||||||
.map(|t| t.trim().to_string())
|
.map(|t| t.trim().to_string())
|
||||||
.filter(|t| !t.is_empty())
|
.filter(|t| !t.is_empty())
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user