refactor: 优化部分代码,移除一批 unwrap

This commit is contained in:
amtoaer
2025-01-21 03:12:45 +08:00
parent c10c14c125
commit cdc30e1b32
9 changed files with 70 additions and 100 deletions
+2 -2
View File
@@ -133,7 +133,7 @@ impl<'a> Collection<'a> {
("pn", page.as_str()),
("ps", "30"),
],
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
MIXIN_KEY.load().as_deref(),
),
),
CollectionType::Season => (
@@ -146,7 +146,7 @@ impl<'a> Collection<'a> {
("page_num", page.as_str()),
("page_size", "30"),
],
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
MIXIN_KEY.load().as_deref(),
),
),
};
+2 -2
View File
@@ -210,10 +210,10 @@ fn get_filename(url: &str) -> Option<&str> {
pub fn encoded_query<'a>(
params: Vec<(&'a str, impl Into<Cow<'a, str>>)>,
mixin_key: Option<&str>,
mixin_key: Option<impl AsRef<str>>,
) -> Vec<(&'a str, Cow<'a, str>)> {
match mixin_key {
Some(key) => _encoded_query(params, key, chrono::Local::now().timestamp().to_string()),
Some(key) => _encoded_query(params, key.as_ref(), chrono::Local::now().timestamp().to_string()),
None => params.into_iter().map(|(k, v)| (k, v.into())).collect(),
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ impl<'a> Submission<'a> {
("pn", page.to_string()),
("ps", "30".to_string()),
],
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
MIXIN_KEY.load().as_deref(),
))
.send()
.await?
+1 -1
View File
@@ -154,7 +154,7 @@ impl<'a> Video<'a> {
("fnval", "4048"),
("fourk", "1"),
],
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
MIXIN_KEY.load().as_deref(),
))
.send()
.await?