mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
feat: add allow auto update option for profiles and update UI components
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
- 新增批量选择配置文件功能
|
- 新增批量选择配置文件功能
|
||||||
- 新增本地备份功能
|
- 新增本地备份功能
|
||||||
- 主界面“当前节点”卡片新增自动延迟检测开关(默认关闭)
|
- 主界面“当前节点”卡片新增自动延迟检测开关(默认关闭)
|
||||||
|
- 允许独立控制订阅自动更新
|
||||||
|
|
||||||
### 🚀 优化改进
|
### 🚀 优化改进
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ pub struct PrfOption {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub danger_accept_invalid_certs: Option<bool>,
|
pub danger_accept_invalid_certs: Option<bool>,
|
||||||
|
|
||||||
|
#[serde(default = "default_allow_auto_update")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub allow_auto_update: Option<bool>,
|
||||||
|
|
||||||
pub merge: Option<String>,
|
pub merge: Option<String>,
|
||||||
|
|
||||||
pub script: Option<String>,
|
pub script: Option<String>,
|
||||||
@@ -122,6 +126,7 @@ impl PrfOption {
|
|||||||
a.danger_accept_invalid_certs = b
|
a.danger_accept_invalid_certs = b
|
||||||
.danger_accept_invalid_certs
|
.danger_accept_invalid_certs
|
||||||
.or(a.danger_accept_invalid_certs);
|
.or(a.danger_accept_invalid_certs);
|
||||||
|
a.allow_auto_update = b.allow_auto_update.or(a.allow_auto_update);
|
||||||
a.update_interval = b.update_interval.or(a.update_interval);
|
a.update_interval = b.update_interval.or(a.update_interval);
|
||||||
a.merge = b.merge.or(a.merge);
|
a.merge = b.merge.or(a.merge);
|
||||||
a.script = b.script.or(a.script);
|
a.script = b.script.or(a.script);
|
||||||
@@ -246,6 +251,7 @@ impl PrfItem {
|
|||||||
let self_proxy = opt_ref.is_some_and(|o| o.self_proxy.unwrap_or(false));
|
let self_proxy = opt_ref.is_some_and(|o| o.self_proxy.unwrap_or(false));
|
||||||
let accept_invalid_certs =
|
let accept_invalid_certs =
|
||||||
opt_ref.is_some_and(|o| o.danger_accept_invalid_certs.unwrap_or(false));
|
opt_ref.is_some_and(|o| o.danger_accept_invalid_certs.unwrap_or(false));
|
||||||
|
let allow_auto_update = opt_ref.map(|o| o.allow_auto_update.unwrap_or(true));
|
||||||
let user_agent = opt_ref.and_then(|o| o.user_agent.clone());
|
let user_agent = opt_ref.and_then(|o| o.user_agent.clone());
|
||||||
let update_interval = opt_ref.and_then(|o| o.update_interval);
|
let update_interval = opt_ref.and_then(|o| o.update_interval);
|
||||||
let timeout = opt_ref.and_then(|o| o.timeout_seconds).unwrap_or(20);
|
let timeout = opt_ref.and_then(|o| o.timeout_seconds).unwrap_or(20);
|
||||||
@@ -404,6 +410,7 @@ impl PrfItem {
|
|||||||
rules,
|
rules,
|
||||||
proxies,
|
proxies,
|
||||||
groups,
|
groups,
|
||||||
|
allow_auto_update,
|
||||||
..PrfOption::default()
|
..PrfOption::default()
|
||||||
}),
|
}),
|
||||||
home,
|
home,
|
||||||
@@ -547,3 +554,8 @@ impl PrfItem {
|
|||||||
fs::write(path, data.as_bytes()).context("failed to save the file")
|
fs::write(path, data.as_bytes()).context("failed to save the file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 向前兼容,默认为订阅启用自动更新
|
||||||
|
fn default_allow_auto_update() -> Option<bool> {
|
||||||
|
Some(true)
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,6 +45,14 @@ pub async fn update_profile(
|
|||||||
} else if item.url.is_none() {
|
} else if item.url.is_none() {
|
||||||
log::warn!(target: "app", "[订阅更新] {uid} 缺少URL,无法更新");
|
log::warn!(target: "app", "[订阅更新] {uid} 缺少URL,无法更新");
|
||||||
bail!("failed to get the profile item url");
|
bail!("failed to get the profile item url");
|
||||||
|
} else if !item
|
||||||
|
.option
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|o| o.allow_auto_update)
|
||||||
|
.unwrap_or(true)
|
||||||
|
{
|
||||||
|
log::info!(target: "app", "[订阅更新] {} 禁止自动更新,跳过更新", uid);
|
||||||
|
None
|
||||||
} else {
|
} else {
|
||||||
log::info!(target: "app",
|
log::info!(target: "app",
|
||||||
"[订阅更新] {} 是远程订阅,URL: {}",
|
"[订阅更新] {} 是远程订阅,URL: {}",
|
||||||
|
|||||||
@@ -377,6 +377,17 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
|||||||
</StyledBox>
|
</StyledBox>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
name="option.allow_auto_update"
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<StyledBox>
|
||||||
|
<InputLabel>{t("Allow Auto Update")}</InputLabel>
|
||||||
|
<Switch checked={field.value} {...field} color="primary" />
|
||||||
|
</StyledBox>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</BaseDialog>
|
</BaseDialog>
|
||||||
|
|||||||
@@ -706,5 +706,6 @@
|
|||||||
"Selected profiles deleted successfully": "Selected profiles deleted successfully",
|
"Selected profiles deleted successfully": "Selected profiles deleted successfully",
|
||||||
"Prefer System Titlebar": "Prefer System Titlebar",
|
"Prefer System Titlebar": "Prefer System Titlebar",
|
||||||
"App Log Max Size": "App Log Max Size",
|
"App Log Max Size": "App Log Max Size",
|
||||||
"App Log Max Count": "App Log Max Count"
|
"App Log Max Count": "App Log Max Count",
|
||||||
|
"Allow Auto Update": "Allow Auto Update"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -706,5 +706,6 @@
|
|||||||
"Selected profiles deleted successfully": "选中的订阅已成功删除",
|
"Selected profiles deleted successfully": "选中的订阅已成功删除",
|
||||||
"Prefer System Titlebar": "优先使用系统标题栏",
|
"Prefer System Titlebar": "优先使用系统标题栏",
|
||||||
"App Log Max Size": "应用日志最大大小",
|
"App Log Max Size": "应用日志最大大小",
|
||||||
"App Log Max Count": "应用日志最大数量"
|
"App Log Max Count": "应用日志最大数量",
|
||||||
|
"Allow Auto Update": "允许自动更新"
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/services/types.d.ts
vendored
1
src/services/types.d.ts
vendored
@@ -270,6 +270,7 @@ interface IProfileOption {
|
|||||||
update_interval?: number;
|
update_interval?: number;
|
||||||
timeout_seconds?: number;
|
timeout_seconds?: number;
|
||||||
danger_accept_invalid_certs?: boolean;
|
danger_accept_invalid_certs?: boolean;
|
||||||
|
allow_auto_update?: boolean;
|
||||||
merge?: string;
|
merge?: string;
|
||||||
script?: string;
|
script?: string;
|
||||||
rules?: string;
|
rules?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user