feat: default user agent same with app version
This commit is contained in:
parent
30ef3057ac
commit
f68378041f
@ -204,7 +204,9 @@ impl PrfItem {
|
|||||||
builder = builder.no_proxy();
|
builder = builder.no_proxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
builder = builder.user_agent(user_agent.unwrap_or("clash-verge/v1.0.0".into()));
|
let version = unsafe { dirs::APP_VERSION };
|
||||||
|
let version = format!("clash-verge/{version}");
|
||||||
|
builder = builder.user_agent(user_agent.unwrap_or(version));
|
||||||
|
|
||||||
let resp = builder.build()?.get(url).send().await?;
|
let resp = builder.build()?.get(url).send().await?;
|
||||||
let header = resp.headers();
|
let header = resp.headers();
|
||||||
|
@ -21,6 +21,8 @@ static mut RESOURCE_DIR: Option<PathBuf> = None;
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
static mut PORTABLE_FLAG: bool = false;
|
static mut PORTABLE_FLAG: bool = false;
|
||||||
|
|
||||||
|
pub static mut APP_VERSION: &str = "v1.1.1";
|
||||||
|
|
||||||
/// initialize portable flag
|
/// initialize portable flag
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub unsafe fn init_portable_flag() {
|
pub unsafe fn init_portable_flag() {
|
||||||
@ -66,6 +68,10 @@ pub fn app_resources_dir(package_info: &PackageInfo) -> PathBuf {
|
|||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
RESOURCE_DIR = Some(res_dir.clone());
|
RESOURCE_DIR = Some(res_dir.clone());
|
||||||
|
|
||||||
|
let ver = &package_info.version;
|
||||||
|
let ver_str = format!("v{}.{}.{}", ver.major, ver.minor, ver.patch);
|
||||||
|
APP_VERSION = Box::leak(Box::new(ver_str));
|
||||||
}
|
}
|
||||||
|
|
||||||
res_dir
|
res_dir
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { Settings } from "@mui/icons-material";
|
import { Settings } from "@mui/icons-material";
|
||||||
import { patchProfile } from "@/services/cmds";
|
import { patchProfile } from "@/services/cmds";
|
||||||
|
import { version } from "@root/package.json";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -119,7 +120,7 @@ const InfoEditor = (props: Props) => {
|
|||||||
{...textFieldProps}
|
{...textFieldProps}
|
||||||
label="User Agent"
|
label="User Agent"
|
||||||
value={option.user_agent}
|
value={option.user_agent}
|
||||||
placeholder="clash-verge/v1.0.0"
|
placeholder={`clash-verge/v${version}`}
|
||||||
onChange={(e) => setOption({ user_agent: e.target.value })}
|
onChange={(e) => setOption({ user_agent: e.target.value })}
|
||||||
onKeyDown={(e) => e.key === "Enter" && onUpdate()}
|
onKeyDown={(e) => e.key === "Enter" && onUpdate()}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user