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")]
|
||||
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 script: Option<String>,
|
||||
@@ -122,6 +126,7 @@ impl PrfOption {
|
||||
a.danger_accept_invalid_certs = b
|
||||
.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.merge = b.merge.or(a.merge);
|
||||
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 accept_invalid_certs =
|
||||
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 update_interval = opt_ref.and_then(|o| o.update_interval);
|
||||
let timeout = opt_ref.and_then(|o| o.timeout_seconds).unwrap_or(20);
|
||||
@@ -404,6 +410,7 @@ impl PrfItem {
|
||||
rules,
|
||||
proxies,
|
||||
groups,
|
||||
allow_auto_update,
|
||||
..PrfOption::default()
|
||||
}),
|
||||
home,
|
||||
@@ -547,3 +554,8 @@ impl PrfItem {
|
||||
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() {
|
||||
log::warn!(target: "app", "[订阅更新] {uid} 缺少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 {
|
||||
log::info!(target: "app",
|
||||
"[订阅更新] {} 是远程订阅,URL: {}",
|
||||
|
||||
@@ -377,6 +377,17 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
||||
</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>
|
||||
|
||||
@@ -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"
|
||||
"App Log Max Count": "App Log Max Count",
|
||||
"Allow Auto Update": "Allow Auto Update"
|
||||
}
|
||||
|
||||
@@ -706,5 +706,6 @@
|
||||
"Selected profiles deleted successfully": "选中的订阅已成功删除",
|
||||
"Prefer System Titlebar": "优先使用系统标题栏",
|
||||
"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;
|
||||
timeout_seconds?: number;
|
||||
danger_accept_invalid_certs?: boolean;
|
||||
allow_auto_update?: boolean;
|
||||
merge?: string;
|
||||
script?: string;
|
||||
rules?: string;
|
||||
|
||||
Reference in New Issue
Block a user