Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27bcc5f4f8 | ||
|
|
d884bd539b | ||
|
|
580a56727c | ||
|
|
ac3163d061 | ||
|
|
8bc7a6c3e1 | ||
|
|
31d368979e |
91
.github/workflows/release.yml
vendored
91
.github/workflows/release.yml
vendored
@@ -106,7 +106,6 @@ jobs:
|
||||
with:
|
||||
tagName: v__VERSION__
|
||||
releaseName: "Clash Verge Rev Lite v__VERSION__"
|
||||
releaseBody: "More new features are now supported."
|
||||
tauriScript: pnpm
|
||||
args: --target ${{ matrix.target }}
|
||||
|
||||
@@ -219,14 +218,13 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install jq
|
||||
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
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: v${{env.VERSION}}
|
||||
name: "Clash Verge Rev Lite v${{env.VERSION}}"
|
||||
body: "More new features are now supported."
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: |
|
||||
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||
@@ -275,8 +273,8 @@ jobs:
|
||||
|
||||
- name: Download WebView2 Runtime
|
||||
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
|
||||
Expand .\Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -F:* ./src-tauri
|
||||
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.133.0.3065.92.${{ matrix.arch }}.cab -F:* ./src-tauri
|
||||
Remove-Item .\src-tauri\tauri.windows.conf.json
|
||||
Rename-Item .\src-tauri\webview2.${{ matrix.arch }}.json tauri.windows.conf.json
|
||||
|
||||
@@ -317,7 +315,6 @@ jobs:
|
||||
with:
|
||||
tag_name: 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 }}
|
||||
files: src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*setup*
|
||||
|
||||
@@ -376,3 +373,85 @@ jobs:
|
||||
run: pnpm updater-fixed-webview2
|
||||
env:
|
||||
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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
- added handlers for "Announe", "Support-Url", "New-Sub-Domain", "Profile-Title" headers:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clash-verge",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"license": "GPL-3.0-only",
|
||||
"scripts": {
|
||||
"dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev",
|
||||
|
||||
@@ -49,9 +49,9 @@ async function resolvePortable() {
|
||||
zip.addLocalFolder(
|
||||
path.join(
|
||||
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");
|
||||
|
||||
|
||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -1061,7 +1061,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clash-verge"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"aes-gcm",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clash-verge"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
description = "clash verge"
|
||||
authors = ["zzzgydi", "wonfen", "MystiPanda", "coolcoala"]
|
||||
license = "GPL-3.0-only"
|
||||
|
||||
@@ -129,8 +129,24 @@ pub async fn enhance_profiles() -> CmdResult {
|
||||
/// 导入配置文件
|
||||
#[tauri::command]
|
||||
pub async fn import_profile(url: String, option: Option<PrfOption>) -> CmdResult {
|
||||
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
|
||||
wrap_err!(Config::profiles().data().append_item(item))
|
||||
let existing_uid = {
|
||||
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);
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ pub struct PrfItem {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub announce: Option<String>,
|
||||
|
||||
/// profile announce url
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub announce_url: Option<String>,
|
||||
|
||||
/// the file data
|
||||
#[serde(skip)]
|
||||
pub file_data: Option<String>,
|
||||
@@ -126,6 +130,9 @@ pub struct PrfOption {
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub use_hwid: Option<bool>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub update_always: Option<bool>,
|
||||
}
|
||||
|
||||
impl PrfOption {
|
||||
@@ -146,6 +153,7 @@ impl PrfOption {
|
||||
a.groups = b.groups.or(a.groups);
|
||||
a.timeout_seconds = b.timeout_seconds.or(a.timeout_seconds);
|
||||
a.use_hwid = b.use_hwid.or(a.use_hwid);
|
||||
a.update_always = b.update_always.or(a.update_always);
|
||||
Some(a)
|
||||
}
|
||||
t => t.0.or(t.1),
|
||||
@@ -246,6 +254,7 @@ impl PrfItem {
|
||||
home: None,
|
||||
support_url: None,
|
||||
announce: None,
|
||||
announce_url: None,
|
||||
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||
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 update_interval = opt_ref.and_then(|o| o.update_interval);
|
||||
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 script = opt_ref.and_then(|o| o.script.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") {
|
||||
Some(value) => {
|
||||
let str_value = value.to_str().unwrap_or("");
|
||||
@@ -403,6 +417,14 @@ impl PrfItem {
|
||||
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") {
|
||||
Some(value) => {
|
||||
let str_value = value.to_str().unwrap_or("");
|
||||
@@ -472,6 +494,7 @@ impl PrfItem {
|
||||
extra,
|
||||
option: Some(PrfOption {
|
||||
update_interval,
|
||||
update_always,
|
||||
merge,
|
||||
script,
|
||||
rules,
|
||||
@@ -482,6 +505,7 @@ impl PrfItem {
|
||||
home,
|
||||
support_url,
|
||||
announce,
|
||||
announce_url,
|
||||
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||
file_data: Some(data.into()),
|
||||
})
|
||||
@@ -511,6 +535,7 @@ impl PrfItem {
|
||||
home: None,
|
||||
support_url: None,
|
||||
announce: None,
|
||||
announce_url: None,
|
||||
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||
file_data: Some(template),
|
||||
})
|
||||
@@ -535,6 +560,7 @@ impl PrfItem {
|
||||
home: None,
|
||||
support_url: None,
|
||||
announce: None,
|
||||
announce_url: None,
|
||||
selected: None,
|
||||
extra: None,
|
||||
option: None,
|
||||
@@ -558,6 +584,7 @@ impl PrfItem {
|
||||
home: None,
|
||||
support_url: None,
|
||||
announce: None,
|
||||
announce_url: None,
|
||||
selected: None,
|
||||
extra: None,
|
||||
option: None,
|
||||
@@ -581,6 +608,7 @@ impl PrfItem {
|
||||
home: None,
|
||||
support_url: None,
|
||||
announce: None,
|
||||
announce_url: None,
|
||||
selected: None,
|
||||
extra: None,
|
||||
option: None,
|
||||
@@ -604,6 +632,7 @@ impl PrfItem {
|
||||
home: None,
|
||||
support_url: None,
|
||||
announce: None,
|
||||
announce_url: None,
|
||||
selected: None,
|
||||
extra: None,
|
||||
option: None,
|
||||
|
||||
@@ -221,6 +221,7 @@ impl IProfiles {
|
||||
each.updated = item.updated;
|
||||
each.home = item.home;
|
||||
each.announce = item.announce;
|
||||
each.announce_url = item.announce_url;
|
||||
each.support_url = item.support_url;
|
||||
each.name = item.name;
|
||||
each.url = item.url;
|
||||
|
||||
@@ -74,6 +74,8 @@ pub struct IVerge {
|
||||
/// enable dns settings - this controls whether dns_config.yaml is applied
|
||||
pub enable_dns_settings: Option<bool>,
|
||||
|
||||
pub enable_send_hwid: Option<bool>,
|
||||
|
||||
pub primary_action: Option<String>,
|
||||
|
||||
/// always use default bypass
|
||||
@@ -403,6 +405,7 @@ impl IVerge {
|
||||
enable_auto_light_weight_mode: Some(false),
|
||||
auto_light_weight_minutes: Some(10),
|
||||
enable_dns_settings: Some(false),
|
||||
enable_send_hwid: Some(true),
|
||||
primary_action: Some("tun-mode".into()),
|
||||
home_cards: None,
|
||||
service_state: None,
|
||||
@@ -492,6 +495,7 @@ impl IVerge {
|
||||
patch!(enable_auto_light_weight_mode);
|
||||
patch!(auto_light_weight_minutes);
|
||||
patch!(enable_dns_settings);
|
||||
patch!(enable_send_hwid);
|
||||
patch!(primary_action);
|
||||
patch!(home_cards);
|
||||
patch!(service_state);
|
||||
@@ -588,6 +592,7 @@ pub struct IVergeResponse {
|
||||
pub enable_auto_light_weight_mode: Option<bool>,
|
||||
pub auto_light_weight_minutes: Option<u64>,
|
||||
pub enable_dns_settings: Option<bool>,
|
||||
pub enable_send_hwid: Option<bool>,
|
||||
pub primary_action: Option<String>,
|
||||
pub home_cards: Option<serde_json::Value>,
|
||||
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,
|
||||
auto_light_weight_minutes: verge.auto_light_weight_minutes,
|
||||
enable_dns_settings: verge.enable_dns_settings,
|
||||
enable_send_hwid: verge.enable_send_hwid,
|
||||
primary_action: verge.primary_action,
|
||||
home_cards: verge.home_cards,
|
||||
enable_hover_jump_navigator: verge.enable_hover_jump_navigator,
|
||||
|
||||
@@ -216,6 +216,14 @@ pub fn run() {
|
||||
app.manage(Mutex::new(state::proxy::CmdProxyState::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, "初始化完成,继续执行");
|
||||
Ok(())
|
||||
})
|
||||
@@ -295,6 +303,7 @@ pub fn run() {
|
||||
cmd::read_profile_file,
|
||||
cmd::save_profile_file,
|
||||
cmd::get_next_update_time,
|
||||
cmd::update_profiles_on_startup,
|
||||
// script validation
|
||||
cmd::script_validate_notice,
|
||||
cmd::validate_script_file,
|
||||
|
||||
@@ -552,33 +552,21 @@ pub async fn resolve_scheme(param: String) -> Result<()> {
|
||||
if link_parsed.scheme() == "clash" || link_parsed.scheme() == "clash-verge" {
|
||||
let mut name: Option<String> = None;
|
||||
let mut url_param: Option<String> = None;
|
||||
let mut use_hwid = true;
|
||||
|
||||
for (key, value) in link_parsed.query_pairs() {
|
||||
match key.as_ref() {
|
||||
"name" => name = Some(value.into_owned()),
|
||||
"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 {
|
||||
Some(url) => {
|
||||
log::info!(target:"app", "decoded subscription url: {url}");
|
||||
|
||||
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) => {
|
||||
let uid = item.uid.clone().unwrap();
|
||||
let _ = wrap_err!(Config::profiles().data().append_item(item));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"bundle": {
|
||||
"active": true,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"timestampUrl": "",
|
||||
"webviewInstallMode": {
|
||||
"type": "fixedRuntime",
|
||||
"path": "./Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.arm64/"
|
||||
"path": "./Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.arm64/"
|
||||
},
|
||||
"nsis": {
|
||||
"displayLanguageSelector": true,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"timestampUrl": "",
|
||||
"webviewInstallMode": {
|
||||
"type": "fixedRuntime",
|
||||
"path": "./Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.x64/"
|
||||
"path": "./Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.x64/"
|
||||
},
|
||||
"nsis": {
|
||||
"displayLanguageSelector": true,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"timestampUrl": "",
|
||||
"webviewInstallMode": {
|
||||
"type": "fixedRuntime",
|
||||
"path": "./Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.x86/"
|
||||
"path": "./Microsoft.WebView2.FixedVersionRuntime.133.0.3065.92.x86/"
|
||||
},
|
||||
"nsis": {
|
||||
"displayLanguageSelector": true,
|
||||
|
||||
@@ -447,6 +447,21 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
||||
</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
|
||||
control={control}
|
||||
name="option.with_proxy"
|
||||
|
||||
@@ -43,6 +43,7 @@ import {
|
||||
Power,
|
||||
BellOff,
|
||||
Repeat,
|
||||
Fingerprint
|
||||
} from "lucide-react";
|
||||
|
||||
// Модальные окна
|
||||
@@ -390,6 +391,22 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
</Select>
|
||||
</GuardState>
|
||||
</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>
|
||||
);
|
||||
|
||||
@@ -660,5 +660,7 @@
|
||||
"Show Advanced Settings": "Show Advanced Settings",
|
||||
"Hide Advanced Settings": "Hide Advanced Settings",
|
||||
"Main Toggle Action": "Main Toggle Action",
|
||||
"Support": "Support"
|
||||
"Support": "Support",
|
||||
"Update on Startup": "Update on Startup",
|
||||
"Send HWID": "Send HWID"
|
||||
}
|
||||
|
||||
@@ -612,5 +612,7 @@
|
||||
"Show Advanced Settings": "Показать дополнительные настройки",
|
||||
"Hide Advanced Settings": "Скрыть дополнительные настройки",
|
||||
"Main Toggle Action": "Действие главного переключателя",
|
||||
"Support": "Поддержка"
|
||||
"Support": "Поддержка",
|
||||
"Update on Startup": "Обновлять при запуске",
|
||||
"Send HWID": "Отправлять HWID"
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ const handleNoticeMessage = (
|
||||
switch (status) {
|
||||
case "import_sub_url::ok":
|
||||
mutate("getProfiles");
|
||||
navigate("/profile", { state: { current: msg } });
|
||||
navigate("/", { state: { activateProfile: msg } });
|
||||
showNotice("success", t("Import Subscription Successful"));
|
||||
window.dispatchEvent(new CustomEvent('activate-profile', { detail: msg }));
|
||||
break;
|
||||
case "import_sub_url::error":
|
||||
navigate("/profile");
|
||||
showNotice("error", msg);
|
||||
break;
|
||||
case "set_config::error":
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useRef, useMemo, useCallback, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import React, {useRef, useMemo, useCallback, useState, useEffect} from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
AlertTriangle,
|
||||
Loader2,
|
||||
Globe,
|
||||
Send,
|
||||
Send, ExternalLink, RefreshCw,
|
||||
} from "lucide-react";
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
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 { closeAllConnections } from "@/services/api";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { updateProfile } from "@/services/cmds";
|
||||
|
||||
const MinimalHomePage: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [isToggling, setIsToggling] = useState(false);
|
||||
const [isUpdating, setIsUpdating] = useState(false);
|
||||
const { profiles, patchProfiles, activateSelected, mutateProfiles } =
|
||||
useProfiles();
|
||||
const viewerRef = useRef<ProfileViewerRef>(null);
|
||||
const [uidToActivate, setUidToActivate] = useState<string | null>(null);
|
||||
|
||||
const profileItems = useMemo(() => {
|
||||
const items =
|
||||
@@ -56,7 +59,7 @@ const MinimalHomePage: React.FC = () => {
|
||||
const currentProfile = useMemo(() => {
|
||||
return profileItems.find(p => p.uid === profiles?.current);
|
||||
}, [profileItems, profiles?.current]);
|
||||
console.log(currentProfile);
|
||||
console.log("Current profile", currentProfile);
|
||||
const currentProfileName = currentProfile?.name || profiles?.current;
|
||||
|
||||
const activateProfile = useCallback(
|
||||
@@ -76,6 +79,28 @@ const MinimalHomePage: React.FC = () => {
|
||||
[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) => {
|
||||
if (profiles?.current === uid) return;
|
||||
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 = [
|
||||
{ label: "Profiles", path: "/profile" },
|
||||
{ label: "Settings", path: "/settings" },
|
||||
@@ -141,42 +180,69 @@ const MinimalHomePage: React.FC = () => {
|
||||
<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">
|
||||
<div className="w-10"></div>
|
||||
|
||||
{profileItems.length > 0 && (
|
||||
<div className="flex-shrink-0">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
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" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-[--radix-dropdown-menu-trigger-width]">
|
||||
<DropdownMenuLabel>{t("Profiles")}</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
{profileItems.map((p) => (
|
||||
<DropdownMenuItem
|
||||
key={p.uid}
|
||||
onSelect={() => handleProfileChange(p.uid)}
|
||||
>
|
||||
<span className="flex-1 truncate">{p.name}</span>
|
||||
{profiles?.current === p.uid && (
|
||||
<Check className="ml-4 h-4 w-4" />
|
||||
)}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onSelect={() => viewerRef.current?.create()}>
|
||||
<PlusCircle className="mr-2 h-4 w-4" />
|
||||
<span>{t("Add Profile")}</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
{profileItems.length > 0 && (
|
||||
<div className="flex-shrink-0">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
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" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-[--radix-dropdown-menu-trigger-width]">
|
||||
<DropdownMenuLabel>{t("Profiles")}</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
{profileItems.map((p) => (
|
||||
<DropdownMenuItem
|
||||
key={p.uid}
|
||||
onSelect={() => handleProfileChange(p.uid)}
|
||||
>
|
||||
<span className="flex-1 truncate">{p.name}</span>
|
||||
{profiles?.current === p.uid && (
|
||||
<Check className="ml-4 h-4 w-4" />
|
||||
)}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onSelect={() => viewerRef.current?.create()}>
|
||||
<PlusCircle className="mr-2 h-4 w-4" />
|
||||
<span>{t("Add Profile")}</span>
|
||||
</DropdownMenuItem>
|
||||
</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 className="w-10">
|
||||
<DropdownMenu>
|
||||
@@ -204,9 +270,24 @@ const MinimalHomePage: React.FC = () => {
|
||||
<div className="flex items-center justify-center flex-grow w-full">
|
||||
<div className="flex flex-col items-center gap-8 pt-10">
|
||||
{currentProfile?.announce && (
|
||||
<p className="relative -translate-y-15 text-xl font-semibold text-foreground max-w-lg text-center">
|
||||
{currentProfile.announce}
|
||||
</p>
|
||||
<div className="flex-shrink-0 flex justify-center text-center px-5">
|
||||
{currentProfile.announce_url ? (
|
||||
<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">
|
||||
<h1
|
||||
@@ -286,7 +367,7 @@ const MinimalHomePage: React.FC = () => {
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<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" />
|
||||
) : (
|
||||
<Globe className="h-5 w-5" />
|
||||
|
||||
3
src/services/types.d.ts
vendored
3
src/services/types.d.ts
vendored
@@ -203,6 +203,7 @@ interface IProfileItem {
|
||||
home?: string;
|
||||
support_url?: string;
|
||||
announce?: string;
|
||||
announce_url?: string;
|
||||
}
|
||||
|
||||
interface IProfileOption {
|
||||
@@ -210,6 +211,7 @@ interface IProfileOption {
|
||||
with_proxy?: boolean;
|
||||
self_proxy?: boolean;
|
||||
update_interval?: number;
|
||||
update_always?: boolean;
|
||||
timeout_seconds?: number;
|
||||
danger_accept_invalid_certs?: boolean;
|
||||
merge?: string;
|
||||
@@ -752,6 +754,7 @@ interface IVergeConfig {
|
||||
enable_global_hotkey?: boolean;
|
||||
enable_dns_settings?: boolean;
|
||||
primary_action?: "tun-mode" | "system-proxy";
|
||||
enable_send_hwid?: boolean;
|
||||
proxy_auto_config?: boolean;
|
||||
pac_file_content?: string;
|
||||
proxy_host?: string;
|
||||
|
||||
Reference in New Issue
Block a user