6 Commits

23 changed files with 378 additions and 78 deletions

View File

@@ -106,7 +106,6 @@ jobs:
with: with:
tagName: v__VERSION__ tagName: v__VERSION__
releaseName: "Clash Verge Rev Lite v__VERSION__" releaseName: "Clash Verge Rev Lite v__VERSION__"
releaseBody: "More new features are now supported."
tauriScript: pnpm tauriScript: pnpm
args: --target ${{ matrix.target }} args: --target ${{ matrix.target }}
@@ -219,14 +218,13 @@ jobs:
sudo apt-get update sudo apt-get update
sudo apt-get install jq sudo apt-get install jq
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV echo "BUILDTIME=$(TZ=Europe/Moscow date)" >> $GITHUB_ENV
- name: Upload Release - name: Upload Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
tag_name: v${{env.VERSION}} tag_name: v${{env.VERSION}}
name: "Clash Verge Rev Lite v${{env.VERSION}}" name: "Clash Verge Rev Lite v${{env.VERSION}}"
body: "More new features are now supported."
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
files: | files: |
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
@@ -275,8 +273,8 @@ jobs:
- name: Download WebView2 Runtime - name: Download WebView2 Runtime
run: | run: |
invoke-webrequest -uri https://github.com/westinyang/WebView2RuntimeArchive/releases/download/109.0.1518.78/Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -outfile Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab invoke-webrequest -uri https://github.com/westinyang/WebView2RuntimeArchive/releases/download/133.0.3065.92/Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${{ matrix.arch }}.cab -outfile Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${{ matrix.arch }}.cab
Expand .\Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -F:* ./src-tauri Expand .\Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${{ matrix.arch }}.cab -F:* ./src-tauri
Remove-Item .\src-tauri\tauri.windows.conf.json Remove-Item .\src-tauri\tauri.windows.conf.json
Rename-Item .\src-tauri\webview2.${{ matrix.arch }}.json tauri.windows.conf.json Rename-Item .\src-tauri\webview2.${{ matrix.arch }}.json tauri.windows.conf.json
@@ -317,7 +315,6 @@ jobs:
with: with:
tag_name: v${{steps.build.outputs.appVersion}} tag_name: v${{steps.build.outputs.appVersion}}
name: "Clash Verge Rev Lite v${{steps.build.outputs.appVersion}}" name: "Clash Verge Rev Lite v${{steps.build.outputs.appVersion}}"
body: "More new features are now supported."
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup* files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup*
@@ -376,3 +373,85 @@ jobs:
run: pnpm updater-fixed-webview2 run: pnpm updater-fixed-webview2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create_release_notes:
name: Create Release Notes
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch UPDATE logs
id: fetch_update_logs
run: |
if [ -f "UPDATELOG.md" ]; then
UPDATE_LOGS=$(awk '/^## v/{if(flag) exit; flag=1} flag' UPDATELOG.md)
if [ -n "$UPDATE_LOGS" ]; then
echo "Found update logs"
echo "UPDATE_LOGS<<EOF" >> $GITHUB_ENV
echo "$UPDATE_LOGS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "No update sections found in UPDATELOG.md"
fi
else
echo "UPDATELOG.md file not found"
fi
shell: bash
- name: Get Version
run: |
sudo apt-get update
sudo apt-get install jq
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
echo "BUILDTIME=$(TZ=Europe/Moscow date)" >> $GITHUB_ENV
- run: |
if [ -z "$UPDATE_LOGS" ]; then
echo "No update logs found, using default message"
UPDATE_LOGS="More new features are now supported. Check for detailed changelog soon."
else
echo "Using found update logs"
fi
cat > release.txt << EOF
$UPDATE_LOGS
## Which version should I download?
### macOS
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_aarch64.dmg"><img src="https://img.shields.io/badge/DMG-default?style=flat&logo=apple&label=Apple%20Silicon"></a><br>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_x64.dmg"><img src="https://img.shields.io/badge/DMG-default?style=flat&logo=apple&label=Intel"></a><br>
> :warning: **Warning**
If you get a notification that the application is corrupted when you run it on macOS, run this command:<br>
`sudo xattr -r -c /Applications/Clash\ Verge\ Rev\ Lite.app`
### Linux
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_amd64.deb"><img src="https://img.shields.io/badge/x64-default?style=flat&logo=debian&label=DEB"> </a><br>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite-${{ env.VERSION }}-1.x86_64.rpm"><img src="https://img.shields.io/badge/x64-default?style=flat&logo=fedora&label=RPM"> </a>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_arm64.deb"><img src="https://img.shields.io/badge/arm64-default?style=flat&logo=debian&label=DEB"> </a><br>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite-${{ env.VERSION }}-1.aarch64.rpm"><img src="https://img.shields.io/badge/aarch64-default?style=flat&logo=fedora&label=RPM"> </a>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_armhf.deb"><img src="https://img.shields.io/badge/armhf-default?style=flat&logo=debian&label=DEB"> </a><br>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite-${{ env.VERSION }}-1.armhfp.rpm"><img src="https://img.shields.io/badge/armhfp-default?style=flat&logo=fedora&label=RPM"> </a>
### Windows (Win7 is no longer supported)
#### Normal version (recommended)
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_x64-setup.exe"><img src="https://badgen.net/badge/icon/x64?icon=windows&label=exe"></a><br>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_arm64-setup.exe"><img src="https://badgen.net/badge/icon/arm64?icon=windows&label=exe"></a>
#### Portable version is no longer available with many problems
#### Built-in Webview version 2 (large size, only used in enterprise version of the system or can not install webview2)
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_x64_fixed_webview2-setup.exe"><img src="https://badgen.net/badge/icon/x64?icon=windows&label=exe"></a><br>
<a href="https://github.com/coolcoala/clash-verge-rev-lite/releases/download/v${{ env.VERSION }}/Clash.Verge.Rev.Lite_${{ env.VERSION }}_arm64_fixed_webview2-setup.exe"><img src="https://badgen.net/badge/icon/arm64?icon=windows&label=exe"></a>
Created at ${{ env.BUILDTIME }}.
EOF
- name: Upload Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{env.VERSION}}
name: "Clash Verge Rev Lite v${{env.VERSION}}"
body_path: release.txt
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,3 +1,10 @@
## v0.2.1
- added headers "announce-url", "update-always"
- added a check for the presence of a profile, if it already exists, an update will be performed
- fixed processing of links for displaying telegram icon on the main page
- added profile update button on the main page
## v0.2 ## v0.2
- added handlers for "Announe", "Support-Url", "New-Sub-Domain", "Profile-Title" headers: - added handlers for "Announe", "Support-Url", "New-Sub-Domain", "Profile-Title" headers:

View File

@@ -1,6 +1,6 @@
{ {
"name": "clash-verge", "name": "clash-verge",
"version": "0.2.0", "version": "0.2.1",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"scripts": { "scripts": {
"dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev", "dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev",

View File

@@ -49,9 +49,9 @@ async function resolvePortable() {
zip.addLocalFolder( zip.addLocalFolder(
path.join( path.join(
releaseDir, releaseDir,
`Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${arch}`, `Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${arch}`,
), ),
`Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${arch}`, `Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.${arch}`,
); );
zip.addLocalFolder(configDir, ".config"); zip.addLocalFolder(configDir, ".config");

2
src-tauri/Cargo.lock generated
View File

@@ -1061,7 +1061,7 @@ dependencies = [
[[package]] [[package]]
name = "clash-verge" name = "clash-verge"
version = "0.2.0" version = "0.2.1"
dependencies = [ dependencies = [
"ab_glyph", "ab_glyph",
"aes-gcm", "aes-gcm",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "clash-verge" name = "clash-verge"
version = "0.2.0" version = "0.2.1"
description = "clash verge" description = "clash verge"
authors = ["zzzgydi", "wonfen", "MystiPanda", "coolcoala"] authors = ["zzzgydi", "wonfen", "MystiPanda", "coolcoala"]
license = "GPL-3.0-only" license = "GPL-3.0-only"

View File

@@ -129,8 +129,24 @@ pub async fn enhance_profiles() -> CmdResult {
/// 导入配置文件 /// 导入配置文件
#[tauri::command] #[tauri::command]
pub async fn import_profile(url: String, option: Option<PrfOption>) -> CmdResult { pub async fn import_profile(url: String, option: Option<PrfOption>) -> CmdResult {
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?; let existing_uid = {
wrap_err!(Config::profiles().data().append_item(item)) let profiles = Config::profiles();
let profiles = profiles.latest();
profiles.items.as_ref()
.and_then(|items| items.iter().find(|item| item.url.as_deref() == Some(&url)))
.and_then(|item| item.uid.clone())
};
if let Some(uid) = existing_uid {
logging!(info, Type::Cmd, true, "The profile with URL {} already exists (UID: {}). Running the update...", url, uid);
update_profile(uid, option).await
} else {
logging!(info, Type::Cmd, true, "Profile with URL {} not found. Create a new one...", url);
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
wrap_err!(Config::profiles().data().append_item(item))
}
} }
/// 重新排序配置文件 /// 重新排序配置文件
@@ -647,3 +663,48 @@ pub fn get_next_update_time(uid: String) -> CmdResult<Option<i64>> {
let next_time = timer.get_next_update_time(&uid); let next_time = timer.get_next_update_time(&uid);
Ok(next_time) Ok(next_time)
} }
#[tauri::command]
pub async fn update_profiles_on_startup() -> CmdResult {
logging!(info, Type::Cmd, true, "Checking profiles for updates at startup...");
let profiles_to_update = {
let profiles = Config::profiles();
let profiles = profiles.latest();
profiles.items.as_ref()
.map_or_else(
Vec::new,
|items| items.iter()
.filter(|item| item.option.as_ref().is_some_and(|opt| opt.update_always == Some(true)))
.filter_map(|item| item.uid.clone())
.collect()
)
};
if profiles_to_update.is_empty() {
logging!(info, Type::Cmd, true, "No profiles to update immediately.");
return Ok(());
}
logging!(info, Type::Cmd, true, "Found profiles to update: {:?}", profiles_to_update);
let mut update_futures = Vec::new();
for uid in profiles_to_update {
update_futures.push(update_profile(uid, None));
}
let results = futures::future::join_all(update_futures).await;
if results.iter().any(|res| res.is_ok()) {
logging!(info, Type::Cmd, true, "The startup update is complete, restart the kernel...");
CoreManager::global().update_config().await.map_err(|e| e.to_string())?;
handle::Handle::refresh_clash();
} else {
logging!(warn, Type::Cmd, true, "All updates completed with errors on startup.");
}
Ok(())
}

View File

@@ -63,6 +63,10 @@ pub struct PrfItem {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub announce: Option<String>, pub announce: Option<String>,
/// profile announce url
#[serde(skip_serializing_if = "Option::is_none")]
pub announce_url: Option<String>,
/// the file data /// the file data
#[serde(skip)] #[serde(skip)]
pub file_data: Option<String>, pub file_data: Option<String>,
@@ -126,6 +130,9 @@ pub struct PrfOption {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub use_hwid: Option<bool>, pub use_hwid: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub update_always: Option<bool>,
} }
impl PrfOption { impl PrfOption {
@@ -146,6 +153,7 @@ impl PrfOption {
a.groups = b.groups.or(a.groups); a.groups = b.groups.or(a.groups);
a.timeout_seconds = b.timeout_seconds.or(a.timeout_seconds); a.timeout_seconds = b.timeout_seconds.or(a.timeout_seconds);
a.use_hwid = b.use_hwid.or(a.use_hwid); a.use_hwid = b.use_hwid.or(a.use_hwid);
a.update_always = b.update_always.or(a.update_always);
Some(a) Some(a)
} }
t => t.0.or(t.1), t => t.0.or(t.1),
@@ -246,6 +254,7 @@ impl PrfItem {
home: None, home: None,
support_url: None, support_url: None,
announce: None, announce: None,
announce_url: None,
updated: Some(chrono::Local::now().timestamp() as usize), updated: Some(chrono::Local::now().timestamp() as usize),
file_data: Some(file_data.unwrap_or(tmpl::ITEM_LOCAL.into())), file_data: Some(file_data.unwrap_or(tmpl::ITEM_LOCAL.into())),
}) })
@@ -267,7 +276,7 @@ impl PrfItem {
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);
let use_hwid = opt_ref.is_some_and(|o| o.use_hwid.unwrap_or(true)); let use_hwid = Config::verge().latest().enable_send_hwid.unwrap_or(true);
let mut merge = opt_ref.and_then(|o| o.merge.clone()); let mut merge = opt_ref.and_then(|o| o.merge.clone());
let mut script = opt_ref.and_then(|o| o.script.clone()); let mut script = opt_ref.and_then(|o| o.script.clone());
let mut rules = opt_ref.and_then(|o| o.rules.clone()); let mut rules = opt_ref.and_then(|o| o.rules.clone());
@@ -373,6 +382,11 @@ impl PrfItem {
}, },
}; };
let update_always = match header.get("update-always") {
Some(value) => value.to_str().unwrap_or("false").parse::<bool>().ok(),
None => None,
};
let home = match header.get("profile-web-page-url") { let home = match header.get("profile-web-page-url") {
Some(value) => { Some(value) => {
let str_value = value.to_str().unwrap_or(""); let str_value = value.to_str().unwrap_or("");
@@ -403,6 +417,14 @@ impl PrfItem {
None => None, None => None,
}; };
let announce_url = match header.get("announce-url") {
Some(value) => {
let str_value = value.to_str().unwrap_or("");
Some(str_value.to_string())
}
None => None,
};
let profile_title = match header.get("profile-title") { let profile_title = match header.get("profile-title") {
Some(value) => { Some(value) => {
let str_value = value.to_str().unwrap_or(""); let str_value = value.to_str().unwrap_or("");
@@ -472,6 +494,7 @@ impl PrfItem {
extra, extra,
option: Some(PrfOption { option: Some(PrfOption {
update_interval, update_interval,
update_always,
merge, merge,
script, script,
rules, rules,
@@ -482,6 +505,7 @@ impl PrfItem {
home, home,
support_url, support_url,
announce, announce,
announce_url,
updated: Some(chrono::Local::now().timestamp() as usize), updated: Some(chrono::Local::now().timestamp() as usize),
file_data: Some(data.into()), file_data: Some(data.into()),
}) })
@@ -511,6 +535,7 @@ impl PrfItem {
home: None, home: None,
support_url: None, support_url: None,
announce: None, announce: None,
announce_url: None,
updated: Some(chrono::Local::now().timestamp() as usize), updated: Some(chrono::Local::now().timestamp() as usize),
file_data: Some(template), file_data: Some(template),
}) })
@@ -535,6 +560,7 @@ impl PrfItem {
home: None, home: None,
support_url: None, support_url: None,
announce: None, announce: None,
announce_url: None,
selected: None, selected: None,
extra: None, extra: None,
option: None, option: None,
@@ -558,6 +584,7 @@ impl PrfItem {
home: None, home: None,
support_url: None, support_url: None,
announce: None, announce: None,
announce_url: None,
selected: None, selected: None,
extra: None, extra: None,
option: None, option: None,
@@ -581,6 +608,7 @@ impl PrfItem {
home: None, home: None,
support_url: None, support_url: None,
announce: None, announce: None,
announce_url: None,
selected: None, selected: None,
extra: None, extra: None,
option: None, option: None,
@@ -604,6 +632,7 @@ impl PrfItem {
home: None, home: None,
support_url: None, support_url: None,
announce: None, announce: None,
announce_url: None,
selected: None, selected: None,
extra: None, extra: None,
option: None, option: None,

View File

@@ -221,6 +221,7 @@ impl IProfiles {
each.updated = item.updated; each.updated = item.updated;
each.home = item.home; each.home = item.home;
each.announce = item.announce; each.announce = item.announce;
each.announce_url = item.announce_url;
each.support_url = item.support_url; each.support_url = item.support_url;
each.name = item.name; each.name = item.name;
each.url = item.url; each.url = item.url;

View File

@@ -74,6 +74,8 @@ pub struct IVerge {
/// enable dns settings - this controls whether dns_config.yaml is applied /// enable dns settings - this controls whether dns_config.yaml is applied
pub enable_dns_settings: Option<bool>, pub enable_dns_settings: Option<bool>,
pub enable_send_hwid: Option<bool>,
pub primary_action: Option<String>, pub primary_action: Option<String>,
/// always use default bypass /// always use default bypass
@@ -403,6 +405,7 @@ impl IVerge {
enable_auto_light_weight_mode: Some(false), enable_auto_light_weight_mode: Some(false),
auto_light_weight_minutes: Some(10), auto_light_weight_minutes: Some(10),
enable_dns_settings: Some(false), enable_dns_settings: Some(false),
enable_send_hwid: Some(true),
primary_action: Some("tun-mode".into()), primary_action: Some("tun-mode".into()),
home_cards: None, home_cards: None,
service_state: None, service_state: None,
@@ -492,6 +495,7 @@ impl IVerge {
patch!(enable_auto_light_weight_mode); patch!(enable_auto_light_weight_mode);
patch!(auto_light_weight_minutes); patch!(auto_light_weight_minutes);
patch!(enable_dns_settings); patch!(enable_dns_settings);
patch!(enable_send_hwid);
patch!(primary_action); patch!(primary_action);
patch!(home_cards); patch!(home_cards);
patch!(service_state); patch!(service_state);
@@ -588,6 +592,7 @@ pub struct IVergeResponse {
pub enable_auto_light_weight_mode: Option<bool>, pub enable_auto_light_weight_mode: Option<bool>,
pub auto_light_weight_minutes: Option<u64>, pub auto_light_weight_minutes: Option<u64>,
pub enable_dns_settings: Option<bool>, pub enable_dns_settings: Option<bool>,
pub enable_send_hwid: Option<bool>,
pub primary_action: Option<String>, pub primary_action: Option<String>,
pub home_cards: Option<serde_json::Value>, pub home_cards: Option<serde_json::Value>,
pub enable_hover_jump_navigator: Option<bool>, pub enable_hover_jump_navigator: Option<bool>,
@@ -661,6 +666,7 @@ impl From<IVerge> for IVergeResponse {
enable_auto_light_weight_mode: verge.enable_auto_light_weight_mode, enable_auto_light_weight_mode: verge.enable_auto_light_weight_mode,
auto_light_weight_minutes: verge.auto_light_weight_minutes, auto_light_weight_minutes: verge.auto_light_weight_minutes,
enable_dns_settings: verge.enable_dns_settings, enable_dns_settings: verge.enable_dns_settings,
enable_send_hwid: verge.enable_send_hwid,
primary_action: verge.primary_action, primary_action: verge.primary_action,
home_cards: verge.home_cards, home_cards: verge.home_cards,
enable_hover_jump_navigator: verge.enable_hover_jump_navigator, enable_hover_jump_navigator: verge.enable_hover_jump_navigator,

View File

@@ -216,6 +216,14 @@ pub fn run() {
app.manage(Mutex::new(state::proxy::CmdProxyState::default())); app.manage(Mutex::new(state::proxy::CmdProxyState::default()));
app.manage(Mutex::new(state::lightweight::LightWeightState::default())); app.manage(Mutex::new(state::lightweight::LightWeightState::default()));
tauri::async_runtime::spawn(async {
tokio::time::sleep(Duration::from_secs(5)).await;
logging!(info, Type::Cmd, true, "Running profile updates at startup...");
if let Err(e) = crate::cmd::update_profiles_on_startup().await {
log::error!("Failed to update profiles on startup: {}", e);
}
});
logging!(info, Type::Setup, true, "初始化完成,继续执行"); logging!(info, Type::Setup, true, "初始化完成,继续执行");
Ok(()) Ok(())
}) })
@@ -295,6 +303,7 @@ pub fn run() {
cmd::read_profile_file, cmd::read_profile_file,
cmd::save_profile_file, cmd::save_profile_file,
cmd::get_next_update_time, cmd::get_next_update_time,
cmd::update_profiles_on_startup,
// script validation // script validation
cmd::script_validate_notice, cmd::script_validate_notice,
cmd::validate_script_file, cmd::validate_script_file,

View File

@@ -552,33 +552,21 @@ pub async fn resolve_scheme(param: String) -> Result<()> {
if link_parsed.scheme() == "clash" || link_parsed.scheme() == "clash-verge" { if link_parsed.scheme() == "clash" || link_parsed.scheme() == "clash-verge" {
let mut name: Option<String> = None; let mut name: Option<String> = None;
let mut url_param: Option<String> = None; let mut url_param: Option<String> = None;
let mut use_hwid = true;
for (key, value) in link_parsed.query_pairs() { for (key, value) in link_parsed.query_pairs() {
match key.as_ref() { match key.as_ref() {
"name" => name = Some(value.into_owned()), "name" => name = Some(value.into_owned()),
"url" => url_param = Some(percent_decode_str(&value).decode_utf8_lossy().to_string()), "url" => url_param = Some(percent_decode_str(&value).decode_utf8_lossy().to_string()),
"hwid" => use_hwid = value == "1" || value == "true",
_ => {} _ => {}
} }
} }
let option = if use_hwid {
log::info!(target:"app", "HWID usage requested via deep link");
Some(PrfOption {
use_hwid: Some(true),
..Default::default()
})
} else {
None
};
match url_param { match url_param {
Some(url) => { Some(url) => {
log::info!(target:"app", "decoded subscription url: {url}"); log::info!(target:"app", "decoded subscription url: {url}");
create_window(false); create_window(false);
match PrfItem::from_url(url.as_ref(), name, None, option).await { match PrfItem::from_url(url.as_ref(), name, None, None).await {
Ok(item) => { Ok(item) => {
let uid = item.uid.clone().unwrap(); let uid = item.uid.clone().unwrap();
let _ = wrap_err!(Config::profiles().data().append_item(item)); let _ = wrap_err!(Config::profiles().data().append_item(item));

View File

@@ -1,5 +1,5 @@
{ {
"version": "0.2.0", "version": "0.2.1",
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"bundle": { "bundle": {
"active": true, "active": true,

View File

@@ -9,7 +9,7 @@
"timestampUrl": "", "timestampUrl": "",
"webviewInstallMode": { "webviewInstallMode": {
"type": "fixedRuntime", "type": "fixedRuntime",
"path": "./Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.arm64/" "path": "./Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.arm64/"
}, },
"nsis": { "nsis": {
"displayLanguageSelector": true, "displayLanguageSelector": true,

View File

@@ -9,7 +9,7 @@
"timestampUrl": "", "timestampUrl": "",
"webviewInstallMode": { "webviewInstallMode": {
"type": "fixedRuntime", "type": "fixedRuntime",
"path": "./Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.x64/" "path": "./Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.x64/"
}, },
"nsis": { "nsis": {
"displayLanguageSelector": true, "displayLanguageSelector": true,

View File

@@ -9,7 +9,7 @@
"timestampUrl": "", "timestampUrl": "",
"webviewInstallMode": { "webviewInstallMode": {
"type": "fixedRuntime", "type": "fixedRuntime",
"path": "./Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.x86/" "path": "./Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.x86/"
}, },
"nsis": { "nsis": {
"displayLanguageSelector": true, "displayLanguageSelector": true,

View File

@@ -447,6 +447,21 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
</FormItem> </FormItem>
)} )}
/> />
<FormField
control={control}
name="option.update_always"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between">
<FormLabel>{t("Update on Startup")}</FormLabel>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</FormItem>
)}
/>
<FormField <FormField
control={control} control={control}
name="option.with_proxy" name="option.with_proxy"

View File

@@ -43,6 +43,7 @@ import {
Power, Power,
BellOff, BellOff,
Repeat, Repeat,
Fingerprint
} from "lucide-react"; } from "lucide-react";
// Модальные окна // Модальные окна
@@ -390,6 +391,22 @@ const SettingSystem = ({ onError }: Props) => {
</Select> </Select>
</GuardState> </GuardState>
</SettingRow> </SettingRow>
<SettingRow
label={<LabelWithIcon icon={Fingerprint} text={t("Send HWID")} />}
>
<GuardState
value={verge?.enable_send_hwid ?? true} // По умолчанию включено
valueProps="checked"
onChangeProps="onCheckedChange"
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ enable_send_hwid: e })}
onGuard={(e) => patchVerge({ enable_send_hwid: e })}
onCatch={onError}
>
<Switch />
</GuardState>
</SettingRow>
</div> </div>
</div> </div>
); );

View File

@@ -660,5 +660,7 @@
"Show Advanced Settings": "Show Advanced Settings", "Show Advanced Settings": "Show Advanced Settings",
"Hide Advanced Settings": "Hide Advanced Settings", "Hide Advanced Settings": "Hide Advanced Settings",
"Main Toggle Action": "Main Toggle Action", "Main Toggle Action": "Main Toggle Action",
"Support": "Support" "Support": "Support",
"Update on Startup": "Update on Startup",
"Send HWID": "Send HWID"
} }

View File

@@ -612,5 +612,7 @@
"Show Advanced Settings": "Показать дополнительные настройки", "Show Advanced Settings": "Показать дополнительные настройки",
"Hide Advanced Settings": "Скрыть дополнительные настройки", "Hide Advanced Settings": "Скрыть дополнительные настройки",
"Main Toggle Action": "Действие главного переключателя", "Main Toggle Action": "Действие главного переключателя",
"Support": "Поддержка" "Support": "Поддержка",
"Update on Startup": "Обновлять при запуске",
"Send HWID": "Отправлять HWID"
} }

View File

@@ -50,11 +50,11 @@ const handleNoticeMessage = (
switch (status) { switch (status) {
case "import_sub_url::ok": case "import_sub_url::ok":
mutate("getProfiles"); mutate("getProfiles");
navigate("/profile", { state: { current: msg } }); navigate("/", { state: { activateProfile: msg } });
showNotice("success", t("Import Subscription Successful")); showNotice("success", t("Import Subscription Successful"));
window.dispatchEvent(new CustomEvent('activate-profile', { detail: msg }));
break; break;
case "import_sub_url::error": case "import_sub_url::error":
navigate("/profile");
showNotice("error", msg); showNotice("error", msg);
break; break;
case "set_config::error": case "set_config::error":

View File

@@ -1,5 +1,5 @@
import React, { useRef, useMemo, useCallback, useState } from "react"; import React, {useRef, useMemo, useCallback, useState, useEffect} from "react";
import { useNavigate } from "react-router-dom"; import { useLocation, useNavigate } from "react-router-dom";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { toast } from "sonner"; import { toast } from "sonner";
@@ -27,7 +27,7 @@ import {
AlertTriangle, AlertTriangle,
Loader2, Loader2,
Globe, Globe,
Send, Send, ExternalLink, RefreshCw,
} from "lucide-react"; } from "lucide-react";
import { useVerge } from "@/hooks/use-verge"; import { useVerge } from "@/hooks/use-verge";
import { useSystemState } from "@/hooks/use-system-state"; import { useSystemState } from "@/hooks/use-system-state";
@@ -37,14 +37,17 @@ import { ProxySelectors } from "@/components/home/proxy-selectors";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { closeAllConnections } from "@/services/api"; import { closeAllConnections } from "@/services/api";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { updateProfile } from "@/services/cmds";
const MinimalHomePage: React.FC = () => { const MinimalHomePage: React.FC = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const navigate = useNavigate(); const navigate = useNavigate();
const [isToggling, setIsToggling] = useState(false); const [isToggling, setIsToggling] = useState(false);
const [isUpdating, setIsUpdating] = useState(false);
const { profiles, patchProfiles, activateSelected, mutateProfiles } = const { profiles, patchProfiles, activateSelected, mutateProfiles } =
useProfiles(); useProfiles();
const viewerRef = useRef<ProfileViewerRef>(null); const viewerRef = useRef<ProfileViewerRef>(null);
const [uidToActivate, setUidToActivate] = useState<string | null>(null);
const profileItems = useMemo(() => { const profileItems = useMemo(() => {
const items = const items =
@@ -56,7 +59,7 @@ const MinimalHomePage: React.FC = () => {
const currentProfile = useMemo(() => { const currentProfile = useMemo(() => {
return profileItems.find(p => p.uid === profiles?.current); return profileItems.find(p => p.uid === profiles?.current);
}, [profileItems, profiles?.current]); }, [profileItems, profiles?.current]);
console.log(currentProfile); console.log("Current profile", currentProfile);
const currentProfileName = currentProfile?.name || profiles?.current; const currentProfileName = currentProfile?.name || profiles?.current;
const activateProfile = useCallback( const activateProfile = useCallback(
@@ -76,6 +79,28 @@ const MinimalHomePage: React.FC = () => {
[patchProfiles, activateSelected, mutateProfiles, t], [patchProfiles, activateSelected, mutateProfiles, t],
); );
useEffect(() => {
const handleActivationEvent = (event: Event) => {
const customEvent = event as CustomEvent<string>;
const profileId = customEvent.detail;
if (profileId) {
setUidToActivate(profileId);
}
};
window.addEventListener('activate-profile', handleActivationEvent);
return () => {
window.removeEventListener('activate-profile', handleActivationEvent);
};
}, []);
useEffect(() => {
if (uidToActivate && profileItems.some(p => p.uid === uidToActivate)) {
activateProfile(uidToActivate, false);
setUidToActivate(null);
}
}, [uidToActivate, profileItems, activateProfile]);
const handleProfileChange = useLockFn(async (uid: string) => { const handleProfileChange = useLockFn(async (uid: string) => {
if (profiles?.current === uid) return; if (profiles?.current === uid) return;
await activateProfile(uid, true); await activateProfile(uid, true);
@@ -128,6 +153,20 @@ const MinimalHomePage: React.FC = () => {
} }
}); });
const handleUpdateProfile = useLockFn(async () => {
if (!currentProfile?.uid || currentProfile.type !== 'remote') return;
setIsUpdating(true);
try {
await updateProfile(currentProfile.uid);
toast.success(t("Profile Updated Successfully"));
mutateProfiles(); // Обновляем данные в UI
} catch (err: any) {
toast.error(t("Failed to update profile"), { description: err.message });
} finally {
setIsUpdating(false);
}
});
const navMenuItems = [ const navMenuItems = [
{ label: "Profiles", path: "/profile" }, { label: "Profiles", path: "/profile" },
{ label: "Settings", path: "/settings" }, { label: "Settings", path: "/settings" },
@@ -141,42 +180,69 @@ const MinimalHomePage: React.FC = () => {
<div className="flex flex-col h-screen p-5"> <div className="flex flex-col h-screen p-5">
<header className="absolute top-0 left-0 right-0 p-5 flex items-center justify-between z-20"> <header className="absolute top-0 left-0 right-0 p-5 flex items-center justify-between z-20">
<div className="w-10"></div> <div className="w-10"></div>
<div className="flex flex-col items-center gap-2">
{profileItems.length > 0 && ( <div className="flex items-center gap-2">
<div className="flex-shrink-0"> {profileItems.length > 0 && (
<DropdownMenu> <div className="flex-shrink-0">
<DropdownMenuTrigger asChild> <DropdownMenu>
<Button <DropdownMenuTrigger asChild>
variant="outline" <Button
className="w-full max-w-[250px] sm:max-w-xs" variant="outline"
> className="w-full max-w-[250px] sm:max-w-xs"
<span className="truncate">{currentProfileName}</span> >
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" /> <span className="truncate">{currentProfileName}</span>
</Button> <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</DropdownMenuTrigger> </Button>
<DropdownMenuContent className="w-[--radix-dropdown-menu-trigger-width]"> </DropdownMenuTrigger>
<DropdownMenuLabel>{t("Profiles")}</DropdownMenuLabel> <DropdownMenuContent className="w-[--radix-dropdown-menu-trigger-width]">
<DropdownMenuSeparator /> <DropdownMenuLabel>{t("Profiles")}</DropdownMenuLabel>
{profileItems.map((p) => ( <DropdownMenuSeparator />
<DropdownMenuItem {profileItems.map((p) => (
key={p.uid} <DropdownMenuItem
onSelect={() => handleProfileChange(p.uid)} key={p.uid}
> onSelect={() => handleProfileChange(p.uid)}
<span className="flex-1 truncate">{p.name}</span> >
{profiles?.current === p.uid && ( <span className="flex-1 truncate">{p.name}</span>
<Check className="ml-4 h-4 w-4" /> {profiles?.current === p.uid && (
)} <Check className="ml-4 h-4 w-4" />
</DropdownMenuItem> )}
))} </DropdownMenuItem>
<DropdownMenuSeparator /> ))}
<DropdownMenuItem onSelect={() => viewerRef.current?.create()}> <DropdownMenuSeparator />
<PlusCircle className="mr-2 h-4 w-4" /> <DropdownMenuItem onSelect={() => viewerRef.current?.create()}>
<span>{t("Add Profile")}</span> <PlusCircle className="mr-2 h-4 w-4" />
</DropdownMenuItem> <span>{t("Add Profile")}</span>
</DropdownMenuContent> </DropdownMenuItem>
</DropdownMenu> </DropdownMenuContent>
</DropdownMenu>
</div>
)}
{currentProfile?.type === 'remote' && (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
onClick={handleUpdateProfile}
disabled={isUpdating}
className="flex-shrink-0"
>
{isUpdating ? (
<Loader2 className="h-5 w-5 animate-spin" />
) : (
<RefreshCw className="h-5 w-5" />
)}
</Button>
</TooltipTrigger>
<TooltipContent>
<p>{t("Update")}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
</div> </div>
)} </div>
<div className="w-10"> <div className="w-10">
<DropdownMenu> <DropdownMenu>
@@ -204,9 +270,24 @@ const MinimalHomePage: React.FC = () => {
<div className="flex items-center justify-center flex-grow w-full"> <div className="flex items-center justify-center flex-grow w-full">
<div className="flex flex-col items-center gap-8 pt-10"> <div className="flex flex-col items-center gap-8 pt-10">
{currentProfile?.announce && ( {currentProfile?.announce && (
<p className="relative -translate-y-15 text-xl font-semibold text-foreground max-w-lg text-center"> <div className="flex-shrink-0 flex justify-center text-center px-5">
{currentProfile.announce} {currentProfile.announce_url ? (
</p> <a
href={currentProfile.announce_url}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-2 text-base font-semibold text-foreground hover:underline hover:opacity-80 transition-all"
title={currentProfile.announce_url}
>
<span>{currentProfile.announce}</span>
<ExternalLink className="h-4 w-4 flex-shrink-0" />
</a>
) : (
<p className="text-base font-semibold text-foreground max-w-lg">
{currentProfile.announce}
</p>
)}
</div>
)} )}
<div className="text-center"> <div className="text-center">
<h1 <h1
@@ -286,7 +367,7 @@ const MinimalHomePage: React.FC = () => {
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<a href={currentProfile.support_url} target="_blank" rel="noopener noreferrer" className="transition-colors hover:text-primary"> <a href={currentProfile.support_url} target="_blank" rel="noopener noreferrer" className="transition-colors hover:text-primary">
{(currentProfile.support_url.includes('t.me') || currentProfile.support_url.includes('telegram')) ? ( {(currentProfile.support_url.includes('t.me') || currentProfile.support_url.includes('telegram') || currentProfile.support_url.startsWith('tg://')) ? (
<Send className="h-5 w-5" /> <Send className="h-5 w-5" />
) : ( ) : (
<Globe className="h-5 w-5" /> <Globe className="h-5 w-5" />

View File

@@ -203,6 +203,7 @@ interface IProfileItem {
home?: string; home?: string;
support_url?: string; support_url?: string;
announce?: string; announce?: string;
announce_url?: string;
} }
interface IProfileOption { interface IProfileOption {
@@ -210,6 +211,7 @@ interface IProfileOption {
with_proxy?: boolean; with_proxy?: boolean;
self_proxy?: boolean; self_proxy?: boolean;
update_interval?: number; update_interval?: number;
update_always?: boolean;
timeout_seconds?: number; timeout_seconds?: number;
danger_accept_invalid_certs?: boolean; danger_accept_invalid_certs?: boolean;
merge?: string; merge?: string;
@@ -752,6 +754,7 @@ interface IVergeConfig {
enable_global_hotkey?: boolean; enable_global_hotkey?: boolean;
enable_dns_settings?: boolean; enable_dns_settings?: boolean;
primary_action?: "tun-mode" | "system-proxy"; primary_action?: "tun-mode" | "system-proxy";
enable_send_hwid?: boolean;
proxy_auto_config?: boolean; proxy_auto_config?: boolean;
pac_file_content?: string; pac_file_content?: string;
proxy_host?: string; proxy_host?: string;