Skip to content

Commit

Permalink
fix: 修复字体 api 请求失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
QingXia-Ela committed Jul 29, 2024
1 parent 5f93cbc commit b9bd878
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
14 changes: 13 additions & 1 deletion packages/plugins/ncm_inject/src-rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,7 @@ impl NcmRequestHandler {
}

#[tokio::main]
pub async fn ping(&self) {
let res = self
.client
.get(format!("{REQUEST_BASE}/pong"))
.send()
.await
.unwrap();

// if res.status()
}
pub async fn ping(&self) {}

/// Only allow get single song.
#[tokio::main]
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/proxy/cdn_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ async fn handle_request(

fn change_body(body: String, port: u16, api_port: u16, filter_rules: FilterType) -> String {
let mut basic = body
// fontset api handle
.replace("/api/fontset", "/fontset")
// replace cdn
.replace("web.hycdn.cn", format!("localhost:{}", port).as_str())
.replace("https", "http")
Expand Down
30 changes: 24 additions & 6 deletions src-tauri/src/proxy/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,18 @@ pub async fn handle_request_with_plugin(
msg: "".to_string(),
data: r,
};
return Ok(get_response_from_string(
serde_json::to_string(&res).unwrap(),
));
match serde_json::to_string(&res) {
Ok(s) => {
return Ok(get_response_from_string(s));
}
Err(e) => {
#[cfg(debug_assertions)]
logger::error(format!("{:?}", e).as_str());
return Ok(parse_plugin_request_error_2_warp_rejection(
PluginRequestError::new(format!("{:?}", e)),
));
}
}
}
Err(e) => {
return Ok(parse_plugin_request_error_2_warp_rejection(e.into()));
Expand All @@ -154,9 +163,18 @@ pub async fn handle_request_with_plugin(
msg: "".to_string(),
data: r,
};
return Ok(get_response_from_string(
serde_json::to_string(&res).unwrap(),
));
match serde_json::to_string(&res) {
Ok(s) => {
return Ok(get_response_from_string(s));
}
Err(e) => {
#[cfg(debug_assertions)]
logger::error(format!("{:?}", e).as_str());
return Ok(parse_plugin_request_error_2_warp_rejection(
PluginRequestError::new(format!("{:?}", e)),
));
}
}
}
Err(e) => {
return Ok(parse_plugin_request_error_2_warp_rejection(e.into()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ const useControlledMenu = (options: any) => {
function parseU64Duration2Time(duration: number) {
const minute = Math.floor(duration / 60000);
const second = Math.floor((duration % 60000) / 1000);
return `${minute < 10 ? '0' + minute : minute}:${
second < 10 ? '0' + second : second
}`;
return `${minute < 10 ? '0' + minute : minute}:${second < 10 ? '0' + second : second
}`;
}

function getTagsBySongCid(cid: string, data: InjectorMetadata[]) {
Expand Down Expand Up @@ -105,8 +104,6 @@ const RightDetailsBottomList: FunctionComponent<
return <PendingTips />;
}

console.log(list);

return list.length ? (
<>
<Scrollbar
Expand Down

0 comments on commit b9bd878

Please sign in to comment.