60 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
GyDi
cceb4bb81f v0.0.13 2022-01-25 02:11:00 +08:00
GyDi
f0f45e007d feat: global proxies use virtual list 2022-01-25 02:08:10 +08:00
GyDi
6a8ffe1642 feat: enable change proxy mode 2022-01-25 01:51:44 +08:00
GyDi
3a73868c10 feat: update styles 2022-01-25 01:48:26 +08:00
GyDi
ab1b5897a6 feat: manage clash mode 2022-01-24 23:13:13 +08:00
GyDi
f94734a5c8 chore: update readme 2022-01-22 23:57:39 +08:00
GyDi
61b86c9584 v0.0.12 2022-01-21 03:09:21 +08:00
GyDi
1ac1d6e903 chore: update ci 2022-01-21 03:08:40 +08:00
GyDi
b6c58f74c0 fix: type error 2022-01-21 03:08:20 +08:00
GyDi
c88e99d87c v0.0.12 2022-01-21 02:59:33 +08:00
GyDi
8d7ab9d05e refactor: rename profiles & command state 2022-01-21 02:57:15 +08:00
GyDi
47155a4a29 feat: change system porxy when changed port 2022-01-21 02:50:13 +08:00
GyDi
d0b87fd7c3 feat: enable change mixed port 2022-01-21 02:32:23 +08:00
GyDi
d49fd37656 feat: manage clash config 2022-01-21 02:31:44 +08:00
GyDi
0bd29d71be chore: add ahooks 2022-01-21 02:29:45 +08:00
GyDi
4b5b62c8ae fix: restart clash should update something 2022-01-21 00:29:33 +08:00
GyDi
65fb2ca2d5 feat: enable update clash info 2022-01-20 23:41:08 +08:00
GyDi
0d5bfc0997 feat: rename edit as view 2022-01-19 23:58:34 +08:00
GyDi
4f02c373c2 chore: adjust ci 2022-01-19 23:55:05 +08:00
GyDi
209a5b1207 fix: script error... 2022-01-19 00:49:23 +08:00
GyDi
95349eacab fix: tag error 2022-01-19 00:46:43 +08:00
GyDi
82ba604b99 fix: script error 2022-01-19 00:42:37 +08:00
GyDi
46a8dec655 feat: test auto gen update.json ci 2022-01-19 00:37:59 +08:00
GyDi
b5af234524 v0.0.11 2022-01-17 02:53:07 +08:00
GyDi
b5c41750f7 fix: remove cargo test 2022-01-17 02:50:19 +08:00
GyDi
6083824eec v0.0.11 2022-01-17 02:44:08 +08:00
GyDi
40977785c3 feat: adjust setting typography 2022-01-17 02:42:52 +08:00
GyDi
5eddf4f1aa feat: enable force select profile 2022-01-17 02:28:23 +08:00
GyDi
99a8e25411 feat: support edit profile item 2022-01-17 02:16:17 +08:00
GyDi
08587d8f2f fix: reduce proxy item height 2022-01-17 02:15:54 +08:00
GyDi
3480d50f61 feat: adjust control ui 2022-01-17 02:15:06 +08:00
GyDi
43af55252d feat: update profile supports noproxy 2022-01-16 22:57:42 +08:00
GyDi
9c43b31fc0 refactor: something 2022-01-16 18:30:25 +08:00
GyDi
9ec7184aa1 fix: put profile request with no proxy 2022-01-16 18:20:01 +08:00
GyDi
4e2cb30db7 refactor: notice caller 2022-01-16 17:56:43 +08:00
GyDi
9ca83d3291 chore: change ci 2022-01-16 16:03:53 +08:00
GyDi
6b2172d873 fix: ci strategy 2022-01-16 14:30:49 +08:00
GyDi
1a5d9f7dad chore: enhance ci 2022-01-16 14:27:41 +08:00
GyDi
a8425862f0 feat: rename page 2022-01-16 03:25:50 +08:00
GyDi
a3a3db6abb refactor: setting page 2022-01-16 03:22:37 +08:00
GyDi
d6c3bc57c0 feat: refactor and adjust ui 2022-01-16 03:11:07 +08:00
GyDi
59c09f90f9 feat: rm some commands 2022-01-16 03:09:36 +08:00
GyDi
d982b83e14 feat: change type 2022-01-15 21:58:13 +08:00
GyDi
cc0e930d34 feat: supports auto launch on macos and windows 2022-01-15 21:55:05 +08:00
GyDi
3c3d77fbea chore: add auto-launch 2022-01-15 21:00:19 +08:00
GyDi
da7453fdbf v0.0.10 2022-01-13 02:53:29 +08:00
GyDi
5fcd25506e feat: adjust proxy page 2022-01-13 02:51:30 +08:00
GyDi
4979a472de feat: press esc hide the window 2022-01-13 02:11:50 +08:00
GyDi
4e8d4f4591 fix: version update error 2022-01-12 22:19:44 +08:00
57 changed files with 1952 additions and 1016 deletions

View File

@@ -1,26 +1,24 @@
name: Release Project name: CI
on: on: [push]
push:
tags: env:
- v* CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short
jobs: jobs:
build-tauri: release:
strategy: strategy:
fail-fast: false
matrix: matrix:
platform: [windows-latest, macos-latest] os: [windows-latest, macos-11]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.os }}
if: |
startsWith(github.repository, 'zzzgydi') &&
startsWith(github.ref, 'refs/tags/v')
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@@ -28,6 +26,14 @@ jobs:
profile: minimal profile: minimal
override: true override: true
- name: Rust Cache
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Get yarn cache dir path - name: Get yarn cache dir path
id: yarn-cache-dir-path id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)" run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -41,14 +47,15 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-yarn- ${{ runner.os }}-yarn-
- name: Rust Cache
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
- name: Yarn install and check - name: Yarn install and check
run: yarn && yarn run check run: |
yarn install --network-timeout 1000000
yarn run check
- name: Tauri build - name: Tauri build
uses: tauri-apps/tauri-action@v0 uses: tauri-apps/tauri-action@v0
# enable cache even though failed
continue-on-error: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
@@ -57,3 +64,35 @@ jobs:
releaseBody: "Clash Verge now supports Windows and macos(intel)." releaseBody: "Clash Verge now supports Windows and macos(intel)."
releaseDraft: false releaseDraft: false
prerelease: true prerelease: true
release-update:
needs: release
runs-on: macos-11
if: |
startsWith(github.repository, 'zzzgydi') &&
startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get yarn cache dir path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Yarn Cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
run: yarn
- name: Release update.json
run: yarn run release
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -58,6 +58,15 @@ This is a learning project for Rust practice.
PR welcome! PR welcome!
## Acknowledgement
Clash Verge was based on or inspired by these projects and so on:
- [tauri-apps/tauri](https://github.com/tauri-apps/tauri): Build smaller, faster, and more secure desktop applications with a web frontend.
- [Dreamacro/clash](https://github.com/Dreamacro/clash): A rule-based tunnel in Go.
- [Fndroid/clash_for_windows_pkg](https://github.com/Fndroid/clash_for_windows_pkg): A Windows/macOS GUI based on Clash.
- [vitejs/vite](https://github.com/vitejs/vite): Next generation frontend tooling. It's fast!
## License ## License
GPL-3.0 License GPL-3.0 License. See [License here](./LICENSE) for details.

View File

@@ -1,6 +1,6 @@
{ {
"name": "clash-verge", "name": "clash-verge",
"version": "0.0.9", "version": "0.0.14",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {
"dev": "cargo tauri dev", "dev": "cargo tauri dev",
@@ -11,6 +11,7 @@
"web:serve": "vite preview", "web:serve": "vite preview",
"check": "node scripts/check.mjs", "check": "node scripts/check.mjs",
"publish": "node scripts/publish.mjs", "publish": "node scripts/publish.mjs",
"release": "node scripts/release.mjs",
"prepare": "husky install" "prepare": "husky install"
}, },
"dependencies": { "dependencies": {
@@ -19,6 +20,7 @@
"@mui/icons-material": "^5.2.1", "@mui/icons-material": "^5.2.1",
"@mui/material": "^5.2.3", "@mui/material": "^5.2.3",
"@tauri-apps/api": "^1.0.0-beta.8", "@tauri-apps/api": "^1.0.0-beta.8",
"ahooks": "^3.1.7",
"axios": "^0.24.0", "axios": "^0.24.0",
"dayjs": "^1.10.7", "dayjs": "^1.10.7",
"react": "^17.0.0", "react": "^17.0.0",
@@ -29,8 +31,10 @@
"swr": "^1.1.2-beta.0" "swr": "^1.1.2-beta.0"
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "^5.0.0",
"@tauri-apps/cli": "^1.0.0-beta.10", "@tauri-apps/cli": "^1.0.0-beta.10",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/js-cookie": "^3.0.1",
"@types/react": "^17.0.0", "@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0", "@types/react-dom": "^17.0.0",
"@vitejs/plugin-react": "^1.1.1", "@vitejs/plugin-react": "^1.1.1",

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

View File

@@ -11,10 +11,16 @@ async function resolvePublish() {
let [a, b, c] = packageJson.version.split(".").map(Number); let [a, b, c] = packageJson.version.split(".").map(Number);
if (flag === "major") a += 1; if (flag === "major") {
else if (flag === "minor") b += 1; a += 1;
else if (flag === "patch") c += 1; b = 0;
else throw new Error(`invalid flag "${flag}"`); c = 0;
} else if (flag === "minor") {
b += 1;
c = 0;
} else if (flag === "patch") {
c += 1;
} else throw new Error(`invalid flag "${flag}"`);
const nextVersion = `${a}.${b}.${c}`; const nextVersion = `${a}.${b}.${c}`;
packageJson.version = nextVersion; packageJson.version = nextVersion;

68
scripts/release.mjs Normal file
View File

@@ -0,0 +1,68 @@
import { createRequire } from "module";
import { getOctokit, context } from "@actions/github";
const require = createRequire(import.meta.url);
/// generate update.json
/// upload to update tag's release asset
async function resolveRelease() {
if (process.env.GITHUB_TOKEN === undefined) {
throw new Error("GITHUB_TOKEN is required");
}
const packageJson = require("../package.json");
const { version } = packageJson;
const urlPrefix = "https://github.com/zzzgydi/clash-verge/releases/download";
const updateData = {
name: `v${version}`,
notes: `Version ${version} is available now!!!`,
pub_date: new Date().toISOString(),
platforms: {
win64: {
signature: "",
url: `${urlPrefix}/v${version}/clash-verge_${version}_x64.msi.zip`,
},
darwin: {
signature: "",
url: `${urlPrefix}/v${version}/clash-verge.app.tar.gz`,
},
},
};
console.log(`Generating Version "${version}" update.json`);
const github = getOctokit(process.env.GITHUB_TOKEN);
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: "updater",
});
const { data: assets } = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
});
for (let asset of assets) {
if (asset.name === "update.json") {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id,
});
break;
}
}
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
name: "update.json",
data: JSON.stringify(updateData, null, 2),
});
}
resolveRelease();

329
src-tauri/Cargo.lock generated
View File

@@ -34,31 +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 = [
"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",
"winreg 0.10.1",
]
[[package]] [[package]]
name = "arc-swap" name = "arc-swap"
@@ -145,6 +123,16 @@ dependencies = [
"wildmatch", "wildmatch",
] ]
[[package]]
name = "auto-launch"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f0ab475f9b1049a9d4e9c83f45ff27ec3bce4a6cb8e58e7f29030f8992af8c5"
dependencies = [
"dirs 4.0.0",
"winreg 0.10.1",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.0.1" version = "1.0.1"
@@ -185,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",
@@ -378,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"
@@ -482,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",
] ]
@@ -792,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",
] ]
@@ -1094,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",
@@ -1259,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",
@@ -1577,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",
] ]
@@ -1627,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"
@@ -2106,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"
@@ -2134,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",
@@ -2487,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",
] ]
@@ -2555,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]]
@@ -2651,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",
] ]
@@ -2830,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",
@@ -2843,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",
@@ -2897,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",
] ]
@@ -2916,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",
@@ -2927,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",
@@ -2949,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",
] ]
@@ -3024,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"
@@ -3036,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",
@@ -3164,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"
@@ -3207,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",
@@ -3240,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",
] ]
@@ -3271,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",
@@ -3333,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",
@@ -3351,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",
@@ -3362,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",
@@ -3396,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",
@@ -3412,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",
] ]
@@ -3437,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",
@@ -3516,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",
] ]
@@ -3551,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",
@@ -3688,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",
@@ -3835,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]]
@@ -3933,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",
@@ -3943,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",
@@ -3958,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",
@@ -3970,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",
@@ -3980,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",
@@ -3993,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",
@@ -4055,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",
] ]
@@ -4078,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",
] ]
@@ -4099,6 +4121,17 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "which"
version = "4.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
dependencies = [
"either",
"lazy_static",
"libc",
]
[[package]] [[package]]
name = "wildmatch" name = "wildmatch"
version = "2.1.0" version = "2.1.0"
@@ -4154,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",
@@ -4162,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",
@@ -4178,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",
@@ -4199,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"
@@ -4212,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",
@@ -4225,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"
@@ -4247,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"
@@ -4259,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"
@@ -4288,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",
@@ -4300,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",
@@ -4316,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"
@@ -29,6 +29,8 @@ tokio = { version = "1", features = ["full"] }
log = "0.4.14" log = "0.4.14"
log4rs = "1.0.0" log4rs = "1.0.0"
warp = "0.3" warp = "0.3"
which = "4.2.2"
auto-launch = "0.2"
port_scanner = "0.1.5" port_scanner = "0.1.5"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]

View File

@@ -4,4 +4,5 @@ mixed-port: 7890
log-level: info log-level: info
allow-lan: false allow-lan: false
external-controller: 127.0.0.1:9090 external-controller: 127.0.0.1:9090
mode: rule
secret: "" secret: ""

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

@@ -1,20 +1,17 @@
use crate::{ use crate::{
core::{ClashInfo, ProfileItem, ProfilesConfig, VergeConfig}, core::{ClashInfo, ProfileItem, Profiles, VergeConfig},
states::{ClashState, ProfilesState, VergeState}, states::{ClashState, ProfilesState, VergeState},
utils::{ utils::{dirs::app_home_dir, fetch::fetch_profile, sysopt::SysProxyConfig},
config::{read_clash, save_clash},
fetch::fetch_profile,
sysopt::SysProxyConfig,
},
}; };
use serde_yaml::Mapping; use serde_yaml::Mapping;
use tauri::{AppHandle, Manager, State}; use std::process::Command;
use tauri::State;
/// get all profiles from `profiles.yaml` /// get all profiles from `profiles.yaml`
/// do not acquire the lock of ProfileLock /// do not acquire the lock of ProfileLock
#[tauri::command] #[tauri::command]
pub fn get_profiles(profiles: State<'_, ProfilesState>) -> Result<ProfilesConfig, String> { pub fn get_profiles(profiles_state: State<'_, ProfilesState>) -> Result<Profiles, String> {
match profiles.0.lock() { match profiles_state.0.lock() {
Ok(profiles) => Ok(profiles.clone()), Ok(profiles) => Ok(profiles.clone()),
Err(_) => Err("failed to get profiles lock".into()), Err(_) => Err("failed to get profiles lock".into()),
} }
@@ -22,38 +19,76 @@ pub fn get_profiles(profiles: State<'_, ProfilesState>) -> Result<ProfilesConfig
/// synchronize data irregularly /// synchronize data irregularly
#[tauri::command] #[tauri::command]
pub fn sync_profiles(profiles: State<'_, ProfilesState>) -> Result<(), String> { pub fn sync_profiles(profiles_state: State<'_, ProfilesState>) -> Result<(), String> {
match profiles.0.lock() { match profiles_state.0.lock() {
Ok(mut profiles) => profiles.sync_file(), Ok(mut profiles) => profiles.sync_file(),
Err(_) => Err("failed to get profiles lock".into()), Err(_) => Err("failed to get profiles lock".into()),
} }
} }
/// Import the profile from url /// import the profile from url
/// and save to `profiles.yaml` /// and save to `profiles.yaml`
#[tauri::command] #[tauri::command]
pub async fn import_profile(url: String, profiles: State<'_, ProfilesState>) -> Result<(), String> { pub async fn import_profile(
match fetch_profile(&url).await { url: String,
with_proxy: bool,
profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> {
match fetch_profile(&url, with_proxy).await {
Some(result) => { Some(result) => {
let mut profiles = profiles.0.lock().unwrap(); let mut profiles = profiles_state.0.lock().unwrap();
profiles.import_from_url(url, result) profiles.import_from_url(url, result)
} }
None => Err(format!("failed to fetch profile from `{}`", url)), None => Err(format!("failed to fetch profile from `{}`", url)),
} }
} }
/// 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
/// and save to `profiles.yaml`
/// http request firstly
/// then acquire the lock of `profiles.yaml`
#[tauri::command] #[tauri::command]
pub async fn update_profile( pub async fn update_profile(
index: usize, index: usize,
clash: State<'_, ClashState>, with_proxy: bool,
profiles: State<'_, ProfilesState>, clash_state: State<'_, ClashState>,
profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> { ) -> Result<(), String> {
// maybe we can get the url from the web app directly // maybe we can get the url from the web app directly
let url = match profiles.0.lock() { let url = match profiles_state.0.lock() {
Ok(mut profile) => { Ok(mut profile) => {
let items = profile.items.take().unwrap_or(vec![]); let items = profile.items.take().unwrap_or(vec![]);
if index >= items.len() { if index >= items.len() {
@@ -69,16 +104,16 @@ pub async fn update_profile(
Err(_) => return Err("failed to get profiles lock".into()), Err(_) => return Err("failed to get profiles lock".into()),
}; };
match fetch_profile(&url).await { match fetch_profile(&url, with_proxy).await {
Some(result) => match profiles.0.lock() { Some(result) => match profiles_state.0.lock() {
Ok(mut profiles) => { Ok(mut profiles) => {
profiles.update_item(index, result)?; profiles.update_item(index, result)?;
// reactivate the profile // reactivate the profile
let current = profiles.current.clone().unwrap_or(0); let current = profiles.current.clone().unwrap_or(0);
if current == index { if current == index {
let clash = clash.0.lock().unwrap(); let clash = clash_state.0.lock().unwrap();
profiles.activate(clash.info.clone()) profiles.activate(&clash)
} else { } else {
Ok(()) Ok(())
} }
@@ -93,15 +128,15 @@ pub async fn update_profile(
#[tauri::command] #[tauri::command]
pub fn select_profile( pub fn select_profile(
index: usize, index: usize,
clash: State<'_, ClashState>, clash_state: State<'_, ClashState>,
profiles: State<'_, ProfilesState>, profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> { ) -> Result<(), String> {
let mut profiles = profiles.0.lock().unwrap(); let mut profiles = profiles_state.0.lock().unwrap();
match profiles.put_current(index) { match profiles.put_current(index) {
Ok(()) => { Ok(()) => {
let clash = clash.0.lock().unwrap(); let clash = clash_state.0.lock().unwrap();
profiles.activate(clash.info.clone()) profiles.activate(&clash)
} }
Err(err) => Err(err), Err(err) => Err(err),
} }
@@ -119,7 +154,7 @@ pub fn delete_profile(
Ok(change) => match change { Ok(change) => match change {
true => { true => {
let clash = clash_state.0.lock().unwrap(); let clash = clash_state.0.lock().unwrap();
profiles.activate(clash.info.clone()) profiles.activate(&clash)
} }
false => Ok(()), false => Ok(()),
}, },
@@ -132,14 +167,54 @@ pub fn delete_profile(
pub fn patch_profile( pub fn patch_profile(
index: usize, index: usize,
profile: ProfileItem, profile: ProfileItem,
profiles: State<'_, ProfilesState>, profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> { ) -> Result<(), String> {
match profiles.0.lock() { match profiles_state.0.lock() {
Ok(mut profiles) => profiles.patch_item(index, profile), Ok(mut profiles) => profiles.patch_item(index, profile),
Err(_) => Err("can not get profiles lock".into()), Err(_) => Err("can not get profiles lock".into()),
} }
} }
/// run vscode command to edit the profile
#[tauri::command]
pub fn view_profile(index: usize, profiles_state: State<'_, ProfilesState>) -> Result<(), String> {
let mut profiles = profiles_state.0.lock().unwrap();
let items = profiles.items.take().unwrap_or(vec![]);
if index >= items.len() {
profiles.items = Some(items);
return Err("the index out of bound".into());
}
let file = items[index].file.clone().unwrap_or("".into());
profiles.items = Some(items);
let path = app_home_dir().join("profiles").join(file);
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()),
};
}
// recommand to use vscode
// todo: support other editors
return Err("please install VScode".into());
}
/// restart the sidecar /// restart the sidecar
#[tauri::command] #[tauri::command]
pub fn restart_sidecar( pub fn restart_sidecar(
@@ -147,18 +222,10 @@ pub fn restart_sidecar(
profiles_state: State<'_, ProfilesState>, profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> { ) -> Result<(), String> {
let mut clash = clash_state.0.lock().unwrap(); let mut clash = clash_state.0.lock().unwrap();
let mut profiles = profiles_state.0.lock().unwrap();
match clash.restart_sidecar() { match clash.restart_sidecar(&mut profiles) {
Ok(_) => { Ok(_) => Ok(()),
let profiles = profiles_state.0.lock().unwrap();
match profiles.activate(clash.info.clone()) {
Ok(()) => Ok(()),
Err(err) => {
log::error!("{}", err);
Err(err)
}
}
}
Err(err) => { Err(err) => {
log::error!("{}", err); log::error!("{}", err);
Err(err) Err(err)
@@ -171,26 +238,25 @@ pub fn restart_sidecar(
#[tauri::command] #[tauri::command]
pub fn get_clash_info(clash_state: State<'_, ClashState>) -> Result<ClashInfo, String> { pub fn get_clash_info(clash_state: State<'_, ClashState>) -> Result<ClashInfo, String> {
match clash_state.0.lock() { match clash_state.0.lock() {
Ok(arc) => Ok(arc.info.clone()), Ok(clash) => Ok(clash.info.clone()),
Err(_) => Err("failed to get clash lock".into()), Err(_) => Err("failed to get clash lock".into()),
} }
} }
/// todo: need refactor
/// update the clash core config /// update the clash core config
/// after putting the change to the clash core /// after putting the change to the clash core
/// then we should save the latest config /// then we should save the latest config
#[tauri::command] #[tauri::command]
pub fn patch_clash_config(payload: Mapping) -> Result<(), String> { pub fn patch_clash_config(
let mut config = read_clash(); payload: Mapping,
for (key, value) in payload.iter() { clash_state: State<'_, ClashState>,
if config.contains_key(key) { verge_state: State<'_, VergeState>,
config[key] = value.clone(); profiles_state: State<'_, ProfilesState>,
} else { ) -> Result<(), String> {
config.insert(key.clone(), value.clone()); let mut clash = clash_state.0.lock().unwrap();
} let mut verge = verge_state.0.lock().unwrap();
} let mut profiles = profiles_state.0.lock().unwrap();
save_clash(&config) clash.patch_config(payload, &mut verge, &mut profiles)
} }
/// get the system proxy /// get the system proxy
@@ -231,25 +297,3 @@ pub async fn patch_verge_config(
let mut verge = verge_state.0.lock().unwrap(); let mut verge = verge_state.0.lock().unwrap();
verge.patch_config(payload) verge.patch_config(payload)
} }
/// start dragging window
#[tauri::command]
pub fn win_drag(app_handle: AppHandle) {
let window = app_handle.get_window("main").unwrap();
window.start_dragging().unwrap();
}
/// hide the window
#[tauri::command]
pub fn win_hide(app_handle: AppHandle) {
let window = app_handle.get_window("main").unwrap();
window.hide().unwrap();
}
/// mini the window
#[tauri::command]
pub fn win_mini(app_handle: AppHandle) {
let window = app_handle.get_window("main").unwrap();
// todo: these methods still has bug on Windows
window.minimize().unwrap();
}

View File

@@ -1,3 +1,4 @@
use super::{Profiles, Verge};
use crate::utils::{config, dirs}; use crate::utils::{config, dirs};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_yaml::{Mapping, Value}; use serde_yaml::{Mapping, Value};
@@ -20,6 +21,9 @@ pub struct ClashInfo {
#[derive(Debug)] #[derive(Debug)]
pub struct Clash { pub struct Clash {
/// maintain the clash config
pub config: Mapping,
/// some info /// some info
pub info: ClashInfo, pub info: ClashInfo,
@@ -32,8 +36,19 @@ static CLASH_CONFIG: &str = "config.yaml";
// todo: be able to change config field // todo: be able to change config field
impl Clash { impl Clash {
pub fn new() -> Clash { pub fn new() -> Clash {
let clash_config = config::read_yaml::<Mapping>(dirs::app_home_dir().join(CLASH_CONFIG)); let config = Clash::get_config();
let info = Clash::get_info(&config);
Clash {
config,
info,
sidecar: None,
}
}
/// parse the clash's config.yaml
/// get some information
fn get_info(clash_config: &Mapping) -> ClashInfo {
let key_port_1 = Value::String("port".to_string()); let key_port_1 = Value::String("port".to_string());
let key_port_2 = Value::String("mixed-port".to_string()); let key_port_2 = Value::String("mixed-port".to_string());
let key_server = Value::String("external-controller".to_string()); let key_server = Value::String("external-controller".to_string());
@@ -76,14 +91,11 @@ impl Clash {
_ => None, _ => None,
}; };
Clash { ClashInfo {
info: ClashInfo { status: "init".into(),
status: "init".into(), port,
port, server,
server, secret,
secret,
},
sidecar: None,
} }
} }
@@ -126,9 +138,70 @@ impl Clash {
} }
/// restart clash sidecar /// restart clash sidecar
pub fn restart_sidecar(&mut self) -> Result<(), String> { /// should reactivate profile after restart
pub fn restart_sidecar(&mut self, profiles: &mut Profiles) -> Result<(), String> {
self.update_config();
self.drop_sidecar()?; self.drop_sidecar()?;
self.run_sidecar() self.run_sidecar()?;
profiles.activate(&self)
}
/// update the clash info
pub fn update_config(&mut self) {
self.config = Clash::get_config();
self.info = Clash::get_info(&self.config);
}
/// get clash config
fn get_config() -> Mapping {
config::read_yaml::<Mapping>(dirs::app_home_dir().join(CLASH_CONFIG))
}
/// save the clash config
fn save_config(&self) -> Result<(), String> {
config::save_yaml(
dirs::app_home_dir().join(CLASH_CONFIG),
&self.config,
Some("# Default Config For Clash Core\n\n"),
)
}
/// patch update the clash config
pub fn patch_config(
&mut self,
patch: Mapping,
verge: &mut Verge,
profiles: &mut Profiles,
) -> Result<(), String> {
for (key, value) in patch.iter() {
let value = value.clone();
let key_str = key.as_str().clone().unwrap_or("");
// restart the clash
if key_str == "mixed-port" {
self.restart_sidecar(profiles)?;
let port = if value.is_number() {
match value.as_i64().clone() {
Some(num) => Some(format!("{num}")),
None => None,
}
} else {
match value.as_str().clone() {
Some(num) => Some(num.into()),
None => None,
}
};
verge.init_sysproxy(port);
}
if self.config.contains_key(key) {
self.config[key] = value;
} else {
self.config.insert(key.clone(), value);
}
}
self.save_config()
} }
} }

View File

@@ -1,3 +1,4 @@
use super::{Clash, ClashInfo};
use crate::utils::{config, dirs}; use crate::utils::{config, dirs};
use reqwest::header::HeaderMap; use reqwest::header::HeaderMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -6,13 +7,12 @@ 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};
use super::ClashInfo;
/// Define the `profiles.yaml` schema /// Define the `profiles.yaml` schema
#[derive(Default, Debug, Clone, Deserialize, Serialize)] #[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct ProfilesConfig { pub struct Profiles {
/// current profile's name /// current profile's name
pub current: Option<usize>, pub current: Option<usize>,
@@ -24,6 +24,8 @@ pub struct ProfilesConfig {
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
@@ -64,10 +66,10 @@ pub struct ProfileResponse {
static PROFILE_YAML: &str = "profiles.yaml"; static PROFILE_YAML: &str = "profiles.yaml";
static PROFILE_TEMP: &str = "clash-verge-runtime.yaml"; static PROFILE_TEMP: &str = "clash-verge-runtime.yaml";
impl ProfilesConfig { impl Profiles {
/// read the config from the file /// read the config from the file
pub fn read_file() -> Self { pub fn read_file() -> Self {
config::read_yaml::<ProfilesConfig>(dirs::app_home_dir().join(PROFILE_YAML)) config::read_yaml::<Profiles>(dirs::app_home_dir().join(PROFILE_YAML))
} }
/// save the config to the file /// save the config to the file
@@ -100,7 +102,7 @@ impl ProfilesConfig {
File::create(path).unwrap().write(file_data).unwrap(); File::create(path).unwrap().write(file_data).unwrap();
// update `profiles.yaml` // update `profiles.yaml`
let data = ProfilesConfig::read_file(); let data = Profiles::read_file();
let mut items = data.items.unwrap_or(vec![]); let mut items = data.items.unwrap_or(vec![]);
let now = SystemTime::now() let now = SystemTime::now()
@@ -110,6 +112,7 @@ impl ProfilesConfig {
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),
@@ -139,6 +142,49 @@ impl ProfilesConfig {
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
@@ -224,7 +270,7 @@ impl ProfilesConfig {
} }
/// activate current profile /// activate current profile
pub fn activate(&self, clash_config: ClashInfo) -> Result<(), String> { pub fn activate(&self, clash: &Clash) -> Result<(), String> {
let current = self.current.unwrap_or(0); let current = self.current.unwrap_or(0);
match self.items.clone() { match self.items.clone() {
Some(items) => { Some(items) => {
@@ -233,11 +279,13 @@ impl ProfilesConfig {
} }
let profile = items[current].clone(); let profile = items[current].clone();
let clash_config = clash.config.clone();
let clash_info = clash.info.clone();
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
let mut count = 5; // retry times let mut count = 5; // retry times
let mut err = String::from(""); let mut err = String::from("");
while count > 0 { while count > 0 {
match activate_profile(&profile, &clash_config).await { match activate_profile(&profile, &clash_config, &clash_info).await {
Ok(_) => return, Ok(_) => return,
Err(e) => err = e, Err(e) => err = e,
} }
@@ -254,7 +302,11 @@ impl ProfilesConfig {
} }
/// put the profile to clash /// put the profile to clash
pub async fn activate_profile(profile_item: &ProfileItem, info: &ClashInfo) -> Result<(), String> { pub async fn activate_profile(
profile_item: &ProfileItem,
clash_config: &Mapping,
clash_info: &ClashInfo,
) -> Result<(), String> {
// temp profile's path // temp profile's path
let temp_path = temp_dir().join(PROFILE_TEMP); let temp_path = temp_dir().join(PROFILE_TEMP);
@@ -267,25 +319,47 @@ pub async fn activate_profile(profile_item: &ProfileItem, info: &ClashInfo) -> R
let file_path = dirs::app_home_dir().join("profiles").join(file_name); let file_path = dirs::app_home_dir().join("profiles").join(file_name);
if !file_path.exists() { if !file_path.exists() {
return Err(format!("profile `{:?}` not exists", file_path)); return Err(format!(
"profile `{}` not exists",
file_path.as_os_str().to_str().unwrap()
));
} }
// begin to generate the new profile config
let def_config = config::read_yaml::<Mapping>(file_path.clone());
let mut new_config = Mapping::new();
// Only the following fields are allowed: // Only the following fields are allowed:
// proxies/proxy-providers/proxy-groups/rule-providers/rules // proxies/proxy-providers/proxy-groups/rule-providers/rules
let config = config::read_yaml::<Mapping>(file_path.clone()); let valid_keys = vec![
let mut new_config = Mapping::new();
vec![
"proxies", "proxies",
"proxy-providers", "proxy-providers",
"proxy-groups", "proxy-groups",
"rule-providers", "rule-providers",
"rules", "rules",
] ];
.iter() valid_keys.iter().for_each(|key| {
.map(|item| Value::String(item.to_string())) let key = Value::String(key.to_string());
.for_each(|key| { if def_config.contains_key(&key) {
if config.contains_key(&key) { let value = def_config[&key].clone();
let value = config[&key].clone(); new_config.insert(key, value);
}
});
// add some of the clash `config.yaml` config to it
let valid_keys = vec![
"mixed-port",
"log-level",
"allow-lan",
"external-controller",
"secret",
"mode",
"ipv6",
];
valid_keys.iter().for_each(|key| {
let key = Value::String(key.to_string());
if clash_config.contains_key(&key) {
let value = clash_config[&key].clone();
new_config.insert(key, value); new_config.insert(key, value);
} }
}); });
@@ -297,12 +371,12 @@ pub async fn activate_profile(profile_item: &ProfileItem, info: &ClashInfo) -> R
)? )?
}; };
let server = format!("http://{}/configs", info.server.clone().unwrap()); let server = format!("http://{}/configs", clash_info.server.clone().unwrap());
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
headers.insert("Content-Type", "application/json".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
if let Some(secret) = info.secret.clone() { if let Some(secret) = clash_info.secret.clone() {
headers.insert( headers.insert(
"Authorization", "Authorization",
format!("Bearer {}", secret).parse().unwrap(), format!("Bearer {}", secret).parse().unwrap(),
@@ -312,7 +386,10 @@ pub async fn activate_profile(profile_item: &ProfileItem, info: &ClashInfo) -> R
let mut data = HashMap::new(); let mut data = HashMap::new();
data.insert("path", temp_path.as_os_str().to_str().unwrap()); data.insert("path", temp_path.as_os_str().to_str().unwrap());
let client = reqwest::Client::new(); let client = match reqwest::ClientBuilder::new().no_proxy().build() {
Ok(c) => c,
Err(_) => return Err("failed to create http::put".into()),
};
match client.put(server).headers(headers).json(&data).send().await { match client.put(server).headers(headers).json(&data).send().await {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(err) => Err(format!("request failed `{}`", err.to_string())), Err(err) => Err(format!("request failed `{}`", err.to_string())),

View File

@@ -1,6 +1,6 @@
use crate::utils::{config, dirs, startup, sysopt::SysProxyConfig}; use crate::utils::{config, dirs, sysopt::SysProxyConfig};
use auto_launch::{AutoLaunch, AutoLaunchBuilder};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use tauri::api::path::resource_dir; use tauri::api::path::resource_dir;
/// ### `verge.yaml` schema /// ### `verge.yaml` schema
@@ -14,7 +14,7 @@ pub struct VergeConfig {
pub theme_blur: Option<bool>, pub theme_blur: Option<bool>,
/// can the app auto startup /// can the app auto startup
pub enable_self_startup: Option<bool>, pub enable_auto_launch: Option<bool>,
/// set system proxy /// set system proxy
pub enable_system_proxy: Option<bool>, pub enable_system_proxy: Option<bool>,
@@ -49,7 +49,7 @@ pub struct Verge {
pub cur_sysproxy: Option<SysProxyConfig>, pub cur_sysproxy: Option<SysProxyConfig>,
pub exe_path: Option<PathBuf>, pub auto_launch: Option<AutoLaunch>,
} }
impl Default for Verge { impl Default for Verge {
@@ -64,7 +64,7 @@ impl Verge {
config: VergeConfig::new(), config: VergeConfig::new(),
old_sysproxy: None, old_sysproxy: None,
cur_sysproxy: None, cur_sysproxy: None,
exe_path: None, auto_launch: None,
} }
} }
@@ -101,58 +101,87 @@ impl Verge {
} }
} }
/// set the exe_path /// init the auto launch
pub fn set_exe_path(&mut self, package_info: &tauri::PackageInfo) { pub fn init_launch(&mut self, package_info: &tauri::PackageInfo) {
let exe = if cfg!(target_os = "windows") { let app_name = "clash-verge";
"clash-verge.exe" let app_path = get_app_path(app_name);
} else { let app_path = resource_dir(package_info).unwrap().join(app_path);
"clash-verge" let app_path = app_path.as_os_str().to_str().unwrap();
};
let path = resource_dir(package_info).unwrap().join(exe); let auto = AutoLaunchBuilder::new()
self.exe_path = Some(path); .set_app_name(app_name)
.set_app_path(app_path)
.build();
self.auto_launch = Some(auto);
} }
/// sync the startup when run the app /// sync the startup when run the app
pub fn sync_startup(&self) -> Result<(), String> { pub fn sync_launch(&self) -> Result<(), String> {
let enable = self.config.enable_self_startup.clone().unwrap_or(false); let enable = self.config.enable_auto_launch.clone().unwrap_or(false);
if !enable { if !enable {
return Ok(()); return Ok(());
} }
if self.exe_path.is_none() {
return Err("should init the exe_path first".into()); if self.auto_launch.is_none() {
return Err("should init the auto launch first".into());
} }
let exe_path = self.exe_path.clone().unwrap(); let auto_launch = self.auto_launch.clone().unwrap();
match startup::get_startup(&exe_path) {
Ok(sys_enable) => { let is_enabled = auto_launch.is_enabled().unwrap_or(false);
if sys_enable || (!sys_enable && startup::set_startup(true, &exe_path).is_ok()) { if !is_enabled {
Ok(()) if let Err(_) = auto_launch.enable() {
} else { return Err("failed to enable auto-launch".into());
Err("failed to sync startup".into())
}
} }
Err(_) => Err("failed to get system startup info".into()),
} }
Ok(())
} }
/// update the startup /// update the startup
fn update_startup(&mut self, enable: bool) -> Result<(), String> { fn update_launch(&mut self, enable: bool) -> Result<(), String> {
let conf_enable = self.config.enable_self_startup.clone().unwrap_or(false); let conf_enable = self.config.enable_auto_launch.clone().unwrap_or(false);
if enable == conf_enable { if enable == conf_enable {
return Ok(()); return Ok(());
} }
if self.exe_path.is_none() {
return Err("should init the exe_path first".into()); let auto_launch = self.auto_launch.clone().unwrap();
}
let exe_path = self.exe_path.clone().unwrap(); let result = if enable {
match startup::set_startup(enable, &exe_path) { auto_launch.enable()
} else {
auto_launch.disable()
};
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())
}
} }
} }
// fn guard_thread(&mut self) -> Result<(), String> {
// let sysproxy = self.cur_sysproxy.clone();
// use std::{thread, time};
// tauri::async_runtime::spawn(async move {
// if let Some(sysproxy) = sysproxy {
// sysproxy.set_sys();
// }
// let ten_millis = time::Duration::from_millis(10);
// let now = time::Instant::now();
// thread::sleep(ten_millis);
// });
// Ok(())
// }
/// patch verge config /// patch verge config
/// There should be only one update at a time here /// There should be only one update at a time here
/// so call the save_file at the end is savely /// so call the save_file at the end is savely
@@ -166,10 +195,10 @@ impl Verge {
} }
// should update system startup // should update system startup
if patch.enable_self_startup.is_some() { if patch.enable_auto_launch.is_some() {
let enable = patch.enable_self_startup.unwrap(); let enable = patch.enable_auto_launch.unwrap();
self.update_startup(enable)?; self.update_launch(enable)?;
self.config.enable_self_startup = Some(enable); self.config.enable_auto_launch = Some(enable);
} }
// should update system proxy // should update system proxy
@@ -187,7 +216,7 @@ impl Verge {
} }
// todo // todo
// should update system proxt too // should update system proxy too
if patch.system_proxy_bypass.is_some() { if patch.system_proxy_bypass.is_some() {
self.config.system_proxy_bypass = patch.system_proxy_bypass; self.config.system_proxy_bypass = patch.system_proxy_bypass;
} }
@@ -195,3 +224,14 @@ impl Verge {
self.config.save_file() self.config.save_file()
} }
} }
// Get the target app_path
fn get_app_path(app_name: &str) -> String {
#[cfg(target_os = "linux")]
let ext = "";
#[cfg(target_os = "macos")]
let ext = "";
#[cfg(target_os = "windows")]
let ext = ".exe";
String::from(app_name) + ext
}

View File

@@ -3,8 +3,6 @@
windows_subsystem = "windows" windows_subsystem = "windows"
)] )]
extern crate tauri;
mod cmds; mod cmds;
mod core; mod core;
mod states; mod states;
@@ -37,19 +35,19 @@ fn main() -> std::io::Result<()> {
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() { SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
"open_window" => { "open_window" => {
let window = app_handle.get_window("main").unwrap(); let window = app_handle.get_window("main").unwrap();
window.unminimize().unwrap();
window.show().unwrap(); window.show().unwrap();
window.set_focus().unwrap(); window.set_focus().unwrap();
} }
"restart_clash" => { "restart_clash" => {
let clash_state = app_handle.state::<states::ClashState>(); let clash_state = app_handle.state::<states::ClashState>();
let profiles_state = app_handle.state::<states::ProfilesState>();
let mut clash = clash_state.0.lock().unwrap(); let mut clash = clash_state.0.lock().unwrap();
match clash.restart_sidecar() { let mut profiles = profiles_state.0.lock().unwrap();
match clash.restart_sidecar(&mut profiles) {
Ok(_) => { Ok(_) => {
let profiles = app_handle.state::<states::ProfilesState>(); let window = app_handle.get_window("main").unwrap();
let profiles = profiles.0.lock().unwrap(); window.emit("restart_clash", "yes").unwrap();
if let Err(err) = profiles.activate(clash.info.clone()) {
log::error!("{}", err);
}
} }
Err(err) => log::error!("{}", err), Err(err) => log::error!("{}", err),
} }
@@ -62,9 +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.show().unwrap(); let window = app_handle.get_window("main").unwrap();
window.set_focus().unwrap(); window.unminimize().unwrap();
window.show().unwrap();
window.set_focus().unwrap();
}
} }
_ => {} _ => {}
}) })
@@ -73,9 +74,6 @@ fn main() -> std::io::Result<()> {
cmds::restart_sidecar, cmds::restart_sidecar,
cmds::get_sys_proxy, cmds::get_sys_proxy,
cmds::get_cur_proxy, cmds::get_cur_proxy,
cmds::win_drag,
cmds::win_hide,
cmds::win_mini,
// clash // clash
cmds::get_clash_info, cmds::get_clash_info,
cmds::patch_clash_config, cmds::patch_clash_config,
@@ -83,13 +81,15 @@ 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::patch_profile,
cmds::import_profile, cmds::import_profile,
cmds::update_profile, cmds::update_profile,
cmds::delete_profile, cmds::delete_profile,
cmds::select_profile, cmds::select_profile,
cmds::patch_profile,
cmds::sync_profiles,
cmds::get_profiles, cmds::get_profiles,
cmds::sync_profiles,
]) ])
.build(tauri::generate_context!()) .build(tauri::generate_context!())
.expect("error while running tauri application") .expect("error while running tauri application")

View File

@@ -1,8 +1,8 @@
use crate::core::{Clash, ProfilesConfig, Verge}; use crate::core::{Clash, Profiles, Verge};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
#[derive(Default)] #[derive(Default)]
pub struct ProfilesState(pub Arc<Mutex<ProfilesConfig>>); pub struct ProfilesState(pub Arc<Mutex<Profiles>>);
#[derive(Default)] #[derive(Default)]
pub struct ClashState(pub Arc<Mutex<Clash>>); pub struct ClashState(pub Arc<Mutex<Clash>>);

View File

@@ -1,6 +1,4 @@
use crate::utils::dirs;
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
use serde_yaml::Mapping;
use std::{fs, path::PathBuf}; use std::{fs, path::PathBuf};
/// read data from yaml as struct T /// read data from yaml as struct T
@@ -32,17 +30,3 @@ pub fn save_yaml<T: Serialize>(
Err(_) => Err("can not convert the data to yaml".into()), Err(_) => Err("can not convert the data to yaml".into()),
} }
} }
/// Get Clash Core Config `config.yaml`
pub fn read_clash() -> Mapping {
read_yaml::<Mapping>(dirs::app_home_dir().join("config.yaml"))
}
/// Save the clash core Config `config.yaml`
pub fn save_clash(config: &Mapping) -> Result<(), String> {
save_yaml(
dirs::app_home_dir().join("config.yaml"),
config,
Some("# Default Config For Clash Core\n\n"),
)
}

View File

@@ -23,11 +23,20 @@ fn parse_string<T: FromStr>(target: &str, key: &str) -> Option<T> {
} }
/// fetch and parse the profile /// fetch and parse the profile
pub async fn fetch_profile(url: &str) -> Option<ProfileResponse> { pub async fn fetch_profile(url: &str, with_proxy: bool) -> Option<ProfileResponse> {
let resp = match reqwest::get(url).await { let builder = reqwest::ClientBuilder::new();
Ok(res) => res, let client = match with_proxy {
true => builder.build(),
false => builder.no_proxy().build(),
};
let resp = match client {
Ok(client) => match client.get(url).send().await {
Ok(res) => res,
Err(_) => return None,
},
Err(_) => return None, Err(_) => return None,
}; };
let header = resp.headers(); let header = resp.headers();
// parse the Subscription Userinfo // parse the Subscription Userinfo

View File

@@ -4,5 +4,4 @@ pub mod fetch;
pub mod init; pub mod init;
pub mod resolve; pub mod resolve;
pub mod server; pub mod server;
pub mod startup;
pub mod sysopt; pub mod sysopt;

View File

@@ -1,5 +1,5 @@
use super::{init, server}; use super::{init, server};
use crate::{core::ProfilesConfig, states}; use crate::{core::Profiles, states};
use tauri::{App, AppHandle, Manager}; use tauri::{App, AppHandle, Manager};
use tauri_plugin_shadows::Shadows; use tauri_plugin_shadows::Shadows;
@@ -9,12 +9,14 @@ pub fn resolve_setup(app: &App) {
let window = app.get_window("main").unwrap(); let window = app.get_window("main").unwrap();
window.set_shadow(true); window.set_shadow(true);
// enable system blur
use tauri_plugin_vibrancy::Vibrancy; use tauri_plugin_vibrancy::Vibrancy;
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
window.apply_blur(); window.apply_blur();
#[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);
} }
@@ -37,14 +39,14 @@ pub fn resolve_setup(app: &App) {
log::error!("{}", err); log::error!("{}", err);
} }
*profiles = ProfilesConfig::read_file(); *profiles = Profiles::read_file();
if let Err(err) = profiles.activate(clash.info.clone()) { if let Err(err) = profiles.activate(&clash) {
log::error!("{}", err); log::error!("{}", err);
} }
verge.set_exe_path(app.package_info());
verge.init_sysproxy(clash.info.port.clone()); verge.init_sysproxy(clash.info.port.clone());
if let Err(err) = verge.sync_startup() { verge.init_launch(app.package_info());
if let Err(err) = verge.sync_launch() {
log::error!("{}", err); log::error!("{}", err);
} }
} }

View File

@@ -1,74 +0,0 @@
use std::io;
use std::path::PathBuf;
static APP_KEY: &str = "ClashVerge";
/// get the startup value
/// whether as same as the exe_path
#[cfg(target_os = "windows")]
pub fn get_startup(exe_path: &PathBuf) -> io::Result<bool> {
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\\Run",
KEY_READ,
)?;
match cur_var.get_value::<String, _>(APP_KEY) {
Ok(path) => {
let exe_path = exe_path.clone();
let exe_path = exe_path.as_os_str().to_str().unwrap();
Ok(path == exe_path)
}
Err(_) => Ok(false),
}
}
/// set the startup on windows
/// delete the reg key if disabled
#[cfg(target_os = "windows")]
pub fn set_startup(enable: bool, exe_path: &PathBuf) -> 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\\Run",
KEY_SET_VALUE,
)?;
match enable {
true => {
let exe_path = exe_path.clone();
let exe_path = exe_path.as_os_str().to_str().unwrap();
cur_var.set_value::<&str, _>(APP_KEY, &exe_path)
}
false => cur_var.delete_value(APP_KEY),
}
}
/// todo
#[cfg(target_os = "macos")]
pub fn get_startup(exe_path: &PathBuf) -> io::Result<bool> {
Ok(true)
}
/// todo
#[cfg(target_os = "macos")]
pub fn set_startup(enable: bool, exe_path: &PathBuf) -> io::Result<()> {
Ok(())
}
#[cfg(target_os = "windows")]
#[test]
fn test() {
let path = PathBuf::from(r"D:\Software\Clash Verge\clash-verge.exe");
assert!(set_startup(true, &path).is_ok());
assert_eq!(get_startup(&path).unwrap(), true);
assert!(set_startup(false, &path).is_ok());
assert_eq!(get_startup(&path).unwrap(), false);
}

View File

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

View File

@@ -28,3 +28,4 @@ body {
} }
@import "./layout.scss"; @import "./layout.scss";
@import "./page.scss";

View File

@@ -27,6 +27,10 @@
text-align: center; text-align: center;
box-sizing: border-box; box-sizing: border-box;
img {
width: 100%;
}
.the-newbtn { .the-newbtn {
position: absolute; position: absolute;
right: 20px; right: 20px;
@@ -54,27 +58,24 @@
position: relative; position: relative;
flex: 1 1 75%; flex: 1 1 75%;
height: 100%; height: 100%;
display: flex;
flex-direction: column;
padding: 2px 0;
box-sizing: border-box;
.the-bar { .the-bar {
flex: 0 0 30px; position: absolute;
width: 100%; top: 2px;
height: 30px; right: 8px;
padding: 0 16px; height: 36px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end;
box-sizing: border-box; box-sizing: border-box;
z-index: 2;
} }
.the-content { .the-content {
flex: 1 1 100%; position: absolute;
overflow: auto; top: 30px;
box-sizing: border-box; left: 0;
scrollbar-gutter: stable; right: 2px;
bottom: 10px;
} }
} }
} }

View File

@@ -0,0 +1,35 @@
.base-page {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
> header {
flex: 0 0 58px;
width: 90%;
max-width: 850px;
margin: 0 auto;
padding-right: 4px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
}
> section {
position: relative;
flex: 1 1 100%;
width: 100%;
height: 100%;
overflow: auto;
padding: 8px 0;
box-sizing: border-box;
scrollbar-gutter: stable;
.base-content {
width: 90%;
max-width: 850px;
margin: 0 auto;
}
}
}

View File

@@ -0,0 +1,32 @@
import { Typography } from "@mui/material";
import React from "react";
interface Props {
title?: React.ReactNode; // the page title
header?: React.ReactNode; // something behind title
contentStyle?: React.CSSProperties;
}
const BasePage: React.FC<Props> = (props) => {
const { title, header, contentStyle, children } = props;
return (
<div className="base-page" data-windrag>
<header data-windrag>
<Typography variant="h4" component="h1">
{title}
</Typography>
{header}
</header>
<section>
<div className="base-content" style={contentStyle} data-windrag>
{children}
</div>
</section>
</div>
);
};
export default BasePage;

View File

@@ -0,0 +1,41 @@
import { Button } from "@mui/material";
import { appWindow } from "@tauri-apps/api/window";
import {
CloseRounded,
CropSquareRounded,
HorizontalRuleRounded,
} from "@mui/icons-material";
const LayoutControl = () => {
const minWidth = 40;
return (
<>
<Button
size="small"
sx={{ minWidth, svg: { transform: "scale(0.9)" } }}
onClick={() => appWindow.minimize()}
>
<HorizontalRuleRounded fontSize="small" />
</Button>
<Button
size="small"
sx={{ minWidth, svg: { transform: "scale(0.9)" } }}
onClick={() => appWindow.toggleMaximize()}
>
<CropSquareRounded fontSize="small" />
</Button>
<Button
size="small"
sx={{ minWidth, svg: { transform: "scale(1.05)" } }}
onClick={() => appWindow.hide()}
>
<CloseRounded fontSize="small" />
</Button>
</>
);
};
export default LayoutControl;

92
src/components/notice.tsx Normal file
View File

@@ -0,0 +1,92 @@
import ReactDOM from "react-dom";
import { ReactNode, useState } from "react";
import { Box, IconButton, Slide, Snackbar, Typography } from "@mui/material";
import { Close, CheckCircleRounded, ErrorRounded } from "@mui/icons-material";
interface InnerProps {
type: string;
duration?: number;
message: ReactNode;
onClose: () => void;
}
const NoticeInner = (props: InnerProps) => {
const { type, message, duration = 2000, onClose } = props;
const [visible, setVisible] = useState(true);
const onBtnClose = () => {
setVisible(false);
onClose();
};
const onAutoClose = (_e: any, reason: string) => {
if (reason !== "clickaway") onBtnClose();
};
const msgElement =
type === "info" ? (
message
) : (
<Box sx={{ display: "flex", alignItems: "center" }}>
{type === "error" && <ErrorRounded color="error" />}
{type === "success" && <CheckCircleRounded color="success" />}
<Typography
sx={{ ml: 1, wordWrap: "break-word", wordBreak: "break-all" }}
>
{message}
</Typography>
</Box>
);
return (
<Snackbar
open={visible}
anchorOrigin={{ vertical: "top", horizontal: "right" }}
autoHideDuration={duration}
onClose={onAutoClose}
message={msgElement}
sx={{ maxWidth: 360 }}
TransitionComponent={(p) => <Slide {...p} direction="left" />}
transitionDuration={200}
action={
<IconButton size="small" color="inherit" onClick={onBtnClose}>
<Close fontSize="inherit" />
</IconButton>
}
/>
);
};
interface NoticeInstance {
(props: Omit<InnerProps, "onClose">): void;
info(message: ReactNode, duration?: number): void;
error(message: ReactNode, duration?: number): void;
success(message: ReactNode, duration?: number): void;
}
let parent: HTMLDivElement = null!;
// @ts-ignore
const Notice: NoticeInstance = (props) => {
if (!parent) {
parent = document.createElement("div");
document.body.appendChild(parent);
}
const container = document.createElement("div");
parent.appendChild(container);
const onUnmount = () => {
const result = ReactDOM.unmountComponentAtNode(container);
if (result && parent) parent.removeChild(container);
};
ReactDOM.render(<NoticeInner {...props} onClose={onUnmount} />, container);
};
(["info", "error", "success"] as const).forEach((type) => {
Notice[type] = (message, duration) => Notice({ type, message, duration });
});
export default Notice;

View File

@@ -1,4 +1,4 @@
import React, { useState } from "react"; import React, { useRef, useState } from "react";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { import {
alpha, alpha,
@@ -14,7 +14,8 @@ import {
import { useSWRConfig } from "swr"; import { useSWRConfig } from "swr";
import { RefreshRounded } from "@mui/icons-material"; import { RefreshRounded } from "@mui/icons-material";
import { CmdType } from "../services/types"; import { CmdType } from "../services/types";
import { updateProfile, deleteProfile } from "../services/cmds"; import { updateProfile, deleteProfile, viewProfile } from "../services/cmds";
import Notice from "./notice";
import parseTraffic from "../utils/parse-traffic"; import parseTraffic from "../utils/parse-traffic";
import relativeTime from "dayjs/plugin/relativeTime"; import relativeTime from "dayjs/plugin/relativeTime";
@@ -32,19 +33,19 @@ const Wrapper = styled(Box)(({ theme }) => ({
})); }));
const round = keyframes` const round = keyframes`
from { transform: rotate(0deg); } from { transform: rotate(0deg); }
to { transform: rotate(360deg); } to { transform: rotate(360deg); }
`; `;
interface Props { interface Props {
index: number; index: number;
selected: boolean; selected: boolean;
itemData: CmdType.ProfileItem; itemData: CmdType.ProfileItem;
onClick: () => void; onSelect: (force: boolean) => void;
} }
const ProfileItemComp: React.FC<Props> = (props) => { const ProfileItem: React.FC<Props> = (props) => {
const { index, selected, itemData, onClick } = props; const { index, selected, itemData, onSelect } = props;
const { mutate } = useSWRConfig(); const { mutate } = useSWRConfig();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -58,27 +59,49 @@ const ProfileItemComp: 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() : "";
const onUpdate = async () => { // url or file mode
const isUrlMode = itemData.url && extra;
const onView = async () => {
setAnchorEl(null);
try {
await viewProfile(index);
} catch (err: any) {
Notice.error(err.toString());
}
};
const onForceSelect = () => {
setAnchorEl(null);
onSelect(true);
};
const onUpdateWrapper = (withProxy: boolean) => async () => {
setAnchorEl(null); setAnchorEl(null);
if (loading) return; if (loading) return;
setLoading(true); setLoading(true);
try { try {
await updateProfile(index); await updateProfile(index, withProxy);
mutate("getProfiles"); mutate("getProfiles");
} catch (err) { } catch (err: any) {
console.error(err); Notice.error(err.toString());
} finally { } finally {
setLoading(false); setLoading(false);
} }
}; };
const deleteRef = useRef(false);
const onDelete = async () => { const onDelete = async () => {
setAnchorEl(null); setAnchorEl(null);
if (deleteRef.current) return;
deleteRef.current = true;
try { try {
await deleteProfile(index); await deleteProfile(index);
mutate("getProfiles"); mutate("getProfiles");
} catch (err) { } catch (err: any) {
console.error(err); Notice.error(err.toString());
} finally {
deleteRef.current = false;
} }
}; };
@@ -91,6 +114,13 @@ const ProfileItemComp: React.FC<Props> = (props) => {
event.preventDefault(); event.preventDefault();
}; };
const boxStyle = {
height: 26,
display: "flex",
alignItems: "center",
justifyContent: "space-between",
};
return ( return (
<> <>
<Wrapper <Wrapper
@@ -121,7 +151,7 @@ const ProfileItemComp: React.FC<Props> = (props) => {
return { bgcolor, color, "& h2": { color: h2color } }; return { bgcolor, color, "& h2": { color: h2color } };
}} }}
onClick={onClick} onClick={() => onSelect(false)}
onContextMenu={handleContextMenu} onContextMenu={handleContextMenu}
> >
<Box display="flex" justifyContent="space-between"> <Box display="flex" justifyContent="space-between">
@@ -135,52 +165,63 @@ const ProfileItemComp: 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) => {
onUpdate(); 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"
@@ -196,9 +237,11 @@ const ProfileItemComp: React.FC<Props> = (props) => {
anchorPosition={position} anchorPosition={position}
anchorReference="anchorPosition" anchorReference="anchorPosition"
> >
<MenuItem onClick={onUpdate}>Update</MenuItem> <MenuItem onClick={onForceSelect}>Select</MenuItem>
<MenuItem onClick={onView}>View</MenuItem>
<MenuItem onClick={onUpdateWrapper(false)}>Update</MenuItem>
<MenuItem onClick={onUpdateWrapper(true)}>Update(Proxy)</MenuItem>
<MenuItem onClick={onDelete}>Delete</MenuItem> <MenuItem onClick={onDelete}>Delete</MenuItem>
{/* <MenuItem>Update(proxy)</MenuItem> */}
</Menu> </Menu>
</> </>
); );
@@ -216,4 +259,4 @@ function parseExpire(expire?: number) {
return dayjs(expire * 1000).format("YYYY-MM-DD"); return dayjs(expire * 1000).format("YYYY-MM-DD");
} }
export default ProfileItemComp; export default ProfileItem;

View File

@@ -1,15 +1,12 @@
import { useState } from "react"; import { useState } from "react";
import { Virtuoso } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso";
import { import {
alpha,
Box, Box,
Collapse, Collapse,
Divider, Divider,
IconButton, IconButton,
List, List,
ListItem, ListItem,
ListItemButton,
ListItemIcon,
ListItemText, ListItemText,
} from "@mui/material"; } from "@mui/material";
import { import {
@@ -18,53 +15,11 @@ import {
ExpandMoreRounded, ExpandMoreRounded,
MyLocationRounded, MyLocationRounded,
NetworkCheckRounded, NetworkCheckRounded,
CheckCircleOutlineRounded,
} from "@mui/icons-material"; } from "@mui/icons-material";
import { updateProxy } from "../services/api"; import { updateProxy } from "../services/api";
import { ApiType } from "../services/types"; import { ApiType } from "../services/types";
import { getProfiles, patchProfile } from "../services/cmds"; import { getProfiles, patchProfile } from "../services/cmds";
import ProxyItem from "./proxy-item";
interface ItemProps {
proxy: ApiType.ProxyItem;
selected: boolean;
onClick?: (name: string) => void;
}
const Item = ({ proxy, selected, onClick }: ItemProps) => {
return (
<ListItem sx={{ py: 0, pl: 4 }}>
<ListItemButton
dense
selected={selected}
onClick={() => onClick?.(proxy.name)}
sx={[
{
borderRadius: 1,
},
({ palette: { mode, primary } }) => {
const bgcolor =
mode === "light"
? alpha(primary.main, 0.15)
: alpha(primary.main, 0.35);
const color = mode === "light" ? primary.main : primary.light;
return {
"&.Mui-selected": { bgcolor },
"&.Mui-selected .MuiListItemText-secondary": { color },
};
},
]}
>
<ListItemText title={proxy.name} secondary={proxy.name} />
<ListItemIcon
sx={{ justifyContent: "flex-end", color: "primary.main" }}
>
{selected && <CheckCircleOutlineRounded sx={{ fontSize: 16 }} />}
</ListItemIcon>
</ListItemButton>
</ListItem>
);
};
interface Props { interface Props {
group: ApiType.ProxyGroupItem; group: ApiType.ProxyGroupItem;
@@ -143,12 +98,13 @@ const ProxyGroup = ({ group }: Props) => {
{proxies.length >= 10 ? ( {proxies.length >= 10 ? (
<Virtuoso <Virtuoso
style={{ height: "400px", marginBottom: "4px" }} style={{ height: "320px", marginBottom: "4px" }}
totalCount={proxies.length} totalCount={proxies.length}
itemContent={(index) => ( itemContent={(index) => (
<Item <ProxyItem
proxy={proxies[index]} proxy={proxies[index]}
selected={proxies[index].name === now} selected={proxies[index].name === now}
sx={{ py: 0, pl: 4 }}
onClick={onUpdate} onClick={onUpdate}
/> />
)} )}
@@ -157,13 +113,14 @@ const ProxyGroup = ({ group }: Props) => {
<List <List
component="div" component="div"
disablePadding disablePadding
sx={{ maxHeight: "400px", overflow: "auto", mb: "4px" }} sx={{ maxHeight: "320px", overflow: "auto", mb: "4px" }}
> >
{proxies.map((proxy) => ( {proxies.map((proxy) => (
<Item <ProxyItem
key={proxy.name} key={proxy.name}
proxy={proxy} proxy={proxy}
selected={proxy.name === now} selected={proxy.name === now}
sx={{ py: 0, pl: 4 }}
onClick={onUpdate} onClick={onUpdate}
/> />
))} ))}

View File

@@ -0,0 +1,58 @@
import { CheckCircleOutlineRounded } from "@mui/icons-material";
import {
alpha,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
SxProps,
Theme,
} from "@mui/material";
import { ApiType } from "../services/types";
interface Props {
proxy: ApiType.ProxyItem;
selected: boolean;
sx?: SxProps<Theme>;
onClick?: (name: string) => void;
}
const ProxyItem = (props: Props) => {
const { proxy, selected, sx, onClick } = props;
return (
<ListItem sx={sx}>
<ListItemButton
dense
selected={selected}
onClick={() => onClick?.(proxy.name)}
sx={[
{
borderRadius: 1,
},
({ palette: { mode, primary } }) => {
const bgcolor =
mode === "light"
? alpha(primary.main, 0.15)
: alpha(primary.main, 0.35);
const color = mode === "light" ? primary.main : primary.light;
return {
"&.Mui-selected": { bgcolor },
"&.Mui-selected .MuiListItemText-secondary": { color },
};
},
]}
>
<ListItemText title={proxy.name} secondary={proxy.name} />
<ListItemIcon
sx={{ justifyContent: "flex-end", color: "primary.main" }}
>
{selected && <CheckCircleOutlineRounded sx={{ fontSize: 16 }} />}
</ListItemIcon>
</ListItemButton>
</ListItem>
);
};
export default ProxyItem;

View File

@@ -1,8 +0,0 @@
import { ListItem, styled } from "@mui/material";
const SettingItem = styled(ListItem)(() => ({
paddingTop: 5,
paddingBottom: 5,
}));
export default SettingItem;

View File

@@ -1,117 +0,0 @@
import useSWR, { useSWRConfig } from "swr";
import {
Box,
List,
ListItemText,
ListSubheader,
Switch,
Typography,
} from "@mui/material";
import { getVergeConfig, patchVergeConfig } from "../services/cmds";
import { CmdType } from "../services/types";
import { version } from "../../package.json";
import GuardState from "./guard-state";
import SettingItem from "./setting-item";
import PaletteSwitch from "./palette-switch";
import SysproxyTooltip from "./sysproxy-tooltip";
interface Props {
onError?: (err: Error) => void;
}
const SettingVerge = ({ onError }: Props) => {
const { mutate } = useSWRConfig();
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
const {
theme_mode: mode = "light",
theme_blur: blur = false,
enable_self_startup: startup = false,
enable_system_proxy: proxy = false,
} = vergeConfig ?? {};
const onSwitchFormat = (_e: any, value: boolean) => value;
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
mutate("getVergeConfig", { ...vergeConfig, ...patch }, false);
};
return (
<List>
<ListSubheader sx={{ background: "transparent" }}>
Common Setting
</ListSubheader>
<SettingItem>
<ListItemText primary="Theme Mode" />
<GuardState
value={mode === "dark"}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ theme_mode: e ? "dark" : "light" })}
onGuard={(c) =>
patchVergeConfig({ theme_mode: c ? "dark" : "light" })
}
>
<PaletteSwitch edge="end" />
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText primary="Theme Blur" />
<GuardState
value={blur}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ theme_blur: e })}
onGuard={(e) => patchVergeConfig({ theme_blur: e })}
>
<Switch edge="end" />
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText primary="Self Startup" />
<GuardState
value={startup}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ enable_self_startup: e })}
onGuard={(e) => patchVergeConfig({ enable_self_startup: e })}
>
<Switch edge="end" />
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText
primary={
<Box sx={{ display: "flex", alignItems: "center" }}>
System Proxy
<SysproxyTooltip />
</Box>
}
/>
<GuardState
value={proxy}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ enable_system_proxy: e })}
onGuard={(e) => patchVergeConfig({ enable_system_proxy: e })}
>
<Switch edge="end" />
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText primary="Version" />
<Typography sx={{ py: "6px" }}>v{version}</Typography>
</SettingItem>
</List>
);
};
export default SettingVerge;

View File

@@ -1,5 +1,5 @@
import { cloneElement, isValidElement, ReactNode, useRef } from "react"; import { cloneElement, isValidElement, ReactNode, useRef } from "react";
import noop from "../utils/noop"; import noop from "../../utils/noop";
interface Props<Value> { interface Props<Value> {
value?: Value; value?: Value;
@@ -7,7 +7,7 @@ interface Props<Value> {
onChangeProps?: string; onChangeProps?: string;
onChange?: (value: Value) => void; onChange?: (value: Value) => void;
onFormat?: (...args: any[]) => Value; onFormat?: (...args: any[]) => Value;
onGuard?: (value: Value) => Promise<void>; onGuard?: (value: Value, oldValue: Value) => Promise<void>;
onCatch?: (error: Error) => void; onCatch?: (error: Error) => void;
children: ReactNode; children: ReactNode;
} }
@@ -41,7 +41,7 @@ function GuardState<T>(props: Props<T>) {
const newValue = (onFormat as any)(...args); const newValue = (onFormat as any)(...args);
// 先在ui上响应操作 // 先在ui上响应操作
onChange(newValue); onChange(newValue);
await onGuard(newValue); await onGuard(newValue, oldValue!);
} catch (err: any) { } catch (err: any) {
// 状态回退 // 状态回退
onChange(oldValue!); onChange(oldValue!);

View File

@@ -1,21 +1,24 @@
import { useEffect, useState } from "react";
import { useDebounceFn } from "ahooks";
import { useSetRecoilState } from "recoil";
import useSWR, { useSWRConfig } from "swr"; import useSWR, { useSWRConfig } from "swr";
import { import {
List,
ListItemText, ListItemText,
ListSubheader,
TextField, TextField,
Switch, Switch,
Select, Select,
MenuItem, MenuItem,
} from "@mui/material"; } from "@mui/material";
import { getClashConfig, updateConfigs } from "../services/api"; import { getClashConfig, updateConfigs } from "../../services/api";
import { patchClashConfig } from "../services/cmds"; import { SettingList, SettingItem } from "./setting";
import { ApiType } from "../services/types"; import { patchClashConfig } from "../../services/cmds";
import { atomClashPort } from "../../states/setting";
import { ApiType } from "../../services/types";
import GuardState from "./guard-state"; import GuardState from "./guard-state";
import SettingItem from "./setting-item"; import Notice from "../notice";
interface Props { interface Props {
onError?: (err: Error) => void; onError: (err: Error) => void;
} }
const SettingClash = ({ onError }: Props) => { const SettingClash = ({ onError }: Props) => {
@@ -26,26 +29,47 @@ const SettingClash = ({ onError }: Props) => {
ipv6 = false, ipv6 = false,
"allow-lan": allowLan = false, "allow-lan": allowLan = false,
"log-level": logLevel = "silent", "log-level": logLevel = "silent",
"mixed-port": mixedPort = 7890, "mixed-port": thePort = 0,
} = clashConfig ?? {}; } = clashConfig ?? {};
const onSwitchFormat = (_e: any, value: boolean) => value; const setPort = useSetRecoilState(atomClashPort);
const [mixedPort, setMixedPort] = useState(thePort);
useEffect(() => setMixedPort(thePort), [thePort]);
const onSwitchFormat = (_e: any, value: boolean) => value;
const onChangeData = (patch: Partial<ApiType.ConfigData>) => { const onChangeData = (patch: Partial<ApiType.ConfigData>) => {
mutate("getClashConfig", { ...clashConfig, ...patch }, false); mutate("getClashConfig", { ...clashConfig, ...patch }, false);
}; };
const onUpdateData = async (patch: Partial<ApiType.ConfigData>) => { const onUpdateData = async (patch: Partial<ApiType.ConfigData>) => {
await updateConfigs(patch); await updateConfigs(patch);
await patchClashConfig(patch); await patchClashConfig(patch);
}; };
return ( // restart clash when port is changed
<List> const { run: onUpdatePort } = useDebounceFn(
<ListSubheader sx={{ background: "transparent" }}> async (port: number) => {
Clash Setting (async () => {
</ListSubheader> if (port < 1000) {
throw new Error("The port should not < 1000");
}
if (port > 65536) {
throw new Error("The port should not > 65536");
}
await patchClashConfig({ "mixed-port": port });
onChangeData({ "mixed-port": port });
setPort(port);
Notice.success("Change Clash port successfully!");
})().catch((err: any) => {
setMixedPort(thePort); // back to old port value
Notice.error(err.message ?? err.toString());
});
},
{ wait: 1000 }
);
return (
<SettingList title="Clash Setting">
<SettingItem> <SettingItem>
<ListItemText primary="Allow Lan" /> <ListItemText primary="Allow Lan" />
<GuardState <GuardState
@@ -95,14 +119,16 @@ const SettingClash = ({ onError }: Props) => {
<SettingItem> <SettingItem>
<ListItemText primary="Mixed Port" /> <ListItemText primary="Mixed Port" />
<TextField <GuardState
size="small"
value={mixedPort!} value={mixedPort!}
sx={{ width: 120 }} onFormat={(e: any) => +e.target.value?.replace(/\D+/, "")}
disabled onChange={setMixedPort}
/> onGuard={onUpdatePort}
>
<TextField autoComplete="off" size="small" sx={{ width: 120 }} />
</GuardState>
</SettingItem> </SettingItem>
</List> </SettingList>
); );
}; };

View File

@@ -0,0 +1,67 @@
import useSWR, { useSWRConfig } from "swr";
import { Box, ListItemText, Switch } from "@mui/material";
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
import { SettingList, SettingItem } from "./setting";
import { CmdType } from "../../services/types";
import GuardState from "./guard-state";
import SysproxyTooltip from "./sysproxy-tooltip";
interface Props {
onError?: (err: Error) => void;
}
const SettingSystem = ({ onError }: Props) => {
const { mutate } = useSWRConfig();
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
const {
enable_auto_launch: startup = false,
enable_system_proxy: proxy = false,
} = vergeConfig ?? {};
const onSwitchFormat = (_e: any, value: boolean) => value;
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
mutate("getVergeConfig", { ...vergeConfig, ...patch }, false);
};
return (
<SettingList title="System Setting">
<SettingItem>
<ListItemText primary="Auto Launch" />
<GuardState
value={startup}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ enable_auto_launch: e })}
onGuard={(e) => patchVergeConfig({ enable_auto_launch: e })}
>
<Switch edge="end" />
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText
primary={
<Box sx={{ display: "flex", alignItems: "center" }}>
System Proxy
<SysproxyTooltip />
</Box>
}
/>
<GuardState
value={proxy}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ enable_system_proxy: e })}
onGuard={(e) => patchVergeConfig({ enable_system_proxy: e })}
>
<Switch edge="end" />
</GuardState>
</SettingItem>
</SettingList>
);
};
export default SettingSystem;

View File

@@ -0,0 +1,66 @@
import useSWR, { useSWRConfig } from "swr";
import { ListItemText, Switch, Typography } from "@mui/material";
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
import { SettingList, SettingItem } from "./setting";
import { CmdType } from "../../services/types";
import { version } from "../../../package.json";
import GuardState from "./guard-state";
import PaletteSwitch from "./palette-switch";
interface Props {
onError?: (err: Error) => void;
}
const SettingVerge = ({ onError }: Props) => {
const { mutate } = useSWRConfig();
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
const { theme_mode: mode = "light", theme_blur: blur = false } =
vergeConfig ?? {};
const onSwitchFormat = (_e: any, value: boolean) => value;
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
mutate("getVergeConfig", { ...vergeConfig, ...patch }, false);
};
return (
<SettingList title="Verge Setting">
<SettingItem>
<ListItemText primary="Theme Mode" />
<GuardState
value={mode === "dark"}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ theme_mode: e ? "dark" : "light" })}
onGuard={(c) =>
patchVergeConfig({ theme_mode: c ? "dark" : "light" })
}
>
<PaletteSwitch edge="end" />
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText primary="Theme Blur" />
<GuardState
value={blur}
valueProps="checked"
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ theme_blur: e })}
onGuard={(e) => patchVergeConfig({ theme_blur: e })}
>
<Switch edge="end" />
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText primary="Version" />
<Typography sx={{ py: "6px" }}>v{version}</Typography>
</SettingItem>
</SettingList>
);
};
export default SettingVerge;

View File

@@ -0,0 +1,17 @@
import React from "react";
import { List, ListItem, ListSubheader, styled } from "@mui/material";
export const SettingItem = styled(ListItem)(() => ({
paddingTop: 5,
paddingBottom: 5,
}));
export const SettingList: React.FC<{ title: string }> = (props) => (
<List>
<ListSubheader sx={{ background: "transparent" }} disableSticky>
{props.title}
</ListSubheader>
{props.children}
</List>
);

View File

@@ -1,7 +1,7 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { InfoRounded } from "@mui/icons-material"; import { InfoRounded } from "@mui/icons-material";
import { ClickAwayListener, Tooltip } from "@mui/material"; import { ClickAwayListener, Tooltip } from "@mui/material";
import { getSystemProxy } from "../services/cmds"; import { getSystemProxy } from "../../services/cmds";
const SysproxyTooltip = () => { const SysproxyTooltip = () => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -9,7 +9,6 @@ const SysproxyTooltip = () => {
const onShow = async () => { const onShow = async () => {
const data = await getSystemProxy(); const data = await getSystemProxy();
console.log(data);
setInfo(data ?? {}); setInfo(data ?? {});
setOpen(true); setOpen(true);
}; };

View File

@@ -1,11 +1,14 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useRecoilValue } from "recoil";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import { ArrowDownward, ArrowUpward } from "@mui/icons-material"; import { ArrowDownward, ArrowUpward } from "@mui/icons-material";
import { getInfomation } from "../services/api"; import { getInfomation } from "../services/api";
import { ApiType } from "../services/types"; import { ApiType } from "../services/types";
import { atomClashPort } from "../states/setting";
import parseTraffic from "../utils/parse-traffic"; import parseTraffic from "../utils/parse-traffic";
const Traffic = () => { const Traffic = () => {
const portValue = useRecoilValue(atomClashPort);
const [traffic, setTraffic] = useState({ up: 0, down: 0 }); const [traffic, setTraffic] = useState({ up: 0, down: 0 });
useEffect(() => { useEffect(() => {
@@ -21,7 +24,7 @@ const Traffic = () => {
}); });
return () => ws?.close(); return () => ws?.close();
}, []); }, [portValue]);
const [up, upUnit] = parseTraffic(traffic.up); const [up, upUnit] = parseTraffic(traffic.up);
const [down, downUnit] = parseTraffic(traffic.down); const [down, downUnit] = parseTraffic(traffic.down);

View File

@@ -0,0 +1,40 @@
import useSWR from "swr";
import { useState } from "react";
import { Button } from "@mui/material";
import { checkUpdate } from "@tauri-apps/api/updater";
import UpdateDialog from "./update-dialog";
interface Props {
className?: string;
}
const UpdateButton = (props: Props) => {
const { className } = props;
const [dialogOpen, setDialogOpen] = useState(false);
const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, {
errorRetryCount: 2,
revalidateIfStale: false,
focusThrottleInterval: 36e5, // 1 hour
});
if (!updateInfo?.shouldUpdate) return null;
return (
<>
<Button
color="error"
variant="contained"
size="small"
className={className}
onClick={() => setDialogOpen(true)}
>
New
</Button>
<UpdateDialog open={dialogOpen} onClose={() => setDialogOpen(false)} />
</>
);
};
export default UpdateButton;

View File

@@ -1,68 +1,40 @@
import { useEffect, useMemo, useState } from "react"; import useSWR, { SWRConfig, useSWRConfig } from "swr";
import useSWR, { SWRConfig } from "swr"; import { useEffect, useMemo } from "react";
import { Route, Routes } from "react-router-dom"; import { Route, Routes } from "react-router-dom";
import { useRecoilState } from "recoil"; import { useRecoilState } from "recoil";
import { import { alpha, createTheme, List, Paper, ThemeProvider } from "@mui/material";
alpha, import { listen } from "@tauri-apps/api/event";
Button, import { appWindow } from "@tauri-apps/api/window";
createTheme,
IconButton,
List,
Paper,
ThemeProvider,
} from "@mui/material";
import { HorizontalRuleRounded, CloseRounded } from "@mui/icons-material";
import { checkUpdate } from "@tauri-apps/api/updater";
import { atomPaletteMode, atomThemeBlur } from "../states/setting"; import { atomPaletteMode, atomThemeBlur } from "../states/setting";
import { getVergeConfig, windowDrag, windowHide } from "../services/cmds"; import { getVergeConfig } from "../services/cmds";
import { getAxios } from "../services/api";
import { routers } from "./_routers";
import LogoSvg from "../assets/image/logo.svg"; import LogoSvg from "../assets/image/logo.svg";
import LogPage from "./log";
import ProfilePage from "./profile";
import ProxyPage from "./proxy";
import SettingPage from "./setting";
import ConnectionsPage from "./connections";
import LayoutItem from "../components/layout-item";
import Traffic from "../components/traffic"; import Traffic from "../components/traffic";
import UpdateDialog from "../components/update-dialog"; import LayoutItem from "../components/layout-item";
import UpdateButton from "../components/update-button";
const routers = [ import LayoutControl from "../components/layout-control";
{
label: "Proxy",
link: "/",
ele: ProxyPage,
},
{
label: "Profile",
link: "/profile",
ele: ProfilePage,
},
{
label: "Connections",
link: "/connections",
ele: ConnectionsPage,
},
{
label: "Log",
link: "/log",
ele: LogPage,
},
{
label: "Setting",
link: "/setting",
ele: SettingPage,
},
];
const Layout = () => { const Layout = () => {
const { mutate } = useSWRConfig();
const [mode, setMode] = useRecoilState(atomPaletteMode); const [mode, setMode] = useRecoilState(atomPaletteMode);
const [blur, setBlur] = useRecoilState(atomThemeBlur); const [blur, setBlur] = useRecoilState(atomThemeBlur);
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig); const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, {
errorRetryCount: 2, useEffect(() => {
revalidateIfStale: false, window.addEventListener("keydown", (e) => {
focusThrottleInterval: 36e5, // 1 hour if (e.key === "Escape") appWindow.hide();
}); });
const [dialogOpen, setDialogOpen] = useState(false);
listen("restart_clash", async () => {
// the clash info may be updated
await getAxios(true);
// make sure that the clash is ok
setTimeout(() => mutate("getProxies"), 1000);
setTimeout(() => mutate("getProxies"), 2000);
mutate("getClashConfig");
});
}, []);
useEffect(() => { useEffect(() => {
if (!vergeConfig) return; if (!vergeConfig) return;
@@ -90,6 +62,12 @@ const Layout = () => {
}); });
}, [mode]); }, [mode]);
const onDragging = (e: any) => {
if (e?.target?.dataset?.windrag) {
appWindow.startDragging();
}
};
return ( return (
<SWRConfig value={{}}> <SWRConfig value={{}}>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
@@ -97,38 +75,21 @@ const Layout = () => {
square square
elevation={0} elevation={0}
className="layout" className="layout"
onPointerDown={onDragging}
sx={[ sx={[
(theme) => ({ (theme) => ({
bgcolor: alpha(theme.palette.background.paper, blur ? 0.85 : 1), bgcolor: alpha(theme.palette.background.paper, blur ? 0.85 : 1),
}), }),
]} ]}
> >
<div className="layout__left"> <div className="layout__left" data-windrag>
<div className="the-logo"> <div className="the-logo" data-windrag>
<img <img src={LogoSvg} alt="" data-windrag />
src={LogoSvg}
width="100%"
alt=""
onPointerDown={(e) => {
windowDrag();
e.preventDefault();
}}
/>
{updateInfo?.shouldUpdate && ( <UpdateButton className="the-newbtn" />
<Button
color="error"
variant="contained"
size="small"
className="the-newbtn"
onClick={() => setDialogOpen(true)}
>
New
</Button>
)}
</div> </div>
<List className="the-menu"> <List className="the-menu" data-windrag>
{routers.map((router) => ( {routers.map((router) => (
<LayoutItem key={router.label} to={router.link}> <LayoutItem key={router.label} to={router.link}>
{router.label} {router.label}
@@ -136,26 +97,14 @@ const Layout = () => {
))} ))}
</List> </List>
<div className="the-traffic"> <div className="the-traffic" data-windrag>
<Traffic /> <Traffic />
</div> </div>
</div> </div>
<div className="layout__right"> <div className="layout__right" data-windrag>
<div <div className="the-bar">
className="the-bar" <LayoutControl />
onPointerDown={(e) =>
e.target === e.currentTarget && windowDrag()
}
>
{/* todo: onClick = windowMini */}
<IconButton size="small" sx={{ mx: 1 }} onClick={windowHide}>
<HorizontalRuleRounded fontSize="inherit" />
</IconButton>
<IconButton size="small" onClick={windowHide}>
<CloseRounded fontSize="inherit" />
</IconButton>
</div> </div>
<div className="the-content"> <div className="the-content">
@@ -167,7 +116,6 @@ const Layout = () => {
</div> </div>
</div> </div>
</Paper> </Paper>
<UpdateDialog open={dialogOpen} onClose={() => setDialogOpen(false)} />
</ThemeProvider> </ThemeProvider>
</SWRConfig> </SWRConfig>
); );

33
src/pages/_routers.tsx Normal file
View File

@@ -0,0 +1,33 @@
import LogsPage from "./logs";
import ProxiesPage from "./proxies";
import ProfilesPage from "./profiles";
import SettingsPage from "./settings";
import ConnectionsPage from "./connections";
export const routers = [
{
label: "Proxies",
link: "/",
ele: ProxiesPage,
},
{
label: "Profiles",
link: "/profile",
ele: ProfilesPage,
},
{
label: "Connections",
link: "/connections",
ele: ConnectionsPage,
},
{
label: "Logs",
link: "/logs",
ele: LogsPage,
},
{
label: "Settings",
link: "/settings",
ele: SettingsPage,
},
];

View File

@@ -1,8 +1,9 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Box, Paper, Typography } from "@mui/material"; import { Paper } from "@mui/material";
import { Virtuoso } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso";
import { getInfomation } from "../services/api";
import { ApiType } from "../services/types"; import { ApiType } from "../services/types";
import { getInfomation } from "../services/api";
import BasePage from "../components/base-page";
import ConnectionItem from "../components/connection-item"; import ConnectionItem from "../components/connection-item";
const ConnectionsPage = () => { const ConnectionsPage = () => {
@@ -26,25 +27,14 @@ const ConnectionsPage = () => {
}, []); }, []);
return ( return (
<Box <BasePage title="Connections" contentStyle={{ height: "100%" }}>
sx={{ <Paper sx={{ boxShadow: 2, height: "100%" }}>
width: 0.9,
maxWidth: "850px",
height: "100%",
mx: "auto",
}}
>
<Typography variant="h4" component="h1" sx={{ py: 2 }}>
Connections
</Typography>
<Paper sx={{ boxShadow: 2, height: "calc(100% - 100px)" }}>
<Virtuoso <Virtuoso
data={conn.connections} data={conn.connections}
itemContent={(index, item) => <ConnectionItem value={item} />} itemContent={(index, item) => <ConnectionItem value={item} />}
/> />
</Paper> </Paper>
</Box> </BasePage>
); );
}; };

View File

@@ -1,9 +1,10 @@
import dayjs from "dayjs"; import dayjs from "dayjs";
import { useEffect, useRef, useState } from "react"; import { useEffect, useState } from "react";
import { Box, Button, Paper, Typography } from "@mui/material"; import { Button, Paper } from "@mui/material";
import { Virtuoso } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso";
import { ApiType } from "../services/types"; import { ApiType } from "../services/types";
import { getInfomation } from "../services/api"; import { getInfomation } from "../services/api";
import BasePage from "../components/base-page";
import LogItem from "../components/log-item"; import LogItem from "../components/log-item";
let logCache: ApiType.LogItem[] = []; let logCache: ApiType.LogItem[] = [];
@@ -28,33 +29,27 @@ const LogPage = () => {
return () => ws?.close(); return () => ws?.close();
}, []); }, []);
const onClear = () => {
setLogData([]);
logCache = [];
};
return ( return (
<Box <BasePage
sx={{ title="Logs"
position: "relative", contentStyle={{ height: "100%" }}
width: 0.9, header={
maxWidth: "850px", <Button
height: "100%", size="small"
mx: "auto", sx={{ mt: 1 }}
}} variant="contained"
onClick={onClear}
>
Clear
</Button>
}
> >
<Typography variant="h4" component="h1" sx={{ py: 2 }}> <Paper sx={{ boxShadow: 2, height: "100%" }}>
Logs
</Typography>
<Button
size="small"
variant="contained"
sx={{ position: "absolute", top: 22, right: 0 }}
onClick={() => {
setLogData([]);
logCache = [];
}}
>
Clear
</Button>
<Paper sx={{ boxShadow: 2, height: "calc(100% - 100px)" }}>
<Virtuoso <Virtuoso
initialTopMostItemIndex={999} initialTopMostItemIndex={999}
data={logData} data={logData}
@@ -62,7 +57,7 @@ const LogPage = () => {
followOutput={"smooth"} followOutput={"smooth"}
/> />
</Paper> </Paper>
</Box> </BasePage>
); );
}; };

View File

@@ -1,21 +1,22 @@
import { useEffect, useRef, useState } from "react";
import useSWR, { useSWRConfig } from "swr"; import useSWR, { useSWRConfig } from "swr";
import { Box, Button, Grid, TextField, Typography } from "@mui/material"; import { useEffect, useRef, useState } from "react";
import { Box, Button, Grid, TextField } from "@mui/material";
import { import {
getProfiles, getProfiles,
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 ProfileItemComp from "../components/profile-item";
import useNotice from "../utils/use-notice";
import noop from "../utils/noop"; import noop from "../utils/noop";
import Notice from "../components/notice";
import BasePage from "../components/base-page";
import ProfileItem from "../components/profile-item";
const ProfilePage = () => { const ProfilePage = () => {
const [url, setUrl] = useState(""); const [url, setUrl] = useState("");
const [disabled, setDisabled] = useState(false); const [disabled, setDisabled] = useState(false);
const [notice, noticeElement] = useNotice();
const { mutate } = useSWRConfig(); const { mutate } = useSWRConfig();
const { data: profiles = {} } = useSWR("getProfiles", getProfiles); const { data: profiles = {} } = useSWR("getProfiles", getProfiles);
@@ -71,37 +72,46 @@ const ProfilePage = () => {
await importProfile(url); await importProfile(url);
mutate("getProfiles", getProfiles()); mutate("getProfiles", getProfiles());
if (!profiles.items?.length) selectProfile(0).catch(noop); if (!profiles.items?.length) selectProfile(0).catch(noop);
notice.success("Successfully import profile."); Notice.success("Successfully import profile.");
} catch { } catch {
notice.error("Failed to import profile."); Notice.error("Failed to import profile.");
} finally { } finally {
setDisabled(false); setDisabled(false);
} }
}; };
const lockRef = useRef(false); const lockRef = useRef(false);
const onProfileChange = (index: number) => { const onSelect = async (index: number, force: boolean) => {
if (index === profiles.current || lockRef.current) return;
if (lockRef.current) return; if (lockRef.current) return;
if (!force && index === profiles.current) return;
lockRef.current = true; lockRef.current = true;
selectProfile(index) try {
.then(() => { await selectProfile(index);
mutate("getProfiles", { ...profiles, current: index }, true); mutate("getProfiles", { ...profiles, current: index }, true);
}) } catch (err: any) {
.catch((err) => { err && Notice.error(err.toString());
console.error(err); } finally {
}) lockRef.current = false;
.finally(() => { }
lockRef.current = false; };
});
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 (
<Box sx={{ width: 0.9, maxWidth: "850px", mx: "auto", mb: 2 }}> <BasePage title="Profiles">
<Typography variant="h4" component="h1" sx={{ py: 2, mb: 1 }}>
Profiles
</Typography>
<Box sx={{ display: "flex", mb: 3 }}> <Box sx={{ display: "flex", mb: 3 }}>
<TextField <TextField
id="profile_url" id="profile_url"
@@ -111,32 +121,34 @@ const ProfilePage = () => {
fullWidth fullWidth
value={url} value={url}
onChange={(e) => setUrl(e.target.value)} onChange={(e) => setUrl(e.target.value)}
sx={{ mr: 4 }} 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}>
{profiles?.items?.map((item, idx) => ( {profiles?.items?.map((item, idx) => (
<Grid item xs={12} sm={6} key={item.file}> <Grid item xs={12} sm={6} key={item.file}>
<ProfileItemComp <ProfileItem
index={idx} index={idx}
selected={profiles.current === idx} selected={profiles.current === idx}
itemData={item} itemData={item}
onClick={() => onProfileChange(idx)} onSelect={(f) => onSelect(idx, f)}
/> />
</Grid> </Grid>
))} ))}
</Grid> </Grid>
</BasePage>
{noticeElement}
</Box>
); );
}; };

130
src/pages/proxies.tsx Normal file
View File

@@ -0,0 +1,130 @@
import useSWR, { useSWRConfig } from "swr";
import { useEffect, useMemo, useRef, useState } from "react";
import { Virtuoso } from "react-virtuoso";
import { Button, ButtonGroup, List, Paper } from "@mui/material";
import { getClashConfig, updateConfigs, updateProxy } from "../services/api";
import { patchClashConfig } from "../services/cmds";
import { getProxies } from "../services/api";
import BasePage from "../components/base-page";
import ProxyItem from "../components/proxy-item";
import ProxyGroup from "../components/proxy-group";
const ProxyPage = () => {
const { mutate } = useSWRConfig();
const { data: proxiesData } = useSWR("getProxies", getProxies);
const { data: clashConfig } = useSWR("getClashConfig", getClashConfig);
const [curProxy, setCurProxy] = useState<string>("DIRECT");
const curMode = clashConfig?.mode.toLowerCase();
// proxy groups
const { groups = [] } = proxiesData ?? {};
// proxies and sorted
const filterProxies = useMemo(() => {
if (!proxiesData?.proxies) return [];
const list = Object.values(proxiesData.proxies);
const retList = list.filter(
(p) => !p.all?.length && p.name !== "DIRECT" && p.name !== "REJECT"
);
const direct = list.filter((p) => p.name === "DIRECT");
const reject = list.filter((p) => p.name === "REJECT");
return direct.concat(retList).concat(reject);
}, [proxiesData]);
const modeList = ["rule", "global", "direct"];
const asGroup = curMode === "rule" && groups.length;
// make sure that fetch the proxies successfully
useEffect(() => {
if (
(curMode === "rule" && !groups.length) ||
(curMode === "global" && filterProxies.length < 4)
) {
setTimeout(() => mutate("getProxies"), 500);
}
}, [groups, filterProxies, curMode]);
// update the current proxy
useEffect(() => {
if (curMode === "direct") setCurProxy("DIRECT");
if (curMode === "global") {
const globalNow = proxiesData?.proxies?.GLOBAL?.now;
setCurProxy(globalNow || "DIRECT");
}
}, [curMode, proxiesData]);
const changeLockRef = useRef(false);
const onChangeMode = async (mode: string) => {
if (changeLockRef.current) return;
changeLockRef.current = true;
try {
// switch rapidly
await updateConfigs({ mode });
await patchClashConfig({ mode });
mutate("getClashConfig");
} finally {
changeLockRef.current = false;
}
};
const onChangeProxy = async (name: string) => {
if (curMode !== "global") return;
await updateProxy("GLOBAL", name);
setCurProxy(name);
};
// difference style
const pageStyle = asGroup ? {} : { height: "100%" };
const paperStyle: any = asGroup
? { mb: 0.5 }
: { py: 1, height: "100%", boxSizing: "border-box" };
return (
<BasePage
contentStyle={pageStyle}
title={asGroup ? "Proxy Groups" : "Proxies"}
header={
<ButtonGroup size="small">
{modeList.map((mode) => (
<Button
key={mode}
variant={mode === curMode ? "contained" : "outlined"}
onClick={() => onChangeMode(mode)}
sx={{ textTransform: "capitalize" }}
>
{mode}
</Button>
))}
</ButtonGroup>
}
>
<Paper sx={{ borderRadius: 1, boxShadow: 2, ...paperStyle }}>
{asGroup ? (
<List>
{groups.map((group) => (
<ProxyGroup key={group.name} group={group} />
))}
</List>
) : (
// virtual list
<Virtuoso
style={{ height: "100%" }}
totalCount={filterProxies.length}
itemContent={(index) => (
<ProxyItem
proxy={filterProxies[index]}
selected={filterProxies[index].name === curProxy}
onClick={onChangeProxy}
sx={{ py: 0, px: 2 }}
/>
)}
/>
)}
</Paper>
</BasePage>
);
};
export default ProxyPage;

View File

@@ -1,39 +0,0 @@
import useSWR, { useSWRConfig } from "swr";
import { useEffect } from "react";
import { Box, List, Paper, Typography } from "@mui/material";
import { getProxies } from "../services/api";
import ProxyGroup from "../components/proxy-group";
const ProxyPage = () => {
const { mutate } = useSWRConfig();
const { data: proxiesData } = useSWR("getProxies", getProxies);
const { groups = [] } = proxiesData ?? {};
useEffect(() => {
// fix the empty proxies on the first sight
// this bud only show on the build version
// call twice to avoid something unknown or the delay of the clash startup
setTimeout(() => mutate("getProxies"), 250);
setTimeout(() => mutate("getProxies"), 1000);
}, []);
return (
<Box sx={{ width: 0.9, maxWidth: "850px", mx: "auto", mb: 2 }}>
<Typography variant="h4" component="h1" sx={{ py: 2 }}>
Proxy Groups
</Typography>
{groups.length > 0 && (
<Paper sx={{ borderRadius: 1, boxShadow: 2 }}>
<List>
{groups.map((group) => (
<ProxyGroup key={group.name} group={group} />
))}
</List>
</Paper>
)}
</Box>
);
};
export default ProxyPage;

View File

@@ -1,23 +0,0 @@
import { Box, Paper, Typography } from "@mui/material";
import SettingVerge from "../components/setting-verge";
import SettingClash from "../components/setting-clash";
const SettingPage = () => {
return (
<Box sx={{ width: 0.9, maxWidth: 850, mx: "auto", mb: 2 }}>
<Typography variant="h4" component="h1" sx={{ py: 2 }}>
Setting
</Typography>
<Paper sx={{ borderRadius: 1, boxShadow: 2 }}>
<SettingVerge />
</Paper>
<Paper sx={{ borderRadius: 1, boxShadow: 2, mt: 3 }}>
<SettingClash />
</Paper>
</Box>
);
};
export default SettingPage;

30
src/pages/settings.tsx Normal file
View File

@@ -0,0 +1,30 @@
import { Paper } from "@mui/material";
import BasePage from "../components/base-page";
import SettingVerge from "../components/setting/setting-verge";
import SettingClash from "../components/setting/setting-clash";
import SettingSystem from "../components/setting/setting-system";
import Notice from "../components/notice";
const SettingPage = () => {
const onError = (error: any) => {
error && Notice.error(error.toString());
};
return (
<BasePage title="Settings">
<Paper sx={{ borderRadius: 1, boxShadow: 2, mb: 3 }}>
<SettingClash onError={onError} />
</Paper>
<Paper sx={{ borderRadius: 1, boxShadow: 2, mb: 3 }}>
<SettingSystem onError={onError} />
</Paper>
<Paper sx={{ borderRadius: 1, boxShadow: 2 }}>
<SettingVerge onError={onError} />
</Paper>
</BasePage>
);
};
export default SettingPage;

View File

@@ -7,8 +7,9 @@ let server = "";
let secret = ""; let secret = "";
/// initialize some infomation /// initialize some infomation
export async function getAxios() { /// enable force update axiosIns
if (axiosIns) return axiosIns; export async function getAxios(force: boolean = false) {
if (axiosIns && !force) return axiosIns;
try { try {
const info = await getClashInfo(); const info = await getClashInfo();

View File

@@ -9,12 +9,20 @@ export async function syncProfiles() {
return invoke<void>("sync_profiles"); return invoke<void>("sync_profiles");
} }
export async function importProfile(url: string) { export async function newProfile(name: string, desc: string) {
return invoke<void>("import_profile", { url }); return invoke<void>("new_profile", { name, desc });
} }
export async function updateProfile(index: number) { export async function viewProfile(index: number) {
return invoke<void>("update_profile", { index }); return invoke<void>("view_profile", { index });
}
export async function importProfile(url: string) {
return invoke<void>("import_profile", { url, withProxy: true });
}
export async function updateProfile(index: number, withProxy: boolean) {
return invoke<void>("update_profile", { index, withProxy });
} }
export async function deleteProfile(index: number) { export async function deleteProfile(index: number) {
@@ -36,18 +44,6 @@ export async function restartSidecar() {
return invoke<void>("restart_sidecar"); return invoke<void>("restart_sidecar");
} }
export async function windowDrag() {
return invoke<void>("win_drag");
}
export async function windowHide() {
return invoke<void>("win_hide");
}
export async function windowMini() {
return invoke<void>("win_mini");
}
export async function getClashInfo() { export async function getClashInfo() {
return invoke<CmdType.ClashInfo | null>("get_clash_info"); return invoke<CmdType.ClashInfo | null>("get_clash_info");
} }

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;
@@ -111,7 +112,7 @@ export namespace CmdType {
export interface VergeConfig { export interface VergeConfig {
theme_mode?: "light" | "dark"; theme_mode?: "light" | "dark";
theme_blur?: boolean; theme_blur?: boolean;
enable_self_startup?: boolean; enable_auto_launch?: boolean;
enable_system_proxy?: boolean; enable_system_proxy?: boolean;
} }
} }

View File

@@ -9,3 +9,8 @@ export const atomThemeBlur = atom<boolean>({
key: "atomThemeBlur", key: "atomThemeBlur",
default: false, default: false,
}); });
export const atomClashPort = atom<number>({
key: "atomClashPort",
default: 0,
});

View File

@@ -1,68 +0,0 @@
import { useMemo, useState } from "react";
import { Box, IconButton, Slide, Snackbar } from "@mui/material";
import { Close, CheckCircleRounded, ErrorRounded } from "@mui/icons-material";
interface NoticeInstance {
info: (msg: string) => void;
error: (msg: string) => void;
success: (msg: string) => void;
}
const useNotice = () => {
const [message, setMessage] = useState("");
const [level, setLevel] = useState<"info" | "error" | "success">("info");
const handleClose = (_e: any, reason: string) => {
if (reason !== "clickaway") setMessage("");
};
const msgElement =
level === "info" ? (
message
) : (
<Box sx={{ display: "flex", alignItems: "center" }}>
{level === "error" && <ErrorRounded color="error" />}
{level === "success" && <CheckCircleRounded color="success" />}
<span style={{ marginLeft: 4 }}>{message}</span>
</Box>
);
const element = useMemo(
() => (
<Snackbar
open={!!message}
anchorOrigin={{ vertical: "top", horizontal: "right" }}
autoHideDuration={3000}
onClose={handleClose}
message={msgElement}
sx={{ maxWidth: 360 }}
TransitionComponent={(p) => <Slide {...p} direction="left" />}
transitionDuration={200}
action={
<IconButton
size="small"
color="inherit"
onClick={() => setMessage("")}
>
<Close fontSize="small" />
</IconButton>
}
/>
),
[message]
);
const instance = (Object.fromEntries(
(["info", "error", "success"] as const).map((item) => [
item,
(msg: string) => {
setLevel(item);
setMessage(msg);
},
])
) as unknown) as NoticeInstance;
return [instance, element] as const;
};
export default useNotice;

198
yarn.lock
View File

@@ -2,6 +2,23 @@
# yarn lockfile v1 # yarn lockfile v1
"@actions/github@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.0.0.tgz#1754127976c50bd88b2e905f10d204d76d1472f8"
integrity sha512-QvE9eAAfEsS+yOOk0cylLBIO/d6WyWIOvsxxzdrPFaud39G6BOkUwScXZn1iBzQzHyu9SBkkLSWlohDWdsasAQ==
dependencies:
"@actions/http-client" "^1.0.11"
"@octokit/core" "^3.4.0"
"@octokit/plugin-paginate-rest" "^2.13.3"
"@octokit/plugin-rest-endpoint-methods" "^5.1.1"
"@actions/http-client@^1.0.11":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0"
integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==
dependencies:
tunnel "0.0.6"
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.16.0": "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.16.0":
version "7.16.0" version "7.16.0"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.0.tgz#0dfc80309beec8411e65e706461c408b0bb9b431" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.0.tgz#0dfc80309beec8411e65e706461c408b0bb9b431"
@@ -467,6 +484,92 @@
"@nodelib/fs.scandir" "2.1.5" "@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0" fastq "^1.6.0"
"@octokit/auth-token@^2.4.4":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36"
integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==
dependencies:
"@octokit/types" "^6.0.3"
"@octokit/core@^3.4.0":
version "3.5.1"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.5.1.tgz#8601ceeb1ec0e1b1b8217b960a413ed8e947809b"
integrity sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==
dependencies:
"@octokit/auth-token" "^2.4.4"
"@octokit/graphql" "^4.5.8"
"@octokit/request" "^5.6.0"
"@octokit/request-error" "^2.0.5"
"@octokit/types" "^6.0.3"
before-after-hook "^2.2.0"
universal-user-agent "^6.0.0"
"@octokit/endpoint@^6.0.1":
version "6.0.12"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.12.tgz#3b4d47a4b0e79b1027fb8d75d4221928b2d05658"
integrity sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==
dependencies:
"@octokit/types" "^6.0.3"
is-plain-object "^5.0.0"
universal-user-agent "^6.0.0"
"@octokit/graphql@^4.5.8":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3"
integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==
dependencies:
"@octokit/request" "^5.6.0"
"@octokit/types" "^6.0.3"
universal-user-agent "^6.0.0"
"@octokit/openapi-types@^11.2.0":
version "11.2.0"
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-11.2.0.tgz#b38d7fc3736d52a1e96b230c1ccd4a58a2f400a6"
integrity sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA==
"@octokit/plugin-paginate-rest@^2.13.3":
version "2.17.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz#32e9c7cab2a374421d3d0de239102287d791bce7"
integrity sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==
dependencies:
"@octokit/types" "^6.34.0"
"@octokit/plugin-rest-endpoint-methods@^5.1.1":
version "5.13.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz#8c46109021a3412233f6f50d28786f8e552427ba"
integrity sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==
dependencies:
"@octokit/types" "^6.34.0"
deprecation "^2.3.1"
"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677"
integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==
dependencies:
"@octokit/types" "^6.0.3"
deprecation "^2.0.0"
once "^1.4.0"
"@octokit/request@^5.6.0":
version "5.6.2"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.2.tgz#1aa74d5da7b9e04ac60ef232edd9a7438dcf32d8"
integrity sha512-je66CvSEVf0jCpRISxkUcCa0UkxmFs6eGDRSbfJtAVwbLH5ceqF+YEyC8lj8ystKyZTy8adWr0qmkY52EfOeLA==
dependencies:
"@octokit/endpoint" "^6.0.1"
"@octokit/request-error" "^2.1.0"
"@octokit/types" "^6.16.1"
is-plain-object "^5.0.0"
node-fetch "^2.6.1"
universal-user-agent "^6.0.0"
"@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.34.0":
version "6.34.0"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.34.0.tgz#c6021333334d1ecfb5d370a8798162ddf1ae8218"
integrity sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw==
dependencies:
"@octokit/openapi-types" "^11.2.0"
"@popperjs/core@^2.4.4": "@popperjs/core@^2.4.4":
version "2.11.0" version "2.11.0"
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.0.tgz#6734f8ebc106a0860dff7f92bf90df193f0935d7" resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.0.tgz#6734f8ebc106a0860dff7f92bf90df193f0935d7"
@@ -571,6 +674,11 @@
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812" resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812"
integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==
"@types/js-cookie@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-3.0.1.tgz#04aa743e2e0a85a22ee9aa61f6591a8bc19b5d68"
integrity sha512-7wg/8gfHltklehP+oyJnZrz9XBuX5ZPP4zB6UsI84utdlkRYLnOm2HfpLXazTwZA+fpGn0ir8tGNgVnMEleBGQ==
"@types/keyv@*": "@types/keyv@*":
version "3.1.3" version "3.1.3"
resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.3.tgz#1c9aae32872ec1f20dcdaee89a9f3ba88f465e41" resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.3.tgz#1c9aae32872ec1f20dcdaee89a9f3ba88f465e41"
@@ -671,6 +779,24 @@ adm-zip@^0.5.9:
resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.5.9.tgz#b33691028333821c0cf95c31374c5462f2905a83" resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.5.9.tgz#b33691028333821c0cf95c31374c5462f2905a83"
integrity sha512-s+3fXLkeeLjZ2kLjCBwQufpI5fuN+kIGBxu6530nVQZGVol0d7Y/M88/xw9HGGUcJjKf8LutN3VPRUBq6N7Ajg== integrity sha512-s+3fXLkeeLjZ2kLjCBwQufpI5fuN+kIGBxu6530nVQZGVol0d7Y/M88/xw9HGGUcJjKf8LutN3VPRUBq6N7Ajg==
ahooks-v3-count@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ahooks-v3-count/-/ahooks-v3-count-1.0.0.tgz#ddeb392e009ad6e748905b3cbf63a9fd8262ca80"
integrity sha512-V7uUvAwnimu6eh/PED4mCDjE7tokeZQLKlxg9lCTMPhN+NjsSbtdacByVlR1oluXQzD3MOw55wylDmQo4+S9ZQ==
ahooks@^3.1.7:
version "3.1.7"
resolved "https://registry.yarnpkg.com/ahooks/-/ahooks-3.1.7.tgz#e5a7096608e2d82f74eaaf9bb038a81fc097a825"
integrity sha512-H+5LCbOXs7rpHkegiBApGgI6U/Ute8P93elU+bGsgdXkUsElJjYuEmWY6RujSr/IkV/dskFb7iptce3tLbYxng==
dependencies:
ahooks-v3-count "^1.0.0"
dayjs "^1.9.1"
intersection-observer "^0.12.0"
js-cookie "^2.x.x"
lodash "^4.17.21"
resize-observer-polyfill "^1.5.1"
screenfull "^5.0.0"
ansi-align@^3.0.0: ansi-align@^3.0.0:
version "3.0.1" version "3.0.1"
resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.1.tgz#0cdf12e111ace773a86e9a1fad1225c43cb19a59" resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.1.tgz#0cdf12e111ace773a86e9a1fad1225c43cb19a59"
@@ -798,6 +924,11 @@ base64-js@^1.3.1:
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
before-after-hook@^2.2.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e"
integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ==
bin-build@^3.0.0: bin-build@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/bin-build/-/bin-build-3.0.0.tgz#c5780a25a8a9f966d8244217e6c1f5082a143861" resolved "https://registry.yarnpkg.com/bin-build/-/bin-build-3.0.0.tgz#c5780a25a8a9f966d8244217e6c1f5082a143861"
@@ -1304,7 +1435,7 @@ data-uri-to-buffer@^4.0.0:
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz#b5db46aea50f6176428ac05b73be39a57701a64b" resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz#b5db46aea50f6176428ac05b73be39a57701a64b"
integrity sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA== integrity sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==
dayjs@^1.10.7: dayjs@^1.10.7, dayjs@^1.9.1:
version "1.10.7" version "1.10.7"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.7.tgz#2cf5f91add28116748440866a0a1d26f3a6ce468" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.7.tgz#2cf5f91add28116748440866a0a1d26f3a6ce468"
integrity sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig== integrity sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==
@@ -1434,6 +1565,11 @@ delegates@^1.0.0:
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=
deprecation@^2.0.0, deprecation@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==
detect-libc@^1.0.3: detect-libc@^1.0.3:
version "1.0.3" version "1.0.3"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
@@ -2371,6 +2507,11 @@ inquirer@8.1.2:
strip-ansi "^6.0.0" strip-ansi "^6.0.0"
through "^2.3.6" through "^2.3.6"
intersection-observer@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/intersection-observer/-/intersection-observer-0.12.0.tgz#6c84628f67ce8698e5f9ccf857d97718745837aa"
integrity sha512-2Vkz8z46Dv401zTWudDGwO7KiGHNDkMv417T5ItcNYfmvHR/1qCTVBO9vwH8zZmQ0WkA/1ARwpysR9bsnop4NQ==
into-stream@^3.1.0: into-stream@^3.1.0:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/into-stream/-/into-stream-3.1.0.tgz#96fb0a936c12babd6ff1752a17d05616abd094c6" resolved "https://registry.yarnpkg.com/into-stream/-/into-stream-3.1.0.tgz#96fb0a936c12babd6ff1752a17d05616abd094c6"
@@ -2487,6 +2628,11 @@ is-plain-obj@^1.0.0, is-plain-obj@^1.1.0:
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4=
is-plain-object@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344"
integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==
is-png@3.0.0: is-png@3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/is-png/-/is-png-3.0.0.tgz#7bf5db7f32527d10c90594a751c15f74d46c8f5e" resolved "https://registry.yarnpkg.com/is-png/-/is-png-3.0.0.tgz#7bf5db7f32527d10c90594a751c15f74d46c8f5e"
@@ -2550,6 +2696,11 @@ isurl@^1.0.0-alpha5:
has-to-string-tag-x "^1.2.0" has-to-string-tag-x "^1.2.0"
is-object "^1.0.1" is-object "^1.0.1"
js-cookie@^2.x.x:
version "2.2.1"
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -2893,6 +3044,13 @@ node-addon-api@^3.2.0:
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==
node-fetch@^2.6.1:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
dependencies:
whatwg-url "^5.0.0"
node-fetch@^3.1.0: node-fetch@^3.1.0:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.1.0.tgz#714f4922dc270239487654eaeeab86b8206cb52e" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.1.0.tgz#714f4922dc270239487654eaeeab86b8206cb52e"
@@ -3553,6 +3711,11 @@ replace-ext@^2.0.0:
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-2.0.0.tgz#9471c213d22e1bcc26717cd6e50881d88f812b06" resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-2.0.0.tgz#9471c213d22e1bcc26717cd6e50881d88f812b06"
integrity sha512-UszKE5KVK6JvyD92nzMn9cDapSk6w/CaFZ96CnmDMUqH9oowfxF/ZjRITD25H4DnOQClLA4/j7jLGXXLVKxAug== integrity sha512-UszKE5KVK6JvyD92nzMn9cDapSk6w/CaFZ96CnmDMUqH9oowfxF/ZjRITD25H4DnOQClLA4/j7jLGXXLVKxAug==
resize-observer-polyfill@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
resolve-alpn@^1.0.0: resolve-alpn@^1.0.0:
version "1.2.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9"
@@ -3674,6 +3837,11 @@ scheduler@^0.20.2:
loose-envify "^1.1.0" loose-envify "^1.1.0"
object-assign "^4.1.1" object-assign "^4.1.1"
screenfull@^5.0.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/screenfull/-/screenfull-5.2.0.tgz#6533d524d30621fc1283b9692146f3f13a93d1ba"
integrity sha512-9BakfsO2aUQN2K9Fdbj87RJIEZ82Q9IGim7FqM5OsebfoFC6ZHXgDq/KvniuLTPdeM8wY2o6Dj3WQ7KeQCj3cA==
seek-bzip@^1.0.5: seek-bzip@^1.0.5:
version "1.0.6" version "1.0.6"
resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.6.tgz#35c4171f55a680916b52a07859ecf3b5857f21c4" resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.6.tgz#35c4171f55a680916b52a07859ecf3b5857f21c4"
@@ -4104,6 +4272,11 @@ token-types@^4.1.1:
"@tokenizer/token" "^0.3.0" "@tokenizer/token" "^0.3.0"
ieee754 "^1.2.1" ieee754 "^1.2.1"
tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
trim-newlines@^1.0.0: trim-newlines@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
@@ -4128,6 +4301,11 @@ tunnel-agent@^0.6.0:
dependencies: dependencies:
safe-buffer "^5.0.1" safe-buffer "^5.0.1"
tunnel@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
type-fest@^0.13.1: type-fest@^0.13.1:
version "0.13.1" version "0.13.1"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934"
@@ -4170,6 +4348,11 @@ unique-string@^2.0.0:
dependencies: dependencies:
crypto-random-string "^2.0.0" crypto-random-string "^2.0.0"
universal-user-agent@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee"
integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==
universalify@^2.0.0: universalify@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
@@ -4256,6 +4439,19 @@ web-streams-polyfill@^3.0.3:
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz#a6b74026b38e4885869fb5c589e90b95ccfc7965" resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz#a6b74026b38e4885869fb5c589e90b95ccfc7965"
integrity sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA== integrity sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA==
webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=
whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0=
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"
which@^1.2.9: which@^1.2.9:
version "1.3.1" version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"