chore: format rust code

This commit is contained in:
GyDi 2022-11-12 11:37:23 +08:00
parent a211fc7c97
commit 4668be6e24
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A
31 changed files with 3268 additions and 3262 deletions

View File

@ -5,3 +5,9 @@ charset = utf-8
end_of_line = lf
indent_size = 2
insert_final_newline = true
[*.rs]
charset = utf-8
end_of_line = lf
indent_size = 4
insert_final_newline = true

View File

@ -1,6 +1,6 @@
max_width = 100
hard_tabs = false
tab_spaces = 2
tab_spaces = 4
newline_style = "Auto"
use_small_heuristics = "Default"
reorder_imports = true

View File

@ -14,8 +14,7 @@ impl Handle {
}
pub fn get_window(&self) -> Option<Window> {
self
.app_handle
self.app_handle
.as_ref()
.map_or(None, |a| a.get_window("main"))
}

View File

@ -241,7 +241,9 @@ impl Service {
204 => break,
// 配置有问题不重试
400 => bail!("failed to update clash config with status 400"),
status @ _ => report_err!(i, "failed to activate clash with status \"{status}\""),
status @ _ => {
report_err!(i, "failed to activate clash with status \"{status}\"")
}
},
Err(err) => report_err!(i, "{err}"),
}

View File

@ -68,7 +68,8 @@ impl Timer {
.filter(|item| item.uid.is_some() && item.updated.is_some() && item.option.is_some())
.filter(|item| {
// mins to seconds
let interval = item.option.as_ref().unwrap().update_interval.unwrap_or(0) as usize * 60;
let interval =
item.option.as_ref().unwrap().update_interval.unwrap_or(0) as usize * 60;
let updated = item.updated.unwrap();
return interval > 0 && cur_timestamp - updated >= interval;
})
@ -149,8 +150,7 @@ impl Timer {
.spawn_async_routine(move || Self::async_task(core.to_owned(), uid.to_owned()))
.context("failed to create timer task")?;
self
.delay_timer
self.delay_timer
.add_task(task)
.context("failed to add timer task")?;

View File

@ -33,7 +33,10 @@ impl Tray {
SystemTrayMenu::new()
.add_item(CustomMenuItem::new("restart_clash", "重启 Clash"))
.add_item(CustomMenuItem::new("restart_app", "重启应用"))
.add_item(CustomMenuItem::new("app_version", format!("Version {version}")).disabled()),
.add_item(
CustomMenuItem::new("app_version", format!("Version {version}"))
.disabled(),
),
))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("quit", "退出").accelerator("CmdOrControl+Q"))
@ -53,7 +56,10 @@ impl Tray {
SystemTrayMenu::new()
.add_item(CustomMenuItem::new("restart_clash", "Restart Clash"))
.add_item(CustomMenuItem::new("restart_app", "Restart App"))
.add_item(CustomMenuItem::new("app_version", format!("Version {version}")).disabled()),
.add_item(
CustomMenuItem::new("app_version", format!("Version {version}"))
.disabled(),
),
))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("quit", "Quit").accelerator("CmdOrControl+Q"))

View File

@ -203,7 +203,8 @@ impl Profiles {
// move the field value after save
if let Some(file_data) = item.file_data.take() {
let file = each.file.take();
let file = file.unwrap_or(item.file.take().unwrap_or(format!("{}.yaml", &uid)));
let file =
file.unwrap_or(item.file.take().unwrap_or(format!("{}.yaml", &uid)));
// the file must exists
each.file = Some(file.clone());

View File

@ -91,7 +91,7 @@ fn main() -> std::io::Result<()> {
.add_native_item(MenuItem::Cut)
.add_native_item(MenuItem::SelectAll)
.add_native_item(MenuItem::CloseWindow)
.add_native_item(MenuItem::Quit)
.add_native_item(MenuItem::Quit),
)),
);
}

View File

@ -25,13 +25,8 @@
"icons/icon-new.icns",
"icons/icon.ico"
],
"resources": [
"resources"
],
"externalBin": [
"sidecar/clash",
"sidecar/clash-meta"
],
"resources": ["resources"],
"externalBin": ["sidecar/clash", "sidecar/clash-meta"],
"copyright": "© 2022 zzzgydi All Rights Reserved",
"category": "DeveloperTool",
"shortDescription": "A Clash GUI based on tauri.",
@ -51,10 +46,7 @@
"digestAlgorithm": "sha256",
"timestampUrl": "",
"wix": {
"language": [
"zh-CN",
"en-US"
]
"language": ["zh-CN", "en-US"]
}
}
},