11 Commits

Author SHA1 Message Date
GyDi
3ed6938d4a v0.0.14 2022-02-09 02:11:01 +08:00
GyDi
99fec25ed5 feat: profile item ui 2022-02-09 02:08:27 +08:00
GyDi
73758ad1fd fix: proxy list error 2022-02-09 02:02:29 +08:00
GyDi
c53fe0ed1f feat: support new profile 2022-02-07 17:26:05 +08:00
GyDi
6082c2bcac feat: support open command for viewing 2022-02-07 16:45:20 +08:00
GyDi
069abed784 chore: add item template yaml 2022-02-02 20:56:06 +08:00
GyDi
7d8fa4d78a fix: something 2022-01-31 23:34:58 +08:00
GyDi
76081f8d89 fix: macos auto launch fail 2022-01-31 23:32:41 +08:00
GyDi
5ef4285558 chore: update deps and app name 2022-01-31 23:27:11 +08:00
GyDi
aa7df4282e chore: cargo update 2022-01-28 22:02:17 +08:00
GyDi
0ef1d5d0de chore: update clash version 2022-01-28 22:00:15 +08:00
16 changed files with 408 additions and 190 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "clash-verge", "name": "clash-verge",
"version": "0.0.13", "version": "0.0.14",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {
"dev": "cargo tauri dev", "dev": "cargo tauri dev",

View File

@@ -9,7 +9,7 @@ const cwd = process.cwd();
const CLASH_URL_PREFIX = const CLASH_URL_PREFIX =
"https://github.com/Dreamacro/clash/releases/download/premium/"; "https://github.com/Dreamacro/clash/releases/download/premium/";
const CLASH_LATEST_DATE = "2022.01.03"; const CLASH_LATEST_DATE = "2022.01.27";
/** /**
* get the correct clash release infomation * get the correct clash release infomation

314
src-tauri/Cargo.lock generated
View File

@@ -34,33 +34,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.52" version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
[[package]]
name = "app"
version = "0.1.0"
dependencies = [
"auto-launch",
"chrono",
"dirs 4.0.0",
"log",
"log4rs",
"port_scanner",
"reqwest",
"serde",
"serde_json",
"serde_yaml",
"tauri",
"tauri-build",
"tauri-plugin-shadows",
"tauri-plugin-vibrancy",
"tokio",
"warp",
"which",
"winreg 0.10.1",
]
[[package]] [[package]]
name = "arc-swap" name = "arc-swap"
@@ -197,9 +173,9 @@ dependencies = [
[[package]] [[package]]
name = "blake3" name = "blake3"
version = "1.3.0" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "882e99e4a0cb2ae6cb6e442102e8e6b7131718d94110e64c3e6a34ea9b106f37" checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f"
dependencies = [ dependencies = [
"arrayref", "arrayref",
"arrayvec 0.7.2", "arrayvec 0.7.2",
@@ -390,6 +366,30 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "clash-verge"
version = "0.1.0"
dependencies = [
"auto-launch",
"chrono",
"dirs 4.0.0",
"log",
"log4rs",
"port_scanner",
"reqwest",
"serde",
"serde_json",
"serde_yaml",
"tauri",
"tauri-build",
"tauri-plugin-shadows",
"tauri-plugin-vibrancy",
"tokio",
"warp",
"which",
"winreg 0.10.1",
]
[[package]] [[package]]
name = "cocoa" name = "cocoa"
version = "0.24.0" version = "0.24.0"
@@ -494,9 +494,9 @@ dependencies = [
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.0" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
] ]
@@ -804,9 +804,9 @@ dependencies = [
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "1.6.0" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2" checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
dependencies = [ dependencies = [
"instant", "instant",
] ]
@@ -1106,9 +1106,9 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.3" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
@@ -1271,9 +1271,9 @@ dependencies = [
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.3.10" version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c9de88456263e249e241fcd211d3954e2c9b0ef7ccfc235a444eb367cae3689" checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
@@ -1589,9 +1589,9 @@ dependencies = [
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.55" version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@@ -1639,9 +1639,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.112" version = "0.2.115"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d"
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
@@ -2118,9 +2118,9 @@ dependencies = [
[[package]] [[package]]
name = "openssl-probe" name = "openssl-probe"
version = "0.1.4" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
@@ -2146,9 +2146,9 @@ dependencies = [
[[package]] [[package]]
name = "os_info" name = "os_info"
version = "3.0.9" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b89dd55b8d8d97dabd0d1adc625d188378fcf87632825bfe9c956acc9a11a72a" checksum = "198e392be7e882f0c2836f425e430f81d9a0e99651e4646311347417cddbfd43"
dependencies = [ dependencies = [
"log", "log",
"serde", "serde",
@@ -2499,9 +2499,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.14" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@@ -2567,7 +2567,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [ dependencies = [
"getrandom 0.2.3", "getrandom 0.2.4",
] ]
[[package]] [[package]]
@@ -2663,7 +2663,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
dependencies = [ dependencies = [
"getrandom 0.2.3", "getrandom 0.2.4",
"redox_syscall 0.2.10", "redox_syscall 0.2.10",
] ]
@@ -2842,9 +2842,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.4.2" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation", "core-foundation",
@@ -2855,9 +2855,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "2.4.2" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@@ -2909,9 +2909,9 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.133" version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@@ -2928,9 +2928,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.133" version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -2939,9 +2939,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.74" version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085"
dependencies = [ dependencies = [
"itoa 1.0.1", "itoa 1.0.1",
"ryu", "ryu",
@@ -2961,12 +2961,12 @@ dependencies = [
[[package]] [[package]]
name = "serde_urlencoded" name = "serde_urlencoded"
version = "0.7.0" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"itoa 0.4.8", "itoa 1.0.1",
"ryu", "ryu",
"serde", "serde",
] ]
@@ -3036,9 +3036,9 @@ dependencies = [
[[package]] [[package]]
name = "siphasher" name = "siphasher"
version = "0.3.7" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e"
[[package]] [[package]]
name = "slab" name = "slab"
@@ -3048,15 +3048,15 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.7.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.4.2" version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
dependencies = [ dependencies = [
"libc", "libc",
"winapi", "winapi",
@@ -3176,15 +3176,25 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.85" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "sys-info"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c"
dependencies = [
"cc",
"libc",
]
[[package]] [[package]]
name = "system-deps" name = "system-deps"
version = "3.2.0" version = "3.2.0"
@@ -3219,7 +3229,7 @@ dependencies = [
[[package]] [[package]]
name = "tao" name = "tao"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/tauri-apps/tao?branch=next#a3a2e0cfc49ddfa8cdf65cf9870fb8e3d45b4bc0" source = "git+https://github.com/tauri-apps/tao?branch=next#e940f2f7250a6075704e50c5aeafaa4b46c0a912"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cairo-rs", "cairo-rs",
@@ -3252,7 +3262,7 @@ dependencies = [
"serde", "serde",
"tao-core-video-sys", "tao-core-video-sys",
"unicode-segmentation", "unicode-segmentation",
"windows 0.29.0", "windows 0.30.0",
"windows_macros", "windows_macros",
"x11-dl", "x11-dl",
] ]
@@ -3283,7 +3293,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "1.0.0-beta.8" version = "1.0.0-beta.8"
source = "git+https://github.com/tauri-apps/tauri?branch=next#c6e05380f7a3b5de3a12db9414a0d7d96102737a" source = "git+https://github.com/tauri-apps/tauri?branch=next#8ab8d529426b1ed7926daced16a45b077033bfe2"
dependencies = [ dependencies = [
"attohttpc", "attohttpc",
"base64", "base64",
@@ -3345,7 +3355,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-codegen" name = "tauri-codegen"
version = "1.0.0-beta.4" version = "1.0.0-beta.4"
source = "git+https://github.com/tauri-apps/tauri?branch=next#c6e05380f7a3b5de3a12db9414a0d7d96102737a" source = "git+https://github.com/tauri-apps/tauri?branch=next#8ab8d529426b1ed7926daced16a45b077033bfe2"
dependencies = [ dependencies = [
"blake3", "blake3",
"kuchiki", "kuchiki",
@@ -3363,7 +3373,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-macros" name = "tauri-macros"
version = "1.0.0-beta.5" version = "1.0.0-beta.5"
source = "git+https://github.com/tauri-apps/tauri?branch=next#c6e05380f7a3b5de3a12db9414a0d7d96102737a" source = "git+https://github.com/tauri-apps/tauri?branch=next#8ab8d529426b1ed7926daced16a45b077033bfe2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -3374,29 +3384,29 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-shadows" name = "tauri-plugin-shadows"
version = "0.0.0" version = "0.0.0"
source = "git+https://github.com/tauri-apps/tauri-plugin-shadows#e61ff61f7f7dfac5d881e310588c3f6ceac16dba" source = "git+https://github.com/tauri-apps/tauri-plugin-shadows#73e33a0820879c9444fd06fc042972a1ba50be81"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"objc", "objc",
"tauri", "tauri",
"windows 0.29.0", "windows 0.30.0",
] ]
[[package]] [[package]]
name = "tauri-plugin-vibrancy" name = "tauri-plugin-vibrancy"
version = "0.0.0" version = "0.0.0"
source = "git+https://github.com/tauri-apps/tauri-plugin-vibrancy#b4fceab0d4a6d024f1b9916c126f10f513101128" source = "git+https://github.com/tauri-apps/tauri-plugin-vibrancy#ac460f4d2e1951ffcc223d16be13b67c3c6372ee"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"objc", "objc",
"tauri", "tauri",
"windows 0.29.0", "windows 0.30.0",
] ]
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "0.2.1" version = "0.2.1"
source = "git+https://github.com/tauri-apps/tauri?branch=next#c6e05380f7a3b5de3a12db9414a0d7d96102737a" source = "git+https://github.com/tauri-apps/tauri?branch=next#8ab8d529426b1ed7926daced16a45b077033bfe2"
dependencies = [ dependencies = [
"gtk", "gtk",
"http", "http",
@@ -3408,13 +3418,13 @@ dependencies = [
"thiserror", "thiserror",
"uuid", "uuid",
"webview2-com", "webview2-com",
"windows 0.29.0", "windows 0.30.0",
] ]
[[package]] [[package]]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "0.2.1" version = "0.2.1"
source = "git+https://github.com/tauri-apps/tauri?branch=next#c6e05380f7a3b5de3a12db9414a0d7d96102737a" source = "git+https://github.com/tauri-apps/tauri?branch=next#8ab8d529426b1ed7926daced16a45b077033bfe2"
dependencies = [ dependencies = [
"gtk", "gtk",
"ico", "ico",
@@ -3424,7 +3434,7 @@ dependencies = [
"tauri-utils 1.0.0-beta.3 (git+https://github.com/tauri-apps/tauri?branch=next)", "tauri-utils 1.0.0-beta.3 (git+https://github.com/tauri-apps/tauri?branch=next)",
"uuid", "uuid",
"webview2-com", "webview2-com",
"windows 0.29.0", "windows 0.30.0",
"wry", "wry",
] ]
@@ -3449,7 +3459,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-utils" name = "tauri-utils"
version = "1.0.0-beta.3" version = "1.0.0-beta.3"
source = "git+https://github.com/tauri-apps/tauri?branch=next#c6e05380f7a3b5de3a12db9414a0d7d96102737a" source = "git+https://github.com/tauri-apps/tauri?branch=next#8ab8d529426b1ed7926daced16a45b077033bfe2"
dependencies = [ dependencies = [
"heck 0.4.0", "heck 0.4.0",
"html5ever", "html5ever",
@@ -3528,9 +3538,9 @@ dependencies = [
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.3" version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
dependencies = [ dependencies = [
"once_cell", "once_cell",
] ]
@@ -3563,9 +3573,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.15.0" version = "1.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a"
dependencies = [ dependencies = [
"bytes", "bytes",
"libc", "libc",
@@ -3700,9 +3710,9 @@ dependencies = [
[[package]] [[package]]
name = "tracing-subscriber" name = "tracing-subscriber"
version = "0.3.5" version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d81bfa81424cc98cb034b837c985b7a290f592e5b4322f353f94a0ab0f9f594" checksum = "5312f325fe3588e277415f5a6cca1f4ccad0f248c4cd5a4bd33032d7286abc22"
dependencies = [ dependencies = [
"ansi_term", "ansi_term",
"lazy_static", "lazy_static",
@@ -3847,7 +3857,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [ dependencies = [
"getrandom 0.2.3", "getrandom 0.2.4",
] ]
[[package]] [[package]]
@@ -3945,9 +3955,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@@ -3955,9 +3965,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
@@ -3970,9 +3980,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.28" version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"js-sys", "js-sys",
@@ -3982,9 +3992,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@@ -3992,9 +4002,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -4005,15 +4015,15 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.78" version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2"
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.55" version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
@@ -4067,13 +4077,13 @@ dependencies = [
[[package]] [[package]]
name = "webview2-com" name = "webview2-com"
version = "0.9.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b0f21eed16a0078ef52de94d15d6e3a22f9998cf45bdabaf9ef4a235ae235ac" checksum = "381febeeb86214fd262941a2b26322c33c38bf8b565b0ddfd4a7a8d4003053a9"
dependencies = [ dependencies = [
"webview2-com-macros", "webview2-com-macros",
"webview2-com-sys", "webview2-com-sys",
"windows 0.29.0", "windows 0.30.0",
"windows_macros", "windows_macros",
] ]
@@ -4090,15 +4100,15 @@ dependencies = [
[[package]] [[package]]
name = "webview2-com-sys" name = "webview2-com-sys"
version = "0.9.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a56fe9356e3729233bed63e7c002c0f5064f5d2148f169ce77eec8932a98c4c0" checksum = "a2e3542bb16fe61e951f87c9146571344f1e773327498efa65704a4cff472662"
dependencies = [ dependencies = [
"regex", "regex",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror",
"windows 0.29.0", "windows 0.30.0",
"windows-bindgen", "windows-bindgen",
] ]
@@ -4113,9 +4123,9 @@ dependencies = [
[[package]] [[package]]
name = "which" name = "which"
version = "4.2.2" version = "4.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
dependencies = [ dependencies = [
"either", "either",
"lazy_static", "lazy_static",
@@ -4177,7 +4187,7 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aac7fef12f4b59cd0a29339406cc9203ab44e440ddff6b3f5a41455349fa9cf3" checksum = "aac7fef12f4b59cd0a29339406cc9203ab44e440ddff6b3f5a41455349fa9cf3"
dependencies = [ dependencies = [
"windows_aarch64_msvc", "windows_aarch64_msvc 0.29.0",
"windows_i686_gnu 0.29.0", "windows_i686_gnu 0.29.0",
"windows_i686_msvc 0.29.0", "windows_i686_msvc 0.29.0",
"windows_x86_64_gnu 0.29.0", "windows_x86_64_gnu 0.29.0",
@@ -4185,10 +4195,23 @@ dependencies = [
] ]
[[package]] [[package]]
name = "windows-bindgen" name = "windows"
version = "0.29.0" version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b01138bf46333583966ea4b86fd4f61a9b524c0f5f88bc3c18768d6b66cb6c4e" checksum = "b749ebd2304aa012c5992d11a25d07b406bdbe5f79d371cb7a918ce501a19eb0"
dependencies = [
"windows_aarch64_msvc 0.30.0",
"windows_i686_gnu 0.30.0",
"windows_i686_msvc 0.30.0",
"windows_x86_64_gnu 0.30.0",
"windows_x86_64_msvc 0.30.0",
]
[[package]]
name = "windows-bindgen"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "944c545fcae9dd66488308f8b69aa3ba34f53714416ecfcdcbbfa4b6821e27c6"
dependencies = [ dependencies = [
"windows_quote", "windows_quote",
"windows_reader", "windows_reader",
@@ -4201,10 +4224,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d027175d00b01e0cbeb97d6ab6ebe03b12330a35786cbaca5252b1c4bf5d9b" checksum = "c3d027175d00b01e0cbeb97d6ab6ebe03b12330a35786cbaca5252b1c4bf5d9b"
[[package]] [[package]]
name = "windows_gen" name = "windows_aarch64_msvc"
version = "0.29.0" version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e59eb69ef41a029911bb604a850f70ec1f58c8587511bc10ed84a3465931df0b" checksum = "29277a4435d642f775f63c7d1faeb927adba532886ce0287bd985bffb16b6bca"
[[package]]
name = "windows_gen"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30dff4d91d22520628bb94b66f2bb313cb16a09a515a32320a84a1b449bc94c0"
dependencies = [ dependencies = [
"windows_quote", "windows_quote",
"windows_reader", "windows_reader",
@@ -4222,6 +4251,12 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8793f59f7b8e8b01eda1a652b2697d87b93097198ae85f823b969ca5b89bba58" checksum = "8793f59f7b8e8b01eda1a652b2697d87b93097198ae85f823b969ca5b89bba58"
[[package]]
name = "windows_i686_gnu"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1145e1989da93956c68d1864f32fb97c8f561a8f89a5125f6a2b7ea75524e4b8"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.24.0" version = "0.24.0"
@@ -4235,10 +4270,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8602f6c418b67024be2996c512f5f995de3ba417f4c75af68401ab8756796ae4" checksum = "8602f6c418b67024be2996c512f5f995de3ba417f4c75af68401ab8756796ae4"
[[package]] [[package]]
name = "windows_macros" name = "windows_i686_msvc"
version = "0.29.0" version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f6443f71f760ce91f4cc7fc81ee78f680dccb8ec110c52a92ec857a7def39a3" checksum = "d4a09e3a0d4753b73019db171c1339cd4362c8c44baf1bcea336235e955954a6"
[[package]]
name = "windows_macros"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62ae44ab917e9005fe710d99d52d227ca0164b10a09be90649142cc3fab825d3"
dependencies = [ dependencies = [
"syn", "syn",
"windows_gen", "windows_gen",
@@ -4248,15 +4289,15 @@ dependencies = [
[[package]] [[package]]
name = "windows_quote" name = "windows_quote"
version = "0.29.0" version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd83f20d7c391dc3b115a7e8a0851b71d0a9c356be2791571e858063b5f823c" checksum = "71f02c51a77e6248c1206aaa920802c32d50a05205e229b118d7f3afd3036667"
[[package]] [[package]]
name = "windows_reader" name = "windows_reader"
version = "0.29.0" version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d87b34c04457bad3c5436ffe1ed262c908228bb634e3bda34f4ce2c252495787" checksum = "e44e6df0da993cda589c5ac852272fbb2a0ead67a031a017dd3eac11528a2d72"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
@@ -4270,6 +4311,12 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d615f419543e0bd7d2b3323af0d86ff19cbc4f816e6453f36a2c2ce889c354" checksum = "f3d615f419543e0bd7d2b3323af0d86ff19cbc4f816e6453f36a2c2ce889c354"
[[package]]
name = "windows_x86_64_gnu"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ca64fcb0220d58db4c119e050e7af03c69e6f4f415ef69ec1773d9aab422d5a"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.24.0" version = "0.24.0"
@@ -4282,6 +4329,12 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11d95421d9ed3672c280884da53201a5c46b7b2765ca6faf34b0d71cf34a3561" checksum = "11d95421d9ed3672c280884da53201a5c46b7b2765ca6faf34b0d71cf34a3561"
[[package]]
name = "windows_x86_64_msvc"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08cabc9f0066848fef4bc6a1c1668e6efce38b661d2aeec75d18d8617eebb5f1"
[[package]] [[package]]
name = "winreg" name = "winreg"
version = "0.7.0" version = "0.7.0"
@@ -4311,9 +4364,9 @@ dependencies = [
[[package]] [[package]]
name = "winrt-notification" name = "winrt-notification"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eda101fb8e034a25f3d50a0714d7ca4f234a4fc7bc57427f6d81040db0ccbe6a" checksum = "007a0353840b23e0c6dc73e5b962ff58ed7f6bc9ceff3ce7fe6fbad8d496edf4"
dependencies = [ dependencies = [
"strum 0.22.0", "strum 0.22.0",
"windows 0.24.0", "windows 0.24.0",
@@ -4323,7 +4376,7 @@ dependencies = [
[[package]] [[package]]
name = "wry" name = "wry"
version = "0.12.2" version = "0.12.2"
source = "git+https://github.com/tauri-apps/wry?rev=3284f8d442978269f7654edbdfc9bc51022eaa40#3284f8d442978269f7654edbdfc9bc51022eaa40" source = "git+https://github.com/tauri-apps/wry?rev=a3829035a3e49e76db77b0db6924e147831124c7#a3829035a3e49e76db77b0db6924e147831124c7"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"core-graphics", "core-graphics",
@@ -4339,13 +4392,14 @@ dependencies = [
"once_cell", "once_cell",
"serde", "serde",
"serde_json", "serde_json",
"sys-info",
"tao", "tao",
"thiserror", "thiserror",
"url", "url",
"webkit2gtk", "webkit2gtk",
"webkit2gtk-sys", "webkit2gtk-sys",
"webview2-com", "webview2-com",
"windows 0.29.0", "windows 0.30.0",
"windows_macros", "windows_macros",
] ]

View File

@@ -1,11 +1,11 @@
[package] [package]
name = "app" name = "clash-verge"
version = "0.1.0" version = "0.1.0"
description = "clash verge" description = "clash verge"
authors = ["zzzgydi"] authors = ["zzzgydi"]
license = "GPL-3.0" license = "GPL-3.0"
repository = "https://github.com/zzzgydi/clash-verge.git" repository = "https://github.com/zzzgydi/clash-verge.git"
default-run = "app" default-run = "clash-verge"
edition = "2021" edition = "2021"
build = "build.rs" build = "build.rs"

View File

@@ -0,0 +1,16 @@
# Profile Template for clash verge
# the profile's name
name: New Profile
# the description of this profile(optional)
description:
# proxies defination (optional, the same as clash)
proxies:
# proxy-groups (optional, the same as clash)
proxy-groups:
# rules (optional, the same as clash)
rules:

View File

@@ -43,6 +43,42 @@ pub async fn import_profile(
} }
} }
/// new a profile
/// append a temp profile item file to the `profiles` dir
/// view the temp profile file by using vscode or other editor
#[tauri::command]
pub async fn new_profile(
name: String,
desc: String,
profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> {
let mut profiles = profiles_state.0.lock().unwrap();
let (_, path) = profiles.append_item(name, desc)?;
if !path.exists() {
return Err("the file not found".into());
}
// use vscode first
if let Ok(code) = which::which("code") {
return match Command::new(code).arg(path).status() {
Ok(_) => Ok(()),
Err(_) => Err("failed to open file by VScode".into()),
};
}
// use `open` command
if let Ok(open) = which::which("open") {
return match Command::new(open).arg(path).status() {
Ok(_) => Ok(()),
Err(_) => Err("failed to open file by `open`".into()),
};
}
return Err("failed to open the file, please edit the file manually".into());
}
/// Update the profile /// Update the profile
#[tauri::command] #[tauri::command]
pub async fn update_profile( pub async fn update_profile(
@@ -155,16 +191,28 @@ pub fn view_profile(index: usize, profiles_state: State<'_, ProfilesState>) -> R
let path = app_home_dir().join("profiles").join(file); let path = app_home_dir().join("profiles").join(file);
if !path.exists() { if !path.exists() {
return Err("failed to open the file".into()); return Err("the file not found".into());
} }
match which::which("code") { // use vscode first
Ok(code) => match Command::new(code).arg(path).status() { if let Ok(code) = which::which("code") {
return match Command::new(code).arg(path).status() {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(_) => Err("failed to open file by VScode".into()), Err(_) => Err("failed to open file by VScode".into()),
}, };
Err(_) => Err("please install VScode for edit".into()),
} }
// use `open` command
if let Ok(open) = which::which("open") {
return match Command::new(open).arg(path).status() {
Ok(_) => Ok(()),
Err(_) => Err("failed to open file by `open`".into()),
};
}
// recommand to use vscode
// todo: support other editors
return Err("please install VScode".into());
} }
/// restart the sidecar /// restart the sidecar

View File

@@ -7,6 +7,7 @@ use std::collections::HashMap;
use std::env::temp_dir; use std::env::temp_dir;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
/// Define the `profiles.yaml` schema /// Define the `profiles.yaml` schema
@@ -23,6 +24,8 @@ pub struct Profiles {
pub struct ProfileItem { pub struct ProfileItem {
/// profile name /// profile name
pub name: Option<String>, pub name: Option<String>,
/// profile description
pub desc: Option<String>,
/// profile file /// profile file
pub file: Option<String>, pub file: Option<String>,
/// current mode /// current mode
@@ -109,6 +112,7 @@ impl Profiles {
items.push(ProfileItem { items.push(ProfileItem {
name: Some(result.name), name: Some(result.name),
desc: Some("imported url".into()),
file: Some(result.file), file: Some(result.file),
mode: Some(format!("rule")), mode: Some(format!("rule")),
url: Some(url), url: Some(url),
@@ -138,6 +142,49 @@ impl Profiles {
self.save_file() self.save_file()
} }
/// append new item
/// return the new item's index
pub fn append_item(&mut self, name: String, desc: String) -> Result<(usize, PathBuf), String> {
let mut items = self.items.take().unwrap_or(vec![]);
// create a new profile file
let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs();
let file = format!("{}.yaml", now);
let path = dirs::app_home_dir().join("profiles").join(&file);
let file_data = b"# Profile Template for clash verge\n
# proxies defination (optional, the same as clash)
proxies:\n
# proxy-groups (optional, the same as clash)
proxy-groups:\n
# rules (optional, the same as clash)
rules:\n\n
";
match File::create(&path).unwrap().write(file_data) {
Ok(_) => {
items.push(ProfileItem {
name: Some(name),
desc: Some(desc),
file: Some(file),
mode: None,
url: None,
selected: Some(vec![]),
extra: None,
updated: Some(now as usize),
});
let index = items.len();
self.items = Some(items);
Ok((index, path))
}
Err(_) => Err("failed to create file".into()),
}
}
/// update the target profile /// update the target profile
/// and save to config file /// and save to config file
/// only support the url item /// only support the url item

View File

@@ -157,7 +157,10 @@ impl Verge {
match result { match result {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(_) => Err("failed to set system startup info".into()), Err(err) => {
log::error!("{err}");
Err("failed to set system startup info".into())
}
} }
} }
@@ -227,7 +230,7 @@ fn get_app_path(app_name: &str) -> String {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
let ext = ""; let ext = "";
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
let ext = ".app"; let ext = "";
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
let ext = ".exe"; let ext = ".exe";
String::from(app_name) + ext String::from(app_name) + ext

View File

@@ -60,10 +60,12 @@ fn main() -> std::io::Result<()> {
_ => {} _ => {}
}, },
SystemTrayEvent::LeftClick { .. } => { SystemTrayEvent::LeftClick { .. } => {
let window = app_handle.get_window("main").unwrap(); if cfg![target_os = "windows"] {
window.unminimize().unwrap(); let window = app_handle.get_window("main").unwrap();
window.show().unwrap(); window.unminimize().unwrap();
window.set_focus().unwrap(); window.show().unwrap();
window.set_focus().unwrap();
}
} }
_ => {} _ => {}
}) })
@@ -79,6 +81,7 @@ fn main() -> std::io::Result<()> {
cmds::get_verge_config, cmds::get_verge_config,
cmds::patch_verge_config, cmds::patch_verge_config,
// profile // profile
cmds::new_profile,
cmds::view_profile, cmds::view_profile,
cmds::patch_profile, cmds::patch_profile,
cmds::import_profile, cmds::import_profile,

View File

@@ -16,6 +16,7 @@ pub fn resolve_setup(app: &App) {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
{ {
use tauri_plugin_vibrancy::MacOSVibrancy; use tauri_plugin_vibrancy::MacOSVibrancy;
#[allow(deprecated)]
window.apply_vibrancy(MacOSVibrancy::AppearanceBased); window.apply_vibrancy(MacOSVibrancy::AppearanceBased);
} }

View File

@@ -1,7 +1,7 @@
{ {
"package": { "package": {
"productName": "clash-verge", "productName": "clash-verge",
"version": "0.0.13" "version": "0.0.14"
}, },
"build": { "build": {
"distDir": "../dist", "distDir": "../dist",

View File

@@ -59,6 +59,9 @@ const ProfileItem: React.FC<Props> = (props) => {
const progress = Math.round(((download + upload) * 100) / (total + 0.1)); const progress = Math.round(((download + upload) * 100) / (total + 0.1));
const fromnow = updated > 0 ? dayjs(updated * 1000).fromNow() : ""; const fromnow = updated > 0 ? dayjs(updated * 1000).fromNow() : "";
// url or file mode
const isUrlMode = itemData.url && extra;
const onView = async () => { const onView = async () => {
setAnchorEl(null); setAnchorEl(null);
try { try {
@@ -111,6 +114,13 @@ const ProfileItem: React.FC<Props> = (props) => {
event.preventDefault(); event.preventDefault();
}; };
const boxStyle = {
height: 26,
display: "flex",
alignItems: "center",
justifyContent: "space-between",
};
return ( return (
<> <>
<Wrapper <Wrapper
@@ -155,52 +165,63 @@ const ProfileItem: React.FC<Props> = (props) => {
{name} {name}
</Typography> </Typography>
<IconButton {isUrlMode && (
sx={{ <IconButton
width: 30, sx={{
height: 30, width: 26,
animation: loading ? `1s linear infinite ${round}` : "none", height: 26,
}} animation: loading ? `1s linear infinite ${round}` : "none",
color="inherit" }}
disabled={loading} color="inherit"
onClick={(e) => { disabled={loading}
e.stopPropagation(); onClick={(e) => {
onUpdateWrapper(false)(); e.stopPropagation();
}} onUpdateWrapper(false)();
> }}
<RefreshRounded /> >
</IconButton> <RefreshRounded />
</IconButton>
)}
</Box> </Box>
<Box display="flex" justifyContent="space-between" alignItems="center"> {isUrlMode ? (
<Typography noWrap title={`From: ${from}`}> <>
{from} <Box sx={boxStyle}>
</Typography> <Typography noWrap title={`From: ${from}`}>
{from}
</Typography>
<Typography <Typography
noWrap noWrap
flex="1 0 auto" flex="1 0 auto"
fontSize={14} fontSize={14}
textAlign="right" textAlign="right"
title="updated time" title="updated time"
> >
{fromnow} {fromnow}
</Typography> </Typography>
</Box> </Box>
<Box <Box sx={{ ...boxStyle, fontSize: 14 }}>
sx={{ <span title="used / total">
my: 0.5, {parseTraffic(upload + download)} / {parseTraffic(total)}
fontSize: 14, </span>
display: "flex", <span title="expire time">{expire}</span>
justifyContent: "space-between", </Box>
}} </>
> ) : (
<span title="used / total"> <>
{parseTraffic(upload + download)} / {parseTraffic(total)} <Box sx={boxStyle}>
</span> <Typography noWrap title={itemData.desc}>
<span title="expire time">{expire}</span> {itemData.desc}
</Box> </Typography>
</Box>
<Box sx={{ ...boxStyle, fontSize: 14, justifyContent: "flex-end" }}>
<span title="updated time">{parseExpire(updated)}</span>
</Box>
</>
)}
<LinearProgress <LinearProgress
variant="determinate" variant="determinate"

View File

@@ -6,6 +6,7 @@ import {
selectProfile, selectProfile,
patchProfile, patchProfile,
importProfile, importProfile,
newProfile,
} from "../services/cmds"; } from "../services/cmds";
import { getProxies, updateProxy } from "../services/api"; import { getProxies, updateProxy } from "../services/api";
import noop from "../utils/noop"; import noop from "../utils/noop";
@@ -94,6 +95,21 @@ const ProfilePage = () => {
} }
}; };
const lockNewRef = useRef(false);
const onNew = async () => {
if (lockNewRef.current) return;
lockNewRef.current = true;
try {
await newProfile("New Profile", "no desc");
mutate("getProfiles");
} catch (err: any) {
err && Notice.error(err.toString());
} finally {
lockNewRef.current = false;
}
};
return ( return (
<BasePage title="Profiles"> <BasePage title="Profiles">
<Box sx={{ display: "flex", mb: 3 }}> <Box sx={{ display: "flex", mb: 3 }}>
@@ -105,15 +121,19 @@ const ProfilePage = () => {
fullWidth fullWidth
value={url} value={url}
onChange={(e) => setUrl(e.target.value)} onChange={(e) => setUrl(e.target.value)}
sx={{ mr: 2 }} sx={{ mr: 1 }}
/> />
<Button <Button
disabled={!url || disabled} disabled={!url || disabled}
variant="contained" variant="contained"
onClick={onImport} onClick={onImport}
sx={{ mr: 1 }}
> >
Import Import
</Button> </Button>
<Button variant="contained" onClick={onNew}>
New
</Button>
</Box> </Box>
<Grid container spacing={3}> <Grid container spacing={3}>

View File

@@ -33,7 +33,7 @@ const ProxyPage = () => {
}, [proxiesData]); }, [proxiesData]);
const modeList = ["rule", "global", "direct"]; const modeList = ["rule", "global", "direct"];
const asGroup = curMode === "rule" || !groups.length; const asGroup = curMode === "rule" && groups.length;
// make sure that fetch the proxies successfully // make sure that fetch the proxies successfully
useEffect(() => { useEffect(() => {

View File

@@ -9,6 +9,10 @@ export async function syncProfiles() {
return invoke<void>("sync_profiles"); return invoke<void>("sync_profiles");
} }
export async function newProfile(name: string, desc: string) {
return invoke<void>("new_profile", { name, desc });
}
export async function viewProfile(index: number) { export async function viewProfile(index: number) {
return invoke<void>("view_profile", { index }); return invoke<void>("view_profile", { index });
} }

View File

@@ -87,6 +87,7 @@ export namespace CmdType {
export interface ProfileItem { export interface ProfileItem {
name?: string; name?: string;
desc?: string;
file?: string; file?: string;
mode?: string; mode?: string;
url?: string; url?: string;