mirror of
https://github.com/lanyeeee/bilibili-video-downloader.git
synced 2026-06-11 10:30:13 +08:00
feat: 添加一些实用方法
This commit is contained in:
@@ -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
19
src-tauri/src/utils.rs
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user