Compare commits
19 Commits
15
.github/workflows/release.yml
vendored
15
.github/workflows/release.yml
vendored
@@ -258,12 +258,23 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
submit-to-winget:
|
||||
runs-on: windows-latest
|
||||
runs-on: ubuntu-latest
|
||||
needs: [release-update]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get Version
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install jq
|
||||
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||
- name: Submit to Winget
|
||||
uses: vedantmgoyal9/winget-releaser@main
|
||||
with:
|
||||
identifier: ClashVergeRev.ClashVergeRev
|
||||
version: ${{env.VERSION}}
|
||||
release-tag: v${{env.VERSION}}
|
||||
installers-regex: '_(arm64|x64|x86)-setup\.exe$'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
token: ${{ secrets.WINGET_TOKEN }}
|
||||
|
||||
26
UPDATELOG.md
26
UPDATELOG.md
@@ -1,4 +1,28 @@
|
||||
## v1.7.4
|
||||
## v1.7.6
|
||||
|
||||
### Notice
|
||||
|
||||
- Clash Verge Rev 目前已进入稳定周期,日后更新将着重于 bug 修复与内核常规升级
|
||||
|
||||
### Features
|
||||
|
||||
- Meta(mihomo)内核升级 1.18.7
|
||||
- 界面细节调整
|
||||
- 优化服务模式安装逻辑
|
||||
- 移除无用的 console log
|
||||
- 能自动选择第一个订阅
|
||||
|
||||
### Bugs Fixes
|
||||
|
||||
- 修复服务模式安装问题
|
||||
- 修复 Mac 下的代理绕过 CIDR 写法过滤
|
||||
- 修复 32 位升级 URL
|
||||
- 修复不同分组 URL 测试地址配置无效的问题
|
||||
- 修复 Web UI 下的一处 hostname 参数
|
||||
|
||||
---
|
||||
|
||||
## v1.7.5
|
||||
|
||||
### Features
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clash-verge",
|
||||
"version": "1.7.4",
|
||||
"version": "1.7.6",
|
||||
"license": "GPL-3.0-only",
|
||||
"scripts": {
|
||||
"dev": "tauri dev",
|
||||
|
||||
@@ -72,12 +72,12 @@ async function resolveUpdater() {
|
||||
}
|
||||
|
||||
// win32 url
|
||||
if (name.endsWith("x64-setup.nsis.zip")) {
|
||||
if (name.endsWith("x86-setup.nsis.zip")) {
|
||||
updateData.platforms["windows-x86"].url = browser_download_url;
|
||||
updateData.platforms["windows-i686"].url = browser_download_url;
|
||||
}
|
||||
// win32 signature
|
||||
if (name.endsWith("x64-setup.nsis.zip.sig")) {
|
||||
if (name.endsWith("x86-setup.nsis.zip.sig")) {
|
||||
const sig = await getSignature(browser_download_url);
|
||||
updateData.platforms["windows-x86"].signature = sig;
|
||||
updateData.platforms["windows-i686"].signature = sig;
|
||||
|
||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -790,7 +790,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clash-verge"
|
||||
version = "1.7.4"
|
||||
version = "1.7.6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"auto-launch",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clash-verge"
|
||||
version = "1.7.4"
|
||||
version = "1.7.6"
|
||||
description = "clash verge"
|
||||
authors = ["zzzgydi", "wonfen", "MystiPanda"]
|
||||
license = "GPL-3.0-only"
|
||||
|
||||
@@ -389,13 +389,13 @@ pub mod service {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn install_service() -> CmdResult {
|
||||
wrap_err!(service::install_service().await)
|
||||
pub async fn install_service(passwd: String) -> CmdResult {
|
||||
wrap_err!(service::install_service(passwd).await)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn uninstall_service() -> CmdResult {
|
||||
wrap_err!(service::uninstall_service().await)
|
||||
pub async fn uninstall_service(passwd: String) -> CmdResult {
|
||||
wrap_err!(service::uninstall_service(passwd).await)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ impl IProfiles {
|
||||
if item.uid.is_none() {
|
||||
bail!("the uid should not be null");
|
||||
}
|
||||
let uid = item.uid.clone();
|
||||
|
||||
// save the file data
|
||||
// move the field value after save
|
||||
@@ -128,6 +129,12 @@ impl IProfiles {
|
||||
.with_context(|| format!("failed to write to file \"{}\"", file))?;
|
||||
}
|
||||
|
||||
if self.current.is_none()
|
||||
&& (item.itype == Some("remote".to_string()) || item.itype == Some("local".to_string()))
|
||||
{
|
||||
self.current = uid;
|
||||
}
|
||||
|
||||
if self.items.is_none() {
|
||||
self.items = Some(vec![]);
|
||||
}
|
||||
@@ -135,6 +142,7 @@ impl IProfiles {
|
||||
if let Some(items) = self.items.as_mut() {
|
||||
items.push(item)
|
||||
}
|
||||
|
||||
self.save_file()
|
||||
}
|
||||
|
||||
@@ -355,10 +363,15 @@ impl IProfiles {
|
||||
}
|
||||
// delete the original uid
|
||||
if current == uid {
|
||||
self.current = match !items.is_empty() {
|
||||
true => items[0].uid.clone(),
|
||||
false => None,
|
||||
};
|
||||
self.current = None;
|
||||
for item in items.iter() {
|
||||
if item.itype == Some("remote".to_string())
|
||||
|| item.itype == Some("local".to_string())
|
||||
{
|
||||
self.current = item.uid.clone();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.items = Some(items);
|
||||
|
||||
@@ -28,11 +28,19 @@ pub struct JsonResponse {
|
||||
pub data: Option<ResponseBody>,
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn sudo(passwd: &String, cmd: String) -> StdCommand {
|
||||
let shell = format!("echo \"{}\" | sudo -S {}", passwd, cmd);
|
||||
let mut command = StdCommand::new("bash");
|
||||
command.arg("-c").arg(shell);
|
||||
command
|
||||
}
|
||||
|
||||
/// Install the Clash Verge Service
|
||||
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
|
||||
///
|
||||
#[cfg(target_os = "windows")]
|
||||
pub async fn install_service() -> Result<()> {
|
||||
pub async fn install_service(_passwd: String) -> Result<()> {
|
||||
use deelevate::{PrivilegeLevel, Token};
|
||||
use runas::Command as RunasCommand;
|
||||
use std::os::windows::process::CommandExt;
|
||||
@@ -65,30 +73,45 @@ pub async fn install_service() -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub async fn install_service() -> Result<()> {
|
||||
pub async fn install_service(passwd: String) -> Result<()> {
|
||||
use users::get_effective_uid;
|
||||
|
||||
let binary_path = dirs::service_path()?;
|
||||
let installer_path = binary_path.with_file_name("install-service");
|
||||
|
||||
if !installer_path.exists() {
|
||||
bail!("installer not found");
|
||||
}
|
||||
|
||||
let elevator = crate::utils::unix_helper::linux_elevator();
|
||||
let status = match get_effective_uid() {
|
||||
0 => StdCommand::new(installer_path).status()?,
|
||||
_ => StdCommand::new(elevator)
|
||||
.arg("sh")
|
||||
.arg("-c")
|
||||
.arg(installer_path)
|
||||
.status()?,
|
||||
let output = match get_effective_uid() {
|
||||
0 => {
|
||||
StdCommand::new("chmod")
|
||||
.arg("+x")
|
||||
.arg(installer_path.clone())
|
||||
.output()?;
|
||||
StdCommand::new("chmod")
|
||||
.arg("+x")
|
||||
.arg(binary_path)
|
||||
.output()?;
|
||||
StdCommand::new(installer_path.clone()).output()?
|
||||
}
|
||||
_ => {
|
||||
sudo(
|
||||
&passwd,
|
||||
format!("chmod +x {}", installer_path.to_string_lossy()),
|
||||
)
|
||||
.output()?;
|
||||
sudo(
|
||||
&passwd,
|
||||
format!("chmod +x {}", binary_path.to_string_lossy()),
|
||||
)
|
||||
.output()?;
|
||||
sudo(&passwd, format!("{}", installer_path.to_string_lossy())).output()?
|
||||
}
|
||||
};
|
||||
|
||||
if !status.success() {
|
||||
if !output.status.success() {
|
||||
bail!(
|
||||
"failed to install service with status {}",
|
||||
status.code().unwrap()
|
||||
"failed to install service with error: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -96,7 +119,7 @@ pub async fn install_service() -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub async fn install_service() -> Result<()> {
|
||||
pub async fn install_service(passwd: String) -> Result<()> {
|
||||
let binary_path = dirs::service_path()?;
|
||||
let installer_path = binary_path.with_file_name("install-service");
|
||||
|
||||
@@ -104,22 +127,24 @@ pub async fn install_service() -> Result<()> {
|
||||
bail!("installer not found");
|
||||
}
|
||||
|
||||
let _ = StdCommand::new("chmod")
|
||||
.arg("+x")
|
||||
.arg(installer_path.to_string_lossy().replace(" ", "\\ "))
|
||||
.output();
|
||||
sudo(
|
||||
&passwd,
|
||||
format!(
|
||||
"chmod +x {}",
|
||||
installer_path.to_string_lossy().replace(" ", "\\ ")
|
||||
),
|
||||
)
|
||||
.output()?;
|
||||
let output = sudo(
|
||||
&passwd,
|
||||
format!("{}", installer_path.to_string_lossy().replace(" ", "\\ ")),
|
||||
)
|
||||
.output()?;
|
||||
|
||||
let shell = installer_path.to_string_lossy().replace(" ", "\\\\ ");
|
||||
let command = format!(r#"do shell script "{shell}" with administrator privileges"#);
|
||||
|
||||
let status = StdCommand::new("osascript")
|
||||
.args(vec!["-e", &command])
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
if !output.status.success() {
|
||||
bail!(
|
||||
"failed to install service with status {}",
|
||||
status.code().unwrap()
|
||||
"failed to install service with error: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,7 +153,7 @@ pub async fn install_service() -> Result<()> {
|
||||
/// Uninstall the Clash Verge Service
|
||||
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
|
||||
#[cfg(target_os = "windows")]
|
||||
pub async fn uninstall_service() -> Result<()> {
|
||||
pub async fn uninstall_service(_passwd: String) -> Result<()> {
|
||||
use deelevate::{PrivilegeLevel, Token};
|
||||
use runas::Command as RunasCommand;
|
||||
use std::os::windows::process::CommandExt;
|
||||
@@ -161,7 +186,7 @@ pub async fn uninstall_service() -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub async fn uninstall_service() -> Result<()> {
|
||||
pub async fn uninstall_service(passwd: String) -> Result<()> {
|
||||
use users::get_effective_uid;
|
||||
|
||||
let binary_path = dirs::service_path()?;
|
||||
@@ -171,20 +196,29 @@ pub async fn uninstall_service() -> Result<()> {
|
||||
bail!("uninstaller not found");
|
||||
}
|
||||
|
||||
let elevator = crate::utils::unix_helper::linux_elevator();
|
||||
let status = match get_effective_uid() {
|
||||
0 => StdCommand::new(uninstaller_path).status()?,
|
||||
_ => StdCommand::new(elevator)
|
||||
.arg("sh")
|
||||
.arg("-c")
|
||||
.arg(uninstaller_path)
|
||||
.status()?,
|
||||
let output = match get_effective_uid() {
|
||||
0 => {
|
||||
StdCommand::new("chmod")
|
||||
.arg("+x")
|
||||
.arg(uninstaller_path.clone())
|
||||
.output()?;
|
||||
StdCommand::new(uninstaller_path.clone()).output()?
|
||||
}
|
||||
_ => {
|
||||
sudo(
|
||||
&passwd,
|
||||
format!("chmod +x {}", uninstaller_path.to_string_lossy()),
|
||||
)
|
||||
.output()?;
|
||||
|
||||
sudo(&passwd, format!("{}", uninstaller_path.to_string_lossy())).output()?
|
||||
}
|
||||
};
|
||||
|
||||
if !status.success() {
|
||||
if !output.status.success() {
|
||||
bail!(
|
||||
"failed to install service with status {}",
|
||||
status.code().unwrap()
|
||||
"failed to install service with error: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,7 +226,7 @@ pub async fn uninstall_service() -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub async fn uninstall_service() -> Result<()> {
|
||||
pub async fn uninstall_service(passwd: String) -> Result<()> {
|
||||
let binary_path = dirs::service_path()?;
|
||||
let uninstaller_path = binary_path.with_file_name("uninstall-service");
|
||||
|
||||
@@ -200,17 +234,24 @@ pub async fn uninstall_service() -> Result<()> {
|
||||
bail!("uninstaller not found");
|
||||
}
|
||||
|
||||
let shell = uninstaller_path.to_string_lossy().replace(" ", "\\\\ ");
|
||||
let command = format!(r#"do shell script "{shell}" with administrator privileges"#);
|
||||
sudo(
|
||||
&passwd,
|
||||
format!(
|
||||
"chmod +x {}",
|
||||
uninstaller_path.to_string_lossy().replace(" ", "\\ ")
|
||||
),
|
||||
)
|
||||
.output()?;
|
||||
let output = sudo(
|
||||
&passwd,
|
||||
format!("{}", uninstaller_path.to_string_lossy().replace(" ", "\\ ")),
|
||||
)
|
||||
.output()?;
|
||||
|
||||
let status = StdCommand::new("osascript")
|
||||
.args(vec!["-e", &command])
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
if !output.status.success() {
|
||||
bail!(
|
||||
"failed to install service with status {}",
|
||||
status.code().unwrap()
|
||||
"failed to uninstall service with error: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,11 +191,15 @@ pub fn init_config() -> Result<()> {
|
||||
/// after tauri setup
|
||||
pub fn init_resources() -> Result<()> {
|
||||
let app_dir = dirs::app_home_dir()?;
|
||||
let test_dir = app_dir.join("test");
|
||||
let res_dir = dirs::app_resources_dir()?;
|
||||
|
||||
if !app_dir.exists() {
|
||||
let _ = fs::create_dir_all(&app_dir);
|
||||
}
|
||||
if !test_dir.exists() {
|
||||
let _ = fs::create_dir_all(&test_dir);
|
||||
}
|
||||
if !res_dir.exists() {
|
||||
let _ = fs::create_dir_all(&res_dir);
|
||||
}
|
||||
@@ -210,9 +214,10 @@ pub fn init_resources() -> Result<()> {
|
||||
for file in file_list.iter() {
|
||||
let src_path = res_dir.join(file);
|
||||
let dest_path = app_dir.join(file);
|
||||
let test_dest_path = test_dir.join(file);
|
||||
|
||||
let handle_copy = || {
|
||||
match fs::copy(&src_path, &dest_path) {
|
||||
let handle_copy = |dest: &PathBuf| {
|
||||
match fs::copy(&src_path, dest) {
|
||||
Ok(_) => log::debug!(target: "app", "resources copied '{file}'"),
|
||||
Err(err) => {
|
||||
log::error!(target: "app", "failed to copy resources '{file}', {err}")
|
||||
@@ -220,8 +225,11 @@ pub fn init_resources() -> Result<()> {
|
||||
};
|
||||
};
|
||||
|
||||
if src_path.exists() && !test_dest_path.exists() {
|
||||
handle_copy(&test_dest_path);
|
||||
}
|
||||
if src_path.exists() && !dest_path.exists() {
|
||||
handle_copy();
|
||||
handle_copy(&dest_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -231,14 +239,14 @@ pub fn init_resources() -> Result<()> {
|
||||
match (src_modified, dest_modified) {
|
||||
(Ok(src_modified), Ok(dest_modified)) => {
|
||||
if src_modified > dest_modified {
|
||||
handle_copy();
|
||||
handle_copy(&dest_path);
|
||||
} else {
|
||||
log::debug!(target: "app", "skipping resource copy '{file}'");
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
log::debug!(target: "app", "failed to get modified '{file}'");
|
||||
handle_copy();
|
||||
handle_copy(&dest_path);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,4 +4,3 @@ pub mod init;
|
||||
pub mod resolve;
|
||||
pub mod server;
|
||||
pub mod tmpl;
|
||||
pub mod unix_helper;
|
||||
|
||||
@@ -8,6 +8,7 @@ use serde_yaml::Mapping;
|
||||
use std::net::TcpListener;
|
||||
use tauri::api::notification;
|
||||
use tauri::{App, AppHandle, Manager};
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
use window_shadows::set_shadow;
|
||||
|
||||
pub static VERSION: OnceCell<String> = OnceCell::new();
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn linux_elevator() -> &'static str {
|
||||
use std::process::Command;
|
||||
match Command::new("which").arg("pkexec").output() {
|
||||
Ok(output) => {
|
||||
if output.stdout.is_empty() {
|
||||
"sudo"
|
||||
} else {
|
||||
"pkexec"
|
||||
}
|
||||
}
|
||||
Err(_) => "sudo",
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
||||
"package": {
|
||||
"productName": "Clash Verge",
|
||||
"version": "1.7.4"
|
||||
"version": "1.7.6"
|
||||
},
|
||||
"build": {
|
||||
"distDir": "../dist",
|
||||
|
||||
@@ -723,7 +723,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
throw new Error(t("Group Name Already Exists"));
|
||||
}
|
||||
}
|
||||
setPrependSeq([...prependSeq, formIns.getValues()]);
|
||||
setPrependSeq([formIns.getValues(), ...prependSeq]);
|
||||
} catch (err: any) {
|
||||
Notice.error(err.message || err.toString());
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
startIcon={<VerticalAlignTopRounded />}
|
||||
onClick={() => {
|
||||
let proxies = handleParse();
|
||||
setPrependSeq([...prependSeq, ...proxies]);
|
||||
setPrependSeq([...proxies, ...prependSeq]);
|
||||
}}
|
||||
>
|
||||
{t("Prepend Proxy")}
|
||||
|
||||
@@ -543,7 +543,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
try {
|
||||
let raw = validateRule();
|
||||
if (prependSeq.includes(raw)) return;
|
||||
setPrependSeq([...prependSeq, raw]);
|
||||
setPrependSeq([raw, ...prependSeq]);
|
||||
} catch (err: any) {
|
||||
Notice.error(err.message || err.toString());
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import delayManager from "@/services/delay";
|
||||
|
||||
interface Props {
|
||||
sx?: SxProps;
|
||||
url?: string;
|
||||
groupName: string;
|
||||
headState: HeadState;
|
||||
onLocation: () => void;
|
||||
@@ -29,7 +30,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export const ProxyHead = (props: Props) => {
|
||||
const { sx = {}, groupName, headState, onHeadState } = props;
|
||||
const { sx = {}, url, groupName, headState, onHeadState } = props;
|
||||
|
||||
const { showType, sortType, filterText, textState, testUrl } = headState;
|
||||
|
||||
@@ -45,7 +46,10 @@ export const ProxyHead = (props: Props) => {
|
||||
const { verge } = useVerge();
|
||||
|
||||
useEffect(() => {
|
||||
delayManager.setUrl(groupName, testUrl || verge?.default_latency_test!);
|
||||
delayManager.setUrl(
|
||||
groupName,
|
||||
testUrl || url || verge?.default_latency_test!
|
||||
);
|
||||
}, [groupName, testUrl, verge?.default_latency_test]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -129,6 +129,7 @@ export const ProxyRender = (props: RenderProps) => {
|
||||
return (
|
||||
<ProxyHead
|
||||
sx={{ pl: 2, pr: 3, mt: indent ? 1 : 0.5, mb: 1 }}
|
||||
url={group.testUrl}
|
||||
groupName={group.name}
|
||||
headState={headState!}
|
||||
onLocation={() => onLocation(group)}
|
||||
|
||||
@@ -24,7 +24,6 @@ export const NetworkInterfaceViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
getNetworkInterfacesInfo().then((res) => {
|
||||
console.log(res);
|
||||
setNetworkInterfaces(res);
|
||||
});
|
||||
}, [open]);
|
||||
@@ -49,9 +48,8 @@ export const NetworkInterfaceViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
</Box>
|
||||
}
|
||||
contentSx={{ width: 450, maxHeight: 330 }}
|
||||
okBtn={t("Save")}
|
||||
cancelBtn={t("Cancel")}
|
||||
onClose={() => setOpen(false)}
|
||||
disableOk
|
||||
cancelBtn={t("Close")}
|
||||
onCancel={() => setOpen(false)}
|
||||
>
|
||||
{networkInterfaces.map((item) => (
|
||||
@@ -116,7 +114,7 @@ const AddressDisplay = (props: { label: string; content: string }) => {
|
||||
<Box
|
||||
sx={({ palette }) => ({
|
||||
borderRadius: "8px",
|
||||
padding: "2px",
|
||||
padding: "2px 2px 2px 8px",
|
||||
background:
|
||||
palette.mode === "dark"
|
||||
? alpha(palette.background.paper, 0.3)
|
||||
|
||||
54
src/components/setting/mods/password-input.tsx
Normal file
54
src/components/setting/mods/password-input.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
TextField,
|
||||
} from "@mui/material";
|
||||
|
||||
interface Props {
|
||||
onConfirm: (passwd: string) => Promise<void>;
|
||||
}
|
||||
|
||||
export const PasswordInput = (props: Props) => {
|
||||
const { onConfirm } = props;
|
||||
|
||||
const { t } = useTranslation();
|
||||
const [passwd, setPasswd] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<Dialog open={true} maxWidth="xs" fullWidth>
|
||||
<DialogTitle>{t("Please enter your root password")}</DialogTitle>
|
||||
|
||||
<DialogContent>
|
||||
<TextField
|
||||
sx={{ mt: 1 }}
|
||||
autoFocus
|
||||
label={t("Password")}
|
||||
fullWidth
|
||||
size="small"
|
||||
type="password"
|
||||
value={passwd}
|
||||
onKeyDown={(e) => e.key === "Enter" && onConfirm(passwd)}
|
||||
onChange={(e) => setPasswd(e.target.value)}
|
||||
></TextField>
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={async () => await onConfirm(passwd)}
|
||||
variant="contained"
|
||||
>
|
||||
{t("Confirm")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
@@ -5,6 +5,8 @@ import { useTranslation } from "react-i18next";
|
||||
import { installService, uninstallService } from "@/services/cmds";
|
||||
import { Notice } from "@/components/base";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { PasswordInput } from "./password-input";
|
||||
import getSystem from "@/utils/get-system";
|
||||
|
||||
interface Props {
|
||||
status: "active" | "installed" | "unknown" | "uninstall";
|
||||
@@ -15,7 +17,7 @@ interface Props {
|
||||
|
||||
export const ServiceSwitcher = (props: Props) => {
|
||||
const { status, mutate, patchVerge, onChangeData } = props;
|
||||
|
||||
const isWindows = getSystem() === "windows";
|
||||
const isActive = status === "active";
|
||||
const isInstalled = status === "installed";
|
||||
const isUninstall = status === "uninstall" || status === "unknown";
|
||||
@@ -23,40 +25,33 @@ export const ServiceSwitcher = (props: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const [serviceLoading, setServiceLoading] = useState(false);
|
||||
const [uninstallServiceLoaing, setUninstallServiceLoading] = useState(false);
|
||||
const [openInstall, setOpenInstall] = useState(false);
|
||||
const [openUninstall, setOpenUninstall] = useState(false);
|
||||
|
||||
const onInstallOrEnableService = useLockFn(async () => {
|
||||
setServiceLoading(true);
|
||||
async function install(passwd: string) {
|
||||
try {
|
||||
if (isUninstall) {
|
||||
// install service
|
||||
await installService();
|
||||
await mutate();
|
||||
setTimeout(() => {
|
||||
mutate();
|
||||
}, 2000);
|
||||
Notice.success(t("Service Installed Successfully"));
|
||||
setServiceLoading(false);
|
||||
} else {
|
||||
// enable or disable service
|
||||
await patchVerge({ enable_service_mode: !isActive });
|
||||
onChangeData({ enable_service_mode: !isActive });
|
||||
await mutate();
|
||||
setTimeout(() => {
|
||||
mutate();
|
||||
}, 2000);
|
||||
setServiceLoading(false);
|
||||
}
|
||||
setOpenInstall(false);
|
||||
await installService(passwd);
|
||||
await mutate();
|
||||
setTimeout(() => {
|
||||
mutate();
|
||||
}, 2000);
|
||||
Notice.success(t("Service Installed Successfully"));
|
||||
setServiceLoading(false);
|
||||
} catch (err: any) {
|
||||
await mutate();
|
||||
setTimeout(() => {
|
||||
mutate();
|
||||
}, 2000);
|
||||
Notice.error(err.message || err.toString());
|
||||
setServiceLoading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const onUninstallService = useLockFn(async () => {
|
||||
setUninstallServiceLoading(true);
|
||||
async function uninstall(passwd: string) {
|
||||
try {
|
||||
await uninstallService();
|
||||
setOpenUninstall(false);
|
||||
await uninstallService(passwd);
|
||||
await mutate();
|
||||
setTimeout(() => {
|
||||
mutate();
|
||||
@@ -65,13 +60,55 @@ export const ServiceSwitcher = (props: Props) => {
|
||||
setUninstallServiceLoading(false);
|
||||
} catch (err: any) {
|
||||
await mutate();
|
||||
setTimeout(() => {
|
||||
mutate();
|
||||
}, 2000);
|
||||
Notice.error(err.message || err.toString());
|
||||
setUninstallServiceLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const onInstallOrEnableService = useLockFn(async () => {
|
||||
setServiceLoading(true);
|
||||
if (isUninstall) {
|
||||
// install service
|
||||
if (isWindows) {
|
||||
await install("");
|
||||
} else {
|
||||
setOpenInstall(true);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
// enable or disable service
|
||||
await patchVerge({ enable_service_mode: !isActive });
|
||||
onChangeData({ enable_service_mode: !isActive });
|
||||
await mutate();
|
||||
setTimeout(() => {
|
||||
mutate();
|
||||
}, 2000);
|
||||
setServiceLoading(false);
|
||||
} catch (err: any) {
|
||||
await mutate();
|
||||
Notice.error(err.message || err.toString());
|
||||
setServiceLoading(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const onUninstallService = useLockFn(async () => {
|
||||
setUninstallServiceLoading(true);
|
||||
if (isWindows) {
|
||||
await uninstall("");
|
||||
} else {
|
||||
setOpenUninstall(true);
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
{openInstall && <PasswordInput onConfirm={install} />}
|
||||
{openUninstall && <PasswordInput onConfirm={uninstall} />}
|
||||
|
||||
<LoadingButton
|
||||
size="small"
|
||||
variant={isUninstall ? "outlined" : "contained"}
|
||||
|
||||
@@ -34,17 +34,22 @@ const domain_tld_part = String.raw`(?:\w{2,64}\*?|\*)`;
|
||||
const rDomainSimple = domain_subdomain_part + domain_tld_part;
|
||||
|
||||
const ipv4_part = String.raw`\d{1,3}`;
|
||||
// 127.0.0.1 (full ipv4)
|
||||
const rIPv4 = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}`;
|
||||
// const rIPv4Partial = String.raw`${ipv4_part}\.(?:(?:${ipv4_part}|\*)\.){0,2}\.\*`;
|
||||
|
||||
const ipv6_part = "(?:[a-fA-F0-9:])+";
|
||||
const rIPv6 = `(?:${ipv6_part}:+)+${ipv6_part}`;
|
||||
|
||||
const rLocal = `localhost|<local>|localdomain`;
|
||||
const rValidPart = `${rDomainSimple}|${rIPv4}|${rIPv6}|${rLocal}`;
|
||||
|
||||
const getValidReg = (isWindows: boolean) => {
|
||||
// 127.0.0.1 (full ipv4)
|
||||
const rIPv4Unix = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}(?:\/\d{1,2})?`;
|
||||
const rIPv4Windows = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}`;
|
||||
|
||||
const rIPv6Unix = String.raw`(?:${ipv6_part}:+)+${ipv6_part}(?:\/\d{1,3})?`;
|
||||
const rIPv6Windows = String.raw`(?:${ipv6_part}:+)+${ipv6_part}`;
|
||||
|
||||
const rValidPart = `${rDomainSimple}|${
|
||||
isWindows ? rIPv4Windows : rIPv4Unix
|
||||
}|${isWindows ? rIPv6Windows : rIPv6Unix}|${rLocal}`;
|
||||
const separator = isWindows ? ";" : ",";
|
||||
const rValid = String.raw`^(${rValidPart})(?:${separator}\s?(${rValidPart}))*${separator}?$`;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export const WebUIViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
|
||||
const webUIList = verge?.web_ui_list || [
|
||||
"https://metacubex.github.io/metacubexd/#/setup?http=true&hostname=%host&port=%port&secret=%secret",
|
||||
"https://yacd.metacubex.one/?host=%host&port=%port&secret=%secret",
|
||||
"https://yacd.metacubex.one/?hostname=%host&port=%port&secret=%secret",
|
||||
];
|
||||
|
||||
const handleAdd = useLockFn(async (value: string) => {
|
||||
|
||||
@@ -28,7 +28,7 @@ interface Props {
|
||||
onDelete: (uid: string) => void;
|
||||
}
|
||||
|
||||
let eventListener: UnlistenFn | null = null;
|
||||
let eventListener: UnlistenFn = () => {};
|
||||
|
||||
export const TestItem = (props: Props) => {
|
||||
const { itemData, onEdit, onDelete: onDeleteItem } = props;
|
||||
@@ -90,9 +90,7 @@ export const TestItem = (props: Props) => {
|
||||
];
|
||||
|
||||
const listenTsetEvent = async () => {
|
||||
if (eventListener !== null) {
|
||||
eventListener();
|
||||
}
|
||||
eventListener();
|
||||
eventListener = await listen("verge://test-all", () => {
|
||||
onDelay();
|
||||
});
|
||||
@@ -100,7 +98,7 @@ export const TestItem = (props: Props) => {
|
||||
|
||||
useEffect(() => {
|
||||
listenTsetEvent();
|
||||
}, []);
|
||||
}, [url]);
|
||||
|
||||
return (
|
||||
<Box
|
||||
|
||||
@@ -267,6 +267,7 @@
|
||||
"Release Version": "Release Version",
|
||||
"Alpha Version": "Alpha Version",
|
||||
"Please Enable Service Mode": "Please Install and Enable Service Mode First",
|
||||
"Please enter your root password": "Please enter your root password",
|
||||
"Grant": "Grant",
|
||||
"Open UWP tool": "Open UWP tool",
|
||||
"Open UWP tool Info": "Since Windows 8, UWP apps (such as Microsoft Store) are restricted from directly accessing local host network services, and this tool can be used to bypass this restriction",
|
||||
|
||||
@@ -262,6 +262,7 @@
|
||||
"Release Version": "نسخه نهایی",
|
||||
"Alpha Version": "نسخه آلفا",
|
||||
"Please Install and Enable Service Mode First": "لطفاً ابتدا حالت سرویس را نصب و فعال کنید",
|
||||
"Please enter your root password": "لطفاً رمز ریشه خود را وارد کنید",
|
||||
"Grant": "اعطا",
|
||||
"Open UWP tool": "باز کردن ابزار UWP",
|
||||
"Open UWP tool Info": "از ویندوز 8 به بعد، برنامههای UWP (مانند Microsoft Store) از دسترسی مستقیم به خدمات شبکه محلی محدود شدهاند و این ابزار میتواند برای دور زدن این محدودیت استفاده شود",
|
||||
|
||||
@@ -265,6 +265,7 @@
|
||||
"Release Version": "Официальная версия",
|
||||
"Alpha Version": "Альфа-версия",
|
||||
"Please Enable Service Mode": "Пожалуйста, сначала установите и включите режим обслуживания",
|
||||
"Please enter your root password": "Пожалуйста, введите ваш пароль root",
|
||||
"Grant": "Предоставить",
|
||||
"Open UWP tool": "Открыть UWP инструмент",
|
||||
"Open UWP tool Info": "С Windows 8 приложения UWP (такие как Microsoft Store) ограничены в прямом доступе к сетевым службам локального хоста, и этот инструмент позволяет обойти это ограничение",
|
||||
|
||||
@@ -267,6 +267,7 @@
|
||||
"Release Version": "正式版",
|
||||
"Alpha Version": "预览版",
|
||||
"Please Enable Service Mode": "请先安装并启用服务模式",
|
||||
"Please enter your root password": "请输入您的 root 密码",
|
||||
"Grant": "授权",
|
||||
"Open UWP tool": "UWP 工具",
|
||||
"Open UWP tool Info": "Windows 8开始限制 UWP 应用(如微软商店)直接访问本地主机的网络服务,使用此工具可绕过该限制",
|
||||
|
||||
@@ -201,12 +201,12 @@ export async function checkService() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function installService() {
|
||||
return invoke<void>("install_service");
|
||||
export async function installService(passwd: string) {
|
||||
return invoke<void>("install_service", { passwd });
|
||||
}
|
||||
|
||||
export async function uninstallService() {
|
||||
return invoke<void>("uninstall_service");
|
||||
export async function uninstallService(passwd: string) {
|
||||
return invoke<void>("uninstall_service", { passwd });
|
||||
}
|
||||
|
||||
export async function invoke_uwp_tool() {
|
||||
|
||||
1
src/services/types.d.ts
vendored
1
src/services/types.d.ts
vendored
@@ -59,6 +59,7 @@ interface IProxyItem {
|
||||
time: string;
|
||||
delay: number;
|
||||
}[];
|
||||
testUrl?: string;
|
||||
all?: string[];
|
||||
now?: string;
|
||||
hidden?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user