mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-26 15:29:57 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
372a45e667 | ||
|
|
ab6b796ce2 | ||
|
|
71e6c02897 | ||
|
|
3edeaa7038 | ||
|
|
f2f75d4015 | ||
|
|
69adade738 | ||
|
|
1bd88828e4 | ||
|
|
977fcbe6cd | ||
|
|
aa76a5c436 | ||
|
|
ea5fad428d | ||
|
|
0e1e27b35a | ||
|
|
d41f67a156 | ||
|
|
6f10dec808 | ||
|
|
9b79da2cdf | ||
|
|
c11b8519f1 | ||
|
|
b9e23a0b59 | ||
|
|
75d41b6fe5 | ||
|
|
4256590735 | ||
|
|
462fb05ea8 | ||
|
|
812dbfd836 | ||
|
|
cfca837777 | ||
|
|
ac5fb1948a | ||
|
|
22d8b73625 | ||
|
|
edde40c298 |
@@ -14,7 +14,7 @@ elif [ "$INPUT_TARGET" = "aarch64-unknown-linux-gnu" ]; then
|
|||||||
dpkg --add-architecture arm64
|
dpkg --add-architecture arm64
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y libncurses6:arm64 libtinfo6:arm64 linux-libc-dev:arm64 libncursesw6:arm64 libssl3:arm64 libcups2:arm64
|
apt-get install -y libncurses6:arm64 libtinfo6:arm64 linux-libc-dev:arm64 libncursesw6:arm64 libssl3:arm64 libcups2:arm64
|
||||||
apt-get install -y --no-install-recommends g++-aarch64-linux-gnu libc6-dev-arm64-cross libssl-dev:arm64 libwebkit2gtk-4.0-dev:arm64 libgtk-3-dev:arm64 patchelf:arm64 librsvg2-dev:arm64 libayatana-appindicator3-dev:arm64
|
apt-get install -y --no-install-recommends g++-aarch64-linux-gnu libc6-dev-arm64-cross libwebkit2gtk-4.0-dev:arm64 libgtk-3-dev:arm64 patchelf:arm64 librsvg2-dev:arm64 libayatana-appindicator3-dev:arm64
|
||||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
|
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
|
||||||
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
|
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
|
||||||
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
|
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
|
||||||
@@ -24,12 +24,22 @@ elif [ "$INPUT_TARGET" = "armv7-unknown-linux-gnueabihf" ]; then
|
|||||||
dpkg --add-architecture armhf
|
dpkg --add-architecture armhf
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y libncurses6:armhf libtinfo6:armhf linux-libc-dev:armhf libncursesw6:armhf libssl3:armhf libcups2:armhf
|
apt-get install -y libncurses6:armhf libtinfo6:armhf linux-libc-dev:armhf libncursesw6:armhf libssl3:armhf libcups2:armhf
|
||||||
apt-get install -y --no-install-recommends g++-arm-linux-gnueabihf libc6-dev-armhf-cross libssl-dev:armhf libwebkit2gtk-4.0-dev:armhf libgtk-3-dev:armhf patchelf:armhf librsvg2-dev:armhf libayatana-appindicator3-dev:armhf
|
apt-get install -y --no-install-recommends g++-arm-linux-gnueabihf libc6-dev-armhf-cross libwebkit2gtk-4.0-dev:armhf libgtk-3-dev:armhf patchelf:armhf librsvg2-dev:armhf libayatana-appindicator3-dev:armhf
|
||||||
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
|
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
|
||||||
export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
|
export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
|
||||||
export CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
|
export CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
|
||||||
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
|
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
|
||||||
export PKG_CONFIG_ALLOW_CROSS=1
|
export PKG_CONFIG_ALLOW_CROSS=1
|
||||||
|
elif [ "$INPUT_TARGET" = "riscv64gc-unknown-linux-gnu" ]; then
|
||||||
|
dpkg --add-architecture riscv64
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y libncurses6:riscv64 libtinfo6:riscv64 linux-libc-dev:riscv64 libncursesw6:riscv64 libssl3:riscv64 libcups2:riscv64
|
||||||
|
apt-get install -y --no-install-recommends g++-riscv64-linux-gnu libc6-dev-riscv64-cross libwebkit2gtk-4.0-dev:riscv64 libgtk-3-dev:riscv64 patchelf:riscv64 librsvg2-dev:riscv64 libayatana-appindicator3-dev:riscv64
|
||||||
|
export CARGO_TARGET_RISCV64_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc
|
||||||
|
export CC_riscv64_unknown_linux_gnu=riscv64-linux-gnu-gcc
|
||||||
|
export CXX_riscv64_unknown_linux_gnu=riscv64-linux-gnu-g++
|
||||||
|
export PKG_CONFIG_PATH=/usr/lib/riscv64-linux-gnu/pkgconfig
|
||||||
|
export PKG_CONFIG_ALLOW_CROSS=1
|
||||||
else
|
else
|
||||||
echo "Unknown target: $INPUT_TARGET" && exit 1
|
echo "Unknown target: $INPUT_TARGET" && exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
+51
-15
@@ -30,17 +30,6 @@ jobs:
|
|||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Apply Patch
|
|
||||||
if: matrix.target == 'aarch64-pc-windows-msvc'
|
|
||||||
run: |
|
|
||||||
git config --global user.email "clash-verge-rev@github.io"
|
|
||||||
git config --global user.name "clash-verge-rev"
|
|
||||||
git am patches/support-windows-aarch64.patch
|
|
||||||
|
|
||||||
- name: Init Submodule
|
|
||||||
if: matrix.target == 'aarch64-pc-windows-msvc'
|
|
||||||
run: git submodule update --init --recursive
|
|
||||||
|
|
||||||
- name: Install Rust Stable
|
- name: Install Rust Stable
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
@@ -57,7 +46,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "20"
|
node-version: "20"
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v3
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 8
|
||||||
@@ -100,6 +89,8 @@ jobs:
|
|||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
target: aarch64-unknown-linux-gnu
|
target: aarch64-unknown-linux-gnu
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: armv7-unknown-linux-gnueabihf
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
@@ -112,30 +103,56 @@ jobs:
|
|||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install jq
|
sudo apt-get install jq
|
||||||
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||||
|
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- run: |
|
||||||
|
cat > release.txt << 'EOF'
|
||||||
|
### 我应该下载哪个版本?
|
||||||
|
|
||||||
|
- Windows x86_64架构: x64-setup.exe (不支持win7)
|
||||||
|
- Windows arm64架构: arm64-setup.exe
|
||||||
|
- MacOS intel芯片: x64.dmg
|
||||||
|
- MacOS apple M芯片: aarch64.dmg (提示文件损坏看下面FAQ)
|
||||||
|
- Linux x64架构: amd64.AppImage/amd64.deb
|
||||||
|
- Linux arm64架构: arm64.deb
|
||||||
|
- Linux armv7架构: armhf.deb
|
||||||
|
- Windows 便携板 x86_64架构: x64_portable.zip (不推荐使用,无法自动更新)
|
||||||
|
- Windows 便携板 arm64架构: arm64_portable.zip (不推荐使用,无法自动更新)
|
||||||
|
|
||||||
|
### FAQ
|
||||||
|
|
||||||
|
- [https://clash-verge-rev.github.io/faq.html](https://clash-verge-rev.github.io/faq.html)
|
||||||
|
|
||||||
|
Created at ${{ env.BUILDTIME }}.
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
if: startsWith(matrix.target, 'x86_64')
|
if: startsWith(matrix.target, 'x86_64')
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: alpha
|
tag_name: alpha
|
||||||
name: "Clash Verge Rev Alpha"
|
name: "Clash Verge Rev Alpha"
|
||||||
body: "More new features are now supported."
|
body_path: release.txt
|
||||||
prerelease: true
|
prerelease: true
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage*
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage*
|
||||||
|
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: alpha
|
tag_name: alpha
|
||||||
name: "Clash Verge Rev Alpha"
|
name: "Clash Verge Rev Alpha"
|
||||||
body: "More new features are now supported."
|
body_path: release.txt
|
||||||
prerelease: true
|
prerelease: true
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||||
|
|
||||||
update_tag:
|
update_tag:
|
||||||
name: Update tag
|
name: Update tag
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -143,21 +160,40 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set Env
|
- name: Set Env
|
||||||
run: |
|
run: |
|
||||||
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Update Tag
|
- name: Update Tag
|
||||||
uses: richardsimko/update-tag@v1
|
uses: richardsimko/update-tag@v1
|
||||||
with:
|
with:
|
||||||
tag_name: alpha
|
tag_name: alpha
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
cat > release.txt << 'EOF'
|
cat > release.txt << 'EOF'
|
||||||
## Clash Verge Rev Alpha
|
### 我应该下载哪个版本?
|
||||||
|
|
||||||
|
- Windows x86_64架构: x64-setup.exe (不支持win7)
|
||||||
|
- Windows arm64架构: arm64-setup.exe
|
||||||
|
- MacOS intel芯片: x64.dmg
|
||||||
|
- MacOS apple M芯片: aarch64.dmg (提示文件损坏看下面FAQ)
|
||||||
|
- Linux x64架构: amd64.AppImage/amd64.deb
|
||||||
|
- Linux arm64架构: arm64.deb
|
||||||
|
- Linux armv7架构: armhf.deb
|
||||||
|
- Windows 便携板 x86_64架构: x64_portable.zip (不推荐使用,无法自动更新)
|
||||||
|
- Windows 便携板 arm64架构: arm64_portable.zip (不推荐使用,无法自动更新)
|
||||||
|
|
||||||
|
### FAQ
|
||||||
|
|
||||||
|
- [https://clash-verge-rev.github.io/faq.html](https://clash-verge-rev.github.io/faq.html)
|
||||||
|
|
||||||
Created at ${{ env.BUILDTIME }}.
|
Created at ${{ env.BUILDTIME }}.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -27,17 +27,6 @@ jobs:
|
|||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Apply Patch
|
|
||||||
if: matrix.target == 'aarch64-pc-windows-msvc'
|
|
||||||
run: |
|
|
||||||
git config --global user.email "clash-verge-rev@github.io"
|
|
||||||
git config --global user.name "clash-verge-rev"
|
|
||||||
git am patches/support-windows-aarch64.patch
|
|
||||||
|
|
||||||
- name: Init Submodule
|
|
||||||
if: matrix.target == 'aarch64-pc-windows-msvc'
|
|
||||||
run: git submodule update --init --recursive
|
|
||||||
|
|
||||||
- name: Install Rust Stable
|
- name: Install Rust Stable
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
@@ -54,7 +43,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "20"
|
node-version: "20"
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v3
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 8
|
||||||
@@ -97,6 +86,8 @@ jobs:
|
|||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
target: aarch64-unknown-linux-gnu
|
target: aarch64-unknown-linux-gnu
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: armv7-unknown-linux-gnueabihf
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
@@ -109,11 +100,13 @@ jobs:
|
|||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install jq
|
sudo apt-get install jq
|
||||||
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
if: startsWith(matrix.target, 'x86_64')
|
if: startsWith(matrix.target, 'x86_64')
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
@@ -123,6 +116,7 @@ jobs:
|
|||||||
body: "More new features are now supported."
|
body: "More new features are now supported."
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage*
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage*
|
||||||
|
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ dist-ssr
|
|||||||
update.json
|
update.json
|
||||||
scripts/_env.sh
|
scripts/_env.sh
|
||||||
.vscode
|
.vscode
|
||||||
|
.tool-version
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
nodejs 21.7.1
|
||||||
@@ -9,6 +9,10 @@
|
|||||||
A Clash Meta GUI based on <a href="https://github.com/tauri-apps/tauri">Tauri</a>.
|
A Clash Meta GUI based on <a href="https://github.com/tauri-apps/tauri">Tauri</a>.
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
## Preview
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
请到发布页面下载对应的安装包:[Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases)<br>
|
请到发布页面下载对应的安装包:[Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases)<br>
|
||||||
@@ -43,10 +47,6 @@ Supports Windows (x64/x86), Linux (x64/arm64) and macOS 10.15+ (intel/apple).
|
|||||||
- Built-in support [Clash.Meta(mihomo)](https://github.com/MetaCubeX/mihomo) core.
|
- Built-in support [Clash.Meta(mihomo)](https://github.com/MetaCubeX/mihomo) core.
|
||||||
- System proxy setting and guard.
|
- System proxy setting and guard.
|
||||||
|
|
||||||
## Preview
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### FAQ
|
### FAQ
|
||||||
|
|
||||||
Refer to [Doc FAQ Page](https://clash-verge-rev.github.io/faq.html)
|
Refer to [Doc FAQ Page](https://clash-verge-rev.github.io/faq.html)
|
||||||
|
|||||||
@@ -1,3 +1,36 @@
|
|||||||
|
## v1.5.9
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- 缓存代理组图标
|
||||||
|
- 使用`boa_engine` 代替 `rquickjs`
|
||||||
|
- 支持 Linux armv7
|
||||||
|
|
||||||
|
### Bugs Fixes
|
||||||
|
|
||||||
|
- Windows 首次安装无法点击
|
||||||
|
- Windows 触摸屏无法拖动
|
||||||
|
- 规则列表 `REJECT-DROP` 颜色
|
||||||
|
- MacOS Dock 栏不显示图标
|
||||||
|
- MacOS 自定义字体无效
|
||||||
|
- 避免使用空 UA 拉取订阅
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v1.5.8
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- 优化 UI 细节
|
||||||
|
- Linux 绘制窗口圆角
|
||||||
|
- 开放 DevTools
|
||||||
|
|
||||||
|
### Bugs Fixes
|
||||||
|
|
||||||
|
- 修复 MacOS 下开启 Tun 内核崩溃的问题
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## v1.5.7
|
## v1.5.7
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.7 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 576 KiB |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "clash-verge",
|
"name": "clash-verge",
|
||||||
"version": "1.5.7",
|
"version": "1.5.9",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tauri dev",
|
"dev": "tauri dev",
|
||||||
|
|||||||
@@ -1,195 +0,0 @@
|
|||||||
From 871c9a6d1ed014c93da2436a437df03734e9f76c Mon Sep 17 00:00:00 2001
|
|
||||||
From: MystiPanda <mystipanda@proton.me>
|
|
||||||
Date: Sun, 10 Dec 2023 19:47:45 +0800
|
|
||||||
Subject: [PATCH] feat: Support windows aarch64
|
|
||||||
|
|
||||||
---
|
|
||||||
.gitmodules | 3 +
|
|
||||||
src-tauri/Cargo.toml | 2 +-
|
|
||||||
src-tauri/quick-rs | 1 +
|
|
||||||
src-tauri/src/enhance/script.rs | 130 +++++++++++++++++++-------------
|
|
||||||
4 files changed, 81 insertions(+), 55 deletions(-)
|
|
||||||
create mode 100644 .gitmodules
|
|
||||||
create mode 160000 src-tauri/quick-rs
|
|
||||||
|
|
||||||
diff --git a/.gitmodules b/.gitmodules
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..2eda7e4
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/.gitmodules
|
|
||||||
@@ -0,0 +1,3 @@
|
|
||||||
+[submodule "src-tauri/quick-rs"]
|
|
||||||
+ path = src-tauri/quick-rs
|
|
||||||
+ url = https://github.com/clash-verge-rev/quick-rs.git
|
|
||||||
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
|
|
||||||
index 2f1a3be..d67f6ed 100644
|
|
||||||
--- a/src-tauri/Cargo.toml
|
|
||||||
+++ b/src-tauri/Cargo.toml
|
|
||||||
@@ -25,7 +25,6 @@ log4rs = "1"
|
|
||||||
nanoid = "0.4"
|
|
||||||
chrono = "0.4"
|
|
||||||
sysinfo = "0.30"
|
|
||||||
-rquickjs = "0.3" # 高版本不支持 Linux aarch64
|
|
||||||
serde_json = "1.0"
|
|
||||||
serde_yaml = "0.9"
|
|
||||||
once_cell = "1.18"
|
|
||||||
@@ -33,6 +32,7 @@ port_scanner = "0.1.5"
|
|
||||||
delay_timer = "0.11.5"
|
|
||||||
parking_lot = "0.12"
|
|
||||||
percent-encoding = "2.3.1"
|
|
||||||
+quick-rs = { path = "quick-rs" }
|
|
||||||
window-shadows = { version = "0.2" }
|
|
||||||
tokio = { version = "1", features = ["full"] }
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
diff --git a/src-tauri/quick-rs b/src-tauri/quick-rs
|
|
||||||
new file mode 160000
|
|
||||||
index 0000000..78277c4
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src-tauri/quick-rs
|
|
||||||
@@ -0,0 +1 @@
|
|
||||||
+Subproject commit 78277c4509c64f18c0fc5c9f2b84671de7c83343
|
|
||||||
diff --git a/src-tauri/src/enhance/script.rs b/src-tauri/src/enhance/script.rs
|
|
||||||
index 30a922f..d47dc33 100644
|
|
||||||
--- a/src-tauri/src/enhance/script.rs
|
|
||||||
+++ b/src-tauri/src/enhance/script.rs
|
|
||||||
@@ -3,61 +3,83 @@ use anyhow::Result;
|
|
||||||
use serde_yaml::Mapping;
|
|
||||||
|
|
||||||
pub fn use_script(script: String, config: Mapping) -> Result<(Mapping, Vec<(String, String)>)> {
|
|
||||||
- use rquickjs::{function::Func, Context, Runtime};
|
|
||||||
- use std::sync::{Arc, Mutex};
|
|
||||||
-
|
|
||||||
- let runtime = Runtime::new().unwrap();
|
|
||||||
- let context = Context::full(&runtime).unwrap();
|
|
||||||
- let outputs = Arc::new(Mutex::new(vec![]));
|
|
||||||
-
|
|
||||||
- let copy_outputs = outputs.clone();
|
|
||||||
- let result = context.with(|ctx| -> Result<Mapping> {
|
|
||||||
- ctx.globals().set(
|
|
||||||
- "__verge_log__",
|
|
||||||
- Func::from(move |level: String, data: String| {
|
|
||||||
- let mut out = copy_outputs.lock().unwrap();
|
|
||||||
- out.push((level, data));
|
|
||||||
- }),
|
|
||||||
- )?;
|
|
||||||
-
|
|
||||||
- ctx.eval(
|
|
||||||
- r#"var console = Object.freeze({
|
|
||||||
- log(data){__verge_log__("log",JSON.stringify(data))},
|
|
||||||
- info(data){__verge_log__("info",JSON.stringify(data))},
|
|
||||||
- error(data){__verge_log__("error",JSON.stringify(data))},
|
|
||||||
- debug(data){__verge_log__("debug",JSON.stringify(data))},
|
|
||||||
- });"#,
|
|
||||||
- )?;
|
|
||||||
-
|
|
||||||
- let config = use_lowercase(config.clone());
|
|
||||||
- let config_str = serde_json::to_string(&config)?;
|
|
||||||
-
|
|
||||||
- let code = format!(
|
|
||||||
- r#"try{{
|
|
||||||
+ use quick_rs::{context::Context, function::Function, module::Module, runtime::Runtime};
|
|
||||||
+
|
|
||||||
+ let config = use_lowercase(config.clone());
|
|
||||||
+ let config_str = serde_json::to_string(&config)?;
|
|
||||||
+
|
|
||||||
+ let runtime = Runtime::new();
|
|
||||||
+ let context = Context::from(&runtime);
|
|
||||||
+
|
|
||||||
+ let code = format!(
|
|
||||||
+ r#"
|
|
||||||
+ let output = [];
|
|
||||||
+
|
|
||||||
+ function __verge_log__(type, data) {{
|
|
||||||
+ output.push([type, data]);
|
|
||||||
+ }}
|
|
||||||
+
|
|
||||||
+ var console = Object.freeze({{
|
|
||||||
+ log(data) {{ __verge_log__("log", JSON.stringify(data)) }},
|
|
||||||
+ info(data) {{ __verge_log__("info", JSON.stringify(data)) }},
|
|
||||||
+ error(data) {{ __verge_log__("error", JSON.stringify(data)) }},
|
|
||||||
+ debug(data) {{ __verge_log__("debug", JSON.stringify(data)) }},
|
|
||||||
+ }});
|
|
||||||
+
|
|
||||||
{script};
|
|
||||||
- JSON.stringify(main({config_str})||'')
|
|
||||||
- }} catch(err) {{
|
|
||||||
- `__error_flag__ ${{err.toString()}}`
|
|
||||||
- }}"#
|
|
||||||
- );
|
|
||||||
- let result: String = ctx.eval(code.as_str())?;
|
|
||||||
- if result.starts_with("__error_flag__") {
|
|
||||||
- anyhow::bail!(result[15..].to_owned());
|
|
||||||
- }
|
|
||||||
- if result == "\"\"" {
|
|
||||||
- anyhow::bail!("main function should return object");
|
|
||||||
- }
|
|
||||||
- Ok(serde_json::from_str::<Mapping>(result.as_str())?)
|
|
||||||
- });
|
|
||||||
-
|
|
||||||
- let mut out = outputs.lock().unwrap();
|
|
||||||
- match result {
|
|
||||||
- Ok(config) => Ok((use_lowercase(config), out.to_vec())),
|
|
||||||
- Err(err) => {
|
|
||||||
- out.push(("exception".into(), err.to_string()));
|
|
||||||
- Ok((config, out.to_vec()))
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+
|
|
||||||
+ export function _main(){{
|
|
||||||
+ try{{
|
|
||||||
+ let result = JSON.stringify(main({config_str})||"");
|
|
||||||
+ return JSON.stringify({{result, output}});
|
|
||||||
+ }} catch(err) {{
|
|
||||||
+ output.push(["exception", err.toString()]);
|
|
||||||
+ return JSON.stringify({{result: "__error__", output}});
|
|
||||||
+ }}
|
|
||||||
+ }}
|
|
||||||
+ "#
|
|
||||||
+ );
|
|
||||||
+ let value = context.eval_module(&code, "_main")?;
|
|
||||||
+ let module = Module::new(value)?;
|
|
||||||
+ let value = module.get("_main")?;
|
|
||||||
+ let function = Function::new(value)?;
|
|
||||||
+ let value = function.call(vec![])?;
|
|
||||||
+ let result = serde_json::from_str::<serde_json::Value>(&value.to_string()?)?;
|
|
||||||
+ result
|
|
||||||
+ .as_object()
|
|
||||||
+ .map(|obj| {
|
|
||||||
+ let result = obj.get("result").unwrap().as_str().unwrap();
|
|
||||||
+ let output = obj.get("output").unwrap();
|
|
||||||
+
|
|
||||||
+ let mut out = output
|
|
||||||
+ .as_array()
|
|
||||||
+ .unwrap()
|
|
||||||
+ .iter()
|
|
||||||
+ .map(|item| {
|
|
||||||
+ let item = item.as_array().unwrap();
|
|
||||||
+ (
|
|
||||||
+ item[0].as_str().unwrap().into(),
|
|
||||||
+ item[1].as_str().unwrap().into(),
|
|
||||||
+ )
|
|
||||||
+ })
|
|
||||||
+ .collect::<Vec<_>>();
|
|
||||||
+ if result.is_empty() {
|
|
||||||
+ anyhow::bail!("main function should return object");
|
|
||||||
+ }
|
|
||||||
+ if result == "__error__" {
|
|
||||||
+ return Ok((config, out.to_vec()));
|
|
||||||
+ }
|
|
||||||
+ let result = serde_json::from_str::<Mapping>(result);
|
|
||||||
+
|
|
||||||
+ match result {
|
|
||||||
+ Ok(config) => Ok((use_lowercase(config), out.to_vec())),
|
|
||||||
+ Err(err) => {
|
|
||||||
+ out.push(("exception".into(), err.to_string()));
|
|
||||||
+ Ok((config, out.to_vec()))
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ })
|
|
||||||
+ .unwrap_or_else(|| anyhow::bail!("Unknown result"))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
--
|
|
||||||
2.43.0.windows.1
|
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@ const PLATFORM_MAP = {
|
|||||||
"i686-unknown-linux-gnu": "linux",
|
"i686-unknown-linux-gnu": "linux",
|
||||||
"aarch64-unknown-linux-gnu": "linux",
|
"aarch64-unknown-linux-gnu": "linux",
|
||||||
"armv7-unknown-linux-gnueabihf": "linux",
|
"armv7-unknown-linux-gnueabihf": "linux",
|
||||||
|
"riscv64gc-unknown-linux-gnu": "linux",
|
||||||
"loongarch64-unknown-linux-gnu": "linux",
|
"loongarch64-unknown-linux-gnu": "linux",
|
||||||
};
|
};
|
||||||
const ARCH_MAP = {
|
const ARCH_MAP = {
|
||||||
@@ -33,6 +34,7 @@ const ARCH_MAP = {
|
|||||||
"i686-unknown-linux-gnu": "ia32",
|
"i686-unknown-linux-gnu": "ia32",
|
||||||
"aarch64-unknown-linux-gnu": "arm64",
|
"aarch64-unknown-linux-gnu": "arm64",
|
||||||
"armv7-unknown-linux-gnueabihf": "arm",
|
"armv7-unknown-linux-gnueabihf": "arm",
|
||||||
|
"riscv64gc-unknown-linux-gnu": "riscv64",
|
||||||
"loongarch64-unknown-linux-gnu": "loong64",
|
"loongarch64-unknown-linux-gnu": "loong64",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,6 +67,7 @@ const META_ALPHA_MAP = {
|
|||||||
"linux-ia32": "mihomo-linux-386",
|
"linux-ia32": "mihomo-linux-386",
|
||||||
"linux-arm64": "mihomo-linux-arm64",
|
"linux-arm64": "mihomo-linux-arm64",
|
||||||
"linux-arm": "mihomo-linux-armv7",
|
"linux-arm": "mihomo-linux-armv7",
|
||||||
|
"linux-riscv64": "mihomo-linux-riscv64",
|
||||||
"linux-loong64": "mihomo-linux-loong64",
|
"linux-loong64": "mihomo-linux-loong64",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,6 +114,7 @@ const META_MAP = {
|
|||||||
"linux-ia32": "mihomo-linux-386",
|
"linux-ia32": "mihomo-linux-386",
|
||||||
"linux-arm64": "mihomo-linux-arm64",
|
"linux-arm64": "mihomo-linux-arm64",
|
||||||
"linux-arm": "mihomo-linux-armv7",
|
"linux-arm": "mihomo-linux-armv7",
|
||||||
|
"linux-riscv64": "mihomo-linux-riscv64",
|
||||||
"linux-loong64": "mihomo-linux-loong64",
|
"linux-loong64": "mihomo-linux-loong64",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -370,6 +374,16 @@ const resolveUninstall = () =>
|
|||||||
file: "uninstall-service.exe",
|
file: "uninstall-service.exe",
|
||||||
downloadURL: `${SERVICE_URL}/uninstall-service.exe`,
|
downloadURL: `${SERVICE_URL}/uninstall-service.exe`,
|
||||||
});
|
});
|
||||||
|
const resolveSetDnsScript = () =>
|
||||||
|
resolveResource({
|
||||||
|
file: "set_dns.sh",
|
||||||
|
downloadURL: `https://github.com/clash-verge-rev/set-dns-script/releases/download/script/set_dns.sh`,
|
||||||
|
});
|
||||||
|
const resolveUnSetDnsScript = () =>
|
||||||
|
resolveResource({
|
||||||
|
file: "unset_dns.sh",
|
||||||
|
downloadURL: `https://github.com/clash-verge-rev/set-dns-script/releases/download/script/unset_dns.sh`,
|
||||||
|
});
|
||||||
const resolveMmdb = () =>
|
const resolveMmdb = () =>
|
||||||
resolveResource({
|
resolveResource({
|
||||||
file: "Country.mmdb",
|
file: "Country.mmdb",
|
||||||
@@ -409,6 +423,8 @@ const tasks = [
|
|||||||
{ name: "service", func: resolveService, retry: 5, winOnly: true },
|
{ name: "service", func: resolveService, retry: 5, winOnly: true },
|
||||||
{ name: "install", func: resolveInstall, retry: 5, winOnly: true },
|
{ name: "install", func: resolveInstall, retry: 5, winOnly: true },
|
||||||
{ name: "uninstall", func: resolveUninstall, retry: 5, winOnly: true },
|
{ name: "uninstall", func: resolveUninstall, retry: 5, winOnly: true },
|
||||||
|
{ name: "set_dns_script", func: resolveSetDnsScript, retry: 5 },
|
||||||
|
{ name: "unset_dns_script", func: resolveUnSetDnsScript, retry: 5 },
|
||||||
{ name: "mmdb", func: resolveMmdb, retry: 5 },
|
{ name: "mmdb", func: resolveMmdb, retry: 5 },
|
||||||
{ name: "geosite", func: resolveGeosite, retry: 5 },
|
{ name: "geosite", func: resolveGeosite, retry: 5 },
|
||||||
{ name: "geoip", func: resolveGeoIP, retry: 5 },
|
{ name: "geoip", func: resolveGeoIP, retry: 5 },
|
||||||
|
|||||||
Generated
+768
-124
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "clash-verge"
|
name = "clash-verge"
|
||||||
version = "1.5.7"
|
version = "1.5.9"
|
||||||
description = "clash verge"
|
description = "clash verge"
|
||||||
authors = ["zzzgydi", "wonfen", "MystiPanda"]
|
authors = ["zzzgydi", "wonfen", "MystiPanda"]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
@@ -14,18 +14,16 @@ tauri-build = { version = "1", features = [] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
warp = "0.3"
|
warp = "0.3"
|
||||||
which = "6.0.0"
|
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
dirs = "5.0"
|
dirs = "5.0"
|
||||||
open = "5.0"
|
open = "5.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
ctrlc = "3.4"
|
|
||||||
dunce = "1.0"
|
dunce = "1.0"
|
||||||
log4rs = "1"
|
log4rs = "1"
|
||||||
nanoid = "0.4"
|
nanoid = "0.4"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
sysinfo = "0.30"
|
sysinfo = "0.30"
|
||||||
rquickjs = "0.3" # 高版本不支持 Linux aarch64
|
boa_engine = "0.18"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_yaml = "0.9"
|
serde_yaml = "0.9"
|
||||||
once_cell = "1.18"
|
once_cell = "1.18"
|
||||||
@@ -39,10 +37,10 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
|
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
|
||||||
sysproxy = { git="https://github.com/zzzgydi/sysproxy-rs", branch = "main" }
|
sysproxy = { git="https://github.com/zzzgydi/sysproxy-rs", branch = "main" }
|
||||||
auto-launch = { git="https://github.com/zzzgydi/auto-launch", branch = "main" }
|
auto-launch = { git="https://github.com/zzzgydi/auto-launch", branch = "main" }
|
||||||
tauri = { version = "1.5", features = [ "path-all", "protocol-asset", "dialog-open", "notification-all", "icon-png", "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
|
tauri = { version = "1.6", features = [ "path-all", "protocol-asset", "dialog-open", "notification-all", "icon-png", "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all", "devtools"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
runas = "=1.0.0" # 高版本会返回错误 Status
|
runas = "=1.2.0"
|
||||||
deelevate = "0.2.0"
|
deelevate = "0.2.0"
|
||||||
winreg = "0.52.0"
|
winreg = "0.52.0"
|
||||||
|
|
||||||
|
|||||||
+29
-1
@@ -9,7 +9,7 @@ use anyhow::{Context, Result};
|
|||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use sysproxy::Sysproxy;
|
use sysproxy::Sysproxy;
|
||||||
use tauri::api;
|
use tauri::{api, Manager};
|
||||||
type CmdResult<T = ()> = Result<T, String>;
|
type CmdResult<T = ()> = Result<T, String>;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -275,6 +275,23 @@ pub fn get_app_dir() -> CmdResult<String> {
|
|||||||
Ok(app_home_dir)
|
Ok(app_home_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String> {
|
||||||
|
let icon_cache_dir = wrap_err!(dirs::app_home_dir())?.join("icons").join("cache");
|
||||||
|
let icon_path = icon_cache_dir.join(name);
|
||||||
|
if !icon_cache_dir.exists() {
|
||||||
|
let _ = std::fs::create_dir_all(&icon_cache_dir);
|
||||||
|
}
|
||||||
|
if !icon_path.exists() {
|
||||||
|
let response = wrap_err!(reqwest::get(url).await)?;
|
||||||
|
|
||||||
|
let mut file = wrap_err!(std::fs::File::create(&icon_path))?;
|
||||||
|
|
||||||
|
let content = wrap_err!(response.bytes().await)?;
|
||||||
|
wrap_err!(std::io::copy(&mut content.as_ref(), &mut file))?;
|
||||||
|
}
|
||||||
|
Ok(icon_path.to_string_lossy().to_string())
|
||||||
|
}
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn copy_icon_file(path: String, name: String) -> CmdResult<String> {
|
pub fn copy_icon_file(path: String, name: String) -> CmdResult<String> {
|
||||||
let file_path = std::path::Path::new(&path);
|
let file_path = std::path::Path::new(&path);
|
||||||
@@ -294,6 +311,17 @@ pub fn copy_icon_file(path: String, name: String) -> CmdResult<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn open_devtools(app_handle: tauri::AppHandle) {
|
||||||
|
if let Some(window) = app_handle.get_window("main") {
|
||||||
|
if !window.is_devtools_open() {
|
||||||
|
window.open_devtools();
|
||||||
|
} else {
|
||||||
|
window.close_devtools();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn exit_app(app_handle: tauri::AppHandle) {
|
pub fn exit_app(app_handle: tauri::AppHandle) {
|
||||||
let _ = resolve::save_window_size_position(&app_handle, true);
|
let _ = resolve::save_window_size_position(&app_handle, true);
|
||||||
|
|||||||
@@ -105,22 +105,6 @@ impl CoreManager {
|
|||||||
sleep(Duration::from_millis(500)).await;
|
sleep(Duration::from_millis(500)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
let enable_tun = Config::verge().latest().enable_tun_mode.clone();
|
|
||||||
let enable_tun = enable_tun.unwrap_or(false);
|
|
||||||
log::debug!(target: "app", "try to set system dns");
|
|
||||||
if enable_tun {
|
|
||||||
let script = include_str!("./script/set_dns.sh");
|
|
||||||
match (|| async { Command::new("bash").args([script]).output() })().await {
|
|
||||||
Ok(_) => return Ok(()),
|
|
||||||
Err(err) => {
|
|
||||||
log::error!(target: "app", "{err}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use super::win_service;
|
use super::win_service;
|
||||||
@@ -263,22 +247,6 @@ impl CoreManager {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
let enable_tun = Config::verge().latest().enable_tun_mode.clone();
|
|
||||||
let enable_tun = enable_tun.unwrap_or(false);
|
|
||||||
log::debug!(target: "app", "try to unset system dns");
|
|
||||||
if enable_tun {
|
|
||||||
let script = include_str!("./script/unset_dns.sh");
|
|
||||||
match (|| Command::new("bash").args([script]).output())() {
|
|
||||||
Ok(_) => return Ok(()),
|
|
||||||
Err(err) => {
|
|
||||||
log::error!(target: "app", "{err}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut sidecar = self.sidecar.lock();
|
let mut sidecar = self.sidecar.lock();
|
||||||
if let Some(child) = sidecar.take() {
|
if let Some(child) = sidecar.take() {
|
||||||
log::debug!(target: "app", "stop the core by sidecar");
|
log::debug!(target: "app", "stop the core by sidecar");
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
nic=$(route -n get default | grep "interface" | awk '{print $2}')
|
|
||||||
|
|
||||||
hardware_port=$(networksetup -listallhardwareports | awk -v dev="$nic" '/Hardware Port/{port=$3} /Device:/{if ($2 == dev) {print port; exit}}')
|
|
||||||
|
|
||||||
networksetup -setdnsservers $hardware_port 223.5.5.5
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
nic=$(route -n get default | grep "interface" | awk '{print $2}')
|
|
||||||
|
|
||||||
hardware_port=$(networksetup -listallhardwareports | awk -v dev="$nic" '/Hardware Port/{port=$3} /Device:/{if ($2 == dev) {print port; exit}}')
|
|
||||||
|
|
||||||
networksetup -setdnsservers $hardware_port Empty
|
|
||||||
@@ -1,62 +1,75 @@
|
|||||||
use super::use_lowercase;
|
use super::use_lowercase;
|
||||||
use anyhow::Result;
|
use anyhow::{Error, Result};
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
|
|
||||||
pub fn use_script(script: String, config: Mapping) -> Result<(Mapping, Vec<(String, String)>)> {
|
pub fn use_script(script: String, config: Mapping) -> Result<(Mapping, Vec<(String, String)>)> {
|
||||||
use rquickjs::{function::Func, Context, Runtime};
|
use boa_engine::{native_function::NativeFunction, Context, JsValue, Source};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
let mut context = Context::default();
|
||||||
|
|
||||||
let runtime = Runtime::new().unwrap();
|
|
||||||
let context = Context::full(&runtime).unwrap();
|
|
||||||
let outputs = Arc::new(Mutex::new(vec![]));
|
let outputs = Arc::new(Mutex::new(vec![]));
|
||||||
|
|
||||||
let copy_outputs = outputs.clone();
|
let copy_outputs = outputs.clone();
|
||||||
let result = context.with(|ctx| -> Result<Mapping> {
|
unsafe {
|
||||||
ctx.globals().set(
|
let _ = context.register_global_builtin_callable(
|
||||||
"__verge_log__",
|
"__verge_log__".into(),
|
||||||
Func::from(move |level: String, data: String| {
|
2,
|
||||||
let mut out = copy_outputs.lock().unwrap();
|
NativeFunction::from_closure(
|
||||||
out.push((level, data));
|
move |_: &JsValue, args: &[JsValue], context: &mut Context| {
|
||||||
}),
|
let level = args.get(0).unwrap().to_string(context)?;
|
||||||
)?;
|
let level = level.to_std_string().unwrap();
|
||||||
|
let data = args.get(1).unwrap().to_string(context)?;
|
||||||
ctx.eval(
|
let data = data.to_std_string().unwrap();
|
||||||
r#"var console = Object.freeze({
|
let mut out = copy_outputs.lock().unwrap();
|
||||||
|
out.push((level, data));
|
||||||
|
Ok(JsValue::undefined())
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let _ = context.eval(Source::from_bytes(
|
||||||
|
r#"var console = Object.freeze({
|
||||||
log(data){__verge_log__("log",JSON.stringify(data))},
|
log(data){__verge_log__("log",JSON.stringify(data))},
|
||||||
info(data){__verge_log__("info",JSON.stringify(data))},
|
info(data){__verge_log__("info",JSON.stringify(data))},
|
||||||
error(data){__verge_log__("error",JSON.stringify(data))},
|
error(data){__verge_log__("error",JSON.stringify(data))},
|
||||||
debug(data){__verge_log__("debug",JSON.stringify(data))},
|
debug(data){__verge_log__("debug",JSON.stringify(data))},
|
||||||
});"#,
|
});"#,
|
||||||
)?;
|
));
|
||||||
|
|
||||||
let config = use_lowercase(config.clone());
|
let config = use_lowercase(config.clone());
|
||||||
let config_str = serde_json::to_string(&config)?;
|
let config_str = serde_json::to_string(&config)?;
|
||||||
|
|
||||||
let code = format!(
|
let code = format!(
|
||||||
r#"try{{
|
r#"try{{
|
||||||
{script};
|
{script};
|
||||||
JSON.stringify(main({config_str})||'')
|
JSON.stringify(main({config_str})||'')
|
||||||
}} catch(err) {{
|
}} catch(err) {{
|
||||||
`__error_flag__ ${{err.toString()}}`
|
`__error_flag__ ${{err.toString()}}`
|
||||||
}}"#
|
}}"#
|
||||||
);
|
);
|
||||||
let result: String = ctx.eval(code.as_str())?;
|
if let Ok(result) = context.eval(Source::from_bytes(code.as_str())) {
|
||||||
|
if !result.is_string() {
|
||||||
|
anyhow::bail!("main function should return object");
|
||||||
|
}
|
||||||
|
let result = result.to_string(&mut context).unwrap();
|
||||||
|
let result = result.to_std_string().unwrap();
|
||||||
if result.starts_with("__error_flag__") {
|
if result.starts_with("__error_flag__") {
|
||||||
anyhow::bail!(result[15..].to_owned());
|
anyhow::bail!(result[15..].to_owned());
|
||||||
}
|
}
|
||||||
if result == "\"\"" {
|
if result == "\"\"" {
|
||||||
anyhow::bail!("main function should return object");
|
anyhow::bail!("main function should return object");
|
||||||
}
|
}
|
||||||
Ok(serde_json::from_str::<Mapping>(result.as_str())?)
|
let res: Result<Mapping, Error> = Ok(serde_json::from_str::<Mapping>(result.as_str())?);
|
||||||
});
|
let mut out = outputs.lock().unwrap();
|
||||||
|
match res {
|
||||||
let mut out = outputs.lock().unwrap();
|
Ok(config) => Ok((use_lowercase(config), out.to_vec())),
|
||||||
match result {
|
Err(err) => {
|
||||||
Ok(config) => Ok((use_lowercase(config), out.to_vec())),
|
out.push(("exception".into(), err.to_string()));
|
||||||
Err(err) => {
|
Ok((config, out.to_vec()))
|
||||||
out.push(("exception".into(), err.to_string()));
|
}
|
||||||
Ok((config, out.to_vec()))
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
anyhow::bail!("main function should return object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,38 @@ pub fn use_tun(mut config: Mapping, enable: bool) -> Mapping {
|
|||||||
revise!(config, "tun", tun_val);
|
revise!(config, "tun", tun_val);
|
||||||
|
|
||||||
if enable {
|
if enable {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
use crate::utils::dirs;
|
||||||
|
use tauri::api::process::Command;
|
||||||
|
log::info!(target: "app", "try to set system dns");
|
||||||
|
let resource_dir = dirs::app_resources_dir().unwrap();
|
||||||
|
let script = resource_dir.join("set_dns.sh");
|
||||||
|
let script = script.to_string_lossy();
|
||||||
|
match Command::new("bash").args([script]).output() {
|
||||||
|
Ok(_) => log::info!(target: "app", "set system dns successfully"),
|
||||||
|
Err(err) => {
|
||||||
|
log::error!(target: "app", "set system dns failed: {err}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
use_dns_for_tun(config)
|
use_dns_for_tun(config)
|
||||||
} else {
|
} else {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
use crate::utils::dirs;
|
||||||
|
use tauri::api::process::Command;
|
||||||
|
log::info!(target: "app", "try to unset system dns");
|
||||||
|
let resource_dir = dirs::app_resources_dir().unwrap();
|
||||||
|
let script = resource_dir.join("unset_dns.sh");
|
||||||
|
let script = script.to_string_lossy();
|
||||||
|
match Command::new("bash").args([script]).output() {
|
||||||
|
Ok(_) => log::info!(target: "app", "unset system dns successfully"),
|
||||||
|
Err(err) => {
|
||||||
|
log::error!(target: "app", "unset system dns failed: {err}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ fn main() -> std::io::Result<()> {
|
|||||||
cmds::test_delay,
|
cmds::test_delay,
|
||||||
cmds::get_app_dir,
|
cmds::get_app_dir,
|
||||||
cmds::copy_icon_file,
|
cmds::copy_icon_file,
|
||||||
|
cmds::download_icon_cache,
|
||||||
|
cmds::open_devtools,
|
||||||
cmds::exit_app,
|
cmds::exit_app,
|
||||||
// cmds::update_hotkeys,
|
// cmds::update_hotkeys,
|
||||||
// profile
|
// profile
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ pub fn find_unused_port() -> Result<u16> {
|
|||||||
|
|
||||||
/// handle something when start app
|
/// handle something when start app
|
||||||
pub fn resolve_setup(app: &mut App) {
|
pub fn resolve_setup(app: &mut App) {
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
|
|
||||||
let version = app.package_info().version.to_string();
|
let version = app.package_info().version.to_string();
|
||||||
handle::Handle::global().init(app.app_handle());
|
handle::Handle::global().init(app.app_handle());
|
||||||
VERSION.get_or_init(|| version.clone());
|
VERSION.get_or_init(|| version.clone());
|
||||||
@@ -141,10 +139,7 @@ pub fn create_window(app_handle: &AppHandle) {
|
|||||||
_ => {
|
_ => {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
builder = builder
|
builder = builder.inner_size(800.0, 636.0).center();
|
||||||
.additional_browser_args("--enable-features=msWebView2EnableDraggableRegions")
|
|
||||||
.inner_size(800.0, 636.0)
|
|
||||||
.center();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
@@ -161,6 +156,7 @@ pub fn create_window(app_handle: &AppHandle) {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
let window = builder
|
let window = builder
|
||||||
.decorations(false)
|
.decorations(false)
|
||||||
|
.additional_browser_args("--enable-features=msWebView2EnableDraggableRegions --disable-features=OverscrollHistoryNavigation,msExperimentalScrolling")
|
||||||
.transparent(true)
|
.transparent(true)
|
||||||
.visible(false)
|
.visible(false)
|
||||||
.build();
|
.build();
|
||||||
@@ -171,7 +167,7 @@ pub fn create_window(app_handle: &AppHandle) {
|
|||||||
.title_bar_style(tauri::TitleBarStyle::Overlay)
|
.title_bar_style(tauri::TitleBarStyle::Overlay)
|
||||||
.build();
|
.build();
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let window = builder.decorations(true).transparent(false).build();
|
let window = builder.decorations(false).transparent(true).build();
|
||||||
|
|
||||||
match window {
|
match window {
|
||||||
Ok(win) => {
|
Ok(win) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "Clash Verge",
|
"productName": "Clash Verge",
|
||||||
"version": "1.5.7"
|
"version": "1.5.9"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"distDir": "../dist",
|
"distDir": "../dist",
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ body {
|
|||||||
@import "./page.scss";
|
@import "./page.scss";
|
||||||
@import "./font.scss";
|
@import "./font.scss";
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
// @media (prefers-color-scheme: dark) {
|
||||||
:root {
|
// :root {
|
||||||
background-color: rgba(18, 18, 18, 1);
|
// background-color: rgba(18, 18, 18, 1);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
.user-none {
|
.user-none {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@@ -59,7 +59,3 @@ body {
|
|||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-tauri-drag-region] {
|
|
||||||
app-region: drag;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
// max-width: 225px;
|
// max-width: 225px;
|
||||||
// min-width: 225px;
|
// min-width: 225px;
|
||||||
padding: 16px 0 8px;
|
// padding: 16px 0 8px;
|
||||||
|
padding: 0px 0px 8px;
|
||||||
// position: relative;
|
// position: relative;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
// $maxLogo: 100px;
|
// $maxLogo: 100px;
|
||||||
|
|
||||||
.the-logo {
|
.the-logo {
|
||||||
|
app-region: drag;
|
||||||
position: relative;
|
position: relative;
|
||||||
flex: 1 0 58px;
|
flex: 1 0 58px;
|
||||||
// width: 100%;
|
// width: 100%;
|
||||||
@@ -37,7 +39,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
border-bottom: 1px solid var(--divider-color);
|
// border-bottom: 1px solid var(--divider-color);
|
||||||
// max-width: $maxLogo + 32px;
|
// max-width: $maxLogo + 32px;
|
||||||
// max-height: $maxLogo;
|
// max-height: $maxLogo;
|
||||||
// margin: 0 auto;
|
// margin: 0 auto;
|
||||||
@@ -94,12 +96,15 @@
|
|||||||
// position: absolute;
|
// position: absolute;
|
||||||
// top: 0px;
|
// top: 0px;
|
||||||
// right: 0px;
|
// right: 0px;
|
||||||
height: 24px;
|
height: 36px;
|
||||||
display: flex;
|
display: flex;
|
||||||
// align-items: center;
|
// align-items: center;
|
||||||
justify-content: end;
|
justify-content: end;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
.the-dragbar {
|
||||||
|
app-region: drag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.the-content {
|
.the-content {
|
||||||
@@ -117,11 +122,13 @@
|
|||||||
.unknown {
|
.unknown {
|
||||||
&.layout {
|
&.layout {
|
||||||
.layout__left {
|
.layout__left {
|
||||||
padding-top: 24px;
|
// padding-top: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout__left .the-logo {
|
.layout__left .the-logo {
|
||||||
flex: 1 0 58px;
|
flex: 1 0 58px;
|
||||||
|
padding-top: 40px;
|
||||||
|
padding-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout__right .the-content {
|
.layout__right .the-content {
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ export const ProfileItem = (props: Props) => {
|
|||||||
|
|
||||||
<Typography
|
<Typography
|
||||||
width="calc(100% - 36px)"
|
width="calc(100% - 36px)"
|
||||||
|
sx={{ fontSize: "18px", fontWeight: "600", lineHeight: "26px" }}
|
||||||
variant="h6"
|
variant="h6"
|
||||||
component="h2"
|
component="h2"
|
||||||
noWrap
|
noWrap
|
||||||
@@ -279,7 +280,11 @@ export const ProfileItem = (props: Props) => {
|
|||||||
{
|
{
|
||||||
<>
|
<>
|
||||||
{description ? (
|
{description ? (
|
||||||
<Typography noWrap title={description}>
|
<Typography
|
||||||
|
noWrap
|
||||||
|
title={description}
|
||||||
|
sx={{ fontSize: "14px" }}
|
||||||
|
>
|
||||||
{description}
|
{description}
|
||||||
</Typography>
|
</Typography>
|
||||||
) : (
|
) : (
|
||||||
@@ -312,7 +317,7 @@ export const ProfileItem = (props: Props) => {
|
|||||||
<span title="Expire Time">{expire}</span>
|
<span title="Expire Time">{expire}</span>
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Box sx={{ ...boxStyle, fontSize: 14, justifyContent: "flex-end" }}>
|
<Box sx={{ ...boxStyle, fontSize: 12, justifyContent: "flex-end" }}>
|
||||||
<span title="Updated Time">{parseExpire(updated)}</span>
|
<span title="Updated Time">{parseExpire(updated)}</span>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
|||||||
desc: "",
|
desc: "",
|
||||||
url: "",
|
url: "",
|
||||||
option: {
|
option: {
|
||||||
// user_agent: "",
|
|
||||||
with_proxy: false,
|
with_proxy: false,
|
||||||
self_proxy: false,
|
self_proxy: false,
|
||||||
},
|
},
|
||||||
@@ -99,6 +98,9 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>(
|
|||||||
if (form.option?.update_interval) {
|
if (form.option?.update_interval) {
|
||||||
form.option.update_interval = +form.option.update_interval;
|
form.option.update_interval = +form.option.update_interval;
|
||||||
}
|
}
|
||||||
|
if (form.option?.user_agent === "") {
|
||||||
|
delete form.option.user_agent;
|
||||||
|
}
|
||||||
const name = form.name || `${form.type} file`;
|
const name = form.name || `${form.type} file`;
|
||||||
const item = { ...form, name };
|
const item = { ...form, name };
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ import type { IRenderItem } from "./use-render-list";
|
|||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import { atomThemeMode } from "@/services/states";
|
import { atomThemeMode } from "@/services/states";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { convertFileSrc } from "@tauri-apps/api/tauri";
|
||||||
|
import { downloadIconCache } from "@/services/cmds";
|
||||||
|
|
||||||
interface RenderProps {
|
interface RenderProps {
|
||||||
item: IRenderItem;
|
item: IRenderItem;
|
||||||
@@ -38,6 +41,23 @@ export const ProxyRender = (props: RenderProps) => {
|
|||||||
const [mode] = useRecoilState(atomThemeMode);
|
const [mode] = useRecoilState(atomThemeMode);
|
||||||
const isDark = mode === "light" ? false : true;
|
const isDark = mode === "light" ? false : true;
|
||||||
const itembackgroundcolor = isDark ? "#282A36" : "#ffffff";
|
const itembackgroundcolor = isDark ? "#282A36" : "#ffffff";
|
||||||
|
const [iconCachePath, setIconCachePath] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
initIconCachePath();
|
||||||
|
}, [group]);
|
||||||
|
|
||||||
|
async function initIconCachePath() {
|
||||||
|
if (group.icon && group.icon.trim().startsWith("http")) {
|
||||||
|
const fileName = getFileName(group.icon);
|
||||||
|
const iconPath = await downloadIconCache(group.icon, fileName);
|
||||||
|
setIconCachePath(convertFileSrc(iconPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFileName(url: string) {
|
||||||
|
return url.substring(url.lastIndexOf("/") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 0 && !group.hidden) {
|
if (type === 0 && !group.hidden) {
|
||||||
return (
|
return (
|
||||||
@@ -55,7 +75,7 @@ export const ProxyRender = (props: RenderProps) => {
|
|||||||
group.icon &&
|
group.icon &&
|
||||||
group.icon.trim().startsWith("http") && (
|
group.icon.trim().startsWith("http") && (
|
||||||
<img
|
<img
|
||||||
src={group.icon}
|
src={iconCachePath === "" ? group.icon : iconCachePath}
|
||||||
height="32px"
|
height="32px"
|
||||||
style={{ marginRight: "12px", borderRadius: "6px" }}
|
style={{ marginRight: "12px", borderRadius: "6px" }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parseColor = (text: string) => {
|
const parseColor = (text: string) => {
|
||||||
if (text === "REJECT") return "error.main";
|
if (text === "REJECT" || text === "REJECT-DROP") return "error.main";
|
||||||
if (text === "DIRECT") return "text.primary";
|
if (text === "DIRECT") return "text.primary";
|
||||||
|
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
const [sysproxyIcon, setSysproxyIcon] = useState("");
|
const [sysproxyIcon, setSysproxyIcon] = useState("");
|
||||||
const [tunIcon, setTunIcon] = useState("");
|
const [tunIcon, setTunIcon] = useState("");
|
||||||
|
|
||||||
// const { menu_icon } = verge ?? {};
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initIconPath();
|
initIconPath();
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { exitApp, openAppDir, openCoreDir, openLogsDir } from "@/services/cmds";
|
import {
|
||||||
|
exitApp,
|
||||||
|
openAppDir,
|
||||||
|
openCoreDir,
|
||||||
|
openLogsDir,
|
||||||
|
openDevTools,
|
||||||
|
} from "@/services/cmds";
|
||||||
import { ArrowForward } from "@mui/icons-material";
|
import { ArrowForward } from "@mui/icons-material";
|
||||||
import { checkUpdate } from "@tauri-apps/api/updater";
|
import { checkUpdate } from "@tauri-apps/api/updater";
|
||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
@@ -27,6 +33,7 @@ import { LayoutViewer } from "./mods/layout-viewer";
|
|||||||
import { UpdateViewer } from "./mods/update-viewer";
|
import { UpdateViewer } from "./mods/update-viewer";
|
||||||
import getSystem from "@/utils/get-system";
|
import getSystem from "@/utils/get-system";
|
||||||
import { routers } from "@/pages/_routers";
|
import { routers } from "@/pages/_routers";
|
||||||
|
import { appWindow } from "@tauri-apps/api/window";
|
||||||
interface Props {
|
interface Props {
|
||||||
onError?: (err: Error) => void;
|
onError?: (err: Error) => void;
|
||||||
}
|
}
|
||||||
@@ -304,6 +311,17 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
|
<SettingItem label={t("Open Dev Tools")}>
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
sx={{ my: "2px" }}
|
||||||
|
onClick={openDevTools}
|
||||||
|
>
|
||||||
|
<ArrowForward />
|
||||||
|
</IconButton>
|
||||||
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem label={t("Exit")}>
|
<SettingItem label={t("Exit")}>
|
||||||
<IconButton
|
<IconButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ import { LanguageTwoTone } from "@mui/icons-material";
|
|||||||
import { Notice } from "@/components/base";
|
import { Notice } from "@/components/base";
|
||||||
import { TestBox } from "./test-box";
|
import { TestBox } from "./test-box";
|
||||||
import delayManager from "@/services/delay";
|
import delayManager from "@/services/delay";
|
||||||
import { cmdTestDelay } from "@/services/cmds";
|
import { cmdTestDelay, downloadIconCache } from "@/services/cmds";
|
||||||
import { listen, Event, UnlistenFn } from "@tauri-apps/api/event";
|
import { listen, Event, UnlistenFn } from "@tauri-apps/api/event";
|
||||||
|
import { convertFileSrc } from "@tauri-apps/api/tauri";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -39,6 +40,23 @@ export const TestItem = (props: Props) => {
|
|||||||
const [position, setPosition] = useState({ left: 0, top: 0 });
|
const [position, setPosition] = useState({ left: 0, top: 0 });
|
||||||
const [delay, setDelay] = useState(-1);
|
const [delay, setDelay] = useState(-1);
|
||||||
const { uid, name, icon, url } = itemData;
|
const { uid, name, icon, url } = itemData;
|
||||||
|
const [iconCachePath, setIconCachePath] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
initIconCachePath();
|
||||||
|
}, [icon]);
|
||||||
|
|
||||||
|
async function initIconCachePath() {
|
||||||
|
if (icon && icon.trim().startsWith("http")) {
|
||||||
|
const fileName = getFileName(icon);
|
||||||
|
const iconPath = await downloadIconCache(icon, fileName);
|
||||||
|
setIconCachePath(convertFileSrc(iconPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFileName(url: string) {
|
||||||
|
return url.substring(url.lastIndexOf("/") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
const onDelay = async () => {
|
const onDelay = async () => {
|
||||||
setDelay(-2);
|
setDelay(-2);
|
||||||
@@ -104,7 +122,10 @@ export const TestItem = (props: Props) => {
|
|||||||
{icon && icon.trim() !== "" ? (
|
{icon && icon.trim() !== "" ? (
|
||||||
<Box sx={{ display: "flex", justifyContent: "center" }}>
|
<Box sx={{ display: "flex", justifyContent: "center" }}>
|
||||||
{icon.trim().startsWith("http") && (
|
{icon.trim().startsWith("http") && (
|
||||||
<img src={icon} height="40px" />
|
<img
|
||||||
|
src={iconCachePath === "" ? icon : iconCachePath}
|
||||||
|
height="40px"
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{icon.trim().startsWith("data") && (
|
{icon.trim().startsWith("data") && (
|
||||||
<img src={icon} height="40px" />
|
<img src={icon} height="40px" />
|
||||||
|
|||||||
@@ -123,6 +123,7 @@
|
|||||||
"Open Core Dir": "内核目录",
|
"Open Core Dir": "内核目录",
|
||||||
"Open Logs Dir": "日志目录",
|
"Open Logs Dir": "日志目录",
|
||||||
"Check for Updates": "检查更新",
|
"Check for Updates": "检查更新",
|
||||||
|
"Open Dev Tools": "打开开发者工具",
|
||||||
"Verge Version": "Verge 版本",
|
"Verge Version": "Verge 版本",
|
||||||
"theme.light": "浅色",
|
"theme.light": "浅色",
|
||||||
"theme.dark": "深色",
|
"theme.dark": "深色",
|
||||||
|
|||||||
+18
-5
@@ -122,9 +122,17 @@ const Layout = () => {
|
|||||||
({ palette }) => ({
|
({ palette }) => ({
|
||||||
bgcolor: palette.background.paper,
|
bgcolor: palette.background.paper,
|
||||||
}),
|
}),
|
||||||
|
OS === "linux"
|
||||||
|
? {
|
||||||
|
borderRadius: "8px",
|
||||||
|
border: "2px solid var(--divider-color)",
|
||||||
|
width: "calc(100vw - 4px)",
|
||||||
|
height: "calc(100vh - 4px)",
|
||||||
|
}
|
||||||
|
: {},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<div className="layout__left" data-tauri-drag-region="true">
|
<div className="layout__left">
|
||||||
<div className="the-logo" data-tauri-drag-region="true">
|
<div className="the-logo" data-tauri-drag-region="true">
|
||||||
{!isDark ? <LogoSvg /> : <LogoSvg_dark />}
|
{!isDark ? <LogoSvg /> : <LogoSvg_dark />}
|
||||||
{<UpdateButton className="the-newbtn" />}
|
{<UpdateButton className="the-newbtn" />}
|
||||||
@@ -148,11 +156,16 @@ const Layout = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="layout__right">
|
<div className="layout__right">
|
||||||
{OS === "windows" && (
|
{
|
||||||
<div className="the-bar" data-tauri-drag-region="true">
|
<div className="the-bar">
|
||||||
<LayoutControl />
|
<div
|
||||||
|
className="the-dragbar"
|
||||||
|
data-tauri-drag-region="true"
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
></div>
|
||||||
|
{OS !== "macos" && <LayoutControl />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
}
|
||||||
|
|
||||||
<TransitionGroup className="the-content">
|
<TransitionGroup className="the-content">
|
||||||
<CSSTransition
|
<CSSTransition
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const OS = getSystem();
|
|||||||
// default theme setting
|
// default theme setting
|
||||||
export const defaultTheme = {
|
export const defaultTheme = {
|
||||||
primary_color: "#007AFF",
|
primary_color: "#007AFF",
|
||||||
secondary_color: "#FFCC00",
|
secondary_color: "#fc9b76",
|
||||||
primary_text: "#000000",
|
primary_text: "#000000",
|
||||||
secondary_text: "#3c3c4399",
|
secondary_text: "#3c3c4399",
|
||||||
info_color: "#007AFF",
|
info_color: "#007AFF",
|
||||||
@@ -12,8 +12,8 @@ export const defaultTheme = {
|
|||||||
warning_color: "#FF9500",
|
warning_color: "#FF9500",
|
||||||
success_color: "#06943D",
|
success_color: "#06943D",
|
||||||
background_color: "#f5f5f5",
|
background_color: "#f5f5f5",
|
||||||
font_family: `-apple-system, BlinkMacSystemFont,"Microsoft YaHei UI", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", ${
|
font_family: `-apple-system, BlinkMacSystemFont,"Microsoft YaHei UI", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji"${
|
||||||
OS === "windows" ? "twemoji mozilla" : ""
|
OS === "windows" ? ", twemoji mozilla" : ""
|
||||||
}`,
|
}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -200,10 +200,10 @@ const ConnectionsPage = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
height="calc(100% - 70px)"
|
height="calc(100% - 65px)"
|
||||||
sx={{
|
sx={{
|
||||||
userSelect: "text",
|
userSelect: "text",
|
||||||
margin: "12px",
|
margin: "10px",
|
||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
bgcolor: isDark ? "#282a36" : "#ffffff",
|
bgcolor: isDark ? "#282a36" : "#ffffff",
|
||||||
}}
|
}}
|
||||||
|
|||||||
+2
-2
@@ -110,9 +110,9 @@ const LogPage = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
height="calc(100% - 70px)"
|
height="calc(100% - 65px)"
|
||||||
sx={{
|
sx={{
|
||||||
margin: "12px",
|
margin: "10px",
|
||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
bgcolor: isDark ? "#282a36" : "#ffffff",
|
bgcolor: isDark ? "#282a36" : "#ffffff",
|
||||||
}}
|
}}
|
||||||
|
|||||||
+48
-21
@@ -2,7 +2,15 @@ import useSWR, { mutate } from "swr";
|
|||||||
import { useMemo, useRef, useState } from "react";
|
import { useMemo, useRef, useState } from "react";
|
||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
import { Box, Button, Grid, IconButton, Stack, TextField } from "@mui/material";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Grid,
|
||||||
|
IconButton,
|
||||||
|
Stack,
|
||||||
|
TextField,
|
||||||
|
Divider,
|
||||||
|
} from "@mui/material";
|
||||||
import {
|
import {
|
||||||
DndContext,
|
DndContext,
|
||||||
closestCenter,
|
closestCenter,
|
||||||
@@ -46,6 +54,8 @@ import { ProfileMore } from "@/components/profile/profile-more";
|
|||||||
import { useProfiles } from "@/hooks/use-profiles";
|
import { useProfiles } from "@/hooks/use-profiles";
|
||||||
import { ConfigViewer } from "@/components/setting/mods/config-viewer";
|
import { ConfigViewer } from "@/components/setting/mods/config-viewer";
|
||||||
import { throttle } from "lodash-es";
|
import { throttle } from "lodash-es";
|
||||||
|
import { useRecoilState } from "recoil";
|
||||||
|
import { atomThemeMode } from "@/services/states";
|
||||||
|
|
||||||
const ProfilePage = () => {
|
const ProfilePage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -235,6 +245,11 @@ const ProfilePage = () => {
|
|||||||
const text = await navigator.clipboard.readText();
|
const text = await navigator.clipboard.readText();
|
||||||
if (text) setUrl(text);
|
if (text) setUrl(text);
|
||||||
};
|
};
|
||||||
|
const [mode] = useRecoilState(atomThemeMode);
|
||||||
|
const islight = mode === "light" ? true : false;
|
||||||
|
const dividercolor = islight
|
||||||
|
? "rgba(0, 0, 0, 0.06)"
|
||||||
|
: "rgba(255, 255, 255, 0.06)";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
@@ -323,6 +338,7 @@ const ProfilePage = () => {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
size="small"
|
size="small"
|
||||||
|
sx={{ borderRadius: "6px" }}
|
||||||
onClick={onImport}
|
onClick={onImport}
|
||||||
>
|
>
|
||||||
{t("Import")}
|
{t("Import")}
|
||||||
@@ -330,6 +346,7 @@ const ProfilePage = () => {
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
size="small"
|
size="small"
|
||||||
|
sx={{ borderRadius: "6px" }}
|
||||||
onClick={() => viewerRef.current?.create()}
|
onClick={() => viewerRef.current?.create()}
|
||||||
>
|
>
|
||||||
{t("New")}
|
{t("New")}
|
||||||
@@ -341,7 +358,7 @@ const ProfilePage = () => {
|
|||||||
mb: 0.5,
|
mb: 0.5,
|
||||||
pl: "10px",
|
pl: "10px",
|
||||||
mr: "10px",
|
mr: "10px",
|
||||||
height: "calc(100% - 20px)",
|
height: "calc(100% - 68px)",
|
||||||
overflowY: "auto",
|
overflowY: "auto",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -350,7 +367,7 @@ const ProfilePage = () => {
|
|||||||
collisionDetection={closestCenter}
|
collisionDetection={closestCenter}
|
||||||
onDragEnd={onDragEnd}
|
onDragEnd={onDragEnd}
|
||||||
>
|
>
|
||||||
<Box sx={{ mb: 4.5 }}>
|
<Box sx={{ mb: 1.5 }}>
|
||||||
<Grid container spacing={{ xs: 1, lg: 1 }}>
|
<Grid container spacing={{ xs: 1, lg: 1 }}>
|
||||||
<SortableContext
|
<SortableContext
|
||||||
items={regularItems.map((x) => {
|
items={regularItems.map((x) => {
|
||||||
@@ -375,24 +392,34 @@ const ProfilePage = () => {
|
|||||||
</DndContext>
|
</DndContext>
|
||||||
|
|
||||||
{enhanceItems.length > 0 && (
|
{enhanceItems.length > 0 && (
|
||||||
<Grid container spacing={{ xs: 2, lg: 2 }}>
|
<Divider
|
||||||
{enhanceItems.map((item) => (
|
variant="middle"
|
||||||
<Grid item xs={12} sm={6} md={4} lg={3} key={item.file}>
|
flexItem
|
||||||
<ProfileMore
|
sx={{ width: `calc(100% - 32px)`, borderColor: dividercolor }}
|
||||||
selected={!!chain.includes(item.uid)}
|
></Divider>
|
||||||
itemData={item}
|
)}
|
||||||
enableNum={chain.length || 0}
|
|
||||||
logInfo={chainLogs[item.uid]}
|
{enhanceItems.length > 0 && (
|
||||||
onEnable={() => onEnable(item.uid)}
|
<Box sx={{ mt: 1.5 }}>
|
||||||
onDisable={() => onDisable(item.uid)}
|
<Grid container spacing={{ xs: 1, lg: 1 }}>
|
||||||
onDelete={() => onDelete(item.uid)}
|
{enhanceItems.map((item) => (
|
||||||
onMoveTop={() => onMoveTop(item.uid)}
|
<Grid item xs={12} sm={6} md={4} lg={3} key={item.file}>
|
||||||
onMoveEnd={() => onMoveEnd(item.uid)}
|
<ProfileMore
|
||||||
onEdit={() => viewerRef.current?.edit(item)}
|
selected={!!chain.includes(item.uid)}
|
||||||
/>
|
itemData={item}
|
||||||
</Grid>
|
enableNum={chain.length || 0}
|
||||||
))}
|
logInfo={chainLogs[item.uid]}
|
||||||
</Grid>
|
onEnable={() => onEnable(item.uid)}
|
||||||
|
onDisable={() => onDisable(item.uid)}
|
||||||
|
onDelete={() => onDelete(item.uid)}
|
||||||
|
onMoveTop={() => onMoveTop(item.uid)}
|
||||||
|
onMoveEnd={() => onMoveEnd(item.uid)}
|
||||||
|
onEdit={() => viewerRef.current?.edit(item)}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<ProfileViewer ref={viewerRef} onChange={() => mutateProfiles()} />
|
<ProfileViewer ref={viewerRef} onChange={() => mutateProfiles()} />
|
||||||
|
|||||||
+2
-2
@@ -56,9 +56,9 @@ const RulesPage = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
height="calc(100% - 70px)"
|
height="calc(100% - 65px)"
|
||||||
sx={{
|
sx={{
|
||||||
margin: "12px",
|
margin: "10px",
|
||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
bgcolor: isDark ? "#282a36" : "#ffffff",
|
bgcolor: isDark ? "#282a36" : "#ffffff",
|
||||||
}}
|
}}
|
||||||
|
|||||||
+1
-1
@@ -134,7 +134,7 @@ const TestPage = () => {
|
|||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
pt: 1,
|
pt: 1.25,
|
||||||
mb: 0.5,
|
mb: 0.5,
|
||||||
px: "10px",
|
px: "10px",
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -213,6 +213,10 @@ export async function getPortableFlag() {
|
|||||||
return invoke<boolean>("get_portable_flag");
|
return invoke<boolean>("get_portable_flag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function openDevTools() {
|
||||||
|
return invoke("open_devtools");
|
||||||
|
}
|
||||||
|
|
||||||
export async function exitApp() {
|
export async function exitApp() {
|
||||||
return invoke("exit_app");
|
return invoke("exit_app");
|
||||||
}
|
}
|
||||||
@@ -223,3 +227,7 @@ export async function copyIconFile(
|
|||||||
) {
|
) {
|
||||||
return invoke<void>("copy_icon_file", { path, name });
|
return invoke<void>("copy_icon_file", { path, name });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function downloadIconCache(url: string, name: string) {
|
||||||
|
return invoke<string>("download_icon_cache", { url, name });
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user