mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-20 02:42:12 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b654b95ca |
@@ -5,7 +5,7 @@
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/node:2": {
|
||||
"version": "26.13.1",
|
||||
"pnpmVersion": "12.21.0"
|
||||
"pnpmVersion": "12.18.0"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/rust:1": {
|
||||
"version": "1.100.0",
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
"version": "v9.0.0",
|
||||
"sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3"
|
||||
},
|
||||
"github/gh-aw-actions/setup@v1.3.1": {
|
||||
"github/gh-aw-actions/setup@v1.3.0": {
|
||||
"repo": "github/gh-aw-actions/setup",
|
||||
"version": "v1.3.1",
|
||||
"sha": "dfe97a19c8249d41e2adfc95f92db2b8facea58f"
|
||||
"version": "v1.3.0",
|
||||
"sha": "8126d6cb07dea9221848de275af8a41474d839ca"
|
||||
}
|
||||
},
|
||||
"containers": {
|
||||
|
||||
@@ -31,9 +31,9 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Install gh-aw extension
|
||||
uses: github/gh-aw-actions/setup-cli@dfe97a19c8249d41e2adfc95f92db2b8facea58f # v1.3.1
|
||||
uses: github/gh-aw-actions/setup-cli@8126d6cb07dea9221848de275af8a41474d839ca # v1.3.0
|
||||
with:
|
||||
version: v1.3.1
|
||||
version: v1.3.0
|
||||
- name: Install Rust Stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
|
||||
+70
-36
File diff suppressed because one or more lines are too long
@@ -30,10 +30,6 @@ max-ai-credits: 60
|
||||
max-turns: 12
|
||||
max-daily-ai-credits: 5000
|
||||
|
||||
# Routine, low-risk tasks such as triage, labeling, and summaries.
|
||||
# See https://github.github.com/gh-aw/reference/model-routing/#setting-the-level-yourself
|
||||
model: router/economy
|
||||
|
||||
permissions:
|
||||
issues: read
|
||||
pull-requests: read
|
||||
|
||||
Generated
+71
-37
File diff suppressed because one or more lines are too long
@@ -26,9 +26,6 @@ imports:
|
||||
max-ai-credits: 60
|
||||
max-turns: 12
|
||||
max-daily-ai-credits: 500
|
||||
# Routine, low-risk tasks such as triage, labeling, and summaries.
|
||||
# See https://github.github.com/gh-aw/reference/model-routing/#setting-the-level-yourself
|
||||
model: router/economy
|
||||
permissions:
|
||||
contents: read
|
||||
issues: read
|
||||
|
||||
+73
-39
File diff suppressed because one or more lines are too long
@@ -32,13 +32,8 @@ permissions:
|
||||
max-ai-credits: 60
|
||||
max-turns: 12
|
||||
max-daily-ai-credits: 500
|
||||
# Routine, low-risk tasks such as triage, labeling, and summaries.
|
||||
# See https://github.github.com/gh-aw/reference/model-routing/#setting-the-level-yourself
|
||||
model: router/economy
|
||||
network:
|
||||
# GitHub CLI recommend using ecosystem identifiers instead of individual domain names for better maintainability,
|
||||
# hence "node" is prefer than "nodejs.org"
|
||||
allowed: [github, docs.rs, doc.rust-lang.org, node, www.typescriptlang.org]
|
||||
allowed: [github, docs.rs, doc.rust-lang.org, nodejs.org, www.typescriptlang.org]
|
||||
steps:
|
||||
- name: Load trusted metadata parser
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
nodejs 26.13.1
|
||||
pnpm 12.21.0
|
||||
pnpm 12.18.0
|
||||
rust 1.100.0
|
||||
|
||||
Generated
+2
-2
@@ -7545,8 +7545,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-mihomo"
|
||||
version = "0.7.1"
|
||||
source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo?rev=7e4fa8642cf6c394ed88b5a969420d8eab60087f#7e4fa8642cf6c394ed88b5a969420d8eab60087f"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo?rev=e49bbedcc67d60da2c10e81bc6433b0f8e8fa232#e49bbedcc67d60da2c10e81bc6433b0f8e8fa232"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"clashmap",
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
- 修复「连接」页表格排序时表头换行、标题位置跳动
|
||||
- 修复「TUN 设置」未手动保存时,界面显示的默认 MTU 1500 未生效
|
||||
- 修复「链式代理」节点列表按名称排序,未保持订阅中的节点顺序
|
||||
- 修复规则模式下 Muse AI 解锁检测显示错误的出口地区
|
||||
|
||||
**🍎 macOS**
|
||||
|
||||
@@ -56,7 +55,6 @@
|
||||
<summary><strong> ✨ 新增功能 </strong></summary>
|
||||
|
||||
- 新增连接页面按网络协议(TCP/UDP)筛选连接
|
||||
- 新增规则模式下在 `url-test` 或 `fallback` 代理组选节点时,自动将首个包含该组的 `select` 代理组切换到该组,可在「杂项设置」关闭
|
||||
|
||||
</details>
|
||||
|
||||
@@ -65,8 +63,6 @@
|
||||
|
||||
- 优化连接、规则和日志筛选:切换页面后保留过滤条件
|
||||
- 优化全局模式代理列表:仅显示 `GLOBAL` 节点,选中其中的策略组时才显示该组
|
||||
- 优化设置页开关和选项所在行的鼠标悬停高亮,便于对应说明与控件
|
||||
- 优化首页「当前节点」卡片:代理组列表加入 `fallback` 代理组,切换到 `url-test` 或 `fallback` 代理组时同样联动 `select` 代理组
|
||||
|
||||
**🍎 macOS**
|
||||
|
||||
|
||||
@@ -15,6 +15,3 @@ tokio = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -19,7 +19,6 @@ fn make_draft() -> Draft<IVerge> {
|
||||
}
|
||||
|
||||
pub fn bench_draft(c: &mut Criterion) {
|
||||
#[allow(clippy::panic, reason = "bench setup cannot proceed without a runtime")]
|
||||
let rt = Runtime::new().unwrap_or_else(|e| panic!("Tokio runtime init failed: {e}"));
|
||||
|
||||
let mut group = c.benchmark_group("draft");
|
||||
|
||||
@@ -102,7 +102,6 @@ impl<T: Clone> Draft<T> {
|
||||
let (local, original_arc) = {
|
||||
let guard = self.inner.data.lock();
|
||||
let arc = Arc::clone(&guard.0);
|
||||
drop(guard);
|
||||
((**arc).clone(), arc)
|
||||
};
|
||||
let (new_local, res) = f(local).await?;
|
||||
@@ -113,7 +112,6 @@ impl<T: Clone> Draft<T> {
|
||||
));
|
||||
}
|
||||
guard.0 = Arc::new(Box::new(new_local));
|
||||
drop(guard);
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
@@ -127,10 +125,7 @@ impl<T: Clone> Draft<T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
async fn acquire_data_modify_permit(&self) -> DataModifyPermit<'_>
|
||||
where
|
||||
T: Send + Sync,
|
||||
{
|
||||
async fn acquire_data_modify_permit(&self) -> DataModifyPermit<'_> {
|
||||
for _ in 0..DATA_MODIFY_FAST_RETRY_YIELDS {
|
||||
if let Some(permit) = self.try_acquire_data_modify_permit() {
|
||||
return permit;
|
||||
|
||||
@@ -15,6 +15,3 @@ default = []
|
||||
tokio-trace = ["tracing-estuary/tokio-trace"]
|
||||
chrome-trace = ["tracing-estuary/chrome-trace"]
|
||||
color = ["tracing-estuary/color"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -160,7 +160,7 @@ pub struct Logger {
|
||||
static LOGGER: OnceLock<Logger> = OnceLock::new();
|
||||
|
||||
impl Logger {
|
||||
const fn new() -> Self {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
pipeline: OnceLock::new(),
|
||||
sidecar_file_writer: RwLock::new(None),
|
||||
@@ -185,7 +185,7 @@ impl Logger {
|
||||
self.store_config(cfg);
|
||||
let pipeline = tracing_estuary::PipelineBuilder::new()
|
||||
.default_level(log_level)
|
||||
.file_writer(self.generate_file_log_writer())
|
||||
.file_writer(self.generate_file_log_writer()?)
|
||||
.init()?;
|
||||
self.pipeline.set(pipeline).ok();
|
||||
Ok(())
|
||||
@@ -225,11 +225,11 @@ impl Logger {
|
||||
self.log_max_count.store(cfg.max_count, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
fn generate_file_log_writer(&self) -> FileLogWriterBuilder {
|
||||
fn generate_file_log_writer(&self) -> Result<FileLogWriterBuilder> {
|
||||
let log_dir = self.log_dir.get().cloned().unwrap_or_default();
|
||||
let log_max_size = self.log_max_size.load(Ordering::SeqCst);
|
||||
let log_max_count = self.log_max_count.load(Ordering::SeqCst);
|
||||
FileLogWriter::builder(FileSpec::default().directory(log_dir).basename(""))
|
||||
let flwb = FileLogWriter::builder(FileSpec::default().directory(log_dir).basename(""))
|
||||
.format(tracing_estuary::file_format_with_level)
|
||||
.write_mode(flexi_logger::WriteMode::BufferAndFlushWith(
|
||||
WRITE_BUFFER_CAPACITY,
|
||||
@@ -239,7 +239,8 @@ impl Logger {
|
||||
Criterion::Size(log_max_size * 1024),
|
||||
ROTATE_NAMING,
|
||||
Cleanup::KeepLogFiles(log_max_count),
|
||||
)
|
||||
);
|
||||
Ok(flwb)
|
||||
}
|
||||
|
||||
/// Ensures the sidecar writer exists and points at `builder`'s config:
|
||||
@@ -310,7 +311,7 @@ impl Logger {
|
||||
self.log_max_size.store(log_max_size, Ordering::SeqCst);
|
||||
self.log_max_count.store(log_max_count, Ordering::SeqCst);
|
||||
if let Some(pipeline) = self.pipeline.get() {
|
||||
let log_file_writer = self.generate_file_log_writer();
|
||||
let log_file_writer = self.generate_file_log_writer()?;
|
||||
if let Some(sink) = pipeline.sink.as_ref() {
|
||||
sink.reset(log_file_writer)
|
||||
.map_err(|error| anyhow::anyhow!("failed to reset log writer: {error}"))?;
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
use reqwest::Client;
|
||||
|
||||
use crate::utils::classify_restricted_status;
|
||||
use crate::utils::{classify_restricted_status, get_trace_location};
|
||||
|
||||
use super::UnlockItem;
|
||||
|
||||
pub(crate) const MUSE_AI_NAME: &str = "Muse AI";
|
||||
|
||||
const MUSE_URL: &str = "https://muse.ai";
|
||||
const CLOUDFLARE_TRACE_URL: &str = "https://www.cloudflare.com/cdn-cgi/trace";
|
||||
|
||||
// The aymh ("Are You a Human") gateway answers plain HTTP requests with a
|
||||
// generic Meta error page that always contains the Facebook logo asset.
|
||||
const AYMH_ERROR_MARKERS: &[&str] = &["Sorry, something went wrong", "static.facebook.com/images/logos"];
|
||||
|
||||
pub(super) async fn check_muse_ai(client: &Client) -> UnlockItem {
|
||||
// muse.ai is served by Vercel and does not expose a service-specific region trace endpoint.
|
||||
// Querying a generic third-party domain (e.g. www.cloudflare.com/cdn-cgi/trace) would report
|
||||
// that domain's proxy group rather than muse.ai's actual exit in Rule mode, so leave region as None.
|
||||
// muse.ai itself is served by Vercel, so resolve the exit region through
|
||||
// the generic Cloudflare trace endpoint instead of a service-specific one.
|
||||
let region = get_trace_location(client, CLOUDFLARE_TRACE_URL)
|
||||
.await
|
||||
.map(|code| code.trim().to_ascii_uppercase())
|
||||
.map(|code| UnlockItem::region_label(&code));
|
||||
|
||||
let Ok(response) = client.get(MUSE_URL).send().await else {
|
||||
return UnlockItem::checked(MUSE_AI_NAME, "Failed (Network Connection)", None);
|
||||
return UnlockItem::checked(MUSE_AI_NAME, "Failed (Network Connection)", region);
|
||||
};
|
||||
|
||||
let status = response.status();
|
||||
@@ -39,5 +44,5 @@ pub(super) async fn check_muse_ai(client: &Client) -> UnlockItem {
|
||||
classify_restricted_status(status).unwrap_or("Failed")
|
||||
};
|
||||
|
||||
UnlockItem::checked(MUSE_AI_NAME, result, None)
|
||||
UnlockItem::checked(MUSE_AI_NAME, result, region)
|
||||
}
|
||||
|
||||
+2
-2
@@ -75,7 +75,7 @@
|
||||
"react-dom": "19.3.1",
|
||||
"react-error-boundary": "6.1.6",
|
||||
"react-hook-form": "^7.88.0",
|
||||
"react-i18next": "18.0.1",
|
||||
"react-i18next": "18.0.2",
|
||||
"react-markdown": "10.1.0",
|
||||
"react-router": "^8.4.0",
|
||||
"rehype-raw": "^7.0.0",
|
||||
@@ -138,5 +138,5 @@
|
||||
]
|
||||
},
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@12.21.0"
|
||||
"packageManager": "pnpm@12.18.0"
|
||||
}
|
||||
|
||||
Generated
+66
-75
@@ -7,162 +7,153 @@ importers:
|
||||
configDependencies: {}
|
||||
packageManagerDependencies:
|
||||
pnpm:
|
||||
specifier: 12.21.0
|
||||
version: 12.21.0
|
||||
specifier: 12.18.0
|
||||
version: 12.18.0
|
||||
|
||||
packages:
|
||||
|
||||
'@pnpm/exe.android-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-iaWidxR5B9NUBpwMznCQu1yUpKB6BjTY5BYX2lORj76VsfINdj8Z8XWSzSNrGI8qlxa28Jzdp5fiaspzOaJZlA==}
|
||||
'@pnpm/exe.android-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-fOF6IwgvnUKEmVedGqiAsNPfN2Ry8GvaqzSQOiF3RJFbpBfPKO/6YT54s1GjToyYinRxw9preHHPe4y2N3SzhA==}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@pnpm/exe.android-x64@12.21.0':
|
||||
resolution: {integrity: sha512-35e5v3wlwjIYxDywq+R6/z8CE4gLOEgRxt18yqz1tMRLmx2mnW+CFJI2Q8+srTNjn7gykXUC0x1k195JNikC5A==}
|
||||
'@pnpm/exe.android-x64@12.18.0':
|
||||
resolution: {integrity: sha512-6OiolnaCsB3/GcJ9XNrenbUH3zFHRJ+5QynrMUUEyThbgnnCzWxa199hpQlOmxN4rAXuYQ0IYgWFNUZxyzg31Q==}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
|
||||
'@pnpm/exe.darwin-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-F5OyMX/6zLSowpTZEQRojbCmPS1Pq+fyRaIinslsIe6Glh3qbyQ52u+Fe0eEzSaRuIbWZkXmAAXSWh6Q5Wrlgg==}
|
||||
'@pnpm/exe.darwin-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-zkq+4YzVIX39ETYLyC3W7LY7MpHEU/J3nRhHl4i2yPld2Cf2+rEKRh3ejJ4AmaQ77HHJLCktY4Z3jq0fpcxFXg==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@pnpm/exe.darwin-x64@12.21.0':
|
||||
resolution: {integrity: sha512-EzpvcsaE6hrrgYeEiAFYd2rSgFybYyxXhkAY7K3y6Hg3loVfcyJ81hHczpFzi8lW5RXtUlFECRPZ8ZAMRFQYYg==}
|
||||
'@pnpm/exe.darwin-x64@12.18.0':
|
||||
resolution: {integrity: sha512-qMsL9qx92unOTa6hgkfiTJv8ceZaTx0IQg7InhYDVX2ZrTECujaVEEVypnJK5m3eGUsP1KD7Y4qIgleCwfRsYw==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@pnpm/exe.freebsd-x64@12.21.0':
|
||||
resolution: {integrity: sha512-wNjuEnmdLks4aayPu/QZWQ5tQM9Jn+odUp/vwQM8BXRYoulkTZhtZTHoD60N6mUdLWef1hgUeUh8llNGEUsimw==}
|
||||
'@pnpm/exe.freebsd-x64@12.18.0':
|
||||
resolution: {integrity: sha512-/9vy/4ms52cU4MjZ5NhHd6N2d9L9W0kARf5/ff2tweAHu0VeUzs/0qp/7ZHFuddm2Wa/m0AKQoPum9AVUCqKsw==}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@pnpm/exe.linux-arm64-musl@12.21.0':
|
||||
resolution: {integrity: sha512-Ceit9zn4g5ZqCJtx1fV8eJE7p8aeXMrGZ+Dc01vRqZLIUNgNeI+Ur0ruyqxtsnJx6rGADyXzohumxPLHjaJ5AQ==}
|
||||
'@pnpm/exe.linux-arm64-musl@12.18.0':
|
||||
resolution: {integrity: sha512-Vp+TIMPPyackVCXkOdEKH/RmAn/r07EcIyrgZYQK7VrkksqZOie0GnWIx+85mPqeFEYCRtXIZAFJ9L4ceTndDg==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/exe.linux-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-4Oj/iF2TDCe2lcH0n4TupPR5sSdrNLclJB6xBElLMPCUOAvBhdf2rRlSaO5M4erJ6g4Fyy7YTXTpcmfFsKyxEA==}
|
||||
'@pnpm/exe.linux-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-2dpyVBCHT+FfpuQh9i+7MXAqNWYLCvD5vYr5p6Eimxoga8USLnjbUgyj72AOrO0hjc5ri3TEFP3jiyBHjkSZpQ==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-ppc64@12.21.0':
|
||||
resolution: {integrity: sha512-s2o7rdSDeUTBFsNqxptpZXlTgT6cojmMVUOvTQvFNSv6Easian02ha4tR32fwwD97Au4YzIIjMCwywCF4D82Sw==}
|
||||
'@pnpm/exe.linux-ppc64@12.18.0':
|
||||
resolution: {integrity: sha512-BBOOOfNJ2QwIIya3eKqOjiN4WNTszfRz7HCvw9XggcT7+ftMjNP8XJ/GfW+ltCBeUFR9d8WBVsr2m/NLjX2CZQ==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-riscv64@12.21.0':
|
||||
resolution: {integrity: sha512-EYv3GzxeBTITCuM3yGHHbpRFpUvyulkXpQ6LsjKAQNL3iaba1E6h9iDmlouLb3Io4AMMsfdk0/uG6poQ41uewA==}
|
||||
'@pnpm/exe.linux-riscv64@12.18.0':
|
||||
resolution: {integrity: sha512-7kMN77xSOYJX8GPSH5RbNAc5oM61LMmcSUukDDUwllnZPXm8GRPskCNsTWy8SCw01Kr1FB+5SwGNMiTdiziLNQ==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-s390x@12.21.0':
|
||||
resolution: {integrity: sha512-8VXGNGVNEfs7pL9GTZOzFxjFEnMt4WL3rLOADR5/kPQ7ROTV9GfpVI2DPO/zArXFSkvfc9Zad/WypHLbvzoaTQ==}
|
||||
'@pnpm/exe.linux-s390x@12.18.0':
|
||||
resolution: {integrity: sha512-htuSCpEcmDzhKoJqXbPkvfr176dBHU0QIF5mWcRiqxRXAB/1JoYiMYotfjWpk+ztgpB9qlx4XnWlLFAf7gzc6g==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-x64-musl@12.21.0':
|
||||
resolution: {integrity: sha512-MnC5vpIXYubhDZCgCwlfJMg7Cg6HupN2IuouT9gD/tUmOfVdQYqeyYccWbthyo/Jeto8de1oQlxeRN1+1Hl2DQ==}
|
||||
'@pnpm/exe.linux-x64-musl@12.18.0':
|
||||
resolution: {integrity: sha512-Uj+vzfIQ62kDP10x36yHZIXVs5ohdNtiPYwn5FhCLlNScHPo0OAI+ShGDtLofiBXKE7umu71Jmjm7N8a8zVcDw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/exe.linux-x64@12.21.0':
|
||||
resolution: {integrity: sha512-8eufCjHXspKbNS/kh8q4Q0gqJoOuvC4Q5pgos6XS8By/nAMtP+jf8F1Cw9er840kfAX+PJ/ts+A9qnLE91rvXQ==}
|
||||
'@pnpm/exe.linux-x64@12.18.0':
|
||||
resolution: {integrity: sha512-OJ+X2wcraldCwj75pCIerWARQSRpdfj0eBTs/2ODyhfeW46ylOnjTIE/GKra6Mn6E72/gBmXS8igrUioa+F9fQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.netbsd-x64@12.21.0':
|
||||
resolution: {integrity: sha512-eyh1M8hQZCkLWxuva7S/fc1SbFbgqg0/5di0dgWmyiuc2Io3dbWVihDun8X+XM8zsR5uhIDvvZpbS9aZQbCovg==}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
|
||||
'@pnpm/exe.win32-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-7xTxxUXo/grRLivSeIl6B21gnsz7ooe5EMPcJmQqwxc8WLJVReN8MzrlHru8bqXfVr4X3+6ZGZscntKenlCBqQ==}
|
||||
'@pnpm/exe.win32-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-wEY6jiACGcbhhi5yD59doHqNTndS7AaujaPmtWAu1DKkHru2hy5fJ9yUGecW72Ypaw2/I3BEprfMOopap2NQtw==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@pnpm/exe.win32-x64@12.21.0':
|
||||
resolution: {integrity: sha512-9TpkJemVApxJ1Z1w0ZFGN+AuSx4nJOqXSJUqMqDvaXTYwGOzvBiiWdFP9GN0ketiWCQS1Q0/pza2E7I3pP0OBQ==}
|
||||
'@pnpm/exe.win32-x64@12.18.0':
|
||||
resolution: {integrity: sha512-5FJkghO7RLRkQpWxeVEygW9XsmnNuxzPfXbgwFWCHsFyFhpDn/vOdL88ToQEM0Kt5igdW5s6U0/IDH8Dvkt3pg==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
pnpm@12.21.0:
|
||||
resolution: {integrity: sha512-Zv2CeO4ok1zpUXktNDZ/869cQyonVkRYIwKVM4NbjaUpu+C+UTCv1W7QcT+4eJ5Hutgtk71a4v5UsVVi1idu8A==}
|
||||
pnpm@12.18.0:
|
||||
resolution: {integrity: sha512-nXiC1dyCFH7PxOBiqjSDTgrQKWcQoYN6ERWuASEn02txCeMhrBWYod0KZVl2gbHpmRfhLtDXSerpEYeUM2O+sw==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
'@pnpm/exe.android-arm64@12.21.0':
|
||||
'@pnpm/exe.android-arm64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.android-x64@12.21.0':
|
||||
'@pnpm/exe.android-x64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.darwin-arm64@12.21.0':
|
||||
'@pnpm/exe.darwin-arm64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.darwin-x64@12.21.0':
|
||||
'@pnpm/exe.darwin-x64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.freebsd-x64@12.21.0':
|
||||
'@pnpm/exe.freebsd-x64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-arm64-musl@12.21.0':
|
||||
'@pnpm/exe.linux-arm64-musl@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-arm64@12.21.0':
|
||||
'@pnpm/exe.linux-arm64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-ppc64@12.21.0':
|
||||
'@pnpm/exe.linux-ppc64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-riscv64@12.21.0':
|
||||
'@pnpm/exe.linux-riscv64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-s390x@12.21.0':
|
||||
'@pnpm/exe.linux-s390x@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-x64-musl@12.21.0':
|
||||
'@pnpm/exe.linux-x64-musl@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-x64@12.21.0':
|
||||
'@pnpm/exe.linux-x64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.netbsd-x64@12.21.0':
|
||||
'@pnpm/exe.win32-arm64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.win32-arm64@12.21.0':
|
||||
'@pnpm/exe.win32-x64@12.18.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.win32-x64@12.21.0':
|
||||
optional: true
|
||||
|
||||
pnpm@12.21.0:
|
||||
pnpm@12.18.0:
|
||||
optionalDependencies:
|
||||
'@pnpm/exe.android-arm64': 12.21.0
|
||||
'@pnpm/exe.android-x64': 12.21.0
|
||||
'@pnpm/exe.darwin-arm64': 12.21.0
|
||||
'@pnpm/exe.darwin-x64': 12.21.0
|
||||
'@pnpm/exe.freebsd-x64': 12.21.0
|
||||
'@pnpm/exe.linux-arm64': 12.21.0
|
||||
'@pnpm/exe.linux-arm64-musl': 12.21.0
|
||||
'@pnpm/exe.linux-ppc64': 12.21.0
|
||||
'@pnpm/exe.linux-riscv64': 12.21.0
|
||||
'@pnpm/exe.linux-s390x': 12.21.0
|
||||
'@pnpm/exe.linux-x64': 12.21.0
|
||||
'@pnpm/exe.linux-x64-musl': 12.21.0
|
||||
'@pnpm/exe.netbsd-x64': 12.21.0
|
||||
'@pnpm/exe.win32-arm64': 12.21.0
|
||||
'@pnpm/exe.win32-x64': 12.21.0
|
||||
'@pnpm/exe.android-arm64': 12.18.0
|
||||
'@pnpm/exe.android-x64': 12.18.0
|
||||
'@pnpm/exe.darwin-arm64': 12.18.0
|
||||
'@pnpm/exe.darwin-x64': 12.18.0
|
||||
'@pnpm/exe.freebsd-x64': 12.18.0
|
||||
'@pnpm/exe.linux-arm64': 12.18.0
|
||||
'@pnpm/exe.linux-arm64-musl': 12.18.0
|
||||
'@pnpm/exe.linux-ppc64': 12.18.0
|
||||
'@pnpm/exe.linux-riscv64': 12.18.0
|
||||
'@pnpm/exe.linux-s390x': 12.18.0
|
||||
'@pnpm/exe.linux-x64': 12.18.0
|
||||
'@pnpm/exe.linux-x64-musl': 12.18.0
|
||||
'@pnpm/exe.win32-arm64': 12.18.0
|
||||
'@pnpm/exe.win32-x64': 12.18.0
|
||||
|
||||
---
|
||||
lockfileVersion: '9.0'
|
||||
@@ -284,8 +275,8 @@ importers:
|
||||
specifier: ^7.88.0
|
||||
version: 7.88.0(react@19.3.1)
|
||||
react-i18next:
|
||||
specifier: 18.0.1
|
||||
version: 18.0.1(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3)
|
||||
specifier: 18.0.2
|
||||
version: 18.0.2(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3)
|
||||
react-markdown:
|
||||
specifier: 10.1.0
|
||||
version: 10.1.0(@types/react@19.3.0)(react@19.3.1)(supports-color@7.2.0)
|
||||
@@ -3792,8 +3783,8 @@ packages:
|
||||
peerDependencies:
|
||||
react: ^16.8.0 || ^17 || ^18 || ^19
|
||||
|
||||
react-i18next@18.0.1:
|
||||
resolution: {integrity: sha512-kPWXI0E/lrPj3+/umcKNzYZVnWmEedLiamMzDIHfbs+5ANf6yzvlZsjKou8f7kaGkfMMDLIZBejV+4aSN1CyBw==}
|
||||
react-i18next@18.0.2:
|
||||
resolution: {integrity: sha512-g7YfBxTDC9dYdEsb3F7o0pRr6jg14f08U5G6N3DTUqSgGt/nq7AYf279ESRjE3Dy+Q/YG7OGVd7vtiylxTfV4w==}
|
||||
engines: {node: '>=22'}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
@@ -7883,7 +7874,7 @@ snapshots:
|
||||
dependencies:
|
||||
react: 19.3.1
|
||||
|
||||
react-i18next@18.0.1(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3):
|
||||
react-i18next@18.0.2(@types/react@19.3.0)(i18next@27.0.1(typescript@6.0.3))(react@19.3.1)(typescript@6.0.3):
|
||||
dependencies:
|
||||
html-parse-stringify: 4.0.1
|
||||
i18next: 27.0.1(typescript@6.0.3)
|
||||
|
||||
@@ -91,7 +91,7 @@ backon = { version = "1.6.0", features = ["tokio-sleep"] }
|
||||
tauri-plugin-http = "2.9.0"
|
||||
tracing = { workspace = true }
|
||||
tauri-plugin-devtools = { version = "2.2.3", optional = true }
|
||||
tauri-plugin-mihomo = { git = "https://github.com/clash-verge-rev/tauri-plugin-mihomo", rev = "7e4fa8642cf6c394ed88b5a969420d8eab60087f" }
|
||||
tauri-plugin-mihomo = { git = "https://github.com/clash-verge-rev/tauri-plugin-mihomo", rev = "e49bbedcc67d60da2c10e81bc6433b0f8e8fa232" }
|
||||
async-trait = "0.1.92"
|
||||
clash_verge_service_ipc = { git = "https://github.com/clash-verge-rev/clash-verge-service-ipc.git", tag = "v2.8.1", version = "2.8.1", features = [
|
||||
"client",
|
||||
|
||||
@@ -27,12 +27,6 @@ pub async fn switch_proxy_node(group_name: String, proxy_name: String, unfix: bo
|
||||
.stringify_err()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn follow_proxy_group(group_name: String) {
|
||||
crate::feat::follow_proxy_group(&group_name).await;
|
||||
}
|
||||
|
||||
fn runtime_group_order(config: Option<&Mapping>) -> Vec<String> {
|
||||
let mut seen = HashSet::new();
|
||||
|
||||
|
||||
@@ -34,9 +34,6 @@ pub(crate) struct Config {
|
||||
|
||||
static CONFIG_WRITE_LOCK: Mutex<()> = Mutex::const_new(());
|
||||
|
||||
static RUNTIME_YAML_CACHE: parking_lot::Mutex<Option<(u64, std::sync::Arc<std::string::String>)>> =
|
||||
parking_lot::Mutex::new(None);
|
||||
|
||||
impl Config {
|
||||
async fn global() -> &'static Self {
|
||||
static CONFIG: OnceCell<Config> = OnceCell::const_new();
|
||||
@@ -208,7 +205,7 @@ impl Config {
|
||||
Self::write_runtime_file(&yaml).await
|
||||
}
|
||||
|
||||
pub(crate) async fn runtime_config_yaml() -> Result<std::sync::Arc<std::string::String>> {
|
||||
pub(crate) async fn runtime_config_yaml() -> Result<std::string::String> {
|
||||
let runtime = Self::runtime().await;
|
||||
AsyncHandler::spawn_blocking(move || {
|
||||
let runtime_lastest = runtime.latest_arc();
|
||||
@@ -218,16 +215,7 @@ impl Config {
|
||||
.as_ref()
|
||||
.or_else(|| runtime_data.config.as_ref())
|
||||
.ok_or_else(|| anyhow!("failed to generate runtime config, might need to restart application"))?;
|
||||
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
||||
std::hash::Hash::hash(config, &mut hasher);
|
||||
let key = std::hash::Hasher::finish(&hasher);
|
||||
if let Some((cached_key, cached)) = RUNTIME_YAML_CACHE.lock().as_ref()
|
||||
&& *cached_key == key
|
||||
{
|
||||
return Ok(std::sync::Arc::clone(cached));
|
||||
}
|
||||
let yaml_str = std::sync::Arc::new(serde_yaml_ng::to_string(config)?);
|
||||
*RUNTIME_YAML_CACHE.lock() = Some((key, std::sync::Arc::clone(&yaml_str)));
|
||||
let yaml_str = serde_yaml_ng::to_string(config)?;
|
||||
Ok(yaml_str)
|
||||
})
|
||||
.await
|
||||
|
||||
@@ -109,8 +109,6 @@ pub struct IVerge {
|
||||
|
||||
pub auto_close_connection: Option<bool>,
|
||||
|
||||
pub auto_switch_selector_group: Option<bool>,
|
||||
|
||||
pub auto_check_update: Option<bool>,
|
||||
pub default_latency_test: Option<String>,
|
||||
|
||||
@@ -370,7 +368,6 @@ impl IVerge {
|
||||
use_default_bypass: Some(true),
|
||||
proxy_guard_duration: Some(30),
|
||||
auto_close_connection: Some(true),
|
||||
auto_switch_selector_group: Some(true),
|
||||
auto_check_update: Some(true),
|
||||
enable_builtin_enhanced: Some(true),
|
||||
auto_log_clean: Some(2), // 1: 1天, 2: 7天, 3: 30天, 4: 90天
|
||||
@@ -459,7 +456,6 @@ impl IVerge {
|
||||
patch_opt_field!(self, patch, enable_global_hotkey);
|
||||
|
||||
patch_opt_field!(self, patch, auto_close_connection);
|
||||
patch_opt_field!(self, patch, auto_switch_selector_group);
|
||||
patch_opt_field!(self, patch, auto_check_update);
|
||||
patch_opt_field!(self, patch, default_latency_test);
|
||||
patch_opt_field!(self, patch, default_latency_timeout);
|
||||
|
||||
@@ -3,22 +3,17 @@ use crate::{
|
||||
config::PrfItem,
|
||||
utils::{dirs, help},
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use serde_yaml_ng::Mapping;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, LazyLock};
|
||||
use std::time::SystemTime;
|
||||
use tokio::fs;
|
||||
use tristr::alias::String;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ChainItem {
|
||||
pub uid: String,
|
||||
pub data: ChainType,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ChainType {
|
||||
Merge(Mapping),
|
||||
Script(String),
|
||||
@@ -27,39 +22,26 @@ pub enum ChainType {
|
||||
Groups(SeqMap),
|
||||
}
|
||||
|
||||
struct CachedChain {
|
||||
mtime: SystemTime,
|
||||
len: u64,
|
||||
item: Arc<ChainItem>,
|
||||
}
|
||||
|
||||
static CHAIN_CACHE: LazyLock<Mutex<HashMap<PathBuf, CachedChain>>> = LazyLock::new(|| Mutex::new(HashMap::new()));
|
||||
|
||||
// Helper trait to allow async conversion
|
||||
pub trait AsyncChainItemFrom {
|
||||
async fn from_async(item: &PrfItem) -> Option<Arc<ChainItem>>;
|
||||
async fn from_async(item: &PrfItem) -> Option<ChainItem>;
|
||||
}
|
||||
|
||||
impl AsyncChainItemFrom for Option<Arc<ChainItem>> {
|
||||
impl AsyncChainItemFrom for Option<ChainItem> {
|
||||
async fn from_async(item: &PrfItem) -> Self {
|
||||
let itype = item.itype.as_ref()?.as_str();
|
||||
let file = item.file.clone()?;
|
||||
let uid = item.uid.clone().unwrap_or_else(|| "".into());
|
||||
let path = dirs::app_profiles_dir().ok()?.join(file.as_str());
|
||||
|
||||
let meta = fs::metadata(&path).await.ok()?;
|
||||
let (mtime, len) = (meta.modified().ok()?, meta.len());
|
||||
if let Some(cached) = CHAIN_CACHE.lock().get(&path)
|
||||
&& cached.mtime == mtime
|
||||
&& cached.len == len
|
||||
{
|
||||
return Some(Arc::clone(&cached.item));
|
||||
if !path.exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let loaded = Arc::new(match itype {
|
||||
match itype {
|
||||
"script" => Some(ChainItem {
|
||||
uid,
|
||||
data: ChainType::Script(fs::read_to_string(&path).await.ok()?.as_str().into()),
|
||||
data: ChainType::Script(fs::read_to_string(path).await.ok()?.into()),
|
||||
}),
|
||||
"merge" => Some(ChainItem {
|
||||
uid,
|
||||
@@ -75,16 +57,6 @@ impl AsyncChainItemFrom for Option<Arc<ChainItem>> {
|
||||
Some(ChainItem { uid, data })
|
||||
}
|
||||
_ => None,
|
||||
}?);
|
||||
|
||||
CHAIN_CACHE.lock().insert(
|
||||
path,
|
||||
CachedChain {
|
||||
mtime,
|
||||
len,
|
||||
item: Arc::clone(&loaded),
|
||||
},
|
||||
);
|
||||
Some(loaded)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ use parking_lot::Mutex;
|
||||
use serde_yaml_ng::{Mapping, Value};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::hash::{Hash as _, Hasher as _};
|
||||
use std::sync::Arc;
|
||||
use tokio::fs;
|
||||
use tristr::alias::String;
|
||||
|
||||
@@ -52,13 +51,13 @@ struct ConfigValues {
|
||||
#[derive(Debug)]
|
||||
struct ProfileItems {
|
||||
config: Mapping,
|
||||
merge_item: Arc<ChainItem>,
|
||||
script_item: Arc<ChainItem>,
|
||||
rules_item: Arc<ChainItem>,
|
||||
proxies_item: Arc<ChainItem>,
|
||||
groups_item: Arc<ChainItem>,
|
||||
global_merge: Arc<ChainItem>,
|
||||
global_script: Arc<ChainItem>,
|
||||
merge_item: ChainItem,
|
||||
script_item: ChainItem,
|
||||
rules_item: ChainItem,
|
||||
proxies_item: ChainItem,
|
||||
groups_item: ChainItem,
|
||||
global_merge: ChainItem,
|
||||
global_script: ChainItem,
|
||||
profile_name: String,
|
||||
}
|
||||
|
||||
@@ -67,46 +66,41 @@ impl Default for ProfileItems {
|
||||
Self {
|
||||
config: Default::default(),
|
||||
profile_name: Default::default(),
|
||||
merge_item: Arc::new(ChainItem {
|
||||
merge_item: ChainItem {
|
||||
uid: "".into(),
|
||||
data: ChainType::Merge(Mapping::new()),
|
||||
}),
|
||||
script_item: Arc::new(ChainItem {
|
||||
},
|
||||
script_item: ChainItem {
|
||||
uid: "".into(),
|
||||
data: ChainType::Script(tmpl::ITEM_SCRIPT.into()),
|
||||
}),
|
||||
rules_item: Arc::new(ChainItem {
|
||||
},
|
||||
rules_item: ChainItem {
|
||||
uid: "".into(),
|
||||
data: ChainType::Rules(SeqMap::default()),
|
||||
}),
|
||||
proxies_item: Arc::new(ChainItem {
|
||||
},
|
||||
proxies_item: ChainItem {
|
||||
uid: "".into(),
|
||||
data: ChainType::Proxies(SeqMap::default()),
|
||||
}),
|
||||
groups_item: Arc::new(ChainItem {
|
||||
},
|
||||
groups_item: ChainItem {
|
||||
uid: "".into(),
|
||||
data: ChainType::Groups(SeqMap::default()),
|
||||
}),
|
||||
global_merge: Arc::new(ChainItem {
|
||||
},
|
||||
global_merge: ChainItem {
|
||||
uid: "Merge".into(),
|
||||
data: ChainType::Merge(Mapping::new()),
|
||||
}),
|
||||
global_script: Arc::new(ChainItem {
|
||||
},
|
||||
global_script: ChainItem {
|
||||
uid: "Script".into(),
|
||||
data: ChainType::Script(tmpl::ITEM_SCRIPT.into()),
|
||||
}),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn chain_item_or_default(
|
||||
item: Option<&PrfItem>,
|
||||
default_item: impl FnOnce() -> Arc<ChainItem>,
|
||||
) -> Arc<ChainItem> {
|
||||
async fn chain_item_or_default(item: Option<&PrfItem>, default_item: impl FnOnce() -> ChainItem) -> ChainItem {
|
||||
if let Some(item) = item {
|
||||
<Option<Arc<ChainItem>>>::from_async(item)
|
||||
.await
|
||||
.unwrap_or_else(default_item)
|
||||
<Option<ChainItem>>::from_async(item).await.unwrap_or_else(default_item)
|
||||
} else {
|
||||
default_item()
|
||||
}
|
||||
@@ -241,28 +235,28 @@ async fn process_override_items(
|
||||
mut config: Mapping,
|
||||
mut exists_keys: Vec<String>,
|
||||
mut result_map: HashMap<String, ResultLog>,
|
||||
merge_item: Arc<ChainItem>,
|
||||
script_item: Arc<ChainItem>,
|
||||
merge_item: ChainItem,
|
||||
script_item: ChainItem,
|
||||
profile_name: &str,
|
||||
authoritative: &AuthoritativeFields,
|
||||
) -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
||||
if let ChainType::Merge(merge) = &merge_item.data {
|
||||
exists_keys.extend(use_keys(merge));
|
||||
if let ChainType::Merge(merge) = merge_item.data {
|
||||
exists_keys.extend(use_keys(&merge));
|
||||
let before = authoritative.current(&config);
|
||||
config = use_merge(merge.clone(), config);
|
||||
config = use_merge(merge, config);
|
||||
let notes: ResultLog = authoritative
|
||||
.overridden(&before, &authoritative.current(&config))
|
||||
.into_iter()
|
||||
.map(discarded_note)
|
||||
.collect();
|
||||
if !notes.is_empty() {
|
||||
result_map.entry(merge_item.uid.clone()).or_default().extend(notes);
|
||||
result_map.entry(merge_item.uid).or_default().extend(notes);
|
||||
}
|
||||
}
|
||||
|
||||
if let ChainType::Script(script) = &script_item.data {
|
||||
if let ChainType::Script(script) = script_item.data {
|
||||
let before = authoritative.current(&config);
|
||||
let (res_config, changed_keys, mut logs) = use_script(script.clone(), config, profile_name.into()).await;
|
||||
let (res_config, changed_keys, mut logs) = use_script(script, config, profile_name.into()).await;
|
||||
exists_keys.extend(changed_keys);
|
||||
config = res_config;
|
||||
logs.extend(
|
||||
@@ -271,7 +265,7 @@ async fn process_override_items(
|
||||
.into_iter()
|
||||
.map(discarded_note),
|
||||
);
|
||||
result_map.insert(script_item.uid.clone(), logs);
|
||||
result_map.insert(script_item.uid, logs);
|
||||
}
|
||||
|
||||
(config, exists_keys, result_map)
|
||||
@@ -279,20 +273,20 @@ async fn process_override_items(
|
||||
|
||||
fn process_seq_items(
|
||||
mut config: Mapping,
|
||||
rules_item: Arc<ChainItem>,
|
||||
proxies_item: Arc<ChainItem>,
|
||||
groups_item: Arc<ChainItem>,
|
||||
rules_item: ChainItem,
|
||||
proxies_item: ChainItem,
|
||||
groups_item: ChainItem,
|
||||
) -> Mapping {
|
||||
if let ChainType::Rules(rules) = &rules_item.data {
|
||||
config = use_seq(rules.clone(), config, "rules");
|
||||
if let ChainType::Rules(rules) = rules_item.data {
|
||||
config = use_seq(rules, config, "rules");
|
||||
}
|
||||
|
||||
if let ChainType::Proxies(proxies) = &proxies_item.data {
|
||||
config = use_seq(proxies.clone(), config, "proxies");
|
||||
if let ChainType::Proxies(proxies) = proxies_item.data {
|
||||
config = use_seq(proxies, config, "proxies");
|
||||
}
|
||||
|
||||
if let ChainType::Groups(groups) = &groups_item.data {
|
||||
config = use_seq(groups.clone(), config, "proxy-groups");
|
||||
if let ChainType::Groups(groups) = groups_item.data {
|
||||
config = use_seq(groups, config, "proxy-groups");
|
||||
}
|
||||
|
||||
config
|
||||
@@ -1403,7 +1397,6 @@ mod tests {
|
||||
process_override_items, use_keys,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn mapping(yaml: &str) -> serde_yaml_ng::Mapping {
|
||||
serde_yaml_ng::from_str(yaml).expect("test config should be valid")
|
||||
@@ -1444,11 +1437,9 @@ mod tests {
|
||||
(profile.clone(), Mapping::new())
|
||||
};
|
||||
let authoritative = AuthoritativeFields::capture(&config, &[], dns_settings);
|
||||
let merge_item = |uid: &str| {
|
||||
Arc::new(ChainItem {
|
||||
uid: uid.into(),
|
||||
data: ChainType::Merge(merge.clone()),
|
||||
})
|
||||
let merge_item = |uid: &str| ChainItem {
|
||||
uid: uid.into(),
|
||||
data: ChainType::Merge(merge.clone()),
|
||||
};
|
||||
let profile_name = "test-profile";
|
||||
let (config, keys, logs) = process_override_items(
|
||||
@@ -1456,10 +1447,10 @@ mod tests {
|
||||
vec![],
|
||||
HashMap::new(),
|
||||
merge_item("global-merge"),
|
||||
Arc::new(ChainItem {
|
||||
ChainItem {
|
||||
uid: "global-script".into(),
|
||||
data: ChainType::Script(script.into()),
|
||||
}),
|
||||
},
|
||||
profile_name,
|
||||
&authoritative,
|
||||
)
|
||||
@@ -1469,10 +1460,10 @@ mod tests {
|
||||
keys,
|
||||
logs,
|
||||
merge_item("profile-merge"),
|
||||
Arc::new(ChainItem {
|
||||
ChainItem {
|
||||
uid: "profile-script".into(),
|
||||
data: ChainType::Script(script.into()),
|
||||
}),
|
||||
},
|
||||
profile_name,
|
||||
&authoritative,
|
||||
)
|
||||
@@ -1509,15 +1500,15 @@ mod tests {
|
||||
let exists_keys = use_keys(&config).collect();
|
||||
config.insert("application-only".into(), true.into());
|
||||
|
||||
let global_merge = Arc::new(ChainItem {
|
||||
let global_merge = ChainItem {
|
||||
uid: "Merge".into(),
|
||||
data: ChainType::Merge(mapping(
|
||||
r"{global-merge-wins: global-merge, global-script-wins: global-merge,
|
||||
profile-merge-wins: global-merge, profile-script-wins: global-merge,
|
||||
nested: {winner: global-merge}, dns: {enable: false}, tun: {enable: false}}",
|
||||
)),
|
||||
});
|
||||
let global_script = Arc::new(ChainItem {
|
||||
};
|
||||
let global_script = ChainItem {
|
||||
uid: "Script".into(),
|
||||
data: ChainType::Script(
|
||||
r#"function main(config) {
|
||||
@@ -1529,15 +1520,15 @@ mod tests {
|
||||
}"#
|
||||
.into(),
|
||||
),
|
||||
});
|
||||
let profile_merge = Arc::new(ChainItem {
|
||||
};
|
||||
let profile_merge = ChainItem {
|
||||
uid: "profile-merge".into(),
|
||||
data: ChainType::Merge(mapping(
|
||||
r"{profile-merge-wins: profile-merge, profile-script-wins: profile-merge,
|
||||
nested: {winner: profile-merge}}",
|
||||
)),
|
||||
});
|
||||
let profile_script = Arc::new(ChainItem {
|
||||
};
|
||||
let profile_script = ChainItem {
|
||||
uid: "profile-script".into(),
|
||||
data: ChainType::Script(
|
||||
r#"function main(config) {
|
||||
@@ -1547,7 +1538,7 @@ mod tests {
|
||||
}"#
|
||||
.into(),
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
let profile_name = "test-profile";
|
||||
let authoritative = AuthoritativeFields::capture(&config, &[], Mapping::new());
|
||||
|
||||
@@ -90,7 +90,6 @@ verge_registry! {
|
||||
enable_global_hotkey => NoEffect;
|
||||
home_cards => NoEffect;
|
||||
auto_close_connection => NoEffect;
|
||||
auto_switch_selector_group => NoEffect;
|
||||
auto_check_update => NoEffect;
|
||||
default_latency_test => NoEffect;
|
||||
default_latency_timeout => NoEffect;
|
||||
|
||||
@@ -9,7 +9,6 @@ use crate::{
|
||||
};
|
||||
use anyhow::{Result, bail};
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use tauri_plugin_mihomo::models::ProxyType;
|
||||
use tristr::alias::String;
|
||||
|
||||
/// Toggle proxy profile
|
||||
@@ -23,80 +22,9 @@ pub async fn toggle_proxy_profile(profile_index: String) {
|
||||
}
|
||||
}
|
||||
|
||||
/// First `select` group in config order that lists `group_name`, when that group is `url-test` or `fallback`.
|
||||
fn parent_selector<'a>(groups: &'a [serde_yaml_ng::Value], group_name: &str) -> Option<&'a str> {
|
||||
let field = |group: &'a serde_yaml_ng::Value, key: &str| group.get(key)?.as_str();
|
||||
let group = groups.iter().find(|group| field(group, "name") == Some(group_name))?;
|
||||
if !matches!(field(group, "type"), Some("url-test" | "fallback")) {
|
||||
return None;
|
||||
}
|
||||
groups
|
||||
.iter()
|
||||
.filter(|group| field(group, "type") == Some("select"))
|
||||
.filter(|group| {
|
||||
group
|
||||
.get("proxies")
|
||||
.and_then(|members| members.as_sequence())
|
||||
.is_some_and(|members| members.iter().any(|member| member.as_str() == Some(group_name)))
|
||||
})
|
||||
.filter_map(|group| field(group, "name"))
|
||||
.find(|name| *name != "GLOBAL")
|
||||
}
|
||||
|
||||
/// Rule traffic enters through `select` groups, so a pick inside a `url-test`/`fallback` group only
|
||||
/// carries traffic once the first `select` group listing that group points at it.
|
||||
/// Returns the node that group left.
|
||||
async fn follow_group_selection(group_name: &str) -> Option<std::string::String> {
|
||||
if !Config::verge()
|
||||
.await
|
||||
.data_arc()
|
||||
.auto_switch_selector_group
|
||||
.unwrap_or(true)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
if Config::clash()
|
||||
.await
|
||||
.data_arc()
|
||||
.get_mode()
|
||||
.is_some_and(|mode| mode != "rule")
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let selector = {
|
||||
let runtime = Config::runtime().await.latest_arc();
|
||||
let groups = runtime.config.as_ref()?.get("proxy-groups")?.as_sequence()?;
|
||||
parent_selector(groups, group_name)?.to_owned()
|
||||
};
|
||||
|
||||
let mihomo = handle::Handle::mihomo();
|
||||
let current = mihomo.get_proxy_by_name(&selector).await.ok()?;
|
||||
// The runtime config can lag the core, which alone knows what this group is now.
|
||||
if current.proxy_type != ProxyType::Selector {
|
||||
return None;
|
||||
}
|
||||
let previous = current.now?;
|
||||
if previous == group_name {
|
||||
return None;
|
||||
}
|
||||
if let Err(err) = mihomo.select_node_for_group(&selector, group_name).await {
|
||||
logging!(warn, Type::Core, "Failed to point {selector} at {group_name}: {err:#}");
|
||||
return None;
|
||||
}
|
||||
if let Err(error) = crate::config::profiles::record_selected_node(&selector, group_name).await {
|
||||
logging!(
|
||||
warn,
|
||||
Type::Config,
|
||||
"Failed to persist proxy selection for {selector}: {error:#}"
|
||||
);
|
||||
}
|
||||
Some(previous)
|
||||
}
|
||||
|
||||
pub async fn switch_proxy_node(group_name: &str, proxy_name: &str, unfix: bool) -> Result<()> {
|
||||
let mihomo = handle::Handle::mihomo();
|
||||
let auto_close = Config::verge().await.data_arc().auto_close_connection.unwrap_or(false);
|
||||
let previous_proxy = if auto_close {
|
||||
let previous_proxy = if Config::verge().await.data_arc().auto_close_connection.unwrap_or(false) {
|
||||
match mihomo.get_proxy_by_name(group_name).await {
|
||||
Ok(group) => group.now.filter(|name| !name.is_empty()),
|
||||
Err(err) => {
|
||||
@@ -130,31 +58,9 @@ pub async fn switch_proxy_node(group_name: &str, proxy_name: &str, unfix: bool)
|
||||
"Failed to persist proxy selection for {group_name}: {error:#}"
|
||||
);
|
||||
}
|
||||
let mut stale_proxies: Vec<_> = previous_proxy.into_iter().collect();
|
||||
if !unfix
|
||||
&& let Some(left) = follow_group_selection(group_name).await
|
||||
&& auto_close
|
||||
{
|
||||
stale_proxies.push(left);
|
||||
}
|
||||
finish_proxy_switch(stale_proxies).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Lets a `url-test`/`fallback` group carry rule traffic without fixing a node in it.
|
||||
pub async fn follow_proxy_group(group_name: &str) {
|
||||
let Some(left) = follow_group_selection(group_name).await else {
|
||||
return;
|
||||
};
|
||||
let auto_close = Config::verge().await.data_arc().auto_close_connection.unwrap_or(false);
|
||||
finish_proxy_switch(auto_close.then_some(left).into_iter().collect()).await;
|
||||
}
|
||||
|
||||
async fn finish_proxy_switch(stale_proxies: Vec<std::string::String>) {
|
||||
let mihomo = handle::Handle::mihomo();
|
||||
announce(Refresh::Proxies);
|
||||
|
||||
if !stale_proxies.is_empty() {
|
||||
if let Some(previous_proxy) = previous_proxy {
|
||||
AsyncHandler::spawn(move || async move {
|
||||
let connections = match mihomo.get_connections().await {
|
||||
Ok(connections) => connections,
|
||||
@@ -172,7 +78,7 @@ async fn finish_proxy_switch(stale_proxies: Vec<std::string::String>) {
|
||||
.connections
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.filter(|connection| stale_proxies.iter().any(|proxy| connection.chains.contains(proxy)))
|
||||
.filter(|connection| connection.chains.contains(&previous_proxy))
|
||||
.map(|connection| async move {
|
||||
if let Err(err) = mihomo.close_connection(&connection.id).await {
|
||||
logging!(
|
||||
@@ -194,6 +100,7 @@ async fn finish_proxy_switch(stale_proxies: Vec<std::string::String>) {
|
||||
"Failed to refresh tray after switching proxy: {err:#}"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn should_update_profile(uid: &str, ignore_auto_update: bool) -> Result<Option<(String, Option<PrfOption>)>> {
|
||||
@@ -373,24 +280,3 @@ pub async fn update_profile(uid: &str, option: Option<&PrfOption>, is_mannual_tr
|
||||
pub async fn enhance_profiles() -> Result<ValidationOutcome> {
|
||||
CoreManager::global().update_config_forced().await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn only_the_first_select_group_follows_an_auto_group() -> Result<()> {
|
||||
let groups: Vec<serde_yaml_ng::Value> = serde_yaml_ng::from_str(
|
||||
"
|
||||
- { name: GLOBAL, type: select, proxies: [Auto, Proxy, Direct] }
|
||||
- { name: Auto, type: url-test, proxies: [Node] }
|
||||
- { name: Proxy, type: select, proxies: [Auto, Node] }
|
||||
- { name: Direct, type: select, proxies: [DIRECT, Auto] }
|
||||
",
|
||||
)?;
|
||||
|
||||
assert_eq!(parent_selector(&groups, "Auto"), Some("Proxy"));
|
||||
assert_eq!(parent_selector(&groups, "Proxy"), None);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ pub fn builder() -> tauri_specta::Builder<tauri::Wry> {
|
||||
cmd::copy_clash_env,
|
||||
cmd::record_selected_node,
|
||||
cmd::switch_proxy_node,
|
||||
cmd::follow_proxy_group,
|
||||
cmd::save_dns_config,
|
||||
cmd::apply_dns_config,
|
||||
cmd::set_dns_override,
|
||||
|
||||
@@ -53,15 +53,6 @@ const StyledTextField = styled(TextField)(({ theme }) => ({
|
||||
},
|
||||
}))
|
||||
|
||||
const iconStyle = {
|
||||
style: {
|
||||
height: '24px',
|
||||
width: '24px',
|
||||
cursor: 'pointer',
|
||||
} as React.CSSProperties,
|
||||
inheritViewBox: true,
|
||||
}
|
||||
|
||||
const useControllableState = <T,>(options: {
|
||||
controlled: T | undefined
|
||||
defaultValue: T
|
||||
@@ -128,6 +119,15 @@ export const BaseSearchBox = ({
|
||||
defaultValue: defaultUseRegularExpression,
|
||||
})
|
||||
|
||||
const iconStyle = {
|
||||
style: {
|
||||
height: '24px',
|
||||
width: '24px',
|
||||
cursor: 'pointer',
|
||||
} as React.CSSProperties,
|
||||
inheritViewBox: true,
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
onSearchRef.current = onSearch
|
||||
}, [onSearch])
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import { styled } from '@mui/material/styles'
|
||||
import { default as MuiSwitch, SwitchProps } from '@mui/material/Switch'
|
||||
|
||||
/**
|
||||
* MUI Switch delivers the boolean as the second onChange argument, so
|
||||
* switch handlers use this adapter to stay boolean-only.
|
||||
*/
|
||||
export const switchChangeValue = (_event: unknown, value: boolean): boolean =>
|
||||
value
|
||||
|
||||
export const Switch = styled((props: SwitchProps) => (
|
||||
<MuiSwitch
|
||||
focusVisibleClassName=".Mui-focusVisible"
|
||||
|
||||
@@ -10,7 +10,7 @@ export { BaseSplitChipEditor } from './base-split-chip-editor'
|
||||
export { BaseStyledSelect } from './base-styled-select'
|
||||
export { BaseStyledTextField } from './base-styled-text-field'
|
||||
export { MonacoEditor } from './monaco-editor'
|
||||
export { Switch, switchChangeValue } from './base-switch'
|
||||
export { Switch } from './base-switch'
|
||||
export { TooltipIcon } from './base-tooltip-icon'
|
||||
export { VirtualList, type VirtualListHandle } from './virtual-list'
|
||||
export {
|
||||
|
||||
@@ -55,7 +55,6 @@ import {
|
||||
useCoreDataStatus,
|
||||
useProxiesData,
|
||||
} from '@/providers/app-data-context'
|
||||
import { followProxyGroup } from '@/services/cmds'
|
||||
import delayManager from '@/services/delay'
|
||||
import {
|
||||
findCurrentGroupMember,
|
||||
@@ -666,7 +665,7 @@ export const CurrentProxyCard = () => {
|
||||
return proxyView.groups.filter(
|
||||
(group) =>
|
||||
!group.hidden &&
|
||||
['Selector', 'URLTest', 'Fallback'].includes(group.type),
|
||||
(group.type === 'Selector' || group.type === 'URLTest'),
|
||||
)
|
||||
}, [proxyView])
|
||||
|
||||
@@ -766,7 +765,6 @@ export const CurrentProxyCard = () => {
|
||||
if (isGlobalMode || isDirectMode) return
|
||||
setLastGroupName(newGroupName)
|
||||
writeProfileScopedItem(STORAGE_KEY_GROUP, newGroupName)
|
||||
void followProxyGroup(newGroupName)
|
||||
},
|
||||
[isDirectMode, isGlobalMode, writeProfileScopedItem],
|
||||
)
|
||||
|
||||
@@ -23,8 +23,6 @@ import { emitTestAll } from '@/services/bus'
|
||||
|
||||
import { EnhancedCard } from './enhanced-card'
|
||||
|
||||
const TEST_LIST_SENSORS = [PointerSensor]
|
||||
|
||||
// 自定义滚动条样式
|
||||
const ScrollBox = styled(Box)(({ theme }) => ({
|
||||
maxHeight: '180px',
|
||||
@@ -207,7 +205,7 @@ export const TestCard = () => {
|
||||
}
|
||||
>
|
||||
<ScrollBox>
|
||||
<DragDropProvider sensors={TEST_LIST_SENSORS} onDragEnd={onDragEnd}>
|
||||
<DragDropProvider sensors={[PointerSensor]} onDragEnd={onDragEnd}>
|
||||
{renderTestItems}
|
||||
</DragDropProvider>
|
||||
</ScrollBox>
|
||||
|
||||
@@ -5,8 +5,6 @@ import { type PointerEvent, useCallback } from 'react'
|
||||
import { useWindowControls } from '@/hooks/use-window'
|
||||
import getSystem from '@/utils/get-system'
|
||||
|
||||
const OS = getSystem()
|
||||
|
||||
const RESIZE_HANDLES = [
|
||||
{ direction: 'North', position: 'north' },
|
||||
{ direction: 'NorthEast', position: 'north-east' },
|
||||
@@ -40,7 +38,7 @@ export const WindowResizeHandles = () => {
|
||||
[currentWindow],
|
||||
)
|
||||
|
||||
if (OS !== 'linux' || maximized) return null
|
||||
if (getSystem() !== 'linux' || maximized) return null
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -61,6 +59,7 @@ export const WindowResizeHandles = () => {
|
||||
}
|
||||
|
||||
export const WindowControls = () => {
|
||||
const OS = getSystem()
|
||||
const { maximized, minimize, close, toggleMaximize } = useWindowControls()
|
||||
|
||||
// 通过前端对 tauri 窗口进行翻转全屏时会短暂地与系统图标重叠渲染。
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Alert, Box, Typography } from '@mui/material'
|
||||
import { useMemo } from 'react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
|
||||
const stageHints = {
|
||||
@@ -15,31 +14,26 @@ interface Props {
|
||||
|
||||
export const EnhanceHint = ({ stage }: Props) => {
|
||||
const { t } = useTranslation()
|
||||
// The component map identity changes only when the active stage changes.
|
||||
const orderComponents = useMemo(
|
||||
() =>
|
||||
Object.fromEntries(
|
||||
Object.keys(stageHints).map((key) => [
|
||||
key,
|
||||
<Box
|
||||
key={key}
|
||||
component={key === stage ? 'strong' : 'span'}
|
||||
sx={
|
||||
key === stage
|
||||
? {
|
||||
fontWeight: 'bold',
|
||||
color: 'primary.contrastText',
|
||||
bgcolor: 'primary.main',
|
||||
borderRadius: 0.5,
|
||||
px: 0.5,
|
||||
boxDecorationBreak: 'clone',
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>,
|
||||
]),
|
||||
),
|
||||
[stage],
|
||||
const orderComponents = Object.fromEntries(
|
||||
Object.keys(stageHints).map((key) => [
|
||||
key,
|
||||
<Box
|
||||
key={key}
|
||||
component={key === stage ? 'strong' : 'span'}
|
||||
sx={
|
||||
key === stage
|
||||
? {
|
||||
fontWeight: 'bold',
|
||||
color: 'primary.contrastText',
|
||||
bgcolor: 'primary.main',
|
||||
borderRadius: 0.5,
|
||||
px: 0.5,
|
||||
boxDecorationBreak: 'clone',
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>,
|
||||
]),
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -56,8 +56,6 @@ interface GroupedVirtualListProps<T> {
|
||||
style?: CSSProperties
|
||||
}
|
||||
|
||||
const GROUPED_LIST_SENSORS = [PointerSensor, KeyboardSensor]
|
||||
|
||||
/**
|
||||
* 用于编辑规则/节点/代理组功能的 prepend/original/append 分组虚拟化列表
|
||||
*/
|
||||
@@ -143,7 +141,7 @@ export function GroupedVirtualList<T>(props: GroupedVirtualListProps<T>) {
|
||||
|
||||
return (
|
||||
<DragDropProvider
|
||||
sensors={GROUPED_LIST_SENSORS}
|
||||
sensors={[PointerSensor, KeyboardSensor]}
|
||||
onDragStart={onDragStart}
|
||||
onDragOver={onDragOver}
|
||||
onDragEnd={onDragEnd}
|
||||
|
||||
@@ -112,12 +112,9 @@ export const ProfileMore = (props: Props) => {
|
||||
document.markSaved(currentValue)
|
||||
})
|
||||
|
||||
// document gets a fresh identity every render; setValue is the stable
|
||||
// useState setter, so the callback keys on it instead.
|
||||
const { setValue } = document
|
||||
const handleResetToDefault = useCallback(() => {
|
||||
setValue(DEFAULT_SCRIPT)
|
||||
}, [setValue])
|
||||
document.setValue(DEFAULT_SCRIPT)
|
||||
}, [document])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -61,26 +61,21 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
||||
},
|
||||
})
|
||||
|
||||
// The handle only closes over stable form/state setters.
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
create: () => {
|
||||
setOpenType('new')
|
||||
setOpen(true)
|
||||
},
|
||||
edit: (item: IProfileItem) => {
|
||||
if (item) {
|
||||
Object.entries(item).forEach(([key, value]) => {
|
||||
setValue(key as any, value)
|
||||
})
|
||||
}
|
||||
setOpenType('edit')
|
||||
setOpen(true)
|
||||
},
|
||||
}),
|
||||
[setValue],
|
||||
)
|
||||
useImperativeHandle(ref, () => ({
|
||||
create: () => {
|
||||
setOpenType('new')
|
||||
setOpen(true)
|
||||
},
|
||||
edit: (item: IProfileItem) => {
|
||||
if (item) {
|
||||
Object.entries(item).forEach(([key, value]) => {
|
||||
setValue(key as any, value)
|
||||
})
|
||||
}
|
||||
setOpenType('edit')
|
||||
setOpen(true)
|
||||
},
|
||||
}))
|
||||
|
||||
const handleOk = useLockFn(
|
||||
handleSubmit(async (form) => {
|
||||
|
||||
@@ -57,8 +57,6 @@ const chainPointerSensor = PointerSensor.configure({
|
||||
activationConstraints: () => undefined,
|
||||
})
|
||||
|
||||
const CHAIN_SENSORS = [chainPointerSensor, KeyboardSensor]
|
||||
|
||||
type RuntimeConfigWithProxySequence = IConfigData & { proxies?: unknown }
|
||||
|
||||
interface ProxyChainProps {
|
||||
@@ -667,7 +665,10 @@ export const ProxyChain = ({
|
||||
</Button>
|
||||
</Box>
|
||||
) : (
|
||||
<DragDropProvider sensors={CHAIN_SENSORS} onDragEnd={handleDragEnd}>
|
||||
<DragDropProvider
|
||||
sensors={[chainPointerSensor, KeyboardSensor]}
|
||||
onDragEnd={handleDragEnd}
|
||||
>
|
||||
<Box sx={{ borderRadius: 1, minHeight: 60, p: 1 }}>
|
||||
{currentProxyChain.map((proxy, index) => (
|
||||
<SortableProxyChainItem
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from '@mui/material'
|
||||
import { useLockFn } from 'ahooks'
|
||||
import dayjs from 'dayjs'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { updateRuleProvider } from 'tauri-plugin-mihomo-api'
|
||||
|
||||
@@ -42,11 +42,6 @@ export const ProviderButton = () => {
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(false)
|
||||
const { ruleProviders } = useRulesData()
|
||||
|
||||
const sortedProviderEntries = useMemo(
|
||||
() => Object.entries(ruleProviders || {}).sort(),
|
||||
[ruleProviders],
|
||||
)
|
||||
const { refreshRules, refreshRuleProviders } = useAppRefreshers()
|
||||
const [updating, setUpdating] = useState<Record<string, boolean>>({})
|
||||
|
||||
@@ -171,119 +166,121 @@ export const ProviderButton = () => {
|
||||
|
||||
<DialogContent>
|
||||
<List sx={{ py: 0, minHeight: 250 }}>
|
||||
{sortedProviderEntries.map(([key, item]) => {
|
||||
const provider = item
|
||||
const time = dayjs(provider.updatedAt)
|
||||
const isUpdating = updating[key]
|
||||
{Object.entries(ruleProviders || {})
|
||||
.sort()
|
||||
.map(([key, item]) => {
|
||||
const provider = item
|
||||
const time = dayjs(provider.updatedAt)
|
||||
const isUpdating = updating[key]
|
||||
|
||||
return (
|
||||
<ListItem
|
||||
key={key}
|
||||
sx={[
|
||||
{
|
||||
p: 0,
|
||||
mb: '8px',
|
||||
borderRadius: 2,
|
||||
overflow: 'hidden',
|
||||
transition: 'all 0.2s',
|
||||
},
|
||||
({ palette: { mode, primary } }) => {
|
||||
const bgcolor = mode === 'light' ? '#ffffff' : '#24252f'
|
||||
const hoverColor =
|
||||
mode === 'light'
|
||||
? alpha(primary.main, 0.1)
|
||||
: alpha(primary.main, 0.2)
|
||||
return (
|
||||
<ListItem
|
||||
key={key}
|
||||
sx={[
|
||||
{
|
||||
p: 0,
|
||||
mb: '8px',
|
||||
borderRadius: 2,
|
||||
overflow: 'hidden',
|
||||
transition: 'all 0.2s',
|
||||
},
|
||||
({ palette: { mode, primary } }) => {
|
||||
const bgcolor = mode === 'light' ? '#ffffff' : '#24252f'
|
||||
const hoverColor =
|
||||
mode === 'light'
|
||||
? alpha(primary.main, 0.1)
|
||||
: alpha(primary.main, 0.2)
|
||||
|
||||
return {
|
||||
backgroundColor: bgcolor,
|
||||
'&:hover': {
|
||||
backgroundColor: hoverColor,
|
||||
borderColor: alpha(primary.main, 0.3),
|
||||
},
|
||||
}
|
||||
},
|
||||
]}
|
||||
>
|
||||
<ListItemText
|
||||
sx={{ px: 2, py: 1 }}
|
||||
primary={
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
component="div"
|
||||
noWrap
|
||||
title={key}
|
||||
sx={{ display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
<span style={{ marginRight: '8px' }}>{key}</span>
|
||||
<TypeBox component="span">
|
||||
{provider.ruleCount}
|
||||
</TypeBox>
|
||||
</Typography>
|
||||
|
||||
<Typography
|
||||
variant="body2"
|
||||
color="text.secondary"
|
||||
noWrap
|
||||
>
|
||||
<small>{t('shared.labels.updateAt')}: </small>
|
||||
{time.fromNow()}
|
||||
</Typography>
|
||||
</Box>
|
||||
}
|
||||
secondary={
|
||||
<Box sx={{ display: 'flex' }}>
|
||||
<TypeBox component="span">
|
||||
{typeof provider.vehicleType === 'string'
|
||||
? provider.vehicleType
|
||||
: provider.vehicleType.Unknown}
|
||||
</TypeBox>
|
||||
<TypeBox component="span">
|
||||
{typeof provider.behavior === 'string'
|
||||
? provider.behavior
|
||||
: provider.behavior.Unknown}
|
||||
</TypeBox>
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
<Divider orientation="vertical" flexItem />
|
||||
<Box
|
||||
sx={{
|
||||
width: 40,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
return {
|
||||
backgroundColor: bgcolor,
|
||||
'&:hover': {
|
||||
backgroundColor: hoverColor,
|
||||
borderColor: alpha(primary.main, 0.3),
|
||||
},
|
||||
}
|
||||
},
|
||||
]}
|
||||
>
|
||||
<IconButton
|
||||
size="small"
|
||||
color="primary"
|
||||
onClick={() => updateProvider(key)}
|
||||
disabled={isUpdating}
|
||||
aria-label={t('rules.page.provider.actions.update')}
|
||||
<ListItemText
|
||||
sx={{ px: 2, py: 1 }}
|
||||
primary={
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
component="div"
|
||||
noWrap
|
||||
title={key}
|
||||
sx={{ display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
<span style={{ marginRight: '8px' }}>{key}</span>
|
||||
<TypeBox component="span">
|
||||
{provider.ruleCount}
|
||||
</TypeBox>
|
||||
</Typography>
|
||||
|
||||
<Typography
|
||||
variant="body2"
|
||||
color="text.secondary"
|
||||
noWrap
|
||||
>
|
||||
<small>{t('shared.labels.updateAt')}: </small>
|
||||
{time.fromNow()}
|
||||
</Typography>
|
||||
</Box>
|
||||
}
|
||||
secondary={
|
||||
<Box sx={{ display: 'flex' }}>
|
||||
<TypeBox component="span">
|
||||
{typeof provider.vehicleType === 'string'
|
||||
? provider.vehicleType
|
||||
: provider.vehicleType.Unknown}
|
||||
</TypeBox>
|
||||
<TypeBox component="span">
|
||||
{typeof provider.behavior === 'string'
|
||||
? provider.behavior
|
||||
: provider.behavior.Unknown}
|
||||
</TypeBox>
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
<Divider orientation="vertical" flexItem />
|
||||
<Box
|
||||
sx={{
|
||||
animation: isUpdating
|
||||
? 'spin 1s linear infinite'
|
||||
: 'none',
|
||||
'@keyframes spin': {
|
||||
'0%': { transform: 'rotate(0deg)' },
|
||||
'100%': { transform: 'rotate(360deg)' },
|
||||
},
|
||||
width: 40,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
title={t('rules.page.provider.actions.update')}
|
||||
>
|
||||
<RefreshRounded />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</ListItem>
|
||||
)
|
||||
})}
|
||||
<IconButton
|
||||
size="small"
|
||||
color="primary"
|
||||
onClick={() => updateProvider(key)}
|
||||
disabled={isUpdating}
|
||||
aria-label={t('rules.page.provider.actions.update')}
|
||||
sx={{
|
||||
animation: isUpdating
|
||||
? 'spin 1s linear infinite'
|
||||
: 'none',
|
||||
'@keyframes spin': {
|
||||
'0%': { transform: 'rotate(0deg)' },
|
||||
'100%': { transform: 'rotate(360deg)' },
|
||||
},
|
||||
}}
|
||||
title={t('rules.page.provider.actions.update')}
|
||||
>
|
||||
<RefreshRounded />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</ListItem>
|
||||
)
|
||||
})}
|
||||
</List>
|
||||
</DialogContent>
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@ const HOTKEY_FUNC_LABELS: Record<(typeof HOTKEY_FUNC)[number], string> = {
|
||||
reactivate_profiles: 'settings.modals.hotkey.functions.reactivateProfiles',
|
||||
}
|
||||
|
||||
const EMPTY_KEYS: string[] = []
|
||||
|
||||
export const HotkeyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -134,7 +132,7 @@ export const HotkeyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
<ItemWrapper key={func} data-setting-target={HOTKEY_FUNC_LABELS[func]}>
|
||||
<Typography>{t(HOTKEY_FUNC_LABELS[func])}</Typography>
|
||||
<HotkeyInput
|
||||
value={hotkeyMap[func] ?? EMPTY_KEYS}
|
||||
value={hotkeyMap[func] ?? []}
|
||||
onChange={(v) => setHotkeyMap((m) => ({ ...m, [func]: v }))}
|
||||
/>
|
||||
</ItemWrapper>
|
||||
|
||||
@@ -17,13 +17,7 @@ import { exists } from '@tauri-apps/plugin-fs'
|
||||
import { forwardRef, useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import {
|
||||
BaseDialog,
|
||||
DialogRef,
|
||||
Switch,
|
||||
TooltipIcon,
|
||||
switchChangeValue,
|
||||
} from '@/components/base'
|
||||
import { BaseDialog, DialogRef, Switch, TooltipIcon } from '@/components/base'
|
||||
import { DEFAULT_HOVER_DELAY } from '@/components/proxy/proxy-group-navigator'
|
||||
import { useVerge } from '@/hooks/use-verge'
|
||||
import { useWindowDecorations } from '@/hooks/use-window'
|
||||
@@ -110,6 +104,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
close: () => setOpen(false),
|
||||
}))
|
||||
|
||||
const onSwitchFormat = (_e: any, value: boolean) => value
|
||||
const onError = (err: any) => {
|
||||
showNotice.error(err)
|
||||
}
|
||||
@@ -139,7 +134,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={decorated}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={async () => {
|
||||
await toggleDecorations()
|
||||
}}
|
||||
@@ -156,7 +151,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.traffic_graph ?? true}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ traffic_graph: e })}
|
||||
onGuard={(e) => patchVerge({ traffic_graph: e })}
|
||||
>
|
||||
@@ -172,7 +167,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.enable_memory_usage ?? true}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_memory_usage: e })}
|
||||
onGuard={(e) => patchVerge({ enable_memory_usage: e })}
|
||||
>
|
||||
@@ -190,7 +185,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.enable_group_icon ?? true}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_group_icon: e })}
|
||||
onGuard={(e) => patchVerge({ enable_group_icon: e })}
|
||||
>
|
||||
@@ -208,7 +203,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.pause_render_traffic_stats_on_blur ?? true}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) =>
|
||||
onChangeData({ pause_render_traffic_stats_on_blur: e })
|
||||
}
|
||||
@@ -276,7 +271,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.enable_hover_jump_navigator ?? true}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_hover_jump_navigator: e })}
|
||||
onGuard={(e) => patchVerge({ enable_hover_jump_navigator: e })}
|
||||
>
|
||||
@@ -378,7 +373,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.collapse_navbar ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ collapse_navbar: e })}
|
||||
onGuard={(e) => patchVerge({ collapse_navbar: e })}
|
||||
>
|
||||
@@ -425,7 +420,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.enable_tray_speed ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_tray_speed: e })}
|
||||
onGuard={(e) => patchVerge({ enable_tray_speed: e })}
|
||||
>
|
||||
@@ -445,7 +440,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_tray_icon: e })}
|
||||
onGuard={(e) => patchVerge({ enable_tray_icon: e })}
|
||||
>
|
||||
@@ -499,7 +494,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
value={verge?.tray_inline_outbound_modes ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ tray_inline_outbound_modes: e })}
|
||||
onGuard={(e) => patchVerge({ tray_inline_outbound_modes: e })}
|
||||
>
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
TextField,
|
||||
} from '@mui/material'
|
||||
import { useLockFn } from 'ahooks'
|
||||
import { forwardRef, useMemo, useState } from 'react'
|
||||
import { forwardRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { BaseDialog, DialogRef, Switch, TooltipIcon } from '@/components/base'
|
||||
@@ -17,26 +17,11 @@ import { showNotice } from '@/services/notice-service'
|
||||
|
||||
import { useSettingDialog } from '../settings-search-context'
|
||||
|
||||
const APP_LOG_LEVEL_OPTIONS = [
|
||||
'trace',
|
||||
'debug',
|
||||
'info',
|
||||
'warn',
|
||||
'error',
|
||||
'silent',
|
||||
].map((level) => ({
|
||||
value: level,
|
||||
label: level[0].toUpperCase() + level.slice(1).toLowerCase(),
|
||||
}))
|
||||
|
||||
const PROXY_LAYOUT_COLUMN_VALUES = [1, 2, 3, 4, 5]
|
||||
|
||||
const buildInitialValues = (verge?: IVergeConfig | null) => ({
|
||||
appLogLevel: verge?.app_log_level ?? 'warn',
|
||||
appLogMaxSize: verge?.app_log_max_size ?? 128,
|
||||
appLogMaxCount: verge?.app_log_max_count ?? 8,
|
||||
autoCloseConnection: verge?.auto_close_connection ?? true,
|
||||
autoSwitchSelectorGroup: verge?.auto_switch_selector_group ?? true,
|
||||
autoCheckUpdate: verge?.auto_check_update ?? true,
|
||||
enableBuiltinEnhanced: verge?.enable_builtin_enhanced ?? true,
|
||||
proxyLayoutColumn: verge?.proxy_layout_column || 6,
|
||||
@@ -52,40 +37,6 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
const { t } = useTranslation()
|
||||
const { verge, patchVerge } = useVerge()
|
||||
|
||||
const autoLogCleanOptions = useMemo(
|
||||
() => [
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.never'),
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 1,
|
||||
}),
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 7,
|
||||
}),
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 30,
|
||||
}),
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 90,
|
||||
}),
|
||||
value: 4,
|
||||
},
|
||||
],
|
||||
[t],
|
||||
)
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
const [values, setValues] = useState(() => buildInitialValues(null))
|
||||
|
||||
@@ -104,7 +55,6 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
app_log_max_size: values.appLogMaxSize,
|
||||
app_log_max_count: values.appLogMaxCount,
|
||||
auto_close_connection: values.autoCloseConnection,
|
||||
auto_switch_selector_group: values.autoSwitchSelectorGroup,
|
||||
auto_check_update: values.autoCheckUpdate,
|
||||
enable_builtin_enhanced: values.enableBuiltinEnhanced,
|
||||
proxy_layout_column: values.proxyLayoutColumn,
|
||||
@@ -152,9 +102,9 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
}))
|
||||
}
|
||||
>
|
||||
{APP_LOG_LEVEL_OPTIONS.map(({ value, label }) => (
|
||||
<MenuItem value={value} key={value}>
|
||||
{label}
|
||||
{['trace', 'debug', 'info', 'warn', 'error', 'silent'].map((i) => (
|
||||
<MenuItem value={i} key={i}>
|
||||
{i[0].toUpperCase() + i.slice(1).toLowerCase()}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
@@ -252,28 +202,6 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<ListItem
|
||||
data-setting-target="settings.modals.misc.fields.autoSwitchSelectorGroup"
|
||||
sx={{ padding: '5px 2px' }}
|
||||
>
|
||||
<ListItemText
|
||||
primary={t('settings.modals.misc.fields.autoSwitchSelectorGroup')}
|
||||
sx={{ maxWidth: 'fit-content' }}
|
||||
/>
|
||||
<TooltipIcon
|
||||
title={t('settings.modals.misc.tooltips.autoSwitchSelectorGroup')}
|
||||
sx={{ opacity: '0.7' }}
|
||||
/>
|
||||
<Switch
|
||||
edge="end"
|
||||
checked={values.autoSwitchSelectorGroup}
|
||||
onChange={(_, c) =>
|
||||
setValues((v) => ({ ...v, autoSwitchSelectorGroup: c }))
|
||||
}
|
||||
sx={{ marginLeft: 'auto' }}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<ListItem
|
||||
data-setting-target="settings.modals.misc.fields.autoCheckUpdate"
|
||||
sx={{ padding: '5px 2px' }}
|
||||
@@ -333,7 +261,7 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
<MenuItem value={6} key={6}>
|
||||
{t('settings.modals.misc.options.proxyLayoutColumns.auto')}
|
||||
</MenuItem>
|
||||
{PROXY_LAYOUT_COLUMN_VALUES.map((i) => (
|
||||
{[1, 2, 3, 4, 5].map((i) => (
|
||||
<MenuItem value={i} key={i}>
|
||||
{i}
|
||||
</MenuItem>
|
||||
@@ -360,7 +288,36 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
}
|
||||
>
|
||||
{/* 1: 1天, 2: 7天, 3: 30天, 4: 90天*/}
|
||||
{autoLogCleanOptions.map((i) => (
|
||||
{[
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.never'),
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 1,
|
||||
}),
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 7,
|
||||
}),
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 30,
|
||||
}),
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
key: t('settings.modals.misc.options.autoLogClean.retainDays', {
|
||||
n: 90,
|
||||
}),
|
||||
value: 4,
|
||||
},
|
||||
].map((i) => (
|
||||
<MenuItem key={i.value} value={i.value}>
|
||||
{i.key}
|
||||
</MenuItem>
|
||||
|
||||
@@ -62,14 +62,7 @@ export const SettingItem: React.FC<ItemProps> = ({
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
) : (
|
||||
<ListItem
|
||||
data-setting-target={searchTarget}
|
||||
sx={{
|
||||
pt: '5px',
|
||||
pb: '5px',
|
||||
'&:hover': { bgcolor: 'action.hover' },
|
||||
}}
|
||||
>
|
||||
<ListItem data-setting-target={searchTarget} sx={{ pt: '5px', pb: '5px' }}>
|
||||
<ListItemText primary={primary} secondary={secondary} />
|
||||
{children}
|
||||
</ListItem>
|
||||
|
||||
@@ -84,19 +84,6 @@ const splitBypass = (value?: string) =>
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
const OS = getSystem()
|
||||
|
||||
const DEFAULT_BYPASS =
|
||||
OS === 'windows'
|
||||
? 'localhost;127.*;192.168.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;*.local;<local>'
|
||||
: OS === 'linux'
|
||||
? 'localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,::1'
|
||||
: '127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,localhost,*.local,*.crashlytics.com,<local>'
|
||||
|
||||
const DEFAULT_BYPASS_CHIPS = splitBypass(DEFAULT_BYPASS)
|
||||
|
||||
const BYPASS_SEPARATOR = OS === 'windows' ? ';' : ','
|
||||
|
||||
const buildInitialValues = (verge?: IVergeConfig | null) => ({
|
||||
guard: verge?.enable_proxy_guard,
|
||||
enable_bypass_check: verge?.enable_bypass_check ?? true,
|
||||
@@ -110,7 +97,8 @@ const buildInitialValues = (verge?: IVergeConfig | null) => ({
|
||||
|
||||
export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
const { t } = useTranslation()
|
||||
const isWindows = OS === 'windows'
|
||||
const systemName = getSystem()
|
||||
const isWindows = systemName === 'windows'
|
||||
const validReg = useMemo(() => getValidReg(isWindows), [isWindows])
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -142,7 +130,17 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
queryFn: getEmbeddedServerPort,
|
||||
})
|
||||
|
||||
const separator = BYPASS_SEPARATOR
|
||||
const separator = useMemo(() => (isWindows ? ';' : ','), [isWindows])
|
||||
|
||||
const defaultBypass = () => {
|
||||
if (isWindows) {
|
||||
return 'localhost;127.*;192.168.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;*.local;<local>'
|
||||
}
|
||||
if (systemName === 'linux') {
|
||||
return 'localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,::1'
|
||||
}
|
||||
return '127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,localhost,*.local,*.crashlytics.com,<local>'
|
||||
}
|
||||
|
||||
const { systemProxyAddress } = useSystemData()
|
||||
const displayedMixedPort = useDisplayedMixedPort()
|
||||
@@ -505,7 +503,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
checked={value.use_default}
|
||||
onChange={(_, e) => {
|
||||
if (!e && !value.bypass) {
|
||||
const nextBypass = DEFAULT_BYPASS
|
||||
const nextBypass = defaultBypass()
|
||||
setValue((v) => ({
|
||||
...v,
|
||||
use_default: e,
|
||||
@@ -577,7 +575,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
/>
|
||||
<Box sx={{ padding: '0 2px 5px' }}>
|
||||
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1 }}>
|
||||
{DEFAULT_BYPASS_CHIPS.map((item) => (
|
||||
{splitBypass(defaultBypass()).map((item) => (
|
||||
<Chip key={item} label={item} size="small" />
|
||||
))}
|
||||
</Box>
|
||||
|
||||
@@ -20,12 +20,6 @@ import { showNotice } from '@/services/notice-service'
|
||||
|
||||
import { useSettingDialog } from '../settings-search-context'
|
||||
|
||||
const textProps = {
|
||||
size: 'small',
|
||||
autoComplete: 'off',
|
||||
sx: { width: 135 },
|
||||
} as const
|
||||
|
||||
export function ThemeViewer(props: { ref?: React.Ref<DialogRef> }) {
|
||||
const { ref } = props
|
||||
const { t } = useTranslation()
|
||||
@@ -51,6 +45,12 @@ export function ThemeViewer(props: { ref?: React.Ref<DialogRef> }) {
|
||||
close: () => setOpen(false),
|
||||
}))
|
||||
|
||||
const textProps = {
|
||||
size: 'small',
|
||||
autoComplete: 'off',
|
||||
sx: { width: 135 },
|
||||
} as const
|
||||
|
||||
const handleChange = (field: keyof typeof theme) => (e: any) => {
|
||||
setTheme((t) => ({ ...t, [field]: e.target.value }))
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from '@mui/material'
|
||||
import { useLockFn } from 'ahooks'
|
||||
import type { Ref } from 'react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import {
|
||||
@@ -58,9 +58,8 @@ export function TunViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
dnsMode: '',
|
||||
})
|
||||
|
||||
const routeExcludeAddressItems = useMemo(
|
||||
() => splitRouteExcludeAddress(values.routeExcludeAddress),
|
||||
[values.routeExcludeAddress],
|
||||
const routeExcludeAddressItems = splitRouteExcludeAddress(
|
||||
values.routeExcludeAddress,
|
||||
)
|
||||
const routeExcludeAddressError =
|
||||
values.autoRoute &&
|
||||
|
||||
@@ -189,7 +189,10 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
void openExternalUrl(url).catch(showNotice.error)
|
||||
}
|
||||
|
||||
const progress = total <= 0 ? 0 : Math.min((downloaded / total) * 100, 100)
|
||||
const progress = useMemo(() => {
|
||||
if (total <= 0) return 0
|
||||
return Math.min((downloaded / total) * 100, 100)
|
||||
}, [downloaded, total])
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
open: () => {
|
||||
|
||||
@@ -5,13 +5,7 @@ import { useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { updateGeo, type LogLevel } from 'tauri-plugin-mihomo-api'
|
||||
|
||||
import {
|
||||
BaseDialog,
|
||||
DialogRef,
|
||||
Switch,
|
||||
TooltipIcon,
|
||||
switchChangeValue,
|
||||
} from '@/components/base'
|
||||
import { BaseDialog, DialogRef, Switch, TooltipIcon } from '@/components/base'
|
||||
import { useClash } from '@/hooks/use-clash'
|
||||
import { useClashLog } from '@/hooks/use-clash-log'
|
||||
import { useDisplayedMixedPort } from '@/hooks/use-displayed-mixed-port'
|
||||
@@ -75,6 +69,7 @@ const SettingClash = ({ onError }: Props) => {
|
||||
const corsRef = useRef<DialogRef>(null)
|
||||
const tunnelRef = useRef<DialogRef>(null)
|
||||
|
||||
const onSwitchFormat = (_e: any, value: boolean) => value
|
||||
const onChangeData = (patch: Partial<IConfigData>) => {
|
||||
mutateClash((old) => ({ ...old!, ...patch }), false)
|
||||
}
|
||||
@@ -178,7 +173,7 @@ const SettingClash = ({ onError }: Props) => {
|
||||
value={allowLan ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ 'allow-lan': e })}
|
||||
onGuard={(e) => patchClash({ 'allow-lan': e })}
|
||||
>
|
||||
@@ -218,7 +213,7 @@ const SettingClash = ({ onError }: Props) => {
|
||||
value={ipv6 ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ ipv6: e })}
|
||||
onGuard={(e) => patchClash({ ipv6: e })}
|
||||
>
|
||||
@@ -240,7 +235,7 @@ const SettingClash = ({ onError }: Props) => {
|
||||
value={unifiedDelay ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ 'unified-delay': e })}
|
||||
onGuard={(e) => patchClash({ 'unified-delay': e })}
|
||||
>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Box } from '@mui/material'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { Switch, TooltipIcon, switchChangeValue } from '@/components/base'
|
||||
import { Switch, TooltipIcon } from '@/components/base'
|
||||
import ProxyControlSwitches from '@/components/shared/proxy-control-switches'
|
||||
import { useVerge } from '@/hooks/use-verge'
|
||||
|
||||
@@ -19,6 +20,10 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
|
||||
const { enable_auto_launch, enable_silent_start } = verge ?? {}
|
||||
|
||||
const onSwitchFormat = (
|
||||
_e: React.ChangeEvent<HTMLInputElement>,
|
||||
value: boolean,
|
||||
) => value
|
||||
const onChangeData = (patch: Partial<IVergeConfig>) => {
|
||||
mutateVerge({ ...verge, ...patch })
|
||||
}
|
||||
@@ -47,7 +52,7 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
value={enable_auto_launch ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => {
|
||||
onChangeData({ enable_auto_launch: e })
|
||||
}}
|
||||
@@ -80,7 +85,7 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
value={enable_silent_start ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={switchChangeValue}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_silent_start: e })}
|
||||
onGuard={(e) => patchVerge({ enable_silent_start: e })}
|
||||
>
|
||||
|
||||
@@ -480,8 +480,6 @@ const settingsCatalog: readonly SettingEntry[] = [
|
||||
'settings.modals.misc.fields.appLogMaxCount': 'app log max count',
|
||||
'settings.modals.misc.fields.autoCloseConnections':
|
||||
'auto close connections',
|
||||
'settings.modals.misc.fields.autoSwitchSelectorGroup':
|
||||
'auto switch select group',
|
||||
'settings.modals.misc.fields.autoCheckUpdate': 'auto check update',
|
||||
'settings.modals.misc.fields.enableBuiltinEnhanced':
|
||||
'enable builtin enhanced',
|
||||
|
||||
+12
-22
@@ -1,6 +1,5 @@
|
||||
import { useLockFn } from 'ahooks'
|
||||
import i18n from 'i18next'
|
||||
import { useCallback } from 'react'
|
||||
import { getVersion } from 'tauri-plugin-mihomo-api'
|
||||
|
||||
import {
|
||||
@@ -87,29 +86,23 @@ export const useClashMode = (shouldFetch: boolean = true) => {
|
||||
}
|
||||
|
||||
export const useClash = () => {
|
||||
const { data: clash } = useRuntimeConfig()
|
||||
const { data: clash, refetch } = useRuntimeConfig()
|
||||
|
||||
const { data: versionData, refetch: mutateVersion } = useQuery({
|
||||
queryKey: ['getVersion'],
|
||||
queryFn: getVersion,
|
||||
})
|
||||
|
||||
// Stable identity: consumers pass mutateClash into their own callbacks.
|
||||
// revalidateQuery hits the same cache key refetch would, without capturing
|
||||
// the per-render refetch closure.
|
||||
const mutateClash = useCallback(
|
||||
(updater?: MutateClashUpdater, revalidate?: boolean) => {
|
||||
if (updater === undefined) {
|
||||
return revalidateQuery(['getRuntimeConfig'])
|
||||
}
|
||||
void setCacheData<IConfigData>(['getRuntimeConfig'], updater)
|
||||
if (revalidate !== false) {
|
||||
return revalidateQuery(['getRuntimeConfig'])
|
||||
}
|
||||
return Promise.resolve()
|
||||
},
|
||||
[],
|
||||
)
|
||||
const mutateClash = (updater?: MutateClashUpdater, revalidate?: boolean) => {
|
||||
if (updater === undefined) {
|
||||
return refetch()
|
||||
}
|
||||
void setCacheData<IConfigData>(['getRuntimeConfig'], updater)
|
||||
if (revalidate !== false) {
|
||||
return refetch()
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const patchClash = useLockFn(async (patch: Partial<IConfigData>) => {
|
||||
await mutate(() => patchClashConfig(patch), {
|
||||
@@ -150,10 +143,7 @@ export const useClashInfo = () => {
|
||||
})
|
||||
})
|
||||
|
||||
const invalidateClashConfig = useCallback(
|
||||
() => revalidateQuery(['getClashConfig']),
|
||||
[],
|
||||
)
|
||||
const invalidateClashConfig = () => revalidateQuery(['getClashConfig'])
|
||||
|
||||
return {
|
||||
clashInfo,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useMemo, useSyncExternalStore } from 'react'
|
||||
import { useCallback, useSyncExternalStore } from 'react'
|
||||
|
||||
import delayManager, { type DelaySnapshot } from '@/services/delay'
|
||||
import type { ResolvedProxyMember } from '@/types/proxy-view'
|
||||
@@ -32,7 +32,7 @@ export const useGroupsDelays = (
|
||||
groups: readonly string[],
|
||||
): ReadonlyMap<string, DelaySnapshot> => {
|
||||
// Group membership must remain unambiguous when names contain spaces.
|
||||
const groupKey = useMemo(() => JSON.stringify(groups), [groups])
|
||||
const groupKey = JSON.stringify(groups)
|
||||
|
||||
const subscribe = useCallback(
|
||||
(onSettle: () => void) => {
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "App Log Max Size",
|
||||
"appLogMaxCount": "App Log Max Count",
|
||||
"autoCloseConnections": "إغلاق الاتصالات تلقائيًا",
|
||||
"autoSwitchSelectorGroup": "تبديل مجموعة select تلقائيًا",
|
||||
"autoCheckUpdate": "فحص التحديث تلقائيًا",
|
||||
"enableBuiltinEnhanced": "تفعيل التحسين المدمج",
|
||||
"proxyLayoutColumns": "أعمدة عرض الوكيل",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "إنهاء الاتصالات القائمة عند تغيير اختيار مجموعة الوكيل أو وضع الوكيل",
|
||||
"autoSwitchSelectorGroup": "في وضع القواعد، عند اختيار عقدة في مجموعة url-test أو fallback يتم أيضًا تحويل أول مجموعة select تحتوي عليها إلى تلك المجموعة",
|
||||
"enableBuiltinEnhanced": "معالجة توافق ملف التكوين",
|
||||
"autoDelayDetection": "يختبر زمن استجابة العقدة الحالية على نحو دوري في الخلفية",
|
||||
"defaultLatencyTest": "يُستخدم فقط لاختبار طلب HTTP العميل. لن يؤثر على ملف التكوين"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "Maximale Größe des Anwendungsprotokolls",
|
||||
"appLogMaxCount": "Maximale Anzahl der Anwendungsprotokolle",
|
||||
"autoCloseConnections": "Verbindungen automatisch schließen",
|
||||
"autoSwitchSelectorGroup": "Select-Gruppe automatisch umschalten",
|
||||
"autoCheckUpdate": "Automatisch auf Updates prüfen",
|
||||
"enableBuiltinEnhanced": "Eingebaute Verbesserungen aktivieren",
|
||||
"proxyLayoutColumns": "Anzahl der Spalten im Proxy-Layout",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Wenn der ausgewählte Knoten in der Proxy-Gruppe oder der Proxy-Modus geändert wird, werden die bestehenden Verbindungen geschlossen.",
|
||||
"autoSwitchSelectorGroup": "Wird im Regelmodus ein Knoten in einer url-test- oder fallback-Gruppe gewählt, wechselt auch die erste select-Gruppe, die diese Gruppe enthält, auf diese Gruppe.",
|
||||
"enableBuiltinEnhanced": "Kompatibilitätsbehandlung der Konfigurationsdatei",
|
||||
"autoDelayDetection": "Überprüft regelmäßig im Hintergrund die Latenz des aktuellen Knotens",
|
||||
"defaultLatencyTest": "Dies wird nur für HTTP-Client-Anfragentests verwendet und hat keine Auswirkungen auf die Konfigurationsdatei."
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "App Log Max Size",
|
||||
"appLogMaxCount": "App Log Max Count",
|
||||
"autoCloseConnections": "Auto Close Connections",
|
||||
"autoSwitchSelectorGroup": "Auto Switch Select Group",
|
||||
"autoCheckUpdate": "Auto Check Update",
|
||||
"enableBuiltinEnhanced": "Enable Builtin Enhanced",
|
||||
"proxyLayoutColumns": "Proxy Layout Columns",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Terminate established connections when the proxy group selection or proxy mode changes",
|
||||
"autoSwitchSelectorGroup": "In rule mode, selecting a node in a url-test or fallback group also switches the first select group containing it to that group",
|
||||
"enableBuiltinEnhanced": "Compatibility handling for the configuration file",
|
||||
"autoDelayDetection": "Periodically test the current node latency in the background",
|
||||
"defaultLatencyTest": "Used for HTTP client request testing only and won't make a difference to the configuration file"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "App Log Max Size",
|
||||
"appLogMaxCount": "App Log Max Count",
|
||||
"autoCloseConnections": "Cerrar conexiones automáticamente",
|
||||
"autoSwitchSelectorGroup": "Cambiar grupo select automáticamente",
|
||||
"autoCheckUpdate": "Comprobar actualizaciones automáticamente",
|
||||
"enableBuiltinEnhanced": "Habilitar funciones mejoradas integradas",
|
||||
"proxyLayoutColumns": "Número de columnas en la disposición de la página de proxy",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Cierra las conexiones establecidas cuando se cambia el nodo seleccionado en el grupo de proxy o el modo de proxy.",
|
||||
"autoSwitchSelectorGroup": "En modo de reglas, al elegir un nodo en un grupo url-test o fallback, el primer grupo select que lo contiene también cambia a ese grupo.",
|
||||
"enableBuiltinEnhanced": "Procesamiento de compatibilidad de archivos de configuración",
|
||||
"autoDelayDetection": "Prueba periódicamente la latencia del nodo actual en segundo plano",
|
||||
"defaultLatencyTest": "Solo se utiliza para pruebas de solicitudes de clientes HTTP y no afectará al archivo de configuración."
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "App Log Max Size",
|
||||
"appLogMaxCount": "App Log Max Count",
|
||||
"autoCloseConnections": "بستن خودکار اتصالات",
|
||||
"autoSwitchSelectorGroup": "تغییر خودکار گروه select",
|
||||
"autoCheckUpdate": "بررسی خودکار بهروزرسانی",
|
||||
"enableBuiltinEnhanced": "فعال کردن تقویت داخلی",
|
||||
"proxyLayoutColumns": "ستون چیدمان پراکسی",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "اتصالات برقرار شده را هنگام تغییر انتخاب گروه پروکسی یا حالت پروکسی خاتمه دهید",
|
||||
"autoSwitchSelectorGroup": "در حالت قانون، با انتخاب یک گره در گروه url-test یا fallback، اولین گروه select شامل آن نیز به همان گروه تغییر میکند",
|
||||
"enableBuiltinEnhanced": "مدیریت سازگاری برای فایل پیکربندی",
|
||||
"autoDelayDetection": "بهصورت دورهای تأخیر گره فعلی را در پسزمینه آزمایش میکند",
|
||||
"defaultLatencyTest": "فقط برای تست درخواستهای کلاینت HTTP استفاده میشود و بر فایل پیکربندی تأثیری نخواهد داشت"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "App Log Max Size",
|
||||
"appLogMaxCount": "App Log Max Count",
|
||||
"autoCloseConnections": "Tutup Koneksi Otomatis",
|
||||
"autoSwitchSelectorGroup": "Alihkan Grup Select Otomatis",
|
||||
"autoCheckUpdate": "Periksa Pembaruan Otomatis",
|
||||
"enableBuiltinEnhanced": "Aktifkan Peningkatan Bawaan",
|
||||
"proxyLayoutColumns": "Kolom Tata Letak Proksi",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Hentikan koneksi yang sudah ada saat pemilihan grup proksi atau mode proksi berubah",
|
||||
"autoSwitchSelectorGroup": "Dalam mode aturan, memilih node di grup url-test atau fallback juga mengalihkan grup select pertama yang memuatnya ke grup tersebut",
|
||||
"enableBuiltinEnhanced": "Penanganan kompatibilitas untuk file konfigurasi",
|
||||
"autoDelayDetection": "Secara berkala menguji latensi node saat ini di latar belakang",
|
||||
"defaultLatencyTest": "Digunakan hanya untuk pengujian permintaan klien HTTP dan tidak akan mempengaruhi file konfigurasi"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "App Log Max Size",
|
||||
"appLogMaxCount": "App Log Max Count",
|
||||
"autoCloseConnections": "接続を自動的に閉じる",
|
||||
"autoSwitchSelectorGroup": "ノード選択時にグループを連動",
|
||||
"autoCheckUpdate": "自動更新チェック",
|
||||
"enableBuiltinEnhanced": "組み込み拡張機能を有効にする",
|
||||
"proxyLayoutColumns": "プロキシページのレイアウト列数",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "プロキシグループで選択されたノードまたはプロキシモードが変更されたときに、既存の接続を閉じます。",
|
||||
"autoSwitchSelectorGroup": "ルールモードで url-test または fallback グループのノードを選択すると、そのグループを含む最初の select グループも当該グループに切り替えます。",
|
||||
"enableBuiltinEnhanced": "設定ファイルの互換性処理",
|
||||
"autoDelayDetection": "バックグラウンドで現在のノードのレイテンシーを定期的にテストします",
|
||||
"defaultLatencyTest": "HTTPクライアントリクエストテストにのみ使用され、設定ファイルには影響しません。"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "앱 로그 최대 크기",
|
||||
"appLogMaxCount": "앱 로그 최대 개수",
|
||||
"autoCloseConnections": "연결 자동 종료",
|
||||
"autoSwitchSelectorGroup": "노드 선택 시 그룹 연동",
|
||||
"autoCheckUpdate": "업데이트 자동 확인",
|
||||
"enableBuiltinEnhanced": "내장 향상 기능 사용",
|
||||
"proxyLayoutColumns": "프록시 레이아웃 열 수",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "프록시 그룹 선택 또는 프록시 모드 변경 시 기존 연결을 종료합니다",
|
||||
"autoSwitchSelectorGroup": "규칙 모드에서 url-test 또는 fallback 그룹의 노드를 선택하면 해당 그룹을 포함하는 첫 번째 select 그룹도 그 그룹으로 전환합니다",
|
||||
"enableBuiltinEnhanced": "구성 파일에 대한 호환성 처리를 수행합니다",
|
||||
"autoDelayDetection": "백그라운드에서 현재 노드의 지연을 주기적으로 검사합니다",
|
||||
"defaultLatencyTest": "HTTP 클라이언트 요청 테스트에만 사용되며 구성 파일에는 영향을 주지 않습니다"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "Tamanho Máximo do Log do Aplicativo",
|
||||
"appLogMaxCount": "Quantidade Máxima de Logs do Aplicativo",
|
||||
"autoCloseConnections": "Fechar Conexões Automaticamente",
|
||||
"autoSwitchSelectorGroup": "Alternar Grupo Select Automaticamente",
|
||||
"autoCheckUpdate": "Verificar Atualizações Automaticamente",
|
||||
"enableBuiltinEnhanced": "Ativar Aprimoramento Integrado",
|
||||
"proxyLayoutColumns": "Colunas do Layout de Proxy",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Encerra as conexões estabelecidas quando a seleção do grupo de proxy ou o modo de proxy muda",
|
||||
"autoSwitchSelectorGroup": "No modo de regras, ao escolher um nó em um grupo url-test ou fallback, o primeiro grupo select que o contém também muda para esse grupo",
|
||||
"enableBuiltinEnhanced": "Tratamento de compatibilidade para o arquivo de configuração",
|
||||
"autoDelayDetection": "Testa periodicamente a latência do nó atual em segundo plano",
|
||||
"defaultLatencyTest": "Usado apenas para testes de requisição do cliente HTTP e não afeta o arquivo de configuração"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "Максимальный размер журнала приложения",
|
||||
"appLogMaxCount": "Максимальное количество файлов журнала",
|
||||
"autoCloseConnections": "Автоматическое закрытие соединений",
|
||||
"autoSwitchSelectorGroup": "Автопереключение группы select",
|
||||
"autoCheckUpdate": "Автоматическая проверка обновлений",
|
||||
"enableBuiltinEnhanced": "Включить встроенные улучшения",
|
||||
"proxyLayoutColumns": "Количество столбцов в макете прокси",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Закрывать установленные соединения при изменении выбора группы прокси или режима прокси",
|
||||
"autoSwitchSelectorGroup": "В режиме правил при выборе узла в группе url-test или fallback первая группа select, содержащая эту группу, также переключается на неё",
|
||||
"enableBuiltinEnhanced": "Обработка совместимости для файла конфигурации",
|
||||
"autoDelayDetection": "Периодически проверяет задержку текущего узла в фоновом режиме",
|
||||
"defaultLatencyTest": "Используется только для тестирования HTTP-запросов клиента и не влияет на файл конфигурации"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "Uygulama Günlüğü En Büyük Boyutu",
|
||||
"appLogMaxCount": "Uygulama Günlüğü En Fazla Dosya Sayısı",
|
||||
"autoCloseConnections": "Bağlantıları Otomatik Kapat",
|
||||
"autoSwitchSelectorGroup": "Select Grubunu Otomatik Değiştir",
|
||||
"autoCheckUpdate": "Otomatik Güncelleme Kontrolü",
|
||||
"enableBuiltinEnhanced": "Yerleşik Geliştirilmiş Modu Etkinleştir",
|
||||
"proxyLayoutColumns": "Vekil Düzeni Sütunları",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Vekil grup seçimi veya vekil modu değiştiğinde kurulan bağlantıları sonlandır",
|
||||
"autoSwitchSelectorGroup": "Kural modunda url-test veya fallback grubunda bir düğüm seçildiğinde, bu grubu içeren ilk select grubu da o gruba geçer",
|
||||
"enableBuiltinEnhanced": "Yapılandırma dosyası için uyumluluk işleme",
|
||||
"autoDelayDetection": "Arka planda mevcut düğümün gecikmesini periyodik olarak test eder",
|
||||
"defaultLatencyTest": "Yalnızca HTTP istemci isteği testi için kullanılır ve yapılandırma dosyasında bir fark yaratmaz"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "App Log Max Size",
|
||||
"appLogMaxCount": "App Log Max Count",
|
||||
"autoCloseConnections": "Тоташуларны автоматик ябу",
|
||||
"autoSwitchSelectorGroup": "Select төркемен автоматик күчерү",
|
||||
"autoCheckUpdate": "Яңартуларны автоматик тикшерү",
|
||||
"enableBuiltinEnhanced": "Эчке камилләштерүне кабызу",
|
||||
"proxyLayoutColumns": "Прокси күрсәтү баганалары саны",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "Прокси төркеме яисә режимын үзгәрткәндә актив тоташуларны өзү",
|
||||
"autoSwitchSelectorGroup": "Кагыйдәләр режимында url-test яки fallback төркемендә төен сайлаганда, аны эченә алган беренче select төркеме дә шул төркемгә күчә",
|
||||
"enableBuiltinEnhanced": "Конфигурация файлы белән туры килә торган өстәмә оптимизация",
|
||||
"autoDelayDetection": "Фон режимында хәзерге төен тоткарлыгын периодик тикшерә",
|
||||
"defaultLatencyTest": "Бу фәкать клиентның HTTP сораулары тесты өчен кулланыла, конфигурация файлына йогынты ясамый"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "应用日志最大大小",
|
||||
"appLogMaxCount": "应用日志最大数量",
|
||||
"autoCloseConnections": "自动关闭连接",
|
||||
"autoSwitchSelectorGroup": "选择节点时联动代理组",
|
||||
"autoCheckUpdate": "自动检查更新",
|
||||
"enableBuiltinEnhanced": "内置增强功能",
|
||||
"proxyLayoutColumns": "代理页布局列数",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "当代理组选中节点或代理模式变动时,关闭已建立的连接",
|
||||
"autoSwitchSelectorGroup": "规则模式下,在 url-test 或 fallback 代理组中选择节点时,将首个包含该组的 select 代理组切换到该组",
|
||||
"enableBuiltinEnhanced": "配置文件的兼容性处理",
|
||||
"autoDelayDetection": "后台定时检测当前节点延迟",
|
||||
"defaultLatencyTest": "仅用于 HTTP 客户端请求测试,不会对配置文件产生影响"
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
"appLogMaxSize": "應用程式日誌最大大小",
|
||||
"appLogMaxCount": "應用程式日誌最大數量",
|
||||
"autoCloseConnections": "自動關閉連線",
|
||||
"autoSwitchSelectorGroup": "選擇節點時聯動代理組",
|
||||
"autoCheckUpdate": "自動檢查更新",
|
||||
"enableBuiltinEnhanced": "內建增強功能",
|
||||
"proxyLayoutColumns": "代理頁面欄數",
|
||||
@@ -423,7 +422,6 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"autoCloseConnections": "當代理組選中節點或代理模式變動時,關閉已建立的連線",
|
||||
"autoSwitchSelectorGroup": "規則模式下,在 url-test 或 fallback 代理組中選擇節點時,將首個包含該組的 select 代理組切換到該組",
|
||||
"enableBuiltinEnhanced": "配置檔案的相容性處理",
|
||||
"autoDelayDetection": "在背景定時偵測目前節點延遲",
|
||||
"defaultLatencyTest": "僅用於 HTTP 客戶端請求測試,不會對配置檔案產生影響"
|
||||
|
||||
@@ -83,8 +83,6 @@ export const commands = {
|
||||
__TAURI_INVOKE<null>('record_selected_node', { groupName, node }),
|
||||
switchProxyNode: (groupName: string, proxyName: string, unfix: boolean) =>
|
||||
__TAURI_INVOKE<null>('switch_proxy_node', { groupName, proxyName, unfix }),
|
||||
followProxyGroup: (groupName: string) =>
|
||||
__TAURI_INVOKE<void>('follow_proxy_group', { groupName }),
|
||||
saveDnsConfig: (dnsConfig: YamlMapping) =>
|
||||
__TAURI_INVOKE<null>('save_dns_config', { dnsConfig }),
|
||||
applyDnsConfig: (apply: boolean) =>
|
||||
@@ -418,7 +416,6 @@ export type IVerge_Deserialize = {
|
||||
enable_global_hotkey?: boolean | null
|
||||
home_cards?: JsonValue | null
|
||||
auto_close_connection?: boolean | null
|
||||
auto_switch_selector_group?: boolean | null
|
||||
auto_check_update?: boolean | null
|
||||
default_latency_test?: string | null
|
||||
default_latency_timeout?: number | null
|
||||
@@ -509,7 +506,6 @@ export type IVerge_Serialize = {
|
||||
enable_global_hotkey: boolean | null
|
||||
home_cards: JsonValue | null
|
||||
auto_close_connection: boolean | null
|
||||
auto_switch_selector_group: boolean | null
|
||||
auto_check_update: boolean | null
|
||||
default_latency_test: string | null
|
||||
default_latency_timeout: number | null
|
||||
|
||||
+4
-10
@@ -165,10 +165,6 @@ export async function switchProxyNode(
|
||||
return commands.switchProxyNode(groupName, proxyName, unfix)
|
||||
}
|
||||
|
||||
export async function followProxyGroup(groupName: string) {
|
||||
return commands.followProxyGroup(groupName)
|
||||
}
|
||||
|
||||
export async function getProxyView(): Promise<ProxyViewV1> {
|
||||
const view = await commands.getProxyView()
|
||||
if (view.schemaVersion !== 1) {
|
||||
@@ -177,15 +173,13 @@ export async function getProxyView(): Promise<ProxyViewV1> {
|
||||
return view
|
||||
}
|
||||
|
||||
// getClashLogs matches both patterns against every log line.
|
||||
const CLASH_LOG_REGEX = /time="(.+?)"\s+level=(.+?)\s+msg="(.+?)"/
|
||||
const CLASH_LOG_NEW_REGEX = /(.+?)\s+(.+?)\s+(.+)/
|
||||
|
||||
export async function getClashLogs() {
|
||||
const regex = /time="(.+?)"\s+level=(.+?)\s+msg="(.+?)"/
|
||||
const newRegex = /(.+?)\s+(.+?)\s+(.+)/
|
||||
const logs = await commands.getClashLogs()
|
||||
|
||||
return logs.reduce<ILogItem[]>((acc, log) => {
|
||||
const result = log.match(CLASH_LOG_REGEX)
|
||||
const result = log.match(regex)
|
||||
if (result) {
|
||||
const [_, _time, type, payload] = result
|
||||
const time = dayjs(_time).format('MM-DD HH:mm:ss')
|
||||
@@ -193,7 +187,7 @@ export async function getClashLogs() {
|
||||
return acc
|
||||
}
|
||||
|
||||
const result2 = log.match(CLASH_LOG_NEW_REGEX)
|
||||
const result2 = log.match(newRegex)
|
||||
if (result2) {
|
||||
const [_, time, type, payload] = result2
|
||||
acc.push({ time, type, payload })
|
||||
|
||||
@@ -514,21 +514,9 @@ export function hideNotice(id: number) {
|
||||
}
|
||||
|
||||
function hideNoticesByCode(code: string) {
|
||||
// One subscriber notification for the whole batch; per-notice removal
|
||||
// would notify once per item.
|
||||
const remaining: NoticeItem[] = []
|
||||
let removed = false
|
||||
for (const notice of notices) {
|
||||
if (notice.code === code) {
|
||||
removed = true
|
||||
if (notice.timerId) clearTimeout(notice.timerId)
|
||||
} else {
|
||||
remaining.push(notice)
|
||||
}
|
||||
}
|
||||
if (!removed) return
|
||||
notices = remaining
|
||||
notifySubscribers()
|
||||
notices
|
||||
.filter((notice) => notice.code === code)
|
||||
.forEach(({ id }) => hideNotice(id))
|
||||
}
|
||||
|
||||
export function syncSidecarFailure(snapshot: SidecarFailureSnapshot) {
|
||||
|
||||
@@ -652,7 +652,6 @@ export const translationKeys = [
|
||||
'settings.modals.misc.fields.appLogMaxSize',
|
||||
'settings.modals.misc.fields.appLogMaxCount',
|
||||
'settings.modals.misc.fields.autoCloseConnections',
|
||||
'settings.modals.misc.fields.autoSwitchSelectorGroup',
|
||||
'settings.modals.misc.fields.autoCheckUpdate',
|
||||
'settings.modals.misc.fields.enableBuiltinEnhanced',
|
||||
'settings.modals.misc.fields.proxyLayoutColumns',
|
||||
@@ -662,7 +661,6 @@ export const translationKeys = [
|
||||
'settings.modals.misc.fields.defaultLatencyTest',
|
||||
'settings.modals.misc.fields.defaultLatencyTimeout',
|
||||
'settings.modals.misc.tooltips.autoCloseConnections',
|
||||
'settings.modals.misc.tooltips.autoSwitchSelectorGroup',
|
||||
'settings.modals.misc.tooltips.enableBuiltinEnhanced',
|
||||
'settings.modals.misc.tooltips.autoDelayDetection',
|
||||
'settings.modals.misc.tooltips.defaultLatencyTest',
|
||||
|
||||
@@ -1123,7 +1123,6 @@ export interface TranslationResources {
|
||||
autoDelayDetection: string
|
||||
autoDelayDetectionInterval: string
|
||||
autoLogClean: string
|
||||
autoSwitchSelectorGroup: string
|
||||
defaultLatencyTest: string
|
||||
defaultLatencyTimeout: string
|
||||
enableBuiltinEnhanced: string
|
||||
@@ -1142,7 +1141,6 @@ export interface TranslationResources {
|
||||
tooltips: {
|
||||
autoCloseConnections: string
|
||||
autoDelayDetection: string
|
||||
autoSwitchSelectorGroup: string
|
||||
defaultLatencyTest: string
|
||||
enableBuiltinEnhanced: string
|
||||
}
|
||||
|
||||
@@ -241,17 +241,17 @@ export function parseUrlLike(
|
||||
: result
|
||||
}
|
||||
|
||||
// Both predicates run per parsed proxy URI.
|
||||
const IPV4_REGEX = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/
|
||||
const IPV6_REGEX =
|
||||
/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::$|^::1$|^([0-9a-fA-F]{1,4}:)*::([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4}$/
|
||||
|
||||
export function isIPv4(address: string): boolean {
|
||||
return IPV4_REGEX.test(address)
|
||||
// Check if the address is IPv4
|
||||
const ipv4Regex = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/
|
||||
return ipv4Regex.test(address)
|
||||
}
|
||||
|
||||
export function isIPv6(address: string): boolean {
|
||||
return IPV6_REGEX.test(address)
|
||||
// Check if the address is IPv6 - simplified regex to avoid backreference issues
|
||||
const ipv6Regex =
|
||||
/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::$|^::1$|^([0-9a-fA-F]{1,4}:)*::([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4}$/
|
||||
return ipv6Regex.test(address)
|
||||
}
|
||||
|
||||
export function decodeBase64OrOriginal(str: string): string {
|
||||
|
||||
Reference in New Issue
Block a user