21 Commits

Author SHA1 Message Date
GyDi
b2a24c7abd v0.0.22 2022-03-10 02:27:00 +08:00
GyDi
732a1f4694 chore: rm dead code 2022-03-10 02:25:35 +08:00
GyDi
4c5aa7084e fix: external-controller 2022-03-10 02:19:06 +08:00
GyDi
fe1fea671c feat: support more options for remote profile 2022-03-10 02:03:55 +08:00
GyDi
04c754c0ac chore: reduce icon size on macOS 2022-03-10 01:04:53 +08:00
GyDi
754c22c84e chore: adjust icon 2022-03-10 00:04:59 +08:00
GyDi
629331870b chore: add linux link 2022-03-09 20:14:15 +08:00
GyDi
78774315cb feat: linux system proxy 2022-03-09 19:48:32 +08:00
GyDi
36b9c07928 chore: update deps 2022-03-09 02:36:40 +08:00
GyDi
40a818630d fix: change proxy bypass on mac 2022-03-09 02:36:03 +08:00
GyDi
568511a4cf fix: kill sidecars after install still in test 2022-03-09 02:09:51 +08:00
GyDi
109fb39e09 fix: log some error 2022-03-09 02:00:56 +08:00
GyDi
68450d2042 chore: rename productName 2022-03-09 01:53:34 +08:00
GyDi
8a052bbed6 chore: update tauri version 2022-03-09 01:50:37 +08:00
GyDi
3afbb56640 fix: apply_blur parameter 2022-03-08 10:44:41 +08:00
GyDi
c0ad84a491 fix: limit enhanced profile range 2022-03-08 01:45:46 +08:00
GyDi
c72f17605c chore: update deps 2022-03-08 01:18:20 +08:00
GyDi
42fbee0cdb chore: add default bypass 2022-03-08 00:39:09 +08:00
GyDi
e9b7ec735f fix: profile updated field 2022-03-07 01:41:42 +08:00
GyDi
743788135f fix: profile field check 2022-03-07 01:30:32 +08:00
GyDi
8ea3e6fa26 fix: create dir panic 2022-03-07 01:06:21 +08:00
23 changed files with 574 additions and 269 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "clash-verge",
"version": "0.0.21",
"version": "0.0.22",
"license": "GPL-3.0",
"scripts": {
"dev": "tauri dev",
@@ -19,7 +19,7 @@
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.4.4",
"@mui/material": "^5.4.4",
"@tauri-apps/api": "^1.0.0-rc.1",
"@tauri-apps/api": "^1.0.0-rc.2",
"ahooks": "^3.1.13",
"axios": "^0.26.0",
"dayjs": "^1.10.8",
@@ -32,7 +32,7 @@
},
"devDependencies": {
"@actions/github": "^5.0.0",
"@tauri-apps/cli": "^1.0.0-rc.5",
"@tauri-apps/cli": "^1.0.0-rc.7",
"@types/fs-extra": "^9.0.13",
"@types/js-cookie": "^3.0.1",
"@types/react": "^17.0.0",

View File

@@ -6,6 +6,7 @@ import fetch from "node-fetch";
import { execSync } from "child_process";
const cwd = process.cwd();
const FORCE = process.argv.includes("--force");
const CLASH_URL_PREFIX =
"https://github.com/Dreamacro/clash/releases/download/premium/";
@@ -19,9 +20,10 @@ function resolveClash() {
// todo
const map = {
"win32-x64": "clash-windows-386",
"win32-x64": "clash-windows-amd64",
"darwin-x64": "clash-darwin-amd64",
"darwin-arm64": "clash-darwin-arm64",
"linux-x64": "clash-linux-amd64",
};
const name = map[`${platform}-${arch}`];
@@ -51,7 +53,7 @@ async function resolveSidecar() {
const sidecarPath = path.join(sidecarDir, sidecarFile);
await fs.mkdirp(sidecarDir);
if (await fs.pathExists(sidecarPath)) return;
if (!FORCE && (await fs.pathExists(sidecarPath))) return;
// download sidecar
const binInfo = resolveClash();
@@ -98,7 +100,7 @@ async function resolveMmdb() {
const resDir = path.join(cwd, "src-tauri", "resources");
const resPath = path.join(resDir, "Country.mmdb");
if (await fs.pathExists(resPath)) return;
if (!FORCE && (await fs.pathExists(resPath))) return;
await fs.mkdirp(resDir);
await downloadFile(url, resPath);
}

203
src-tauri/Cargo.lock generated
View File

@@ -34,9 +34,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.55"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
[[package]]
name = "arc-swap"
@@ -147,9 +147,9 @@ dependencies = [
[[package]]
name = "async-task"
version = "4.1.0"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8"
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9"
[[package]]
name = "async-trait"
@@ -180,8 +180,8 @@ version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6"
dependencies = [
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"system-deps 6.0.2",
]
@@ -317,27 +317,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "bzip2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0"
dependencies = [
"bzip2-sys",
"libc",
]
[[package]]
name = "bzip2-sys"
version = "0.1.11+1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "cache-padded"
version = "1.2.0"
@@ -363,7 +342,7 @@ version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
dependencies = [
"glib-sys 0.15.6",
"glib-sys 0.15.7",
"libc",
"system-deps 6.0.2",
]
@@ -1173,9 +1152,9 @@ version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413424d9818621fa3cfc8a3a915cdb89a7c3c507d56761b4ec83a9a98e587171"
dependencies = [
"gio-sys 0.15.6",
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"gio-sys 0.15.7",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"system-deps 6.0.2",
]
@@ -1188,9 +1167,9 @@ checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88"
dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
"gio-sys 0.15.6",
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"gio-sys 0.15.7",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"pango-sys",
"pkg-config",
@@ -1204,7 +1183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b7f8c7a84b407aa9b143877e267e848ff34106578b64d1e0a24bf550716178"
dependencies = [
"gdk-sys",
"glib-sys 0.15.6",
"glib-sys 0.15.7",
"libc",
"system-deps 6.0.2",
"x11",
@@ -1257,15 +1236,15 @@ dependencies = [
[[package]]
name = "gio"
version = "0.15.6"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96efd8a1c00d890f6b45671916e165b5e43ccec61957d443aff6d7e44f62d348"
checksum = "bb50e113645fba48bc36c8abaee1fe5e43d353e8763966e29dfe69660514e461"
dependencies = [
"bitflags",
"futures-channel",
"futures-core",
"futures-io",
"gio-sys 0.15.6",
"gio-sys 0.15.7",
"glib",
"libc",
"once_cell",
@@ -1287,12 +1266,12 @@ dependencies = [
[[package]]
name = "gio-sys"
version = "0.15.6"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d0fa5052773f5a56b8ae47dab09d040f5d9ce1311f4f99006e16e9a08269296"
checksum = "9cb5dabebbb63c5cf763c9d9cb120280bf1a442cc496e17fd78ff75272d68244"
dependencies = [
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"system-deps 6.0.2",
"winapi",
@@ -1300,9 +1279,9 @@ dependencies = [
[[package]]
name = "glib"
version = "0.15.6"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa570813c504bdf7539a9400180c2dd4b789a819556fb86da7226d7d1b037b49"
checksum = "eb53a1102178803a8ea21d383a4332238e42988be61a97819be583bbb405e969"
dependencies = [
"bitflags",
"futures-channel",
@@ -1310,8 +1289,8 @@ dependencies = [
"futures-executor",
"futures-task",
"glib-macros",
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"once_cell",
"smallvec",
@@ -1345,9 +1324,9 @@ dependencies = [
[[package]]
name = "glib-sys"
version = "0.15.6"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4366377bd56697de8aaee24e673c575d2694d72e7756324ded2b0428829a7b8"
checksum = "19289e4953dad38c9fea1c5c52cc594f29afc4a70802822ef382dca356b27bfd"
dependencies = [
"libc",
"system-deps 6.0.2",
@@ -1385,11 +1364,11 @@ dependencies = [
[[package]]
name = "gobject-sys"
version = "0.15.5"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df6859463843c20cf3837e3a9069b6ab2051aeeadf4c899d33344f4aea83189a"
checksum = "db362c9cb92af37a8d58cedb3464ff307485dcc463e46b298f1da1bda60f78b0"
dependencies = [
"glib-sys 0.15.6",
"glib-sys 0.15.7",
"libc",
"system-deps 6.0.2",
]
@@ -1427,9 +1406,9 @@ dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
"gdk-sys",
"gio-sys 0.15.6",
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"gio-sys 0.15.7",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"pango-sys",
"system-deps 6.0.2",
@@ -1710,9 +1689,9 @@ dependencies = [
[[package]]
name = "ipnet"
version = "2.3.1"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"
checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c"
[[package]]
name = "itertools"
@@ -1752,8 +1731,8 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "905fbb87419c5cde6e3269537e4ea7d46431f3008c5d057e915ef3f115e7793c"
dependencies = [
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"system-deps 5.0.0",
]
@@ -2209,18 +2188,18 @@ dependencies = [
[[package]]
name = "num_enum"
version = "0.5.6"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad"
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
dependencies = [
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.5.6"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21"
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
dependencies = [
"proc-macro-crate 1.1.3",
"proc-macro2",
@@ -2235,6 +2214,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
"objc_exception",
]
[[package]]
@@ -2248,6 +2228,15 @@ dependencies = [
"objc_id",
]
[[package]]
name = "objc_exception"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"
dependencies = [
"cc",
]
[[package]]
name = "objc_id"
version = "0.1.1"
@@ -2259,9 +2248,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.9.0"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
[[package]]
name = "opaque-debug"
@@ -2271,9 +2260,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "open"
version = "2.1.0"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a82915836ef43159bb6a3c64d884c42329ccd0b8afdca737cf1e3dd701709dc"
checksum = "9213e7b66aa06a7722828ee2980c1adff22a3922b582baaa1e62e30ca2a6c018"
dependencies = [
"pathdiff",
"winapi",
@@ -2343,9 +2332,9 @@ dependencies = [
[[package]]
name = "pango"
version = "0.15.6"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c7420fc01a390ec200da7395b64d705f5d82fe03e5d0708aee422c46538be7"
checksum = "a159678be05876e40e1bb4e93db9c9e2f86986fac010b3630feab1273f83b605"
dependencies = [
"bitflags",
"glib",
@@ -2360,8 +2349,8 @@ version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7022c2fb88cd2d9d55e1a708a8c53a3ae8678234c4a54bf623400aeb7f31fac2"
dependencies = [
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"libc",
"system-deps 6.0.2",
]
@@ -2853,9 +2842,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.4"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",
@@ -2931,8 +2920,8 @@ dependencies = [
"ashpd",
"block",
"dispatch",
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"gtk-sys",
"js-sys",
"lazy_static",
@@ -3293,9 +3282,9 @@ dependencies = [
[[package]]
name = "siphasher"
version = "0.3.9"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e"
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]]
name = "slab"
@@ -3473,9 +3462,9 @@ dependencies = [
[[package]]
name = "tao"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c4c62fc16d698750c5c918088c8134c63e8661e65efc608fe614236c59462f4"
checksum = "6a01ed3d6141768e0e36bfe3910f24511022c3dfb977810b00c518d507d4ead4"
dependencies = [
"bitflags",
"cairo-rs",
@@ -3491,7 +3480,7 @@ dependencies = [
"gdkx11-sys",
"gio",
"glib",
"glib-sys 0.15.6",
"glib-sys 0.15.7",
"gtk",
"instant",
"lazy_static",
@@ -3538,9 +3527,9 @@ dependencies = [
[[package]]
name = "tauri"
version = "1.0.0-rc.3"
version = "1.0.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0c4a4ffd1f9b02cc3e974ce902f8132fb3d08ec6cce4ca193f97d921f5bce4"
checksum = "1112a78b3de89c41e01b671d62f24038d324c6cb61708896ee16f533b655c82e"
dependencies = [
"anyhow",
"attohttpc",
@@ -3558,6 +3547,7 @@ dependencies = [
"gtk",
"http",
"ignore",
"memchr",
"minisign-verify",
"once_cell",
"open",
@@ -3584,14 +3574,15 @@ dependencies = [
"tokio",
"url",
"uuid",
"windows",
"zip",
]
[[package]]
name = "tauri-build"
version = "1.0.0-rc.3"
version = "1.0.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "855e47d8cfb2219fc14d2eed2c09bfb35f9ecd71a40ca2084aeeee2d23e0b60d"
checksum = "d7e31905edc1b40f369beccbbfb30b2e44c2f2bb1ffc06a3778d844af4a81da8"
dependencies = [
"anyhow",
"cargo_toml",
@@ -3602,12 +3593,14 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "1.0.0-rc.2"
version = "1.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eef4656d174ba982198266da0c016573fe6c7c760e4290f05c8c384fe180007e"
checksum = "fbcba93e945eb73ee232621763a1295247d0155867bb72e815ab107a10a7cf97"
dependencies = [
"base64",
"blake3",
"ico",
"png 0.16.8",
"proc-macro2",
"quote",
"regex",
@@ -3623,9 +3616,9 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "1.0.0-rc.2"
version = "1.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0993f5a867e321d26200b2d6394cdf482bd6cc5a0e4691bcabf811544f51cd4"
checksum = "ed251657dcdd21922e0146af5f8a3b9ccf92707d4a42add615c250ff92a6838d"
dependencies = [
"heck 0.4.0",
"proc-macro2",
@@ -3637,9 +3630,9 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "851cd65e2c9df4dd70a4f9e115fb2441ac89f1c80df79de0c15a448b4acd7768"
checksum = "ae0442d935c2d168541d74be51c4d4f176b1c00ee6bf052f07c1aa5f688ba497"
dependencies = [
"gtk",
"http",
@@ -3656,14 +3649,11 @@ dependencies = [
[[package]]
name = "tauri-runtime-wry"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0184f95e065fb80afadf53f0a5f87a75af2da774d0524fe8cb2976fbec4a0bf2"
checksum = "643aaa56237304264804dbf34748b21042eadda71d2e964bced1651c19cc0314"
dependencies = [
"gtk",
"ico",
"infer",
"png 0.16.8",
"tauri-runtime",
"tauri-utils",
"uuid",
@@ -3674,9 +3664,9 @@ dependencies = [
[[package]]
name = "tauri-utils"
version = "1.0.0-rc.2"
version = "1.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ad38ad698838886bf22ecb91c4b3d1ce178fdff7901ac7bff370103a4f51e59"
checksum = "21f11483d205c77d1ec398e80566485101696335983e69832cc6c41ab1e07266"
dependencies = [
"ctor",
"glob",
@@ -4280,10 +4270,10 @@ dependencies = [
"gdk",
"gdk-sys",
"gio",
"gio-sys 0.15.6",
"gio-sys 0.15.7",
"glib",
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"gtk",
"gtk-sys",
"javascriptcore-rs",
@@ -4303,9 +4293,9 @@ dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
"gdk-sys",
"gio-sys 0.15.6",
"glib-sys 0.15.6",
"gobject-sys 0.15.5",
"gio-sys 0.15.7",
"glib-sys 0.15.7",
"gobject-sys 0.15.7",
"gtk-sys",
"javascriptcore-rs-sys",
"libc",
@@ -4411,8 +4401,8 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "window-shadows"
version = "0.0.0"
source = "git+https://github.com/tauri-apps/window-shadows#72de826498573de6bed48038bbc74a3dbde7460e"
version = "0.1.0"
source = "git+https://github.com/tauri-apps/window-shadows#71c656abf892313e0a91d56ddf8bef5d80bd2a22"
dependencies = [
"cocoa",
"objc",
@@ -4423,7 +4413,7 @@ dependencies = [
[[package]]
name = "window-vibrancy"
version = "0.1.0"
source = "git+https://github.com/tauri-apps/window-vibrancy#3fd5be20535ec9b595e893b75dc74b6725664852"
source = "git+https://github.com/tauri-apps/window-vibrancy#c91cd362e0758fe93cf41a740d2e00a668523fe8"
dependencies = [
"cocoa",
"objc",
@@ -4768,11 +4758,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815"
dependencies = [
"byteorder",
"bzip2",
"crc32fast",
"flate2",
"thiserror",
"time",
]
[[package]]

View File

@@ -10,7 +10,7 @@ edition = "2021"
build = "build.rs"
[build-dependencies]
tauri-build = { version = "1.0.0-rc.3", features = [] }
tauri-build = { version = "1.0.0-rc.4", features = [] }
[dependencies]
anyhow = "1.0"
@@ -21,7 +21,7 @@ chrono = "0.4.19"
serde_json = "1.0"
serde_yaml = "0.8"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-rc.3", features = ["shell-all", "system-tray", "updater", "window-all"] }
tauri = { version = "1.0.0-rc.4", features = ["shell-all", "system-tray", "updater", "window-all"] }
window-shadows = { git = "https://github.com/tauri-apps/window-shadows" }
window-vibrancy = { git = "https://github.com/tauri-apps/window-vibrancy" }

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

View File

@@ -1,5 +1,5 @@
use crate::{
core::{ClashInfo, PrfItem, Profiles, VergeConfig},
core::{ClashInfo, PrfItem, PrfOption, Profiles, VergeConfig},
states::{ClashState, ProfilesState, VergeState},
utils::{dirs, sysopt::SysProxyConfig},
};
@@ -28,10 +28,10 @@ pub fn sync_profiles(profiles_state: State<'_, ProfilesState>) -> Result<(), Str
#[tauri::command]
pub async fn import_profile(
url: String,
with_proxy: bool,
option: Option<PrfOption>,
profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> {
let item = wrap_err!(PrfItem::from_url(&url, None, None, with_proxy).await)?;
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
let mut profiles = profiles_state.0.lock().unwrap();
wrap_err!(profiles.append_item(item))
@@ -55,7 +55,7 @@ pub async fn create_profile(
#[tauri::command]
pub async fn update_profile(
index: String,
with_proxy: bool,
option: Option<PrfOption>,
clash_state: State<'_, ClashState>,
profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> {
@@ -71,7 +71,7 @@ pub async fn update_profile(
item.url.clone().unwrap()
};
let item = wrap_err!(PrfItem::from_url(&url, None, None, with_proxy).await)?;
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
let mut profiles = profiles_state.0.lock().unwrap();
wrap_err!(profiles.update_item(index.clone(), item))?;
@@ -181,21 +181,23 @@ pub fn view_profile(index: String, profiles_state: State<'_, ProfilesState>) ->
{
use std::os::windows::process::CommandExt;
return match Command::new(code)
if let Err(err) = Command::new(code)
.creation_flags(0x08000000)
.arg(path)
.spawn()
{
Ok(_) => Ok(()),
Err(_) => Err("failed to open file by VScode".into()),
};
log::error!("{err}");
return Err("failed to open file by VScode".into());
}
}
#[cfg(not(target_os = "windows"))]
return match Command::new(code).arg(path).spawn() {
Ok(_) => Ok(()),
Err(_) => Err("failed to open file by VScode".into()),
};
if let Err(err) = Command::new(code).arg(path).spawn() {
log::error!("{err}");
return Err("failed to open file by VScode".into());
}
return Ok(());
}
open_path_cmd(path, "failed to open file by `open`")
@@ -317,19 +319,21 @@ fn open_path_cmd(dir: PathBuf, err_str: &str) -> Result<(), String> {
{
use std::os::windows::process::CommandExt;
match Command::new("explorer")
if let Err(err) = Command::new("explorer")
.creation_flags(0x08000000)
.arg(dir)
.spawn()
{
Ok(_) => Ok(()),
Err(_) => Err(err_str.into()),
log::error!("{err}");
return Err(err_str.into());
}
}
#[cfg(not(target_os = "windows"))]
match Command::new("open").arg(dir).spawn() {
Ok(_) => Ok(()),
Err(_) => Err(err_str.into()),
if let Err(err) = Command::new("open").arg(dir).spawn() {
log::error!("{err}");
return Err(err_str.into());
}
return Ok(());
}

View File

@@ -258,8 +258,14 @@ impl Clash {
config::save_yaml(temp_path.clone(), &config, Some("# Clash Verge Temp File"))?;
tauri::async_runtime::spawn(async move {
// `external-controller` could be
// "127.0.0.1:9090" or ":9090"
// Todo: maybe it could support single port
let server = info.server.unwrap();
let server = format!("http://{server}/configs");
let server = match server.starts_with(":") {
true => format!("http://127.0.0.1{server}/configs"),
false => format!("http://{server}/configs"),
};
let mut headers = HeaderMap::new();
headers.insert("Content-Type", "application/json".parse().unwrap());
@@ -320,9 +326,28 @@ impl Clash {
let result: PrfEnhancedResult = serde_json::from_str(result).unwrap();
if let Some(data) = result.data {
// all of these can not be revised by script
// http/https/socks port should be under control
let not_allow: Vec<Value> = vec![
"port",
"socks-port",
"mixed-port",
"allow-lan",
"mode",
"external-controller",
"secret",
"log-level",
]
.iter()
.map(|&i| Value::from(i))
.collect();
for (key, value) in data.into_iter() {
config.insert(key, value);
if not_allow.iter().find(|&i| i == &key).is_none() {
config.insert(key, value);
}
}
Self::_activate(info, config).unwrap();
}

View File

@@ -31,13 +31,17 @@ pub struct PrfItem {
#[serde(skip_serializing_if = "Option::is_none")]
pub selected: Option<Vec<PrfSelected>>,
/// user info
/// subscription user info
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<PrfExtra>,
/// updated time
pub updated: Option<usize>,
/// some options of the item
#[serde(skip_serializing_if = "Option::is_none")]
pub option: Option<PrfOption>,
/// the file data
#[serde(skip)]
pub file_data: Option<String>,
@@ -57,6 +61,18 @@ pub struct PrfExtra {
pub expire: usize,
}
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct PrfOption {
/// for `remote` profile's http request
/// see issue #13
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
/// for `remote` profile
#[serde(skip_serializing_if = "Option::is_none")]
pub with_proxy: Option<bool>,
}
impl Default for PrfItem {
fn default() -> Self {
PrfItem {
@@ -69,6 +85,7 @@ impl Default for PrfItem {
selected: None,
extra: None,
updated: None,
option: None,
file_data: None,
}
}
@@ -90,7 +107,7 @@ impl PrfItem {
let url = item.url.as_ref().unwrap().as_str();
let name = item.name;
let desc = item.desc;
PrfItem::from_url(url, name, desc, false).await
PrfItem::from_url(url, name, desc, item.option).await
}
"local" => {
let name = item.name.unwrap_or("Local File".into());
@@ -126,6 +143,7 @@ impl PrfItem {
url: None,
selected: None,
extra: None,
option: None,
updated: Some(help::get_now()),
file_data: Some(tmpl::ITEM_LOCAL.into()),
})
@@ -137,13 +155,25 @@ impl PrfItem {
url: &str,
name: Option<String>,
desc: Option<String>,
with_proxy: bool,
option: Option<PrfOption>,
) -> Result<PrfItem> {
let with_proxy = match option.as_ref() {
Some(opt) => opt.with_proxy.unwrap_or(false),
None => false,
};
let user_agent = match option.as_ref() {
Some(opt) => opt.user_agent.clone(),
None => None,
};
let mut builder = reqwest::ClientBuilder::new();
if !with_proxy {
builder = builder.no_proxy();
}
if let Some(user_agent) = user_agent {
builder = builder.user_agent(user_agent);
}
let resp = builder.build()?.get(url).send().await?;
let header = resp.headers();
@@ -177,6 +207,7 @@ impl PrfItem {
url: Some(url.into()),
selected: None,
extra,
option,
updated: Some(help::get_now()),
file_data: Some(data),
})
@@ -197,6 +228,7 @@ impl PrfItem {
url: None,
selected: None,
extra: None,
option: None,
updated: Some(help::get_now()),
file_data: Some(tmpl::ITEM_MERGE.into()),
})
@@ -217,6 +249,7 @@ impl PrfItem {
url: None,
selected: None,
extra: None,
option: None,
updated: Some(help::get_now()),
file_data: Some(tmpl::ITEM_SCRIPT.into()),
})
@@ -380,8 +413,10 @@ impl Profiles {
patch!(each, item, url);
patch!(each, item, selected);
patch!(each, item, extra);
patch!(each, item, updated);
each.updated = Some(help::get_now());
// can be removed
each.option = item.option;
self.items = Some(items);
return self.save_file();

View File

@@ -67,13 +67,13 @@ pub fn init_app(package_info: &PackageInfo) {
let res_dir = dirs::app_resources_dir(package_info);
if !app_dir.exists() {
fs::create_dir(&app_dir).unwrap();
fs::create_dir_all(&app_dir).unwrap();
}
if !log_dir.exists() {
fs::create_dir(&log_dir).unwrap();
fs::create_dir_all(&log_dir).unwrap();
}
if !profiles_dir.exists() {
fs::create_dir(&profiles_dir).unwrap();
fs::create_dir_all(&profiles_dir).unwrap();
}
init_log(&log_dir);

View File

@@ -61,7 +61,7 @@ fn resolve_window(app: &App) {
window.set_decorations(false).unwrap();
set_shadow(&window, true).unwrap();
apply_blur(&window).unwrap();
apply_blur(&window, None).unwrap();
}
#[cfg(target_os = "macos")]

View File

@@ -1,8 +1,10 @@
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::io;
#[cfg(target_os = "windows")]
static DEFAULT_BYPASS: &str = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*;<local>";
#[cfg(target_os = "linux")]
static DEFAULT_BYPASS: &str = "localhost,127.0.0.1/8,::1";
#[cfg(target_os = "macos")]
static DEFAULT_BYPASS: &str =
"192.168.0.0/16\n10.0.0.0/8\n172.16.0.0/12\n127.0.0.1\nlocalhost\n*.local\ntimestamp.apple.com\n";
@@ -34,10 +36,12 @@ impl SysProxyConfig {
bypass: bypass.unwrap_or(DEFAULT_BYPASS.into()),
}
}
}
#[cfg(target_os = "windows")]
#[cfg(target_os = "windows")]
impl SysProxyConfig {
/// Get the windows system proxy config
pub fn get_sys() -> io::Result<Self> {
pub fn get_sys() -> Result<Self> {
use winreg::enums::*;
use winreg::RegKey;
@@ -54,9 +58,30 @@ impl SysProxyConfig {
})
}
#[cfg(target_os = "macos")]
/// Set the windows system proxy config
pub fn set_sys(&self) -> Result<()> {
use winreg::enums::*;
use winreg::RegKey;
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let cur_var = hkcu.open_subkey_with_flags(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
KEY_SET_VALUE,
)?;
let enable: u32 = if self.enable { 1u32 } else { 0u32 };
cur_var.set_value("ProxyEnable", &enable)?;
cur_var.set_value("ProxyServer", &self.server)?;
cur_var.set_value("ProxyOverride", &self.bypass)?;
Ok(())
}
}
#[cfg(target_os = "macos")]
impl SysProxyConfig {
/// Get the macos system proxy config
pub fn get_sys() -> io::Result<Self> {
pub fn get_sys() -> Result<Self> {
use std::process::Command;
let http = macproxy::get_proxy(&["-getwebproxy", MACOS_SERVICE])?;
@@ -82,63 +107,59 @@ impl SysProxyConfig {
let bypass_output = Command::new("networksetup")
.args(["-getproxybypassdomains", MACOS_SERVICE])
.output()?;
let bypass = std::str::from_utf8(&bypass_output.stdout).unwrap_or(DEFAULT_BYPASS);
// change the format to xxx,xxx
let bypass = std::str::from_utf8(&bypass_output.stdout)
.unwrap_or(DEFAULT_BYPASS)
.to_string()
.split('\n')
.collect::<Vec<_>>()
.join(",");
Ok(SysProxyConfig {
enable,
server,
bypass: bypass.into(),
bypass,
})
}
#[cfg(target_os = "windows")]
/// Set the windows system proxy config
pub fn set_sys(&self) -> io::Result<()> {
use winreg::enums::*;
use winreg::RegKey;
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let cur_var = hkcu.open_subkey_with_flags(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
KEY_SET_VALUE,
)?;
let enable: u32 = if self.enable { 1u32 } else { 0u32 };
cur_var.set_value("ProxyEnable", &enable)?;
cur_var.set_value("ProxyServer", &self.server)?;
cur_var.set_value("ProxyOverride", &self.bypass)
}
#[cfg(target_os = "macos")]
/// Set the macos system proxy config
pub fn set_sys(&self) -> io::Result<()> {
pub fn set_sys(&self) -> Result<()> {
use std::process::Command;
let enable = self.enable;
let server = self.server.as_str();
let bypass = self.bypass.clone();
macproxy::set_proxy("-setwebproxy", MACOS_SERVICE, enable, server)?;
macproxy::set_proxy("-setsecurewebproxy", MACOS_SERVICE, enable, server)?;
macproxy::set_proxy("-setsocksfirewallproxy", MACOS_SERVICE, enable, server)
macproxy::set_proxy("-setsocksfirewallproxy", MACOS_SERVICE, enable, server)?;
let domains = bypass.split(",").collect::<Vec<_>>();
Command::new("networksetup")
.args([["-setproxybypassdomains", MACOS_SERVICE].to_vec(), domains].concat())
.status()?;
Ok(())
}
}
#[cfg(target_os = "macos")]
mod macproxy {
use super::*;
use anyhow::bail;
use std::process::Command;
/// use networksetup
/// get the target proxy config
pub(super) fn get_proxy(args: &[&str; 2]) -> io::Result<(String, String)> {
pub(super) fn get_proxy(args: &[&str; 2]) -> Result<(String, String)> {
let output = Command::new("networksetup").args(args).output()?;
match std::str::from_utf8(&output.stdout) {
Ok(stdout) => {
let enable = parse(stdout, "Enabled:");
let server = parse(stdout, "Server:");
let port = parse(stdout, "Port:");
let server = format!("{}:{}", server, port);
Ok((enable.into(), server))
}
Err(_) => Err(io::Error::from_raw_os_error(1)),
}
let stdout = std::str::from_utf8(&output.stdout)?;
let enable = parse(stdout, "Enabled:");
let server = parse(stdout, "Server:");
let port = parse(stdout, "Port:");
let server = format!("{server}:{port}");
Ok((enable.into(), server))
}
/// use networksetup
@@ -148,17 +169,17 @@ mod macproxy {
device: &str,
enable: bool,
server: &str,
) -> io::Result<()> {
) -> Result<()> {
let mut split = server.split(":");
let domain = split.next();
let host = split.next();
let port = split.next();
// can not parse the field
if domain.is_none() || port.is_none() {
return Err(io::Error::from_raw_os_error(1));
if host.is_none() || port.is_none() {
bail!("failed to parse the server into host:port");
}
let args = vec![target, device, domain.unwrap(), port.unwrap()];
let args = vec![target, device, host.unwrap(), port.unwrap()];
Command::new("networksetup").args(&args).status()?;
let target_state = String::from(target) + "state";
@@ -169,7 +190,7 @@ mod macproxy {
}
/// parse the networksetup output
pub(super) fn parse<'a>(target: &'a str, key: &'a str) -> &'a str {
fn parse<'a>(target: &'a str, key: &'a str) -> &'a str {
match target.find(key) {
Some(idx) => {
let idx = idx + key.len();
@@ -209,3 +230,137 @@ mod macproxy {
dbg!(sysproxy.set_sys().unwrap());
}
}
///
/// Linux Desktop System Proxy Supports
/// by using `gsettings`
#[cfg(target_os = "linux")]
impl SysProxyConfig {
/// Get the system proxy config [http/https/socks]
pub fn get_sys() -> Result<Self> {
use std::process::Command;
let schema = "org.gnome.system.proxy";
// get enable
let mode = Command::new("gsettings")
.args(["get", schema, "mode"])
.output()?;
let mode = std::str::from_utf8(&mode.stdout)?;
let enable = mode == "manual";
// get bypass
// Todo: parse the ignore-hosts
// ['aaa', 'bbb'] -> aaa,bbb
let ignore = Command::new("gsettings")
.args(["get", schema, "ignore-hosts"])
.output()?;
let ignore = std::str::from_utf8(&ignore.stdout)?;
let bypass = ignore.to_string();
let http = Self::get_proxy("http")?;
let https = Self::get_proxy("https")?;
let socks = Self::get_proxy("socks")?;
let mut server = "".into();
if socks.len() > 0 {
server = socks;
}
if https.len() > 0 {
server = https;
}
if http.len() > 0 {
server = http;
}
Ok(SysProxyConfig {
enable,
server,
bypass,
})
}
/// Get the system proxy config [http/https/socks]
pub fn set_sys(&self) -> Result<()> {
use anyhow::bail;
use std::process::Command;
let enable = self.enable;
let server = self.server.as_str();
let bypass = self.bypass.clone();
let schema = "org.gnome.system.proxy";
if enable {
let mut split = server.split(":");
let host = split.next();
let port = split.next();
if port.is_none() {
bail!("failed to parse the port");
}
let host = format!("'{}'", host.unwrap_or("127.0.0.1"));
let host = host.as_str();
let port = port.unwrap();
let http = format!("{schema}.http");
Command::new("gsettings")
.args(["set", http.as_str(), "host", host])
.status()?;
Command::new("gsettings")
.args(["set", http.as_str(), "port", port])
.status()?;
let https = format!("{schema}.https");
Command::new("gsettings")
.args(["set", https.as_str(), "host", host])
.status()?;
Command::new("gsettings")
.args(["set", https.as_str(), "port", port])
.status()?;
let socks = format!("{schema}.socks");
Command::new("gsettings")
.args(["set", socks.as_str(), "host", host])
.status()?;
Command::new("gsettings")
.args(["set", socks.as_str(), "port", port])
.status()?;
// set bypass
// Todo: parse the ignore-hosts
// aaa,bbb,cccc -> ['aaa', 'bbb', 'ccc']
Command::new("gsettings")
.args(["set", schema, "ignore-hosts", bypass.as_str()]) // todo
.status()?;
}
let mode = if enable { "'manual'" } else { "'none'" };
Command::new("gsettings")
.args(["set", schema, "mode", mode])
.status()?;
Ok(())
}
/// help function
fn get_proxy(typ: &str) -> Result<String> {
use std::process::Command;
let schema = format!("org.gnome.system.proxy.{typ}");
let schema = schema.as_str();
let host = Command::new("gsettings")
.args(["get", schema, "host"])
.output()?;
let host = std::str::from_utf8(&host.stdout)?;
let port = Command::new("gsettings")
.args(["get", schema, "port"])
.output()?;
let port = std::str::from_utf8(&port.stdout)?;
Ok(format!("{host}:{port}"))
}
}

View File

@@ -1,7 +1,7 @@
{
"package": {
"productName": "clash-verge",
"version": "0.0.21"
"productName": "Clash Verge",
"version": "0.0.22"
},
"build": {
"distDir": "../dist",

View File

@@ -34,8 +34,8 @@ const UpdateDialog = (props: Props) => {
uploadingState = true;
try {
await killSidecars();
await installUpdate();
await killSidecars();
await relaunch();
} catch (err: any) {
await restartSidecar();

View File

@@ -1,5 +1,5 @@
import { mutate } from "swr";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { useLockFn, useSetState } from "ahooks";
import {
Button,
@@ -7,8 +7,10 @@ import {
DialogActions,
DialogContent,
DialogTitle,
IconButton,
TextField,
} from "@mui/material";
import { Settings } from "@mui/icons-material";
import { CmdType } from "../../services/types";
import { patchProfile } from "../../services/cmds";
import Notice from "../base/base-notice";
@@ -20,13 +22,18 @@ interface Props {
}
// edit the profile item
// remote / local file / merge / script
const ProfileEdit = (props: Props) => {
const { open, itemData, onClose } = props;
const [form, setForm] = useSetState({ ...itemData });
const [option, setOption] = useSetState(itemData.option ?? {});
const [showOpt, setShowOpt] = useState(!!itemData.option);
useEffect(() => {
if (itemData) {
setForm({ ...itemData });
setOption(itemData.option ?? {});
setShowOpt(!!itemData.option?.user_agent);
}
}, [itemData]);
@@ -34,7 +41,14 @@ const ProfileEdit = (props: Props) => {
try {
const { uid } = itemData;
const { name, desc, url } = form;
await patchProfile(uid, { uid, name, desc, url });
const option_ = showOpt ? option : undefined;
if (itemData.type === "remote" && !url) {
throw new Error("Remote URL should not be null");
}
await patchProfile(uid, { uid, name, desc, url, option: option_ });
setShowOpt(false);
mutate("getProfiles");
onClose();
} catch (err: any) {
@@ -89,9 +103,28 @@ const ProfileEdit = (props: Props) => {
onChange={(e) => setForm({ url: e.target.value })}
/>
)}
{showOpt && (
<TextField
{...textFieldProps}
label="User Agent"
value={option.user_agent}
onChange={(e) => setOption({ user_agent: e.target.value })}
/>
)}
</DialogContent>
<DialogActions sx={{ px: 2, pb: 2 }}>
<DialogActions sx={{ px: 2, pb: 2, position: "relative" }}>
{form.type === "remote" && (
<IconButton
size="small"
sx={{ position: "absolute", left: 18 }}
onClick={() => setShowOpt((o) => !o)}
>
<Settings />
</IconButton>
)}
<Button onClick={onClose}>Cancel</Button>
<Button onClick={onUpdate} variant="contained">
Update

View File

@@ -98,7 +98,7 @@ const ProfileItem = (props: Props) => {
if (loading) return;
setLoading(true);
try {
await updateProfile(itemData.uid, withProxy);
await updateProfile(itemData.uid, { with_proxy: withProxy });
setLoading(false);
mutate("getProfiles");
} catch (err: any) {

View File

@@ -1,3 +1,4 @@
import { useState } from "react";
import { useSWRConfig } from "swr";
import { useLockFn, useSetState } from "ahooks";
import {
@@ -7,11 +8,13 @@ import {
DialogContent,
DialogTitle,
FormControl,
IconButton,
InputLabel,
MenuItem,
Select,
TextField,
} from "@mui/material";
import { Settings } from "@mui/icons-material";
import { createProfile } from "../../services/cmds";
import Notice from "../base/base-notice";
@@ -27,12 +30,17 @@ const ProfileNew = (props: Props) => {
const { mutate } = useSWRConfig();
const [form, setForm] = useSetState({
type: "remote",
name: "",
desc: "",
type: "remote",
url: "",
});
const [showOpt, setShowOpt] = useState(false);
const [option, setOption] = useSetState({
user_agent: "",
}); // able to add more option
const onCreate = useLockFn(async () => {
if (!form.type) {
Notice.error("`Type` should not be null");
@@ -40,8 +48,18 @@ const ProfileNew = (props: Props) => {
}
try {
await createProfile({ ...form });
setForm({ name: "", desc: "", type: "remote", url: "" });
const name = form.name || `${form.type} file`;
if (form.type === "remote" && !form.url) {
throw new Error("The URL should not be null");
}
const option_ = showOpt ? option : undefined;
await createProfile({ ...form, name, option: option_ });
setForm({ type: "remote", name: "", desc: "", url: "" });
setOption({ user_agent: "" });
setShowOpt(false);
mutate("getProfiles");
onClose();
} catch (err: any) {
@@ -61,17 +79,10 @@ const ProfileNew = (props: Props) => {
<DialogTitle sx={{ pb: 0.5 }}>Create Profile</DialogTitle>
<DialogContent sx={{ width: 336, pb: 1 }}>
<TextField
{...textFieldProps}
autoFocus
label="Name"
value={form.name}
onChange={(e) => setForm({ name: e.target.value })}
/>
<FormControl size="small" fullWidth sx={{ mt: 2, mb: 1 }}>
<InputLabel>Type</InputLabel>
<Select
autoFocus
label="Type"
value={form.type}
onChange={(e) => setForm({ type: e.target.value })}
@@ -83,6 +94,13 @@ const ProfileNew = (props: Props) => {
</Select>
</FormControl>
<TextField
{...textFieldProps}
label="Name"
value={form.name}
onChange={(e) => setForm({ name: e.target.value })}
/>
<TextField
{...textFieldProps}
label="Descriptions"
@@ -98,9 +116,28 @@ const ProfileNew = (props: Props) => {
onChange={(e) => setForm({ url: e.target.value })}
/>
)}
{showOpt && (
<TextField
{...textFieldProps}
label="User Agent"
value={option.user_agent}
onChange={(e) => setOption({ user_agent: e.target.value })}
/>
)}
</DialogContent>
<DialogActions sx={{ px: 2, pb: 2 }}>
<DialogActions sx={{ px: 2, pb: 2, position: "relative" }}>
{form.type === "remote" && (
<IconButton
size="small"
sx={{ position: "absolute", left: 18 }}
onClick={() => setShowOpt((o) => !o)}
>
<Settings />
</IconButton>
)}
<Button onClick={onClose}>Cancel</Button>
<Button onClick={onCreate} variant="contained">
Create

View File

@@ -75,7 +75,7 @@ const ProxyGroup = ({ group }: Props) => {
} else {
profile.selected[index] = { name: group.name, now: name };
}
await patchProfile(profiles!.current!, profile);
await patchProfile(profiles!.current!, { selected: profile.selected });
} catch (err) {
console.error(err);
}

View File

@@ -81,7 +81,10 @@ const ProfilePage = () => {
name,
now,
}));
patchProfile(current!, profile).catch(console.error);
patchProfile(current!, { selected: profile.selected }).catch(
console.error
);
// update proxies cache
if (hasChange) mutate("getProxies", getProxies());
}, 100);

View File

@@ -14,7 +14,13 @@ export async function getAxios(force: boolean = false) {
try {
const info = await getClashInfo();
if (info?.server) server = info?.server;
if (info?.server) {
server = info.server;
// compatible width `external-controller`
if (server.startsWith(":")) server = `127.0.0.1${server}`;
else if (/^\d+$/.test(server)) server = `127.0.0.1:${server}`;
}
if (info?.secret) secret = info?.secret;
} catch {}

View File

@@ -22,11 +22,17 @@ export async function viewProfile(index: string) {
}
export async function importProfile(url: string) {
return invoke<void>("import_profile", { url, withProxy: true });
return invoke<void>("import_profile", {
url,
option: { with_proxy: true },
});
}
export async function updateProfile(index: string, withProxy: boolean) {
return invoke<void>("update_profile", { index, withProxy });
export async function updateProfile(
index: string,
option?: CmdType.ProfileOption
) {
return invoke<void>("update_profile", { index, option });
}
export async function deleteProfile(index: string) {
@@ -35,7 +41,7 @@ export async function deleteProfile(index: string) {
export async function patchProfile(
index: string,
profile: CmdType.ProfileItem
profile: Partial<CmdType.ProfileItem>
) {
return invoke<void>("patch_profile", { index, profile });
}

View File

@@ -105,6 +105,12 @@ export namespace CmdType {
total: number;
expire: number;
};
option?: ProfileOption;
}
export interface ProfileOption {
user_agent?: string;
with_proxy?: boolean;
}
export interface ProfilesConfig {

112
yarn.lock
View File

@@ -572,66 +572,72 @@
estree-walker "^2.0.1"
picomatch "^2.2.2"
"@tauri-apps/api@^1.0.0-rc.1":
version "1.0.0-rc.1"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.0-rc.1.tgz#ce26a0fe30d8980a4682d50015eec28ed4a23c1e"
integrity sha512-VBUOmfT8ea02JB/Qr+FHeaLnug5BRA7ro2pX47q0GZCbZsU9b+iPnOXl0ShJwT0melR7B6iamyhDwkHStMVfQA==
"@tauri-apps/api@^1.0.0-rc.2":
version "1.0.0-rc.2"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.0-rc.2.tgz#bac494a6b8868e05f86184d2ee1ccc8477470363"
integrity sha512-JhUDCJpfxmf/S1R+yHmJGsher4CGi07Qv4fYeucB7naeFZ7yTQe7S1CHKUZaRYpurGSdwOF3my9k0LyGmpAGYw==
dependencies:
type-fest "2.11.2"
type-fest "2.12.0"
"@tauri-apps/cli-darwin-arm64@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.0-rc.5.tgz#9374be8c96afa1cf77b5647bc81fe1a05006757d"
integrity sha512-X+3EIAUGfoL8uE6PBADZC8FcUISe4JPQCxXgaVv6ehoZGoCh/pFJF7AvBGTQxbnvngqM7Xce4Lmh63Io2/5ggw==
"@tauri-apps/cli-darwin-arm64@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.0-rc.7.tgz#c7d190ea7496381bf456494e93dd8b35005a0e78"
integrity sha512-fb1plxZZHDG0KwZOoAl6tuisFU+oZFtNtqK3V2KL+4hz75DyH6BfsrgjyYSecJrtQejL2cHi8q7vUsU+EeLopw==
"@tauri-apps/cli-darwin-x64@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.0-rc.5.tgz#4db1dd56a228bfafe5b3f64c7661abbe5606e804"
integrity sha512-fEpgOdAvKdq9C5/yip8RnwP1VS+nRrtKdzzplu4jY6njDVH/Vom8mg+EfXkCY5RveCaoskJMFgUvt10IGeZHBA==
"@tauri-apps/cli-darwin-x64@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.0-rc.7.tgz#b152f333ea081674e8e6c45d1c3ff1850bff854c"
integrity sha512-FOFPNsYUgCDaxEK+9oQ3vv9bMD3XVcOKdh1vo/DImzZNO6fQkcsDC8zlmA+Q4axd+X8kvu0iti1fK8Vl7HIUEA==
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.0-rc.5.tgz#0f1ff84c534908a54fbe63b45004abc6d4f03f4d"
integrity sha512-V7sWSBrpLyvkQxpkHIM8JltYqQhiTpThySDjO8POtrTqkRwM5BXORcCYhxTAKCedecfYK/RNUJ6Q0t7+3jS6DQ==
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.0-rc.7.tgz#14fb37a337526200dbbe9b49dabd221b81682b02"
integrity sha512-tFzcJtNHy5AInU3E7kKDyhg4Qb7csu3uZ3FhGfORmGvQAiNQFpGV3ypC230RQYa3sxxRMbn8vjUAZMlU6JArbA==
"@tauri-apps/cli-linux-arm64-gnu@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.0-rc.5.tgz#c5d2f1dd962d80a1958261229778b410b86254d4"
integrity sha512-HhM+2FInxtUAI/41LF4fDEzmhLQUq6DOoo7fLN94vgWlhsPyWZoDGP9pA043XbO86+4OX5JZUW1SnTVXMwEaMA==
"@tauri-apps/cli-linux-arm64-gnu@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.0-rc.7.tgz#43e7a38018258ad2bf665bb61e0328688b345355"
integrity sha512-QAoNUJMmoCv/mDZsfEZOOTeEPYuxtMgCgqTDqMd0H8S0Y3Cu2D/Q2fwVl0s9pMb6wLD2GJ2FEneySEMhMxt7Pg==
"@tauri-apps/cli-linux-arm64-musl@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.0-rc.5.tgz#f485db9ca5402f5d2c4585801a3aaa4519bd67e8"
integrity sha512-DhHdKOhf3+peA/sM0c9CpxK89cp8GVwOB5osFW55fxBZbD0mJFeL2SzjkgfGFqFu6Ci/ZiibQGfEp8XTC8OsYA==
"@tauri-apps/cli-linux-arm64-musl@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.0-rc.7.tgz#37ebcfc7d1431dd698f529fa57248adadd94b3b4"
integrity sha512-ieLyACtbY7ezReTnjWLw/kKDXRCbnbrUjQ+hltSmHaRuV51nX+I2rmFO5e7VPdj406jvyKwfSPuBC34bHxt3Og==
"@tauri-apps/cli-linux-x64-gnu@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.0-rc.5.tgz#e468939585bc98e80ec827d0a3d8ba06a7cc38e8"
integrity sha512-pZzsOHRGG/mdcn7fF/yOIOdeVzGxZUtZqvlGSd90ZM9Ps3//uYGCBHoNTbeSwp/V6+D0KVDaSCbm9lYlHoXcdA==
"@tauri-apps/cli-linux-x64-gnu@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.0-rc.7.tgz#b47239c4f10b3fe8e1e2f031f639125ededc6d79"
integrity sha512-wPAZctuFpurACxdCrjw+aaSuFReuIvv1nalVezfqA78AlsCk785yF2YVjoZr5bT8a9+6F+t8uNi3l6Vp5oNqwQ==
"@tauri-apps/cli-linux-x64-musl@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.0-rc.5.tgz#a1308e93850555f2b6c97b5d7cdbbb9afaa803e2"
integrity sha512-COwWCbOhEjBlzGRGTa0ESO4/AiC0cBZ2UEPExRn++S+kWSPJ2vsyMdCLu3hiMy1ABSIRcQ4Vc68M1iVkLhOHHw==
"@tauri-apps/cli-linux-x64-musl@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.0-rc.7.tgz#9e62494cf80aed170f389d84b2b23f354e8ce748"
integrity sha512-/AxuXFC2d1V8KpZJ6cFDcD5QqPFIZFXC/tAJlnTW75VnHgjat9TYP3BdSOuEA81ZLs9tV4PQF40tNnUSzfRYMg==
"@tauri-apps/cli-win32-x64-msvc@1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.0-rc.5.tgz#d15c95143d9123d10c510e28ba90df5349b68ecd"
integrity sha512-zzizUmPWvnWjj+IUCk36kVjS9j1Bg5JmnwOW5QdX26+a64q5vocmVimCgrfZ5STw3sDFXE++S55ghpzhhH5o+g==
"@tauri-apps/cli-win32-ia32-msvc@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.0-rc.7.tgz#71c2f9498f4d03fd2c0ca6137a2be7db95a006f3"
integrity sha512-C4M2rHXlYVPSHGl2Iax1rfiNM5GPSRP1JHxW7/4jH9FfW6mVFcjULZAyVMRfOMQEQ9bYXbVnSTPbhG2Fm0jPxQ==
"@tauri-apps/cli@^1.0.0-rc.5":
version "1.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.0-rc.5.tgz#db8ca22c9f55f5400d1c6addd78ee1df5dc15a29"
integrity sha512-Q3D0R5YdZRA5EcL206hwwKCyXpet2mRDcfaRTU/IXwF73bS4AMja+JdAGfO2cyHuSvXd+b//Cgbei2zCG8M6hw==
"@tauri-apps/cli-win32-x64-msvc@1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.0-rc.7.tgz#6d719f70a0789f2a179d160c302996ce81194099"
integrity sha512-lpstJKOtP+ahhjbutapA02TpvfNTZqXwhmA1fvqxDu6BYVezFn7ZiGG5HwdXlkiRDfbwZwBd1evdkV3MxwY1NQ==
"@tauri-apps/cli@^1.0.0-rc.7":
version "1.0.0-rc.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.0-rc.7.tgz#0eb73718f6ebddc159b0b54f6fd6dfc26d110b36"
integrity sha512-g7lUsI2iFiB2JuPFr209vWNqOnxCOGXN6yBttMRY+94UUXZOeWlKxYYpSabyjSr7EbfAUNzjITYmE4urdtmB+A==
optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "1.0.0-rc.5"
"@tauri-apps/cli-darwin-x64" "1.0.0-rc.5"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.0-rc.5"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.0-rc.5"
"@tauri-apps/cli-linux-arm64-musl" "1.0.0-rc.5"
"@tauri-apps/cli-linux-x64-gnu" "1.0.0-rc.5"
"@tauri-apps/cli-linux-x64-musl" "1.0.0-rc.5"
"@tauri-apps/cli-win32-x64-msvc" "1.0.0-rc.5"
"@tauri-apps/cli-darwin-arm64" "1.0.0-rc.7"
"@tauri-apps/cli-darwin-x64" "1.0.0-rc.7"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.0-rc.7"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.0-rc.7"
"@tauri-apps/cli-linux-arm64-musl" "1.0.0-rc.7"
"@tauri-apps/cli-linux-x64-gnu" "1.0.0-rc.7"
"@tauri-apps/cli-linux-x64-musl" "1.0.0-rc.7"
"@tauri-apps/cli-win32-ia32-msvc" "1.0.0-rc.7"
"@tauri-apps/cli-win32-x64-msvc" "1.0.0-rc.7"
"@types/fs-extra@^9.0.13":
version "9.0.13"
@@ -1863,10 +1869,10 @@ tunnel@0.0.6:
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
type-fest@2.11.2:
version "2.11.2"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.11.2.tgz#5534a919858bc517492cd3a53a673835a76d2e71"
integrity sha512-reW2Y2Mpn0QNA/5fvtm5doROLwDPu2zOm5RtY7xQQS05Q7xgC8MOZ3yPNaP9m/s/sNjjFQtHo7VCNqYW2iI+Ig==
type-fest@2.12.0:
version "2.12.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.12.0.tgz#ce342f58cab9114912f54b493d60ab39c3fc82b6"
integrity sha512-Qe5GRT+n/4GoqCNGGVp5Snapg1Omq3V7irBJB3EaKsp7HWDo5Gv2d/67gfNyV+d5EXD+x/RF5l1h4yJ7qNkcGA==
typescript@^4.5.5:
version "4.6.2"