feat: 添加一些实用方法

This commit is contained in:
lanyeeee
2025-07-10 05:51:50 +08:00
parent 3495cc771a
commit acd7b2902e
2 changed files with 24 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
mod commands;
mod utils;
use tauri::Wry;
@@ -28,6 +29,10 @@ pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(builder.invoke_handler())
.setup(move |app| {
builder.mount_events(app);
Ok(())
})
.run(generate_context())
.expect("error while running tauri application");
}

19
src-tauri/src/utils.rs Normal file
View File

@@ -0,0 +1,19 @@
pub fn filename_filter(s: &str) -> String {
s.chars()
.map(|c| match c {
'\\' | '/' | '\n' => ' ',
':' => '',
'*' => '⭐',
'?' => '',
'"' => '\'',
'<' => '《',
'>' => '》',
'|' => '丨',
_ => c,
})
.collect::<String>()
.trim()
.trim_end_matches('.')
.trim()
.to_string()
}