Skip to content

Commit

Permalink
feat: Add Language
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Sep 24, 2023
1 parent c04c8f1 commit b60cefc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::error::Error;
#[no_mangle]
pub fn collection(
source: &str,
_target: &str,
from: &str,
_to: &str,
needs: HashMap<String, String>,
) -> Result<Value, Box<dyn Error>> {
Expand All @@ -17,7 +19,7 @@ pub fn collection(
let res: Value = client
.get("https://dict.youdao.com/wordbook/webapi/v2/ajax/add")
.header("Cookie", cookie)
.query(&[("word", source), ("lan", "en")])
.query(&[("word", source), ("lan", from)])
.send()?
.json()?;
if let Some(json) = res.as_object() {
Expand All @@ -41,7 +43,7 @@ mod tests {
fn try_request() {
let mut needs = HashMap::new();
needs.insert("cookie".to_string(), "".to_string());
let result = collection("Hello", "en", needs).unwrap();
let result = collection("Hello", "", "en", "zh", needs).unwrap();
println!("{result}");
}
}

0 comments on commit b60cefc

Please sign in to comment.