Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cff4e299b | ||
|
|
bce33639da | ||
|
|
366c465cad | ||
|
|
acc6e05bdc | ||
|
|
4ce15577cd | ||
|
|
98fa4d5e65 | ||
|
|
7fe94076c7 | ||
|
|
b8b0c8fa63 | ||
|
|
e585e87bec | ||
|
|
6a4924bb16 | ||
|
|
ab0d516d91 | ||
|
|
b756ae39d0 | ||
|
|
c15c38ea8f | ||
|
|
743963318f | ||
|
|
ed3fc50858 | ||
|
|
5b886fe6be | ||
|
|
7074bbc405 | ||
|
|
ef314c1707 | ||
|
|
a3e7626dd9 | ||
|
|
5cb5d74eed | ||
|
|
6eee10d46d | ||
|
|
2d95f2b0d6 | ||
|
|
ec41bb9c70 | ||
|
|
2d1780b1cf | ||
|
|
d9ce99887c | ||
|
|
9b9cc90414 | ||
|
|
c1eb539a5c | ||
|
|
e1793f57ef | ||
|
|
dbd09a8743 | ||
|
|
0d189ca617 | ||
|
|
dc9bcc40ee | ||
|
|
4991f7ff39 | ||
|
|
a393b8b122 | ||
|
|
c73b354386 | ||
|
|
392ecee3ff | ||
|
|
bae721c49e | ||
|
|
4e806e21a6 | ||
|
|
ec0fdf83b2 | ||
|
|
cb94d8414f | ||
|
|
8890051c17 | ||
|
|
cf00c9476f | ||
|
|
b2a24c7abd | ||
|
|
732a1f4694 | ||
|
|
4c5aa7084e | ||
|
|
fe1fea671c | ||
|
|
04c754c0ac | ||
|
|
754c22c84e | ||
|
|
629331870b | ||
|
|
78774315cb | ||
|
|
36b9c07928 | ||
|
|
40a818630d | ||
|
|
568511a4cf | ||
|
|
109fb39e09 | ||
|
|
68450d2042 | ||
|
|
8a052bbed6 | ||
|
|
3afbb56640 | ||
|
|
c0ad84a491 | ||
|
|
c72f17605c | ||
|
|
42fbee0cdb | ||
|
|
e9b7ec735f | ||
|
|
743788135f | ||
|
|
8ea3e6fa26 |
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, macos-11]
|
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
if: |
|
if: |
|
||||||
startsWith(github.repository, 'zzzgydi') &&
|
startsWith(github.repository, 'zzzgydi') &&
|
||||||
@@ -34,6 +34,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 14
|
||||||
|
|
||||||
|
- name: Install Dependencies (ubuntu only)
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
- name: Get yarn cache dir path
|
- name: Get yarn cache dir path
|
||||||
id: yarn-cache-dir-path
|
id: yarn-cache-dir-path
|
||||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||||
@@ -53,9 +59,9 @@ jobs:
|
|||||||
yarn run check
|
yarn run check
|
||||||
|
|
||||||
- name: Tauri build
|
- name: Tauri build
|
||||||
uses: tauri-apps/tauri-action@b9ce5d7dc68082d21d30a60103b0ab8c5ddae3a1
|
uses: tauri-apps/tauri-action@0e558392ccadcb49bcc89e7df15a400e8f0c954d
|
||||||
# enable cache even though failed
|
# enable cache even though failed
|
||||||
continue-on-error: true
|
# continue-on-error: true
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
@@ -67,9 +73,16 @@ jobs:
|
|||||||
releaseDraft: false
|
releaseDraft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
|
|
||||||
|
- name: Green zip bundle
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: |
|
||||||
|
yarn run green
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
release-update:
|
release-update:
|
||||||
needs: release
|
needs: release
|
||||||
runs-on: macos-11
|
runs-on: macos-latest
|
||||||
if: |
|
if: |
|
||||||
startsWith(github.repository, 'zzzgydi') &&
|
startsWith(github.repository, 'zzzgydi') &&
|
||||||
startsWith(github.ref, 'refs/tags/v')
|
startsWith(github.ref, 'refs/tags/v')
|
||||||
@@ -91,7 +104,7 @@ jobs:
|
|||||||
${{ runner.os }}-yarn-
|
${{ runner.os }}-yarn-
|
||||||
|
|
||||||
- name: Yarn install
|
- name: Yarn install
|
||||||
run: yarn
|
run: yarn install
|
||||||
|
|
||||||
- name: Release update.json
|
- name: Release update.json
|
||||||
run: yarn run release
|
run: yarn run release
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -11,7 +11,17 @@ A <a href="https://github.com/Dreamacro/clash">Clash</a> GUI based on <a href="h
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
Now it's no different from the others, maybe fewer. (WIP)
|
- Full `clash` config supported, Partial `clash premium` config supported.
|
||||||
|
- Profiles management and enhancement (by yaml and Javascript).
|
||||||
|
- System proxy setting and guard.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Download from [release](https://github.com/zzzgydi/clash-verge/releases). Supports Windows x64 and macOS 11+
|
||||||
|
|
||||||
|
Or you can build it yourself. Supports Windows, Linux and macOS 10.15+
|
||||||
|
|
||||||
|
Notes: If you could not start the app on Windows, please check that you have [Webview2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section) installed.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
@@ -33,6 +43,12 @@ Then run
|
|||||||
yarn dev
|
yarn dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or you can build it
|
||||||
|
|
||||||
|
```shell
|
||||||
|
yarn build
|
||||||
|
```
|
||||||
|
|
||||||
## Todos
|
## Todos
|
||||||
|
|
||||||
> This keng is a little big...
|
> This keng is a little big...
|
||||||
|
|||||||
29
UPDATELOG.md
Normal file
29
UPDATELOG.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## v0.0.24
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Connections page
|
||||||
|
- add wintun.dll (Windows)
|
||||||
|
- supports create local profile with selected file (Windows)
|
||||||
|
- system tray enable set system proxy
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- open dir error
|
||||||
|
- auto launch path (Windows)
|
||||||
|
- fix some clash config error
|
||||||
|
- reduce the impact of the enhanced mode
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v0.0.23
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- i18n supports
|
||||||
|
- Remote profile User Agent supports
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- clash config file case ignore
|
||||||
|
- clash `external-controller` only port
|
||||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "clash-verge",
|
"name": "clash-verge",
|
||||||
"version": "0.0.21",
|
"version": "0.0.24",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tauri dev",
|
"dev": "tauri dev",
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"web:build": "tsc && vite build",
|
"web:build": "tsc && vite build",
|
||||||
"web:serve": "vite preview",
|
"web:serve": "vite preview",
|
||||||
"check": "node scripts/check.mjs",
|
"check": "node scripts/check.mjs",
|
||||||
|
"green": "node scripts/green.mjs",
|
||||||
"publish": "node scripts/publish.mjs",
|
"publish": "node scripts/publish.mjs",
|
||||||
"release": "node scripts/release.mjs",
|
"release": "node scripts/release.mjs",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
@@ -19,20 +20,23 @@
|
|||||||
"@emotion/styled": "^11.8.1",
|
"@emotion/styled": "^11.8.1",
|
||||||
"@mui/icons-material": "^5.4.4",
|
"@mui/icons-material": "^5.4.4",
|
||||||
"@mui/material": "^5.4.4",
|
"@mui/material": "^5.4.4",
|
||||||
"@tauri-apps/api": "^1.0.0-rc.1",
|
"@tauri-apps/api": "^1.0.0-rc.2",
|
||||||
"ahooks": "^3.1.13",
|
"ahooks": "^3.1.13",
|
||||||
"axios": "^0.26.0",
|
"axios": "^0.26.0",
|
||||||
"dayjs": "^1.10.8",
|
"dayjs": "^1.10.8",
|
||||||
|
"i18next": "^21.6.14",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
|
"react-i18next": "^11.15.6",
|
||||||
"react-router-dom": "^6.2.2",
|
"react-router-dom": "^6.2.2",
|
||||||
"react-virtuoso": "^2.7.0",
|
"react-virtuoso": "^2.7.0",
|
||||||
"recoil": "^0.6.1",
|
"recoil": "^0.6.1",
|
||||||
|
"snarkdown": "^2.0.0",
|
||||||
"swr": "^1.2.1"
|
"swr": "^1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/github": "^5.0.0",
|
"@actions/github": "^5.0.0",
|
||||||
"@tauri-apps/cli": "^1.0.0-rc.5",
|
"@tauri-apps/cli": "^1.0.0-rc.7",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/js-cookie": "^3.0.1",
|
"@types/js-cookie": "^3.0.1",
|
||||||
"@types/react": "^17.0.0",
|
"@types/react": "^17.0.0",
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import fetch from "node-fetch";
|
|||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
|
const FORCE = process.argv.includes("--force");
|
||||||
const CLASH_URL_PREFIX =
|
|
||||||
"https://github.com/Dreamacro/clash/releases/download/premium/";
|
|
||||||
const CLASH_LATEST_DATE = "2022.01.27";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the correct clash release infomation
|
* get the correct clash release infomation
|
||||||
@@ -17,11 +14,16 @@ const CLASH_LATEST_DATE = "2022.01.27";
|
|||||||
function resolveClash() {
|
function resolveClash() {
|
||||||
const { platform, arch } = process;
|
const { platform, arch } = process;
|
||||||
|
|
||||||
|
const CLASH_URL_PREFIX =
|
||||||
|
"https://github.com/Dreamacro/clash/releases/download/premium/";
|
||||||
|
const CLASH_LATEST_DATE = "2022.03.19";
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
const map = {
|
const map = {
|
||||||
"win32-x64": "clash-windows-386",
|
"win32-x64": "clash-windows-amd64",
|
||||||
"darwin-x64": "clash-darwin-amd64",
|
"darwin-x64": "clash-darwin-amd64",
|
||||||
"darwin-arm64": "clash-darwin-arm64",
|
"darwin-arm64": "clash-darwin-arm64",
|
||||||
|
"linux-x64": "clash-linux-amd64",
|
||||||
};
|
};
|
||||||
|
|
||||||
const name = map[`${platform}-${arch}`];
|
const name = map[`${platform}-${arch}`];
|
||||||
@@ -51,7 +53,7 @@ async function resolveSidecar() {
|
|||||||
const sidecarPath = path.join(sidecarDir, sidecarFile);
|
const sidecarPath = path.join(sidecarDir, sidecarFile);
|
||||||
|
|
||||||
await fs.mkdirp(sidecarDir);
|
await fs.mkdirp(sidecarDir);
|
||||||
if (await fs.pathExists(sidecarPath)) return;
|
if (!FORCE && (await fs.pathExists(sidecarPath))) return;
|
||||||
|
|
||||||
// download sidecar
|
// download sidecar
|
||||||
const binInfo = resolveClash();
|
const binInfo = resolveClash();
|
||||||
@@ -82,13 +84,55 @@ async function resolveSidecar() {
|
|||||||
console.log(`[INFO]: gunzip finished`);
|
console.log(`[INFO]: gunzip finished`);
|
||||||
execSync(`chmod 755 ${sidecarPath}`);
|
execSync(`chmod 755 ${sidecarPath}`);
|
||||||
console.log(`[INFO]: chmod binary finished`);
|
console.log(`[INFO]: chmod binary finished`);
|
||||||
});
|
})
|
||||||
|
.on("error", (error) => console.error(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete temp dir
|
// delete temp dir
|
||||||
await fs.remove(tempDir);
|
await fs.remove(tempDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* only Windows
|
||||||
|
* get the wintun.dll (not required)
|
||||||
|
*/
|
||||||
|
async function resolveWintun() {
|
||||||
|
const { platform } = process;
|
||||||
|
|
||||||
|
if (platform !== "win32") return;
|
||||||
|
|
||||||
|
const url = "https://www.wintun.net/builds/wintun-0.14.1.zip";
|
||||||
|
|
||||||
|
const tempDir = path.join(cwd, "pre-dev-temp-1");
|
||||||
|
const tempZip = path.join(tempDir, "wintun.zip");
|
||||||
|
|
||||||
|
const wintunPath = path.join(tempDir, "wintun/bin/amd64/wintun.dll");
|
||||||
|
const targetPath = path.join(cwd, "src-tauri/resources", "wintun.dll");
|
||||||
|
|
||||||
|
if (!FORCE && (await fs.pathExists(targetPath))) return;
|
||||||
|
|
||||||
|
await fs.mkdirp(tempDir);
|
||||||
|
|
||||||
|
if (!(await fs.pathExists(tempZip))) {
|
||||||
|
await downloadFile(url, tempZip);
|
||||||
|
}
|
||||||
|
|
||||||
|
// unzip
|
||||||
|
const zip = new AdmZip(tempZip);
|
||||||
|
zip.extractAllTo(tempDir, true);
|
||||||
|
|
||||||
|
if (!(await fs.pathExists(wintunPath))) {
|
||||||
|
throw new Error(`path not found "${wintunPath}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// move wintun.dll to resources
|
||||||
|
await fs.rename(wintunPath, targetPath);
|
||||||
|
// delete temp dir
|
||||||
|
await fs.remove(tempDir);
|
||||||
|
|
||||||
|
console.log(`[INFO]: resolve wintun.dll finished`);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the Country.mmdb (not required)
|
* get the Country.mmdb (not required)
|
||||||
*/
|
*/
|
||||||
@@ -98,7 +142,7 @@ async function resolveMmdb() {
|
|||||||
|
|
||||||
const resDir = path.join(cwd, "src-tauri", "resources");
|
const resDir = path.join(cwd, "src-tauri", "resources");
|
||||||
const resPath = path.join(resDir, "Country.mmdb");
|
const resPath = path.join(resDir, "Country.mmdb");
|
||||||
if (await fs.pathExists(resPath)) return;
|
if (!FORCE && (await fs.pathExists(resPath))) return;
|
||||||
await fs.mkdirp(resDir);
|
await fs.mkdirp(resDir);
|
||||||
await downloadFile(url, resPath);
|
await downloadFile(url, resPath);
|
||||||
}
|
}
|
||||||
@@ -121,4 +165,5 @@ async function downloadFile(url, path) {
|
|||||||
|
|
||||||
/// main
|
/// main
|
||||||
resolveSidecar().catch(console.error);
|
resolveSidecar().catch(console.error);
|
||||||
|
resolveWintun().catch(console.error);
|
||||||
resolveMmdb().catch(console.error);
|
resolveMmdb().catch(console.error);
|
||||||
|
|||||||
56
scripts/green.mjs
Normal file
56
scripts/green.mjs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import fs from "fs-extra";
|
||||||
|
import path from "path";
|
||||||
|
import AdmZip from "adm-zip";
|
||||||
|
import { createRequire } from "module";
|
||||||
|
import { getOctokit, context } from "@actions/github";
|
||||||
|
|
||||||
|
/// Script for ci
|
||||||
|
/// 打包绿色版/便携版 (only Windows)
|
||||||
|
async function resolveGreen() {
|
||||||
|
if (process.platform !== "win32") return;
|
||||||
|
|
||||||
|
const releaseDir = "./src-tauri/target/release";
|
||||||
|
|
||||||
|
if (!(await fs.pathExists(releaseDir))) {
|
||||||
|
throw new Error("could not found the release dir");
|
||||||
|
}
|
||||||
|
|
||||||
|
const zip = new AdmZip();
|
||||||
|
|
||||||
|
zip.addLocalFile(path.join(releaseDir, "Clash Verge.exe"));
|
||||||
|
zip.addLocalFile(path.join(releaseDir, "clash.exe"));
|
||||||
|
zip.addLocalFolder(path.join(releaseDir, "resources"), "resources");
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const packageJson = require("../package.json");
|
||||||
|
const { version } = packageJson;
|
||||||
|
|
||||||
|
const zipFile = `Clash.Verge_${version}_x64_green.zip`;
|
||||||
|
zip.writeZip(zipFile);
|
||||||
|
|
||||||
|
console.log("[INFO]: create green zip successfully");
|
||||||
|
|
||||||
|
// push release assets
|
||||||
|
if (process.env.GITHUB_TOKEN === undefined) {
|
||||||
|
throw new Error("GITHUB_TOKEN is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
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}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(release.name);
|
||||||
|
|
||||||
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
|
...options,
|
||||||
|
release_id: release.id,
|
||||||
|
name: zipFile,
|
||||||
|
data: zip.toBuffer(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
resolveGreen().catch(console.error);
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import { createRequire } from "module";
|
import { createRequire } from "module";
|
||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
|
import { resolveUpdateLog } from "./updatelog.mjs";
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
|
|
||||||
|
// publish
|
||||||
async function resolvePublish() {
|
async function resolvePublish() {
|
||||||
const flag = process.argv[2] ?? "patch";
|
const flag = process.argv[2] ?? "patch";
|
||||||
const packageJson = require("../package.json");
|
const packageJson = require("../package.json");
|
||||||
@@ -26,6 +28,10 @@ async function resolvePublish() {
|
|||||||
packageJson.version = nextVersion;
|
packageJson.version = nextVersion;
|
||||||
tauriJson.package.version = nextVersion;
|
tauriJson.package.version = nextVersion;
|
||||||
|
|
||||||
|
// 发布更新前先写更新日志
|
||||||
|
const nextTag = `v${nextVersion}`;
|
||||||
|
await resolveUpdateLog(nextTag);
|
||||||
|
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
"./package.json",
|
"./package.json",
|
||||||
JSON.stringify(packageJson, undefined, 2)
|
JSON.stringify(packageJson, undefined, 2)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { getOctokit, context } from "@actions/github";
|
import { getOctokit, context } from "@actions/github";
|
||||||
|
import { resolveUpdateLog } from "./updatelog.mjs";
|
||||||
|
|
||||||
const UPDATE_TAG_NAME = "updater";
|
const UPDATE_TAG_NAME = "updater";
|
||||||
const UPDATE_JSON_FILE = "update.json";
|
const UPDATE_JSON_FILE = "update.json";
|
||||||
|
const UPDATE_JSON_PROXY = "update-proxy.json";
|
||||||
|
|
||||||
/// generate update.json
|
/// generate update.json
|
||||||
/// upload to update tag's release asset
|
/// upload to update tag's release asset
|
||||||
@@ -33,10 +35,11 @@ async function resolveRelease() {
|
|||||||
|
|
||||||
const updateData = {
|
const updateData = {
|
||||||
name: tag.name,
|
name: tag.name,
|
||||||
notes: latestRelease.body, // use the release body directly
|
notes: await resolveUpdateLog(tag.name), // use updatelog.md
|
||||||
pub_date: new Date().toISOString(),
|
pub_date: new Date().toISOString(),
|
||||||
platforms: {
|
platforms: {
|
||||||
win64: { signature: "", url: "" },
|
win64: { signature: "", url: "" },
|
||||||
|
linux: { signature: "", url: "" },
|
||||||
darwin: { signature: "", url: "" },
|
darwin: { signature: "", url: "" },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -48,29 +51,41 @@ async function resolveRelease() {
|
|||||||
if (/\.msi\.zip$/.test(name)) {
|
if (/\.msi\.zip$/.test(name)) {
|
||||||
updateData.platforms.win64.url = browser_download_url;
|
updateData.platforms.win64.url = browser_download_url;
|
||||||
}
|
}
|
||||||
// darwin url
|
|
||||||
if (/\.app\.tar\.gz$/.test(name)) {
|
|
||||||
updateData.platforms.darwin.url = browser_download_url;
|
|
||||||
}
|
|
||||||
// win64 signature
|
// win64 signature
|
||||||
if (/\.msi\.zip\.sig$/.test(name)) {
|
if (/\.msi\.zip\.sig$/.test(name)) {
|
||||||
updateData.platforms.win64.signature = await getSignature(
|
updateData.platforms.win64.signature = await getSignature(
|
||||||
browser_download_url
|
browser_download_url
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// darwin url
|
||||||
|
if (/\.app\.tar\.gz$/.test(name)) {
|
||||||
|
updateData.platforms.darwin.url = browser_download_url;
|
||||||
|
}
|
||||||
// darwin signature
|
// darwin signature
|
||||||
if (/\.app\.tar\.gz\.sig$/.test(name)) {
|
if (/\.app\.tar\.gz\.sig$/.test(name)) {
|
||||||
updateData.platforms.darwin.signature = await getSignature(
|
updateData.platforms.darwin.signature = await getSignature(
|
||||||
browser_download_url
|
browser_download_url
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// linux url
|
||||||
|
if (/\.AppImage\.tar\.gz$/.test(name)) {
|
||||||
|
updateData.platforms.linux.url = browser_download_url;
|
||||||
|
}
|
||||||
|
// linux signature
|
||||||
|
if (/\.AppImage\.tar\.gz\.sig$/.test(name)) {
|
||||||
|
updateData.platforms.linux.signature = await getSignature(
|
||||||
|
browser_download_url
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.allSettled(promises);
|
await Promise.allSettled(promises);
|
||||||
console.log(updateData);
|
console.log(updateData);
|
||||||
|
|
||||||
// maybe should test the signature as well
|
// maybe should test the signature as well
|
||||||
const { darwin, win64 } = updateData.platforms;
|
const { darwin, win64, linux } = updateData.platforms;
|
||||||
if (!darwin.url) {
|
if (!darwin.url) {
|
||||||
console.log(`[Error]: failed to parse release for darwin`);
|
console.log(`[Error]: failed to parse release for darwin`);
|
||||||
delete updateData.platforms.darwin;
|
delete updateData.platforms.darwin;
|
||||||
@@ -79,6 +94,24 @@ async function resolveRelease() {
|
|||||||
console.log(`[Error]: failed to parse release for win64`);
|
console.log(`[Error]: failed to parse release for win64`);
|
||||||
delete updateData.platforms.win64;
|
delete updateData.platforms.win64;
|
||||||
}
|
}
|
||||||
|
if (!linux.url) {
|
||||||
|
console.log(`[Error]: failed to parse release for linux`);
|
||||||
|
delete updateData.platforms.linux;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成一个代理github的更新文件
|
||||||
|
// 使用 https://hub.fastgit.xyz/ 做github资源的加速
|
||||||
|
const updateDataNew = JSON.parse(JSON.stringify(updateData));
|
||||||
|
|
||||||
|
Object.keys(updateDataNew.platforms).forEach((key) => {
|
||||||
|
if (updateDataNew.platforms[key]) {
|
||||||
|
updateDataNew.platforms[key].url = updateDataNew.platforms[
|
||||||
|
key
|
||||||
|
].url.replace("https://github.com/", "https://hub.fastgit.xyz/");
|
||||||
|
} else {
|
||||||
|
console.log(`[Error]: updateDataNew.platforms.${key} is null`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// update the update.json
|
// update the update.json
|
||||||
const { data: updateRelease } = await github.rest.repos.getReleaseByTag({
|
const { data: updateRelease } = await github.rest.repos.getReleaseByTag({
|
||||||
@@ -86,22 +119,36 @@ async function resolveRelease() {
|
|||||||
tag: UPDATE_TAG_NAME,
|
tag: UPDATE_TAG_NAME,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// delete the old assets
|
||||||
for (let asset of updateRelease.assets) {
|
for (let asset of updateRelease.assets) {
|
||||||
if (asset.name === UPDATE_JSON_FILE) {
|
if (asset.name === UPDATE_JSON_FILE) {
|
||||||
await github.rest.repos.deleteReleaseAsset({
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
...options,
|
...options,
|
||||||
asset_id: asset.id,
|
asset_id: asset.id,
|
||||||
});
|
});
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
if (asset.name === UPDATE_JSON_PROXY) {
|
||||||
|
await github.rest.repos
|
||||||
|
.deleteReleaseAsset({ ...options, asset_id: asset.id })
|
||||||
|
.catch(console.error); // do not break the pipeline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// upload assets
|
||||||
await github.rest.repos.uploadReleaseAsset({
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
...options,
|
...options,
|
||||||
release_id: updateRelease.id,
|
release_id: updateRelease.id,
|
||||||
name: UPDATE_JSON_FILE,
|
name: UPDATE_JSON_FILE,
|
||||||
data: JSON.stringify(updateData, null, 2),
|
data: JSON.stringify(updateData, null, 2),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
|
...options,
|
||||||
|
release_id: updateRelease.id,
|
||||||
|
name: UPDATE_JSON_PROXY,
|
||||||
|
data: JSON.stringify(updateDataNew, null, 2),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the signature file content
|
// get the signature file content
|
||||||
|
|||||||
44
scripts/updatelog.mjs
Normal file
44
scripts/updatelog.mjs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import fs from "fs-extra";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
const UPDATE_LOG = "UPDATELOG.md";
|
||||||
|
|
||||||
|
// parse the UPDATELOG.md
|
||||||
|
export async function resolveUpdateLog(tag) {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
|
||||||
|
const reTitle = /^## v[\d\.]+/;
|
||||||
|
const reEnd = /^---/;
|
||||||
|
|
||||||
|
const file = path.join(cwd, UPDATE_LOG);
|
||||||
|
|
||||||
|
if (!(await fs.pathExists(file))) {
|
||||||
|
throw new Error("could not found UPDATELOG.md");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await fs.readFile(file).then((d) => d.toString("utf8"));
|
||||||
|
|
||||||
|
const map = {};
|
||||||
|
let p = "";
|
||||||
|
|
||||||
|
data.split("\n").forEach((line) => {
|
||||||
|
if (reTitle.test(line)) {
|
||||||
|
p = line.slice(3).trim();
|
||||||
|
if (!map[p]) {
|
||||||
|
map[p] = [];
|
||||||
|
} else {
|
||||||
|
throw new Error(`Tag ${p} dup`);
|
||||||
|
}
|
||||||
|
} else if (reEnd.test(line)) {
|
||||||
|
p = "";
|
||||||
|
} else if (p) {
|
||||||
|
map[p].push(line);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!map[tag]) {
|
||||||
|
throw new Error(`could not found "${tag}" in UPDATELOG.md`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map[tag].join("\n").trim();
|
||||||
|
}
|
||||||
2
src-tauri/.gitignore
vendored
2
src-tauri/.gitignore
vendored
@@ -2,5 +2,5 @@
|
|||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
/target/
|
/target/
|
||||||
WixTools
|
WixTools
|
||||||
resources/Country.mmdb
|
resources
|
||||||
sidecar
|
sidecar
|
||||||
|
|||||||
203
src-tauri/Cargo.lock
generated
203
src-tauri/Cargo.lock
generated
@@ -34,9 +34,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.55"
|
version = "1.0.56"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
|
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arc-swap"
|
name = "arc-swap"
|
||||||
@@ -147,9 +147,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-task"
|
name = "async-task"
|
||||||
version = "4.1.0"
|
version = "4.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8"
|
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
@@ -180,8 +180,8 @@ version = "0.15.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6"
|
checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
]
|
]
|
||||||
@@ -317,27 +317,6 @@ version = "1.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bzip2"
|
|
||||||
version = "0.4.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0"
|
|
||||||
dependencies = [
|
|
||||||
"bzip2-sys",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bzip2-sys"
|
|
||||||
version = "0.1.11+1.0.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
"pkg-config",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cache-padded"
|
name = "cache-padded"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@@ -363,7 +342,7 @@ version = "0.15.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
|
checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
]
|
]
|
||||||
@@ -1173,9 +1152,9 @@ version = "0.15.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "413424d9818621fa3cfc8a3a915cdb89a7c3c507d56761b4ec83a9a98e587171"
|
checksum = "413424d9818621fa3cfc8a3a915cdb89a7c3c507d56761b4ec83a9a98e587171"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gio-sys 0.15.6",
|
"gio-sys 0.15.7",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
]
|
]
|
||||||
@@ -1188,9 +1167,9 @@ checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cairo-sys-rs",
|
"cairo-sys-rs",
|
||||||
"gdk-pixbuf-sys",
|
"gdk-pixbuf-sys",
|
||||||
"gio-sys 0.15.6",
|
"gio-sys 0.15.7",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"pango-sys",
|
"pango-sys",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
@@ -1204,7 +1183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "b4b7f8c7a84b407aa9b143877e267e848ff34106578b64d1e0a24bf550716178"
|
checksum = "b4b7f8c7a84b407aa9b143877e267e848ff34106578b64d1e0a24bf550716178"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gdk-sys",
|
"gdk-sys",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
"x11",
|
"x11",
|
||||||
@@ -1257,15 +1236,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gio"
|
name = "gio"
|
||||||
version = "0.15.6"
|
version = "0.15.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96efd8a1c00d890f6b45671916e165b5e43ccec61957d443aff6d7e44f62d348"
|
checksum = "bb50e113645fba48bc36c8abaee1fe5e43d353e8763966e29dfe69660514e461"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"gio-sys 0.15.6",
|
"gio-sys 0.15.7",
|
||||||
"glib",
|
"glib",
|
||||||
"libc",
|
"libc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
@@ -1287,12 +1266,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gio-sys"
|
name = "gio-sys"
|
||||||
version = "0.15.6"
|
version = "0.15.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d0fa5052773f5a56b8ae47dab09d040f5d9ce1311f4f99006e16e9a08269296"
|
checksum = "9cb5dabebbb63c5cf763c9d9cb120280bf1a442cc496e17fd78ff75272d68244"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
"winapi",
|
"winapi",
|
||||||
@@ -1300,9 +1279,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glib"
|
name = "glib"
|
||||||
version = "0.15.6"
|
version = "0.15.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa570813c504bdf7539a9400180c2dd4b789a819556fb86da7226d7d1b037b49"
|
checksum = "eb53a1102178803a8ea21d383a4332238e42988be61a97819be583bbb405e969"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
@@ -1310,8 +1289,8 @@ dependencies = [
|
|||||||
"futures-executor",
|
"futures-executor",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
"glib-macros",
|
"glib-macros",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -1345,9 +1324,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glib-sys"
|
name = "glib-sys"
|
||||||
version = "0.15.6"
|
version = "0.15.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f4366377bd56697de8aaee24e673c575d2694d72e7756324ded2b0428829a7b8"
|
checksum = "19289e4953dad38c9fea1c5c52cc594f29afc4a70802822ef382dca356b27bfd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
@@ -1385,11 +1364,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gobject-sys"
|
name = "gobject-sys"
|
||||||
version = "0.15.5"
|
version = "0.15.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df6859463843c20cf3837e3a9069b6ab2051aeeadf4c899d33344f4aea83189a"
|
checksum = "db362c9cb92af37a8d58cedb3464ff307485dcc463e46b298f1da1bda60f78b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
]
|
]
|
||||||
@@ -1427,9 +1406,9 @@ dependencies = [
|
|||||||
"cairo-sys-rs",
|
"cairo-sys-rs",
|
||||||
"gdk-pixbuf-sys",
|
"gdk-pixbuf-sys",
|
||||||
"gdk-sys",
|
"gdk-sys",
|
||||||
"gio-sys 0.15.6",
|
"gio-sys 0.15.7",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"pango-sys",
|
"pango-sys",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
@@ -1710,9 +1689,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipnet"
|
name = "ipnet"
|
||||||
version = "2.3.1"
|
version = "2.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"
|
checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
@@ -1752,8 +1731,8 @@ 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 = "905fbb87419c5cde6e3269537e4ea7d46431f3008c5d057e915ef3f115e7793c"
|
checksum = "905fbb87419c5cde6e3269537e4ea7d46431f3008c5d057e915ef3f115e7793c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 5.0.0",
|
"system-deps 5.0.0",
|
||||||
]
|
]
|
||||||
@@ -2209,18 +2188,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_enum"
|
name = "num_enum"
|
||||||
version = "0.5.6"
|
version = "0.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad"
|
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num_enum_derive",
|
"num_enum_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_enum_derive"
|
name = "num_enum_derive"
|
||||||
version = "0.5.6"
|
version = "0.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21"
|
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate 1.1.3",
|
"proc-macro-crate 1.1.3",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2235,6 +2214,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
|
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"malloc_buf",
|
"malloc_buf",
|
||||||
|
"objc_exception",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2248,6 +2228,15 @@ dependencies = [
|
|||||||
"objc_id",
|
"objc_id",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc_exception"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc_id"
|
name = "objc_id"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@@ -2259,9 +2248,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.9.0"
|
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 = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "opaque-debug"
|
name = "opaque-debug"
|
||||||
@@ -2271,9 +2260,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "open"
|
name = "open"
|
||||||
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 = "5a82915836ef43159bb6a3c64d884c42329ccd0b8afdca737cf1e3dd701709dc"
|
checksum = "9213e7b66aa06a7722828ee2980c1adff22a3922b582baaa1e62e30ca2a6c018"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
"winapi",
|
"winapi",
|
||||||
@@ -2343,9 +2332,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pango"
|
name = "pango"
|
||||||
version = "0.15.6"
|
version = "0.15.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78c7420fc01a390ec200da7395b64d705f5d82fe03e5d0708aee422c46538be7"
|
checksum = "a159678be05876e40e1bb4e93db9c9e2f86986fac010b3630feab1273f83b605"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"glib",
|
"glib",
|
||||||
@@ -2360,8 +2349,8 @@ version = "0.15.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7022c2fb88cd2d9d55e1a708a8c53a3ae8678234c4a54bf623400aeb7f31fac2"
|
checksum = "7022c2fb88cd2d9d55e1a708a8c53a3ae8678234c4a54bf623400aeb7f31fac2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"libc",
|
"libc",
|
||||||
"system-deps 6.0.2",
|
"system-deps 6.0.2",
|
||||||
]
|
]
|
||||||
@@ -2853,9 +2842,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.5.4"
|
version = "1.5.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -2931,8 +2920,8 @@ dependencies = [
|
|||||||
"ashpd",
|
"ashpd",
|
||||||
"block",
|
"block",
|
||||||
"dispatch",
|
"dispatch",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"gtk-sys",
|
"gtk-sys",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@@ -3293,9 +3282,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "siphasher"
|
name = "siphasher"
|
||||||
version = "0.3.9"
|
version = "0.3.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e"
|
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
@@ -3473,9 +3462,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tao"
|
name = "tao"
|
||||||
version = "0.6.3"
|
version = "0.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c4c62fc16d698750c5c918088c8134c63e8661e65efc608fe614236c59462f4"
|
checksum = "6a01ed3d6141768e0e36bfe3910f24511022c3dfb977810b00c518d507d4ead4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cairo-rs",
|
"cairo-rs",
|
||||||
@@ -3491,7 +3480,7 @@ dependencies = [
|
|||||||
"gdkx11-sys",
|
"gdkx11-sys",
|
||||||
"gio",
|
"gio",
|
||||||
"glib",
|
"glib",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gtk",
|
"gtk",
|
||||||
"instant",
|
"instant",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@@ -3538,9 +3527,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri"
|
name = "tauri"
|
||||||
version = "1.0.0-rc.3"
|
version = "1.0.0-rc.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bb0c4a4ffd1f9b02cc3e974ce902f8132fb3d08ec6cce4ca193f97d921f5bce4"
|
checksum = "1112a78b3de89c41e01b671d62f24038d324c6cb61708896ee16f533b655c82e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"attohttpc",
|
"attohttpc",
|
||||||
@@ -3558,6 +3547,7 @@ dependencies = [
|
|||||||
"gtk",
|
"gtk",
|
||||||
"http",
|
"http",
|
||||||
"ignore",
|
"ignore",
|
||||||
|
"memchr",
|
||||||
"minisign-verify",
|
"minisign-verify",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"open",
|
"open",
|
||||||
@@ -3584,14 +3574,15 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
|
"windows",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-build"
|
name = "tauri-build"
|
||||||
version = "1.0.0-rc.3"
|
version = "1.0.0-rc.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "855e47d8cfb2219fc14d2eed2c09bfb35f9ecd71a40ca2084aeeee2d23e0b60d"
|
checksum = "d7e31905edc1b40f369beccbbfb30b2e44c2f2bb1ffc06a3778d844af4a81da8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
@@ -3602,12 +3593,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-codegen"
|
name = "tauri-codegen"
|
||||||
version = "1.0.0-rc.2"
|
version = "1.0.0-rc.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eef4656d174ba982198266da0c016573fe6c7c760e4290f05c8c384fe180007e"
|
checksum = "fbcba93e945eb73ee232621763a1295247d0155867bb72e815ab107a10a7cf97"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"blake3",
|
"blake3",
|
||||||
|
"ico",
|
||||||
|
"png 0.16.8",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex",
|
"regex",
|
||||||
@@ -3623,9 +3616,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-macros"
|
name = "tauri-macros"
|
||||||
version = "1.0.0-rc.2"
|
version = "1.0.0-rc.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a0993f5a867e321d26200b2d6394cdf482bd6cc5a0e4691bcabf811544f51cd4"
|
checksum = "ed251657dcdd21922e0146af5f8a3b9ccf92707d4a42add615c250ff92a6838d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.4.0",
|
"heck 0.4.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -3637,9 +3630,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime"
|
name = "tauri-runtime"
|
||||||
version = "0.3.2"
|
version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "851cd65e2c9df4dd70a4f9e115fb2441ac89f1c80df79de0c15a448b4acd7768"
|
checksum = "ae0442d935c2d168541d74be51c4d4f176b1c00ee6bf052f07c1aa5f688ba497"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gtk",
|
"gtk",
|
||||||
"http",
|
"http",
|
||||||
@@ -3656,14 +3649,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime-wry"
|
name = "tauri-runtime-wry"
|
||||||
version = "0.3.2"
|
version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0184f95e065fb80afadf53f0a5f87a75af2da774d0524fe8cb2976fbec4a0bf2"
|
checksum = "643aaa56237304264804dbf34748b21042eadda71d2e964bced1651c19cc0314"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gtk",
|
"gtk",
|
||||||
"ico",
|
|
||||||
"infer",
|
|
||||||
"png 0.16.8",
|
|
||||||
"tauri-runtime",
|
"tauri-runtime",
|
||||||
"tauri-utils",
|
"tauri-utils",
|
||||||
"uuid",
|
"uuid",
|
||||||
@@ -3674,9 +3664,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-utils"
|
name = "tauri-utils"
|
||||||
version = "1.0.0-rc.2"
|
version = "1.0.0-rc.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ad38ad698838886bf22ecb91c4b3d1ce178fdff7901ac7bff370103a4f51e59"
|
checksum = "21f11483d205c77d1ec398e80566485101696335983e69832cc6c41ab1e07266"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctor",
|
"ctor",
|
||||||
"glob",
|
"glob",
|
||||||
@@ -4280,10 +4270,10 @@ dependencies = [
|
|||||||
"gdk",
|
"gdk",
|
||||||
"gdk-sys",
|
"gdk-sys",
|
||||||
"gio",
|
"gio",
|
||||||
"gio-sys 0.15.6",
|
"gio-sys 0.15.7",
|
||||||
"glib",
|
"glib",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"gtk",
|
"gtk",
|
||||||
"gtk-sys",
|
"gtk-sys",
|
||||||
"javascriptcore-rs",
|
"javascriptcore-rs",
|
||||||
@@ -4303,9 +4293,9 @@ dependencies = [
|
|||||||
"cairo-sys-rs",
|
"cairo-sys-rs",
|
||||||
"gdk-pixbuf-sys",
|
"gdk-pixbuf-sys",
|
||||||
"gdk-sys",
|
"gdk-sys",
|
||||||
"gio-sys 0.15.6",
|
"gio-sys 0.15.7",
|
||||||
"glib-sys 0.15.6",
|
"glib-sys 0.15.7",
|
||||||
"gobject-sys 0.15.5",
|
"gobject-sys 0.15.7",
|
||||||
"gtk-sys",
|
"gtk-sys",
|
||||||
"javascriptcore-rs-sys",
|
"javascriptcore-rs-sys",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -4411,8 +4401,8 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "window-shadows"
|
name = "window-shadows"
|
||||||
version = "0.0.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/tauri-apps/window-shadows#72de826498573de6bed48038bbc74a3dbde7460e"
|
source = "git+https://github.com/tauri-apps/window-shadows#71c656abf892313e0a91d56ddf8bef5d80bd2a22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"objc",
|
"objc",
|
||||||
@@ -4423,7 +4413,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "window-vibrancy"
|
name = "window-vibrancy"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/tauri-apps/window-vibrancy#3fd5be20535ec9b595e893b75dc74b6725664852"
|
source = "git+https://github.com/tauri-apps/window-vibrancy#c91cd362e0758fe93cf41a740d2e00a668523fe8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"objc",
|
"objc",
|
||||||
@@ -4768,11 +4758,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815"
|
checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bzip2",
|
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"flate2",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ edition = "2021"
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "1.0.0-rc.3", features = [] }
|
tauri-build = { version = "1.0.0-rc.4", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
@@ -21,7 +21,7 @@ chrono = "0.4.19"
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_yaml = "0.8"
|
serde_yaml = "0.8"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tauri = { version = "1.0.0-rc.3", features = ["shell-all", "system-tray", "updater", "window-all"] }
|
tauri = { version = "1.0.0-rc.4", features = ["shell-all", "system-tray", "updater", "window-all"] }
|
||||||
window-shadows = { git = "https://github.com/tauri-apps/window-shadows" }
|
window-shadows = { git = "https://github.com/tauri-apps/window-shadows" }
|
||||||
window-vibrancy = { git = "https://github.com/tauri-apps/window-vibrancy" }
|
window-vibrancy = { git = "https://github.com/tauri-apps/window-vibrancy" }
|
||||||
|
|
||||||
@@ -40,3 +40,4 @@ winreg = { version = "0.10", features = ["transactions"] }
|
|||||||
[features]
|
[features]
|
||||||
default = [ "custom-protocol" ]
|
default = [ "custom-protocol" ]
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
custom-protocol = [ "tauri/custom-protocol" ]
|
||||||
|
verge-dev = []
|
||||||
|
|||||||
BIN
src-tauri/icons/icon-shrink.png
Normal file
BIN
src-tauri/icons/icon-shrink.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
core::{ClashInfo, PrfItem, Profiles, VergeConfig},
|
core::{ClashInfo, PrfItem, PrfOption, Profiles, VergeConfig},
|
||||||
states::{ClashState, ProfilesState, VergeState},
|
states::{ClashState, ProfilesState, VergeState},
|
||||||
utils::{dirs, sysopt::SysProxyConfig},
|
utils::{dirs, sysopt::SysProxyConfig},
|
||||||
};
|
};
|
||||||
@@ -28,10 +28,10 @@ pub fn sync_profiles(profiles_state: State<'_, ProfilesState>) -> Result<(), Str
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn import_profile(
|
pub async fn import_profile(
|
||||||
url: String,
|
url: String,
|
||||||
with_proxy: bool,
|
option: Option<PrfOption>,
|
||||||
profiles_state: State<'_, ProfilesState>,
|
profiles_state: State<'_, ProfilesState>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let item = wrap_err!(PrfItem::from_url(&url, None, None, with_proxy).await)?;
|
let item = wrap_err!(PrfItem::from_url(&url, None, None, option).await)?;
|
||||||
|
|
||||||
let mut profiles = profiles_state.0.lock().unwrap();
|
let mut profiles = profiles_state.0.lock().unwrap();
|
||||||
wrap_err!(profiles.append_item(item))
|
wrap_err!(profiles.append_item(item))
|
||||||
@@ -43,9 +43,10 @@ pub async fn import_profile(
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn create_profile(
|
pub async fn create_profile(
|
||||||
item: PrfItem, // partial
|
item: PrfItem, // partial
|
||||||
|
file_data: Option<String>,
|
||||||
profiles_state: State<'_, ProfilesState>,
|
profiles_state: State<'_, ProfilesState>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let item = wrap_err!(PrfItem::from(item).await)?;
|
let item = wrap_err!(PrfItem::from(item, file_data).await)?;
|
||||||
let mut profiles = profiles_state.0.lock().unwrap();
|
let mut profiles = profiles_state.0.lock().unwrap();
|
||||||
|
|
||||||
wrap_err!(profiles.append_item(item))
|
wrap_err!(profiles.append_item(item))
|
||||||
@@ -55,23 +56,31 @@ pub async fn create_profile(
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn update_profile(
|
pub async fn update_profile(
|
||||||
index: String,
|
index: String,
|
||||||
with_proxy: bool,
|
option: Option<PrfOption>,
|
||||||
clash_state: State<'_, ClashState>,
|
clash_state: State<'_, ClashState>,
|
||||||
profiles_state: State<'_, ProfilesState>,
|
profiles_state: State<'_, ProfilesState>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let url = {
|
let (url, opt) = {
|
||||||
// must release the lock here
|
// must release the lock here
|
||||||
let profiles = profiles_state.0.lock().unwrap();
|
let profiles = profiles_state.0.lock().unwrap();
|
||||||
let item = wrap_err!(profiles.get_item(&index))?;
|
let item = wrap_err!(profiles.get_item(&index))?;
|
||||||
|
|
||||||
|
// check the profile type
|
||||||
|
if let Some(typ) = item.itype.as_ref() {
|
||||||
|
if *typ != "remote" {
|
||||||
|
ret_err!(format!("could not update the `{typ}` profile"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if item.url.is_none() {
|
if item.url.is_none() {
|
||||||
ret_err!("failed to get the item url");
|
ret_err!("failed to get the item url");
|
||||||
}
|
}
|
||||||
|
|
||||||
item.url.clone().unwrap()
|
(item.url.clone().unwrap(), item.option.clone())
|
||||||
};
|
};
|
||||||
|
|
||||||
let item = wrap_err!(PrfItem::from_url(&url, None, None, with_proxy).await)?;
|
let fetch_opt = PrfOption::merge(opt, option);
|
||||||
|
let item = wrap_err!(PrfItem::from_url(&url, None, None, fetch_opt).await)?;
|
||||||
|
|
||||||
let mut profiles = profiles_state.0.lock().unwrap();
|
let mut profiles = profiles_state.0.lock().unwrap();
|
||||||
wrap_err!(profiles.update_item(index.clone(), item))?;
|
wrap_err!(profiles.update_item(index.clone(), item))?;
|
||||||
@@ -181,21 +190,23 @@ pub fn view_profile(index: String, profiles_state: State<'_, ProfilesState>) ->
|
|||||||
{
|
{
|
||||||
use std::os::windows::process::CommandExt;
|
use std::os::windows::process::CommandExt;
|
||||||
|
|
||||||
return match Command::new(code)
|
if let Err(err) = Command::new(code)
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.arg(path)
|
.arg(path)
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
Ok(_) => Ok(()),
|
log::error!("{err}");
|
||||||
Err(_) => Err("failed to open file by VScode".into()),
|
return Err("failed to open file by VScode".into());
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
return match Command::new(code).arg(path).spawn() {
|
if let Err(err) = Command::new(code).arg(path).spawn() {
|
||||||
Ok(_) => Ok(()),
|
log::error!("{err}");
|
||||||
Err(_) => Err("failed to open file by VScode".into()),
|
return Err("failed to open file by VScode".into());
|
||||||
};
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
open_path_cmd(path, "failed to open file by `open`")
|
open_path_cmd(path, "failed to open file by `open`")
|
||||||
@@ -269,14 +280,13 @@ pub fn get_verge_config(verge_state: State<'_, VergeState>) -> Result<VergeConfi
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn patch_verge_config(
|
pub fn patch_verge_config(
|
||||||
payload: VergeConfig,
|
payload: VergeConfig,
|
||||||
|
app_handle: tauri::AppHandle,
|
||||||
clash_state: State<'_, ClashState>,
|
clash_state: State<'_, ClashState>,
|
||||||
verge_state: State<'_, VergeState>,
|
verge_state: State<'_, VergeState>,
|
||||||
profiles_state: State<'_, ProfilesState>,
|
profiles_state: State<'_, ProfilesState>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let tun_mode = payload.enable_tun_mode.clone();
|
let tun_mode = payload.enable_tun_mode.clone();
|
||||||
|
let system_proxy = payload.enable_system_proxy.clone();
|
||||||
let mut verge = verge_state.0.lock().unwrap();
|
|
||||||
wrap_err!(verge.patch_config(payload))?;
|
|
||||||
|
|
||||||
// change tun mode
|
// change tun mode
|
||||||
if tun_mode.is_some() {
|
if tun_mode.is_some() {
|
||||||
@@ -288,6 +298,18 @@ pub fn patch_verge_config(
|
|||||||
wrap_err!(clash.activate(&profiles, false))?;
|
wrap_err!(clash.activate(&profiles, false))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut verge = verge_state.0.lock().unwrap();
|
||||||
|
wrap_err!(verge.patch_config(payload))?;
|
||||||
|
|
||||||
|
// change system tray
|
||||||
|
if system_proxy.is_some() {
|
||||||
|
app_handle
|
||||||
|
.tray_handle()
|
||||||
|
.get_item("system_proxy")
|
||||||
|
.set_selected(system_proxy.unwrap())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,25 +333,56 @@ pub fn open_logs_dir() -> Result<(), String> {
|
|||||||
open_path_cmd(log_dir, "failed to open logs dir")
|
open_path_cmd(log_dir, "failed to open logs dir")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get open/explorer command
|
/// use the os default open command to open file or dir
|
||||||
fn open_path_cmd(dir: PathBuf, err_str: &str) -> Result<(), String> {
|
fn open_path_cmd(path: PathBuf, err_str: &str) -> Result<(), String> {
|
||||||
|
let result;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use std::os::windows::process::CommandExt;
|
use std::os::windows::process::CommandExt;
|
||||||
|
|
||||||
match Command::new("explorer")
|
result = Command::new("explorer")
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.arg(dir)
|
.arg(&path)
|
||||||
.spawn()
|
.spawn();
|
||||||
{
|
}
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(_) => Err(err_str.into()),
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
result = Command::new("open").arg(&path).spawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
result = Command::new("xdg-open").arg(&path).spawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
match result {
|
||||||
|
Ok(child) => match child.wait_with_output() {
|
||||||
|
Ok(out) => {
|
||||||
|
// 退出码不为0 不一定没有调用成功
|
||||||
|
// 因此仅做warn log且不返回错误
|
||||||
|
if let Some(code) = out.status.code() {
|
||||||
|
if code != 0 {
|
||||||
|
log::warn!("failed to open {:?} (code {})", &path, code);
|
||||||
|
log::warn!(
|
||||||
|
"open cmd stdout: {}, stderr: {}",
|
||||||
|
String::from_utf8_lossy(&out.stdout),
|
||||||
|
String::from_utf8_lossy(&out.stderr),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("failed to open {:?} for {err}", &path);
|
||||||
|
return Err(err_str.into());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("failed to open {:?} for {err}", &path);
|
||||||
|
return Err(err_str.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
return Ok(());
|
||||||
match Command::new("open").arg(dir).spawn() {
|
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(_) => Err(err_str.into()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,18 @@ impl Clash {
|
|||||||
|
|
||||||
let server = match clash_config.get(&key_server) {
|
let server = match clash_config.get(&key_server) {
|
||||||
Some(value) => match value {
|
Some(value) => match value {
|
||||||
Value::String(val_str) => Some(val_str.clone()),
|
Value::String(val_str) => {
|
||||||
|
// `external-controller` could be
|
||||||
|
// "127.0.0.1:9090" or ":9090"
|
||||||
|
// Todo: maybe it could support single port
|
||||||
|
let server = val_str.clone();
|
||||||
|
let server = match server.starts_with(":") {
|
||||||
|
true => format!("127.0.0.1{server}"),
|
||||||
|
false => server,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(server)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -181,71 +192,109 @@ impl Clash {
|
|||||||
verge: &mut Verge,
|
verge: &mut Verge,
|
||||||
profiles: &mut Profiles,
|
profiles: &mut Profiles,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
for (key, value) in patch.iter() {
|
let mix_port_key = Value::from("mixed-port");
|
||||||
|
let mut port = None;
|
||||||
|
|
||||||
|
for (key, value) in patch.into_iter() {
|
||||||
let value = value.clone();
|
let value = value.clone();
|
||||||
let key_str = key.as_str().clone().unwrap_or("");
|
|
||||||
|
|
||||||
// restart the clash
|
// check whether the mix_port is changed
|
||||||
if key_str == "mixed-port" {
|
if key == mix_port_key {
|
||||||
self.restart_sidecar(profiles)?;
|
if value.is_number() {
|
||||||
|
port = value.as_i64().as_ref().map(|n| n.to_string());
|
||||||
let port = if value.is_number() {
|
|
||||||
match value.as_i64().clone() {
|
|
||||||
Some(num) => Some(format!("{num}")),
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
match value.as_str().clone() {
|
port = value.as_str().as_ref().map(|s| s.to_string());
|
||||||
Some(num) => Some(num.into()),
|
}
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
verge.init_sysproxy(port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.config.insert(key.clone(), value);
|
self.config.insert(key.clone(), value);
|
||||||
}
|
}
|
||||||
self.save_config()
|
|
||||||
|
self.save_config()?;
|
||||||
|
|
||||||
|
if let Some(port) = port {
|
||||||
|
self.restart_sidecar(profiles)?;
|
||||||
|
verge.init_sysproxy(Some(port));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// enable tun mode
|
/// enable tun mode
|
||||||
/// only revise the config and restart the
|
/// only revise the config and restart the
|
||||||
pub fn tun_mode(&mut self, enable: bool) -> Result<()> {
|
pub fn tun_mode(&mut self, enable: bool) -> Result<()> {
|
||||||
let tun_key = Value::String("tun".into());
|
// Windows 需要wintun.dll文件
|
||||||
let tun_val = self.config.get(&tun_key);
|
#[cfg(target_os = "windows")]
|
||||||
|
if enable {
|
||||||
let mut new_val = Mapping::new();
|
let wintun_dll = dirs::app_home_dir().join("wintun.dll");
|
||||||
|
if !wintun_dll.exists() {
|
||||||
if tun_val.is_some() && tun_val.as_ref().unwrap().is_mapping() {
|
bail!("failed to enable TUN for missing `wintun.dll`");
|
||||||
new_val = tun_val.as_ref().unwrap().as_mapping().unwrap().clone();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! revise {
|
macro_rules! revise {
|
||||||
($map: expr, $key: expr, $val: expr) => {
|
($map: expr, $key: expr, $val: expr) => {
|
||||||
let ret_key = Value::String($key.into());
|
let ret_key = Value::String($key.into());
|
||||||
if $map.contains_key(&ret_key) {
|
$map.insert(ret_key, Value::from($val));
|
||||||
$map[&ret_key] = $val;
|
|
||||||
} else {
|
|
||||||
$map.insert(ret_key, $val);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if key not exists then append value
|
||||||
macro_rules! append {
|
macro_rules! append {
|
||||||
($map: expr, $key: expr, $val: expr) => {
|
($map: expr, $key: expr, $val: expr) => {
|
||||||
let ret_key = Value::String($key.into());
|
let ret_key = Value::String($key.into());
|
||||||
if !$map.contains_key(&ret_key) {
|
if !$map.contains_key(&ret_key) {
|
||||||
$map.insert(ret_key, $val);
|
$map.insert(ret_key, Value::from($val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
revise!(new_val, "enable", Value::from(enable));
|
// tun config
|
||||||
append!(new_val, "stack", Value::from("gvisor"));
|
let tun_val = self.config.get(&Value::from("tun"));
|
||||||
append!(new_val, "auto-route", Value::from(true));
|
let mut new_tun = Mapping::new();
|
||||||
append!(new_val, "auto-detect-interface", Value::from(true));
|
|
||||||
|
|
||||||
revise!(self.config, "tun", Value::from(new_val));
|
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);
|
||||||
|
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!(self.config, "tun", new_tun);
|
||||||
|
|
||||||
|
// dns config
|
||||||
|
let dns_val = self.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();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 借鉴cfw的默认配置
|
||||||
|
revise!(new_dns, "enable", enable);
|
||||||
|
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!(self.config, "dns", new_dns);
|
||||||
|
|
||||||
self.save_config()
|
self.save_config()
|
||||||
}
|
}
|
||||||
@@ -253,7 +302,7 @@ impl Clash {
|
|||||||
/// activate the profile
|
/// activate the profile
|
||||||
/// generate a new profile to the temp_dir
|
/// generate a new profile to the temp_dir
|
||||||
/// then put the path to the clash core
|
/// then put the path to the clash core
|
||||||
fn _activate(info: ClashInfo, config: Mapping) -> Result<()> {
|
fn _activate(info: ClashInfo, config: Mapping, window: Option<Window>) -> Result<()> {
|
||||||
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"))?;
|
||||||
|
|
||||||
@@ -283,6 +332,12 @@ impl Clash {
|
|||||||
if resp.status() != 204 {
|
if resp.status() != 204 {
|
||||||
log::error!("failed to activate clash for status \"{}\"", resp.status());
|
log::error!("failed to activate clash for status \"{}\"", resp.status());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// emit the window to update something
|
||||||
|
if let Some(window) = window {
|
||||||
|
window.emit("verge://refresh-clash-config", "yes").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
// do not retry
|
// do not retry
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -314,21 +369,47 @@ impl Clash {
|
|||||||
|
|
||||||
// generate the payload
|
// generate the payload
|
||||||
let payload = profiles.gen_enhanced(event_name.clone())?;
|
let payload = profiles.gen_enhanced(event_name.clone())?;
|
||||||
|
let window = self.window.clone();
|
||||||
|
|
||||||
win.once(&event_name, move |event| {
|
win.once(&event_name, move |event| {
|
||||||
if let Some(result) = event.payload() {
|
if let Some(result) = event.payload() {
|
||||||
let result: PrfEnhancedResult = serde_json::from_str(result).unwrap();
|
let result: PrfEnhancedResult = serde_json::from_str(result).unwrap();
|
||||||
|
|
||||||
if let Some(data) = result.data {
|
if let Some(data) = result.data {
|
||||||
|
// all of these can not be revised by script
|
||||||
|
// http/https/socks port should be under control
|
||||||
|
let not_allow = vec![
|
||||||
|
"port",
|
||||||
|
"socks-port",
|
||||||
|
"mixed-port",
|
||||||
|
"allow-lan",
|
||||||
|
"mode",
|
||||||
|
"external-controller",
|
||||||
|
"secret",
|
||||||
|
"log-level",
|
||||||
|
];
|
||||||
|
|
||||||
for (key, value) in data.into_iter() {
|
for (key, value) in data.into_iter() {
|
||||||
config.insert(key, value);
|
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) {
|
||||||
|
config.insert(Value::String(key_str), value);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Self::_activate(info, config).unwrap();
|
|
||||||
|
log::info!("profile enhanced status {}", result.status);
|
||||||
|
|
||||||
|
Self::_activate(info, config, window).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("profile enhanced status {}", result.status);
|
if let Some(error) = result.error {
|
||||||
|
log::error!("{error}");
|
||||||
result.error.map(|error| log::error!("{error}"));
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -354,7 +435,7 @@ impl Clash {
|
|||||||
config.insert(key, value);
|
config.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::_activate(info, config)?;
|
Self::_activate(info, config, self.window.clone())?;
|
||||||
self.activate_enhanced(profiles, delay)
|
self.activate_enhanced(profiles, delay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,17 @@ pub struct PrfItem {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub selected: Option<Vec<PrfSelected>>,
|
pub selected: Option<Vec<PrfSelected>>,
|
||||||
|
|
||||||
/// user info
|
/// subscription user info
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub extra: Option<PrfExtra>,
|
pub extra: Option<PrfExtra>,
|
||||||
|
|
||||||
/// updated time
|
/// updated time
|
||||||
pub updated: Option<usize>,
|
pub updated: Option<usize>,
|
||||||
|
|
||||||
|
/// some options of the item
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub option: Option<PrfOption>,
|
||||||
|
|
||||||
/// the file data
|
/// the file data
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub file_data: Option<String>,
|
pub file_data: Option<String>,
|
||||||
@@ -57,6 +61,43 @@ pub struct PrfExtra {
|
|||||||
pub expire: usize,
|
pub expire: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct PrfOption {
|
||||||
|
/// for `remote` profile's http request
|
||||||
|
/// see issue #13
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub user_agent: Option<String>,
|
||||||
|
|
||||||
|
/// for `remote` profile
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub with_proxy: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrfOption {
|
||||||
|
pub fn merge(one: Option<Self>, other: Option<Self>) -> Option<Self> {
|
||||||
|
if one.is_some() && other.is_some() {
|
||||||
|
let mut one = one.unwrap();
|
||||||
|
let other = other.unwrap();
|
||||||
|
|
||||||
|
if let Some(val) = other.user_agent {
|
||||||
|
one.user_agent = Some(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(val) = other.with_proxy {
|
||||||
|
one.with_proxy = Some(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Some(one);
|
||||||
|
}
|
||||||
|
|
||||||
|
if one.is_none() {
|
||||||
|
return other;
|
||||||
|
}
|
||||||
|
|
||||||
|
return one;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for PrfItem {
|
impl Default for PrfItem {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
PrfItem {
|
PrfItem {
|
||||||
@@ -69,6 +110,7 @@ impl Default for PrfItem {
|
|||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
|
option: None,
|
||||||
file_data: None,
|
file_data: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +119,7 @@ impl Default for PrfItem {
|
|||||||
impl PrfItem {
|
impl PrfItem {
|
||||||
/// From partial item
|
/// From partial item
|
||||||
/// must contain `itype`
|
/// must contain `itype`
|
||||||
pub async fn from(item: PrfItem) -> Result<PrfItem> {
|
pub async fn from(item: PrfItem, file_data: Option<String>) -> Result<PrfItem> {
|
||||||
if item.itype.is_none() {
|
if item.itype.is_none() {
|
||||||
bail!("type should not be null");
|
bail!("type should not be null");
|
||||||
}
|
}
|
||||||
@@ -90,12 +132,12 @@ impl PrfItem {
|
|||||||
let url = item.url.as_ref().unwrap().as_str();
|
let url = item.url.as_ref().unwrap().as_str();
|
||||||
let name = item.name;
|
let name = item.name;
|
||||||
let desc = item.desc;
|
let desc = item.desc;
|
||||||
PrfItem::from_url(url, name, desc, false).await
|
PrfItem::from_url(url, name, desc, item.option).await
|
||||||
}
|
}
|
||||||
"local" => {
|
"local" => {
|
||||||
let name = item.name.unwrap_or("Local File".into());
|
let name = item.name.unwrap_or("Local File".into());
|
||||||
let desc = item.desc.unwrap_or("".into());
|
let desc = item.desc.unwrap_or("".into());
|
||||||
PrfItem::from_local(name, desc)
|
PrfItem::from_local(name, desc, file_data)
|
||||||
}
|
}
|
||||||
"merge" => {
|
"merge" => {
|
||||||
let name = item.name.unwrap_or("Merge".into());
|
let name = item.name.unwrap_or("Merge".into());
|
||||||
@@ -113,7 +155,7 @@ impl PrfItem {
|
|||||||
|
|
||||||
/// ## Local type
|
/// ## Local type
|
||||||
/// create a new item from name/desc
|
/// create a new item from name/desc
|
||||||
pub fn from_local(name: String, desc: String) -> Result<PrfItem> {
|
pub fn from_local(name: String, desc: String, file_data: Option<String>) -> Result<PrfItem> {
|
||||||
let uid = help::get_uid("l");
|
let uid = help::get_uid("l");
|
||||||
let file = format!("{uid}.yaml");
|
let file = format!("{uid}.yaml");
|
||||||
|
|
||||||
@@ -126,8 +168,9 @@ impl PrfItem {
|
|||||||
url: None,
|
url: None,
|
||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
|
option: None,
|
||||||
updated: Some(help::get_now()),
|
updated: Some(help::get_now()),
|
||||||
file_data: Some(tmpl::ITEM_LOCAL.into()),
|
file_data: Some(file_data.unwrap_or(tmpl::ITEM_LOCAL.into())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,13 +180,25 @@ impl PrfItem {
|
|||||||
url: &str,
|
url: &str,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
desc: Option<String>,
|
desc: Option<String>,
|
||||||
with_proxy: bool,
|
option: Option<PrfOption>,
|
||||||
) -> Result<PrfItem> {
|
) -> Result<PrfItem> {
|
||||||
|
let with_proxy = match option.as_ref() {
|
||||||
|
Some(opt) => opt.with_proxy.unwrap_or(false),
|
||||||
|
None => false,
|
||||||
|
};
|
||||||
|
let user_agent = match option.as_ref() {
|
||||||
|
Some(opt) => opt.user_agent.clone(),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
let mut builder = reqwest::ClientBuilder::new();
|
let mut builder = reqwest::ClientBuilder::new();
|
||||||
|
|
||||||
if !with_proxy {
|
if !with_proxy {
|
||||||
builder = builder.no_proxy();
|
builder = builder.no_proxy();
|
||||||
}
|
}
|
||||||
|
if let Some(user_agent) = user_agent {
|
||||||
|
builder = builder.user_agent(user_agent);
|
||||||
|
}
|
||||||
|
|
||||||
let resp = builder.build()?.get(url).send().await?;
|
let resp = builder.build()?.get(url).send().await?;
|
||||||
let header = resp.headers();
|
let header = resp.headers();
|
||||||
@@ -177,6 +232,7 @@ impl PrfItem {
|
|||||||
url: Some(url.into()),
|
url: Some(url.into()),
|
||||||
selected: None,
|
selected: None,
|
||||||
extra,
|
extra,
|
||||||
|
option,
|
||||||
updated: Some(help::get_now()),
|
updated: Some(help::get_now()),
|
||||||
file_data: Some(data),
|
file_data: Some(data),
|
||||||
})
|
})
|
||||||
@@ -197,6 +253,7 @@ impl PrfItem {
|
|||||||
url: None,
|
url: None,
|
||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
|
option: None,
|
||||||
updated: Some(help::get_now()),
|
updated: Some(help::get_now()),
|
||||||
file_data: Some(tmpl::ITEM_MERGE.into()),
|
file_data: Some(tmpl::ITEM_MERGE.into()),
|
||||||
})
|
})
|
||||||
@@ -217,6 +274,7 @@ impl PrfItem {
|
|||||||
url: None,
|
url: None,
|
||||||
selected: None,
|
selected: None,
|
||||||
extra: None,
|
extra: None,
|
||||||
|
option: None,
|
||||||
updated: Some(help::get_now()),
|
updated: Some(help::get_now()),
|
||||||
file_data: Some(tmpl::ITEM_SCRIPT.into()),
|
file_data: Some(tmpl::ITEM_SCRIPT.into()),
|
||||||
})
|
})
|
||||||
@@ -380,8 +438,8 @@ impl Profiles {
|
|||||||
patch!(each, item, url);
|
patch!(each, item, url);
|
||||||
patch!(each, item, selected);
|
patch!(each, item, selected);
|
||||||
patch!(each, item, extra);
|
patch!(each, item, extra);
|
||||||
|
patch!(each, item, updated);
|
||||||
each.updated = Some(help::get_now());
|
patch!(each, item, option);
|
||||||
|
|
||||||
self.items = Some(items);
|
self.items = Some(items);
|
||||||
return self.save_file();
|
return self.save_file();
|
||||||
@@ -508,13 +566,17 @@ impl Profiles {
|
|||||||
"rules",
|
"rules",
|
||||||
];
|
];
|
||||||
|
|
||||||
valid_keys.iter().for_each(|key| {
|
for (key, value) in def_config.into_iter() {
|
||||||
let key = Value::String(key.to_string());
|
key.as_str().map(|key_str| {
|
||||||
if def_config.contains_key(&key) {
|
// change to lowercase
|
||||||
let value = def_config[&key].clone();
|
let mut key_str = String::from(key_str);
|
||||||
new_config.insert(key, value);
|
key_str.make_ascii_lowercase();
|
||||||
}
|
|
||||||
});
|
if valid_keys.contains(&&*key_str) {
|
||||||
|
new_config.insert(Value::String(key_str), value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(new_config);
|
return Ok(new_config);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use crate::log_if_err;
|
||||||
use crate::{
|
use crate::{
|
||||||
core::Clash,
|
core::Clash,
|
||||||
log_if_err,
|
|
||||||
utils::{config, dirs, sysopt::SysProxyConfig},
|
utils::{config, dirs, sysopt::SysProxyConfig},
|
||||||
};
|
};
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
@@ -12,6 +12,9 @@ use tauri::{async_runtime::Mutex, utils::platform::current_exe};
|
|||||||
/// ### `verge.yaml` schema
|
/// ### `verge.yaml` schema
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct VergeConfig {
|
pub struct VergeConfig {
|
||||||
|
// i18n
|
||||||
|
pub language: Option<String>,
|
||||||
|
|
||||||
/// `light` or `dark`
|
/// `light` or `dark`
|
||||||
pub theme_mode: Option<String>,
|
pub theme_mode: Option<String>,
|
||||||
|
|
||||||
@@ -130,37 +133,31 @@ impl Verge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// init the auto launch
|
/// init the auto launch
|
||||||
pub fn init_launch(&mut self) {
|
pub fn init_launch(&mut self) -> Result<()> {
|
||||||
let app_exe = current_exe().unwrap();
|
let app_exe = current_exe().unwrap();
|
||||||
let app_exe = dunce::canonicalize(app_exe).unwrap();
|
let app_exe = dunce::canonicalize(app_exe).unwrap();
|
||||||
let app_name = app_exe.file_stem().unwrap().to_str().unwrap();
|
let app_name = app_exe.file_stem().unwrap().to_str().unwrap();
|
||||||
let app_path = app_exe.as_os_str().to_str().unwrap();
|
let app_path = app_exe.as_os_str().to_str().unwrap();
|
||||||
|
|
||||||
|
// fix issue #26
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
let app_path = format!("\"{app_path}\"");
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
let app_path = app_path.as_str();
|
||||||
|
|
||||||
let auto = AutoLaunchBuilder::new()
|
let auto = AutoLaunchBuilder::new()
|
||||||
.set_app_name(app_name)
|
.set_app_name(app_name)
|
||||||
.set_app_path(app_path)
|
.set_app_path(app_path)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
if let Some(enable) = self.config.enable_auto_launch.as_ref() {
|
||||||
|
// fix issue #26
|
||||||
|
if *enable {
|
||||||
|
auto.enable()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.auto_launch = Some(auto);
|
self.auto_launch = Some(auto);
|
||||||
}
|
|
||||||
|
|
||||||
/// sync the startup when run the app
|
|
||||||
pub fn sync_launch(&self) -> Result<()> {
|
|
||||||
let enable = self.config.enable_auto_launch.clone().unwrap_or(false);
|
|
||||||
if !enable {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.auto_launch.is_none() {
|
|
||||||
bail!("should init the auto launch first");
|
|
||||||
}
|
|
||||||
|
|
||||||
let auto_launch = self.auto_launch.clone().unwrap();
|
|
||||||
|
|
||||||
let is_enabled = auto_launch.is_enabled().unwrap_or(false);
|
|
||||||
if !is_enabled {
|
|
||||||
auto_launch.enable()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -188,6 +185,9 @@ impl Verge {
|
|||||||
/// so call the save_file at the end is savely
|
/// so call the save_file at the end is savely
|
||||||
pub fn patch_config(&mut self, patch: VergeConfig) -> Result<()> {
|
pub fn patch_config(&mut self, patch: VergeConfig) -> Result<()> {
|
||||||
// only change it
|
// only change it
|
||||||
|
if patch.language.is_some() {
|
||||||
|
self.config.language = patch.language;
|
||||||
|
}
|
||||||
if patch.theme_mode.is_some() {
|
if patch.theme_mode.is_some() {
|
||||||
self.config.theme_mode = patch.theme_mode;
|
self.config.theme_mode = patch.theme_mode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ mod core;
|
|||||||
mod states;
|
mod states;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use crate::utils::{resolve, server};
|
use crate::{
|
||||||
|
core::VergeConfig,
|
||||||
|
utils::{resolve, server},
|
||||||
|
};
|
||||||
use tauri::{
|
use tauri::{
|
||||||
api, CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem,
|
api, CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem,
|
||||||
};
|
};
|
||||||
@@ -21,6 +24,7 @@ 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_item(CustomMenuItem::new("system_proxy", "System Proxy"))
|
||||||
.add_item(CustomMenuItem::new("restart_clash", "Restart Clash"))
|
.add_item(CustomMenuItem::new("restart_clash", "Restart Clash"))
|
||||||
.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"));
|
||||||
@@ -40,18 +44,38 @@ fn main() -> std::io::Result<()> {
|
|||||||
window.show().unwrap();
|
window.show().unwrap();
|
||||||
window.set_focus().unwrap();
|
window.set_focus().unwrap();
|
||||||
}
|
}
|
||||||
|
"system_proxy" => {
|
||||||
|
let verge_state = app_handle.state::<states::VergeState>();
|
||||||
|
let mut verge = verge_state.0.lock().unwrap();
|
||||||
|
|
||||||
|
let old_value = verge.config.enable_system_proxy.clone().unwrap_or(false);
|
||||||
|
let new_value = !old_value;
|
||||||
|
|
||||||
|
match verge.patch_config(VergeConfig {
|
||||||
|
enable_system_proxy: Some(new_value),
|
||||||
|
..VergeConfig::default()
|
||||||
|
}) {
|
||||||
|
Ok(_) => {
|
||||||
|
app_handle
|
||||||
|
.tray_handle()
|
||||||
|
.get_item(id.as_str())
|
||||||
|
.set_selected(new_value)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// update verge config
|
||||||
|
let window = app_handle.get_window("main").unwrap();
|
||||||
|
window.emit("verge://refresh-verge-config", "yes").unwrap();
|
||||||
|
}
|
||||||
|
Err(err) => log::error!("{err}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
"restart_clash" => {
|
"restart_clash" => {
|
||||||
let clash_state = app_handle.state::<states::ClashState>();
|
let clash_state = app_handle.state::<states::ClashState>();
|
||||||
let profiles_state = app_handle.state::<states::ProfilesState>();
|
let profiles_state = app_handle.state::<states::ProfilesState>();
|
||||||
let mut clash = clash_state.0.lock().unwrap();
|
let mut clash = clash_state.0.lock().unwrap();
|
||||||
let mut profiles = profiles_state.0.lock().unwrap();
|
let mut profiles = profiles_state.0.lock().unwrap();
|
||||||
match clash.restart_sidecar(&mut profiles) {
|
|
||||||
Ok(_) => {
|
crate::log_if_err!(clash.restart_sidecar(&mut profiles));
|
||||||
let window = app_handle.get_window("main").unwrap();
|
|
||||||
window.emit("restart_clash", "yes").unwrap();
|
|
||||||
}
|
|
||||||
Err(err) => log::error!("{}", err),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"quit" => {
|
"quit" => {
|
||||||
resolve::resolve_reset(app_handle);
|
resolve::resolve_reset(app_handle);
|
||||||
@@ -60,13 +84,12 @@ fn main() -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
SystemTrayEvent::LeftClick { .. } => {
|
SystemTrayEvent::LeftClick { .. } => {
|
||||||
if cfg![target_os = "windows"] {
|
let window = app_handle.get_window("main").unwrap();
|
||||||
let window = app_handle.get_window("main").unwrap();
|
window.unminimize().unwrap();
|
||||||
window.unminimize().unwrap();
|
window.show().unwrap();
|
||||||
window.show().unwrap();
|
window.set_focus().unwrap();
|
||||||
window.set_focus().unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,12 +5,22 @@ use tauri::{
|
|||||||
Env, PackageInfo,
|
Env, PackageInfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "verge-dev"))]
|
||||||
|
static APP_DIR: &str = "clash-verge";
|
||||||
|
#[cfg(feature = "verge-dev")]
|
||||||
|
static APP_DIR: &str = "clash-verge-dev";
|
||||||
|
|
||||||
|
static CLASH_CONFIG: &str = "config.yaml";
|
||||||
|
static VERGE_CONFIG: &str = "verge.yaml";
|
||||||
|
static PROFILE_YAML: &str = "profiles.yaml";
|
||||||
|
static PROFILE_TEMP: &str = "clash-verge-runtime.yaml";
|
||||||
|
|
||||||
/// get the verge app home dir
|
/// get the verge app home dir
|
||||||
pub fn app_home_dir() -> PathBuf {
|
pub fn app_home_dir() -> PathBuf {
|
||||||
home_dir()
|
home_dir()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.join(Path::new(".config"))
|
.join(Path::new(".config"))
|
||||||
.join(Path::new("clash-verge"))
|
.join(Path::new(APP_DIR))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get the resources dir
|
/// get the resources dir
|
||||||
@@ -30,11 +40,6 @@ pub fn app_logs_dir() -> PathBuf {
|
|||||||
app_home_dir().join("logs")
|
app_home_dir().join("logs")
|
||||||
}
|
}
|
||||||
|
|
||||||
static CLASH_CONFIG: &str = "config.yaml";
|
|
||||||
static VERGE_CONFIG: &str = "verge.yaml";
|
|
||||||
static PROFILE_YAML: &str = "profiles.yaml";
|
|
||||||
static PROFILE_TEMP: &str = "clash-verge-runtime.yaml";
|
|
||||||
|
|
||||||
pub fn clash_path() -> PathBuf {
|
pub fn clash_path() -> PathBuf {
|
||||||
app_home_dir().join(CLASH_CONFIG)
|
app_home_dir().join(CLASH_CONFIG)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ macro_rules! wrap_err {
|
|||||||
/// return the string literal error
|
/// return the string literal error
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! ret_err {
|
macro_rules! ret_err {
|
||||||
($str: literal) => {
|
($str: expr) => {
|
||||||
return Err($str.into())
|
return Err($str.into())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,13 +67,13 @@ 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(&app_dir).unwrap();
|
fs::create_dir_all(&app_dir).unwrap();
|
||||||
}
|
}
|
||||||
if !log_dir.exists() {
|
if !log_dir.exists() {
|
||||||
fs::create_dir(&log_dir).unwrap();
|
fs::create_dir_all(&log_dir).unwrap();
|
||||||
}
|
}
|
||||||
if !profiles_dir.exists() {
|
if !profiles_dir.exists() {
|
||||||
fs::create_dir(&profiles_dir).unwrap();
|
fs::create_dir_all(&profiles_dir).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
init_log(&log_dir);
|
init_log(&log_dir);
|
||||||
@@ -87,4 +87,14 @@ pub fn init_app(package_info: &PackageInfo) {
|
|||||||
if !mmdb_path.exists() && mmdb_tmpl.exists() {
|
if !mmdb_path.exists() && mmdb_tmpl.exists() {
|
||||||
fs::copy(mmdb_tmpl, mmdb_path).unwrap();
|
fs::copy(mmdb_tmpl, mmdb_path).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy the wintun.dll
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
let wintun_path = app_dir.join("wintun.dll");
|
||||||
|
let wintun_tmpl = res_dir.join("wintun.dll");
|
||||||
|
if !wintun_path.exists() && wintun_tmpl.exists() {
|
||||||
|
fs::copy(wintun_tmpl, wintun_path).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,14 @@ pub fn resolve_setup(app: &App) {
|
|||||||
clash.tun_mode(true).unwrap();
|
clash.tun_mode(true).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
verge.init_launch();
|
log_if_err!(verge.init_launch());
|
||||||
log_if_err!(verge.sync_launch());
|
|
||||||
|
verge.config.enable_system_proxy.map(|enable| {
|
||||||
|
log_if_err!(app
|
||||||
|
.tray_handle()
|
||||||
|
.get_item("system_proxy")
|
||||||
|
.set_selected(enable));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// reset system proxy
|
/// reset system proxy
|
||||||
@@ -61,7 +67,7 @@ fn resolve_window(app: &App) {
|
|||||||
|
|
||||||
window.set_decorations(false).unwrap();
|
window.set_decorations(false).unwrap();
|
||||||
set_shadow(&window, true).unwrap();
|
set_shadow(&window, true).unwrap();
|
||||||
apply_blur(&window).unwrap();
|
apply_blur(&window, None).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ use port_scanner::local_port_available;
|
|||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
use warp::Filter;
|
use warp::Filter;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "verge-dev"))]
|
||||||
const SERVER_PORT: u16 = 33333;
|
const SERVER_PORT: u16 = 33333;
|
||||||
|
#[cfg(feature = "verge-dev")]
|
||||||
|
const SERVER_PORT: u16 = 11233;
|
||||||
|
|
||||||
/// check whether there is already exists
|
/// check whether there is already exists
|
||||||
pub fn check_singleton() -> Result<(), ()> {
|
pub fn check_singleton() -> Result<(), ()> {
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io;
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
static DEFAULT_BYPASS: &str = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*;<local>";
|
static DEFAULT_BYPASS: &str = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*;<local>";
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
static DEFAULT_BYPASS: &str = "localhost,127.0.0.1/8,::1";
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
static DEFAULT_BYPASS: &str =
|
static DEFAULT_BYPASS: &str =
|
||||||
"192.168.0.0/16\n10.0.0.0/8\n172.16.0.0/12\n127.0.0.1\nlocalhost\n*.local\ntimestamp.apple.com\n";
|
"192.168.0.0/16\n10.0.0.0/8\n172.16.0.0/12\n127.0.0.1\nlocalhost\n*.local\ntimestamp.apple.com\n";
|
||||||
@@ -34,10 +36,12 @@ impl SysProxyConfig {
|
|||||||
bypass: bypass.unwrap_or(DEFAULT_BYPASS.into()),
|
bypass: bypass.unwrap_or(DEFAULT_BYPASS.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
impl SysProxyConfig {
|
||||||
/// Get the windows system proxy config
|
/// Get the windows system proxy config
|
||||||
pub fn get_sys() -> io::Result<Self> {
|
pub fn get_sys() -> Result<Self> {
|
||||||
use winreg::enums::*;
|
use winreg::enums::*;
|
||||||
use winreg::RegKey;
|
use winreg::RegKey;
|
||||||
|
|
||||||
@@ -54,9 +58,30 @@ impl SysProxyConfig {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
/// Set the windows system proxy config
|
||||||
|
pub fn set_sys(&self) -> Result<()> {
|
||||||
|
use winreg::enums::*;
|
||||||
|
use winreg::RegKey;
|
||||||
|
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
|
||||||
|
let cur_var = hkcu.open_subkey_with_flags(
|
||||||
|
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
|
||||||
|
KEY_SET_VALUE,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let enable: u32 = if self.enable { 1u32 } else { 0u32 };
|
||||||
|
|
||||||
|
cur_var.set_value("ProxyEnable", &enable)?;
|
||||||
|
cur_var.set_value("ProxyServer", &self.server)?;
|
||||||
|
cur_var.set_value("ProxyOverride", &self.bypass)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
impl SysProxyConfig {
|
||||||
/// Get the macos system proxy config
|
/// Get the macos system proxy config
|
||||||
pub fn get_sys() -> io::Result<Self> {
|
pub fn get_sys() -> Result<Self> {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
let http = macproxy::get_proxy(&["-getwebproxy", MACOS_SERVICE])?;
|
let http = macproxy::get_proxy(&["-getwebproxy", MACOS_SERVICE])?;
|
||||||
@@ -82,63 +107,59 @@ impl SysProxyConfig {
|
|||||||
let bypass_output = Command::new("networksetup")
|
let bypass_output = Command::new("networksetup")
|
||||||
.args(["-getproxybypassdomains", MACOS_SERVICE])
|
.args(["-getproxybypassdomains", MACOS_SERVICE])
|
||||||
.output()?;
|
.output()?;
|
||||||
let bypass = std::str::from_utf8(&bypass_output.stdout).unwrap_or(DEFAULT_BYPASS);
|
|
||||||
|
// change the format to xxx,xxx
|
||||||
|
let bypass = std::str::from_utf8(&bypass_output.stdout)
|
||||||
|
.unwrap_or(DEFAULT_BYPASS)
|
||||||
|
.to_string()
|
||||||
|
.split('\n')
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(",");
|
||||||
|
|
||||||
Ok(SysProxyConfig {
|
Ok(SysProxyConfig {
|
||||||
enable,
|
enable,
|
||||||
server,
|
server,
|
||||||
bypass: bypass.into(),
|
bypass,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
/// Set the windows system proxy config
|
|
||||||
pub fn set_sys(&self) -> io::Result<()> {
|
|
||||||
use winreg::enums::*;
|
|
||||||
use winreg::RegKey;
|
|
||||||
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
|
|
||||||
let cur_var = hkcu.open_subkey_with_flags(
|
|
||||||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
|
|
||||||
KEY_SET_VALUE,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let enable: u32 = if self.enable { 1u32 } else { 0u32 };
|
|
||||||
|
|
||||||
cur_var.set_value("ProxyEnable", &enable)?;
|
|
||||||
cur_var.set_value("ProxyServer", &self.server)?;
|
|
||||||
cur_var.set_value("ProxyOverride", &self.bypass)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
/// Set the macos system proxy config
|
/// Set the macos system proxy config
|
||||||
pub fn set_sys(&self) -> io::Result<()> {
|
pub fn set_sys(&self) -> Result<()> {
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
let enable = self.enable;
|
let enable = self.enable;
|
||||||
let server = self.server.as_str();
|
let server = self.server.as_str();
|
||||||
|
let bypass = self.bypass.clone();
|
||||||
macproxy::set_proxy("-setwebproxy", MACOS_SERVICE, enable, server)?;
|
macproxy::set_proxy("-setwebproxy", MACOS_SERVICE, enable, server)?;
|
||||||
macproxy::set_proxy("-setsecurewebproxy", MACOS_SERVICE, enable, server)?;
|
macproxy::set_proxy("-setsecurewebproxy", MACOS_SERVICE, enable, server)?;
|
||||||
macproxy::set_proxy("-setsocksfirewallproxy", MACOS_SERVICE, enable, server)
|
macproxy::set_proxy("-setsocksfirewallproxy", MACOS_SERVICE, enable, server)?;
|
||||||
|
|
||||||
|
let domains = bypass.split(",").collect::<Vec<_>>();
|
||||||
|
Command::new("networksetup")
|
||||||
|
.args([["-setproxybypassdomains", MACOS_SERVICE].to_vec(), domains].concat())
|
||||||
|
.status()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
mod macproxy {
|
mod macproxy {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use anyhow::bail;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
/// use networksetup
|
/// use networksetup
|
||||||
/// get the target proxy config
|
/// get the target proxy config
|
||||||
pub(super) fn get_proxy(args: &[&str; 2]) -> io::Result<(String, String)> {
|
pub(super) fn get_proxy(args: &[&str; 2]) -> Result<(String, String)> {
|
||||||
let output = Command::new("networksetup").args(args).output()?;
|
let output = Command::new("networksetup").args(args).output()?;
|
||||||
match std::str::from_utf8(&output.stdout) {
|
|
||||||
Ok(stdout) => {
|
let stdout = std::str::from_utf8(&output.stdout)?;
|
||||||
let enable = parse(stdout, "Enabled:");
|
let enable = parse(stdout, "Enabled:");
|
||||||
let server = parse(stdout, "Server:");
|
let server = parse(stdout, "Server:");
|
||||||
let port = parse(stdout, "Port:");
|
let port = parse(stdout, "Port:");
|
||||||
let server = format!("{}:{}", server, port);
|
let server = format!("{server}:{port}");
|
||||||
Ok((enable.into(), server))
|
Ok((enable.into(), server))
|
||||||
}
|
|
||||||
Err(_) => Err(io::Error::from_raw_os_error(1)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// use networksetup
|
/// use networksetup
|
||||||
@@ -148,17 +169,17 @@ mod macproxy {
|
|||||||
device: &str,
|
device: &str,
|
||||||
enable: bool,
|
enable: bool,
|
||||||
server: &str,
|
server: &str,
|
||||||
) -> io::Result<()> {
|
) -> Result<()> {
|
||||||
let mut split = server.split(":");
|
let mut split = server.split(":");
|
||||||
let domain = split.next();
|
let host = split.next();
|
||||||
let port = split.next();
|
let port = split.next();
|
||||||
|
|
||||||
// can not parse the field
|
// can not parse the field
|
||||||
if domain.is_none() || port.is_none() {
|
if host.is_none() || port.is_none() {
|
||||||
return Err(io::Error::from_raw_os_error(1));
|
bail!("failed to parse the server into host:port");
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = vec![target, device, domain.unwrap(), port.unwrap()];
|
let args = vec![target, device, host.unwrap(), port.unwrap()];
|
||||||
Command::new("networksetup").args(&args).status()?;
|
Command::new("networksetup").args(&args).status()?;
|
||||||
|
|
||||||
let target_state = String::from(target) + "state";
|
let target_state = String::from(target) + "state";
|
||||||
@@ -169,7 +190,7 @@ mod macproxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// parse the networksetup output
|
/// parse the networksetup output
|
||||||
pub(super) fn parse<'a>(target: &'a str, key: &'a str) -> &'a str {
|
fn parse<'a>(target: &'a str, key: &'a str) -> &'a str {
|
||||||
match target.find(key) {
|
match target.find(key) {
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
let idx = idx + key.len();
|
let idx = idx + key.len();
|
||||||
@@ -209,3 +230,137 @@ mod macproxy {
|
|||||||
dbg!(sysproxy.set_sys().unwrap());
|
dbg!(sysproxy.set_sys().unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Linux Desktop System Proxy Supports
|
||||||
|
/// by using `gsettings`
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl SysProxyConfig {
|
||||||
|
/// Get the system proxy config [http/https/socks]
|
||||||
|
pub fn get_sys() -> Result<Self> {
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
let schema = "org.gnome.system.proxy";
|
||||||
|
|
||||||
|
// get enable
|
||||||
|
let mode = Command::new("gsettings")
|
||||||
|
.args(["get", schema, "mode"])
|
||||||
|
.output()?;
|
||||||
|
let mode = std::str::from_utf8(&mode.stdout)?;
|
||||||
|
let enable = mode == "manual";
|
||||||
|
|
||||||
|
// get bypass
|
||||||
|
// Todo: parse the ignore-hosts
|
||||||
|
// ['aaa', 'bbb'] -> aaa,bbb
|
||||||
|
let ignore = Command::new("gsettings")
|
||||||
|
.args(["get", schema, "ignore-hosts"])
|
||||||
|
.output()?;
|
||||||
|
let ignore = std::str::from_utf8(&ignore.stdout)?;
|
||||||
|
let bypass = ignore.to_string();
|
||||||
|
|
||||||
|
let http = Self::get_proxy("http")?;
|
||||||
|
let https = Self::get_proxy("https")?;
|
||||||
|
let socks = Self::get_proxy("socks")?;
|
||||||
|
|
||||||
|
let mut server = "".into();
|
||||||
|
|
||||||
|
if socks.len() > 0 {
|
||||||
|
server = socks;
|
||||||
|
}
|
||||||
|
if https.len() > 0 {
|
||||||
|
server = https;
|
||||||
|
}
|
||||||
|
if http.len() > 0 {
|
||||||
|
server = http;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(SysProxyConfig {
|
||||||
|
enable,
|
||||||
|
server,
|
||||||
|
bypass,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the system proxy config [http/https/socks]
|
||||||
|
pub fn set_sys(&self) -> Result<()> {
|
||||||
|
use anyhow::bail;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
let enable = self.enable;
|
||||||
|
let server = self.server.as_str();
|
||||||
|
let bypass = self.bypass.clone();
|
||||||
|
let schema = "org.gnome.system.proxy";
|
||||||
|
|
||||||
|
if enable {
|
||||||
|
let mut split = server.split(":");
|
||||||
|
let host = split.next();
|
||||||
|
let port = split.next();
|
||||||
|
|
||||||
|
if port.is_none() {
|
||||||
|
bail!("failed to parse the port");
|
||||||
|
}
|
||||||
|
|
||||||
|
let host = format!("'{}'", host.unwrap_or("127.0.0.1"));
|
||||||
|
let host = host.as_str();
|
||||||
|
let port = port.unwrap();
|
||||||
|
|
||||||
|
let http = format!("{schema}.http");
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", http.as_str(), "host", host])
|
||||||
|
.status()?;
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", http.as_str(), "port", port])
|
||||||
|
.status()?;
|
||||||
|
|
||||||
|
let https = format!("{schema}.https");
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", https.as_str(), "host", host])
|
||||||
|
.status()?;
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", https.as_str(), "port", port])
|
||||||
|
.status()?;
|
||||||
|
|
||||||
|
let socks = format!("{schema}.socks");
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", socks.as_str(), "host", host])
|
||||||
|
.status()?;
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", socks.as_str(), "port", port])
|
||||||
|
.status()?;
|
||||||
|
|
||||||
|
// set bypass
|
||||||
|
// Todo: parse the ignore-hosts
|
||||||
|
// aaa,bbb,cccc -> ['aaa', 'bbb', 'ccc']
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", schema, "ignore-hosts", bypass.as_str()]) // todo
|
||||||
|
.status()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mode = if enable { "'manual'" } else { "'none'" };
|
||||||
|
Command::new("gsettings")
|
||||||
|
.args(["set", schema, "mode", mode])
|
||||||
|
.status()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// help function
|
||||||
|
fn get_proxy(typ: &str) -> Result<String> {
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
let schema = format!("org.gnome.system.proxy.{typ}");
|
||||||
|
let schema = schema.as_str();
|
||||||
|
|
||||||
|
let host = Command::new("gsettings")
|
||||||
|
.args(["get", schema, "host"])
|
||||||
|
.output()?;
|
||||||
|
let host = std::str::from_utf8(&host.stdout)?;
|
||||||
|
|
||||||
|
let port = Command::new("gsettings")
|
||||||
|
.args(["get", schema, "port"])
|
||||||
|
.output()?;
|
||||||
|
let port = std::str::from_utf8(&port.stdout)?;
|
||||||
|
|
||||||
|
Ok(format!("{host}:{port}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ items: ~
|
|||||||
/// template for `verge.yaml`
|
/// template for `verge.yaml`
|
||||||
pub const VERGE_CONFIG: &[u8] = b"# Defaulf Config For Clash Verge
|
pub const VERGE_CONFIG: &[u8] = b"# Defaulf Config For Clash Verge
|
||||||
|
|
||||||
|
language: en
|
||||||
theme_mode: light
|
theme_mode: light
|
||||||
theme_blur: false
|
theme_blur: false
|
||||||
traffic_graph: true
|
traffic_graph: true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "clash-verge",
|
"productName": "Clash Verge",
|
||||||
"version": "0.0.21"
|
"version": "0.0.24"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"distDir": "../dist",
|
"distDir": "../dist",
|
||||||
@@ -52,7 +52,8 @@
|
|||||||
"updater": {
|
"updater": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
"https://github.com/zzzgydi/clash-verge/releases/download/updater/update.json"
|
"https://github.com/zzzgydi/clash-verge/releases/download/updater/update.json",
|
||||||
|
"https://hub.fastgit.xyz/zzzgydi/clash-verge/releases/download/updater/update-proxy.json"
|
||||||
],
|
],
|
||||||
"dialog": false,
|
"dialog": false,
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDExNUFBNTBBN0FDNEFBRTUKUldUbHFzUjZDcVZhRVRJM25NS3NkSFlFVElxUkNZMzZ6bHUwRVJjb2F3alJXVzRaeDdSaTA2YWYK"
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDExNUFBNTBBN0FDNEFBRTUKUldUbHFzUjZDcVZhRVRJM25NS3NkSFlFVElxUkNZMzZ6bHUwRVJjb2F3alJXVzRaeDdSaTA2YWYK"
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
.the-content {
|
.the-content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 30px;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 2px;
|
right: 2px;
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
@@ -80,8 +80,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.macos.layout {
|
.windows.layout {
|
||||||
.layout__right .the-content {
|
.layout__right .the-content {
|
||||||
top: 0;
|
top: 30px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,20 @@
|
|||||||
|
import dayjs from "dayjs";
|
||||||
|
import { useLockFn } from "ahooks";
|
||||||
|
import { styled, Box, ListItem, IconButton, ListItemText } from "@mui/material";
|
||||||
|
import { CloseRounded } from "@mui/icons-material";
|
||||||
import { ApiType } from "../../services/types";
|
import { ApiType } from "../../services/types";
|
||||||
|
import { deleteConnection } from "../../services/api";
|
||||||
|
|
||||||
|
const Tag = styled(Box)(({ theme }) => ({
|
||||||
|
display: "inline-block",
|
||||||
|
fontSize: "12px",
|
||||||
|
padding: "0 4px",
|
||||||
|
lineHeight: 1.375,
|
||||||
|
border: "1px solid #ccc",
|
||||||
|
borderRadius: 4,
|
||||||
|
marginRight: "0.1em",
|
||||||
|
transform: "scale(0.92)",
|
||||||
|
}));
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value: ApiType.ConnectionsItem;
|
value: ApiType.ConnectionsItem;
|
||||||
@@ -7,7 +23,34 @@ interface Props {
|
|||||||
const ConnectionItem = (props: Props) => {
|
const ConnectionItem = (props: Props) => {
|
||||||
const { value } = props;
|
const { value } = props;
|
||||||
|
|
||||||
return <div>{value.metadata.host || value.metadata.destinationIP}</div>;
|
const onDelete = useLockFn(async () => deleteConnection(value.id));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ListItem
|
||||||
|
dense
|
||||||
|
secondaryAction={
|
||||||
|
<IconButton edge="end" onClick={onDelete}>
|
||||||
|
<CloseRounded />
|
||||||
|
</IconButton>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<ListItemText
|
||||||
|
primary={value.metadata.host || value.metadata.destinationIP}
|
||||||
|
secondary={
|
||||||
|
<Box>
|
||||||
|
<Tag sx={{ textTransform: "uppercase", color: "success" }}>
|
||||||
|
{value.metadata.network}
|
||||||
|
</Tag>
|
||||||
|
<Tag>{value.metadata.type}</Tag>
|
||||||
|
{value.chains.length > 0 && (
|
||||||
|
<Tag>{value.chains[value.chains.length - 1]}</Tag>
|
||||||
|
)}
|
||||||
|
<Tag>{dayjs(value.start).fromNow()}</Tag>
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</ListItem>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ConnectionItem;
|
export default ConnectionItem;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import useLogSetup from "./use-log-setup";
|
|||||||
import useTrafficGraph from "./use-traffic-graph";
|
import useTrafficGraph from "./use-traffic-graph";
|
||||||
import parseTraffic from "../../utils/parse-traffic";
|
import parseTraffic from "../../utils/parse-traffic";
|
||||||
|
|
||||||
|
// setup the traffic
|
||||||
const LayoutTraffic = () => {
|
const LayoutTraffic = () => {
|
||||||
const portValue = useRecoilValue(atomClashPort);
|
const portValue = useRecoilValue(atomClashPort);
|
||||||
const [traffic, setTraffic] = useState({ up: 0, down: 0 });
|
const [traffic, setTraffic] = useState({ up: 0, down: 0 });
|
||||||
@@ -26,12 +27,14 @@ const LayoutTraffic = () => {
|
|||||||
useLogSetup();
|
useLogSetup();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let unlisten: () => void = null!;
|
|
||||||
|
|
||||||
// should reconnect the traffic ws
|
// should reconnect the traffic ws
|
||||||
listen("restart_clash", () => setRefresh({})).then((fn) => (unlisten = fn));
|
const unlisten = listen("verge://refresh-clash-config", () =>
|
||||||
|
setRefresh({})
|
||||||
|
);
|
||||||
|
|
||||||
return () => unlisten?.();
|
return () => {
|
||||||
|
unlisten.then((fn) => fn());
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ const UpdateButton = (props: Props) => {
|
|||||||
New
|
New
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<UpdateDialog open={dialogOpen} onClose={() => setDialogOpen(false)} />
|
{dialogOpen && (
|
||||||
|
<UpdateDialog open={dialogOpen} onClose={() => setDialogOpen(false)} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { useState } from "react";
|
import snarkdown from "snarkdown";
|
||||||
|
import { useState, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogActions,
|
DialogActions,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogContentText,
|
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
styled,
|
||||||
} 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";
|
||||||
@@ -18,6 +20,10 @@ interface Props {
|
|||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const UpdateLog = styled(Box)(() => ({
|
||||||
|
"h1,h2,h3,ul,ol,p": { margin: "0.5em 0", color: "inherit" },
|
||||||
|
}));
|
||||||
|
|
||||||
let uploadingState = false;
|
let uploadingState = false;
|
||||||
|
|
||||||
const UpdateDialog = (props: Props) => {
|
const UpdateDialog = (props: Props) => {
|
||||||
@@ -34,8 +40,8 @@ const UpdateDialog = (props: Props) => {
|
|||||||
uploadingState = true;
|
uploadingState = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await killSidecars();
|
|
||||||
await installUpdate();
|
await installUpdate();
|
||||||
|
await killSidecars();
|
||||||
await relaunch();
|
await relaunch();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
await restartSidecar();
|
await restartSidecar();
|
||||||
@@ -46,19 +52,29 @@ const UpdateDialog = (props: Props) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// markdown parser
|
||||||
|
const parseContent = useMemo(() => {
|
||||||
|
if (!updateInfo?.manifest?.body) {
|
||||||
|
return "New Version is available";
|
||||||
|
}
|
||||||
|
return snarkdown(updateInfo?.manifest?.body);
|
||||||
|
}, [updateInfo]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onClose={onClose}>
|
<Dialog open={open} onClose={onClose}>
|
||||||
<DialogTitle>New Version v{updateInfo?.manifest?.version}</DialogTitle>
|
<DialogTitle>New Version v{updateInfo?.manifest?.version}</DialogTitle>
|
||||||
|
|
||||||
<DialogContent sx={{ minWidth: 360, maxWidth: 400, maxHeight: "50vh" }}>
|
<DialogContent sx={{ minWidth: 360, maxWidth: 400, maxHeight: "50vh" }}>
|
||||||
<DialogContentText>{updateInfo?.manifest?.body}</DialogContentText>
|
<UpdateLog dangerouslySetInnerHTML={{ __html: parseContent }} />
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={onClose}>Cancel</Button>
|
<Button onClick={onClose}>Cancel</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
|
||||||
autoFocus
|
autoFocus
|
||||||
onClick={onUpdate}
|
variant="contained"
|
||||||
disabled={uploading}
|
disabled={uploading}
|
||||||
|
onClick={onUpdate}
|
||||||
>
|
>
|
||||||
Update
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { useEffect } 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 { ApiType } from "../../services/types";
|
||||||
@@ -10,11 +10,11 @@ const MAX_LOG_NUM = 1000;
|
|||||||
|
|
||||||
// setup the log websocket
|
// setup the log websocket
|
||||||
export default function useLogSetup() {
|
export default function useLogSetup() {
|
||||||
|
const [refresh, setRefresh] = useState({});
|
||||||
const setLogData = useSetRecoilState(atomLogData);
|
const setLogData = useSetRecoilState(atomLogData);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let ws: WebSocket = null!;
|
let ws: WebSocket = null!;
|
||||||
let unlisten: () => void = null!;
|
|
||||||
|
|
||||||
const handler = (event: MessageEvent<any>) => {
|
const handler = (event: MessageEvent<any>) => {
|
||||||
const data = JSON.parse(event.data) as ApiType.LogItem;
|
const data = JSON.parse(event.data) as ApiType.LogItem;
|
||||||
@@ -25,25 +25,19 @@ export default function useLogSetup() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
(async () => {
|
getInfomation().then((info) => {
|
||||||
const { server = "", secret = "" } = await getInfomation();
|
const { server = "", secret = "" } = info;
|
||||||
|
|
||||||
ws = new WebSocket(`ws://${server}/logs?token=${secret}`);
|
ws = new WebSocket(`ws://${server}/logs?token=${secret}`);
|
||||||
ws.addEventListener("message", handler);
|
ws.addEventListener("message", handler);
|
||||||
|
});
|
||||||
|
|
||||||
// reconnect the websocket
|
const unlisten = listen("verge://refresh-clash-config", () =>
|
||||||
unlisten = await listen("restart_clash", async () => {
|
setRefresh({})
|
||||||
const { server = "", secret = "" } = await getInfomation();
|
);
|
||||||
|
|
||||||
ws?.close();
|
|
||||||
ws = new WebSocket(`ws://${server}/logs?token=${secret}`);
|
|
||||||
ws.addEventListener("message", handler);
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
ws?.close();
|
ws?.close();
|
||||||
unlisten?.();
|
unlisten?.then((fn) => fn());
|
||||||
};
|
};
|
||||||
}, []);
|
}, [refresh]);
|
||||||
}
|
}
|
||||||
|
|||||||
61
src/components/profile/file-input.tsx
Normal file
61
src/components/profile/file-input.tsx
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import { useRef, useState } from "react";
|
||||||
|
import { useLockFn } from "ahooks";
|
||||||
|
import { Box, Button, Typography } from "@mui/material";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FileInput = (props: Props) => {
|
||||||
|
const { onChange } = props;
|
||||||
|
|
||||||
|
// file input
|
||||||
|
const inputRef = useRef<any>();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [fileName, setFileName] = useState("");
|
||||||
|
|
||||||
|
const onFileInput = useLockFn(async (e: any) => {
|
||||||
|
const file = e.target.files?.[0] as File;
|
||||||
|
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
setFileName(file.name);
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = (event) => {
|
||||||
|
resolve(null);
|
||||||
|
onChange(event.target?.result as string);
|
||||||
|
};
|
||||||
|
reader.onerror = reject;
|
||||||
|
reader.readAsText(file);
|
||||||
|
}).finally(() => setLoading(false));
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={{ mt: 2, mb: 1, display: "flex", alignItems: "center" }}>
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
sx={{ flex: "none" }}
|
||||||
|
onClick={() => inputRef.current?.click()}
|
||||||
|
>
|
||||||
|
Choose File
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept=".yaml,.yml"
|
||||||
|
ref={inputRef}
|
||||||
|
style={{ display: "none" }}
|
||||||
|
onChange={onFileInput}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Typography noWrap sx={{ ml: 1 }}>
|
||||||
|
{loading ? "Loading..." : fileName}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FileInput;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { mutate } from "swr";
|
import { mutate } from "swr";
|
||||||
import { useEffect } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useLockFn, useSetState } from "ahooks";
|
import { useLockFn, useSetState } from "ahooks";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -7,8 +7,10 @@ import {
|
|||||||
DialogActions,
|
DialogActions,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
IconButton,
|
||||||
TextField,
|
TextField,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import { Settings } from "@mui/icons-material";
|
||||||
import { CmdType } from "../../services/types";
|
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";
|
||||||
@@ -20,13 +22,18 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// edit the profile item
|
// edit the profile item
|
||||||
|
// remote / local file / merge / script
|
||||||
const ProfileEdit = (props: Props) => {
|
const ProfileEdit = (props: Props) => {
|
||||||
const { open, itemData, onClose } = props;
|
const { open, itemData, onClose } = props;
|
||||||
const [form, setForm] = useSetState({ ...itemData });
|
const [form, setForm] = useSetState({ ...itemData });
|
||||||
|
const [option, setOption] = useSetState(itemData.option ?? {});
|
||||||
|
const [showOpt, setShowOpt] = useState(!!itemData.option);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (itemData) {
|
if (itemData) {
|
||||||
setForm({ ...itemData });
|
setForm({ ...itemData });
|
||||||
|
setOption(itemData.option ?? {});
|
||||||
|
setShowOpt(!!itemData.option?.user_agent);
|
||||||
}
|
}
|
||||||
}, [itemData]);
|
}, [itemData]);
|
||||||
|
|
||||||
@@ -34,7 +41,14 @@ const ProfileEdit = (props: Props) => {
|
|||||||
try {
|
try {
|
||||||
const { uid } = itemData;
|
const { uid } = itemData;
|
||||||
const { name, desc, url } = form;
|
const { name, desc, url } = form;
|
||||||
await patchProfile(uid, { uid, name, desc, url });
|
const option_ = itemData.type === "remote" ? option : undefined;
|
||||||
|
|
||||||
|
if (itemData.type === "remote" && !url) {
|
||||||
|
throw new Error("Remote URL should not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
await patchProfile(uid, { uid, name, desc, url, option: option_ });
|
||||||
|
setShowOpt(false);
|
||||||
mutate("getProfiles");
|
mutate("getProfiles");
|
||||||
onClose();
|
onClose();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@@ -89,9 +103,28 @@ const ProfileEdit = (props: Props) => {
|
|||||||
onChange={(e) => setForm({ url: e.target.value })}
|
onChange={(e) => setForm({ url: e.target.value })}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showOpt && (
|
||||||
|
<TextField
|
||||||
|
{...textFieldProps}
|
||||||
|
label="User Agent"
|
||||||
|
value={option.user_agent}
|
||||||
|
onChange={(e) => setOption({ user_agent: e.target.value })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogActions sx={{ px: 2, pb: 2 }}>
|
<DialogActions sx={{ px: 2, pb: 2, position: "relative" }}>
|
||||||
|
{form.type === "remote" && (
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
sx={{ position: "absolute", left: 18 }}
|
||||||
|
onClick={() => setShowOpt((o) => !o)}
|
||||||
|
>
|
||||||
|
<Settings />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button onClick={onClose}>Cancel</Button>
|
<Button onClick={onClose}>Cancel</Button>
|
||||||
<Button onClick={onUpdate} variant="contained">
|
<Button onClick={onUpdate} variant="contained">
|
||||||
Update
|
Update
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import dayjs from "dayjs";
|
|||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { useSWRConfig } from "swr";
|
import { useSWRConfig } from "swr";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
alpha,
|
alpha,
|
||||||
Box,
|
Box,
|
||||||
@@ -16,13 +17,10 @@ import {
|
|||||||
import { RefreshRounded } from "@mui/icons-material";
|
import { RefreshRounded } from "@mui/icons-material";
|
||||||
import { CmdType } from "../../services/types";
|
import { CmdType } from "../../services/types";
|
||||||
import { updateProfile, deleteProfile, viewProfile } from "../../services/cmds";
|
import { updateProfile, deleteProfile, viewProfile } from "../../services/cmds";
|
||||||
import relativeTime from "dayjs/plugin/relativeTime";
|
|
||||||
import parseTraffic from "../../utils/parse-traffic";
|
import parseTraffic from "../../utils/parse-traffic";
|
||||||
import ProfileEdit from "./profile-edit";
|
import ProfileEdit from "./profile-edit";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
const Wrapper = styled(Box)(({ theme }) => ({
|
const Wrapper = styled(Box)(({ theme }) => ({
|
||||||
width: "100%",
|
width: "100%",
|
||||||
display: "block",
|
display: "block",
|
||||||
@@ -51,6 +49,7 @@ interface Props {
|
|||||||
const ProfileItem = (props: Props) => {
|
const ProfileItem = (props: Props) => {
|
||||||
const { selected, itemData, onSelect } = props;
|
const { selected, itemData, onSelect } = props;
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const [loading, setLoading] = useState(loadingCache[itemData.uid] ?? false);
|
const [loading, setLoading] = useState(loadingCache[itemData.uid] ?? false);
|
||||||
const [anchorEl, setAnchorEl] = useState<any>(null);
|
const [anchorEl, setAnchorEl] = useState<any>(null);
|
||||||
@@ -98,7 +97,7 @@ const ProfileItem = (props: Props) => {
|
|||||||
if (loading) return;
|
if (loading) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
await updateProfile(itemData.uid, withProxy);
|
await updateProfile(itemData.uid, { with_proxy: withProxy });
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
mutate("getProfiles");
|
mutate("getProfiles");
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@@ -271,7 +270,7 @@ const ProfileItem = (props: Props) => {
|
|||||||
onClick={item.handler}
|
onClick={item.handler}
|
||||||
sx={{ minWidth: 133 }}
|
sx={{ minWidth: 133 }}
|
||||||
>
|
>
|
||||||
{item.label}
|
{t(item.label)}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
alpha,
|
alpha,
|
||||||
Box,
|
Box,
|
||||||
@@ -11,13 +12,10 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { CmdType } from "../../services/types";
|
import { CmdType } from "../../services/types";
|
||||||
import { viewProfile } from "../../services/cmds";
|
import { viewProfile } from "../../services/cmds";
|
||||||
import relativeTime from "dayjs/plugin/relativeTime";
|
|
||||||
import ProfileEdit from "./profile-edit";
|
import ProfileEdit from "./profile-edit";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
import enhance from "../../services/enhance";
|
import enhance from "../../services/enhance";
|
||||||
|
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
|
|
||||||
const Wrapper = styled(Box)(({ theme }) => ({
|
const Wrapper = styled(Box)(({ theme }) => ({
|
||||||
width: "100%",
|
width: "100%",
|
||||||
display: "block",
|
display: "block",
|
||||||
@@ -54,6 +52,8 @@ const ProfileMore = (props: Props) => {
|
|||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const { uid, type } = itemData;
|
const { uid, type } = itemData;
|
||||||
|
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);
|
||||||
@@ -221,7 +221,7 @@ const ProfileMore = (props: Props) => {
|
|||||||
onClick={item.handler}
|
onClick={item.handler}
|
||||||
sx={{ minWidth: 133 }}
|
sx={{ minWidth: 133 }}
|
||||||
>
|
>
|
||||||
{item.label}
|
{t(item.label)}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useRef, useState } from "react";
|
||||||
import { useSWRConfig } from "swr";
|
import { useSWRConfig } from "swr";
|
||||||
import { useLockFn, useSetState } from "ahooks";
|
import { useLockFn, useSetState } from "ahooks";
|
||||||
import {
|
import {
|
||||||
@@ -7,13 +8,16 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
IconButton,
|
||||||
InputLabel,
|
InputLabel,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
Select,
|
Select,
|
||||||
TextField,
|
TextField,
|
||||||
} from "@mui/material";
|
} from "@mui/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";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -27,12 +31,18 @@ const ProfileNew = (props: Props) => {
|
|||||||
|
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const [form, setForm] = useSetState({
|
const [form, setForm] = useSetState({
|
||||||
|
type: "remote",
|
||||||
name: "",
|
name: "",
|
||||||
desc: "",
|
desc: "",
|
||||||
type: "remote",
|
|
||||||
url: "",
|
url: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [showOpt, setShowOpt] = useState(false);
|
||||||
|
// can add more option
|
||||||
|
const [option, setOption] = useSetState({ user_agent: "" });
|
||||||
|
// file input
|
||||||
|
const fileDataRef = useRef<string | null>(null);
|
||||||
|
|
||||||
const onCreate = useLockFn(async () => {
|
const onCreate = useLockFn(async () => {
|
||||||
if (!form.type) {
|
if (!form.type) {
|
||||||
Notice.error("`Type` should not be null");
|
Notice.error("`Type` should not be null");
|
||||||
@@ -40,8 +50,23 @@ const ProfileNew = (props: Props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await createProfile({ ...form });
|
const name = form.name || `${form.type} file`;
|
||||||
setForm({ name: "", desc: "", type: "remote", url: "" });
|
|
||||||
|
if (form.type === "remote" && !form.url) {
|
||||||
|
throw new Error("The URL should not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
const option_ = form.type === "remote" ? option : undefined;
|
||||||
|
const item = { ...form, name, option: option_ };
|
||||||
|
const fileData = form.type === "local" ? fileDataRef.current : null;
|
||||||
|
|
||||||
|
await createProfile(item, fileData);
|
||||||
|
|
||||||
|
setForm({ type: "remote", name: "", desc: "", url: "" });
|
||||||
|
setOption({ user_agent: "" });
|
||||||
|
setShowOpt(false);
|
||||||
|
fileDataRef.current = null;
|
||||||
|
|
||||||
mutate("getProfiles");
|
mutate("getProfiles");
|
||||||
onClose();
|
onClose();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@@ -61,17 +86,10 @@ const ProfileNew = (props: Props) => {
|
|||||||
<DialogTitle sx={{ pb: 0.5 }}>Create Profile</DialogTitle>
|
<DialogTitle sx={{ pb: 0.5 }}>Create Profile</DialogTitle>
|
||||||
|
|
||||||
<DialogContent sx={{ width: 336, pb: 1 }}>
|
<DialogContent sx={{ width: 336, pb: 1 }}>
|
||||||
<TextField
|
|
||||||
{...textFieldProps}
|
|
||||||
autoFocus
|
|
||||||
label="Name"
|
|
||||||
value={form.name}
|
|
||||||
onChange={(e) => setForm({ name: e.target.value })}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormControl size="small" fullWidth sx={{ mt: 2, mb: 1 }}>
|
<FormControl size="small" fullWidth sx={{ mt: 2, mb: 1 }}>
|
||||||
<InputLabel>Type</InputLabel>
|
<InputLabel>Type</InputLabel>
|
||||||
<Select
|
<Select
|
||||||
|
autoFocus
|
||||||
label="Type"
|
label="Type"
|
||||||
value={form.type}
|
value={form.type}
|
||||||
onChange={(e) => setForm({ type: e.target.value })}
|
onChange={(e) => setForm({ type: e.target.value })}
|
||||||
@@ -83,9 +101,18 @@ const ProfileNew = (props: Props) => {
|
|||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
{...textFieldProps}
|
||||||
|
label="Name"
|
||||||
|
autoComplete="off"
|
||||||
|
value={form.name}
|
||||||
|
onChange={(e) => setForm({ name: e.target.value })}
|
||||||
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
{...textFieldProps}
|
{...textFieldProps}
|
||||||
label="Descriptions"
|
label="Descriptions"
|
||||||
|
autoComplete="off"
|
||||||
value={form.desc}
|
value={form.desc}
|
||||||
onChange={(e) => setForm({ desc: e.target.value })}
|
onChange={(e) => setForm({ desc: e.target.value })}
|
||||||
/>
|
/>
|
||||||
@@ -94,13 +121,38 @@ const ProfileNew = (props: Props) => {
|
|||||||
<TextField
|
<TextField
|
||||||
{...textFieldProps}
|
{...textFieldProps}
|
||||||
label="Subscription Url"
|
label="Subscription Url"
|
||||||
|
autoComplete="off"
|
||||||
value={form.url}
|
value={form.url}
|
||||||
onChange={(e) => setForm({ url: e.target.value })}
|
onChange={(e) => setForm({ url: e.target.value })}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{form.type === "local" && (
|
||||||
|
<FileInput onChange={(val) => (fileDataRef.current = val)} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showOpt && (
|
||||||
|
<TextField
|
||||||
|
{...textFieldProps}
|
||||||
|
label="User Agent"
|
||||||
|
autoComplete="off"
|
||||||
|
value={option.user_agent}
|
||||||
|
onChange={(e) => setOption({ user_agent: e.target.value })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogActions sx={{ px: 2, pb: 2 }}>
|
<DialogActions sx={{ px: 2, pb: 2, position: "relative" }}>
|
||||||
|
{form.type === "remote" && (
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
sx={{ position: "absolute", left: 18 }}
|
||||||
|
onClick={() => setShowOpt((o) => !o)}
|
||||||
|
>
|
||||||
|
<Settings />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button onClick={onClose}>Cancel</Button>
|
<Button onClick={onClose}>Cancel</Button>
|
||||||
<Button onClick={onCreate} variant="contained">
|
<Button onClick={onCreate} variant="contained">
|
||||||
Create
|
Create
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const ProxyGroup = ({ group }: Props) => {
|
|||||||
} else {
|
} else {
|
||||||
profile.selected[index] = { name: group.name, now: name };
|
profile.selected[index] = { name: group.name, now: name };
|
||||||
}
|
}
|
||||||
await patchProfile(profiles!.current!, profile);
|
await patchProfile(profiles!.current!, { selected: profile.selected });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import useSWR, { useSWRConfig } from "swr";
|
import useSWR, { useSWRConfig } from "swr";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
ListItemText,
|
ListItemText,
|
||||||
TextField,
|
TextField,
|
||||||
@@ -21,15 +22,16 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SettingClash = ({ onError }: Props) => {
|
const SettingClash = ({ onError }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { data: clashConfig } = useSWR("getClashConfig", getClashConfig);
|
const { data: clashConfig } = useSWR("getClashConfig", getClashConfig);
|
||||||
const { data: versionData } = useSWR("getVersion", getVersion);
|
const { data: versionData } = useSWR("getVersion", getVersion);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ipv6 = false,
|
ipv6,
|
||||||
"allow-lan": allowLan = false,
|
"allow-lan": allowLan,
|
||||||
"log-level": logLevel = "silent",
|
"log-level": logLevel,
|
||||||
"mixed-port": mixedPort = 0,
|
"mixed-port": mixedPort,
|
||||||
} = clashConfig ?? {};
|
} = clashConfig ?? {};
|
||||||
|
|
||||||
const setGlobalClashPort = useSetRecoilState(atomClashPort);
|
const setGlobalClashPort = useSetRecoilState(atomClashPort);
|
||||||
@@ -64,11 +66,11 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
: versionData?.version || "-";
|
: versionData?.version || "-";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingList title="Clash Setting">
|
<SettingList title={t("Clash Setting")}>
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Allow Lan" />
|
<ListItemText primary={t("Allow Lan")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={allowLan}
|
value={allowLan ?? false}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
@@ -80,9 +82,9 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="IPv6" />
|
<ListItemText primary={t("IPv6")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={ipv6}
|
value={ipv6 ?? false}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
@@ -94,9 +96,9 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Log Level" />
|
<ListItemText primary={t("Log Level")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={logLevel}
|
value={logLevel ?? "info"}
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={(e: any) => e.target.value}
|
onFormat={(e: any) => e.target.value}
|
||||||
onChange={(e) => onChangeData({ "log-level": e })}
|
onChange={(e) => onChangeData({ "log-level": e })}
|
||||||
@@ -113,9 +115,9 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Mixed Port" />
|
<ListItemText primary={t("Mixed Port")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={mixedPort!}
|
value={mixedPort ?? 0}
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={(e: any) => +e.target.value?.replace(/\D+/, "")}
|
onFormat={(e: any) => +e.target.value?.replace(/\D+/, "")}
|
||||||
onChange={(e) => onChangeData({ "mixed-port": e })}
|
onChange={(e) => onChangeData({ "mixed-port": e })}
|
||||||
@@ -127,7 +129,7 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Clash core" />
|
<ListItemText primary={t("Clash core")} />
|
||||||
<Typography sx={{ py: 1 }}>{clashVer}</Typography>
|
<Typography sx={{ py: 1 }}>{clashVer}</Typography>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</SettingList>
|
</SettingList>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import useSWR, { useSWRConfig } from "swr";
|
import useSWR, { useSWRConfig } from "swr";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { Box, ListItemText, Switch, TextField } from "@mui/material";
|
import { Box, ListItemText, Switch, TextField } from "@mui/material";
|
||||||
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
||||||
import { SettingList, SettingItem } from "./setting";
|
import { SettingList, SettingItem } from "./setting";
|
||||||
@@ -11,15 +12,16 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SettingSystem = ({ onError }: Props) => {
|
const SettingSystem = ({ onError }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
enable_tun_mode = false,
|
enable_tun_mode,
|
||||||
enable_auto_launch = false,
|
enable_auto_launch,
|
||||||
enable_system_proxy = false,
|
enable_system_proxy,
|
||||||
system_proxy_bypass = "",
|
system_proxy_bypass,
|
||||||
enable_proxy_guard = false,
|
enable_proxy_guard,
|
||||||
} = vergeConfig ?? {};
|
} = vergeConfig ?? {};
|
||||||
|
|
||||||
const onSwitchFormat = (_e: any, value: boolean) => value;
|
const onSwitchFormat = (_e: any, value: boolean) => value;
|
||||||
@@ -28,11 +30,11 @@ const SettingSystem = ({ onError }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingList title="System Setting">
|
<SettingList title={t("System Setting")}>
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Tun Mode" />
|
<ListItemText primary={t("Tun Mode")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={enable_tun_mode}
|
value={enable_tun_mode ?? false}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
@@ -44,9 +46,9 @@ const SettingSystem = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Auto Launch" />
|
<ListItemText primary={t("Auto Launch")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={enable_auto_launch}
|
value={enable_auto_launch ?? false}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
@@ -61,13 +63,13 @@ const SettingSystem = ({ onError }: Props) => {
|
|||||||
<ListItemText
|
<ListItemText
|
||||||
primary={
|
primary={
|
||||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||||
System Proxy
|
{t("System Proxy")}
|
||||||
<SysproxyTooltip />
|
<SysproxyTooltip />
|
||||||
</Box>
|
</Box>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<GuardState
|
<GuardState
|
||||||
value={enable_system_proxy}
|
value={enable_system_proxy ?? false}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
@@ -83,9 +85,9 @@ const SettingSystem = ({ onError }: Props) => {
|
|||||||
|
|
||||||
{enable_system_proxy && (
|
{enable_system_proxy && (
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Proxy Guard" />
|
<ListItemText primary={t("Proxy Guard")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={enable_proxy_guard}
|
value={enable_proxy_guard ?? false}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
@@ -99,7 +101,7 @@ const SettingSystem = ({ onError }: Props) => {
|
|||||||
|
|
||||||
{enable_system_proxy && (
|
{enable_system_proxy && (
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Proxy Bypass" />
|
<ListItemText primary={t("Proxy Bypass")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={system_proxy_bypass ?? ""}
|
value={system_proxy_bypass ?? ""}
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
import useSWR, { useSWRConfig } from "swr";
|
import useSWR, { useSWRConfig } from "swr";
|
||||||
import { IconButton, ListItemText, Switch, Typography } from "@mui/material";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {
|
||||||
|
IconButton,
|
||||||
|
ListItemText,
|
||||||
|
MenuItem,
|
||||||
|
Select,
|
||||||
|
Switch,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
import {
|
import {
|
||||||
getVergeConfig,
|
getVergeConfig,
|
||||||
openAppDir,
|
openAppDir,
|
||||||
@@ -18,11 +26,11 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SettingVerge = ({ onError }: Props) => {
|
const SettingVerge = ({ onError }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
||||||
|
|
||||||
const { theme_mode = "light", theme_blur = false, traffic_graph } =
|
const { theme_mode, theme_blur, traffic_graph, language } = vergeConfig ?? {};
|
||||||
vergeConfig ?? {};
|
|
||||||
|
|
||||||
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>) => {
|
||||||
@@ -30,9 +38,9 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingList title="Verge Setting">
|
<SettingList title={t("Verge Setting")}>
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Theme Mode" />
|
<ListItemText primary={t("Theme Mode")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={theme_mode === "dark"}
|
value={theme_mode === "dark"}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
@@ -48,9 +56,9 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Theme Blur" />
|
<ListItemText primary={t("Theme Blur")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={theme_blur}
|
value={theme_blur ?? false}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
@@ -62,7 +70,7 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Traffic Graph" />
|
<ListItemText primary={t("Traffic Graph")} />
|
||||||
<GuardState
|
<GuardState
|
||||||
value={traffic_graph ?? true}
|
value={traffic_graph ?? true}
|
||||||
valueProps="checked"
|
valueProps="checked"
|
||||||
@@ -76,21 +84,37 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Open App Dir" />
|
<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("Open App Dir")} />
|
||||||
<IconButton color="inherit" size="small" onClick={openAppDir}>
|
<IconButton color="inherit" size="small" onClick={openAppDir}>
|
||||||
<ArrowForward />
|
<ArrowForward />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Open Logs Dir" />
|
<ListItemText primary={t("Open Logs Dir")} />
|
||||||
<IconButton color="inherit" size="small" onClick={openLogsDir}>
|
<IconButton color="inherit" size="small" onClick={openLogsDir}>
|
||||||
<ArrowForward />
|
<ArrowForward />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Version" />
|
<ListItemText primary={t("Version")} />
|
||||||
<Typography sx={{ py: "6px" }}>v{version}</Typography>
|
<Typography sx={{ py: "6px" }}>v{version}</Typography>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</SettingList>
|
</SettingList>
|
||||||
|
|||||||
54
src/locales/en.json
Normal file
54
src/locales/en.json
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"Label-Proxies": "Proxies",
|
||||||
|
"Label-Profiles": "Profiles",
|
||||||
|
"Label-Connections": "Connections",
|
||||||
|
"Label-Logs": "Logs",
|
||||||
|
"Label-Settings": "Settings",
|
||||||
|
|
||||||
|
"Connections": "Connections",
|
||||||
|
"Logs": "Logs",
|
||||||
|
"Clear": "Clear",
|
||||||
|
"Proxies": "Proxies",
|
||||||
|
"Proxy Groups": "Proxy Groups",
|
||||||
|
"rule": "rule",
|
||||||
|
"global": "global",
|
||||||
|
"direct": "direct",
|
||||||
|
"Profiles": "Profiles",
|
||||||
|
"Profile URL": "Profile URL",
|
||||||
|
"Import": "Import",
|
||||||
|
"New": "New",
|
||||||
|
"Close All": "Close All",
|
||||||
|
"Select": "Select",
|
||||||
|
"Edit": "Edit",
|
||||||
|
"File": "File",
|
||||||
|
"Update": "Update",
|
||||||
|
"Update(Proxy)": "Update(Proxy)",
|
||||||
|
"Delete": "Delete",
|
||||||
|
"Enable": "Enable",
|
||||||
|
"Disable": "Disable",
|
||||||
|
"Refresh": "Refresh",
|
||||||
|
"To Top": "To Top",
|
||||||
|
"To End": "To End",
|
||||||
|
|
||||||
|
"Settings": "Settings",
|
||||||
|
"Clash Setting": "Clash Setting",
|
||||||
|
"System Setting": "System Setting",
|
||||||
|
"Verge Setting": "Verge Setting",
|
||||||
|
"Allow Lan": "Allow Lan",
|
||||||
|
"IPv6": "IPv6",
|
||||||
|
"Log Level": "Log Level",
|
||||||
|
"Mixed Port": "Mixed Port",
|
||||||
|
"Clash core": "Clash core",
|
||||||
|
"Tun Mode": "Tun Mode",
|
||||||
|
"Auto Launch": "Auto Launch",
|
||||||
|
"System Proxy": "System Proxy",
|
||||||
|
"Proxy Guard": "Proxy Guard",
|
||||||
|
"Proxy Bypass": "Proxy Bypass",
|
||||||
|
"Theme Mode": "Theme Mode",
|
||||||
|
"Theme Blur": "Theme Blur",
|
||||||
|
"Traffic Graph": "Traffic Graph",
|
||||||
|
"Language": "Language",
|
||||||
|
"Open App Dir": "Open App Dir",
|
||||||
|
"Open Logs Dir": "Open Logs Dir",
|
||||||
|
"Version": "Version"
|
||||||
|
}
|
||||||
54
src/locales/zh.json
Normal file
54
src/locales/zh.json
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"Label-Proxies": "代 理",
|
||||||
|
"Label-Profiles": "配 置",
|
||||||
|
"Label-Connections": "连 接",
|
||||||
|
"Label-Logs": "日 志",
|
||||||
|
"Label-Settings": "设 置",
|
||||||
|
|
||||||
|
"Connections": "连接",
|
||||||
|
"Logs": "日志",
|
||||||
|
"Clear": "清除",
|
||||||
|
"Proxies": "代理",
|
||||||
|
"Proxy Groups": "代理组",
|
||||||
|
"rule": "规则",
|
||||||
|
"global": "全局",
|
||||||
|
"direct": "直连",
|
||||||
|
"Profiles": "配置",
|
||||||
|
"Profile URL": "配置文件链接",
|
||||||
|
"Import": "导入",
|
||||||
|
"New": "新建",
|
||||||
|
"Close All": "关闭全部",
|
||||||
|
"Select": "使用",
|
||||||
|
"Edit": "编辑信息",
|
||||||
|
"File": "打开文件",
|
||||||
|
"Update": "更新",
|
||||||
|
"Update(Proxy)": "更新(代理)",
|
||||||
|
"Delete": "删除",
|
||||||
|
"Enable": "启用",
|
||||||
|
"Disable": "禁用",
|
||||||
|
"Refresh": "刷新",
|
||||||
|
"To Top": "移到最前",
|
||||||
|
"To End": "移到末尾",
|
||||||
|
|
||||||
|
"Settings": "设置",
|
||||||
|
"Clash Setting": "Clash 设置",
|
||||||
|
"System Setting": "系统设置",
|
||||||
|
"Verge Setting": "Verge 设置",
|
||||||
|
"Allow Lan": "局域网连接",
|
||||||
|
"IPv6": "IPv6",
|
||||||
|
"Log Level": "日志等级",
|
||||||
|
"Mixed Port": "端口设置",
|
||||||
|
"Clash core": "Clash 内核",
|
||||||
|
"Tun Mode": "Tun 模式",
|
||||||
|
"Auto Launch": "开机自启",
|
||||||
|
"System Proxy": "系统代理",
|
||||||
|
"Proxy Guard": "系统代理守卫",
|
||||||
|
"Proxy Bypass": "Proxy Bypass",
|
||||||
|
"Theme Mode": "暗夜模式",
|
||||||
|
"Theme Blur": "背景模糊",
|
||||||
|
"Traffic Graph": "流量图显",
|
||||||
|
"Language": "语言设置",
|
||||||
|
"Open App Dir": "应用目录",
|
||||||
|
"Open Logs Dir": "日志目录",
|
||||||
|
"Version": "版本"
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ 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 enhance from "./services/enhance";
|
||||||
|
import "./services/i18n";
|
||||||
|
|
||||||
enhance.setup();
|
enhance.setup();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
import dayjs from "dayjs";
|
||||||
|
import i18next from "i18next";
|
||||||
|
import relativeTime from "dayjs/plugin/relativeTime";
|
||||||
import useSWR, { SWRConfig, useSWRConfig } from "swr";
|
import useSWR, { SWRConfig, useSWRConfig } from "swr";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { Route, Routes } from "react-router-dom";
|
import { Route, Routes } from "react-router-dom";
|
||||||
import { alpha, createTheme, List, Paper, ThemeProvider } from "@mui/material";
|
import { alpha, createTheme, List, Paper, ThemeProvider } from "@mui/material";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
@@ -12,10 +16,14 @@ 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 "dayjs/locale/zh-cn";
|
||||||
|
|
||||||
const isMacos = navigator.userAgent.includes("Mac OS X");
|
dayjs.extend(relativeTime);
|
||||||
|
|
||||||
|
const isWinOs = /win64|win32/i.test(navigator.userAgent);
|
||||||
|
|
||||||
const Layout = () => {
|
const Layout = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { data } = useSWR("getVergeConfig", getVergeConfig);
|
const { data } = useSWR("getVergeConfig", getVergeConfig);
|
||||||
|
|
||||||
@@ -27,16 +35,24 @@ const Layout = () => {
|
|||||||
if (e.key === "Escape") appWindow.hide();
|
if (e.key === "Escape") appWindow.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
listen("restart_clash", async () => {
|
listen("verge://refresh-clash-config", async () => {
|
||||||
// the clash info may be updated
|
// the clash info may be updated
|
||||||
await getAxios(true);
|
await getAxios(true);
|
||||||
// make sure that the clash is ok
|
mutate("getProxies");
|
||||||
setTimeout(() => mutate("getProxies"), 1000);
|
|
||||||
setTimeout(() => mutate("getProxies"), 2000);
|
|
||||||
mutate("getClashConfig");
|
mutate("getClashConfig");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// update the verge config
|
||||||
|
listen("verge://refresh-verge-config", () => mutate("getVergeConfig"));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data?.language) {
|
||||||
|
dayjs.locale(data.language === "zh" ? "zh-cn" : data.language);
|
||||||
|
i18next.changeLanguage(data.language);
|
||||||
|
}
|
||||||
|
}, [data?.language]);
|
||||||
|
|
||||||
const theme = useMemo(() => {
|
const theme = useMemo(() => {
|
||||||
// const background = mode === "light" ? "#f5f5f5" : "#000";
|
// const background = mode === "light" ? "#f5f5f5" : "#000";
|
||||||
const selectColor = mode === "light" ? "#f5f5f5" : "#d5d5d5";
|
const selectColor = mode === "light" ? "#f5f5f5" : "#d5d5d5";
|
||||||
@@ -69,8 +85,12 @@ const Layout = () => {
|
|||||||
<Paper
|
<Paper
|
||||||
square
|
square
|
||||||
elevation={0}
|
elevation={0}
|
||||||
className={`${isMacos ? "macos " : ""}layout`}
|
className={`${isWinOs ? "windows " : ""}layout`}
|
||||||
onPointerDown={onDragging}
|
onPointerDown={onDragging}
|
||||||
|
onContextMenu={(e) => {
|
||||||
|
// only prevent it on Windows
|
||||||
|
if (isWinOs) e.preventDefault();
|
||||||
|
}}
|
||||||
sx={[
|
sx={[
|
||||||
(theme) => ({
|
(theme) => ({
|
||||||
bgcolor: alpha(theme.palette.background.paper, blur ? 0.85 : 1),
|
bgcolor: alpha(theme.palette.background.paper, blur ? 0.85 : 1),
|
||||||
@@ -87,7 +107,7 @@ const Layout = () => {
|
|||||||
<List className="the-menu" data-windrag>
|
<List className="the-menu" data-windrag>
|
||||||
{routers.map((router) => (
|
{routers.map((router) => (
|
||||||
<LayoutItem key={router.label} to={router.link}>
|
<LayoutItem key={router.label} to={router.link}>
|
||||||
{router.label}
|
{t(router.label)}
|
||||||
</LayoutItem>
|
</LayoutItem>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
@@ -98,7 +118,7 @@ const Layout = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="layout__right" data-windrag>
|
<div className="layout__right" data-windrag>
|
||||||
{!isMacos && (
|
{isWinOs && (
|
||||||
<div className="the-bar">
|
<div className="the-bar">
|
||||||
<LayoutControl />
|
<LayoutControl />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,27 +6,27 @@ import ConnectionsPage from "./connections";
|
|||||||
|
|
||||||
export const routers = [
|
export const routers = [
|
||||||
{
|
{
|
||||||
label: "Proxies",
|
label: "Label-Proxies",
|
||||||
link: "/",
|
link: "/",
|
||||||
ele: ProxiesPage,
|
ele: ProxiesPage,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Profiles",
|
label: "Label-Profiles",
|
||||||
link: "/profile",
|
link: "/profile",
|
||||||
ele: ProfilesPage,
|
ele: ProfilesPage,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Connections",
|
label: "Label-Connections",
|
||||||
link: "/connections",
|
link: "/connections",
|
||||||
ele: ConnectionsPage,
|
ele: ConnectionsPage,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Logs",
|
label: "Label-Logs",
|
||||||
link: "/logs",
|
link: "/logs",
|
||||||
ele: LogsPage,
|
ele: LogsPage,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Settings",
|
label: "Label-Settings",
|
||||||
link: "/settings",
|
link: "/settings",
|
||||||
ele: SettingsPage,
|
ele: SettingsPage,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Paper } from "@mui/material";
|
import { useLockFn } from "ahooks";
|
||||||
|
import { Button, Paper } from "@mui/material";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { ApiType } from "../services/types";
|
import { ApiType } from "../services/types";
|
||||||
import { getInfomation } from "../services/api";
|
import { closeAllConnections, getInfomation } 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 ConnectionsPage = () => {
|
const ConnectionsPage = () => {
|
||||||
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
const [conn, setConn] = useState<ApiType.Connections>(initConn);
|
const [conn, setConn] = useState<ApiType.Connections>(initConn);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -26,10 +30,26 @@ const ConnectionsPage = () => {
|
|||||||
return () => ws?.close();
|
return () => ws?.close();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const onCloseAll = useLockFn(closeAllConnections);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage title="Connections" contentStyle={{ height: "100%" }}>
|
<BasePage
|
||||||
|
title={t("Connections")}
|
||||||
|
contentStyle={{ height: "100%" }}
|
||||||
|
header={
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
sx={{ mt: 1 }}
|
||||||
|
variant="contained"
|
||||||
|
onClick={onCloseAll}
|
||||||
|
>
|
||||||
|
{t("Close All")}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
<Paper sx={{ boxShadow: 2, height: "100%" }}>
|
<Paper sx={{ boxShadow: 2, height: "100%" }}>
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
|
initialTopMostItemIndex={999}
|
||||||
data={conn.connections}
|
data={conn.connections}
|
||||||
itemContent={(index, item) => <ConnectionItem value={item} />}
|
itemContent={(index, item) => <ConnectionItem value={item} />}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import { Button, Paper } from "@mui/material";
|
import { Button, Paper } from "@mui/material";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
|
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 [logData, setLogData] = useRecoilState(atomLogData);
|
const [logData, setLogData] = useRecoilState(atomLogData);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
title="Logs"
|
title={t("Logs")}
|
||||||
contentStyle={{ height: "100%" }}
|
contentStyle={{ height: "100%" }}
|
||||||
header={
|
header={
|
||||||
<Button
|
<Button
|
||||||
@@ -19,7 +21,7 @@ const LogPage = () => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={() => setLogData([])}
|
onClick={() => setLogData([])}
|
||||||
>
|
>
|
||||||
Clear
|
{t("Clear")}
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import useSWR, { useSWRConfig } from "swr";
|
|||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { Box, Button, Grid, TextField } from "@mui/material";
|
import { Box, Button, Grid, TextField } from "@mui/material";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
getProfiles,
|
getProfiles,
|
||||||
patchProfile,
|
patchProfile,
|
||||||
@@ -19,6 +20,7 @@ import ProfileItem from "../components/profile/profile-item";
|
|||||||
import ProfileMore from "../components/profile/profile-more";
|
import ProfileMore from "../components/profile/profile-more";
|
||||||
|
|
||||||
const ProfilePage = () => {
|
const ProfilePage = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
|
|
||||||
const [url, setUrl] = useState("");
|
const [url, setUrl] = useState("");
|
||||||
@@ -81,7 +83,10 @@ const ProfilePage = () => {
|
|||||||
name,
|
name,
|
||||||
now,
|
now,
|
||||||
}));
|
}));
|
||||||
patchProfile(current!, profile).catch(console.error);
|
|
||||||
|
patchProfile(current!, { selected: profile.selected }).catch(
|
||||||
|
console.error
|
||||||
|
);
|
||||||
// update proxies cache
|
// update proxies cache
|
||||||
if (hasChange) mutate("getProxies", getProxies());
|
if (hasChange) mutate("getProxies", getProxies());
|
||||||
}, 100);
|
}, 100);
|
||||||
@@ -172,12 +177,12 @@ const ProfilePage = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage title="Profiles">
|
<BasePage title={t("Profiles")}>
|
||||||
<Box sx={{ display: "flex", mb: 2.5 }}>
|
<Box sx={{ display: "flex", mb: 2.5 }}>
|
||||||
<TextField
|
<TextField
|
||||||
id="clas_verge_profile_url"
|
id="clas_verge_profile_url"
|
||||||
name="profile_url"
|
name="profile_url"
|
||||||
label="Profile URL"
|
label={t("Profile URL")}
|
||||||
size="small"
|
size="small"
|
||||||
fullWidth
|
fullWidth
|
||||||
value={url}
|
value={url}
|
||||||
@@ -190,10 +195,10 @@ const ProfilePage = () => {
|
|||||||
onClick={onImport}
|
onClick={onImport}
|
||||||
sx={{ mr: 1 }}
|
sx={{ mr: 1 }}
|
||||||
>
|
>
|
||||||
Import
|
{t("Import")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="contained" onClick={() => setDialogOpen(true)}>
|
<Button variant="contained" onClick={() => setDialogOpen(true)}>
|
||||||
New
|
{t("New")}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import useSWR, { useSWRConfig } from "swr";
|
import useSWR, { useSWRConfig } from "swr";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
|
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";
|
||||||
@@ -10,6 +11,7 @@ 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 { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { data: proxiesData } = useSWR("getProxies", getProxies);
|
const { data: proxiesData } = useSWR("getProxies", getProxies);
|
||||||
const { data: clashConfig } = useSWR("getClashConfig", getClashConfig);
|
const { data: clashConfig } = useSWR("getClashConfig", getClashConfig);
|
||||||
@@ -45,7 +47,7 @@ const ProxyPage = () => {
|
|||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
contentStyle={pageStyle}
|
contentStyle={pageStyle}
|
||||||
title={showGroup ? "Proxy Groups" : "Proxies"}
|
title={showGroup ? t("Proxy Groups") : t("Proxies")}
|
||||||
header={
|
header={
|
||||||
<ButtonGroup size="small">
|
<ButtonGroup size="small">
|
||||||
{modeList.map((mode) => (
|
{modeList.map((mode) => (
|
||||||
@@ -55,7 +57,7 @@ const ProxyPage = () => {
|
|||||||
onClick={() => onChangeMode(mode)}
|
onClick={() => onChangeMode(mode)}
|
||||||
sx={{ textTransform: "capitalize" }}
|
sx={{ textTransform: "capitalize" }}
|
||||||
>
|
>
|
||||||
{mode}
|
{t(mode)}
|
||||||
</Button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Paper } from "@mui/material";
|
import { Paper } from "@mui/material";
|
||||||
|
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";
|
||||||
@@ -6,12 +7,14 @@ 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 onError = (error: any) => {
|
const { t } = useTranslation();
|
||||||
error && Notice.error(error.toString());
|
|
||||||
|
const onError = (err: any) => {
|
||||||
|
Notice.error(err?.message || err.toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage title="Settings">
|
<BasePage title={t("Settings")}>
|
||||||
<Paper sx={{ borderRadius: 1, boxShadow: 2, mb: 3 }}>
|
<Paper sx={{ borderRadius: 1, boxShadow: 2, mb: 3 }}>
|
||||||
<SettingClash onError={onError} />
|
<SettingClash onError={onError} />
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ export async function getAxios(force: boolean = false) {
|
|||||||
try {
|
try {
|
||||||
const info = await getClashInfo();
|
const info = await getClashInfo();
|
||||||
|
|
||||||
if (info?.server) server = info?.server;
|
if (info?.server) {
|
||||||
|
server = info.server;
|
||||||
|
|
||||||
|
// compatible width `external-controller`
|
||||||
|
if (server.startsWith(":")) server = `127.0.0.1${server}`;
|
||||||
|
else if (/^\d+$/.test(server)) server = `127.0.0.1:${server}`;
|
||||||
|
}
|
||||||
if (info?.secret) secret = info?.secret;
|
if (info?.secret) secret = info?.secret;
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
@@ -135,3 +141,15 @@ export async function getProviders() {
|
|||||||
const response = await instance.get<any, any>("/providers/proxies");
|
const response = await instance.get<any, any>("/providers/proxies");
|
||||||
return response.providers as any;
|
return response.providers as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close specific connection
|
||||||
|
export async function deleteConnection(id: string) {
|
||||||
|
const instance = await getAxios();
|
||||||
|
await instance.delete<any, any>(`/connections/${encodeURIComponent(id)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close all connections
|
||||||
|
export async function closeAllConnections() {
|
||||||
|
const instance = await getAxios();
|
||||||
|
await instance.delete<any, any>(`/connections`);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { invoke } from "@tauri-apps/api/tauri";
|
import { invoke } from "@tauri-apps/api/tauri";
|
||||||
import { ApiType, CmdType } from "./types";
|
import { ApiType, CmdType } from "./types";
|
||||||
|
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");
|
||||||
@@ -13,8 +14,11 @@ export async function enhanceProfiles() {
|
|||||||
return invoke<void>("enhance_profiles");
|
return invoke<void>("enhance_profiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createProfile(item: Partial<CmdType.ProfileItem>) {
|
export async function createProfile(
|
||||||
return invoke<void>("create_profile", { item });
|
item: Partial<CmdType.ProfileItem>,
|
||||||
|
fileData?: string | null
|
||||||
|
) {
|
||||||
|
return invoke<void>("create_profile", { item, fileData });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function viewProfile(index: string) {
|
export async function viewProfile(index: string) {
|
||||||
@@ -22,11 +26,17 @@ export async function viewProfile(index: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function importProfile(url: string) {
|
export async function importProfile(url: string) {
|
||||||
return invoke<void>("import_profile", { url, withProxy: true });
|
return invoke<void>("import_profile", {
|
||||||
|
url,
|
||||||
|
option: { with_proxy: true },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateProfile(index: string, withProxy: boolean) {
|
export async function updateProfile(
|
||||||
return invoke<void>("update_profile", { index, withProxy });
|
index: string,
|
||||||
|
option?: CmdType.ProfileOption
|
||||||
|
) {
|
||||||
|
return invoke<void>("update_profile", { index, option });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteProfile(index: string) {
|
export async function deleteProfile(index: string) {
|
||||||
@@ -35,7 +45,7 @@ export async function deleteProfile(index: string) {
|
|||||||
|
|
||||||
export async function patchProfile(
|
export async function patchProfile(
|
||||||
index: string,
|
index: string,
|
||||||
profile: CmdType.ProfileItem
|
profile: Partial<CmdType.ProfileItem>
|
||||||
) {
|
) {
|
||||||
return invoke<void>("patch_profile", { index, profile });
|
return invoke<void>("patch_profile", { index, profile });
|
||||||
}
|
}
|
||||||
@@ -77,9 +87,13 @@ export async function killSidecars() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function openAppDir() {
|
export async function openAppDir() {
|
||||||
return invoke<void>("open_app_dir");
|
return invoke<void>("open_app_dir").catch((err) =>
|
||||||
|
Notice.error(err?.message || err.toString(), 1500)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function openLogsDir() {
|
export async function openLogsDir() {
|
||||||
return invoke<void>("open_logs_dir");
|
return invoke<void>("open_logs_dir").catch((err) =>
|
||||||
|
Notice.error(err?.message || err.toString(), 1500)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ class Enhance {
|
|||||||
const payload = event.payload as CmdType.EnhancedPayload;
|
const payload = event.payload as CmdType.EnhancedPayload;
|
||||||
let pdata = payload.current || {};
|
let pdata = payload.current || {};
|
||||||
|
|
||||||
|
let hasScript = false;
|
||||||
|
|
||||||
for (const each of payload.chain) {
|
for (const each of payload.chain) {
|
||||||
const { uid, type = "" } = each.item;
|
const { uid, type = "" } = each.item;
|
||||||
|
|
||||||
@@ -109,6 +111,7 @@ class Enhance {
|
|||||||
if (type === "script") {
|
if (type === "script") {
|
||||||
// support async main function
|
// support async main function
|
||||||
pdata = await toScript(each.script!, { ...pdata });
|
pdata = await toScript(each.script!, { ...pdata });
|
||||||
|
hasScript = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process merge
|
// process merge
|
||||||
@@ -132,6 +135,29 @@ class Enhance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If script is never used
|
||||||
|
// filter other fields
|
||||||
|
if (!hasScript) {
|
||||||
|
const validKeys = [
|
||||||
|
"proxies",
|
||||||
|
"proxy-providers",
|
||||||
|
"proxy-groups",
|
||||||
|
"rule-providers",
|
||||||
|
"rules",
|
||||||
|
];
|
||||||
|
|
||||||
|
// to lowercase
|
||||||
|
const newData: any = {};
|
||||||
|
Object.keys(pdata).forEach((key) => {
|
||||||
|
const newKey = key.toLowerCase();
|
||||||
|
if (validKeys.includes(newKey)) {
|
||||||
|
newData[newKey] = (pdata as any)[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pdata = newData;
|
||||||
|
}
|
||||||
|
|
||||||
const result = { data: pdata, status: "ok" };
|
const result = { data: pdata, status: "ok" };
|
||||||
emit(payload.callback, JSON.stringify(result)).catch(console.error);
|
emit(payload.callback, JSON.stringify(result)).catch(console.error);
|
||||||
});
|
});
|
||||||
|
|||||||
17
src/services/i18n.ts
Normal file
17
src/services/i18n.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import i18n from "i18next";
|
||||||
|
import { initReactI18next } from "react-i18next";
|
||||||
|
import en from "../locales/en.json";
|
||||||
|
import zh from "../locales/zh.json";
|
||||||
|
|
||||||
|
const resources = {
|
||||||
|
en: { translation: en },
|
||||||
|
zh: { translation: zh },
|
||||||
|
};
|
||||||
|
|
||||||
|
i18n.use(initReactI18next).init({
|
||||||
|
resources,
|
||||||
|
lng: "en",
|
||||||
|
interpolation: {
|
||||||
|
escapeValue: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -105,6 +105,12 @@ export namespace CmdType {
|
|||||||
total: number;
|
total: number;
|
||||||
expire: number;
|
expire: number;
|
||||||
};
|
};
|
||||||
|
option?: ProfileOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProfileOption {
|
||||||
|
user_agent?: string;
|
||||||
|
with_proxy?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfilesConfig {
|
export interface ProfilesConfig {
|
||||||
@@ -114,6 +120,7 @@ export namespace CmdType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface VergeConfig {
|
export interface VergeConfig {
|
||||||
|
language?: string;
|
||||||
theme_mode?: "light" | "dark";
|
theme_mode?: "light" | "dark";
|
||||||
theme_blur?: boolean;
|
theme_blur?: boolean;
|
||||||
traffic_graph?: boolean;
|
traffic_graph?: boolean;
|
||||||
|
|||||||
152
yarn.lock
152
yarn.lock
@@ -227,7 +227,7 @@
|
|||||||
"@babel/plugin-syntax-jsx" "^7.16.7"
|
"@babel/plugin-syntax-jsx" "^7.16.7"
|
||||||
"@babel/types" "^7.17.0"
|
"@babel/types" "^7.17.0"
|
||||||
|
|
||||||
"@babel/runtime@^7.13.10", "@babel/runtime@^7.17.2", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.7":
|
"@babel/runtime@^7.13.10", "@babel/runtime@^7.14.5", "@babel/runtime@^7.17.2", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.7":
|
||||||
version "7.17.2"
|
version "7.17.2"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941"
|
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941"
|
||||||
integrity sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==
|
integrity sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==
|
||||||
@@ -572,66 +572,72 @@
|
|||||||
estree-walker "^2.0.1"
|
estree-walker "^2.0.1"
|
||||||
picomatch "^2.2.2"
|
picomatch "^2.2.2"
|
||||||
|
|
||||||
"@tauri-apps/api@^1.0.0-rc.1":
|
"@tauri-apps/api@^1.0.0-rc.2":
|
||||||
version "1.0.0-rc.1"
|
version "1.0.0-rc.2"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.0-rc.1.tgz#ce26a0fe30d8980a4682d50015eec28ed4a23c1e"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.0.0-rc.2.tgz#bac494a6b8868e05f86184d2ee1ccc8477470363"
|
||||||
integrity sha512-VBUOmfT8ea02JB/Qr+FHeaLnug5BRA7ro2pX47q0GZCbZsU9b+iPnOXl0ShJwT0melR7B6iamyhDwkHStMVfQA==
|
integrity sha512-JhUDCJpfxmf/S1R+yHmJGsher4CGi07Qv4fYeucB7naeFZ7yTQe7S1CHKUZaRYpurGSdwOF3my9k0LyGmpAGYw==
|
||||||
dependencies:
|
dependencies:
|
||||||
type-fest "2.11.2"
|
type-fest "2.12.0"
|
||||||
|
|
||||||
"@tauri-apps/cli-darwin-arm64@1.0.0-rc.5":
|
"@tauri-apps/cli-darwin-arm64@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.0-rc.5.tgz#9374be8c96afa1cf77b5647bc81fe1a05006757d"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.0-rc.7.tgz#c7d190ea7496381bf456494e93dd8b35005a0e78"
|
||||||
integrity sha512-X+3EIAUGfoL8uE6PBADZC8FcUISe4JPQCxXgaVv6ehoZGoCh/pFJF7AvBGTQxbnvngqM7Xce4Lmh63Io2/5ggw==
|
integrity sha512-fb1plxZZHDG0KwZOoAl6tuisFU+oZFtNtqK3V2KL+4hz75DyH6BfsrgjyYSecJrtQejL2cHi8q7vUsU+EeLopw==
|
||||||
|
|
||||||
"@tauri-apps/cli-darwin-x64@1.0.0-rc.5":
|
"@tauri-apps/cli-darwin-x64@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.0-rc.5.tgz#4db1dd56a228bfafe5b3f64c7661abbe5606e804"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.0-rc.7.tgz#b152f333ea081674e8e6c45d1c3ff1850bff854c"
|
||||||
integrity sha512-fEpgOdAvKdq9C5/yip8RnwP1VS+nRrtKdzzplu4jY6njDVH/Vom8mg+EfXkCY5RveCaoskJMFgUvt10IGeZHBA==
|
integrity sha512-FOFPNsYUgCDaxEK+9oQ3vv9bMD3XVcOKdh1vo/DImzZNO6fQkcsDC8zlmA+Q4axd+X8kvu0iti1fK8Vl7HIUEA==
|
||||||
|
|
||||||
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.0-rc.5":
|
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.0-rc.5.tgz#0f1ff84c534908a54fbe63b45004abc6d4f03f4d"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.0-rc.7.tgz#14fb37a337526200dbbe9b49dabd221b81682b02"
|
||||||
integrity sha512-V7sWSBrpLyvkQxpkHIM8JltYqQhiTpThySDjO8POtrTqkRwM5BXORcCYhxTAKCedecfYK/RNUJ6Q0t7+3jS6DQ==
|
integrity sha512-tFzcJtNHy5AInU3E7kKDyhg4Qb7csu3uZ3FhGfORmGvQAiNQFpGV3ypC230RQYa3sxxRMbn8vjUAZMlU6JArbA==
|
||||||
|
|
||||||
"@tauri-apps/cli-linux-arm64-gnu@1.0.0-rc.5":
|
"@tauri-apps/cli-linux-arm64-gnu@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.0-rc.5.tgz#c5d2f1dd962d80a1958261229778b410b86254d4"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.0-rc.7.tgz#43e7a38018258ad2bf665bb61e0328688b345355"
|
||||||
integrity sha512-HhM+2FInxtUAI/41LF4fDEzmhLQUq6DOoo7fLN94vgWlhsPyWZoDGP9pA043XbO86+4OX5JZUW1SnTVXMwEaMA==
|
integrity sha512-QAoNUJMmoCv/mDZsfEZOOTeEPYuxtMgCgqTDqMd0H8S0Y3Cu2D/Q2fwVl0s9pMb6wLD2GJ2FEneySEMhMxt7Pg==
|
||||||
|
|
||||||
"@tauri-apps/cli-linux-arm64-musl@1.0.0-rc.5":
|
"@tauri-apps/cli-linux-arm64-musl@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.0-rc.5.tgz#f485db9ca5402f5d2c4585801a3aaa4519bd67e8"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.0-rc.7.tgz#37ebcfc7d1431dd698f529fa57248adadd94b3b4"
|
||||||
integrity sha512-DhHdKOhf3+peA/sM0c9CpxK89cp8GVwOB5osFW55fxBZbD0mJFeL2SzjkgfGFqFu6Ci/ZiibQGfEp8XTC8OsYA==
|
integrity sha512-ieLyACtbY7ezReTnjWLw/kKDXRCbnbrUjQ+hltSmHaRuV51nX+I2rmFO5e7VPdj406jvyKwfSPuBC34bHxt3Og==
|
||||||
|
|
||||||
"@tauri-apps/cli-linux-x64-gnu@1.0.0-rc.5":
|
"@tauri-apps/cli-linux-x64-gnu@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.0-rc.5.tgz#e468939585bc98e80ec827d0a3d8ba06a7cc38e8"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.0-rc.7.tgz#b47239c4f10b3fe8e1e2f031f639125ededc6d79"
|
||||||
integrity sha512-pZzsOHRGG/mdcn7fF/yOIOdeVzGxZUtZqvlGSd90ZM9Ps3//uYGCBHoNTbeSwp/V6+D0KVDaSCbm9lYlHoXcdA==
|
integrity sha512-wPAZctuFpurACxdCrjw+aaSuFReuIvv1nalVezfqA78AlsCk785yF2YVjoZr5bT8a9+6F+t8uNi3l6Vp5oNqwQ==
|
||||||
|
|
||||||
"@tauri-apps/cli-linux-x64-musl@1.0.0-rc.5":
|
"@tauri-apps/cli-linux-x64-musl@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.0-rc.5.tgz#a1308e93850555f2b6c97b5d7cdbbb9afaa803e2"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.0-rc.7.tgz#9e62494cf80aed170f389d84b2b23f354e8ce748"
|
||||||
integrity sha512-COwWCbOhEjBlzGRGTa0ESO4/AiC0cBZ2UEPExRn++S+kWSPJ2vsyMdCLu3hiMy1ABSIRcQ4Vc68M1iVkLhOHHw==
|
integrity sha512-/AxuXFC2d1V8KpZJ6cFDcD5QqPFIZFXC/tAJlnTW75VnHgjat9TYP3BdSOuEA81ZLs9tV4PQF40tNnUSzfRYMg==
|
||||||
|
|
||||||
"@tauri-apps/cli-win32-x64-msvc@1.0.0-rc.5":
|
"@tauri-apps/cli-win32-ia32-msvc@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.0-rc.5.tgz#d15c95143d9123d10c510e28ba90df5349b68ecd"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.0-rc.7.tgz#71c2f9498f4d03fd2c0ca6137a2be7db95a006f3"
|
||||||
integrity sha512-zzizUmPWvnWjj+IUCk36kVjS9j1Bg5JmnwOW5QdX26+a64q5vocmVimCgrfZ5STw3sDFXE++S55ghpzhhH5o+g==
|
integrity sha512-C4M2rHXlYVPSHGl2Iax1rfiNM5GPSRP1JHxW7/4jH9FfW6mVFcjULZAyVMRfOMQEQ9bYXbVnSTPbhG2Fm0jPxQ==
|
||||||
|
|
||||||
"@tauri-apps/cli@^1.0.0-rc.5":
|
"@tauri-apps/cli-win32-x64-msvc@1.0.0-rc.7":
|
||||||
version "1.0.0-rc.5"
|
version "1.0.0-rc.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.0-rc.5.tgz#db8ca22c9f55f5400d1c6addd78ee1df5dc15a29"
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.0-rc.7.tgz#6d719f70a0789f2a179d160c302996ce81194099"
|
||||||
integrity sha512-Q3D0R5YdZRA5EcL206hwwKCyXpet2mRDcfaRTU/IXwF73bS4AMja+JdAGfO2cyHuSvXd+b//Cgbei2zCG8M6hw==
|
integrity sha512-lpstJKOtP+ahhjbutapA02TpvfNTZqXwhmA1fvqxDu6BYVezFn7ZiGG5HwdXlkiRDfbwZwBd1evdkV3MxwY1NQ==
|
||||||
|
|
||||||
|
"@tauri-apps/cli@^1.0.0-rc.7":
|
||||||
|
version "1.0.0-rc.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.0-rc.7.tgz#0eb73718f6ebddc159b0b54f6fd6dfc26d110b36"
|
||||||
|
integrity sha512-g7lUsI2iFiB2JuPFr209vWNqOnxCOGXN6yBttMRY+94UUXZOeWlKxYYpSabyjSr7EbfAUNzjITYmE4urdtmB+A==
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
"@tauri-apps/cli-darwin-arm64" "1.0.0-rc.5"
|
"@tauri-apps/cli-darwin-arm64" "1.0.0-rc.7"
|
||||||
"@tauri-apps/cli-darwin-x64" "1.0.0-rc.5"
|
"@tauri-apps/cli-darwin-x64" "1.0.0-rc.7"
|
||||||
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.0-rc.5"
|
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.0-rc.7"
|
||||||
"@tauri-apps/cli-linux-arm64-gnu" "1.0.0-rc.5"
|
"@tauri-apps/cli-linux-arm64-gnu" "1.0.0-rc.7"
|
||||||
"@tauri-apps/cli-linux-arm64-musl" "1.0.0-rc.5"
|
"@tauri-apps/cli-linux-arm64-musl" "1.0.0-rc.7"
|
||||||
"@tauri-apps/cli-linux-x64-gnu" "1.0.0-rc.5"
|
"@tauri-apps/cli-linux-x64-gnu" "1.0.0-rc.7"
|
||||||
"@tauri-apps/cli-linux-x64-musl" "1.0.0-rc.5"
|
"@tauri-apps/cli-linux-x64-musl" "1.0.0-rc.7"
|
||||||
"@tauri-apps/cli-win32-x64-msvc" "1.0.0-rc.5"
|
"@tauri-apps/cli-win32-ia32-msvc" "1.0.0-rc.7"
|
||||||
|
"@tauri-apps/cli-win32-x64-msvc" "1.0.0-rc.7"
|
||||||
|
|
||||||
"@types/fs-extra@^9.0.13":
|
"@types/fs-extra@^9.0.13":
|
||||||
version "9.0.13"
|
version "9.0.13"
|
||||||
@@ -1285,6 +1291,18 @@ hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
react-is "^16.7.0"
|
react-is "^16.7.0"
|
||||||
|
|
||||||
|
html-escaper@^2.0.2:
|
||||||
|
version "2.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"
|
||||||
|
integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==
|
||||||
|
|
||||||
|
html-parse-stringify@^3.0.1:
|
||||||
|
version "3.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2"
|
||||||
|
integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==
|
||||||
|
dependencies:
|
||||||
|
void-elements "3.1.0"
|
||||||
|
|
||||||
human-signals@^1.1.1:
|
human-signals@^1.1.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
|
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
|
||||||
@@ -1295,6 +1313,13 @@ 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.6.14:
|
||||||
|
version "21.6.14"
|
||||||
|
resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.6.14.tgz#2bc199fba7f4da44b5952d7df0a3814a6e5c3943"
|
||||||
|
integrity sha512-XL6WyD+xlwQwbieXRlXhKWoLb/rkch50/rA+vl6untHnJ+aYnkQ0YDZciTWE78PPhOpbi2gR0LTJCJpiAhA+uQ==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.17.2"
|
||||||
|
|
||||||
ignore@^5.1.4:
|
ignore@^5.1.4:
|
||||||
version "5.2.0"
|
version "5.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
|
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
|
||||||
@@ -1647,6 +1672,15 @@ 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.15.6:
|
||||||
|
version "11.15.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-11.15.6.tgz#693430fbee5ac7d0774bd88683575d62adb24afb"
|
||||||
|
integrity sha512-OUWcFdNgIA9swVx3JGIreuquglAinpRwB/HYrCprTN+s9BQDt9LSiY7x5DGc2JzVpwqtpoTV7oRUTOxEPNyUPw==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.14.5"
|
||||||
|
html-escaper "^2.0.2"
|
||||||
|
html-parse-stringify "^3.0.1"
|
||||||
|
|
||||||
react-is@^16.13.1, react-is@^16.7.0:
|
react-is@^16.13.1, react-is@^16.7.0:
|
||||||
version "16.13.1"
|
version "16.13.1"
|
||||||
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"
|
||||||
@@ -1797,6 +1831,11 @@ signal-exit@^3.0.2:
|
|||||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
|
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
|
||||||
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
|
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
|
||||||
|
|
||||||
|
snarkdown@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/snarkdown/-/snarkdown-2.0.0.tgz#b1feb4db91b9f94a8ebbd7a50f3e99aee18b1e03"
|
||||||
|
integrity sha512-MgL/7k/AZdXCTJiNgrO7chgDqaB9FGM/1Tvlcenenb7div6obaDATzs16JhFyHHBGodHT3B7RzRc5qk8pFhg3A==
|
||||||
|
|
||||||
"source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2:
|
"source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
|
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
|
||||||
@@ -1863,10 +1902,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.11.2:
|
type-fest@2.12.0:
|
||||||
version "2.11.2"
|
version "2.12.0"
|
||||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.11.2.tgz#5534a919858bc517492cd3a53a673835a76d2e71"
|
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.12.0.tgz#ce342f58cab9114912f54b493d60ab39c3fc82b6"
|
||||||
integrity sha512-reW2Y2Mpn0QNA/5fvtm5doROLwDPu2zOm5RtY7xQQS05Q7xgC8MOZ3yPNaP9m/s/sNjjFQtHo7VCNqYW2iI+Ig==
|
integrity sha512-Qe5GRT+n/4GoqCNGGVp5Snapg1Omq3V7irBJB3EaKsp7HWDo5Gv2d/67gfNyV+d5EXD+x/RF5l1h4yJ7qNkcGA==
|
||||||
|
|
||||||
typescript@^4.5.5:
|
typescript@^4.5.5:
|
||||||
version "4.6.2"
|
version "4.6.2"
|
||||||
@@ -1895,6 +1934,11 @@ vite@^2.8.6:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
fsevents "~2.3.2"
|
fsevents "~2.3.2"
|
||||||
|
|
||||||
|
void-elements@3.1.0:
|
||||||
|
version "3.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09"
|
||||||
|
integrity sha1-YU9/v42AHwu18GYfWy9XhXUOTwk=
|
||||||
|
|
||||||
web-streams-polyfill@^3.0.3:
|
web-streams-polyfill@^3.0.3:
|
||||||
version "3.2.0"
|
version "3.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz#a6b74026b38e4885869fb5c589e90b95ccfc7965"
|
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz#a6b74026b38e4885869fb5c589e90b95ccfc7965"
|
||||||
|
|||||||
Reference in New Issue
Block a user