Compare commits

...
62 Commits
Author SHA1 Message Date
GyDi 73458dcd28 v1.0.5 2022-08-16 23:56:29 +08:00
GyDi 23ebeb1cc0 chore: update log 2022-08-16 23:56:04 +08:00
GyDi a7ba9f1886 fix: fill button title attr 2022-08-16 23:46:33 +08:00
GyDi d5192e2244 feat: windows portable version do not check update 2022-08-16 01:53:40 +08:00
GyDi 7eb595170f fix: do not reset system proxy when consistent 2022-08-16 01:27:32 +08:00
GyDi bd576ca808 fix: adjust web ui item style 2022-08-16 01:08:54 +08:00
GyDi 2f8146b11f fix: clash field state error 2022-08-16 00:48:06 +08:00
GyDi 7f321c89cb feat: adjust clash info parsing logs 2022-08-15 20:21:43 +08:00
GyDi fa65f606b8 fix: badge color error 2022-08-15 20:15:44 +08:00
GyDi 7a3285adaf fix: web ui port value error 2022-08-15 20:14:33 +08:00
GyDi 8bf78fef10 fix: delay show window 2022-08-15 01:37:26 +08:00
GyDi 78f97ce4df feat: adjust runtime config 2022-08-15 01:30:37 +08:00
GyDi 66ccbf70f8 feat: support restart app on tray 2022-08-15 01:22:39 +08:00
GyDi cb48600b40 fix: adjust dialog action button variant 2022-08-15 00:55:35 +08:00
GyDi 33ce235713 feat: optimize profile page 2022-08-14 23:10:19 +08:00
GyDi f1a68ece01 fix: script code error 2022-08-12 23:41:25 +08:00
GyDi dd563360af fix: script exception handle 2022-08-12 11:14:34 +08:00
GyDi 7f6dac4271 feat: refactor 2022-08-12 03:20:55 +08:00
GyDi 178fd8e828 feat: adjust tun mode config 2022-08-11 03:26:08 +08:00
GyDi 1641e02a7d feat: reimplement enhanced mode 2022-08-11 02:55:10 +08:00
GyDi cfd04e9bb4 feat: use rquickjs crate 2022-08-10 13:05:48 +08:00
GyDi 38effaf740 feat: reimplement enhanced mode 2022-08-09 21:15:55 +08:00
GyDi a68eb4a73e chore: format 2022-08-09 14:33:47 +08:00
GyDi c02990ef98 fix: change fields 2022-08-09 14:31:59 +08:00
FoundTheWOUT 5aa7d5ffe9 fix: silent start (#150) 2022-08-09 14:14:06 +08:00
GyDi 4942b0fca5 fix: save profile when update 2022-08-08 23:17:22 +08:00
GyDi aed1bdff5a fix: list compare wrong 2022-08-08 23:16:28 +08:00
GyDi 929c840006 fix: button color 2022-08-08 23:15:05 +08:00
GyDi 57aef1d3c2 chore: rm code 2022-08-08 22:30:13 +08:00
GyDi c1734a094c fix: limit theme mode value 2022-08-08 22:28:44 +08:00
GyDi 99c46685ac feat: finish clash field control 2022-08-08 22:14:03 +08:00
GyDi 066b08040a feat: clash field viewer wip 2022-08-08 01:51:30 +08:00
GyDi 35de2334fb fix: add valid clash field 2022-08-07 20:52:50 +08:00
GyDi 5564c966a5 feat: support web ui 2022-08-06 21:56:54 +08:00
GyDi 0891b5e7b7 feat: adjust setting page style 2022-08-06 03:48:03 +08:00
GyDi f3341f201f refactor: ts path alias 2022-08-06 02:35:11 +08:00
GyDi bf0dafabe2 fix: icon style 2022-08-06 01:44:33 +08:00
GyDi 60f6587169 fix: reduce unwrap 2022-07-30 23:32:52 +08:00
GyDi a9bf32919e feat: runtime config viewer 2022-07-25 01:20:13 +08:00
GyDi 7633f9f88b chore: fix updater script 2022-07-18 12:55:59 +08:00
GyDi 9b56233938 v1.0.4 2022-07-17 17:56:07 +08:00
GyDi 65074264b8 chore: update log 2022-07-17 17:52:41 +08:00
GyDi 4f6fceb87f feat: improve log rule 2022-07-17 17:39:44 +08:00
GyDi 659fdd1d37 fix: import mod 2022-07-17 16:51:54 +08:00
GyDi 8bce2ce040 feat: theme mode support follows system 2022-07-17 16:02:17 +08:00
GyDi 55cc83a5d4 chore: update deps 2022-07-17 14:54:09 +08:00
GyDi 6a51e93ded refactor: mode manage on tray 2022-07-13 02:26:54 +08:00
GyDi fcf570e96e chore: rm code 2022-07-13 01:07:29 +08:00
GyDi cbc184e953 fix: add tray separator 2022-07-13 01:05:53 +08:00
GyDi 98f9063352 Merge pull request #128 from Limsanity/main
feat: support switch proxy mode
2022-07-13 01:02:14 +08:00
limsanity c278f1af00 style: resolve formatting problem 2022-07-13 00:54:47 +08:00
limsanity fbb17a0ba5 feat(system tray): support switch rule/global/direct/script mode in system tray 2022-07-13 00:43:27 +08:00
GyDi 8637a9823e chore: update deps 2022-07-11 00:41:21 +08:00
GyDi d717fe7e8c chore: update clash version 2022-07-08 01:42:14 +08:00
GyDi 5e8dfe7267 chore: update aarch rule 2022-07-07 02:54:20 +08:00
GyDi aaa4fbcdbd chore: aarch upload script 2022-07-07 02:53:53 +08:00
GyDi 150f0cf486 fix: instantiate core after init app, close #122 2022-07-06 15:14:33 +08:00
GyDi 711b220a05 chore: update clash version 2022-07-06 00:54:01 +08:00
GyDi b615c485f7 chore: update deps 2022-07-06 00:49:09 +08:00
GyDi 2f3b6b29ae fix: rm macOS transition props 2022-07-05 01:24:23 +08:00
GyDi 7aecd83c4a chore: update deps 2022-07-05 00:52:22 +08:00
GyDi 3b460ab91f chore: change tray icon 2022-06-22 01:26:25 +08:00
91 changed files with 2810 additions and 1846 deletions
+5
View File
@@ -77,10 +77,15 @@ jobs:
- name: Portable Bundle - name: Portable Bundle
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
# rebuild with env settings
run: | run: |
yarn build
yarn run portable yarn run portable
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
VITE_WIN_PORTABLE: 1
release-update: release-update:
needs: release needs: release
+1
View File
@@ -4,3 +4,4 @@ dist
dist-ssr dist-ssr
*.local *.local
update.json update.json
scripts/_env.sh
+32
View File
@@ -1,3 +1,35 @@
## v1.0.5
### Features
- reimplement profile enhanced mode with quick-js
- optimize the runtime config generation process
- support web ui management
- support clash field management
- support viewing the runtime config
- adjust some pages style
### Bug Fixes
- fix silent start
- fix incorrectly reset system proxy on exit
---
## v1.0.4
### Features
- update clash core and clash meta version
- support switch clash mode on system tray
- theme mode support follows system
### Bug Fixes
- config load error on first use
---
## v1.0.3 ## v1.0.3
### Features ### Features
+16 -15
View File
@@ -1,6 +1,6 @@
{ {
"name": "clash-verge", "name": "clash-verge",
"version": "1.0.3", "version": "1.0.5",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {
"dev": "tauri dev", "dev": "tauri dev",
@@ -10,6 +10,7 @@
"web:dev": "vite", "web:dev": "vite",
"web:build": "tsc && vite build", "web:build": "tsc && vite build",
"web:serve": "vite preview", "web:serve": "vite preview",
"aarch": "node scripts/aarch.mjs",
"check": "node scripts/check.mjs", "check": "node scripts/check.mjs",
"updater": "node scripts/updater.mjs", "updater": "node scripts/updater.mjs",
"publish": "node scripts/publish.mjs", "publish": "node scripts/publish.mjs",
@@ -19,26 +20,26 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.9.3", "@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3", "@emotion/styled": "^11.9.3",
"@mui/icons-material": "^5.8.3", "@mui/icons-material": "^5.8.4",
"@mui/material": "^5.8.3", "@mui/material": "^5.9.0",
"@tauri-apps/api": "^1.0.1", "@tauri-apps/api": "^1.0.2",
"ahooks": "^3.4.1", "ahooks": "^3.5.2",
"axios": "^0.27.2", "axios": "^0.27.2",
"dayjs": "^1.11.3", "dayjs": "^1.11.3",
"i18next": "^21.8.9", "i18next": "^21.8.12",
"monaco-editor": "^0.33.0", "monaco-editor": "^0.33.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-i18next": "^11.17.1", "react-i18next": "^11.17.4",
"react-router-dom": "^6.3.0", "react-router-dom": "^6.3.0",
"react-virtuoso": "^2.13.2", "react-virtuoso": "^2.16.1",
"recoil": "^0.6.1", "recoil": "^0.7.4",
"snarkdown": "^2.0.0", "snarkdown": "^2.0.0",
"swr": "^1.3.0" "swr": "^1.3.0"
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "^5.0.3", "@actions/github": "^5.0.3",
"@tauri-apps/cli": "^1.0.0", "@tauri-apps/cli": "^1.0.4",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/js-cookie": "^3.0.2", "@types/js-cookie": "^3.0.2",
"@types/lodash": "^4.14.180", "@types/lodash": "^4.14.180",
@@ -53,11 +54,11 @@
"node-fetch": "^3.2.6", "node-fetch": "^3.2.6",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"pretty-quick": "^3.1.3", "pretty-quick": "^3.1.3",
"sass": "^1.52.3", "sass": "^1.53.0",
"typescript": "^4.7.3", "typescript": "^4.7.4",
"vite": "^2.9.12", "vite": "^2.9.13",
"vite-plugin-monaco-editor": "^1.0.10", "vite-plugin-monaco-editor": "^1.1.0",
"vite-plugin-svgr": "^2.1.0" "vite-plugin-svgr": "^2.2.0"
}, },
"prettier": { "prettier": {
"tabWidth": 2, "tabWidth": 2,
+104
View File
@@ -0,0 +1,104 @@
/**
* Build and upload assets for macOS(aarch)
*/
import fs from "fs-extra";
import path from "path";
import { exit } from "process";
import { createRequire } from "module";
import { getOctokit, context } from "@actions/github";
const require = createRequire(import.meta.url);
async function resolve() {
if (!process.env.GITHUB_TOKEN) {
throw new Error("GITHUB_TOKEN is required");
}
if (!process.env.GITHUB_REPOSITORY) {
throw new Error("GITHUB_REPOSITORY is required");
}
if (!process.env.TAURI_PRIVATE_KEY) {
throw new Error("TAURI_PRIVATE_KEY is required");
}
if (!process.env.TAURI_KEY_PASSWORD) {
throw new Error("TAURI_KEY_PASSWORD is required");
}
const { version } = require("../package.json");
const cwd = process.cwd();
const bundlePath = path.join(cwd, "src-tauri/target/release/bundle");
const join = (p) => path.join(bundlePath, p);
const appPathList = [
join("macos/Clash Verge.aarch64.app.tar.gz"),
join("macos/Clash Verge.aarch64.app.tar.gz.sig"),
];
for (const appPath of appPathList) {
if (fs.pathExistsSync(appPath)) {
fs.removeSync(appPath);
}
}
fs.copyFileSync(join("macos/Clash Verge.app.tar.gz"), appPathList[0]);
fs.copyFileSync(join("macos/Clash Verge.app.tar.gz.sig"), appPathList[1]);
const options = { owner: context.repo.owner, repo: context.repo.repo };
const github = getOctokit(process.env.GITHUB_TOKEN);
const { data: release } = await github.rest.repos.getReleaseByTag({
...options,
tag: `v${version}`,
});
if (!release.id) throw new Error("failed to find the release");
await uploadAssets(release.id, [
join(`dmg/Clash Verge_${version}_aarch64.dmg`),
...appPathList,
]);
}
// From tauri-apps/tauri-action
// https://github.com/tauri-apps/tauri-action/blob/dev/packages/action/src/upload-release-assets.ts
async function uploadAssets(releaseId, assets) {
const github = getOctokit(process.env.GITHUB_TOKEN);
// Determine content-length for header to upload asset
const contentLength = (filePath) => fs.statSync(filePath).size;
for (const assetPath of assets) {
const headers = {
"content-type": "application/zip",
"content-length": contentLength(assetPath),
};
const ext = path.extname(assetPath);
const filename = path.basename(assetPath).replace(ext, "");
const assetName = path.dirname(assetPath).includes(`target${path.sep}debug`)
? `${filename}-debug${ext}`
: `${filename}${ext}`;
console.log(`[INFO]: Uploading ${assetName}...`);
try {
await github.rest.repos.uploadReleaseAsset({
headers,
name: assetName,
data: fs.readFileSync(assetPath),
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseId,
});
} catch (error) {
console.log(error.message);
}
}
}
if (process.platform === "darwin" && process.arch === "arm64") {
resolve();
} else {
console.error("invalid");
exit(1);
}
+2 -2
View File
@@ -20,7 +20,7 @@ function resolveClash() {
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.06.19"; const CLASH_LATEST_DATE = "2022.07.07";
// todo // todo
const map = { const map = {
@@ -52,7 +52,7 @@ async function resolveClashMeta() {
const { platform, arch } = process; const { platform, arch } = process;
const urlPrefix = `https://github.com/MetaCubeX/Clash.Meta/releases/download/`; const urlPrefix = `https://github.com/MetaCubeX/Clash.Meta/releases/download/`;
const latestVersion = "v1.11.2"; const latestVersion = "v1.12.0";
const map = { const map = {
"win32-x64": "Clash.Meta-windows-amd64", "win32-x64": "Clash.Meta-windows-amd64",
+4 -10
View File
@@ -53,18 +53,12 @@ async function resolveUpdater() {
const { name, browser_download_url } = asset; const { name, browser_download_url } = asset;
// win64 url // win64 url
if ( if (name.endsWith(".msi.zip") && name.includes("en-US")) {
name.endsWith(".msi.zip") &&
(!updateData.platforms.win64.url || name.includes("en-US"))
) {
updateData.platforms.win64.url = browser_download_url; updateData.platforms.win64.url = browser_download_url;
updateData.platforms["windows-x86_64"].url = browser_download_url; updateData.platforms["windows-x86_64"].url = browser_download_url;
} }
// win64 signature // win64 signature
if ( if (name.endsWith(".msi.zip.sig") && name.includes("en-US")) {
name.endsWith(".msi.zip.sig") &&
(!updateData.platforms.win64.signature || name.includes("en-US"))
) {
const sig = await getSignature(browser_download_url); const sig = await getSignature(browser_download_url);
updateData.platforms.win64.signature = sig; updateData.platforms.win64.signature = sig;
updateData.platforms["windows-x86_64"].signature = sig; updateData.platforms["windows-x86_64"].signature = sig;
@@ -83,11 +77,11 @@ async function resolveUpdater() {
} }
// darwin url (aarch) // darwin url (aarch)
if (name.endsWith("aarch.app.tar.gz")) { if (name.endsWith("aarch64.app.tar.gz")) {
updateData.platforms["darwin-aarch64"].url = browser_download_url; updateData.platforms["darwin-aarch64"].url = browser_download_url;
} }
// darwin signature (aarch) // darwin signature (aarch)
if (name.endsWith("aarch.app.tar.gz.sig")) { if (name.endsWith("aarch64.app.tar.gz.sig")) {
const sig = await getSignature(browser_download_url); const sig = await getSignature(browser_download_url);
updateData.platforms["darwin-aarch64"].signature = sig; updateData.platforms["darwin-aarch64"].signature = sig;
} }
+197 -138
View File
@@ -69,9 +69,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.57" version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
[[package]] [[package]]
name = "arc-swap" name = "arc-swap"
@@ -173,9 +173,9 @@ dependencies = [
[[package]] [[package]]
name = "async-task" name = "async-task"
version = "4.2.0" version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
[[package]] [[package]]
name = "async-trait" name = "async-trait"
@@ -254,9 +254,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.65" version = "0.3.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cc", "cc",
@@ -365,9 +365,9 @@ checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.9.1" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" checksum = "c53dfa917ec274df8ed3c572698f381a24eef2efba9492d797301b72b6db408a"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
@@ -389,9 +389,9 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]] [[package]]
name = "cairo-rs" name = "cairo-rs"
version = "0.15.11" version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62be3562254e90c1c6050a72aa638f6315593e98c5cdaba9017cedbabf0a5dee" checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cairo-sys-rs", "cairo-sys-rs",
@@ -505,6 +505,7 @@ dependencies = [
"parking_lot 0.12.1", "parking_lot 0.12.1",
"port_scanner", "port_scanner",
"reqwest", "reqwest",
"rquickjs",
"runas", "runas",
"serde", "serde",
"serde_json", "serde_json",
@@ -674,9 +675,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.9" version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978" checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"once_cell", "once_cell",
@@ -684,9 +685,9 @@ dependencies = [
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
version = "0.1.3" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"typenum", "typenum",
@@ -961,9 +962,9 @@ checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541"
[[package]] [[package]]
name = "either" name = "either"
version = "1.6.1" 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 = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be"
[[package]] [[package]]
name = "embed-resource" name = "embed-resource"
@@ -1040,14 +1041,14 @@ dependencies = [
[[package]] [[package]]
name = "filetime" name = "filetime"
version = "0.2.16" version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c" checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
"redox_syscall", "redox_syscall",
"winapi", "windows-sys",
] ]
[[package]] [[package]]
@@ -1333,15 +1334,15 @@ dependencies = [
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.26.1" version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
[[package]] [[package]]
name = "gio" name = "gio"
version = "0.15.11" version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f132be35e05d9662b9fa0fee3f349c6621f7782e0105917f4cc73c1bf47eceb" checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"futures-channel", "futures-channel",
@@ -1369,9 +1370,9 @@ dependencies = [
[[package]] [[package]]
name = "glib" name = "glib"
version = "0.15.11" version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd124026a2fa8c33a3d17a3fe59c103f2d9fa5bd92c19e029e037736729abeab" checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"futures-channel", "futures-channel",
@@ -1525,6 +1526,12 @@ dependencies = [
"ahash", "ahash",
] ]
[[package]]
name = "hashbrown"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022"
[[package]] [[package]]
name = "headers" name = "headers"
version = "0.3.7" version = "0.3.7"
@@ -1642,9 +1649,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.19" version = "0.14.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f" checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
@@ -1738,12 +1745,12 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.8.2" version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown 0.12.2",
] ]
[[package]] [[package]]
@@ -1888,9 +1895,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libappindicator" name = "libappindicator"
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 = "97b29fab3280d59f3d06725f75da9ef9a1b001b2c748b1abfebd1c966c61d7de" checksum = "db2d3cb96d092b4824cb306c9e544c856a4cb6210c1081945187f7f1924b47e8"
dependencies = [ dependencies = [
"glib", "glib",
"gtk", "gtk",
@@ -1901,9 +1908,9 @@ dependencies = [
[[package]] [[package]]
name = "libappindicator-sys" name = "libappindicator-sys"
version = "0.7.2" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a0e019ae1a736a858f4c52b58af2ca6e797f27d7fe534e8a56776d74a8f2535" checksum = "f1b3b6681973cea8cc3bce7391e6d7d5502720b80a581c9a95c9cbaf592826aa"
dependencies = [ dependencies = [
"gtk-sys", "gtk-sys",
"libloading", "libloading",
@@ -1927,10 +1934,19 @@ dependencies = [
] ]
[[package]] [[package]]
name = "linked-hash-map" name = "line-wrap"
version = "0.5.4" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
dependencies = [
"safemem",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
@@ -2005,7 +2021,7 @@ version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c84e6fe5655adc6ce00787cf7dcaf8dc4f998a0565d23eafc207a8b08ca3349a" checksum = "c84e6fe5655adc6ce00787cf7dcaf8dc4f998a0565d23eafc207a8b08ca3349a"
dependencies = [ dependencies = [
"hashbrown", "hashbrown 0.11.2",
] ]
[[package]] [[package]]
@@ -2112,9 +2128,9 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
@@ -2261,9 +2277,9 @@ dependencies = [
[[package]] [[package]]
name = "num-rational" name = "num-rational"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"num-integer", "num-integer",
@@ -2360,18 +2376,18 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.28.4" 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 = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.12.0" version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
@@ -2401,9 +2417,9 @@ dependencies = [
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.40" version = "0.10.41"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@@ -2433,9 +2449,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.74" version = "0.9.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@@ -2679,18 +2695,18 @@ dependencies = [
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "1.0.10" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" checksum = "78203e83c48cffbe01e4a2d35d566ca4de445d79a85372fc64e378bfc812a260"
dependencies = [ dependencies = [
"pin-project-internal", "pin-project-internal",
] ]
[[package]] [[package]]
name = "pin-project-internal" name = "pin-project-internal"
version = "1.0.10" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" checksum = "710faf75e1b33345361201d36d04e98ac1ed8909151a017ed384700836104c74"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -2715,6 +2731,20 @@ version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "plist"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd39bc6cdc9355ad1dc5eeedefee696bb35c34caf21768741e81826c0bbd7225"
dependencies = [
"base64",
"indexmap",
"line-wrap",
"serde",
"time 0.3.11",
"xml-rs",
]
[[package]] [[package]]
name = "png" name = "png"
version = "0.11.0" version = "0.11.0"
@@ -2812,9 +2842,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.39" version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@@ -2827,9 +2857,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.18" version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@@ -2946,9 +2976,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.5.6" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@@ -2966,9 +2996,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.26" version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
@@ -3018,9 +3048,9 @@ dependencies = [
[[package]] [[package]]
name = "rfd" name = "rfd"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95281ea32d3c1ebdf84027986952e22f2bb89fa1b8b97c012be72bbc3b8e4537" checksum = "f121348fd3b9035ed11be1f028e8944263c30641f8c5deacf57a4320782fb402"
dependencies = [ dependencies = [
"block", "block",
"dispatch", "dispatch",
@@ -3041,6 +3071,33 @@ dependencies = [
"windows", "windows",
] ]
[[package]]
name = "rquickjs"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "989910af47b3f21c95205a1e1974bfb0f460e5492f469631297cc44c3340967e"
dependencies = [
"rquickjs-core",
]
[[package]]
name = "rquickjs-core"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78ca2361848dddf910c27296d98bd62be9467d1d1d703eeead8c732adbd4e32"
dependencies = [
"rquickjs-sys",
]
[[package]]
name = "rquickjs-sys"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "263a9a14fc68f2f3403c67e94e5def69af60afbcf7914d2a7fb8f9e17027fa25"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "rs-snowflake" name = "rs-snowflake"
version = "0.6.0" version = "0.6.0"
@@ -3087,14 +3144,14 @@ 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 = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [ dependencies = [
"semver 1.0.10", "semver 1.0.12",
] ]
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.6" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8"
[[package]] [[package]]
name = "ryu" name = "ryu"
@@ -3202,9 +3259,9 @@ dependencies = [
[[package]] [[package]]
name = "semver" name = "semver"
version = "1.0.10" version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@@ -3226,9 +3283,9 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.137" version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@@ -3245,9 +3302,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.137" version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -3256,9 +3313,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.81" version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7"
dependencies = [ dependencies = [
"itoa 1.0.2", "itoa 1.0.2",
"ryu", "ryu",
@@ -3312,9 +3369,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_yaml" name = "serde_yaml"
version = "0.8.24" version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc" checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"ryu", "ryu",
@@ -3474,9 +3531,9 @@ checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.8.0" version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]] [[package]]
name = "smol" name = "smol"
@@ -3583,9 +3640,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.96" version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -3620,9 +3677,9 @@ dependencies = [
[[package]] [[package]]
name = "tao" name = "tao"
version = "0.11.2" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bfe4c782f0543f667ee3b732d026b2f1c64af39cd52e726dec1ea1f2d8f6b80" checksum = "a71c32c2fa7bba46b01becf9cf470f6a781573af7e376c5e317a313ecce27545"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cairo-rs", "cairo-rs",
@@ -3631,6 +3688,7 @@ dependencies = [
"core-foundation", "core-foundation",
"core-graphics", "core-graphics",
"crossbeam-channel", "crossbeam-channel",
"dirs-next",
"dispatch", "dispatch",
"gdk", "gdk",
"gdk-pixbuf", "gdk-pixbuf",
@@ -3658,7 +3716,6 @@ dependencies = [
"raw-window-handle", "raw-window-handle",
"scopeguard", "scopeguard",
"serde", "serde",
"tao-core-video-sys",
"unicode-segmentation", "unicode-segmentation",
"uuid 0.8.2", "uuid 0.8.2",
"windows", "windows",
@@ -3666,18 +3723,6 @@ dependencies = [
"x11-dl", "x11-dl",
] ]
[[package]]
name = "tao-core-video-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271450eb289cb4d8d0720c6ce70c72c8c858c93dd61fc625881616752e6b98f6"
dependencies = [
"cfg-if 1.0.0",
"core-foundation-sys",
"libc",
"objc",
]
[[package]] [[package]]
name = "tar" name = "tar"
version = "0.4.38" version = "0.4.38"
@@ -3691,9 +3736,9 @@ dependencies = [
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "1.0.0" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1ebb60bb8f246d5351ff9b7728fdfa7a6eba72baa722ab6021d553981caba1" checksum = "827f61bd3dd40276694be5c7ffc40d65b94ab00d9f8c1a4a4db07f2cdc306c83"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"attohttpc", "attohttpc",
@@ -3720,7 +3765,7 @@ dependencies = [
"raw-window-handle", "raw-window-handle",
"regex", "regex",
"rfd", "rfd",
"semver 1.0.10", "semver 1.0.12",
"serde", "serde",
"serde_json", "serde_json",
"serde_repr", "serde_repr",
@@ -3734,7 +3779,7 @@ dependencies = [
"tauri-utils", "tauri-utils",
"tempfile", "tempfile",
"thiserror", "thiserror",
"time 0.3.9", "time 0.3.11",
"tokio", "tokio",
"url", "url",
"uuid 1.1.2", "uuid 1.1.2",
@@ -3746,14 +3791,15 @@ dependencies = [
[[package]] [[package]]
name = "tauri-build" name = "tauri-build"
version = "1.0.0" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7b26eb3523e962b90012fedbfb744ca153d9be85e7981e00737e106d5323941" checksum = "acafb1c515c5d14234a294461bd43c723639a84891a45f6a250fd3441ad2e8ed"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
"heck 0.4.0", "heck 0.4.0",
"semver 1.0.10", "json-patch",
"semver 1.0.12",
"serde_json", "serde_json",
"tauri-utils", "tauri-utils",
"winres", "winres",
@@ -3761,32 +3807,35 @@ dependencies = [
[[package]] [[package]]
name = "tauri-codegen" name = "tauri-codegen"
version = "1.0.0" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9468c5189188c820ef605dfe4937c768cb2918e9460c8093dc4ee2cbd717b262" checksum = "16d62a3c8790d6cba686cea6e3f7f569d12c662c3274c2d165a4fd33e3871b72"
dependencies = [ dependencies = [
"base64", "base64",
"brotli", "brotli",
"ico", "ico",
"json-patch",
"plist",
"png 0.17.5", "png 0.17.5",
"proc-macro2", "proc-macro2",
"quote", "quote",
"regex", "regex",
"semver 1.0.10", "semver 1.0.12",
"serde", "serde",
"serde_json", "serde_json",
"sha2 0.10.2", "sha2 0.10.2",
"tauri-utils", "tauri-utils",
"thiserror", "thiserror",
"time 0.3.11",
"uuid 1.1.2", "uuid 1.1.2",
"walkdir", "walkdir",
] ]
[[package]] [[package]]
name = "tauri-macros" name = "tauri-macros"
version = "1.0.0" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40e3ffddd7a274fc7baaa260888c971a0d95d2ef403aa16600c878b8b1c00ffe" checksum = "7296fa17996629f43081e1c66d554703900187ed900c5bf46f97f0bcfb069278"
dependencies = [ dependencies = [
"heck 0.4.0", "heck 0.4.0",
"proc-macro2", "proc-macro2",
@@ -3798,14 +3847,15 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "0.9.0" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb7dc4db360bb40584187b6cb7834da736ce4ef2ab0914e2be98014444fa9920" checksum = "4e4cff3b4d9469727fa2107c4b3d2eda110df1ba45103fb420178e536362fae4"
dependencies = [ dependencies = [
"gtk", "gtk",
"http", "http",
"http-range", "http-range",
"infer", "infer",
"raw-window-handle",
"serde", "serde",
"serde_json", "serde_json",
"tauri-utils", "tauri-utils",
@@ -3817,14 +3867,15 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "0.9.0" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c876fb3a6e7c6fe2ac466b2a6ecd83658528844b4df0914558a9bc1501b31cf3" checksum = "3fa8c4edaf01d8b556e7172c844b1b4dd3399adcd1a606bd520fc3e65f698546"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"gtk", "gtk",
"percent-encoding", "percent-encoding",
"rand 0.8.5", "rand 0.8.5",
"raw-window-handle",
"tauri-runtime", "tauri-runtime",
"tauri-utils", "tauri-utils",
"uuid 1.1.2", "uuid 1.1.2",
@@ -3836,9 +3887,9 @@ dependencies = [
[[package]] [[package]]
name = "tauri-utils" name = "tauri-utils"
version = "1.0.0" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "727145cb55b8897fa9f2bcea4fad31dc39394703d037c9669b40f2d1c0c2d7f3" checksum = "12ff4b68d9faeb57c9c727bf58c9c9768d2b67d8e84e62ce6146e7859a2e9c6b"
dependencies = [ dependencies = [
"brotli", "brotli",
"ctor", "ctor",
@@ -3851,13 +3902,14 @@ dependencies = [
"phf 0.10.1", "phf 0.10.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"semver 1.0.10", "semver 1.0.12",
"serde", "serde",
"serde_json", "serde_json",
"serde_with", "serde_with",
"thiserror", "thiserror",
"url", "url",
"walkdir", "walkdir",
"windows",
] ]
[[package]] [[package]]
@@ -3998,9 +4050,9 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.9" 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 = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" checksum = "72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217"
dependencies = [ dependencies = [
"itoa 1.0.2", "itoa 1.0.2",
"libc", "libc",
@@ -4024,10 +4076,11 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.19.2" version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" checksum = "57aec3cfa4c296db7255446efb4928a6be304b431a806216105542a67b6ca82e"
dependencies = [ dependencies = [
"autocfg",
"bytes", "bytes",
"libc", "libc",
"memchr", "memchr",
@@ -4126,9 +4179,9 @@ dependencies = [
[[package]] [[package]]
name = "tower-service" name = "tower-service"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
[[package]] [[package]]
name = "tracing" name = "tracing"
@@ -4145,9 +4198,9 @@ dependencies = [
[[package]] [[package]]
name = "tracing-attributes" name = "tracing-attributes"
version = "0.1.21" version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -4156,9 +4209,9 @@ dependencies = [
[[package]] [[package]]
name = "tracing-core" name = "tracing-core"
version = "0.1.27" version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921" checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"valuable", "valuable",
@@ -4177,13 +4230,13 @@ dependencies = [
[[package]] [[package]]
name = "tracing-subscriber" name = "tracing-subscriber"
version = "0.3.11" version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" checksum = "3a713421342a5a666b7577783721d3117f1b69a393df803ee17bb73b1e122a59"
dependencies = [ dependencies = [
"ansi_term", "ansi_term",
"lazy_static",
"matchers", "matchers",
"once_cell",
"regex", "regex",
"sharded-slab", "sharded-slab",
"smallvec", "smallvec",
@@ -4259,9 +4312,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]] [[package]]
name = "ucd-trie" name = "ucd-trie"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c"
[[package]] [[package]]
name = "unicase" name = "unicase"
@@ -4280,15 +4333,15 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.1" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
version = "0.1.19" version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
dependencies = [ dependencies = [
"tinyvec", "tinyvec",
] ]
@@ -4677,9 +4730,9 @@ dependencies = [
[[package]] [[package]]
name = "wildmatch" name = "wildmatch"
version = "2.1.0" version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6c48bd20df7e4ced539c12f570f937c6b4884928a87fee70a479d72f031d4e0" checksum = "ee583bdc5ff1cf9db20e9db5bb3ff4c3089a8f6b8b31aff265c9aba85812db86"
[[package]] [[package]]
name = "winapi" name = "winapi"
@@ -4875,9 +4928,9 @@ dependencies = [
[[package]] [[package]]
name = "wry" name = "wry"
version = "0.18.3" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b1ba327c7dd4292f46bf8e6ba8e6ec2db4443b2973c9d304a359d95e0aa856" checksum = "ce19dddbd3ce01dc8f14eb6d4c8f914123bf8379aaa838f6da4f981ff7104a3f"
dependencies = [ dependencies = [
"block", "block",
"cocoa", "cocoa",
@@ -4935,6 +4988,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "xml-rs"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
[[package]] [[package]]
name = "yaml-rust" name = "yaml-rust"
version = "0.4.5" version = "0.4.5"
+1
View File
@@ -33,6 +33,7 @@ tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json"] } reqwest = { version = "0.11", features = ["json"] }
tauri = { version = "1.0.0", features = ["process-all", "shell-all", "system-tray", "updater", "window-all"] } tauri = { version = "1.0.0", features = ["process-all", "shell-all", "system-tray", "updater", "window-all"] }
rquickjs = { version = "0.1.6" }
window-shadows = { version = "0.1" } window-shadows = { version = "0.1" }
window-vibrancy = { version = "0.1" } window-vibrancy = { version = "0.1" }
+51 -21
View File
@@ -5,6 +5,7 @@ use crate::{
use crate::{log_if_err, ret_err, wrap_err}; use crate::{log_if_err, ret_err, wrap_err};
use anyhow::Result; use anyhow::Result;
use serde_yaml::Mapping; use serde_yaml::Mapping;
use std::collections::HashMap;
use tauri::{api, State}; use tauri::{api, State};
type CmdResult<T = ()> = Result<T, String>; type CmdResult<T = ()> = Result<T, String>;
@@ -19,7 +20,7 @@ pub fn get_profiles(core: State<'_, Core>) -> CmdResult<Profiles> {
/// manually exec enhanced profile /// manually exec enhanced profile
#[tauri::command] #[tauri::command]
pub fn enhance_profiles(core: State<'_, Core>) -> CmdResult { pub fn enhance_profiles(core: State<'_, Core>) -> CmdResult {
wrap_err!(core.activate_enhanced(false)) wrap_err!(core.activate())
} }
/// import the profile from url /// import the profile from url
@@ -58,7 +59,7 @@ pub async fn update_profile(
option: Option<PrfOption>, option: Option<PrfOption>,
core: State<'_, Core>, core: State<'_, Core>,
) -> CmdResult { ) -> CmdResult {
wrap_err!(Core::update_profile_item(core.inner().clone(), index, option).await) wrap_err!(core.update_profile_item(index, option).await)
} }
/// change the current profile /// change the current profile
@@ -66,45 +67,36 @@ pub async fn update_profile(
pub fn select_profile(index: String, core: State<'_, Core>) -> CmdResult { pub fn select_profile(index: String, core: State<'_, Core>) -> CmdResult {
let mut profiles = core.profiles.lock(); let mut profiles = core.profiles.lock();
wrap_err!(profiles.put_current(index))?; wrap_err!(profiles.put_current(index))?;
drop(profiles); drop(profiles);
wrap_err!(core.activate())
wrap_err!(core.activate_enhanced(false))
} }
/// change the profile chain /// change the profile chain
#[tauri::command] #[tauri::command]
pub fn change_profile_chain(chain: Option<Vec<String>>, core: State<'_, Core>) -> CmdResult { pub fn change_profile_chain(chain: Option<Vec<String>>, core: State<'_, Core>) -> CmdResult {
let mut profiles = core.profiles.lock(); let mut profiles = core.profiles.lock();
profiles.put_chain(chain); wrap_err!(profiles.put_chain(chain))?;
drop(profiles); drop(profiles);
wrap_err!(core.activate())
wrap_err!(core.activate_enhanced(false))
} }
/// change the profile valid fields /// change the profile valid fields
#[tauri::command] #[tauri::command]
pub fn change_profile_valid(valid: Option<Vec<String>>, core: State<Core>) -> CmdResult { pub fn change_profile_valid(valid: Option<Vec<String>>, core: State<Core>) -> CmdResult {
let mut profiles = core.profiles.lock(); let mut profiles = core.profiles.lock();
profiles.put_valid(valid); wrap_err!(profiles.put_valid(valid))?;
drop(profiles); drop(profiles);
wrap_err!(core.activate())
wrap_err!(core.activate_enhanced(false))
} }
/// delete profile item /// delete profile item
#[tauri::command] #[tauri::command]
pub fn delete_profile(index: String, core: State<'_, Core>) -> CmdResult { pub fn delete_profile(index: String, core: State<'_, Core>) -> CmdResult {
let mut profiles = core.profiles.lock(); let mut profiles = core.profiles.lock();
if wrap_err!(profiles.delete_item(index))? { if wrap_err!(profiles.delete_item(index))? {
drop(profiles); drop(profiles);
log_if_err!(core.activate());
log_if_err!(core.activate_enhanced(false));
} }
Ok(()) Ok(())
} }
@@ -143,10 +135,8 @@ pub fn view_profile(index: String, core: State<'_, Core>) -> CmdResult {
#[tauri::command] #[tauri::command]
pub fn read_profile_file(index: String, core: State<'_, Core>) -> CmdResult<String> { pub fn read_profile_file(index: String, core: State<'_, Core>) -> CmdResult<String> {
let profiles = core.profiles.lock(); let profiles = core.profiles.lock();
let item = wrap_err!(profiles.get_item(&index))?; let item = wrap_err!(profiles.get_item(&index))?;
let data = wrap_err!(item.read_file())?; let data = wrap_err!(item.read_file())?;
Ok(data) Ok(data)
} }
@@ -174,12 +164,46 @@ pub fn get_clash_info(core: State<'_, Core>) -> CmdResult<ClashInfo> {
Ok(clash.info.clone()) Ok(clash.info.clone())
} }
/// get the runtime clash config mapping
#[tauri::command]
pub fn get_runtime_config(core: State<'_, Core>) -> CmdResult<Option<Mapping>> {
let rt = core.runtime.lock();
Ok(rt.config.clone())
}
/// get the runtime clash config yaml string
#[tauri::command]
pub fn get_runtime_yaml(core: State<'_, Core>) -> CmdResult<Option<String>> {
let rt = core.runtime.lock();
Ok(rt.config_yaml.clone())
}
/// get the runtime config exists keys
#[tauri::command]
pub fn get_runtime_exists(core: State<'_, Core>) -> CmdResult<Vec<String>> {
let rt = core.runtime.lock();
Ok(rt.exists_keys.clone())
}
/// get the runtime enhanced chain log
#[tauri::command]
pub fn get_runtime_logs(
core: State<'_, Core>,
) -> CmdResult<HashMap<String, Vec<(String, String)>>> {
let rt = core.runtime.lock();
Ok(rt.chain_logs.clone())
}
/// 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, core: State<'_, Core>) -> CmdResult { pub fn patch_clash_config(
wrap_err!(core.patch_clash(payload)) payload: Mapping,
app_handle: tauri::AppHandle,
core: State<'_, Core>,
) -> CmdResult {
wrap_err!(core.patch_clash(payload, &app_handle))
} }
/// get the verge config /// get the verge config
@@ -246,6 +270,12 @@ pub fn open_logs_dir() -> Result<(), String> {
wrap_err!(open::that(log_dir)) wrap_err!(open::that(log_dir))
} }
/// open url
#[tauri::command]
pub fn open_web_url(url: String) -> Result<(), String> {
wrap_err!(open::that(url))
}
/// service mode /// service mode
#[cfg(windows)] #[cfg(windows)]
pub mod service { pub mod service {
+118
View File
@@ -0,0 +1,118 @@
use serde_yaml::{Mapping, Value};
pub const HANDLE_FIELDS: [&str; 9] = [
"port",
"socks-port",
"mixed-port",
"mode",
"ipv6",
"log-level",
"allow-lan",
"external-controller",
"secret",
];
pub const DEFAULT_FIELDS: [&str; 5] = [
"proxies",
"proxy-groups",
"rules",
"proxy-providers",
"rule-providers",
];
pub const OTHERS_FIELDS: [&str; 20] = [
"tun",
"dns",
"ebpf",
"hosts",
"script",
"profile",
"payload",
"auto-redir",
"experimental",
"interface-name",
"routing-mark",
"redir-port",
"tproxy-port",
"iptables",
"external-ui",
"bind-address",
"authentication",
"sniffer", // meta
"geodata-mode", // meta
"tcp-concurrent", // meta
];
pub fn use_clash_fields() -> Vec<String> {
DEFAULT_FIELDS
.into_iter()
.chain(HANDLE_FIELDS)
.chain(OTHERS_FIELDS)
.map(|s| s.to_string())
.collect()
}
pub fn use_valid_fields(mut valid: Vec<String>) -> Vec<String> {
let others = Vec::from(OTHERS_FIELDS);
valid.iter_mut().for_each(|s| s.make_ascii_lowercase());
valid
.into_iter()
.filter(|s| others.contains(&s.as_str()))
.chain(DEFAULT_FIELDS.iter().map(|s| s.to_string()))
.collect()
}
pub fn use_filter(config: Mapping, filter: &Vec<String>) -> Mapping {
let mut ret = Mapping::new();
for (key, value) in config.into_iter() {
if let Some(key) = key.as_str() {
if filter.contains(&key.to_string()) {
ret.insert(Value::from(key), value);
}
}
}
ret
}
pub fn use_lowercase(config: Mapping) -> Mapping {
let mut ret = Mapping::new();
for (key, value) in config.into_iter() {
if let Some(key_str) = key.as_str() {
let mut key_str = String::from(key_str);
key_str.make_ascii_lowercase();
ret.insert(Value::from(key_str), value);
}
}
ret
}
pub fn use_sort(config: Mapping) -> Mapping {
let mut ret = Mapping::new();
HANDLE_FIELDS
.into_iter()
.chain(OTHERS_FIELDS)
.chain(DEFAULT_FIELDS)
.for_each(|key| {
let key = Value::from(key);
config.get(&key).map(|value| {
ret.insert(key, value.clone());
});
});
ret
}
pub fn use_keys(config: &Mapping) -> Vec<String> {
config
.iter()
.filter_map(|(key, _)| key.as_str())
.map(|s| {
let mut s = s.to_string();
s.make_ascii_lowercase();
return s;
})
.collect()
}
+93
View File
@@ -0,0 +1,93 @@
use super::{use_filter, use_lowercase};
use serde_yaml::{self, Mapping, Sequence, Value};
#[allow(unused)]
const MERGE_FIELDS: [&str; 6] = [
"prepend-rules",
"append-rules",
"prepend-proxies",
"append-proxies",
"prepend-proxy-groups",
"append-proxy-groups",
];
pub fn use_merge(merge: Mapping, mut config: Mapping) -> Mapping {
// 直接覆盖原字段
use_lowercase(merge.clone())
.into_iter()
.for_each(|(key, value)| {
config.insert(key, value);
});
let merge_list = MERGE_FIELDS.iter().map(|s| s.to_string());
let merge = use_filter(merge, &merge_list.collect());
["rules", "proxies", "proxy-groups"]
.iter()
.for_each(|key_str| {
let key_val = Value::from(key_str.to_string());
let mut list = Sequence::default();
list = config.get(&key_val).map_or(list.clone(), |val| {
val.as_sequence().map_or(list, |v| v.clone())
});
let pre_key = Value::from(format!("prepend-{key_str}"));
let post_key = Value::from(format!("append-{key_str}"));
if let Some(pre_val) = merge.get(&pre_key) {
if pre_val.is_sequence() {
let mut pre_val = pre_val.as_sequence().unwrap().clone();
pre_val.extend(list);
list = pre_val;
}
}
if let Some(post_val) = merge.get(&post_key) {
if post_val.is_sequence() {
list.extend(post_val.as_sequence().unwrap().clone());
}
}
config.insert(key_val, Value::from(list));
});
config
}
#[test]
fn test_merge() -> anyhow::Result<()> {
let merge = r"
prepend-rules:
- prepend
- 1123123
append-rules:
- append
prepend-proxies:
- 9999
append-proxies:
- 1111
rules:
- replace
proxy-groups:
- 123781923810
tun:
enable: true
dns:
enable: true
";
let config = r"
rules:
- aaaaa
script1: test
";
let merge = serde_yaml::from_str::<Mapping>(merge)?;
let config = serde_yaml::from_str::<Mapping>(config)?;
let result = serde_yaml::to_string(&use_merge(merge, config))?;
println!("{result}");
Ok(())
}
+69
View File
@@ -0,0 +1,69 @@
mod field;
mod merge;
mod script;
mod tun;
pub(self) use self::field::*;
use self::merge::*;
use self::script::*;
use self::tun::*;
use crate::core::ChainItem;
use crate::core::ChainType;
use serde_yaml::Mapping;
use std::collections::HashMap;
use std::collections::HashSet;
type ResultLog = Vec<(String, String)>;
pub fn enhance_config(
clash_config: Mapping,
profile_config: Mapping,
chain: Vec<ChainItem>,
valid: Vec<String>,
tun_mode: bool,
) -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
let mut config = profile_config;
let mut result_map = HashMap::new();
let mut exists_keys = use_keys(&config);
let valid = use_valid_fields(valid);
chain.into_iter().for_each(|item| match item.data {
ChainType::Merge(merge) => {
exists_keys.extend(use_keys(&merge));
config = use_merge(merge, config.to_owned());
config = use_filter(config.to_owned(), &valid);
}
ChainType::Script(script) => {
let mut logs = vec![];
match use_script(script, config.to_owned()) {
Ok((res_config, res_logs)) => {
exists_keys.extend(use_keys(&res_config));
config = use_filter(res_config, &valid);
logs.extend(res_logs);
}
Err(err) => logs.push(("exception".into(), err.to_string())),
}
result_map.insert(item.uid, logs);
}
});
config = use_filter(config, &valid);
for (key, value) in clash_config.into_iter() {
config.insert(key, value);
}
let clash_fields = use_clash_fields();
config = use_filter(config, &clash_fields);
config = use_tun(config, tun_mode);
config = use_sort(config);
let mut exists_set = HashSet::new();
exists_set.extend(exists_keys.into_iter().filter(|s| clash_fields.contains(s)));
exists_keys = exists_set.into_iter().collect();
(config, exists_keys, result_map)
}
+94
View File
@@ -0,0 +1,94 @@
use super::use_lowercase;
use anyhow::Result;
use serde_yaml::Mapping;
pub fn use_script(script: String, config: Mapping) -> Result<(Mapping, Vec<(String, String)>)> {
use rquickjs::{Context, Func, Runtime};
use std::sync::{Arc, Mutex};
let runtime = Runtime::new().unwrap();
let context = Context::full(&runtime).unwrap();
let outputs = Arc::new(Mutex::new(vec![]));
let copy_outputs = outputs.clone();
let result = context.with(|ctx| -> Result<Mapping> {
ctx.globals().set(
"__verge_log__",
Func::from(move |level: String, data: String| {
let mut out = copy_outputs.lock().unwrap();
out.push((level, data));
}),
)?;
ctx.eval(
r#"var console = Object.freeze({
log(data){__verge_log__("log",JSON.stringify(data))},
info(data){__verge_log__("info",JSON.stringify(data))},
error(data){__verge_log__("error",JSON.stringify(data))},
debug(data){__verge_log__("debug",JSON.stringify(data))},
});"#,
)?;
let config = use_lowercase(config.clone());
let config_str = serde_json::to_string(&config)?;
let code = format!(
r#"try{{
{script};
JSON.stringify(main({config_str})||'')
}} catch(err) {{
`__error_flag__ ${{err.toString()}}`
}}"#
);
let result: String = ctx.eval(code.as_str())?;
if result.starts_with("__error_flag__") {
anyhow::bail!(result[15..].to_owned());
}
if result == "\"\"" {
anyhow::bail!("main function should return object");
}
return Ok(serde_json::from_str::<Mapping>(result.as_str())?);
});
let mut out = outputs.lock().unwrap();
match result {
Ok(config) => Ok((use_lowercase(config), out.to_vec())),
Err(err) => {
out.push(("exception".into(), err.to_string()));
Ok((config, out.to_vec()))
}
}
}
#[test]
fn test_script() {
let script = r#"
function main(config) {
if (Array.isArray(config.rules)) {
config.rules = [...config.rules, "add"];
}
console.log(config);
config.proxies = ["111"];
return config;
}
"#;
let config = r#"
rules:
- 111
- 222
tun:
enable: false
dns:
enable: false
"#;
let config = serde_yaml::from_str(config).unwrap();
let (config, results) = use_script(script.into(), config).unwrap();
let config_str = serde_yaml::to_string(&config).unwrap();
println!("{config_str}");
dbg!(results);
}
+81
View File
@@ -0,0 +1,81 @@
use serde_yaml::{Mapping, Value};
macro_rules! revise {
($map: expr, $key: expr, $val: expr) => {
let ret_key = Value::String($key.into());
$map.insert(ret_key, Value::from($val));
};
}
// if key not exists then append value
macro_rules! append {
($map: expr, $key: expr, $val: expr) => {
let ret_key = Value::String($key.into());
if !$map.contains_key(&ret_key) {
$map.insert(ret_key, Value::from($val));
}
};
}
pub fn use_tun(mut config: Mapping, enable: bool) -> Mapping {
let tun_key = Value::from("tun");
let tun_val = config.get(&tun_key);
if !enable && tun_val.is_none() {
return config;
}
let mut tun_val = tun_val.map_or(Mapping::new(), |val| {
val.as_mapping().cloned().unwrap_or(Mapping::new())
});
revise!(tun_val, "enable", enable);
if enable {
append!(tun_val, "stack", "gvisor");
append!(tun_val, "dns-hijack", vec!["198.18.0.2:53"]);
append!(tun_val, "auto-route", true);
append!(tun_val, "auto-detect-interface", true);
}
revise!(config, "tun", tun_val);
if enable {
use_dns_for_tun(config)
} else {
config
}
}
fn use_dns_for_tun(mut config: Mapping) -> Mapping {
let dns_key = Value::from("dns");
let dns_val = config.get(&dns_key);
let mut dns_val = dns_val.map_or(Mapping::new(), |val| {
val.as_mapping().cloned().unwrap_or(Mapping::new())
});
// 开启tun将同时开启dns
revise!(dns_val, "enable", true);
// 借鉴cfw的默认配置
append!(dns_val, "enhanced-mode", "fake-ip");
append!(
dns_val,
"nameserver",
vec!["114.114.114.114", "223.5.5.5", "8.8.8.8"]
);
append!(dns_val, "fallback", vec![] as Vec<&str>);
#[cfg(target_os = "windows")]
append!(
dns_val,
"fake-ip-filter",
vec![
"dns.msftncsi.com",
"www.msftncsi.com",
"www.msftconnecttest.com"
]
);
revise!(config, "dns", dns_val);
config
}
+41 -168
View File
@@ -22,18 +22,26 @@ impl ClashInfo {
/// parse the clash's config.yaml /// parse the clash's config.yaml
/// get some information /// get some information
pub fn from(config: &Mapping) -> ClashInfo { pub fn from(config: &Mapping) -> ClashInfo {
let key_port_1 = Value::from("port"); let key_port_1 = Value::from("mixed-port");
let key_port_2 = Value::from("mixed-port"); let key_port_2 = Value::from("port");
let key_server = Value::from("external-controller"); let key_server = Value::from("external-controller");
let key_secret = Value::from("secret"); let key_secret = Value::from("secret");
let mut status: u32 = 0;
let port = match config.get(&key_port_1) { let port = match config.get(&key_port_1) {
Some(value) => match value { Some(value) => match value {
Value::String(val_str) => Some(val_str.clone()), Value::String(val_str) => Some(val_str.clone()),
Value::Number(val_num) => Some(val_num.to_string()), Value::Number(val_num) => Some(val_num.to_string()),
_ => None, _ => {
status |= 0b1;
None
}
}, },
_ => None, _ => {
status |= 0b10;
None
}
}; };
let port = match port { let port = match port {
Some(_) => port, Some(_) => port,
@@ -41,25 +49,38 @@ impl ClashInfo {
Some(value) => match value { Some(value) => match value {
Value::String(val_str) => Some(val_str.clone()), Value::String(val_str) => Some(val_str.clone()),
Value::Number(val_num) => Some(val_num.to_string()), Value::Number(val_num) => Some(val_num.to_string()),
_ => None, _ => {
status |= 0b100;
None
}
}, },
_ => None, _ => {
status |= 0b1000;
None
}
}, },
}; };
// `external-controller` could be // `external-controller` could be
// "127.0.0.1:9090" or ":9090" // "127.0.0.1:9090" or ":9090"
let server = match config.get(&key_server) { let server = match config.get(&key_server) {
Some(value) => { Some(value) => match value.as_str() {
let val_str = value.as_str().unwrap_or(""); Some(val_str) => {
if val_str.starts_with(":") {
if val_str.starts_with(":") { Some(format!("127.0.0.1{val_str}"))
Some(format!("127.0.0.1{val_str}")) } else {
} else { Some(val_str.into())
Some(val_str.into()) }
} }
None => {
status |= 0b10000;
None
}
},
None => {
status |= 0b100000;
None
} }
_ => None,
}; };
let secret = match config.get(&key_secret) { let secret = match config.get(&key_secret) {
@@ -73,7 +94,7 @@ impl ClashInfo {
}; };
ClashInfo { ClashInfo {
status: "init".into(), status: format!("{status}"),
port, port,
server, server,
secret, secret,
@@ -113,23 +134,16 @@ impl Clash {
/// patch update the clash config /// patch update the clash config
/// if the port is changed then return true /// if the port is changed then return true
pub fn patch_config(&mut self, patch: Mapping) -> Result<bool> { pub fn patch_config(&mut self, patch: Mapping) -> Result<()> {
let port_key = Value::from("mixed-port"); let port_key = Value::from("mixed-port");
let server_key = Value::from("external-controller"); let server_key = Value::from("external-controller");
let secret_key = Value::from("secret"); let secret_key = Value::from("secret");
let mut change_port = false; let change_info = patch.contains_key(&port_key)
let mut change_info = false; || patch.contains_key(&server_key)
|| patch.contains_key(&secret_key);
for (key, value) in patch.into_iter() { for (key, value) in patch.into_iter() {
if key == port_key {
change_port = true;
}
if key == port_key || key == server_key || key == secret_key {
change_info = true;
}
self.config.insert(key, value); self.config.insert(key, value);
} }
@@ -137,148 +151,7 @@ impl Clash {
self.info = ClashInfo::from(&self.config); self.info = ClashInfo::from(&self.config);
} }
self.save_config()?; self.save_config()
Ok(change_port)
}
/// revise the `tun` and `dns` config
pub fn _tun_mode(mut config: Mapping, enable: bool) -> Mapping {
macro_rules! revise {
($map: expr, $key: expr, $val: expr) => {
let ret_key = Value::String($key.into());
$map.insert(ret_key, Value::from($val));
};
}
// if key not exists then append value
macro_rules! append {
($map: expr, $key: expr, $val: expr) => {
let ret_key = Value::String($key.into());
if !$map.contains_key(&ret_key) {
$map.insert(ret_key, Value::from($val));
}
};
}
// tun config
let tun_val = config.get(&Value::from("tun"));
let mut new_tun = Mapping::new();
if tun_val.is_some() && tun_val.as_ref().unwrap().is_mapping() {
new_tun = tun_val.as_ref().unwrap().as_mapping().unwrap().clone();
}
revise!(new_tun, "enable", enable);
if enable {
append!(new_tun, "stack", "gvisor");
append!(new_tun, "dns-hijack", vec!["198.18.0.2:53"]);
append!(new_tun, "auto-route", true);
append!(new_tun, "auto-detect-interface", true);
}
revise!(config, "tun", new_tun);
if enable {
// dns config
let dns_val = config.get(&Value::from("dns"));
let mut new_dns = Mapping::new();
if dns_val.is_some() && dns_val.as_ref().unwrap().is_mapping() {
new_dns = dns_val.as_ref().unwrap().as_mapping().unwrap().clone();
}
revise!(new_dns, "enable", enable);
// 借鉴cfw的默认配置
append!(new_dns, "enhanced-mode", "fake-ip");
append!(
new_dns,
"nameserver",
vec!["114.114.114.114", "223.5.5.5", "8.8.8.8"]
);
append!(new_dns, "fallback", vec![] as Vec<&str>);
#[cfg(target_os = "windows")]
append!(
new_dns,
"fake-ip-filter",
vec![
"dns.msftncsi.com",
"www.msftncsi.com",
"www.msftconnecttest.com"
]
);
revise!(config, "dns", new_dns);
}
config
}
/// only 5 default fields available (clash config fields)
/// convert to lowercase
pub fn strict_filter(config: Mapping) -> Mapping {
// Only the following fields are allowed:
// proxies/proxy-providers/proxy-groups/rule-providers/rules
let valid_keys = vec![
"proxies",
"proxy-providers",
"proxy-groups",
"rules",
"rule-providers",
];
let mut new_config = Mapping::new();
for (key, value) in config.into_iter() {
key.as_str().map(|key_str| {
// change to lowercase
let mut key_str = String::from(key_str);
key_str.make_ascii_lowercase();
// filter
if valid_keys.contains(&&*key_str) {
new_config.insert(Value::String(key_str), value);
}
});
}
new_config
}
/// more clash config fields available
/// convert to lowercase
pub fn loose_filter(config: Mapping) -> Mapping {
// all of these can not be revised by script or merge
// http/https/socks port should be under control
let not_allow = vec![
"port",
"socks-port",
"mixed-port",
"allow-lan",
"mode",
"external-controller",
"secret",
"log-level",
];
let mut new_config = Mapping::new();
for (key, value) in config.into_iter() {
key.as_str().map(|key_str| {
// change to lowercase
let mut key_str = String::from(key_str);
key_str.make_ascii_lowercase();
// filter
if !not_allow.contains(&&*key_str) {
new_config.insert(Value::String(key_str), value);
}
});
}
new_config
} }
} }
-66
View File
@@ -1,66 +0,0 @@
use super::prfitem::PrfItem;
use crate::utils::{config, dirs};
use serde::{Deserialize, Serialize};
use serde_yaml::Mapping;
use std::fs;
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct PrfEnhanced {
pub current: Mapping,
pub chain: Vec<PrfData>,
pub valid: Vec<String>,
pub callback: String,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct PrfEnhancedResult {
pub data: Option<Mapping>,
pub status: String,
pub error: Option<String>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct PrfData {
item: PrfItem,
#[serde(skip_serializing_if = "Option::is_none")]
merge: Option<Mapping>,
#[serde(skip_serializing_if = "Option::is_none")]
script: Option<String>,
}
impl PrfData {
pub fn from_item(item: &PrfItem) -> Option<PrfData> {
match item.itype.as_ref() {
Some(itype) => {
let file = item.file.clone()?;
let path = dirs::app_profiles_dir().join(file);
if !path.exists() {
return None;
}
match itype.as_str() {
"script" => Some(PrfData {
item: item.clone(),
script: Some(fs::read_to_string(path).unwrap_or("".into())),
merge: None,
}),
"merge" => Some(PrfData {
item: item.clone(),
merge: Some(config::read_yaml::<Mapping>(path)),
script: None,
}),
_ => None,
}
}
None => None,
}
}
}
+107 -174
View File
@@ -1,19 +1,16 @@
use self::notice::Notice; use self::notice::Notice;
use self::sysopt::Sysopt; use self::sysopt::Sysopt;
use self::timer::Timer; use self::timer::Timer;
use crate::core::enhance::PrfEnhancedResult; use crate::config::enhance_config;
use crate::log_if_err; use crate::log_if_err;
use crate::utils::{dirs, help};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use parking_lot::Mutex; use parking_lot::Mutex;
use serde_yaml::Mapping; use serde_yaml::Mapping;
use serde_yaml::Value;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration;
use tauri::{AppHandle, Manager, Window}; use tauri::{AppHandle, Manager, Window};
use tokio::time::sleep;
mod clash; mod clash;
mod enhance;
mod notice; mod notice;
mod prfitem; mod prfitem;
mod profiles; mod profiles;
@@ -28,41 +25,28 @@ pub use self::profiles::*;
pub use self::service::*; pub use self::service::*;
pub use self::verge::*; pub use self::verge::*;
/// close the window for slient start
/// after enhance mode
static mut WINDOW_CLOSABLE: bool = true;
#[derive(Clone)] #[derive(Clone)]
pub struct Core { pub struct Core {
pub clash: Arc<Mutex<Clash>>, pub clash: Arc<Mutex<Clash>>,
pub verge: Arc<Mutex<Verge>>, pub verge: Arc<Mutex<Verge>>,
pub profiles: Arc<Mutex<Profiles>>, pub profiles: Arc<Mutex<Profiles>>,
pub service: Arc<Mutex<Service>>, pub service: Arc<Mutex<Service>>,
pub sysopt: Arc<Mutex<Sysopt>>, pub sysopt: Arc<Mutex<Sysopt>>,
pub timer: Arc<Mutex<Timer>>, pub timer: Arc<Mutex<Timer>>,
pub runtime: Arc<Mutex<RuntimeResult>>,
pub window: Arc<Mutex<Option<Window>>>, pub window: Arc<Mutex<Option<Window>>>,
} }
impl Core { impl Core {
pub fn new() -> Core { pub fn new() -> Core {
let clash = Clash::new();
let verge = Verge::new();
let profiles = Profiles::new();
let service = Service::new();
Core { Core {
clash: Arc::new(Mutex::new(clash)), clash: Arc::new(Mutex::new(Clash::new())),
verge: Arc::new(Mutex::new(verge)), verge: Arc::new(Mutex::new(Verge::new())),
profiles: Arc::new(Mutex::new(profiles)), profiles: Arc::new(Mutex::new(Profiles::new())),
service: Arc::new(Mutex::new(service)), service: Arc::new(Mutex::new(Service::new())),
sysopt: Arc::new(Mutex::new(Sysopt::new())), sysopt: Arc::new(Mutex::new(Sysopt::new())),
timer: Arc::new(Mutex::new(Timer::new())), timer: Arc::new(Mutex::new(Timer::new())),
runtime: Arc::new(Mutex::new(RuntimeResult::default())),
window: Arc::new(Mutex::new(None)), window: Arc::new(Mutex::new(None)),
} }
} }
@@ -90,17 +74,8 @@ impl Core {
let clash = self.clash.lock(); let clash = self.clash.lock();
let verge = self.verge.lock(); let verge = self.verge.lock();
let silent_start = verge.enable_silent_start.clone(); // let silent_start = verge.enable_silent_start.clone();
let auto_launch = verge.enable_auto_launch.clone(); let auto_launch = verge.enable_auto_launch.clone();
// silent start
if silent_start.unwrap_or(false) {
let window = self.window.lock();
window.as_ref().map(|win| {
win.hide().unwrap();
});
}
let mut sysopt = self.sysopt.lock(); let mut sysopt = self.sysopt.lock();
sysopt.init_sysproxy(clash.info.port.clone(), &verge); sysopt.init_sysproxy(clash.info.port.clone(), &verge);
@@ -111,13 +86,7 @@ impl Core {
log_if_err!(sysopt.init_launch(auto_launch)); log_if_err!(sysopt.init_launch(auto_launch));
log_if_err!(self.update_systray(&app_handle)); log_if_err!(self.update_systray(&app_handle));
log_if_err!(self.update_systray_clash(&app_handle));
// wait the window setup during resolve app
let core = self.clone();
tauri::async_runtime::spawn(async move {
sleep(Duration::from_secs(2)).await;
log_if_err!(core.activate_enhanced(true));
});
// timer initialize // timer initialize
let mut timer = self.timer.lock(); let mut timer = self.timer.lock();
@@ -136,9 +105,7 @@ impl Core {
let mut service = self.service.lock(); let mut service = self.service.lock();
service.restart()?; service.restart()?;
drop(service); drop(service);
self.activate()
self.activate()?;
self.activate_enhanced(true)
} }
/// change the clash core /// change the clash core
@@ -162,33 +129,38 @@ impl Core {
service.start()?; service.start()?;
drop(service); drop(service);
self.activate()?; self.activate()
self.activate_enhanced(true)
} }
/// Patch Clash /// Patch Clash
/// handle the clash config changed /// handle the clash config changed
pub fn patch_clash(&self, patch: Mapping) -> Result<()> { pub fn patch_clash(&self, patch: Mapping, app_handle: &AppHandle) -> Result<()> {
let (changed, port) = { let has_port = patch.contains_key(&Value::from("mixed-port"));
let has_mode = patch.contains_key(&Value::from("mode"));
let port = {
let mut clash = self.clash.lock(); let mut clash = self.clash.lock();
(clash.patch_config(patch)?, clash.info.port.clone()) clash.patch_config(patch)?;
clash.info.port.clone()
}; };
// todo: port check // todo: port check
if has_port && port.is_some() {
if changed {
let mut service = self.service.lock(); let mut service = self.service.lock();
service.restart()?; service.restart()?;
drop(service); drop(service);
self.activate()?; self.activate()?;
self.activate_enhanced(true)?;
let mut sysopt = self.sysopt.lock(); let mut sysopt = self.sysopt.lock();
let verge = self.verge.lock(); let verge = self.verge.lock();
sysopt.init_sysproxy(port, &verge); sysopt.init_sysproxy(port, &verge);
} }
if has_mode {
self.update_systray_clash(app_handle)?;
}
Ok(()) Ok(())
} }
@@ -213,7 +185,8 @@ impl Core {
service.start()?; service.start()?;
drop(service); drop(service);
self.activate_enhanced(false)?; // self.activate_enhanced(false)?;
self.activate()?;
} }
} }
@@ -235,7 +208,7 @@ impl Core {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
if tun_mode.is_some() && *tun_mode.as_ref().unwrap_or(&false) { if tun_mode.is_some() && *tun_mode.as_ref().unwrap_or(&false) {
let wintun_dll = dirs::app_home_dir().join("wintun.dll"); let wintun_dll = crate::utils::dirs::app_home_dir().join("wintun.dll");
if !wintun_dll.exists() { if !wintun_dll.exists() {
bail!("failed to enable TUN for missing `wintun.dll`"); bail!("failed to enable TUN for missing `wintun.dll`");
} }
@@ -251,13 +224,38 @@ impl Core {
} }
if tun_mode.is_some() { if tun_mode.is_some() {
self.activate_enhanced(false)?; self.activate()?;
} }
Ok(()) Ok(())
} }
/// update the system tray state // update system tray state (clash config)
pub fn update_systray_clash(&self, app_handle: &AppHandle) -> Result<()> {
let clash = self.clash.lock();
let mode = clash
.config
.get(&Value::from("mode"))
.map(|val| val.as_str().unwrap_or("rule"))
.unwrap_or("rule");
let tray = app_handle.tray_handle();
tray.get_item("rule_mode").set_selected(mode == "rule")?;
tray
.get_item("global_mode")
.set_selected(mode == "global")?;
tray
.get_item("direct_mode")
.set_selected(mode == "direct")?;
tray
.get_item("script_mode")
.set_selected(mode == "script")?;
Ok(())
}
/// update the system tray state (verge config)
pub fn update_systray(&self, app_handle: &AppHandle) -> Result<()> { pub fn update_systray(&self, app_handle: &AppHandle) -> Result<()> {
let verge = self.verge.lock(); let verge = self.verge.lock();
let tray = app_handle.tray_handle(); let tray = app_handle.tray_handle();
@@ -280,141 +278,79 @@ impl Core {
Ok(()) Ok(())
} }
// update rule/global/direct/script mode
pub fn update_mode(&self, app_handle: &AppHandle, mode: &str) -> Result<()> {
// save config to file
let mut clash = self.clash.lock();
clash.config.insert(Value::from("mode"), Value::from(mode));
clash.save_config()?;
let info = clash.info.clone();
drop(clash);
let notice = {
let window = self.window.lock();
Notice::from(window.clone())
};
let mut mapping = Mapping::new();
mapping.insert(Value::from("mode"), Value::from(mode));
let service = self.service.lock();
service.patch_config(info, mapping, notice)?;
// update tray
self.update_systray_clash(app_handle)?;
Ok(())
}
/// activate the profile /// activate the profile
/// auto activate enhanced profile /// auto activate enhanced profile
pub fn activate(&self) -> Result<()> { pub fn activate(&self) -> Result<()> {
let data = { let profile_activate = {
let profiles = self.profiles.lock(); let profiles = self.profiles.lock();
let data = profiles.gen_activate()?; profiles.gen_activate()?
Clash::strict_filter(data)
}; };
let (mut config, info) = { let (clash_config, clash_info) = {
let clash = self.clash.lock(); let clash = self.clash.lock();
let config = clash.config.clone(); (clash.config.clone(), clash.info.clone())
let info = clash.info.clone();
(config, info)
}; };
for (key, value) in data.into_iter() { let tun_mode = {
config.insert(key, value);
}
let config = {
let verge = self.verge.lock(); let verge = self.verge.lock();
let tun_mode = verge.enable_tun_mode.unwrap_or(false); verge.enable_tun_mode.unwrap_or(false)
Clash::_tun_mode(config, tun_mode)
}; };
let (config, exists_keys, logs) = enhance_config(
clash_config,
profile_activate.current,
profile_activate.chain,
profile_activate.valid,
tun_mode,
);
let mut runtime = self.runtime.lock();
runtime.config = Some(config.clone());
runtime.config_yaml = Some(serde_yaml::to_string(&config).unwrap_or("".into()));
runtime.exists_keys = exists_keys;
runtime.chain_logs = logs;
let notice = { let notice = {
let window = self.window.lock(); let window = self.window.lock();
Notice::from(window.clone()) Notice::from(window.clone())
}; };
let service = self.service.lock(); let service = self.service.lock();
service.set_config(info, config, notice) service.set_config(clash_info, config, notice)
} }
/// Enhanced
/// enhanced profiles mode
pub fn activate_enhanced(&self, skip: bool) -> Result<()> {
let window = self.window.lock();
if window.is_none() {
bail!("failed to get the main window");
}
let event_name = help::get_uid("e");
let event_name = format!("enhanced-cb-{event_name}");
// generate the payload
let payload = {
let profiles = self.profiles.lock();
profiles.gen_enhanced(event_name.clone())?
};
// do not run enhanced
if payload.chain.len() == 0 {
if skip {
return Ok(());
}
drop(window);
return self.activate();
}
let tun_mode = {
let verge = self.verge.lock();
verge.enable_tun_mode.unwrap_or(false)
};
let info = {
let clash = self.clash.lock();
clash.info.clone()
};
let notice = Notice::from(window.clone());
let service = self.service.clone();
let window = window.clone().unwrap();
window.once(&event_name, move |event| {
let result = event.payload();
if result.is_none() {
log::warn!("event payload result is none");
return;
}
let result = result.unwrap();
let result: PrfEnhancedResult = serde_json::from_str(result).unwrap();
if let Some(data) = result.data {
let mut config = Clash::read_config();
let filter_data = Clash::loose_filter(data); // loose filter
for (key, value) in filter_data.into_iter() {
config.insert(key, value);
}
let config = Clash::_tun_mode(config, tun_mode);
let service = service.lock();
log_if_err!(service.set_config(info, config, notice));
log::info!("profile enhanced status {}", result.status);
}
result.error.map(|err| log::error!("{err}"));
});
let verge = self.verge.lock();
let silent_start = verge.enable_silent_start.clone();
let closable = unsafe { WINDOW_CLOSABLE };
if silent_start.unwrap_or(false) && closable {
unsafe {
WINDOW_CLOSABLE = false;
}
window.emit("script-handler-close", payload).unwrap();
} else {
window.emit("script-handler", payload).unwrap();
}
Ok(())
}
}
impl Core {
/// Static function /// Static function
/// update profile item /// update profile item
pub async fn update_profile_item( pub async fn update_profile_item(&self, uid: String, option: Option<PrfOption>) -> Result<()> {
core: Core,
uid: String,
option: Option<PrfOption>,
) -> Result<()> {
let (url, opt) = { let (url, opt) = {
let profiles = core.profiles.lock(); let profiles = self.profiles.lock();
let item = profiles.get_item(&uid)?; let item = profiles.get_item(&uid)?;
if let Some(typ) = item.itype.as_ref() { if let Some(typ) = item.itype.as_ref() {
@@ -423,30 +359,27 @@ impl Core {
// reactivate the config // reactivate the config
if Some(uid) == profiles.get_current() { if Some(uid) == profiles.get_current() {
drop(profiles); drop(profiles);
return core.activate_enhanced(false); return self.activate();
} }
return Ok(()); return Ok(());
} }
} }
if item.url.is_none() { if item.url.is_none() {
bail!("failed to get the profile item url"); bail!("failed to get the profile item url");
} }
(item.url.clone().unwrap(), item.option.clone()) (item.url.clone().unwrap(), item.option.clone())
}; };
let merged_opt = PrfOption::merge(opt, option); let merged_opt = PrfOption::merge(opt, option);
let item = PrfItem::from_url(&url, None, None, merged_opt).await?; let item = PrfItem::from_url(&url, None, None, merged_opt).await?;
let mut profiles = core.profiles.lock(); let mut profiles = self.profiles.lock();
profiles.update_item(uid.clone(), item)?; profiles.update_item(uid.clone(), item)?;
// reactivate the profile // reactivate the profile
if Some(uid) == profiles.get_current() { if Some(uid) == profiles.get_current() {
drop(profiles); drop(profiles);
core.activate_enhanced(false)?; self.activate()?;
} }
Ok(()) Ok(())
+2
View File
@@ -11,6 +11,7 @@ impl Notice {
Notice { win } Notice { win }
} }
#[allow(unused)]
pub fn set_win(&mut self, win: Option<Window>) { pub fn set_win(&mut self, win: Option<Window>) {
self.win = win; self.win = win;
} }
@@ -27,6 +28,7 @@ impl Notice {
} }
} }
#[allow(unused)]
pub fn refresh_profiles(&self) { pub fn refresh_profiles(&self) {
if let Some(window) = self.win.as_ref() { if let Some(window) = self.win.as_ref() {
log_if_err!(window.emit("verge://refresh-profiles-config", "yes")); log_if_err!(window.emit("verge://refresh-profiles-config", "yes"));
+37 -1
View File
@@ -1,4 +1,4 @@
use crate::utils::{dirs, help, tmpl}; use crate::utils::{config, dirs, help, tmpl};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_yaml::Mapping; use serde_yaml::Mapping;
@@ -333,4 +333,40 @@ impl PrfItem {
let path = dirs::app_profiles_dir().join(file); let path = dirs::app_profiles_dir().join(file);
fs::write(path, data.as_bytes()).context("failed to save the file") fs::write(path, data.as_bytes()).context("failed to save the file")
} }
/// get the data for enhanced mode
pub fn to_enhance(&self) -> Option<ChainItem> {
let itype = self.itype.as_ref()?.as_str();
let file = self.file.clone()?;
let uid = self.uid.clone().unwrap_or("".into());
let path = dirs::app_profiles_dir().join(file);
if !path.exists() {
return None;
}
match itype {
"script" => Some(ChainItem {
uid,
data: ChainType::Script(fs::read_to_string(path).unwrap_or("".into())),
}),
"merge" => Some(ChainItem {
uid,
data: ChainType::Merge(config::read_yaml::<Mapping>(path)),
}),
_ => None,
}
}
}
#[derive(Debug, Clone)]
pub struct ChainItem {
pub uid: String,
pub data: ChainType,
}
#[derive(Debug, Clone)]
pub enum ChainType {
Merge(Mapping),
Script(String),
} }
+32 -21
View File
@@ -1,9 +1,10 @@
use super::enhance::{PrfData, PrfEnhanced};
use super::prfitem::PrfItem; use super::prfitem::PrfItem;
use super::ChainItem;
use crate::utils::{config, dirs, help}; use crate::utils::{config, dirs, help};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_yaml::Mapping; use serde_yaml::Mapping;
use std::collections::HashMap;
use std::{fs, io::Write}; use std::{fs, io::Write};
/// ///
@@ -91,13 +92,15 @@ impl Profiles {
} }
/// just change the `chain` /// just change the `chain`
pub fn put_chain(&mut self, chain: Option<Vec<String>>) { pub fn put_chain(&mut self, chain: Option<Vec<String>>) -> Result<()> {
self.chain = chain; self.chain = chain;
self.save_file()
} }
/// just change the `field` /// just change the `field`
pub fn put_valid(&mut self, valid: Option<Vec<String>>) { pub fn put_valid(&mut self, valid: Option<Vec<String>>) -> Result<()> {
self.valid = valid; self.valid = valid;
self.save_file()
} }
/// get items ref /// get items ref
@@ -260,8 +263,8 @@ impl Profiles {
Ok(current == uid) Ok(current == uid)
} }
/// only generate config mapping /// generate the current Mapping data
pub fn gen_activate(&self) -> Result<Mapping> { fn gen_current(&self) -> Result<Mapping> {
let config = Mapping::new(); let config = Mapping::new();
if self.current.is_none() || self.items.is_none() { if self.current.is_none() || self.items.is_none() {
@@ -269,7 +272,6 @@ impl Profiles {
} }
let current = self.current.clone().unwrap(); let current = self.current.clone().unwrap();
for item in self.items.as_ref().unwrap().iter() { for item in self.items.as_ref().unwrap().iter() {
if item.uid == Some(current.clone()) { if item.uid == Some(current.clone()) {
let file_path = match item.file.clone() { let file_path = match item.file.clone() {
@@ -284,34 +286,43 @@ impl Profiles {
return Ok(config::read_yaml::<Mapping>(file_path.clone())); return Ok(config::read_yaml::<Mapping>(file_path.clone()));
} }
} }
bail!("failed to found the uid \"{current}\""); bail!("failed to found the uid \"{current}\"");
} }
/// gen the enhanced profiles /// generate the data for activate clash config
pub fn gen_enhanced(&self, callback: String) -> Result<PrfEnhanced> { pub fn gen_activate(&self) -> Result<PrfActivate> {
let current = self.gen_activate()?; let current = self.gen_current()?;
let chain = match self.chain.as_ref() { let chain = match self.chain.as_ref() {
Some(chain) => chain Some(chain) => chain
.iter() .iter()
.map(|uid| self.get_item(uid)) .filter_map(|uid| self.get_item(uid).ok())
.filter(|item| item.is_ok()) .filter_map(|item| item.to_enhance())
.map(|item| item.unwrap()) .collect::<Vec<ChainItem>>(),
.map(|item| PrfData::from_item(item))
.filter(|o| o.is_some())
.map(|o| o.unwrap())
.collect::<Vec<PrfData>>(),
None => vec![], None => vec![],
}; };
let valid = self.valid.clone().unwrap_or(vec![]); let valid = self.valid.clone().unwrap_or(vec![]);
Ok(PrfEnhanced { Ok(PrfActivate {
current, current,
chain, chain,
valid, valid,
callback,
}) })
} }
} }
#[derive(Default, Clone)]
pub struct PrfActivate {
pub current: Mapping,
pub chain: Vec<ChainItem>,
pub valid: Vec<String>,
}
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct RuntimeResult {
pub config: Option<Mapping>,
pub config_yaml: Option<String>,
// 记录在配置中(包括merge和script生成的)出现过的keys
// 这些keys不一定都生效
pub exists_keys: Vec<String>,
pub chain_logs: HashMap<String, Vec<(String, String)>>,
}
+60 -31
View File
@@ -3,7 +3,6 @@ use crate::log_if_err;
use crate::utils::{config, dirs}; use crate::utils::{config, dirs};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use reqwest::header::HeaderMap; use reqwest::header::HeaderMap;
use serde::{Deserialize, Serialize};
use serde_yaml::Mapping; use serde_yaml::Mapping;
use std::{collections::HashMap, time::Duration}; use std::{collections::HashMap, time::Duration};
use tauri::api::process::{Command, CommandChild, CommandEvent}; use tauri::api::process::{Command, CommandChild, CommandEvent};
@@ -54,12 +53,10 @@ impl Service {
Ok(status) => { Ok(status) => {
// 未启动clash // 未启动clash
if status.code != 0 { if status.code != 0 {
if let Err(err) = Self::start_clash_by_service().await { log_if_err!(Self::start_clash_by_service().await);
log::error!("{err}");
}
} }
} }
Err(err) => log::error!("{err}"), Err(err) => log::error!(target: "app", "{err}"),
} }
}); });
@@ -78,9 +75,7 @@ impl Service {
} }
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
if let Err(err) = Self::stop_clash_by_service().await { log_if_err!(Self::stop_clash_by_service().await);
log::error!("{err}");
}
}); });
Ok(()) Ok(())
@@ -110,8 +105,11 @@ impl Service {
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
while let Some(event) = rx.recv().await { while let Some(event) = rx.recv().await {
match event { match event {
CommandEvent::Stdout(line) => log::info!("[clash]: {}", line), CommandEvent::Stdout(line) => {
CommandEvent::Stderr(err) => log::error!("[clash]: {}", err), let stdout = if line.len() > 33 { &line[33..] } else { &line };
log::info!(target: "app" ,"[clash]: {}", stdout);
}
CommandEvent::Stderr(err) => log::error!(target: "app" ,"[clash error]: {}", err),
_ => {} _ => {}
} }
} }
@@ -138,24 +136,7 @@ impl Service {
let temp_path = dirs::profiles_temp_path(); let temp_path = dirs::profiles_temp_path();
config::save_yaml(temp_path.clone(), &config, Some("# Clash Verge Temp File"))?; config::save_yaml(temp_path.clone(), &config, Some("# Clash Verge Temp File"))?;
if info.server.is_none() { let (server, headers) = Self::clash_client_info(info)?;
if info.port.is_none() {
bail!("failed to parse config.yaml file");
} else {
bail!("failed to parse the server");
}
}
let server = info.server.unwrap();
let server = format!("http://{server}/configs");
let mut headers = HeaderMap::new();
headers.insert("Content-Type", "application/json".parse().unwrap());
if let Some(secret) = info.secret.as_ref() {
let secret = format!("Bearer {}", secret.clone()).parse().unwrap();
headers.insert("Authorization", secret);
}
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
let mut data = HashMap::new(); let mut data = HashMap::new();
@@ -170,7 +151,7 @@ impl Service {
match builder.send().await { match builder.send().await {
Ok(resp) => { Ok(resp) => {
if resp.status() != 204 { if resp.status() != 204 {
log::error!("failed to activate clash with status \"{}\"", resp.status()); log::error!(target: "app", "failed to activate clash with status \"{}\"", resp.status());
} }
notice.refresh_clash(); notice.refresh_clash();
@@ -178,10 +159,10 @@ impl Service {
// do not retry // do not retry
break; break;
} }
Err(err) => log::error!("failed to activate for `{err}`"), Err(err) => log::error!(target: "app", "failed to activate for `{err}`"),
} }
} }
Err(err) => log::error!("failed to activate for `{err}`"), Err(err) => log::error!(target: "app", "failed to activate for `{err}`"),
} }
sleep(Duration::from_millis(500)).await; sleep(Duration::from_millis(500)).await;
} }
@@ -189,6 +170,53 @@ impl Service {
Ok(()) Ok(())
} }
/// patch clash config
pub fn patch_config(&self, info: ClashInfo, config: Mapping, notice: Notice) -> Result<()> {
if !self.service_mode && self.sidecar.is_none() {
bail!("did not start sidecar");
}
let (server, headers) = Self::clash_client_info(info)?;
tauri::async_runtime::spawn(async move {
if let Ok(client) = reqwest::ClientBuilder::new().no_proxy().build() {
let builder = client.patch(&server).headers(headers.clone()).json(&config);
match builder.send().await {
Ok(_) => notice.refresh_clash(),
Err(err) => log::error!(target: "app", "{err}"),
}
}
});
Ok(())
}
/// get clash client url and headers from clash info
fn clash_client_info(info: ClashInfo) -> Result<(String, HeaderMap)> {
if info.server.is_none() {
let status = &info.status;
if info.port.is_none() {
bail!("failed to parse config.yaml file with status {status}");
} else {
bail!("failed to parse the server with status {status}");
}
}
let server = info.server.unwrap();
let server = format!("http://{server}/configs");
let mut headers = HeaderMap::new();
headers.insert("Content-Type", "application/json".parse().unwrap());
if let Some(secret) = info.secret.as_ref() {
let secret = format!("Bearer {}", secret.clone()).parse().unwrap();
headers.insert("Authorization", secret);
}
Ok((server, headers))
}
} }
impl Drop for Service { impl Drop for Service {
@@ -205,6 +233,7 @@ pub mod win_service {
use anyhow::Context; use anyhow::Context;
use deelevate::{PrivilegeLevel, Token}; use deelevate::{PrivilegeLevel, Token};
use runas::Command as RunasCommand; use runas::Command as RunasCommand;
use serde::{Deserialize, Serialize};
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
use std::{env::current_exe, process::Command as StdCommand}; use std::{env::current_exe, process::Command as StdCommand};
+15 -5
View File
@@ -2,7 +2,6 @@ use super::{Clash, Verge};
use crate::{log_if_err, utils::sysopt::SysProxyConfig}; use crate::{log_if_err, utils::sysopt::SysProxyConfig};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use auto_launch::{AutoLaunch, AutoLaunchBuilder}; use auto_launch::{AutoLaunch, AutoLaunchBuilder};
// use parking_lot::Mutex;
use std::sync::Arc; use std::sync::Arc;
use tauri::{async_runtime::Mutex, utils::platform::current_exe}; use tauri::{async_runtime::Mutex, utils::platform::current_exe};
@@ -46,7 +45,7 @@ impl Sysopt {
if enable { if enable {
if let Err(err) = sysproxy.set_sys() { if let Err(err) = sysproxy.set_sys() {
log::error!("failed to set system proxy for `{err}`"); log::error!(target: "app", "failed to set system proxy for `{err}`");
} }
} }
@@ -88,9 +87,17 @@ impl Sysopt {
/// reset the sysproxy /// reset the sysproxy
pub fn reset_sysproxy(&mut self) { pub fn reset_sysproxy(&mut self) {
if let Some(sysproxy) = self.old_sysproxy.take() { if let Some(sysproxy) = self.old_sysproxy.take() {
// 如果原代理设置是开启的,且域名端口设置和当前的一致,就不恢复原设置
// https://github.com/zzzgydi/clash-verge/issues/157
if let Some(cur) = self.cur_sysproxy.as_ref() {
if sysproxy.enable && cur.server == sysproxy.server {
return;
}
}
match sysproxy.set_sys() { match sysproxy.set_sys() {
Ok(_) => self.cur_sysproxy = None, Ok(_) => self.cur_sysproxy = None,
Err(_) => log::error!("failed to reset proxy"), Err(_) => log::error!(target: "app", "failed to reset proxy"),
} }
} }
} }
@@ -183,7 +190,7 @@ impl Sysopt {
break; break;
} }
log::debug!("try to guard the system proxy"); log::debug!(target: "app", "try to guard the system proxy");
let clash = Clash::new(); let clash = Clash::new();
@@ -194,7 +201,10 @@ impl Sysopt {
log_if_err!(sysproxy.set_sys()); log_if_err!(sysproxy.set_sys());
} }
None => log::error!("failed to parse clash port"), None => {
let status = &clash.info.status;
log::error!(target: "app", "failed to parse clash port with status {status}")
}
} }
} }
+2 -2
View File
@@ -139,8 +139,8 @@ impl Timer {
/// the task runner /// the task runner
async fn async_task(core: Core, uid: String) { async fn async_task(core: Core, uid: String) {
log::info!("running timer task `{uid}`"); log::info!(target: "app", "running timer task `{uid}`");
log_if_err!(Core::update_profile_item(core, uid, None).await); log_if_err!(core.update_profile_item(uid, None).await);
} }
} }
+24 -45
View File
@@ -46,6 +46,9 @@ pub struct Verge {
/// theme setting /// theme setting
pub theme_setting: Option<VergeTheme>, pub theme_setting: Option<VergeTheme>,
/// web ui list
pub web_ui_list: Option<Vec<String>>,
/// clash core path /// clash core path
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub clash_core: Option<String>, pub clash_core: Option<String>,
@@ -84,55 +87,31 @@ impl Verge {
/// patch verge config /// patch verge config
/// only save to file /// only save to file
pub fn patch_config(&mut self, patch: Verge) -> Result<()> { pub fn patch_config(&mut self, patch: Verge) -> Result<()> {
// only change it macro_rules! patch {
if patch.language.is_some() { ($key: tt) => {
self.language = patch.language; if patch.$key.is_some() {
} self.$key = patch.$key;
if patch.theme_mode.is_some() { }
self.theme_mode = patch.theme_mode; };
}
if patch.theme_blur.is_some() {
self.theme_blur = patch.theme_blur;
}
if patch.theme_setting.is_some() {
self.theme_setting = patch.theme_setting;
}
if patch.traffic_graph.is_some() {
self.traffic_graph = patch.traffic_graph;
}
if patch.clash_core.is_some() {
self.clash_core = patch.clash_core;
} }
// system setting patch!(language);
if patch.enable_silent_start.is_some() { patch!(theme_mode);
self.enable_silent_start = patch.enable_silent_start; patch!(theme_blur);
} patch!(traffic_graph);
if patch.enable_auto_launch.is_some() {
self.enable_auto_launch = patch.enable_auto_launch;
}
// proxy patch!(enable_tun_mode);
if patch.enable_system_proxy.is_some() { patch!(enable_service_mode);
self.enable_system_proxy = patch.enable_system_proxy; patch!(enable_auto_launch);
} patch!(enable_silent_start);
if patch.system_proxy_bypass.is_some() { patch!(enable_system_proxy);
self.system_proxy_bypass = patch.system_proxy_bypass; patch!(enable_proxy_guard);
} patch!(system_proxy_bypass);
if patch.enable_proxy_guard.is_some() { patch!(proxy_guard_duration);
self.enable_proxy_guard = patch.enable_proxy_guard;
}
if patch.proxy_guard_duration.is_some() {
self.proxy_guard_duration = patch.proxy_guard_duration;
}
// tun mode patch!(theme_setting);
if patch.enable_tun_mode.is_some() { patch!(web_ui_list);
self.enable_tun_mode = patch.enable_tun_mode; patch!(clash_core);
}
if patch.enable_service_mode.is_some() {
self.enable_service_mode = patch.enable_service_mode;
}
self.save_file() self.save_file()
} }
+29 -2
View File
@@ -4,6 +4,7 @@
)] )]
mod cmds; mod cmds;
mod config;
mod core; mod core;
mod utils; mod utils;
@@ -30,15 +31,21 @@ fn main() -> std::io::Result<()> {
let tray_menu = SystemTrayMenu::new() let tray_menu = SystemTrayMenu::new()
.add_item(CustomMenuItem::new("open_window", "Show")) .add_item(CustomMenuItem::new("open_window", "Show"))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("rule_mode", "Rule Mode"))
.add_item(CustomMenuItem::new("global_mode", "Global Mode"))
.add_item(CustomMenuItem::new("direct_mode", "Direct Mode"))
.add_item(CustomMenuItem::new("script_mode", "Script Mode"))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("system_proxy", "System Proxy")) .add_item(CustomMenuItem::new("system_proxy", "System Proxy"))
.add_item(CustomMenuItem::new("tun_mode", "Tun Mode")) .add_item(CustomMenuItem::new("tun_mode", "Tun Mode"))
.add_item(CustomMenuItem::new("restart_clash", "Restart Clash")) .add_item(CustomMenuItem::new("restart_clash", "Restart Clash"))
.add_item(CustomMenuItem::new("restart_app", "Restart App"))
.add_native_item(SystemTrayMenuItem::Separator) .add_native_item(SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new("quit", "Quit").accelerator("CmdOrControl+Q")); .add_item(CustomMenuItem::new("quit", "Quit").accelerator("CmdOrControl+Q"));
#[allow(unused_mut)] #[allow(unused_mut)]
let mut builder = tauri::Builder::default() let mut builder = tauri::Builder::default()
.manage(core::Core::new())
.setup(|app| Ok(resolve::resolve_setup(app))) .setup(|app| Ok(resolve::resolve_setup(app)))
.system_tray(SystemTray::new().with_menu(tray_menu)) .system_tray(SystemTray::new().with_menu(tray_menu))
.on_system_tray_event(move |app_handle, event| match event { .on_system_tray_event(move |app_handle, event| match event {
@@ -46,6 +53,11 @@ fn main() -> std::io::Result<()> {
"open_window" => { "open_window" => {
resolve::create_window(app_handle); resolve::create_window(app_handle);
} }
mode @ ("rule_mode" | "global_mode" | "direct_mode" | "script_mode") => {
let mode = &mode[0..mode.len() - 5];
let core = app_handle.state::<core::Core>();
crate::log_if_err!(core.update_mode(app_handle, mode));
}
"system_proxy" => { "system_proxy" => {
let core = app_handle.state::<core::Core>(); let core = app_handle.state::<core::Core>();
@@ -80,6 +92,9 @@ fn main() -> std::io::Result<()> {
let core = app_handle.state::<core::Core>(); let core = app_handle.state::<core::Core>();
crate::log_if_err!(core.restart_clash()); crate::log_if_err!(core.restart_clash());
} }
"restart_app" => {
api::process::restart(&app_handle.env());
}
"quit" => { "quit" => {
resolve::resolve_reset(app_handle); resolve::resolve_reset(app_handle);
app_handle.exit(0); app_handle.exit(0);
@@ -98,12 +113,17 @@ fn main() -> std::io::Result<()> {
cmds::get_cur_proxy, cmds::get_cur_proxy,
cmds::open_app_dir, cmds::open_app_dir,
cmds::open_logs_dir, cmds::open_logs_dir,
cmds::open_web_url,
cmds::kill_sidecar, cmds::kill_sidecar,
cmds::restart_sidecar, cmds::restart_sidecar,
// clash // clash
cmds::get_clash_info, cmds::get_clash_info,
cmds::patch_clash_config, cmds::patch_clash_config,
cmds::change_clash_core, cmds::change_clash_core,
cmds::get_runtime_config,
cmds::get_runtime_yaml,
cmds::get_runtime_exists,
cmds::get_runtime_logs,
// verge // verge
cmds::get_verge_config, cmds::get_verge_config,
cmds::patch_verge_config, cmds::patch_verge_config,
@@ -146,8 +166,15 @@ fn main() -> std::io::Result<()> {
builder = builder.menu(Menu::new().add_submenu(submenu_file)); builder = builder.menu(Menu::new().add_submenu(submenu_file));
} }
let mut context = tauri::generate_context!();
let verge = Verge::new();
for win in context.config_mut().tauri.windows.iter_mut() {
if verge.enable_silent_start.unwrap_or(false) {
win.visible = false;
}
}
builder builder
.build(tauri::generate_context!()) .build(context)
.expect("error while running tauri application") .expect("error while running tauri application")
.run(|app_handle, e| match e { .run(|app_handle, e| match e {
tauri::RunEvent::ExitRequested { api, .. } => { tauri::RunEvent::ExitRequested { api, .. } => {
-11
View File
@@ -1,11 +0,0 @@
// use crate::core::{Clash, Profiles, Verge};
// use std::sync::{Arc, Mutex};
// #[derive(Default)]
// pub struct ProfilesState(pub Arc<Mutex<Profiles>>);
// #[derive(Default)]
// pub struct ClashState(pub Arc<Mutex<Clash>>);
// #[derive(Default)]
// pub struct VergeState(pub Arc<Mutex<Verge>>);
+2 -2
View File
@@ -5,7 +5,7 @@ use std::{fs, path::PathBuf};
/// read data from yaml as struct T /// read data from yaml as struct T
pub fn read_yaml<T: DeserializeOwned + Default>(path: PathBuf) -> T { pub fn read_yaml<T: DeserializeOwned + Default>(path: PathBuf) -> T {
if !path.exists() { if !path.exists() {
log::error!("file not found \"{}\"", path.display()); log::error!(target: "app", "file not found \"{}\"", path.display());
return T::default(); return T::default();
} }
@@ -14,7 +14,7 @@ pub fn read_yaml<T: DeserializeOwned + Default>(path: PathBuf) -> T {
match serde_yaml::from_str::<T>(&yaml_str) { match serde_yaml::from_str::<T>(&yaml_str) {
Ok(val) => val, Ok(val) => val,
Err(_) => { Err(_) => {
log::error!("failed to read yaml file \"{}\"", path.display()); log::error!(target: "app", "failed to read yaml file \"{}\"", path.display());
T::default() T::default()
} }
} }
+2 -2
View File
@@ -80,7 +80,7 @@ pub fn open_file(path: PathBuf) -> Result<()> {
macro_rules! log_if_err { macro_rules! log_if_err {
($result: expr) => { ($result: expr) => {
if let Err(err) = $result { if let Err(err) = $result {
log::error!("{err}"); log::error!(target: "app", "{err}");
} }
}; };
} }
@@ -93,7 +93,7 @@ macro_rules! wrap_err {
match $stat { match $stat {
Ok(a) => Ok(a), Ok(a) => Ok(a),
Err(err) => { Err(err) => {
log::error!("{}", err.to_string()); log::error!(target: "app", "{}", err.to_string());
Err(format!("{}", err.to_string())) Err(format!("{}", err.to_string()))
} }
} }
+22 -20
View File
@@ -1,9 +1,10 @@
use crate::utils::{dirs, tmpl}; use crate::utils::{dirs, tmpl};
use anyhow::Result;
use chrono::Local; use chrono::Local;
use log::LevelFilter; use log::LevelFilter;
use log4rs::append::console::ConsoleAppender; use log4rs::append::console::ConsoleAppender;
use log4rs::append::file::FileAppender; use log4rs::append::file::FileAppender;
use log4rs::config::{Appender, Config, Root}; use log4rs::config::{Appender, Config, Logger, Root};
use log4rs::encode::pattern::PatternEncoder; use log4rs::encode::pattern::PatternEncoder;
use std::fs; use std::fs;
use std::io::Write; use std::io::Write;
@@ -11,7 +12,7 @@ use std::path::PathBuf;
use tauri::PackageInfo; use tauri::PackageInfo;
/// initialize this instance's log file /// initialize this instance's log file
fn init_log(log_dir: &PathBuf) { fn init_log(log_dir: &PathBuf) -> Result<()> {
let local_time = Local::now().format("%Y-%m-%d-%H%M%S").to_string(); let local_time = Local::now().format("%Y-%m-%d-%H%M%S").to_string();
let log_file = format!("{}.log", local_time); let log_file = format!("{}.log", local_time);
let log_file = log_dir.join(log_file); let log_file = log_dir.join(log_file);
@@ -22,24 +23,26 @@ fn init_log(log_dir: &PathBuf) {
.build(); .build();
let tofile = FileAppender::builder() let tofile = FileAppender::builder()
.encoder(Box::new(PatternEncoder::new(time_format))) .encoder(Box::new(PatternEncoder::new(time_format)))
.build(log_file) .build(log_file)?;
.unwrap();
let config = Config::builder() let config = Config::builder()
.appender(Appender::builder().build("stdout", Box::new(stdout))) .appender(Appender::builder().build("stdout", Box::new(stdout)))
.appender(Appender::builder().build("file", Box::new(tofile))) .appender(Appender::builder().build("file", Box::new(tofile)))
.build( .logger(
Root::builder() Logger::builder()
.appenders(["stdout", "file"]) .appenders(["file", "stdout"])
.build(LevelFilter::Info), .additive(false)
.build("app", LevelFilter::Info),
) )
.unwrap(); .build(Root::builder().appender("stdout").build(LevelFilter::Info))?;
log4rs::init_config(config).unwrap(); log4rs::init_config(config)?;
Ok(())
} }
/// Initialize all the files from resources /// Initialize all the files from resources
fn init_config(app_dir: &PathBuf) -> std::io::Result<()> { fn init_config(app_dir: &PathBuf) -> Result<()> {
// target path // target path
let clash_path = app_dir.join("config.yaml"); let clash_path = app_dir.join("config.yaml");
let verge_path = app_dir.join("verge.yaml"); let verge_path = app_dir.join("verge.yaml");
@@ -67,25 +70,24 @@ pub fn init_app(package_info: &PackageInfo) {
let res_dir = dirs::app_resources_dir(package_info); let res_dir = dirs::app_resources_dir(package_info);
if !app_dir.exists() { if !app_dir.exists() {
fs::create_dir_all(&app_dir).unwrap(); let _ = fs::create_dir_all(&app_dir);
} }
if !log_dir.exists() { if !log_dir.exists() {
fs::create_dir_all(&log_dir).unwrap(); let _ = fs::create_dir_all(&log_dir);
} }
if !profiles_dir.exists() { if !profiles_dir.exists() {
fs::create_dir_all(&profiles_dir).unwrap(); let _ = fs::create_dir_all(&profiles_dir);
} }
init_log(&log_dir); crate::log_if_err!(init_log(&log_dir));
if let Err(err) = init_config(&app_dir) {
log::error!("{err}"); crate::log_if_err!(init_config(&app_dir));
}
// copy the resource file // copy the resource file
let mmdb_path = app_dir.join("Country.mmdb"); let mmdb_path = app_dir.join("Country.mmdb");
let mmdb_tmpl = res_dir.join("Country.mmdb"); let mmdb_tmpl = res_dir.join("Country.mmdb");
if !mmdb_path.exists() && mmdb_tmpl.exists() { if !mmdb_path.exists() && mmdb_tmpl.exists() {
fs::copy(mmdb_tmpl, mmdb_path).unwrap(); let _ = fs::copy(mmdb_tmpl, mmdb_path);
} }
// copy the wintun.dll // copy the wintun.dll
@@ -94,7 +96,7 @@ pub fn init_app(package_info: &PackageInfo) {
let wintun_path = app_dir.join("wintun.dll"); let wintun_path = app_dir.join("wintun.dll");
let wintun_tmpl = res_dir.join("wintun.dll"); let wintun_tmpl = res_dir.join("wintun.dll");
if !wintun_path.exists() && wintun_tmpl.exists() { if !wintun_path.exists() && wintun_tmpl.exists() {
fs::copy(wintun_tmpl, wintun_path).unwrap(); let _ = fs::copy(wintun_tmpl, wintun_path);
} }
} }
} }
+11 -3
View File
@@ -9,12 +9,16 @@ pub fn resolve_setup(app: &App) {
// init app config // init app config
init::init_app(app.package_info()); init::init_app(app.package_info());
// init states // init core
let core = app.state::<Core>(); // should be initialized after init_app fix #122
let core = Core::new();
core.set_win(app.get_window("main")); core.set_win(app.get_window("main"));
core.init(app.app_handle()); core.init(app.app_handle());
// fix #122
app.manage(core);
resolve_window(app); resolve_window(app);
} }
@@ -84,6 +88,8 @@ pub fn create_window(app_handle: &AppHandle) {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {
use crate::utils::winhelp; use crate::utils::winhelp;
use std::time::Duration;
use tokio::time::sleep;
use window_shadows::set_shadow; use window_shadows::set_shadow;
use window_vibrancy::apply_blur; use window_vibrancy::apply_blur;
@@ -97,6 +103,8 @@ pub fn create_window(app_handle: &AppHandle) {
let app_handle = app_handle.clone(); let app_handle = app_handle.clone();
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
sleep(Duration::from_secs(1)).await;
if let Some(window) = app_handle.get_window("main") { if let Some(window) = app_handle.get_window("main") {
let _ = window.show(); let _ = window.show();
let _ = set_shadow(&window, true); let _ = set_shadow(&window, true);
@@ -107,7 +115,7 @@ pub fn create_window(app_handle: &AppHandle) {
} }
}); });
} }
Err(err) => log::error!("{err}"), Err(err) => log::error!(target: "app", "{err}"),
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"package": { "package": {
"productName": "Clash Verge", "productName": "Clash Verge",
"version": "1.0.3" "version": "1.0.5"
}, },
"build": { "build": {
"distDir": "../dist", "distDir": "../dist",
@@ -11,7 +11,7 @@
}, },
"tauri": { "tauri": {
"systemTray": { "systemTray": {
"iconPath": "icons/tray-icon.png", "iconPath": "icons/tray-icon.ico",
"iconAsTemplate": true "iconAsTemplate": true
}, },
"bundle": { "bundle": {
+31
View File
@@ -0,0 +1,31 @@
import { alpha, Box, Typography } from "@mui/material";
import { BlurOnRounded } from "@mui/icons-material";
interface Props {
text?: React.ReactNode;
extra?: React.ReactNode;
}
const BaseEmpty = (props: Props) => {
const { text = "Empty", extra } = props;
return (
<Box
sx={({ palette }) => ({
width: "100%",
height: "100%",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
color: alpha(palette.text.secondary, 0.75),
})}
>
<BlurOnRounded sx={{ fontSize: "4em" }} />
<Typography sx={{ fontSize: "1.25em" }}>{text}</Typography>
{extra}
</Box>
);
};
export default BaseEmpty;
@@ -2,9 +2,8 @@ import dayjs from "dayjs";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { styled, ListItem, IconButton, ListItemText } from "@mui/material"; import { styled, ListItem, IconButton, ListItemText } from "@mui/material";
import { CloseRounded } from "@mui/icons-material"; import { CloseRounded } from "@mui/icons-material";
import { ApiType } from "../../services/types"; import { deleteConnection } from "@/services/api";
import { deleteConnection } from "../../services/api"; import parseTraffic from "@/utils/parse-traffic";
import parseTraffic from "../../utils/parse-traffic";
const Tag = styled("span")(({ theme }) => ({ const Tag = styled("span")(({ theme }) => ({
display: "inline-block", display: "inline-block",
+4 -5
View File
@@ -4,13 +4,12 @@ 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 { listen } from "@tauri-apps/api/event"; import { listen } from "@tauri-apps/api/event";
import { ApiType } from "../../services/types"; import { getInformation } from "@/services/api";
import { getInformation } from "../../services/api"; import { getVergeConfig } from "@/services/cmds";
import { getVergeConfig } from "../../services/cmds"; import { atomClashPort } from "@/services/states";
import { atomClashPort } from "../../services/states";
import TrafficGraph from "./traffic-graph"; import TrafficGraph from "./traffic-graph";
import useLogSetup from "./use-log-setup"; import useLogSetup from "./use-log-setup";
import parseTraffic from "../../utils/parse-traffic"; import parseTraffic from "@/utils/parse-traffic";
// setup the traffic // setup the traffic
const LayoutTraffic = () => { const LayoutTraffic = () => {
+8 -4
View File
@@ -2,6 +2,7 @@ import useSWR from "swr";
import snarkdown from "snarkdown"; import snarkdown from "snarkdown";
import { useMemo } from "react"; import { useMemo } from "react";
import { useRecoilState } from "recoil"; import { useRecoilState } from "recoil";
import { useTranslation } from "react-i18next";
import { import {
Box, Box,
Button, Button,
@@ -13,8 +14,8 @@ import {
} from "@mui/material"; } from "@mui/material";
import { relaunch } from "@tauri-apps/api/process"; import { relaunch } from "@tauri-apps/api/process";
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater"; import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
import { killSidecar, restartSidecar } from "../../services/cmds"; import { killSidecar, restartSidecar } from "@/services/cmds";
import { atomUpdateState } from "../../services/states"; import { atomUpdateState } from "@/services/states";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
interface Props { interface Props {
@@ -28,6 +29,7 @@ const UpdateLog = styled(Box)(() => ({
const UpdateDialog = (props: Props) => { const UpdateDialog = (props: Props) => {
const { open, onClose } = props; const { open, onClose } = props;
const { t } = useTranslation();
const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, { const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, {
errorRetryCount: 2, errorRetryCount: 2,
revalidateIfStale: false, revalidateIfStale: false,
@@ -69,14 +71,16 @@ const UpdateDialog = (props: Props) => {
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={onClose}>Cancel</Button> <Button variant="outlined" onClick={onClose}>
{t("Cancel")}
</Button>
<Button <Button
autoFocus autoFocus
variant="contained" variant="contained"
disabled={updateState} disabled={updateState}
onClick={onUpdate} onClick={onUpdate}
> >
Update {t("Update")}
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>
+26 -6
View File
@@ -1,8 +1,11 @@
import useSWR from "swr"; import useSWR from "swr";
import { useMemo } from "react"; import { useEffect, useMemo } from "react";
import { useRecoilState } from "recoil";
import { createTheme } from "@mui/material"; import { createTheme } from "@mui/material";
import { getVergeConfig } from "../../services/cmds"; import { appWindow } from "@tauri-apps/api/window";
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme"; import { getVergeConfig } from "@/services/cmds";
import { atomThemeMode } from "@/services/states";
import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";
/** /**
* custome theme * custome theme
@@ -10,10 +13,27 @@ import { defaultTheme, defaultDarkTheme } from "../../pages/_theme";
export default function useCustomTheme() { export default function useCustomTheme() {
const { data } = useSWR("getVergeConfig", getVergeConfig); const { data } = useSWR("getVergeConfig", getVergeConfig);
const { theme_mode, theme_setting } = data ?? {}; const { theme_mode, theme_setting } = data ?? {};
const [mode, setMode] = useRecoilState(atomThemeMode);
useEffect(() => {
const themeMode = ["light", "dark", "system"].includes(theme_mode!)
? theme_mode!
: "light";
if (themeMode !== "system") {
setMode(themeMode);
return;
}
appWindow.theme().then((m) => m && setMode(m));
const unlisten = appWindow.onThemeChanged((e) => setMode(e.payload));
return () => {
unlisten.then((fn) => fn());
};
}, [theme_mode]);
const theme = useMemo(() => { const theme = useMemo(() => {
const mode = theme_mode ?? "light";
const setting = theme_setting || {}; const setting = theme_setting || {};
const dt = mode === "light" ? defaultTheme : defaultDarkTheme; const dt = mode === "light" ? defaultTheme : defaultDarkTheme;
@@ -78,7 +98,7 @@ export default function useCustomTheme() {
}, 0); }, 0);
return theme; return theme;
}, [theme_mode, theme_setting]); }, [mode, theme_setting]);
return { theme }; return { theme };
} }
+2 -3
View File
@@ -2,9 +2,8 @@ import dayjs from "dayjs";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useSetRecoilState } from "recoil"; import { useSetRecoilState } from "recoil";
import { listen } from "@tauri-apps/api/event"; import { listen } from "@tauri-apps/api/event";
import { ApiType } from "../../services/types"; import { getInformation } from "@/services/api";
import { getInformation } from "../../services/api"; import { atomLogData } from "@/services/states";
import { atomLogData } from "../../services/states";
const MAX_LOG_NUM = 1000; const MAX_LOG_NUM = 1000;
-1
View File
@@ -1,5 +1,4 @@
import { styled, Box } from "@mui/material"; import { styled, Box } from "@mui/material";
import { ApiType } from "../../services/types";
const Item = styled(Box)(({ theme }) => ({ const Item = styled(Box)(({ theme }) => ({
padding: "8px 0", padding: "8px 0",
+22 -116
View File
@@ -1,32 +1,14 @@
import useSWR from "swr"; import useSWR from "swr";
import { useState } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { import { Box, Grid, IconButton, Stack } from "@mui/material";
Box, import { RestartAltRounded } from "@mui/icons-material";
Divider,
Grid,
IconButton,
ListItemIcon,
ListItemText,
Menu,
MenuItem,
Stack,
} from "@mui/material";
import {
AddchartRounded,
CheckRounded,
MenuRounded,
RestartAltRounded,
} from "@mui/icons-material";
import { import {
getProfiles, getProfiles,
deleteProfile, deleteProfile,
enhanceProfiles, enhanceProfiles,
changeProfileChain, changeProfileChain,
changeProfileValid, getRuntimeLogs,
} from "../../services/cmds"; } from "@/services/cmds";
import { CmdType } from "../../services/types";
import getSystem from "../../utils/get-system";
import ProfileMore from "./profile-more"; import ProfileMore from "./profile-more";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
@@ -35,20 +17,20 @@ interface Props {
chain: string[]; chain: string[];
} }
const OS = getSystem();
const EnhancedMode = (props: Props) => { const EnhancedMode = (props: Props) => {
const { items, chain } = props; const { items, chain } = props;
const { data, mutate } = useSWR("getProfiles", getProfiles); const { mutate: mutateProfiles } = useSWR("getProfiles", getProfiles);
const valid = data?.valid || []; const { data: chainLogs = {}, mutate: mutateLogs } = useSWR(
"getRuntimeLogs",
const [anchorEl, setAnchorEl] = useState<any>(null); getRuntimeLogs
);
// handler // handler
const onEnhance = useLockFn(async () => { const onEnhance = useLockFn(async () => {
try { try {
await enhanceProfiles(); await enhanceProfiles();
mutateLogs();
Notice.success("Refresh clash config", 1000); Notice.success("Refresh clash config", 1000);
} catch (err: any) { } catch (err: any) {
Notice.error(err.message || err.toString()); Notice.error(err.message || err.toString());
@@ -60,7 +42,8 @@ const EnhancedMode = (props: Props) => {
const newChain = [...chain, uid]; const newChain = [...chain, uid];
await changeProfileChain(newChain); await changeProfileChain(newChain);
mutate((conf = {}) => ({ ...conf, chain: newChain }), true); mutateProfiles((conf = {}) => ({ ...conf, chain: newChain }), true);
mutateLogs();
}); });
const onEnhanceDisable = useLockFn(async (uid: string) => { const onEnhanceDisable = useLockFn(async (uid: string) => {
@@ -68,14 +51,16 @@ const EnhancedMode = (props: Props) => {
const newChain = chain.filter((i) => i !== uid); const newChain = chain.filter((i) => i !== uid);
await changeProfileChain(newChain); await changeProfileChain(newChain);
mutate((conf = {}) => ({ ...conf, chain: newChain }), true); mutateProfiles((conf = {}) => ({ ...conf, chain: newChain }), true);
mutateLogs();
}); });
const onEnhanceDelete = useLockFn(async (uid: string) => { const onEnhanceDelete = useLockFn(async (uid: string) => {
try { try {
await onEnhanceDisable(uid); await onEnhanceDisable(uid);
await deleteProfile(uid); await deleteProfile(uid);
mutate(); mutateProfiles();
mutateLogs();
} catch (err: any) { } catch (err: any) {
Notice.error(err?.message || err.toString()); Notice.error(err?.message || err.toString());
} }
@@ -86,7 +71,8 @@ const EnhancedMode = (props: Props) => {
const newChain = [uid].concat(chain.filter((i) => i !== uid)); const newChain = [uid].concat(chain.filter((i) => i !== uid));
await changeProfileChain(newChain); await changeProfileChain(newChain);
mutate((conf = {}) => ({ ...conf, chain: newChain }), true); mutateProfiles((conf = {}) => ({ ...conf, chain: newChain }), true);
mutateLogs();
}); });
const onMoveEnd = useLockFn(async (uid: string) => { const onMoveEnd = useLockFn(async (uid: string) => {
@@ -94,24 +80,12 @@ const EnhancedMode = (props: Props) => {
const newChain = chain.filter((i) => i !== uid).concat([uid]); const newChain = chain.filter((i) => i !== uid).concat([uid]);
await changeProfileChain(newChain); await changeProfileChain(newChain);
mutate((conf = {}) => ({ ...conf, chain: newChain }), true); mutateProfiles((conf = {}) => ({ ...conf, chain: newChain }), true);
}); mutateLogs();
// update valid list
const onToggleValid = useLockFn(async (key: string) => {
try {
const newValid = valid.includes(key)
? valid.filter((i) => i !== key)
: valid.concat(key);
await changeProfileValid(newValid);
mutate();
} catch (err: any) {
Notice.error(err.message || err.toString());
}
}); });
return ( return (
<Box sx={{ mt: 4 }}> <Box sx={{ mt: 2 }}>
<Stack <Stack
spacing={1} spacing={1}
direction="row" direction="row"
@@ -127,75 +101,6 @@ const EnhancedMode = (props: Props) => {
> >
<RestartAltRounded /> <RestartAltRounded />
</IconButton> </IconButton>
<IconButton
size="small"
color="inherit"
id="profile-use-button"
title="enable clash fields"
aria-controls={!!anchorEl ? "profile-use-menu" : undefined}
aria-haspopup="true"
aria-expanded={!!anchorEl ? "true" : undefined}
onClick={(e) => setAnchorEl(e.currentTarget)}
>
<MenuRounded />
</IconButton>
<Menu
id="profile-use-menu"
open={!!anchorEl}
anchorEl={anchorEl}
onClose={() => setAnchorEl(null)}
transitionDuration={225}
TransitionProps={
OS === "macos" ? { style: { transitionDuration: "225ms" } } : {}
}
MenuListProps={{
dense: true,
"aria-labelledby": "profile-use-button",
}}
onContextMenu={(e) => {
setAnchorEl(null);
e.preventDefault();
}}
>
<MenuItem>
<ListItemIcon color="inherit">
<AddchartRounded />
</ListItemIcon>
Use Clash Fields
</MenuItem>
<Divider />
{[
"tun",
"dns",
"hosts",
"script",
"profile",
"payload",
"interface-name",
"routing-mark",
].map((key) => {
const has = valid.includes(key);
return (
<MenuItem
key={key}
sx={{ width: 180 }}
onClick={() => onToggleValid(key)}
>
{has && (
<ListItemIcon color="inherit">
<CheckRounded />
</ListItemIcon>
)}
<ListItemText inset={!has}>{key}</ListItemText>
</MenuItem>
);
})}
</Menu>
</Stack> </Stack>
<Grid container spacing={2}> <Grid container spacing={2}>
@@ -205,6 +110,7 @@ const EnhancedMode = (props: Props) => {
selected={!!chain.includes(item.uid)} selected={!!chain.includes(item.uid)}
itemData={item} itemData={item}
enableNum={chain.length} enableNum={chain.length}
logInfo={chainLogs[item.uid]}
onEnable={() => onEnhanceEnable(item.uid)} onEnable={() => onEnhanceEnable(item.uid)}
onDisable={() => onEnhanceDisable(item.uid)} onDisable={() => onEnhanceDisable(item.uid)}
onDelete={() => onEnhanceDelete(item.uid)} onDelete={() => onEnhanceDelete(item.uid)}
+8 -10
View File
@@ -1,6 +1,6 @@
import useSWR from "swr";
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useRecoilValue } from "recoil";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import {
Button, Button,
@@ -9,11 +9,8 @@ import {
DialogContent, DialogContent,
DialogTitle, DialogTitle,
} from "@mui/material"; } from "@mui/material";
import { import { atomThemeMode } from "@/services/states";
getVergeConfig, import { readProfileFile, saveProfileFile } from "@/services/cmds";
readProfileFile,
saveProfileFile,
} from "../../services/cmds";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js"; import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
@@ -35,8 +32,7 @@ const FileEditor = (props: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const editorRef = useRef<any>(); const editorRef = useRef<any>();
const instanceRef = useRef<editor.IStandaloneCodeEditor | null>(null); const instanceRef = useRef<editor.IStandaloneCodeEditor | null>(null);
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig); const themeMode = useRecoilValue(atomThemeMode);
const { theme_mode } = vergeConfig ?? {};
useEffect(() => { useEffect(() => {
if (!open) return; if (!open) return;
@@ -50,7 +46,7 @@ const FileEditor = (props: Props) => {
instanceRef.current = editor.create(editorRef.current, { instanceRef.current = editor.create(editorRef.current, {
value: data, value: data,
language: mode, language: mode,
theme: theme_mode === "light" ? "vs" : "vs-dark", theme: themeMode === "light" ? "vs" : "vs-dark",
minimap: { enabled: false }, minimap: { enabled: false },
}); });
}); });
@@ -86,7 +82,9 @@ const FileEditor = (props: Props) => {
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={onClose}>{t("Cancel")}</Button> <Button onClick={onClose} variant="outlined">
{t("Cancel")}
</Button>
<Button onClick={onSave} variant="contained"> <Button onClick={onSave} variant="contained">
{t("Save")} {t("Save")}
</Button> </Button>
+3 -1
View File
@@ -1,5 +1,6 @@
import { useRef, useState } from "react"; import { useRef, useState } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next";
import { Box, Button, Typography } from "@mui/material"; import { Box, Button, Typography } from "@mui/material";
interface Props { interface Props {
@@ -9,6 +10,7 @@ interface Props {
const FileInput = (props: Props) => { const FileInput = (props: Props) => {
const { onChange } = props; const { onChange } = props;
const { t } = useTranslation();
// file input // file input
const inputRef = useRef<any>(); const inputRef = useRef<any>();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -40,7 +42,7 @@ const FileInput = (props: Props) => {
sx={{ flex: "none" }} sx={{ flex: "none" }}
onClick={() => inputRef.current?.click()} onClick={() => inputRef.current?.click()}
> >
Choose File {t("Choose File")}
</Button> </Button>
<input <input
@@ -12,8 +12,7 @@ import {
TextField, TextField,
} from "@mui/material"; } from "@mui/material";
import { Settings } from "@mui/icons-material"; import { Settings } from "@mui/icons-material";
import { CmdType } from "../../services/types"; import { patchProfile } from "@/services/cmds";
import { patchProfile } from "../../services/cmds";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
interface Props { interface Props {
@@ -24,7 +23,7 @@ interface Props {
// edit the profile item // edit the profile item
// remote / local file / merge / script // remote / local file / merge / script
const ProfileEdit = (props: Props) => { const InfoEditor = (props: Props) => {
const { open, itemData, onClose } = props; const { open, itemData, onClose } = props;
const { t } = useTranslation(); const { t } = useTranslation();
@@ -57,7 +56,6 @@ const ProfileEdit = (props: Props) => {
} }
await patchProfile(uid, { uid, name, desc, url, option: option_ }); await patchProfile(uid, { uid, name, desc, url, option: option_ });
setShowOpt(false);
mutate("getProfiles"); mutate("getProfiles");
onClose(); onClose();
} catch (err: any) { } catch (err: any) {
@@ -134,7 +132,7 @@ const ProfileEdit = (props: Props) => {
value={option.update_interval} value={option.update_interval}
onChange={(e) => { onChange={(e) => {
const str = e.target.value?.replace(/\D/, ""); const str = e.target.value?.replace(/\D/, "");
setOption({ update_interval: str != null ? +str : str }); setOption({ update_interval: !!str ? +str : undefined });
}} }}
onKeyDown={(e) => e.key === "Enter" && onUpdate()} onKeyDown={(e) => e.key === "Enter" && onUpdate()}
/> />
@@ -145,6 +143,7 @@ const ProfileEdit = (props: Props) => {
{form.type === "remote" && ( {form.type === "remote" && (
<IconButton <IconButton
size="small" size="small"
color="inherit"
sx={{ position: "absolute", left: 18 }} sx={{ position: "absolute", left: 18 }}
onClick={() => setShowOpt((o) => !o)} onClick={() => setShowOpt((o) => !o)}
> >
@@ -152,13 +151,15 @@ const ProfileEdit = (props: Props) => {
</IconButton> </IconButton>
)} )}
<Button onClick={onClose}>Cancel</Button> <Button onClick={onClose} variant="outlined">
{t("Cancel")}
</Button>
<Button onClick={onUpdate} variant="contained"> <Button onClick={onUpdate} variant="contained">
Update {t("Save")}
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>
); );
}; };
export default ProfileEdit; export default InfoEditor;
+71
View File
@@ -0,0 +1,71 @@
import { useTranslation } from "react-i18next";
import {
Button,
Chip,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
Divider,
Typography,
} from "@mui/material";
import BaseEmpty from "../base/base-empty";
import { Fragment } from "react";
interface Props {
open: boolean;
logInfo: [string, string][];
onClose: () => void;
}
const LogViewer = (props: Props) => {
const { open, logInfo, onClose } = props;
const { t } = useTranslation();
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>{t("Script Console")}</DialogTitle>
<DialogContent
sx={{
width: 400,
height: 300,
overflowX: "hidden",
userSelect: "text",
pb: 1,
}}
>
{logInfo.map(([level, log], index) => (
<Fragment key={index.toString()}>
<Typography color="text.secondary" component="div">
<Chip
label={level}
size="small"
variant="outlined"
color={
level === "error" || level === "exception"
? "error"
: "default"
}
sx={{ mr: 1 }}
/>
{log}
</Typography>
<Divider sx={{ my: 0.5 }} />
</Fragment>
))}
{logInfo.length === 0 && <BaseEmpty />}
</DialogContent>
<DialogActions>
<Button onClick={onClose} variant="outlined">
{t("Back")}
</Button>
</DialogActions>
</Dialog>
);
};
export default LogViewer;
+43
View File
@@ -0,0 +1,43 @@
import { alpha, Box, styled } from "@mui/material";
const ProfileBox = styled(Box)(({ theme, "aria-selected": selected }) => {
const { mode, primary, text, grey, background } = theme.palette;
const key = `${mode}-${!!selected}`;
const backgroundColor = {
"light-true": alpha(primary.main, 0.2),
"light-false": alpha(background.paper, 0.75),
"dark-true": alpha(primary.main, 0.45),
"dark-false": alpha(grey[700], 0.45),
}[key]!;
const color = {
"light-true": text.secondary,
"light-false": text.secondary,
"dark-true": alpha(text.secondary, 0.85),
"dark-false": alpha(text.secondary, 0.65),
}[key]!;
const h2color = {
"light-true": primary.main,
"light-false": text.primary,
"dark-true": primary.light,
"dark-false": text.primary,
}[key]!;
return {
width: "100%",
display: "block",
cursor: "pointer",
textAlign: "left",
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[2],
padding: "8px 16px",
boxSizing: "border-box",
backgroundColor,
color,
"& h2": { color: h2color },
};
});
export default ProfileBox;
+57 -106
View File
@@ -1,13 +1,11 @@
import dayjs from "dayjs"; import dayjs from "dayjs";
import { mutate } from "swr";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useSWRConfig } from "swr";
import { useRecoilState } from "recoil"; import { useRecoilState } from "recoil";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import {
alpha,
Box, Box,
styled,
Typography, Typography,
LinearProgress, LinearProgress,
IconButton, IconButton,
@@ -16,33 +14,19 @@ import {
Menu, Menu,
} from "@mui/material"; } from "@mui/material";
import { RefreshRounded } from "@mui/icons-material"; import { RefreshRounded } from "@mui/icons-material";
import { CmdType } from "../../services/types"; import { atomLoadingCache } from "@/services/states";
import { atomLoadingCache } from "../../services/states"; import { updateProfile, deleteProfile, viewProfile } from "@/services/cmds";
import { updateProfile, deleteProfile, viewProfile } from "../../services/cmds"; import parseTraffic from "@/utils/parse-traffic";
import parseTraffic from "../../utils/parse-traffic"; import ProfileBox from "./profile-box";
import getSystem from "../../utils/get-system"; import InfoEditor from "./info-editor";
import ProfileEdit from "./profile-edit";
import FileEditor from "./file-editor"; import FileEditor from "./file-editor";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
const Wrapper = styled(Box)(({ theme }) => ({
width: "100%",
display: "block",
cursor: "pointer",
textAlign: "left",
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[2],
padding: "8px 16px",
boxSizing: "border-box",
}));
const round = keyframes` const round = keyframes`
from { transform: rotate(0deg); } from { transform: rotate(0deg); }
to { transform: rotate(360deg); } to { transform: rotate(360deg); }
`; `;
const OS = getSystem();
interface Props { interface Props {
selected: boolean; selected: boolean;
itemData: CmdType.ProfileItem; itemData: CmdType.ProfileItem;
@@ -53,7 +37,6 @@ const ProfileItem = (props: Props) => {
const { selected, itemData, onSelect } = props; const { selected, itemData, onSelect } = props;
const { t } = useTranslation(); const { t } = useTranslation();
const { mutate } = useSWRConfig();
const [anchorEl, setAnchorEl] = useState<any>(null); const [anchorEl, setAnchorEl] = useState<any>(null);
const [position, setPosition] = useState({ left: 0, top: 0 }); const [position, setPosition] = useState({ left: 0, top: 0 });
const [loadingCache, setLoadingCache] = useRecoilState(atomLoadingCache); const [loadingCache, setLoadingCache] = useRecoilState(atomLoadingCache);
@@ -62,7 +45,6 @@ const ProfileItem = (props: Props) => {
// local file mode // local file mode
// remote file mode // remote file mode
// subscription url mode
const hasUrl = !!itemData.url; const hasUrl = !!itemData.url;
const hasExtra = !!extra; // only subscription url has extra info const hasExtra = !!extra; // only subscription url has extra info
@@ -83,7 +65,6 @@ const ProfileItem = (props: Props) => {
const handler = () => { const handler = () => {
const now = Date.now(); const now = Date.now();
const lastUpdate = updated * 1000; const lastUpdate = updated * 1000;
// 大于一天的不管 // 大于一天的不管
if (now - lastUpdate >= 24 * 36e5) return; if (now - lastUpdate >= 24 * 36e5) return;
@@ -156,13 +137,6 @@ const ProfileItem = (props: Props) => {
} }
}); });
const boxStyle = {
height: 26,
display: "flex",
alignItems: "center",
justifyContent: "space-between",
};
const urlModeMenu = [ const urlModeMenu = [
{ label: "Select", handler: onForceSelect }, { label: "Select", handler: onForceSelect },
{ label: "Edit Info", handler: onEditInfo }, { label: "Edit Info", handler: onEditInfo },
@@ -180,36 +154,17 @@ const ProfileItem = (props: Props) => {
{ label: "Delete", handler: onDelete }, { label: "Delete", handler: onDelete },
]; ];
const boxStyle = {
height: 26,
display: "flex",
alignItems: "center",
justifyContent: "space-between",
};
return ( return (
<> <>
<Wrapper <ProfileBox
sx={({ palette }) => { aria-selected={selected}
const { mode, primary, text, grey } = palette;
const key = `${mode}-${selected}`;
const bgcolor = {
"light-true": alpha(primary.main, 0.15),
"light-false": palette.background.paper,
"dark-true": alpha(primary.main, 0.35),
"dark-false": alpha(grey[700], 0.35),
}[key]!;
const color = {
"light-true": text.secondary,
"light-false": text.secondary,
"dark-true": alpha(text.secondary, 0.75),
"dark-false": alpha(text.secondary, 0.75),
}[key]!;
const h2color = {
"light-true": primary.main,
"light-false": text.primary,
"dark-true": primary.light,
"dark-false": text.primary,
}[key]!;
return { bgcolor, color, "& h2": { color: h2color } };
}}
onClick={() => onSelect(false)} onClick={() => onSelect(false)}
onContextMenu={(event) => { onContextMenu={(event) => {
const { clientX, clientY } = event; const { clientX, clientY } = event;
@@ -218,9 +173,9 @@ const ProfileItem = (props: Props) => {
event.preventDefault(); event.preventDefault();
}} }}
> >
<Box display="flex" justifyContent="space-between"> <Box position="relative">
<Typography <Typography
width="calc(100% - 40px)" width="calc(100% - 36px)"
variant="h6" variant="h6"
component="h2" component="h2"
noWrap noWrap
@@ -233,10 +188,13 @@ const ProfileItem = (props: Props) => {
{hasUrl && ( {hasUrl && (
<IconButton <IconButton
sx={{ sx={{
width: 26, position: "absolute",
height: 26, p: "3px",
top: -1,
right: -5,
animation: loading ? `1s linear infinite ${round}` : "none", animation: loading ? `1s linear infinite ${round}` : "none",
}} }}
size="small"
color="inherit" color="inherit"
disabled={loading} disabled={loading}
onClick={(e) => { onClick={(e) => {
@@ -244,47 +202,47 @@ const ProfileItem = (props: Props) => {
onUpdate(false); onUpdate(false);
}} }}
> >
<RefreshRounded /> <RefreshRounded color="inherit" />
</IconButton> </IconButton>
)} )}
</Box> </Box>
{/* the second line show url's info or description */} {/* the second line show url's info or description */}
{hasUrl ? ( <Box sx={boxStyle}>
<Box sx={boxStyle}> {hasUrl ? (
<Typography noWrap title={`From: ${from}`}> <>
{from} <Typography noWrap title={`From: ${from}`}>
</Typography> {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: ${parseExpire(updated)}`}
> >
{updated > 0 ? dayjs(updated * 1000).fromNow() : ""} {updated > 0 ? dayjs(updated * 1000).fromNow() : ""}
</Typography> </Typography>
</Box> </>
) : ( ) : (
<Box sx={boxStyle}>
<Typography noWrap title={itemData.desc}> <Typography noWrap title={itemData.desc}>
{itemData.desc} {itemData.desc}
</Typography> </Typography>
</Box> )}
)} </Box>
{/* the third line show extra info or last updated time */} {/* the third line show extra info or last updated time */}
{hasExtra ? ( {hasExtra ? (
<Box sx={{ ...boxStyle, fontSize: 14 }}> <Box sx={{ ...boxStyle, fontSize: 14 }}>
<span title="used / total"> <span title="Used / Total">
{parseTraffic(upload + download)} / {parseTraffic(total)} {parseTraffic(upload + download)} / {parseTraffic(total)}
</span> </span>
<span title="expire time">{expire}</span> <span title="Expire Time">{expire}</span>
</Box> </Box>
) : ( ) : (
<Box sx={{ ...boxStyle, fontSize: 14, justifyContent: "flex-end" }}> <Box sx={{ ...boxStyle, fontSize: 14, justifyContent: "flex-end" }}>
<span title="updated time">{parseExpire(updated)}</span> <span title="Updated Time">{parseExpire(updated)}</span>
</Box> </Box>
)} )}
@@ -293,7 +251,7 @@ const ProfileItem = (props: Props) => {
value={progress} value={progress}
color="inherit" color="inherit"
/> />
</Wrapper> </ProfileBox>
<Menu <Menu
open={!!anchorEl} open={!!anchorEl}
@@ -302,9 +260,6 @@ const ProfileItem = (props: Props) => {
anchorPosition={position} anchorPosition={position}
anchorReference="anchorPosition" anchorReference="anchorPosition"
transitionDuration={225} transitionDuration={225}
TransitionProps={
OS === "macos" ? { style: { transitionDuration: "225ms" } } : {}
}
onContextMenu={(e) => { onContextMenu={(e) => {
setAnchorEl(null); setAnchorEl(null);
e.preventDefault(); e.preventDefault();
@@ -321,22 +276,18 @@ const ProfileItem = (props: Props) => {
))} ))}
</Menu> </Menu>
{editOpen && ( <InfoEditor
<ProfileEdit open={editOpen}
open={editOpen} itemData={itemData}
itemData={itemData} onClose={() => setEditOpen(false)}
onClose={() => setEditOpen(false)} />
/>
)}
{fileOpen && ( <FileEditor
<FileEditor uid={uid}
uid={uid} open={fileOpen}
open={fileOpen} mode="yaml"
mode="yaml" onClose={() => setFileOpen(false)}
onClose={() => setFileOpen(false)} />
/>
)}
</> </>
); );
}; };
+67 -92
View File
@@ -1,41 +1,29 @@
import dayjs from "dayjs"; import dayjs from "dayjs";
import { useEffect, useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { import {
alpha,
Box, Box,
Badge,
Chip, Chip,
styled,
Typography, Typography,
MenuItem, MenuItem,
Menu, Menu,
IconButton,
} from "@mui/material"; } from "@mui/material";
import { CmdType } from "../../services/types"; import { FeaturedPlayListRounded } from "@mui/icons-material";
import { viewProfile } from "../../services/cmds"; import { viewProfile } from "@/services/cmds";
import getSystem from "../../utils/get-system"; import InfoEditor from "./info-editor";
import enhance from "../../services/enhance";
import ProfileEdit from "./profile-edit";
import FileEditor from "./file-editor"; import FileEditor from "./file-editor";
import ProfileBox from "./profile-box";
import LogViewer from "./log-viewer";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
const Wrapper = styled(Box)(({ theme }) => ({
width: "100%",
display: "block",
cursor: "pointer",
textAlign: "left",
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[2],
padding: "8px 16px",
boxSizing: "border-box",
}));
const OS = getSystem();
interface Props { interface Props {
selected: boolean; selected: boolean;
itemData: CmdType.ProfileItem; itemData: CmdType.ProfileItem;
enableNum: number; enableNum: number;
logInfo?: [string, string][];
onEnable: () => void; onEnable: () => void;
onDisable: () => void; onDisable: () => void;
onMoveTop: () => void; onMoveTop: () => void;
@@ -49,6 +37,7 @@ const ProfileMore = (props: Props) => {
selected, selected,
itemData, itemData,
enableNum, enableNum,
logInfo = [],
onEnable, onEnable,
onDisable, onDisable,
onMoveTop, onMoveTop,
@@ -58,18 +47,11 @@ const ProfileMore = (props: Props) => {
const { uid, type } = itemData; const { uid, type } = itemData;
const { t } = useTranslation(); const { t } = useTranslation();
const [anchorEl, setAnchorEl] = useState<any>(null); const [anchorEl, setAnchorEl] = useState<any>(null);
const [position, setPosition] = useState({ left: 0, top: 0 }); const [position, setPosition] = useState({ left: 0, top: 0 });
const [editOpen, setEditOpen] = useState(false); const [editOpen, setEditOpen] = useState(false);
const [fileOpen, setFileOpen] = useState(false); const [fileOpen, setFileOpen] = useState(false);
const [status, setStatus] = useState(enhance.status(uid)); const [logOpen, setLogOpen] = useState(false);
// unlisten when unmount
useEffect(() => enhance.listen(uid, setStatus), [uid]);
// error during enhanced mode
const hasError = selected && status?.status === "error";
const onEditInfo = () => { const onEditInfo = () => {
setAnchorEl(null); setAnchorEl(null);
@@ -95,6 +77,7 @@ const ProfileMore = (props: Props) => {
return fn(); return fn();
}; };
const hasError = !!logInfo.find((e) => e[0] === "exception");
const showMove = enableNum > 1 && !hasError; const showMove = enableNum > 1 && !hasError;
const enableMenu = [ const enableMenu = [
@@ -125,39 +108,8 @@ const ProfileMore = (props: Props) => {
return ( return (
<> <>
<Wrapper <ProfileBox
sx={({ palette }) => { aria-selected={selected}
// todo
// 区分 selected 和 error 和 mode 下各种颜色的排列组合
const { mode, primary, text, grey, error } = palette;
const key = `${mode}-${selected}`;
const bgkey = hasError ? `${mode}-err` : key;
const bgcolor = {
"light-true": alpha(primary.main, 0.15),
"light-false": palette.background.paper,
"dark-true": alpha(primary.main, 0.35),
"dark-false": alpha(grey[700], 0.35),
"light-err": alpha(error.main, 0.12),
"dark-err": alpha(error.main, 0.3),
}[bgkey]!;
const color = {
"light-true": text.secondary,
"light-false": text.secondary,
"dark-true": alpha(text.secondary, 0.6),
"dark-false": alpha(text.secondary, 0.6),
}[key]!;
const h2color = {
"light-true": primary.main,
"light-false": text.primary,
"dark-true": primary.light,
"dark-false": text.primary,
}[key]!;
return { bgcolor, color, "& h2": { color: h2color } };
}}
// onClick={() => onSelect(false)} // onClick={() => onSelect(false)}
onContextMenu={(event) => { onContextMenu={(event) => {
const { clientX, clientY } = event; const { clientX, clientY } = event;
@@ -166,7 +118,12 @@ const ProfileMore = (props: Props) => {
event.preventDefault(); event.preventDefault();
}} }}
> >
<Box display="flex" justifyContent="space-between" alignItems="center"> <Box
display="flex"
justifyContent="space-between"
alignItems="center"
mb={0.5}
>
<Typography <Typography
width="calc(100% - 52px)" width="calc(100% - 52px)"
variant="h6" variant="h6"
@@ -182,20 +139,35 @@ const ProfileMore = (props: Props) => {
color="primary" color="primary"
size="small" size="small"
variant="outlined" variant="outlined"
sx={{ textTransform: "capitalize" }} sx={{ height: 20, textTransform: "capitalize" }}
/> />
</Box> </Box>
<Box sx={boxStyle}> <Box sx={boxStyle}>
{hasError ? ( {selected ? (
<Typography hasError ? (
noWrap <Badge color="error" variant="dot" overlap="circular">
color="error" <IconButton
sx={{ width: "calc(100% - 75px)" }} size="small"
title={status.message} edge="start"
> color="error"
{status.message} title="Console"
</Typography> onClick={() => setLogOpen(true)}
>
<FeaturedPlayListRounded fontSize="inherit" />
</IconButton>
</Badge>
) : (
<IconButton
size="small"
edge="start"
color="inherit"
title="Console"
onClick={() => setLogOpen(true)}
>
<FeaturedPlayListRounded fontSize="inherit" />
</IconButton>
)
) : ( ) : (
<Typography <Typography
noWrap noWrap
@@ -208,13 +180,15 @@ const ProfileMore = (props: Props) => {
<Typography <Typography
component="span" component="span"
title="updated time" title={`Updated Time: ${parseExpire(itemData.updated)}`}
style={{ fontSize: 14 }} style={{ fontSize: 14 }}
> >
{parseExpire(itemData.updated)} {!!itemData.updated
? dayjs(itemData.updated! * 1000).fromNow()
: ""}
</Typography> </Typography>
</Box> </Box>
</Wrapper> </ProfileBox>
<Menu <Menu
open={!!anchorEl} open={!!anchorEl}
@@ -223,9 +197,6 @@ const ProfileMore = (props: Props) => {
anchorPosition={position} anchorPosition={position}
anchorReference="anchorPosition" anchorReference="anchorPosition"
transitionDuration={225} transitionDuration={225}
TransitionProps={
OS === "macos" ? { style: { transitionDuration: "225ms" } } : {}
}
onContextMenu={(e) => { onContextMenu={(e) => {
setAnchorEl(null); setAnchorEl(null);
e.preventDefault(); e.preventDefault();
@@ -244,20 +215,24 @@ const ProfileMore = (props: Props) => {
))} ))}
</Menu> </Menu>
{editOpen && ( <InfoEditor
<ProfileEdit open={editOpen}
open={editOpen} itemData={itemData}
itemData={itemData} onClose={() => setEditOpen(false)}
onClose={() => setEditOpen(false)} />
/>
)}
{fileOpen && ( <FileEditor
<FileEditor uid={uid}
uid={uid} open={fileOpen}
open={fileOpen} mode={type === "merge" ? "yaml" : "javascript"}
mode={type === "merge" ? "yaml" : "javascript"} onClose={() => setFileOpen(false)}
onClose={() => setFileOpen(false)} />
{selected && (
<LogViewer
open={logOpen}
logInfo={logInfo}
onClose={() => setLogOpen(false)}
/> />
)} )}
</> </>
+11 -7
View File
@@ -1,5 +1,6 @@
import { useRef, useState } from "react"; import { useRef, useState } from "react";
import { useSWRConfig } from "swr"; import { mutate } from "swr";
import { useTranslation } from "react-i18next";
import { useLockFn, useSetState } from "ahooks"; import { useLockFn, useSetState } from "ahooks";
import { import {
Button, Button,
@@ -15,7 +16,7 @@ import {
TextField, TextField,
} from "@mui/material"; } from "@mui/material";
import { Settings } from "@mui/icons-material"; import { Settings } from "@mui/icons-material";
import { createProfile } from "../../services/cmds"; import { createProfile } from "@/services/cmds";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
import FileInput from "./file-input"; import FileInput from "./file-input";
@@ -29,7 +30,7 @@ interface Props {
const ProfileNew = (props: Props) => { const ProfileNew = (props: Props) => {
const { open, onClose } = props; const { open, onClose } = props;
const { mutate } = useSWRConfig(); const { t } = useTranslation();
const [form, setForm] = useSetState({ const [form, setForm] = useSetState({
type: "remote", type: "remote",
name: "", name: "",
@@ -83,7 +84,7 @@ const ProfileNew = (props: Props) => {
return ( return (
<Dialog open={open} onClose={onClose}> <Dialog open={open} onClose={onClose}>
<DialogTitle sx={{ pb: 0.5 }}>Create Profile</DialogTitle> <DialogTitle sx={{ pb: 0.5 }}>{t("Create Profile")}</DialogTitle>
<DialogContent sx={{ width: 336, pb: 1 }}> <DialogContent sx={{ width: 336, pb: 1 }}>
<FormControl size="small" fullWidth sx={{ mt: 2, mb: 1 }}> <FormControl size="small" fullWidth sx={{ mt: 2, mb: 1 }}>
@@ -120,7 +121,7 @@ const ProfileNew = (props: Props) => {
{form.type === "remote" && ( {form.type === "remote" && (
<TextField <TextField
{...textFieldProps} {...textFieldProps}
label="Subscription Url" label="Subscription URL"
autoComplete="off" autoComplete="off"
value={form.url} value={form.url}
onChange={(e) => setForm({ url: e.target.value })} onChange={(e) => setForm({ url: e.target.value })}
@@ -146,6 +147,7 @@ const ProfileNew = (props: Props) => {
{form.type === "remote" && ( {form.type === "remote" && (
<IconButton <IconButton
size="small" size="small"
color="inherit"
sx={{ position: "absolute", left: 18 }} sx={{ position: "absolute", left: 18 }}
onClick={() => setShowOpt((o) => !o)} onClick={() => setShowOpt((o) => !o)}
> >
@@ -153,9 +155,11 @@ const ProfileNew = (props: Props) => {
</IconButton> </IconButton>
)} )}
<Button onClick={onClose}>Cancel</Button> <Button onClick={onClose} variant="outlined">
{t("Cancel")}
</Button>
<Button onClick={onCreate} variant="contained"> <Button onClick={onCreate} variant="contained">
Create {t("Save")}
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>
+3 -4
View File
@@ -2,13 +2,12 @@ import useSWR, { useSWRConfig } from "swr";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { Virtuoso } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso";
import { ApiType } from "../../services/types"; import { updateProxy } from "@/services/api";
import { updateProxy } from "../../services/api"; import { getProfiles, patchProfile } from "@/services/cmds";
import { getProfiles, patchProfile } from "../../services/cmds"; import delayManager from "@/services/delay";
import useSortProxy from "./use-sort-proxy"; import useSortProxy from "./use-sort-proxy";
import useHeadState from "./use-head-state"; import useHeadState from "./use-head-state";
import useFilterProxy from "./use-filter-proxy"; import useFilterProxy from "./use-filter-proxy";
import delayManager from "../../services/delay";
import ProxyHead from "./proxy-head"; import ProxyHead from "./proxy-head";
import ProxyItem from "./proxy-item"; import ProxyItem from "./proxy-item";
+3 -4
View File
@@ -15,13 +15,12 @@ import {
ExpandLessRounded, ExpandLessRounded,
ExpandMoreRounded, ExpandMoreRounded,
} from "@mui/icons-material"; } from "@mui/icons-material";
import { ApiType } from "../../services/types"; import { updateProxy } from "@/services/api";
import { updateProxy } from "../../services/api"; import { getProfiles, patchProfile } from "@/services/cmds";
import { getProfiles, patchProfile } from "../../services/cmds"; import delayManager from "@/services/delay";
import useSortProxy from "./use-sort-proxy"; import useSortProxy from "./use-sort-proxy";
import useHeadState from "./use-head-state"; import useHeadState from "./use-head-state";
import useFilterProxy from "./use-filter-proxy"; import useFilterProxy from "./use-filter-proxy";
import delayManager from "../../services/delay";
import ProxyHead from "./proxy-head"; import ProxyHead from "./proxy-head";
import ProxyItem from "./proxy-item"; import ProxyItem from "./proxy-item";
+1 -1
View File
@@ -13,7 +13,7 @@ import {
SortByAlphaRounded, SortByAlphaRounded,
SortRounded, SortRounded,
} from "@mui/icons-material"; } from "@mui/icons-material";
import delayManager from "../../services/delay"; import delayManager from "@/services/delay";
import type { HeadState } from "./use-head-state"; import type { HeadState } from "./use-head-state";
import type { ProxySortType } from "./use-sort-proxy"; import type { ProxySortType } from "./use-sort-proxy";
+1 -2
View File
@@ -12,8 +12,7 @@ import {
SxProps, SxProps,
Theme, Theme,
} from "@mui/material"; } from "@mui/material";
import { ApiType } from "../../services/types"; import delayManager from "@/services/delay";
import delayManager from "../../services/delay";
interface Props { interface Props {
groupName: string; groupName: string;
+1 -2
View File
@@ -1,6 +1,5 @@
import { useMemo } from "react"; import { useMemo } from "react";
import { ApiType } from "../../services/types"; import delayManager from "@/services/delay";
import delayManager from "../../services/delay";
const regex1 = /delay([=<>])(\d+|timeout|error)/i; const regex1 = /delay([=<>])(\d+|timeout|error)/i;
const regex2 = /type=(.*)/i; const regex2 = /type=(.*)/i;
+1 -1
View File
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { useRecoilValue } from "recoil"; import { useRecoilValue } from "recoil";
import { atomCurrentProfile } from "../../services/states"; import { atomCurrentProfile } from "@/services/states";
import { ProxySortType } from "./use-sort-proxy"; import { ProxySortType } from "./use-sort-proxy";
export interface HeadState { export interface HeadState {
+1 -2
View File
@@ -1,6 +1,5 @@
import { useMemo } from "react"; import { useMemo } from "react";
import { ApiType } from "../../services/types"; import delayManager from "@/services/delay";
import delayManager from "../../services/delay";
// default | delay | alpha // default | delay | alpha
export type ProxySortType = 0 | 1 | 2; export type ProxySortType = 0 | 1 | 2;
@@ -0,0 +1,168 @@
import useSWR from "swr";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import {
Button,
Checkbox,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
Divider,
Stack,
Tooltip,
Typography,
} from "@mui/material";
import { InfoRounded } from "@mui/icons-material";
import {
changeProfileValid,
getProfiles,
getRuntimeExists,
} from "@/services/cmds";
import { ModalHandler } from "@/hooks/use-modal-handler";
import {
HANDLE_FIELDS,
DEFAULT_FIELDS,
OTHERS_FIELDS,
} from "@/utils/clash-fields";
import Notice from "@/components/base/base-notice";
interface Props {
handler: ModalHandler;
}
const fieldSorter = (a: string, b: string) => {
if (a.includes("-") === a.includes("-")) {
if (a.length === b.length) return a.localeCompare(b);
return a.length - b.length;
} else if (a.includes("-")) return 1;
else if (b.includes("-")) return -1;
return 0;
};
const otherFields = [...OTHERS_FIELDS].sort(fieldSorter);
const handleFields = [...HANDLE_FIELDS, ...DEFAULT_FIELDS].sort(fieldSorter);
const ClashFieldViewer = ({ handler }: Props) => {
const { t } = useTranslation();
const { data: profiles = {}, mutate: mutateProfile } = useSWR(
"getProfiles",
getProfiles
);
const { data: existsKeys = [], mutate: mutateExists } = useSWR(
"getRuntimeExists",
getRuntimeExists
);
const [open, setOpen] = useState(false);
const [selected, setSelected] = useState<string[]>([]);
if (handler) {
handler.current = {
open: () => setOpen(true),
close: () => setOpen(false),
};
}
useEffect(() => {
if (open) {
mutateProfile();
mutateExists();
setSelected(profiles.valid || []);
}
}, [open, profiles.valid]);
const handleChange = (item: string) => {
if (!item) return;
setSelected((old) =>
old.includes(item) ? old.filter((e) => e !== item) : [...old, item]
);
};
const handleSave = async () => {
setOpen(false);
const oldSet = new Set(profiles.valid || []);
const curSet = new Set(selected);
const joinSet = new Set(selected.concat([...oldSet]));
if (curSet.size === oldSet.size && curSet.size === joinSet.size) return;
try {
await changeProfileValid([...curSet]);
mutateProfile();
Notice.success("Refresh clash config", 1000);
} catch (err: any) {
Notice.error(err?.message || err.toString());
}
};
return (
<Dialog open={open} onClose={() => setOpen(false)}>
<DialogTitle>{t("Clash Field")}</DialogTitle>
<DialogContent
sx={{
pb: 0,
width: 320,
height: 300,
overflowY: "auto",
userSelect: "text",
}}
>
{otherFields.map((item) => {
const inSelect = selected.includes(item);
const inConfig = existsKeys.includes(item);
return (
<Stack key={item} mb={0.5} direction="row" alignItems="center">
<Checkbox
checked={inSelect}
size="small"
sx={{ p: 0.5 }}
onChange={() => handleChange(item)}
/>
<Typography width="100%">{item}</Typography>
{!inSelect && inConfig && <WarnIcon />}
</Stack>
);
})}
<Divider sx={{ my: 1 }}>
<Typography color="text.secondary" fontSize={14}>
Clash Verge Control Fields
</Typography>
</Divider>
{handleFields.map((item) => (
<Stack key={item} mb={0.5} direction="row" alignItems="center">
<Checkbox defaultChecked disabled size="small" sx={{ p: 0.5 }} />
<Typography>{item}</Typography>
</Stack>
))}
</DialogContent>
<DialogActions>
<Button variant="outlined" onClick={() => setOpen(false)}>
{t("Back")}
</Button>
<Button variant="contained" onClick={handleSave}>
{t("Save")}
</Button>
</DialogActions>
</Dialog>
);
};
function WarnIcon() {
return (
<Tooltip title="The field exists in the config but not enabled.">
<InfoRounded color="warning" sx={{ cursor: "pointer", opacity: 0.5 }} />
</Tooltip>
);
}
export default ClashFieldViewer;
@@ -0,0 +1,78 @@
import { useEffect, useRef } from "react";
import { useTranslation } from "react-i18next";
import { useRecoilValue } from "recoil";
import {
Button,
Chip,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
} from "@mui/material";
import { atomThemeMode } from "@/services/states";
import { getRuntimeYaml } from "@/services/cmds";
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
import "monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js";
import "monaco-editor/esm/vs/editor/contrib/folding/browser/folding.js";
import { editor } from "monaco-editor/esm/vs/editor/editor.api";
interface Props {
open: boolean;
onClose: () => void;
}
const ConfigViewer = (props: Props) => {
const { open, onClose } = props;
const { t } = useTranslation();
const editorRef = useRef<any>();
const instanceRef = useRef<editor.IStandaloneCodeEditor | null>(null);
const themeMode = useRecoilValue(atomThemeMode);
useEffect(() => {
if (!open) return;
getRuntimeYaml().then((data) => {
const dom = editorRef.current;
if (!dom) return;
if (instanceRef.current) instanceRef.current.dispose();
instanceRef.current = editor.create(editorRef.current, {
value: data ?? "# Error\n",
language: "yaml",
theme: themeMode === "light" ? "vs" : "vs-dark",
minimap: { enabled: false },
readOnly: true,
});
});
return () => {
if (instanceRef.current) {
instanceRef.current.dispose();
instanceRef.current = null;
}
};
}, [open]);
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>
{t("Runtime Config")} <Chip label={t("ReadOnly")} size="small" />
</DialogTitle>
<DialogContent sx={{ width: 520, pb: 1 }}>
<div style={{ width: "100%", height: "420px" }} ref={editorRef} />
</DialogContent>
<DialogActions>
<Button variant="outlined" onClick={onClose}>
{t("Back")}
</Button>
</DialogActions>
</Dialog>
);
};
export default ConfigViewer;
@@ -3,11 +3,9 @@ import { useState } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { Menu, MenuItem } from "@mui/material"; import { Menu, MenuItem } from "@mui/material";
import { Settings } from "@mui/icons-material"; import { Settings } from "@mui/icons-material";
import { changeClashCore, getVergeConfig } from "../../services/cmds"; import { changeClashCore, getVergeConfig } from "@/services/cmds";
import getSystem from "../../utils/get-system"; import { getVersion } from "@/services/api";
import Notice from "../base/base-notice"; import Notice from "@/components/base/base-notice";
const OS = getSystem();
const VALID_CORE = [ const VALID_CORE = [
{ name: "Clash", core: "clash" }, { name: "Clash", core: "clash" },
@@ -31,7 +29,7 @@ const CoreSwitch = () => {
await changeClashCore(core); await changeClashCore(core);
mutate("getVergeConfig"); mutate("getVergeConfig");
mutate("getClashConfig"); mutate("getClashConfig");
mutate("getVersion"); mutate("getVersion", getVersion());
setAnchorEl(null); setAnchorEl(null);
Notice.success(`Successfully switch to ${core}`, 1000); Notice.success(`Successfully switch to ${core}`, 1000);
} catch (err: any) { } catch (err: any) {
@@ -43,7 +41,7 @@ const CoreSwitch = () => {
<> <>
<Settings <Settings
fontSize="small" fontSize="small"
style={{ cursor: "pointer" }} style={{ cursor: "pointer", opacity: 0.75 }}
onClick={(event) => { onClick={(event) => {
const { clientX, clientY } = event; const { clientX, clientY } = event;
setPosition({ top: clientY, left: clientX }); setPosition({ top: clientY, left: clientX });
@@ -58,9 +56,6 @@ const CoreSwitch = () => {
anchorPosition={position} anchorPosition={position}
anchorReference="anchorPosition" anchorReference="anchorPosition"
transitionDuration={225} transitionDuration={225}
TransitionProps={
OS === "macos" ? { style: { transitionDuration: "225ms" } } : {}
}
onContextMenu={(e) => { onContextMenu={(e) => {
setAnchorEl(null); setAnchorEl(null);
e.preventDefault(); e.preventDefault();
@@ -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;
@@ -14,9 +14,9 @@ import {
installService, installService,
uninstallService, uninstallService,
patchVergeConfig, patchVergeConfig,
} from "../../services/cmds"; } from "@/services/cmds";
import Notice from "../base/base-notice"; import Notice from "@/components/base/base-notice";
import noop from "../../utils/noop"; import noop from "@/utils/noop";
interface Props { interface Props {
open: boolean; open: boolean;
@@ -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);
@@ -43,7 +43,11 @@ const SysproxyTooltip = () => {
title={showTitle} title={showTitle}
arrow arrow
> >
<InfoRounded fontSize="small" onClick={onShow} /> <InfoRounded
fontSize="small"
style={{ cursor: "pointer", opacity: 0.75 }}
onClick={onShow}
/>
</Tooltip> </Tooltip>
</ClickAwayListener> </ClickAwayListener>
); );
@@ -0,0 +1,33 @@
import { useTranslation } from "react-i18next";
import { Button, ButtonGroup } from "@mui/material";
type ThemeValue = CmdType.VergeConfig["theme_mode"];
interface Props {
value?: ThemeValue;
onChange?: (value: ThemeValue) => void;
}
const ThemeModeSwitch = (props: Props) => {
const { value, onChange } = props;
const { t } = useTranslation();
const modes = ["light", "dark", "system"] as const;
return (
<ButtonGroup size="small" sx={{ my: "4px" }}>
{modes.map((mode) => (
<Button
key={mode}
variant={mode === value ? "contained" : "outlined"}
onClick={() => onChange?.(mode)}
sx={{ textTransform: "capitalize" }}
>
{t(`theme.${mode}`)}
</Button>
))}
</ButtonGroup>
);
};
export default ThemeModeSwitch;
+132
View File
@@ -0,0 +1,132 @@
import { useState } from "react";
import {
Divider,
IconButton,
Stack,
TextField,
Typography,
} from "@mui/material";
import {
CheckRounded,
CloseRounded,
DeleteRounded,
EditRounded,
OpenInNewRounded,
} from "@mui/icons-material";
interface Props {
value?: string;
onlyEdit?: boolean;
onChange: (value?: string) => void;
onOpenUrl?: (value?: string) => void;
onDelete?: () => void;
onCancel?: () => void;
}
const WebUIItem = (props: Props) => {
const {
value,
onlyEdit = false,
onChange,
onDelete,
onOpenUrl,
onCancel,
} = props;
const [editing, setEditing] = useState(false);
const [editValue, setEditValue] = useState(value);
if (editing || onlyEdit) {
return (
<>
<Stack spacing={0.75} direction="row" mt={1} mb={1} alignItems="center">
<TextField
fullWidth
size="small"
value={editValue}
onChange={(e) => setEditValue(e.target.value)}
placeholder={`Support %host %port %secret`}
autoComplete="off"
/>
<IconButton
size="small"
title="Save"
color="inherit"
onClick={() => {
onChange(editValue);
setEditing(false);
}}
>
<CheckRounded fontSize="inherit" />
</IconButton>
<IconButton
size="small"
title="Cancel"
color="inherit"
onClick={() => {
onCancel?.();
setEditing(false);
}}
>
<CloseRounded fontSize="inherit" />
</IconButton>
</Stack>
<Divider />
</>
);
}
const html = value
?.replace("%host", "<span>%host</span>")
.replace("%port", "<span>%port</span>")
.replace("%secret", "<span>%secret</span>");
return (
<>
<Stack spacing={0.75} direction="row" alignItems="center" mt={1} mb={1}>
<Typography
component="div"
width="100%"
title={value}
color={value ? "text.primary" : "text.secondary"}
sx={({ palette }) => ({
"> span": {
color: palette.primary.main,
},
})}
dangerouslySetInnerHTML={{ __html: html || "NULL" }}
/>
<IconButton
size="small"
title="Open URL"
color="inherit"
onClick={() => onOpenUrl?.(value)}
>
<OpenInNewRounded fontSize="inherit" />
</IconButton>
<IconButton
size="small"
title="Edit"
color="inherit"
onClick={() => {
setEditing(true);
setEditValue(value);
}}
>
<EditRounded fontSize="inherit" />
</IconButton>
<IconButton
size="small"
title="Delete"
color="inherit"
onClick={onDelete}
>
<DeleteRounded fontSize="inherit" />
</IconButton>
</Stack>
<Divider />
</>
);
};
export default WebUIItem;
@@ -0,0 +1,165 @@
import useSWR from "swr";
import { useState } from "react";
import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next";
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
Typography,
} from "@mui/material";
import {
getClashInfo,
getVergeConfig,
openWebUrl,
patchVergeConfig,
} from "@/services/cmds";
import { ModalHandler } from "@/hooks/use-modal-handler";
import BaseEmpty from "@/components/base/base-empty";
import WebUIItem from "./web-ui-item";
interface Props {
handler: ModalHandler;
onError: (err: Error) => void;
}
const WebUIViewer = ({ handler, onError }: Props) => {
const { t } = useTranslation();
const { data: vergeConfig, mutate: mutateVerge } = useSWR(
"getVergeConfig",
getVergeConfig
);
const webUIList = vergeConfig?.web_ui_list || [];
const [open, setOpen] = useState(false);
const [editing, setEditing] = useState(false);
if (handler) {
handler.current = {
open: () => setOpen(true),
close: () => setOpen(false),
};
}
const handleAdd = useLockFn(async (value: string) => {
const newList = [value, ...webUIList];
mutateVerge((old) => (old ? { ...old, web_ui_list: newList } : old), false);
await patchVergeConfig({ web_ui_list: newList });
await mutateVerge();
});
const handleChange = useLockFn(async (index: number, value?: string) => {
const newList = [...webUIList];
newList[index] = value ?? "";
mutateVerge((old) => (old ? { ...old, web_ui_list: newList } : old), false);
await patchVergeConfig({ web_ui_list: newList });
await mutateVerge();
});
const handleDelete = useLockFn(async (index: number) => {
const newList = [...webUIList];
newList.splice(index, 1);
mutateVerge((old) => (old ? { ...old, web_ui_list: newList } : old), false);
await patchVergeConfig({ web_ui_list: newList });
await mutateVerge();
});
const { data: clashInfo } = useSWR("getClashInfo", getClashInfo);
const handleOpenUrl = useLockFn(async (value?: string) => {
if (!value) return;
try {
let url = value.trim().replaceAll("%host", "127.0.0.1");
if (url.includes("%port") || url.includes("%secret")) {
if (!clashInfo) throw new Error("failed to get clash info");
if (!clashInfo.server?.includes(":")) {
throw new Error(
`failed to parse server with status ${clashInfo.status}`
);
}
const port = clashInfo.server
.slice(clashInfo.server.indexOf(":") + 1)
.trim();
url = url.replaceAll("%port", port || "9090");
url = url.replaceAll("%secret", clashInfo.secret || "");
}
await openWebUrl(url);
} catch (e: any) {
onError(e);
}
});
return (
<Dialog open={open} onClose={() => setOpen(false)}>
<DialogTitle display="flex" justifyContent="space-between">
{t("Web UI")}
<Button
variant="contained"
size="small"
disabled={editing}
onClick={() => setEditing(true)}
>
{t("New")}
</Button>
</DialogTitle>
<DialogContent
sx={{
width: 450,
height: 300,
pb: 1,
overflowY: "auto",
userSelect: "text",
}}
>
{editing && (
<WebUIItem
value=""
onlyEdit
onChange={(v) => {
setEditing(false);
handleAdd(v || "");
}}
onCancel={() => setEditing(false)}
/>
)}
{!editing && webUIList.length === 0 && (
<BaseEmpty
text="Empty List"
extra={
<Typography mt={2} sx={{ fontSize: "12px" }}>
Replace host, port, secret with "%host" "%port" "%secret"
</Typography>
}
/>
)}
{webUIList.map((item, index) => (
<WebUIItem
key={index}
value={item}
onChange={(v) => handleChange(index, v)}
onDelete={() => handleDelete(index)}
onOpenUrl={handleOpenUrl}
/>
))}
</DialogContent>
<DialogActions>
<Button variant="outlined" onClick={() => setOpen(false)}>
{t("Back")}
</Button>
</DialogActions>
</Dialog>
);
};
export default WebUIViewer;
-51
View File
@@ -1,51 +0,0 @@
import { styled, Switch } from "@mui/material";
// From: https://mui.com/components/switches/
const PaletteSwitch = styled(Switch)(({ theme }) => ({
width: 62,
height: 34,
padding: 7,
"& .MuiSwitch-switchBase": {
margin: 1,
padding: 0,
transform: "translateX(6px)",
"&.Mui-checked": {
color: "#fff",
transform: "translateX(22px)",
"& .MuiSwitch-thumb:before": {
backgroundImage: `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 20 20"><path fill="${encodeURIComponent(
"#fff"
)}" d="M4.2 2.5l-.7 1.8-1.8.7 1.8.7.7 1.8.6-1.8L6.7 5l-1.9-.7-.6-1.8zm15 8.3a6.7 6.7 0 11-6.6-6.6 5.8 5.8 0 006.6 6.6z"/></svg>')`,
},
"& + .MuiSwitch-track": {
opacity: 1,
backgroundColor: theme.palette.mode === "dark" ? "#8796A5" : "#aab4be",
},
},
},
"& .MuiSwitch-thumb": {
backgroundColor: theme.palette.mode === "dark" ? "#003892" : "#001e3c",
width: 32,
height: 32,
"&:before": {
content: "''",
position: "absolute",
width: "100%",
height: "100%",
left: 0,
top: 0,
backgroundRepeat: "no-repeat",
backgroundPosition: "center",
backgroundImage: `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 20 20"><path fill="${encodeURIComponent(
"#fff"
)}" d="M9.305 1.667V3.75h1.389V1.667h-1.39zm-4.707 1.95l-.982.982L5.09 6.072l.982-.982-1.473-1.473zm10.802 0L13.927 5.09l.982.982 1.473-1.473-.982-.982zM10 5.139a4.872 4.872 0 00-4.862 4.86A4.872 4.872 0 0010 14.862 4.872 4.872 0 0014.86 10 4.872 4.872 0 0010 5.139zm0 1.389A3.462 3.462 0 0113.471 10a3.462 3.462 0 01-3.473 3.472A3.462 3.462 0 016.527 10 3.462 3.462 0 0110 6.528zM1.665 9.305v1.39h2.083v-1.39H1.666zm14.583 0v1.39h2.084v-1.39h-2.084zM5.09 13.928L3.616 15.4l.982.982 1.473-1.473-.982-.982zm9.82 0l-.982.982 1.473 1.473.982-.982-1.473-1.473zM9.305 16.25v2.083h1.389V16.25h-1.39z"/></svg>')`,
},
},
"& .MuiSwitch-track": {
opacity: 1,
backgroundColor: theme.palette.mode === "dark" ? "#8796A5" : "#aab4be",
borderRadius: 20 / 2,
},
}));
export default PaletteSwitch;
+58 -40
View File
@@ -1,35 +1,37 @@
import useSWR, { useSWRConfig } from "swr"; import useSWR from "swr";
import { useSetRecoilState } from "recoil"; import { useSetRecoilState } from "recoil";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import {
ListItemText,
TextField, TextField,
Switch, Switch,
Select, Select,
MenuItem, MenuItem,
Typography, Typography,
Box, IconButton,
} from "@mui/material"; } from "@mui/material";
import { ApiType } from "../../services/types"; import { atomClashPort } from "@/services/states";
import { atomClashPort } from "../../services/states"; import { ArrowForward } from "@mui/icons-material";
import { patchClashConfig } from "../../services/cmds"; import { patchClashConfig } from "@/services/cmds";
import { SettingList, SettingItem } from "./setting"; import { SettingList, SettingItem } from "./setting";
import { getClashConfig, getVersion, updateConfigs } from "../../services/api"; import { getClashConfig, getVersion, updateConfigs } from "@/services/api";
import useModalHandler from "@/hooks/use-modal-handler";
import Notice from "../base/base-notice"; import Notice from "../base/base-notice";
import GuardState from "./guard-state"; import GuardState from "./mods/guard-state";
import CoreSwitch from "./core-switch"; import CoreSwitch from "./mods/core-switch";
import WebUIViewer from "./mods/web-ui-viewer";
import ClashFieldViewer from "./mods/clash-field-viewer";
interface Props { interface Props {
onError: (err: Error) => void; onError: (err: Error) => void;
} }
// const MULTI_CORE = !!import.meta.env.VITE_MULTI_CORE;
const MULTI_CORE = true;
const SettingClash = ({ onError }: Props) => { const SettingClash = ({ onError }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { mutate } = useSWRConfig();
const { data: clashConfig } = useSWR("getClashConfig", getClashConfig); const { data: clashConfig, mutate: mutateClash } = useSWR(
"getClashConfig",
getClashConfig
);
const { data: versionData } = useSWR("getVersion", getVersion); const { data: versionData } = useSWR("getVersion", getVersion);
const { const {
@@ -41,9 +43,12 @@ const SettingClash = ({ onError }: Props) => {
const setGlobalClashPort = useSetRecoilState(atomClashPort); const setGlobalClashPort = useSetRecoilState(atomClashPort);
const webUIHandler = useModalHandler();
const fieldHandler = useModalHandler();
const onSwitchFormat = (_e: any, value: boolean) => value; const onSwitchFormat = (_e: any, value: boolean) => value;
const onChangeData = (patch: Partial<ApiType.ConfigData>) => { const onChangeData = (patch: Partial<ApiType.ConfigData>) => {
mutate("getClashConfig", { ...clashConfig, ...patch }, false); mutateClash((old) => ({ ...(old! || {}), ...patch }), false);
}; };
const onUpdateData = async (patch: Partial<ApiType.ConfigData>) => { const onUpdateData = async (patch: Partial<ApiType.ConfigData>) => {
await updateConfigs(patch); await updateConfigs(patch);
@@ -62,7 +67,7 @@ const SettingClash = ({ onError }: Props) => {
Notice.success("Change Clash port successfully!", 1000); Notice.success("Change Clash port successfully!", 1000);
// update the config // update the config
mutate("getClashConfig"); mutateClash();
}; };
// get clash core version // get clash core version
@@ -72,8 +77,10 @@ const SettingClash = ({ onError }: Props) => {
return ( return (
<SettingList title={t("Clash Setting")}> <SettingList title={t("Clash Setting")}>
<SettingItem> <WebUIViewer handler={webUIHandler} onError={onError} />
<ListItemText primary={t("Allow Lan")} /> <ClashFieldViewer handler={fieldHandler} />
<SettingItem label={t("Allow Lan")}>
<GuardState <GuardState
value={allowLan ?? false} value={allowLan ?? false}
valueProps="checked" valueProps="checked"
@@ -86,8 +93,7 @@ const SettingClash = ({ onError }: Props) => {
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("IPv6")}>
<ListItemText primary={t("IPv6")} />
<GuardState <GuardState
value={ipv6 ?? false} value={ipv6 ?? false}
valueProps="checked" valueProps="checked"
@@ -100,8 +106,7 @@ const SettingClash = ({ onError }: Props) => {
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Log Level")}>
<ListItemText primary={t("Log Level")} />
<GuardState <GuardState
value={logLevel ?? "info"} value={logLevel ?? "info"}
onCatch={onError} onCatch={onError}
@@ -109,7 +114,7 @@ const SettingClash = ({ onError }: Props) => {
onChange={(e) => onChangeData({ "log-level": e })} onChange={(e) => onChangeData({ "log-level": e })}
onGuard={(e) => onUpdateData({ "log-level": e })} onGuard={(e) => onUpdateData({ "log-level": e })}
> >
<Select size="small" sx={{ width: 120 }}> <Select size="small" sx={{ width: 120, "> div": { py: "7.5px" } }}>
<MenuItem value="debug">Debug</MenuItem> <MenuItem value="debug">Debug</MenuItem>
<MenuItem value="info">Info</MenuItem> <MenuItem value="info">Info</MenuItem>
<MenuItem value="warning">Warning</MenuItem> <MenuItem value="warning">Warning</MenuItem>
@@ -119,8 +124,7 @@ const SettingClash = ({ onError }: Props) => {
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Mixed Port")}>
<ListItemText primary={t("Mixed Port")} />
<GuardState <GuardState
value={mixedPort ?? 0} value={mixedPort ?? 0}
onCatch={onError} onCatch={onError}
@@ -129,24 +133,38 @@ const SettingClash = ({ onError }: Props) => {
onGuard={onUpdatePort} onGuard={onUpdatePort}
waitTime={1000} waitTime={1000}
> >
<TextField autoComplete="off" size="small" sx={{ width: 120 }} /> <TextField
autoComplete="off"
size="small"
sx={{ width: 120, input: { py: "7.5px" } }}
/>
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Web UI")}>
<ListItemText <IconButton
primary={ color="inherit"
MULTI_CORE ? ( size="small"
<Box sx={{ display: "flex", alignItems: "center" }}> sx={{ my: "2px" }}
<span style={{ marginRight: 4 }}>{t("Clash Core")}</span> onClick={() => webUIHandler.current.open()}
<CoreSwitch /> >
</Box> <ArrowForward />
) : ( </IconButton>
t("Clash Core") </SettingItem>
)
} <SettingItem label={t("Clash Field")}>
/> <IconButton
<Typography sx={{ py: 1 }}>{clashVer}</Typography> color="inherit"
size="small"
sx={{ my: "2px" }}
onClick={() => fieldHandler.current.open()}
>
<ArrowForward />
</IconButton>
</SettingItem>
<SettingItem label={t("Clash Core")} extra={<CoreSwitch />}>
<Typography sx={{ py: "7px" }}>{clashVer}</Typography>
</SettingItem> </SettingItem>
</SettingList> </SettingList>
); );
+38 -59
View File
@@ -1,25 +1,18 @@
import useSWR, { useSWRConfig } from "swr"; import useSWR, { useSWRConfig } from "swr";
import { useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import { IconButton, Switch, TextField } from "@mui/material";
Box,
IconButton,
ListItemText,
Switch,
TextField,
} from "@mui/material";
import { ArrowForward, PrivacyTipRounded } from "@mui/icons-material"; import { ArrowForward, PrivacyTipRounded } from "@mui/icons-material";
import { import {
checkService, checkService,
getVergeConfig, getVergeConfig,
patchVergeConfig, patchVergeConfig,
} from "../../services/cmds"; } from "@/services/cmds";
import { SettingList, SettingItem } from "./setting"; import { SettingList, SettingItem } from "./setting";
import { CmdType } from "../../services/types"; import getSystem from "@/utils/get-system";
import GuardState from "./guard-state"; import GuardState from "./mods/guard-state";
import ServiceMode from "./service-mode"; import ServiceMode from "./mods/service-mode";
import SysproxyTooltip from "./sysproxy-tooltip"; import SysproxyTooltip from "./mods/sysproxy-tooltip";
import getSystem from "../../utils/get-system";
interface Props { interface Props {
onError?: (err: Error) => void; onError?: (err: Error) => void;
@@ -57,8 +50,7 @@ const SettingSystem = ({ onError }: Props) => {
return ( return (
<SettingList title={t("System Setting")}> <SettingList title={t("System Setting")}>
<SettingItem> <SettingItem label={t("Tun Mode")}>
<ListItemText primary={t("Tun Mode")} />
<GuardState <GuardState
value={enable_tun_mode ?? false} value={enable_tun_mode ?? false}
valueProps="checked" valueProps="checked"
@@ -72,23 +64,18 @@ const SettingSystem = ({ onError }: Props) => {
</SettingItem> </SettingItem>
{isWIN && ( {isWIN && (
<SettingItem> <SettingItem
<ListItemText label={t("Service Mode")}
primary={ extra={
<Box sx={{ display: "flex", alignItems: "center" }}> (serviceStatus === "active" || serviceStatus === "installed") && (
<span style={{ marginRight: 4 }}>{t("Service Mode")}</span> <PrivacyTipRounded
fontSize="small"
{(serviceStatus === "active" || style={{ cursor: "pointer", opacity: 0.75 }}
serviceStatus === "installed") && ( onClick={() => setServiceOpen(true)}
<PrivacyTipRounded />
fontSize="small" )
onClick={() => setServiceOpen(true)} }
/> >
)}
</Box>
}
/>
{serviceStatus === "active" || serviceStatus === "installed" ? ( {serviceStatus === "active" || serviceStatus === "installed" ? (
<GuardState <GuardState
value={enable_service_mode ?? false} value={enable_service_mode ?? false}
@@ -109,20 +96,19 @@ const SettingSystem = ({ onError }: Props) => {
<ArrowForward /> <ArrowForward />
</IconButton> </IconButton>
)} )}
{serviceOpen && (
<ServiceMode
open={serviceOpen}
enable={!!enable_service_mode}
onError={onError}
onClose={() => setServiceOpen(false)}
/>
)}
</SettingItem> </SettingItem>
)} )}
<SettingItem> {isWIN && (
<ListItemText primary={t("Auto Launch")} /> <ServiceMode
open={serviceOpen}
enable={!!enable_service_mode}
onError={onError}
onClose={() => setServiceOpen(false)}
/>
)}
<SettingItem label={t("Auto Launch")}>
<GuardState <GuardState
value={enable_auto_launch ?? false} value={enable_auto_launch ?? false}
valueProps="checked" valueProps="checked"
@@ -135,8 +121,7 @@ const SettingSystem = ({ onError }: Props) => {
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Silent Start")}>
<ListItemText primary={t("Silent Start")} />
<GuardState <GuardState
value={enable_silent_start ?? false} value={enable_silent_start ?? false}
valueProps="checked" valueProps="checked"
@@ -149,15 +134,7 @@ const SettingSystem = ({ onError }: Props) => {
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("System Proxy")} extra={<SysproxyTooltip />}>
<ListItemText
primary={
<Box sx={{ display: "flex", alignItems: "center" }}>
<span style={{ marginRight: 4 }}>{t("System Proxy")}</span>
<SysproxyTooltip />
</Box>
}
/>
<GuardState <GuardState
value={enable_system_proxy ?? false} value={enable_system_proxy ?? false}
valueProps="checked" valueProps="checked"
@@ -174,8 +151,7 @@ const SettingSystem = ({ onError }: Props) => {
</SettingItem> </SettingItem>
{enable_system_proxy && ( {enable_system_proxy && (
<SettingItem> <SettingItem label={t("Proxy Guard")}>
<ListItemText primary={t("Proxy Guard")} />
<GuardState <GuardState
value={enable_proxy_guard ?? false} value={enable_proxy_guard ?? false}
valueProps="checked" valueProps="checked"
@@ -190,8 +166,7 @@ const SettingSystem = ({ onError }: Props) => {
)} )}
{enable_system_proxy && ( {enable_system_proxy && (
<SettingItem> <SettingItem label={t("Proxy Bypass")}>
<ListItemText primary={t("Proxy Bypass")} />
<GuardState <GuardState
value={system_proxy_bypass ?? ""} value={system_proxy_bypass ?? ""}
onCatch={onError} onCatch={onError}
@@ -200,7 +175,11 @@ const SettingSystem = ({ onError }: Props) => {
onGuard={(e) => patchVergeConfig({ system_proxy_bypass: e })} onGuard={(e) => patchVergeConfig({ system_proxy_bypass: e })}
waitTime={1000} waitTime={1000}
> >
<TextField autoComplete="off" size="small" sx={{ width: 120 }} /> <TextField
autoComplete="off"
size="small"
sx={{ width: 120, input: { py: "7.5px" } }}
/>
</GuardState> </GuardState>
</SettingItem> </SettingItem>
)} )}
+5 -3
View File
@@ -15,8 +15,8 @@ import {
TextField, TextField,
useTheme, useTheme,
} from "@mui/material"; } from "@mui/material";
import { getVergeConfig, patchVergeConfig } from "../../services/cmds"; import { getVergeConfig, patchVergeConfig } from "@/services/cmds";
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme"; import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";
interface Props { interface Props {
open: boolean; open: boolean;
@@ -142,7 +142,9 @@ const SettingTheme = (props: Props) => {
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={onClose}>{t("Cancel")}</Button> <Button variant="outlined" onClick={onClose}>
{t("Cancel")}
</Button>
<Button onClick={onSave} variant="contained"> <Button onClick={onSave} variant="contained">
{t("Save")} {t("Save")}
</Button> </Button>
+64 -51
View File
@@ -1,9 +1,8 @@
import useSWR, { useSWRConfig } from "swr"; import useSWR from "swr";
import { useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import {
IconButton, IconButton,
ListItemText,
MenuItem, MenuItem,
Select, Select,
Switch, Switch,
@@ -14,13 +13,13 @@ import {
openAppDir, openAppDir,
openLogsDir, openLogsDir,
patchVergeConfig, patchVergeConfig,
} from "../../services/cmds"; } from "@/services/cmds";
import { ArrowForward } from "@mui/icons-material"; import { ArrowForward } from "@mui/icons-material";
import { SettingList, SettingItem } from "./setting"; import { SettingList, SettingItem } from "./setting";
import { CmdType } from "../../services/types"; import { version } from "@root/package.json";
import { version } from "../../../package.json"; import ThemeModeSwitch from "./mods/theme-mode-switch";
import PaletteSwitch from "./palette-switch"; import ConfigViewer from "./mods/config-viewer";
import GuardState from "./guard-state"; import GuardState from "./mods/guard-state";
import SettingTheme from "./setting-theme"; import SettingTheme from "./setting-theme";
interface Props { interface Props {
@@ -29,38 +28,50 @@ interface Props {
const SettingVerge = ({ onError }: Props) => { const SettingVerge = ({ onError }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { mutate } = useSWRConfig(); const { data: vergeConfig, mutate: mutateVerge } = useSWR(
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig); "getVergeConfig",
getVergeConfig
);
const { theme_mode, theme_blur, traffic_graph, language } = vergeConfig ?? {}; const { theme_mode, theme_blur, traffic_graph, language } = vergeConfig ?? {};
const [themeOpen, setThemeOpen] = useState(false); const [themeOpen, setThemeOpen] = useState(false);
const [configOpen, setConfigOpen] = useState(false);
const onSwitchFormat = (_e: any, value: boolean) => value; const onSwitchFormat = (_e: any, value: boolean) => value;
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => { const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
mutate("getVergeConfig", { ...vergeConfig, ...patch }, false); mutateVerge({ ...vergeConfig, ...patch }, false);
}; };
return ( return (
<SettingList title={t("Verge Setting")}> <SettingList title={t("Verge Setting")}>
<SettingItem> <SettingItem label={t("Language")}>
<ListItemText primary={t("Theme Mode")} />
<GuardState <GuardState
value={theme_mode === "dark"} value={language ?? "en"}
valueProps="checked"
onCatch={onError} onCatch={onError}
onFormat={onSwitchFormat} onFormat={(e: any) => e.target.value}
onChange={(e) => onChangeData({ theme_mode: e ? "dark" : "light" })} onChange={(e) => onChangeData({ language: e })}
onGuard={(e) => onGuard={(e) => patchVergeConfig({ language: e })}
patchVergeConfig({ theme_mode: e ? "dark" : "light" })
}
> >
<PaletteSwitch edge="end" /> <Select size="small" sx={{ width: 100, "> div": { py: "7.5px" } }}>
<MenuItem value="zh">中文</MenuItem>
<MenuItem value="en">English</MenuItem>
</Select>
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Theme Mode")}>
<ListItemText primary={t("Theme Blur")} /> <GuardState
value={theme_mode}
onCatch={onError}
onChange={(e) => onChangeData({ theme_mode: e })}
onGuard={(e) => patchVergeConfig({ theme_mode: e })}
>
<ThemeModeSwitch />
</GuardState>
</SettingItem>
<SettingItem label={t("Theme Blur")}>
<GuardState <GuardState
value={theme_blur ?? false} value={theme_blur ?? false}
valueProps="checked" valueProps="checked"
@@ -73,8 +84,7 @@ const SettingVerge = ({ onError }: Props) => {
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Traffic Graph")}>
<ListItemText primary={t("Traffic Graph")} />
<GuardState <GuardState
value={traffic_graph ?? true} value={traffic_graph ?? true}
valueProps="checked" valueProps="checked"
@@ -87,53 +97,56 @@ const SettingVerge = ({ onError }: Props) => {
</GuardState> </GuardState>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Theme Setting")}>
<ListItemText primary={t("Language")} />
<GuardState
value={language ?? "en"}
onCatch={onError}
onFormat={(e: any) => e.target.value}
onChange={(e) => onChangeData({ language: e })}
onGuard={(e) => patchVergeConfig({ language: e })}
>
<Select size="small" sx={{ width: 100 }}>
<MenuItem value="zh">中文</MenuItem>
<MenuItem value="en">English</MenuItem>
</Select>
</GuardState>
</SettingItem>
<SettingItem>
<ListItemText primary={t("Theme Setting")} />
<IconButton <IconButton
color="inherit" color="inherit"
size="small" size="small"
sx={{ my: "2px" }}
onClick={() => setThemeOpen(true)} onClick={() => setThemeOpen(true)}
> >
<ArrowForward /> <ArrowForward />
</IconButton> </IconButton>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Runtime Config")}>
<ListItemText primary={t("Open App Dir")} /> <IconButton
<IconButton color="inherit" size="small" onClick={openAppDir}> color="inherit"
size="small"
sx={{ my: "2px" }}
onClick={() => setConfigOpen(true)}
>
<ArrowForward /> <ArrowForward />
</IconButton> </IconButton>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Open App Dir")}>
<ListItemText primary={t("Open Logs Dir")} /> <IconButton
<IconButton color="inherit" size="small" onClick={openLogsDir}> color="inherit"
size="small"
sx={{ my: "2px" }}
onClick={openAppDir}
>
<ArrowForward /> <ArrowForward />
</IconButton> </IconButton>
</SettingItem> </SettingItem>
<SettingItem> <SettingItem label={t("Open Logs Dir")}>
<ListItemText primary={t("Version")} /> <IconButton
<Typography sx={{ py: "6px" }}>v{version}</Typography> color="inherit"
size="small"
sx={{ my: "2px" }}
onClick={openLogsDir}
>
<ArrowForward />
</IconButton>
</SettingItem>
<SettingItem label={t("Verge Version")}>
<Typography sx={{ py: "7px" }}>v{version}</Typography>
</SettingItem> </SettingItem>
<SettingTheme open={themeOpen} onClose={() => setThemeOpen(false)} /> <SettingTheme open={themeOpen} onClose={() => setThemeOpen(false)} />
<ConfigViewer open={configOpen} onClose={() => setConfigOpen(false)} />
</SettingList> </SettingList>
); );
}; };
+31 -5
View File
@@ -1,10 +1,36 @@
import React from "react"; import React from "react";
import { List, ListItem, ListSubheader, styled } from "@mui/material"; import {
Box,
List,
ListItem,
ListItemText,
ListSubheader,
} from "@mui/material";
export const SettingItem = styled(ListItem)(() => ({ interface ItemProps {
paddingTop: 5, label: React.ReactNode;
paddingBottom: 5, extra?: React.ReactNode;
})); }
export const SettingItem: React.FC<ItemProps> = (props) => {
const { label, extra, children } = props;
const primary = !extra ? (
label
) : (
<Box sx={{ display: "flex", alignItems: "center" }}>
<span style={{ marginRight: 4 }}>{label}</span>
{extra}
</Box>
);
return (
<ListItem sx={{ pt: "5px", pb: "5px" }}>
<ListItemText primary={primary} />
{children}
</ListItem>
);
};
export const SettingList: React.FC<{ title: string }> = (props) => ( export const SettingList: React.FC<{ title: string }> = (props) => (
<List> <List>
+14
View File
@@ -0,0 +1,14 @@
import { MutableRefObject, useRef } from "react";
interface Handler {
open: () => void;
close: () => void;
}
export type ModalHandler = MutableRefObject<Handler>;
const useModalHandler = (): ModalHandler => {
return useRef({ open: () => {}, close: () => {} });
};
export default useModalHandler;
+10 -1
View File
@@ -18,6 +18,8 @@
"Profile URL": "Profile URL", "Profile URL": "Profile URL",
"Import": "Import", "Import": "Import",
"New": "New", "New": "New",
"Create Profile": "Create Profile",
"Choose File": "Choose File",
"Close All": "Close All", "Close All": "Close All",
"Select": "Select", "Select": "Select",
"Edit Info": "Edit Info", "Edit Info": "Edit Info",
@@ -55,8 +57,15 @@
"Language": "Language", "Language": "Language",
"Open App Dir": "Open App Dir", "Open App Dir": "Open App Dir",
"Open Logs Dir": "Open Logs Dir", "Open Logs Dir": "Open Logs Dir",
"Version": "Version", "Verge Version": "Verge Version",
"theme.light": "Light",
"theme.dark": "Dark",
"theme.system": "System",
"Clash Field": "Clash Field",
"Runtime Config": "Runtime Config",
"ReadOnly": "ReadOnly",
"Back": "Back",
"Save": "Save", "Save": "Save",
"Cancel": "Cancel" "Cancel": "Cancel"
} }
+11 -2
View File
@@ -18,6 +18,8 @@
"Profile URL": "配置文件链接", "Profile URL": "配置文件链接",
"Import": "导入", "Import": "导入",
"New": "新建", "New": "新建",
"Create Profile": "新建配置",
"Choose File": "选择文件",
"Close All": "关闭全部", "Close All": "关闭全部",
"Select": "使用", "Select": "使用",
"Edit Info": "编辑信息", "Edit Info": "编辑信息",
@@ -48,15 +50,22 @@
"System Proxy": "系统代理", "System Proxy": "系统代理",
"Proxy Guard": "系统代理守卫", "Proxy Guard": "系统代理守卫",
"Proxy Bypass": "Proxy Bypass", "Proxy Bypass": "Proxy Bypass",
"Theme Mode": "暗夜模式", "Theme Mode": "主题模式",
"Theme Blur": "背景模糊", "Theme Blur": "背景模糊",
"Theme Setting": "主题设置", "Theme Setting": "主题设置",
"Traffic Graph": "流量图显", "Traffic Graph": "流量图显",
"Language": "语言设置", "Language": "语言设置",
"Open App Dir": "应用目录", "Open App Dir": "应用目录",
"Open Logs Dir": "日志目录", "Open Logs Dir": "日志目录",
"Version": "版本", "Verge Version": "应用版本",
"theme.light": "浅色",
"theme.dark": "深色",
"theme.system": "系统",
"Clash Field": "Clash 字段",
"Runtime Config": "运行配置",
"ReadOnly": "只读",
"Back": "返回",
"Save": "保存", "Save": "保存",
"Cancel": "取消" "Cancel": "取消"
} }
-3
View File
@@ -7,11 +7,8 @@ import ReactDOM from "react-dom";
import { RecoilRoot } from "recoil"; import { RecoilRoot } from "recoil";
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import Layout from "./pages/_layout"; import Layout from "./pages/_layout";
import enhance from "./services/enhance";
import "./services/i18n"; import "./services/i18n";
enhance.setup();
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<RecoilRoot> <RecoilRoot>
+17 -11
View File
@@ -10,18 +10,22 @@ import { alpha, List, Paper, ThemeProvider } from "@mui/material";
import { listen } from "@tauri-apps/api/event"; import { listen } from "@tauri-apps/api/event";
import { appWindow } from "@tauri-apps/api/window"; import { appWindow } from "@tauri-apps/api/window";
import { routers } from "./_routers"; import { routers } from "./_routers";
import { getAxios } from "../services/api"; import { getAxios } from "@/services/api";
import { atomCurrentProfile } from "../services/states"; import { atomCurrentProfile } from "@/services/states";
import { getVergeConfig, getProfiles } from "../services/cmds"; import { getVergeConfig, getProfiles } from "@/services/cmds";
import { ReactComponent as LogoSvg } from "../assets/image/logo.svg"; import { ReactComponent as LogoSvg } from "@/assets/image/logo.svg";
import LayoutItem from "../components/layout/layout-item"; import LayoutItem from "@/components/layout/layout-item";
import LayoutControl from "../components/layout/layout-control"; import LayoutControl from "@/components/layout/layout-control";
import LayoutTraffic from "../components/layout/layout-traffic"; import LayoutTraffic from "@/components/layout/layout-traffic";
import UpdateButton from "../components/layout/update-button"; import UpdateButton from "@/components/layout/update-button";
import useCustomTheme from "../components/layout/use-custom-theme"; import useCustomTheme from "@/components/layout/use-custom-theme";
import getSystem from "../utils/get-system"; import getSystem from "@/utils/get-system";
import "dayjs/locale/zh-cn"; import "dayjs/locale/zh-cn";
declare global {
const WIN_PORTABLE: boolean;
}
dayjs.extend(relativeTime); dayjs.extend(relativeTime);
const OS = getSystem(); const OS = getSystem();
@@ -87,7 +91,9 @@ const Layout = () => {
<div className="the-logo" data-windrag> <div className="the-logo" data-windrag>
<LogoSvg /> <LogoSvg />
<UpdateButton className="the-newbtn" /> {!(OS === "windows" && WIN_PORTABLE) && (
<UpdateButton className="the-newbtn" />
)}
</div> </div>
<List className="the-menu"> <List className="the-menu">
+3 -4
View File
@@ -3,10 +3,9 @@ import { useLockFn } from "ahooks";
import { Box, Button, Paper, TextField } from "@mui/material"; import { Box, Button, Paper, TextField } from "@mui/material";
import { Virtuoso } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { ApiType } from "../services/types"; import { closeAllConnections, getInformation } from "@/services/api";
import { closeAllConnections, getInformation } from "../services/api"; import BasePage from "@/components/base/base-page";
import BasePage from "../components/base/base-page"; import ConnectionItem from "@/components/connection/connection-item";
import ConnectionItem from "../components/connection/connection-item";
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] }; const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
+3 -3
View File
@@ -3,9 +3,9 @@ import { useRecoilState } from "recoil";
import { Box, Button, MenuItem, Paper, Select, TextField } from "@mui/material"; import { Box, Button, MenuItem, Paper, Select, TextField } from "@mui/material";
import { Virtuoso } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { atomLogData } from "../services/states"; import { atomLogData } from "@/services/states";
import BasePage from "../components/base/base-page"; import BasePage from "@/components/base/base-page";
import LogItem from "../components/log/log-item"; import LogItem from "@/components/log/log-item";
const LogPage = () => { const LogPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
+30 -22
View File
@@ -1,26 +1,25 @@
import useSWR, { useSWRConfig } from "swr"; import useSWR, { mutate } from "swr";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { useSetRecoilState } from "recoil"; import { useSetRecoilState } from "recoil";
import { Box, Button, Grid, TextField } from "@mui/material"; import { Button, Grid, Stack, TextField } from "@mui/material";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import {
getProfiles, getProfiles,
patchProfile, patchProfile,
selectProfile, selectProfile,
importProfile, importProfile,
} from "../services/cmds"; } from "@/services/cmds";
import { getProxies, updateProxy } from "../services/api"; import { getProxies, updateProxy } from "@/services/api";
import { atomCurrentProfile } from "../services/states"; import { atomCurrentProfile } from "@/services/states";
import Notice from "../components/base/base-notice"; import Notice from "@/components/base/base-notice";
import BasePage from "../components/base/base-page"; import BasePage from "@/components/base/base-page";
import ProfileNew from "../components/profile/profile-new"; import ProfileNew from "@/components/profile/profile-new";
import ProfileItem from "../components/profile/profile-item"; import ProfileItem from "@/components/profile/profile-item";
import EnhancedMode from "../components/profile/enhanced"; import EnhancedMode from "@/components/profile/enhanced";
const ProfilePage = () => { const ProfilePage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const { mutate } = useSWRConfig();
const [url, setUrl] = useState(""); const [url, setUrl] = useState("");
const [disabled, setDisabled] = useState(false); const [disabled, setDisabled] = useState(false);
@@ -110,10 +109,13 @@ const ProfilePage = () => {
getProfiles().then((newProfiles) => { getProfiles().then((newProfiles) => {
mutate("getProfiles", newProfiles); mutate("getProfiles", newProfiles);
if (!newProfiles.current && newProfiles.items?.length) { const remoteItem = newProfiles.items?.find((e) => e.type === "remote");
const current = newProfiles.items[0].uid;
if (!newProfiles.current && remoteItem) {
const current = remoteItem.uid;
selectProfile(current); selectProfile(current);
mutate("getProfiles", { ...newProfiles, current }, true); mutate("getProfiles", { ...newProfiles, current }, true);
mutate("getRuntimeLogs");
} }
}); });
} catch { } catch {
@@ -130,6 +132,7 @@ const ProfilePage = () => {
await selectProfile(uid); await selectProfile(uid);
setCurrentProfile(uid); setCurrentProfile(uid);
mutate("getProfiles", { ...profiles, current: uid }, true); mutate("getProfiles", { ...profiles, current: uid }, true);
mutate("getRuntimeLogs");
if (force) Notice.success("Refresh clash config", 1000); if (force) Notice.success("Refresh clash config", 1000);
} catch (err: any) { } catch (err: any) {
Notice.error(err?.message || err.toString()); Notice.error(err?.message || err.toString());
@@ -138,29 +141,34 @@ const ProfilePage = () => {
return ( return (
<BasePage title={t("Profiles")}> <BasePage title={t("Profiles")}>
<Box sx={{ display: "flex", mb: 2.5 }}> <Stack direction="row" spacing={1} sx={{ mb: 2 }}>
<TextField <TextField
id="clas_verge_profile_url" hiddenLabel
name="profile_url"
label={t("Profile URL")}
size="small"
fullWidth fullWidth
size="small"
value={url} value={url}
variant="outlined"
autoComplete="off"
onChange={(e) => setUrl(e.target.value)} onChange={(e) => setUrl(e.target.value)}
sx={{ mr: 1 }} sx={{ input: { py: 0.65, px: 1.25 } }}
placeholder={t("Profile URL")}
/> />
<Button <Button
disabled={!url || disabled} disabled={!url || disabled}
variant="contained" variant="contained"
size="small"
onClick={onImport} onClick={onImport}
sx={{ mr: 1 }}
> >
{t("Import")} {t("Import")}
</Button> </Button>
<Button variant="contained" onClick={() => setDialogOpen(true)}> <Button
variant="contained"
size="small"
onClick={() => setDialogOpen(true)}
>
{t("New")} {t("New")}
</Button> </Button>
</Box> </Stack>
<Grid container spacing={2}> <Grid container spacing={2}>
{regularItems.map((item) => ( {regularItems.map((item) => (
+6 -6
View File
@@ -3,12 +3,12 @@ import { useEffect } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Button, ButtonGroup, List, Paper } from "@mui/material"; import { Button, ButtonGroup, List, Paper } from "@mui/material";
import { getClashConfig, updateConfigs } from "../services/api"; import { getClashConfig, updateConfigs } from "@/services/api";
import { patchClashConfig } from "../services/cmds"; import { patchClashConfig } from "@/services/cmds";
import { getProxies } from "../services/api"; import { getProxies } from "@/services/api";
import BasePage from "../components/base/base-page"; import BasePage from "@/components/base/base-page";
import ProxyGroup from "../components/proxy/proxy-group"; import ProxyGroup from "@/components/proxy/proxy-group";
import ProxyGlobal from "../components/proxy/proxy-global"; import ProxyGlobal from "@/components/proxy/proxy-global";
const ProxyPage = () => { const ProxyPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
+5 -5
View File
@@ -1,10 +1,10 @@
import { Paper } from "@mui/material"; import { Paper } from "@mui/material";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import Notice from "../components/base/base-notice"; import Notice from "@/components/base/base-notice";
import BasePage from "../components/base/base-page"; import BasePage from "@/components/base/base-page";
import SettingVerge from "../components/setting/setting-verge"; import SettingVerge from "@/components/setting/setting-verge";
import SettingClash from "../components/setting/setting-clash"; import SettingClash from "@/components/setting/setting-clash";
import SettingSystem from "../components/setting/setting-system"; import SettingSystem from "@/components/setting/setting-system";
const SettingPage = () => { const SettingPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
-1
View File
@@ -1,6 +1,5 @@
import axios, { AxiosInstance } from "axios"; import axios, { AxiosInstance } from "axios";
import { getClashInfo } from "./cmds"; import { getClashInfo } from "./cmds";
import { ApiType } from "./types";
let axiosIns: AxiosInstance = null!; let axiosIns: AxiosInstance = null!;
let server = ""; let server = "";
+21 -2
View File
@@ -1,6 +1,5 @@
import { invoke } from "@tauri-apps/api/tauri"; import { invoke } from "@tauri-apps/api/tauri";
import { ApiType, CmdType } from "./types"; import Notice from "@/components/base/base-notice";
import Notice from "../components/base/base-notice";
export async function getProfiles() { export async function getProfiles() {
return invoke<CmdType.ProfilesConfig>("get_profiles"); return invoke<CmdType.ProfilesConfig>("get_profiles");
@@ -70,6 +69,22 @@ export async function getClashInfo() {
return invoke<CmdType.ClashInfo | null>("get_clash_info"); return invoke<CmdType.ClashInfo | null>("get_clash_info");
} }
export async function getRuntimeConfig() {
return invoke<any | null>("get_runtime_config");
}
export async function getRuntimeYaml() {
return invoke<string | null>("get_runtime_yaml");
}
export async function getRuntimeExists() {
return invoke<string[]>("get_runtime_exists");
}
export async function getRuntimeLogs() {
return invoke<Record<string, [string, string][]>>("get_runtime_logs");
}
export async function patchClashConfig(payload: Partial<ApiType.ConfigData>) { export async function patchClashConfig(payload: Partial<ApiType.ConfigData>) {
return invoke<void>("patch_clash_config", { payload }); return invoke<void>("patch_clash_config", { payload });
} }
@@ -110,6 +125,10 @@ export async function openLogsDir() {
); );
} }
export async function openWebUrl(url: string) {
return invoke<void>("open_web_url", { url });
}
/// service mode /// service mode
export async function startService() { export async function startService() {
-221
View File
@@ -1,221 +0,0 @@
import { emit, listen, Event } from "@tauri-apps/api/event";
import { appWindow } from "@tauri-apps/api/window";
import { CmdType } from "./types";
import ignoreCase from "../utils/ignore-case";
const DEFAULT_FIELDS = [
"rules",
"proxies",
"proxy-groups",
"proxy-providers",
"rule-providers",
] as const;
const USE_FLAG_FIELDS = [
"tun",
"dns",
"hosts",
"script",
"profile",
"payload",
"interface-name",
"routing-mark",
] as const;
/**
* process the merge mode
*/
function toMerge(merge: CmdType.ProfileMerge, data: CmdType.ProfileData) {
if (!merge) return { data, use: [] };
const {
use,
"prepend-rules": preRules,
"append-rules": postRules,
"prepend-proxies": preProxies,
"append-proxies": postProxies,
"prepend-proxy-groups": preProxyGroups,
"append-proxy-groups": postProxyGroups,
...mergeConfig
} = merge;
[...DEFAULT_FIELDS, ...USE_FLAG_FIELDS].forEach((key) => {
// the value should not be null
if (mergeConfig[key] != null) {
data[key] = mergeConfig[key];
}
});
// init
if (!data.rules) data.rules = [];
if (!data.proxies) data.proxies = [];
if (!data["proxy-groups"]) data["proxy-groups"] = [];
// rules
if (Array.isArray(preRules)) {
data.rules.unshift(...preRules);
}
if (Array.isArray(postRules)) {
data.rules.push(...postRules);
}
// proxies
if (Array.isArray(preProxies)) {
data.proxies.unshift(...preProxies);
}
if (Array.isArray(postProxies)) {
data.proxies.push(...postProxies);
}
// proxy-groups
if (Array.isArray(preProxyGroups)) {
data["proxy-groups"].unshift(...preProxyGroups);
}
if (Array.isArray(postProxyGroups)) {
data["proxy-groups"].push(...postProxyGroups);
}
return { data, use: Array.isArray(use) ? use : [] };
}
/**
* process the script mode
*/
function toScript(
script: string,
data: CmdType.ProfileData
): Promise<CmdType.ProfileData> {
if (!script) {
throw new Error("miss the main function");
}
const paramsName = `__verge${Math.floor(Math.random() * 1000)}`;
const code = `'use strict';${script};return main(${paramsName});`;
const func = new Function(paramsName, code);
return func(data);
}
export type EStatus = { status: "ok" | "error"; message?: string };
export type EListener = (status: EStatus) => void;
export type EUnlistener = () => void;
/**
* The service helps to
* implement enhanced profiles
*/
class Enhance {
private isSetup = false;
private listenMap: Map<string, EListener>;
private resultMap: Map<string, EStatus>;
constructor() {
this.listenMap = new Map();
this.resultMap = new Map();
}
// setup some listener
// for the enhanced running status
listen(uid: string, cb: EListener): EUnlistener {
this.listenMap.set(uid, cb);
return () => this.listenMap.delete(uid);
}
// get the running status
status(uid: string): EStatus | undefined {
return this.resultMap.get(uid);
}
async enhanceHandler(event: Event<unknown>) {
const payload = event.payload as CmdType.EnhancedPayload;
const result = await this.runner(payload).catch((err: any) => ({
data: null,
status: "error",
error: err.message,
}));
emit(payload.callback, JSON.stringify(result)).catch(console.error);
}
// setup the handler
setup() {
if (this.isSetup) return;
this.isSetup = true;
listen("script-handler", async (event) => {
await this.enhanceHandler(event);
});
listen("script-handler-close", async (event) => {
await this.enhanceHandler(event);
appWindow.close();
});
}
// enhanced mode runner
private async runner(payload: CmdType.EnhancedPayload) {
const chain = payload.chain || [];
const valid = payload.valid || [];
if (!Array.isArray(chain)) throw new Error("unhandle error");
let pdata = payload.current || {};
let useList = valid;
for (const each of chain) {
const { uid, type = "" } = each.item;
try {
// process script
if (type === "script") {
// support async main function
pdata = await toScript(each.script!, ignoreCase(pdata));
}
// process merge
else if (type === "merge") {
const temp = toMerge(each.merge!, ignoreCase(pdata));
pdata = temp.data;
useList = useList.concat(temp.use || []);
}
// invalid type
else {
throw new Error(`invalid enhanced profile type "${type}"`);
}
this.exec(uid, { status: "ok" });
} catch (err: any) {
console.error(err);
this.exec(uid, {
status: "error",
message: err.message || err.toString(),
});
}
}
pdata = ignoreCase(pdata);
// filter the data
const filterData: typeof pdata = {};
Object.keys(pdata).forEach((key: any) => {
if (
DEFAULT_FIELDS.includes(key) ||
(USE_FLAG_FIELDS.includes(key) && useList.includes(key))
) {
filterData[key] = pdata[key];
}
});
return { data: filterData, status: "ok" };
}
// exec the listener
private exec(uid: string, status: EStatus) {
this.resultMap.set(uid, status);
this.listenMap.get(uid)?.(status);
}
}
export default new Enhance();
+2 -2
View File
@@ -1,7 +1,7 @@
import i18n from "i18next"; import i18n from "i18next";
import { initReactI18next } from "react-i18next"; import { initReactI18next } from "react-i18next";
import en from "../locales/en.json"; import en from "@/locales/en.json";
import zh from "../locales/zh.json"; import zh from "@/locales/zh.json";
const resources = { const resources = {
en: { translation: en }, en: { translation: en },
+5 -1
View File
@@ -1,5 +1,9 @@
import { atom } from "recoil"; import { atom } from "recoil";
import { ApiType } from "./types";
export const atomThemeMode = atom<"light" | "dark">({
key: "atomThemeMode",
default: "light",
});
export const atomClashPort = atom<number>({ export const atomClashPort = atom<number>({
key: "atomClashPort", key: "atomClashPort",
+37 -22
View File
@@ -1,8 +1,8 @@
/** /**
* Some interface for clash api * Some interface for clash api
*/ */
export namespace ApiType { declare namespace ApiType {
export interface ConfigData { interface ConfigData {
port: number; port: number;
mode: string; mode: string;
ipv6: boolean; ipv6: boolean;
@@ -15,13 +15,13 @@ export namespace ApiType {
"tproxy-port": number; "tproxy-port": number;
} }
export interface RuleItem { interface RuleItem {
type: string; type: string;
payload: string; payload: string;
proxy: string; proxy: string;
} }
export interface ProxyItem { interface ProxyItem {
name: string; name: string;
type: string; type: string;
udp: boolean; udp: boolean;
@@ -33,22 +33,22 @@ export namespace ApiType {
now?: string; now?: string;
} }
export type ProxyGroupItem = Omit<ProxyItem, "all"> & { type ProxyGroupItem = Omit<ProxyItem, "all"> & {
all: ProxyItem[]; all: ProxyItem[];
}; };
export interface TrafficItem { interface TrafficItem {
up: number; up: number;
down: number; down: number;
} }
export interface LogItem { interface LogItem {
type: string; type: string;
time?: string; time?: string;
payload: string; payload: string;
} }
export interface ConnectionsItem { interface ConnectionsItem {
id: string; id: string;
metadata: { metadata: {
network: string; network: string;
@@ -69,7 +69,7 @@ export namespace ApiType {
curDownload?: number; // calculate curDownload?: number; // calculate
} }
export interface Connections { interface Connections {
downloadTotal: number; downloadTotal: number;
uploadTotal: number; uploadTotal: number;
connections: ConnectionsItem[]; connections: ConnectionsItem[];
@@ -79,17 +79,17 @@ export namespace ApiType {
/** /**
* Some interface for command * Some interface for command
*/ */
export namespace CmdType { declare namespace CmdType {
export type ProfileType = "local" | "remote" | "merge" | "script"; type ProfileType = "local" | "remote" | "merge" | "script";
export interface ClashInfo { interface ClashInfo {
status: string; status: string;
port?: string; port?: string;
server?: string; server?: string;
secret?: string; secret?: string;
} }
export interface ProfileItem { interface ProfileItem {
uid: string; uid: string;
type?: ProfileType | string; type?: ProfileType | string;
name?: string; name?: string;
@@ -110,23 +110,23 @@ export namespace CmdType {
option?: ProfileOption; option?: ProfileOption;
} }
export interface ProfileOption { interface ProfileOption {
user_agent?: string; user_agent?: string;
with_proxy?: boolean; with_proxy?: boolean;
update_interval?: number; update_interval?: number;
} }
export interface ProfilesConfig { interface ProfilesConfig {
current?: string; current?: string;
chain?: string[]; chain?: string[];
valid?: string[]; valid?: string[];
items?: ProfileItem[]; items?: ProfileItem[];
} }
export interface VergeConfig { interface VergeConfig {
language?: string; language?: string;
clash_core?: string; clash_core?: string;
theme_mode?: "light" | "dark"; theme_mode?: "light" | "dark" | "system";
theme_blur?: boolean; theme_blur?: boolean;
traffic_graph?: boolean; traffic_graph?: boolean;
enable_tun_mode?: boolean; enable_tun_mode?: boolean;
@@ -136,6 +136,7 @@ export namespace CmdType {
enable_system_proxy?: boolean; enable_system_proxy?: boolean;
enable_proxy_guard?: boolean; enable_proxy_guard?: boolean;
system_proxy_bypass?: string; system_proxy_bypass?: string;
web_ui_list?: string[];
theme_setting?: { theme_setting?: {
primary_color?: string; primary_color?: string;
secondary_color?: string; secondary_color?: string;
@@ -152,7 +153,7 @@ export namespace CmdType {
type ClashConfigValue = any; type ClashConfigValue = any;
export interface ProfileMerge { interface ProfileMerge {
// clash config fields (default supports) // clash config fields (default supports)
rules?: ClashConfigValue; rules?: ClashConfigValue;
proxies?: ClashConfigValue; proxies?: ClashConfigValue;
@@ -176,10 +177,24 @@ export namespace CmdType {
"append-proxies"?: any[]; "append-proxies"?: any[];
"prepend-proxy-groups"?: any[]; "prepend-proxy-groups"?: any[];
"append-proxy-groups"?: any[]; "append-proxy-groups"?: any[];
// fix
ebpf?: any;
experimental?: any;
iptables?: any;
sniffer?: any;
authentication?: any;
"bind-address"?: any;
"external-ui"?: any;
"auto-redir"?: any;
"socks-port"?: any;
"redir-port"?: any;
"tproxy-port"?: any;
"geodata-mode"?: any;
"tcp-concurrent"?: any;
} }
// partial of the clash config // partial of the clash config
export type ProfileData = Partial<{ type ProfileData = Partial<{
rules: any[]; rules: any[];
proxies: any[]; proxies: any[];
"proxy-groups": any[]; "proxy-groups": any[];
@@ -189,20 +204,20 @@ export namespace CmdType {
[k: string]: any; [k: string]: any;
}>; }>;
export interface ChainItem { interface ChainItem {
item: ProfileItem; item: ProfileItem;
merge?: ProfileMerge; merge?: ProfileMerge;
script?: string; script?: string;
} }
export interface EnhancedPayload { interface EnhancedPayload {
chain: ChainItem[]; chain: ChainItem[];
valid: string[]; valid: string[];
current: ProfileData; current: ProfileData;
callback: string; callback: string;
} }
export interface EnhancedResult { interface EnhancedResult {
data: ProfileData; data: ProfileData;
status: string; status: string;
error?: string; error?: string;
+42
View File
@@ -0,0 +1,42 @@
export const HANDLE_FIELDS = [
"port",
"socks-port",
"mixed-port",
"allow-lan",
"mode",
"log-level",
"ipv6",
"secret",
"external-controller",
];
export const DEFAULT_FIELDS = [
"rules",
"proxies",
"proxy-groups",
"proxy-providers",
"rule-providers",
] as const;
export const OTHERS_FIELDS = [
"tun",
"dns",
"ebpf",
"hosts",
"script",
"profile",
"payload",
"auto-redir",
"experimental",
"interface-name",
"routing-mark",
"redir-port",
"tproxy-port",
"iptables",
"external-ui",
"bind-address",
"authentication",
"sniffer", // meta
"geodata-mode", // meta
"tcp-concurrent", // meta
] as const;
+1 -1
View File
@@ -2,7 +2,7 @@
type TData = Record<string, any>; type TData = Record<string, any>;
export default function ignoreCase(data: TData): TData { export default function ignoreCase(data: TData): TData {
if (!data) return data; if (!data) return {};
const newData = {} as TData; const newData = {} as TData;
+6 -1
View File
@@ -1,5 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": ".",
"target": "ESNext", "target": "ESNext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"], "lib": ["DOM", "DOM.Iterable", "ESNext"],
@@ -14,7 +15,11 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "noEmit": true,
"jsx": "react-jsx" "jsx": "react-jsx",
"paths": {
"@/*": ["src/*"],
"@root/*": ["./*"]
}
}, },
"include": ["./src"] "include": ["./src"]
} }
+15 -1
View File
@@ -1,4 +1,5 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import path from "path";
import svgr from "vite-plugin-svgr"; import svgr from "vite-plugin-svgr";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import monaco from "vite-plugin-monaco-editor"; import monaco from "vite-plugin-monaco-editor";
@@ -6,9 +7,22 @@ import monaco from "vite-plugin-monaco-editor";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
root: "src", root: "src",
plugins: [svgr(), react(), monaco()], plugins: [
svgr(),
react(),
monaco({ languageWorkers: ["editorWorkerService", "typescript"] }),
],
build: { build: {
outDir: "../dist", outDir: "../dist",
emptyOutDir: true, emptyOutDir: true,
}, },
resolve: {
alias: {
"@": path.resolve("./src"),
"@root": path.resolve("."),
},
},
define: {
WIN_PORTABLE: !!process.env.VITE_WIN_PORTABLE,
},
}); });
+164 -193
View File
@@ -376,17 +376,6 @@
source-map "^0.5.7" source-map "^0.5.7"
stylis "4.0.13" stylis "4.0.13"
"@emotion/cache@^11.7.1":
version "11.7.1"
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-11.7.1.tgz#08d080e396a42e0037848214e8aa7bf879065539"
integrity sha512-r65Zy4Iljb8oyjtLeCuBH8Qjiy107dOYC6SJq7g7GV5UCQWMObY4SJDPGFjiiVpPrOJ2hmJOoBiYTC7hwx9E2A==
dependencies:
"@emotion/memoize" "^0.7.4"
"@emotion/sheet" "^1.1.0"
"@emotion/utils" "^1.0.0"
"@emotion/weak-memoize" "^0.2.5"
stylis "4.0.13"
"@emotion/cache@^11.9.3": "@emotion/cache@^11.9.3":
version "11.9.3" version "11.9.3"
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-11.9.3.tgz#96638449f6929fd18062cfe04d79b29b44c0d6cb" resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-11.9.3.tgz#96638449f6929fd18062cfe04d79b29b44c0d6cb"
@@ -403,13 +392,6 @@
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413" resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413"
integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow== integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==
"@emotion/is-prop-valid@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.1.2.tgz#34ad6e98e871aa6f7a20469b602911b8b11b3a95"
integrity sha512-3QnhqeL+WW88YjYbQL5gUIkthuMw7a0NGbZ7wfFVk2kg/CK5w8w5FFa0RzWjyY1+sujN0NWbtSHH6OJmWHtJpQ==
dependencies:
"@emotion/memoize" "^0.7.4"
"@emotion/is-prop-valid@^1.1.3": "@emotion/is-prop-valid@^1.1.3":
version "1.1.3" version "1.1.3"
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.1.3.tgz#f0907a416368cf8df9e410117068e20fe87c0a3a" resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.1.3.tgz#f0907a416368cf8df9e410117068e20fe87c0a3a"
@@ -457,11 +439,6 @@
"@emotion/utils" "^1.0.0" "@emotion/utils" "^1.0.0"
csstype "^3.0.2" csstype "^3.0.2"
"@emotion/sheet@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.1.0.tgz#56d99c41f0a1cda2726a05aa6a20afd4c63e58d2"
integrity sha512-u0AX4aSo25sMAygCuQTzS+HsImZFuS8llY8O7b9MDRzbJM0kVJlAz6KNDqcG7pOuQZJmj/8X/rAW+66kMnMW+g==
"@emotion/sheet@^1.1.1": "@emotion/sheet@^1.1.1":
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.1.1.tgz#015756e2a9a3c7c5f11d8ec22966a8dbfbfac787" resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.1.1.tgz#015756e2a9a3c7c5f11d8ec22966a8dbfbfac787"
@@ -524,92 +501,92 @@
"@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/sourcemap-codec" "^1.4.10"
"@mui/base@5.0.0-alpha.84": "@mui/base@5.0.0-alpha.89":
version "5.0.0-alpha.84" version "5.0.0-alpha.89"
resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-alpha.84.tgz#83c580c9b04b4e4efe3fb39572720470b0d7cc29" resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-alpha.89.tgz#d72681fa20e05297b426e113c47a0912b59c8b44"
integrity sha512-uDx+wGVytS+ZHiWHyzUyijY83GSIXJpzSJ0PGc/8/s+8nBzeHvaPKrAyJz15ASLr52hYRA6PQGqn0eRAsB7syQ== integrity sha512-2g18hzt947qQ3gQQPOPEBfzQmaT2wafVhyJ7ZOZXeU6kKb88MdlHoPkK2lKXCHMBtRGnnsiF36j0rmhQXu0I5g==
dependencies: dependencies:
"@babel/runtime" "^7.17.2" "@babel/runtime" "^7.17.2"
"@emotion/is-prop-valid" "^1.1.2" "@emotion/is-prop-valid" "^1.1.3"
"@mui/types" "^7.1.3" "@mui/types" "^7.1.4"
"@mui/utils" "^5.8.0" "@mui/utils" "^5.9.0"
"@popperjs/core" "^2.11.5" "@popperjs/core" "^2.11.5"
clsx "^1.1.1" clsx "^1.2.1"
prop-types "^15.8.1" prop-types "^15.8.1"
react-is "^17.0.2" react-is "^18.2.0"
"@mui/icons-material@^5.8.3": "@mui/icons-material@^5.8.4":
version "5.8.3" version "5.8.4"
resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.8.3.tgz#75c8bde42e6ba71e3871439a2b751be987343493" resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.8.4.tgz#3f2907c9f8f5ce4d754cb8fb4b68b5a1abf4d095"
integrity sha512-dAdhimSLKOV0Q8FR7AYGEaCrTUh9OV7zU4Ueo5REoUt4cC3Vy+UBKDjZk66x5ezaYb63AFgQIFwtnZj3B/QDbQ== integrity sha512-9Z/vyj2szvEhGWDvb+gG875bOGm8b8rlHBKOD1+nA3PcgC3fV6W1AU6pfOorPeBfH2X4mb9Boe97vHvaSndQvA==
dependencies: dependencies:
"@babel/runtime" "^7.17.2" "@babel/runtime" "^7.17.2"
"@mui/material@^5.8.3": "@mui/material@^5.9.0":
version "5.8.3" version "5.9.0"
resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.8.3.tgz#86681d14c1a119d1d9b6b981c864736d075d095f" resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.9.0.tgz#e1cc4f67f16d337e9b94939caa8d6905db45d4e4"
integrity sha512-8UecY/W9SMtEZm5PMCUcMbujajVP6fobu0BgBPiIWwwWRblZVEzqprY6v1P2me7qCyrve4L4V/rqAKPKhVHOSg== integrity sha512-KZN3QEeCtwSP1IRpDZ7KQghDX7tyxZojADRCn+UKnoq8HUGNMJm2XKdb7hy9/ybaSW4EXQSKXSGg1AjdfS7Cdg==
dependencies: dependencies:
"@babel/runtime" "^7.17.2" "@babel/runtime" "^7.17.2"
"@mui/base" "5.0.0-alpha.84" "@mui/base" "5.0.0-alpha.89"
"@mui/system" "^5.8.3" "@mui/system" "^5.9.0"
"@mui/types" "^7.1.3" "@mui/types" "^7.1.4"
"@mui/utils" "^5.8.0" "@mui/utils" "^5.9.0"
"@types/react-transition-group" "^4.4.4" "@types/react-transition-group" "^4.4.5"
clsx "^1.1.1" clsx "^1.2.1"
csstype "^3.1.0" csstype "^3.1.0"
hoist-non-react-statics "^3.3.2"
prop-types "^15.8.1" prop-types "^15.8.1"
react-is "^17.0.2" react-is "^18.2.0"
react-transition-group "^4.4.2" react-transition-group "^4.4.2"
"@mui/private-theming@^5.8.0": "@mui/private-theming@^5.9.0":
version "5.8.0" version "5.9.0"
resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.8.0.tgz#7d927e7e12616dc10b0dcbe665df2c00ed859796" resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.9.0.tgz#d2437ed95ecfa3bfc9d2ee7c6053c94d4931cb26"
integrity sha512-MjRAneTmCKLR9u2S4jtjLUe6gpHxlbb4g2bqpDJ2PdwlvwsWIUzbc/gVB4dvccljXeWxr5G2M/Co2blXisvFIw== integrity sha512-t0ZsWxE/LvX5RH5azjx1esBHbIfD9zjnbSAYkpE59BPpkOrqAYDGoJguL2EPd9LaUb6COmBozmAwNenvI6RJRQ==
dependencies: dependencies:
"@babel/runtime" "^7.17.2" "@babel/runtime" "^7.17.2"
"@mui/utils" "^5.8.0" "@mui/utils" "^5.9.0"
prop-types "^15.8.1" prop-types "^15.8.1"
"@mui/styled-engine@^5.8.0": "@mui/styled-engine@^5.8.7":
version "5.8.0" version "5.8.7"
resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.8.0.tgz#89ed42efe7c8749e5a60af035bc5d3a6bea362bf" resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.8.7.tgz#63d0779c07677fe76d4705a02c7ae99f89b50780"
integrity sha512-Q3spibB8/EgeMYHc+/o3RRTnAYkSl7ROCLhXJ830W8HZ2/iDiyYp16UcxKPurkXvLhUaILyofPVrP3Su2uKsAw== integrity sha512-tVqtowjbYmiRq+qcqXK731L9eWoL9H8xTRhuTgaDGKdch1zlt4I2UwInUe1w2N9N/u3/jHsFbLcl1Un3uOwpQg==
dependencies: dependencies:
"@babel/runtime" "^7.17.2" "@babel/runtime" "^7.17.2"
"@emotion/cache" "^11.7.1" "@emotion/cache" "^11.9.3"
prop-types "^15.8.1"
"@mui/system@^5.8.3":
version "5.8.3"
resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.8.3.tgz#66db174f1b5c244eb73dbc48527509782a22ec0a"
integrity sha512-/tyGQcYqZT0nl98qV9XnGiedTO+V7VHc28k4POfhMJNedB1CRrwWRm767DeEdc5f/8CU2See3WD16ikP6pYiOA==
dependencies:
"@babel/runtime" "^7.17.2"
"@mui/private-theming" "^5.8.0"
"@mui/styled-engine" "^5.8.0"
"@mui/types" "^7.1.3"
"@mui/utils" "^5.8.0"
clsx "^1.1.1"
csstype "^3.1.0" csstype "^3.1.0"
prop-types "^15.8.1" prop-types "^15.8.1"
"@mui/types@^7.1.3": "@mui/system@^5.9.0":
version "7.1.3" version "5.9.0"
resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.1.3.tgz#d7636f3046110bcccc63e6acfd100e2ad9ca712a" resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.9.0.tgz#804055bc6fcd557479b8b28dfca7ed5c98fd9bf9"
integrity sha512-DDF0UhMBo4Uezlk+6QxrlDbchF79XG6Zs0zIewlR4c0Dt6GKVFfUtzPtHCH1tTbcSlq/L2bGEdiaoHBJ9Y1gSA== integrity sha512-KLZDYMmT1usokEJH+raGTh1SbdOx4BVrT+wg8nRpKGNii2sfc3ntuJSKuv3Fu9oeC9xVFTnNBHXKrpJuxeDcqg==
dependencies:
"@babel/runtime" "^7.17.2"
"@mui/private-theming" "^5.9.0"
"@mui/styled-engine" "^5.8.7"
"@mui/types" "^7.1.4"
"@mui/utils" "^5.9.0"
clsx "^1.2.1"
csstype "^3.1.0"
prop-types "^15.8.1"
"@mui/utils@^5.8.0": "@mui/types@^7.1.4":
version "5.8.0" version "7.1.4"
resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.8.0.tgz#4b1d19cbcf70773283375e763b7b3552b84cb58f" resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.1.4.tgz#4185c05d6df63ec673cda15feab80440abadc764"
integrity sha512-7LgUtCvz78676iC0wpTH7HizMdCrTphhBmRWimIMFrp5Ph6JbDFVuKS1CwYnWWxRyYKL0QzXrDL0lptAU90EXg== integrity sha512-uveM3byMbthO+6tXZ1n2zm0W3uJCQYtwt/v5zV5I77v2v18u0ITkb8xwhsDD2i3V2Kye7SaNR6FFJ6lMuY/WqQ==
"@mui/utils@^5.9.0":
version "5.9.0"
resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.9.0.tgz#2e1ac58905b767de47412cb32475862875b8e880"
integrity sha512-GAaiWP6zBC3RE1NHP9y1c1iKZh5s/nyKKqWxfTrw5lNQY5tWTh9/47F682FuiE5WT1o3h4w/LEkSSIZpMEDzrA==
dependencies: dependencies:
"@babel/runtime" "^7.17.2" "@babel/runtime" "^7.17.2"
"@types/prop-types" "^15.7.5" "@types/prop-types" "^15.7.5"
"@types/react-is" "^16.7.1 || ^17.0.0" "@types/react-is" "^16.7.1 || ^17.0.0"
prop-types "^15.8.1" prop-types "^15.8.1"
react-is "^17.0.2" react-is "^18.2.0"
"@octokit/auth-token@^2.4.4": "@octokit/auth-token@^2.4.4":
version "2.5.0" version "2.5.0"
@@ -791,72 +768,70 @@
"@svgr/hast-util-to-babel-ast" "^6.2.1" "@svgr/hast-util-to-babel-ast" "^6.2.1"
svg-parser "^2.0.2" svg-parser "^2.0.2"
"@tauri-apps/api@^1.0.1": "@tauri-apps/api@^1.0.2":
version "1.0.1" version "1.0.2"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.1.tgz#f516cf3b83139312141123c08f1d75260274da50" resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.2.tgz#5228720e35d50fd08df87067dc29e7306c1f7a10"
integrity sha512-TJwKkXxtF52kN9Auu5TWD2AE4ssqTrsfdpIrixYwRb3gQ/FuYwvZjrMc9weYpgsW2cMhVNkvKgneNXF/4n04lw== integrity sha512-yuNW0oeJ1/ZA7wNF1KgxhHrSu5viPVzY/UgUczzN5ptLM8dH15Juy5rEGkoHfeXGju90Y/l22hi3BtIrp/za+w==
dependencies:
type-fest "2.13.1"
"@tauri-apps/cli-darwin-arm64@1.0.0": "@tauri-apps/cli-darwin-arm64@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.0.tgz#9ab439898b4d05a6e43df4451a42fa21e9d5eaa1" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.4.tgz#fd63fad851c8c899233618af0a9dc2d1a29a8c41"
integrity sha512-0ryomgLjdpylXypMPVXLU3PZCde3Sw5nwN4coUhBcHPBLFRb8QPet+nweVK/HiZ3mxg8WeIazvpx2s8hS0l2GQ== integrity sha512-hMVTPoinjKYV8fgviQ871ZnVipAVXJV3ZwfiK9FcE9/dkUCUtKtetfwnicRV6YDSFbWY9qAg+Sm0INrLT5Ky+A==
"@tauri-apps/cli-darwin-x64@1.0.0": "@tauri-apps/cli-darwin-x64@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.0.tgz#5ffc8d444c7dc1cab14c8c743a929e448f1b1e93" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.4.tgz#52e7a4151a26e9333375a82a0cb15614f01cf3e0"
integrity sha512-oejvYUT4dEfzBi+FWMj+CMz4cZ6C2gEFHrUtKVLdTXr8Flj5UTwdB1YPGQjiOqk73LOI7cB/vXxb9DZT+Lrxgg== integrity sha512-6bR8WIqJdcutLLcmv4S+bkCRbLAwjl80zPL97vs7Zgum01aeygjUTaZS46fpeDgqF8nR8piFAZkz8Bnco6fbzw==
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.0": "@tauri-apps/cli-linux-arm-gnueabihf@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.0.tgz#c24d63b4637a0c20b9671f0284968b164482f6ee" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.4.tgz#8889ce864dba0763290fa3f05af99f8cd2f574bf"
integrity sha512-yAu78v8TeXNx/ETS5F2G2Uw/HX+LQvZkX94zNiqFsAj7snfWI/IqSUM52OBrdh/D0EC9NCdjUJ7Vuo32uxf7tg== integrity sha512-NNhz8Nh/CQvAPzR5bj1sC2CgpkUOjZg8Eg1i/Ta/pbrjgT0E/reD+12TGdkNuQNEOUQ1klWcdeHfAptWPicRgQ==
"@tauri-apps/cli-linux-arm64-gnu@1.0.0": "@tauri-apps/cli-linux-arm64-gnu@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.0.tgz#dfb107a3d5f56dc0356126135f941261ffad10a3" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.4.tgz#27ae14f15d5fef76dcb70b4d7dac7bbb9e13ea81"
integrity sha512-YFUN/S58AN317njAynzcQ+EHhRsCDXqmp5g9Oiqmcdg1vU7fPWZivVLc1WHz+0037C7JnsX5PtKpNYewP/+Oqw== integrity sha512-chzpMgkZyu0MWF75DDiEV06XyI8LM7q0NMxRx7esJwZpypj4AG0Pj4+9Di38zYWZrfYqz/bWrCMPIV30vty1Gg==
"@tauri-apps/cli-linux-arm64-musl@1.0.0": "@tauri-apps/cli-linux-arm64-musl@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.0.tgz#72ebfc5066c6fac82b513c20fbec6ab841b3ee05" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.4.tgz#118a44226c3e0c324b9c842718548b22fcfbd3d2"
integrity sha512-al+TxMGoNVikEvRQfMyYE/mdjUcUNMo5brkCIAb+fL4rWQlAhAnYVzmg/rM8N4nhdXm1MOaYAagQmxr8898dNA== integrity sha512-w+wbNoIOdHoV65Q/z29EK4KtFiNXfV+2lIsML/Hw0VEJEzl9FsqGelu1zAycq8hkoQhf0yPlD/m4FfAWnFzg6Q==
"@tauri-apps/cli-linux-x64-gnu@1.0.0": "@tauri-apps/cli-linux-x64-gnu@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.0.tgz#76f791378468a9ca2678885f0d14e05f4fd0d0c8" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.4.tgz#1724345de55a597a7fbd363f3af33ebf4eaaad4d"
integrity sha512-KQmYlYyGpn6/2kSl9QivWG6EIepm6PJd57e6IKmYwAyNhLr2XfGl1CLuocUQQgO+jprjT70HXp+MXD0tcB0+Sw== integrity sha512-TiVRk+VBYA2mE4DqwLu/WD6wTHewHVbdMUtfeXdwe/kabLqbJTWuswUv5T8JUp3mYFZKqlPhyi+qWSJOc0Ianw==
"@tauri-apps/cli-linux-x64-musl@1.0.0": "@tauri-apps/cli-linux-x64-musl@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.0.tgz#12ccc0747c88e9c2cbdf21834b94718c8da689ca" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.4.tgz#b36904c42be4bdab21cefdd052c8c85f9913f6be"
integrity sha512-Qpaq5lZz569Aea6jfrRchgfEJaOrfLpCRBATcF8CJFFwVKmfCUcoV+MxbCIW30Zqw5Y06njC/ffa3261AV/ZIQ== integrity sha512-TKdncZ6aFu9PfHakrrqg3XIoxgl510rN0tOTJuZ1WQT2nDD5zlP3Mo++FNIt6/TfjqayLcubIZp3dG9pU383dA==
"@tauri-apps/cli-win32-ia32-msvc@1.0.0": "@tauri-apps/cli-win32-ia32-msvc@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.0.tgz#5d56df6dbb62c11cae28b826619fbbad9a158399" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.4.tgz#6db7d26050f15fca0ad067119001e566085990f5"
integrity sha512-e2DzFqEMI+s+gv14UupdI91gPxTbUJTbbfQlTHdQlOsTk4HEZTsh+ibAYBcCLAaMRW38NEsFlAUe1lQA0iRu/w== integrity sha512-KedA4LB/PsePE3BLm2gg/IIA4rLjbyBUzV2FTdpWqx8ws3OzL6BLDGRVJ+zXe/b9SddhhZk7Rqss6y+gtsWKsA==
"@tauri-apps/cli-win32-x64-msvc@1.0.0": "@tauri-apps/cli-win32-x64-msvc@1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.0.tgz#6227331d177118323cff13bc6bfb04894130c83f" resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.4.tgz#bf14bb0cfa2c0e74a981c6424dc36f68dbfd4b5c"
integrity sha512-lWSs90pJeQX+L31IqIzmRhwLayEeyTh7mga0AxX8G868hvdLtcXCQA/rKoFtGdVLuHAx4+M+CBF5SMYb76xGYA== integrity sha512-6m1Ie7+YeKdOY7aXZCw/Py30DeMEAukE2+WWuZgfxZTTG9QrnZO+DbaKtjuEG0A8HKHCz63+ZNxOTshS1ognEw==
"@tauri-apps/cli@^1.0.0": "@tauri-apps/cli@^1.0.4":
version "1.0.0" version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.0.tgz#28f021a2db4c2087b569845d42b4fe7978ccee19" resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.4.tgz#4a943d10ff022ae6ad9fb33e94cc5c25509bcfb9"
integrity sha512-4eHnk3p0xnCXd9Zel3kLvdiiSURnN98GMFvWUAdirm5AjyOjcx8TIET/jqRYmYKE5yd+LMQqYMUfHRwA6JJUkg== integrity sha512-AqfbQUFU2jDYmkjiowl+Yv1yNkey/e+N23sKyDtXQQNvxE6ieR4voY4i6bShY97F+DbRVdjWcjGiLkWS3i4DHw==
optionalDependencies: optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "1.0.0" "@tauri-apps/cli-darwin-arm64" "1.0.4"
"@tauri-apps/cli-darwin-x64" "1.0.0" "@tauri-apps/cli-darwin-x64" "1.0.4"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.0" "@tauri-apps/cli-linux-arm-gnueabihf" "1.0.4"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.0" "@tauri-apps/cli-linux-arm64-gnu" "1.0.4"
"@tauri-apps/cli-linux-arm64-musl" "1.0.0" "@tauri-apps/cli-linux-arm64-musl" "1.0.4"
"@tauri-apps/cli-linux-x64-gnu" "1.0.0" "@tauri-apps/cli-linux-x64-gnu" "1.0.4"
"@tauri-apps/cli-linux-x64-musl" "1.0.0" "@tauri-apps/cli-linux-x64-musl" "1.0.4"
"@tauri-apps/cli-win32-ia32-msvc" "1.0.0" "@tauri-apps/cli-win32-ia32-msvc" "1.0.4"
"@tauri-apps/cli-win32-x64-msvc" "1.0.0" "@tauri-apps/cli-win32-x64-msvc" "1.0.4"
"@types/fs-extra@^9.0.13": "@types/fs-extra@^9.0.13":
version "9.0.13" version "9.0.13"
@@ -919,10 +894,10 @@
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
"@types/react-transition-group@^4.4.4": "@types/react-transition-group@^4.4.5":
version "4.4.4" version "4.4.5"
resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.4.tgz#acd4cceaa2be6b757db61ed7b432e103242d163e" resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.5.tgz#aae20dcf773c5aa275d5b9f7cdbca638abc5e416"
integrity sha512-7gAPz7anVK5xzbeQW9wFBDg7G++aPLAFY0QaSMOou9rJZpbuI58WAuJrgu+qR92l61grlnCUe7AFX8KGahAgug== integrity sha512-juKD/eiSM3/xZYzjuzH6ZwpP+/lejltmiS3QEzV/vmb/Q8+HfDmxu+Baga8UEMGBqV88Nbg4l2hY/K2DkyaLLA==
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
@@ -983,10 +958,10 @@ ahooks-v3-count@^1.0.0:
resolved "https://registry.yarnpkg.com/ahooks-v3-count/-/ahooks-v3-count-1.0.0.tgz#ddeb392e009ad6e748905b3cbf63a9fd8262ca80" resolved "https://registry.yarnpkg.com/ahooks-v3-count/-/ahooks-v3-count-1.0.0.tgz#ddeb392e009ad6e748905b3cbf63a9fd8262ca80"
integrity sha512-V7uUvAwnimu6eh/PED4mCDjE7tokeZQLKlxg9lCTMPhN+NjsSbtdacByVlR1oluXQzD3MOw55wylDmQo4+S9ZQ== integrity sha512-V7uUvAwnimu6eh/PED4mCDjE7tokeZQLKlxg9lCTMPhN+NjsSbtdacByVlR1oluXQzD3MOw55wylDmQo4+S9ZQ==
ahooks@^3.4.1: ahooks@^3.5.2:
version "3.4.1" version "3.5.2"
resolved "https://registry.yarnpkg.com/ahooks/-/ahooks-3.4.1.tgz#6ce6859039c529311344dc840fe4021680de901a" resolved "https://registry.yarnpkg.com/ahooks/-/ahooks-3.5.2.tgz#283e4b2796d3e00f0a280f0f09e2517feaa434e3"
integrity sha512-PMxCDO6JsFdNrAyN3cW1J/2qt/vy2EJ/9KhxGOxj41hJhQddjgaBJjZKf/FrrnZmL+3yGPioZtbC4C7q7ru3yA== integrity sha512-0OrV3/9s339comBg/F+d9Q7lhZERZK3K5f1J8ebK3z076Kc4KkeGc1MLalFRG+95nVA0wUCZ71oJMs66fIU2Uw==
dependencies: dependencies:
"@types/js-cookie" "^2.x.x" "@types/js-cookie" "^2.x.x"
ahooks-v3-count "^1.0.0" ahooks-v3-count "^1.0.0"
@@ -1160,10 +1135,10 @@ chalk@^3.0.0:
optionalDependencies: optionalDependencies:
fsevents "~2.3.2" fsevents "~2.3.2"
clsx@^1.1.1: clsx@^1.2.1:
version "1.1.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188" resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12"
integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA== integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==
color-convert@^1.9.0: color-convert@^1.9.0:
version "1.9.3" version "1.9.3"
@@ -1612,7 +1587,7 @@ history@^5.2.0:
dependencies: dependencies:
"@babel/runtime" "^7.7.6" "@babel/runtime" "^7.7.6"
hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2: hoist-non-react-statics@^3.3.1:
version "3.3.2" version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -1649,10 +1624,10 @@ husky@^7.0.0:
resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535" resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535"
integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ== integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==
i18next@^21.8.9: i18next@^21.8.12:
version "21.8.9" version "21.8.12"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.8.9.tgz#c79edd5bba61e0a0d5b43a93d52e2d13a526de82" resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.8.12.tgz#30a1ca4a9556d9d523c9dad0fa3c01f81aa5ee72"
integrity sha512-PY9a/8ADVmnju1tETeglbbVQi+nM5pcJQWm9kvKMTE3GPgHHtpDsHy5HQ/hccz2/xtW7j3vuso23JdQSH0EttA== integrity sha512-BCJsQq9DtmLb88ksPZgpjbXhPAhFmDTNrY2Jh8VvgwnTHvL8xbuSribdTsi2WPRk1kbhjtbkoqyCVr12w2XTCA==
dependencies: dependencies:
"@babel/runtime" "^7.17.2" "@babel/runtime" "^7.17.2"
@@ -2028,10 +2003,10 @@ react-dom@^17.0.2:
object-assign "^4.1.1" object-assign "^4.1.1"
scheduler "^0.20.2" scheduler "^0.20.2"
react-i18next@^11.17.1: react-i18next@^11.17.4:
version "11.17.1" version "11.17.4"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-11.17.1.tgz#3a5309ac6c093b4c556c7f8a0a808c034929040c" resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-11.17.4.tgz#fe72ac0ccacc73ae0a00fed503eb3dd3f73016c1"
integrity sha512-4H4fK9vWsQtPP0iAdqzGfdPKLaSXpCjuh1xaGsejX/CO8tx8zCnrOnlQhMgrJf+OlUfzth5YaDPXYGp3RHxV1g== integrity sha512-LswEIl8KNDTP4Wk3c22XDstbR++Vc4BZyNwvGFGaYbYDjdDLkHDLwrgd7DN28f8jufFHaYhQvCG5YWLxFhRt/g==
dependencies: dependencies:
"@babel/runtime" "^7.14.5" "@babel/runtime" "^7.14.5"
html-escaper "^2.0.2" html-escaper "^2.0.2"
@@ -2042,10 +2017,10 @@ react-is@^16.13.1, react-is@^16.7.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
react-is@^17.0.2: react-is@^18.2.0:
version "17.0.2" version "18.2.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
react-refresh@^0.13.0: react-refresh@^0.13.0:
version "0.13.0" version "0.13.0"
@@ -2077,10 +2052,10 @@ react-transition-group@^4.4.2:
loose-envify "^1.4.0" loose-envify "^1.4.0"
prop-types "^15.6.2" prop-types "^15.6.2"
react-virtuoso@^2.13.2: react-virtuoso@^2.16.1:
version "2.13.2" version "2.16.1"
resolved "https://registry.yarnpkg.com/react-virtuoso/-/react-virtuoso-2.13.2.tgz#dc5403e57e3e5aec0f4fe222f61e152f2a7f8017" resolved "https://registry.yarnpkg.com/react-virtuoso/-/react-virtuoso-2.16.1.tgz#0242ca410c4fb6be802e054b7ebd3f799d42efc5"
integrity sha512-DuZpTCC0rY5SAKPHQoZPKX3xAYN2iAGcG3P1Z7JVjq/8727usIwpSwvXGomyCvBIC2DHBX4yX46nVZ97+C6Pkw== integrity sha512-WpcHZedUe00XYSQ56KcdYmWy/oaiPPuweTYemC9gl8CbjchLTKqLPCJa51Yv32U9oj1XPAEMfxuaXM7NTtjOiw==
dependencies: dependencies:
"@virtuoso.dev/react-urx" "^0.2.12" "@virtuoso.dev/react-urx" "^0.2.12"
"@virtuoso.dev/urx" "^0.2.12" "@virtuoso.dev/urx" "^0.2.12"
@@ -2100,10 +2075,10 @@ readdirp@~3.6.0:
dependencies: dependencies:
picomatch "^2.2.1" picomatch "^2.2.1"
recoil@^0.6.1: recoil@^0.7.4:
version "0.6.1" version "0.7.4"
resolved "https://registry.yarnpkg.com/recoil/-/recoil-0.6.1.tgz#6fdf1ba6cb20b5a2e54ec4abcbdaa287e8a03fa2" resolved "https://registry.yarnpkg.com/recoil/-/recoil-0.7.4.tgz#d6508fa656d9c93e66fdf334e1f723a9e98801cf"
integrity sha512-J7oT3LZl2vpyFClgSUpOQjpykz84VSX/NJE/PavAtR8n7Z+whEdVBPUtwc2TEWjONeL/lJmiac2XQ+qEOQA52Q== integrity sha512-sCXvQGMfSprkNU4ZRkJV4B0qFQSURJMgsICqY1952WRlg66NMwYqi6n67vhnhn0qw4zHU1gHXJuMvRDaiRNFZw==
dependencies: dependencies:
hamt_plus "1.0.2" hamt_plus "1.0.2"
@@ -2143,10 +2118,10 @@ safe-buffer@~5.1.1:
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
sass@^1.52.3: sass@^1.53.0:
version "1.52.3" version "1.53.0"
resolved "https://registry.yarnpkg.com/sass/-/sass-1.52.3.tgz#b7cc7ffea2341ccc9a0c4fd372bf1b3f9be1b6cb" resolved "https://registry.yarnpkg.com/sass/-/sass-1.53.0.tgz#eab73a7baac045cc57ddc1d1ff501ad2659952eb"
integrity sha512-LNNPJ9lafx+j1ArtA7GyEJm9eawXN8KlA1+5dF6IZyoONg1Tyo/g+muOsENWJH/2Q1FHbbV4UwliU0cXMa/VIA== integrity sha512-zb/oMirbKhUgRQ0/GFz8TSAwRq2IlR29vOUJZOx0l8sV+CkHUfHa4u5nqrG+1VceZp7Jfj59SVW9ogdhTvJDcQ==
dependencies: dependencies:
chokidar ">=3.0.0 <4.0.0" chokidar ">=3.0.0 <4.0.0"
immutable "^4.0.0" immutable "^4.0.0"
@@ -2263,15 +2238,10 @@ tunnel@^0.0.6:
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
type-fest@2.13.1: typescript@^4.7.4:
version "2.13.1" version "4.7.4"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.13.1.tgz#621c84220df0e01a8469002594fc005714f0cfba" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-hXYyrPFwETT2swFLHeoKtJrvSF/ftG/sA15/8nGaLuaDGfVAaq8DYFpu4yOyV4tzp082WqnTEoMsm3flKMI2FQ== integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
typescript@^4.7.3:
version "4.7.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d"
integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==
universal-user-agent@^6.0.0: universal-user-agent@^6.0.0:
version "6.0.0" version "6.0.0"
@@ -2283,22 +2253,23 @@ universalify@^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"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
vite-plugin-monaco-editor@^1.0.10: vite-plugin-monaco-editor@^1.1.0:
version "1.0.10" version "1.1.0"
resolved "https://registry.yarnpkg.com/vite-plugin-monaco-editor/-/vite-plugin-monaco-editor-1.0.10.tgz#cd370f68d4121bced6f902c6284649cc8eca4170" resolved "https://registry.yarnpkg.com/vite-plugin-monaco-editor/-/vite-plugin-monaco-editor-1.1.0.tgz#a6238c2e13d5e98dd54a1bc51f6f189325219de3"
integrity sha512-7yTAFIE0SefjCmfnjrvXOl53wkxeSASc/ZIcB5tZeEK3vAmHhveV8y3f90Vp8b+PYdbUipjqf91mbFbSENkpcw== integrity sha512-IvtUqZotrRoVqwT0PBBDIZPNraya3BxN/bfcNfnxZ5rkJiGcNtO5eAOWWSgT7zullIAEqQwxMU83yL9J5k7gww==
vite-plugin-svgr@^2.1.0: vite-plugin-svgr@^2.2.0:
version "2.1.0" version "2.2.0"
resolved "https://registry.yarnpkg.com/vite-plugin-svgr/-/vite-plugin-svgr-2.1.0.tgz#cd66862da737949383e6d8f12d981958b9a65cc5" resolved "https://registry.yarnpkg.com/vite-plugin-svgr/-/vite-plugin-svgr-2.2.0.tgz#1943e070b24d91c30dc247d0475fe04393f74b31"
integrity sha512-3J19p8pmGfRt297yvc8Fd36+0AC0sLgA/gZYQDjotNAhv3CmSTQyviXIrDbwiRFVrsZjSlHJH1vca7OGFmjDcA== integrity sha512-CRJgz92vf3SQbt3jwF6/BhyQIhbY0pwbXAPqUh1/EMG6a4eHsHCECcDNrKZMhlRBj3LyXQSfHXJLtM2ISP5rfg==
dependencies: dependencies:
"@rollup/pluginutils" "^4.2.1"
"@svgr/core" "^6.2.1" "@svgr/core" "^6.2.1"
vite@^2.9.12: vite@^2.9.13:
version "2.9.12" version "2.9.13"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.12.tgz#b1d636b0a8ac636afe9d83e3792d4895509a941b" resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.13.tgz#859cb5d4c316c0d8c6ec9866045c0f7858ca6abc"
integrity sha512-suxC36dQo9Rq1qMB2qiRorNJtJAdxguu5TMvBHOc/F370KvqAe9t48vYp+/TbPKRNrMh/J55tOUmkuIqstZaew== integrity sha512-AsOBAaT0AD7Mhe8DuK+/kE4aWYFMx/i0ZNi98hJclxb4e0OhQcZYUrvLjIaQ8e59Ui7txcvKMiJC1yftqpQoDw==
dependencies: dependencies:
esbuild "^0.14.27" esbuild "^0.14.27"
postcss "^8.4.13" postcss "^8.4.13"