mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-04 23:33:44 +08:00
chore: enable pre-commit for Rust formatting, pre-push for Rust linter check
This commit is contained in:
parent
ca0cf4552c
commit
42db9ea0bb
@ -3,14 +3,14 @@
|
||||
#pnpm pretty-quick --staged
|
||||
|
||||
# 运行 clippy fmt
|
||||
#cargo fmt --manifest-path ./src-tauri/Cargo.toml
|
||||
cargo fmt --manifest-path ./src-tauri/Cargo.toml
|
||||
|
||||
# if [ $? -ne 0 ]; then
|
||||
# echo "rustfmt failed to format the code. Please fix the issues and try again."
|
||||
# exit 1
|
||||
# fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "rustfmt failed to format the code. Please fix the issues and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#git add .
|
||||
git add .
|
||||
|
||||
# 允许提交
|
||||
exit 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 运行 clippy
|
||||
#cargo clippy --manifest-path ./src-tauri/Cargo.toml --fix
|
||||
cargo clippy --manifest-path ./src-tauri/Cargo.toml --fix
|
||||
|
||||
# 如果 clippy 失败,阻止 push
|
||||
#if [ $? -ne 0 ]; then
|
||||
# echo "Clippy found issues in sub_crate. Please fix them before pushing."
|
||||
# exit 1
|
||||
#fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Clippy found issues in sub_crate. Please fix them before pushing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 允许 push
|
||||
exit 0
|
@ -2,11 +2,9 @@ use chrono::Local;
|
||||
use regex::Regex;
|
||||
use reqwest::Client;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use tauri::command;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::task::JoinSet;
|
||||
use tokio::{sync::Mutex, task::JoinSet};
|
||||
|
||||
// 定义解锁测试项目的结构
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@ -464,9 +462,11 @@ async fn check_netflix(client: &Client) -> UnlockItem {
|
||||
let url2 = "https://www.netflix.com/title/70143836"; // Breaking Bad
|
||||
|
||||
// 创建简单的请求(不添加太多头部信息)
|
||||
let result1 = client.get(url1)
|
||||
let result1 = client
|
||||
.get(url1)
|
||||
.timeout(std::time::Duration::from_secs(30))
|
||||
.send().await;
|
||||
.send()
|
||||
.await;
|
||||
|
||||
// 检查连接失败情况
|
||||
if let Err(e) = &result1 {
|
||||
@ -480,9 +480,11 @@ async fn check_netflix(client: &Client) -> UnlockItem {
|
||||
}
|
||||
|
||||
// 如果第一个请求成功,尝试第二个请求
|
||||
let result2 = client.get(url2)
|
||||
let result2 = client
|
||||
.get(url2)
|
||||
.timeout(std::time::Duration::from_secs(30))
|
||||
.send().await;
|
||||
.send()
|
||||
.await;
|
||||
|
||||
if let Err(e) = &result2 {
|
||||
eprintln!("Netflix请求错误: {}", e);
|
||||
@ -521,7 +523,8 @@ async fn check_netflix(client: &Client) -> UnlockItem {
|
||||
// 成功解锁,尝试获取地区信息
|
||||
// 使用Netflix测试内容获取区域
|
||||
let test_url = "https://www.netflix.com/title/80018499";
|
||||
match client.get(test_url)
|
||||
match client
|
||||
.get(test_url)
|
||||
.timeout(std::time::Duration::from_secs(30))
|
||||
.send()
|
||||
.await
|
||||
@ -561,7 +564,7 @@ async fn check_netflix(client: &Client) -> UnlockItem {
|
||||
region: None,
|
||||
check_time: Some(get_local_date_string()),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 其他未知错误状态
|
||||
@ -579,9 +582,11 @@ async fn check_netflix_cdn(client: &Client) -> UnlockItem {
|
||||
// Fast.com API URL
|
||||
let url = "https://api.fast.com/netflix/speedtest/v2?https=true&token=YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm&urlCount=5";
|
||||
|
||||
let result = client.get(url)
|
||||
let result = client
|
||||
.get(url)
|
||||
.timeout(std::time::Duration::from_secs(30))
|
||||
.send().await;
|
||||
.send()
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(response) => {
|
||||
@ -602,7 +607,9 @@ async fn check_netflix_cdn(client: &Client) -> UnlockItem {
|
||||
if let Some(targets) = data.get("targets").and_then(|t| t.as_array()) {
|
||||
if !targets.is_empty() {
|
||||
if let Some(location) = targets[0].get("location") {
|
||||
if let Some(country) = location.get("country").and_then(|c| c.as_str()) {
|
||||
if let Some(country) =
|
||||
location.get("country").and_then(|c| c.as_str())
|
||||
{
|
||||
let emoji = country_code_to_emoji(country);
|
||||
return UnlockItem {
|
||||
name: "Netflix".to_string(),
|
||||
|
@ -232,7 +232,7 @@ impl Sysopt {
|
||||
log::info!(target: "app", "Auto launch enabled successfully");
|
||||
}
|
||||
log_err!(result)
|
||||
},
|
||||
}
|
||||
false => {
|
||||
let result = autostart_manager.disable();
|
||||
if let Err(ref e) = result {
|
||||
@ -241,7 +241,7 @@ impl Sysopt {
|
||||
log::info!(target: "app", "Auto launch disabled successfully");
|
||||
}
|
||||
log_err!(result)
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
@ -256,7 +256,7 @@ impl Sysopt {
|
||||
Ok(status) => {
|
||||
log::info!(target: "app", "Auto launch status: {}", status);
|
||||
Ok(status)
|
||||
},
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!(target: "app", "Failed to get auto launch status: {}", e);
|
||||
Err(anyhow::anyhow!("Failed to get auto launch status: {}", e))
|
||||
|
@ -1,3 +1,3 @@
|
||||
pub mod lightweight;
|
||||
pub mod mihomo;
|
||||
pub mod sysinfo;
|
||||
pub mod lightweight;
|
Loading…
x
Reference in New Issue
Block a user