Skip to content
Snippets Groups Projects
Unverified Commit f6837804 authored by GyDi's avatar GyDi
Browse files

feat: default user agent same with app version

parent 30ef3057
No related branches found
No related tags found
No related merge requests found
......@@ -204,7 +204,9 @@ impl PrfItem {
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 header = resp.headers();
......
......@@ -21,6 +21,8 @@ static mut RESOURCE_DIR: Option<PathBuf> = None;
#[allow(unused)]
static mut PORTABLE_FLAG: bool = false;
pub static mut APP_VERSION: &str = "v1.1.1";
/// initialize portable flag
#[allow(unused)]
pub unsafe fn init_portable_flag() {
......@@ -66,6 +68,10 @@ pub fn app_resources_dir(package_info: &PackageInfo) -> PathBuf {
unsafe {
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
......
......@@ -13,6 +13,7 @@ import {
} from "@mui/material";
import { Settings } from "@mui/icons-material";
import { patchProfile } from "@/services/cmds";
import { version } from "@root/package.json";
import Notice from "../base/base-notice";
interface Props {
......@@ -119,7 +120,7 @@ const InfoEditor = (props: Props) => {
{...textFieldProps}
label="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 })}
onKeyDown={(e) => e.key === "Enter" && onUpdate()}
/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment