Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0761869b6 | ||
|
|
bb99b89228 | ||
|
|
7b88beb0b5 | ||
|
|
82c630bd0e | ||
|
|
bb4f11e1b8 | ||
|
|
3182d20b7c | ||
|
|
a6f15e2474 | ||
|
|
0c3f03680c | ||
|
|
a66e8dfc9f | ||
|
|
556232aac4 | ||
|
|
7fcfaadd91 | ||
|
|
18d388e1e2 | ||
|
|
7de6622d74 | ||
|
|
9af1f90990 | ||
|
|
15ab43963d | ||
|
|
6b7465a4b0 | ||
|
|
d64bdf02de | ||
|
|
4a2c94993a | ||
|
|
86c318d86b | ||
|
|
bffc1ad41d | ||
|
|
2a685c116f | ||
|
|
0e271d2924 | ||
|
|
7127c4d590 | ||
|
|
a82929996b | ||
|
|
3f01f52c7b | ||
|
|
9c94494622 | ||
|
|
c8a508f35c | ||
|
|
4ec73ef1c3 | ||
|
|
3465b79e5b | ||
|
|
726a0a33ae | ||
|
|
ba05810d80 | ||
|
|
10bb53e7de | ||
|
|
dd8a083546 | ||
|
|
84131a71c9 | ||
|
|
4909a11896 | ||
|
|
4069357b81 | ||
|
|
e6e87bcc40 | ||
|
|
7ba22045e8 | ||
|
|
d4040b61c4 | ||
|
|
7534f8fc37 | ||
|
|
7ced009e92 | ||
|
|
cc13c71e40 | ||
|
|
d2f09209a7 | ||
|
|
a241b04d99 | ||
|
|
4f35d907cb | ||
|
|
9e50d144a3 | ||
|
|
8514bb48c4 | ||
|
|
3ae633a2a1 | ||
|
|
2799cb9118 | ||
|
|
d20346b6ac | ||
|
|
2f00666a68 | ||
|
|
80f4570093 | ||
|
|
3f0a2ba48f | ||
|
|
fc90094e8a | ||
|
|
20d580ade8 | ||
|
|
290a024a9e | ||
|
|
64a283c3a6 | ||
|
|
3e93f0ecbc | ||
|
|
b12bcc1c49 | ||
|
|
05d7313dcc | ||
|
|
c0b6e549f0 | ||
|
|
31f9bf219e | ||
|
|
4906ca7059 | ||
|
|
b963a7a0e5 | ||
|
|
5d6dadda76 | ||
|
|
77f69fd223 | ||
|
|
7f5052bc87 | ||
|
|
3009c1f4f6 | ||
|
|
5425872bba | ||
|
|
0759e17295 | ||
|
|
56a59d25df | ||
|
|
887f92babe | ||
|
|
197f942b3f | ||
|
|
a5be7a35e9 | ||
|
|
e347675265 | ||
|
|
02a084d571 | ||
|
|
7fbcc23d94 | ||
|
|
bda87167a3 | ||
|
|
34f53c287e | ||
|
|
9ab07f37d7 | ||
|
|
36399b39fb | ||
|
|
1e015287a1 | ||
|
|
a590aa8485 | ||
|
|
c0582fde66 | ||
|
|
d8d75b4afa | ||
|
|
9d4942723c | ||
|
|
e5b1ece5c0 | ||
|
|
1b25bfbf5a | ||
|
|
7c64d9f42a | ||
|
|
61f9f4ef58 | ||
|
|
b8eac56213 | ||
|
|
ab5fb5749b | ||
|
|
e0fb9a1b25 | ||
|
|
97e717f646 | ||
|
|
caa82ad1e6 | ||
|
|
7ec251ea6d | ||
|
|
675b0c3cca | ||
|
|
05e54d4b7f | ||
|
|
b4527c90e5 | ||
|
|
dbc626734d | ||
|
|
3f2ce3cb80 | ||
|
|
0820d6d6fb | ||
|
|
a8c74e39c2 | ||
|
|
d58c29907d | ||
|
|
2322733427 | ||
|
|
d76e8fe85a | ||
|
|
0c2e4fe34a | ||
|
|
30b6c87a49 | ||
|
|
540221467a | ||
|
|
9df1115380 | ||
|
|
f22e360cbb | ||
|
|
67769af6f4 | ||
|
|
b1a9a1d6d9 | ||
|
|
cf0606ecb7 | ||
|
|
7287edcd6f | ||
|
|
e0d26203dd | ||
|
|
7e3a85e9da | ||
|
|
5a0fed9c93 | ||
|
|
1f1e743912 | ||
|
|
b4301ed0d5 | ||
|
|
b5391560fc | ||
|
|
718989cbcf | ||
|
|
d0aee76962 | ||
|
|
fb08af96bd | ||
|
|
510a0c5e70 | ||
|
|
5fe2be031f | ||
|
|
2ba3aaba47 | ||
|
|
ad8903991c | ||
|
|
3e5624c570 |
@@ -1,33 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: "[BUG]"
|
|
||||||
labels: bug
|
|
||||||
assignees: ""
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
||||||
**Information**
|
|
||||||
|
|
||||||
- OS: [e.g. macOS]
|
|
||||||
- Clash Nyanpasu Version: [e.g. 1.3.4]
|
|
||||||
- Clash Core: [e.g. Clash or Clash Meta]
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
name: Bug report
|
||||||
|
description: Create a report to help us improve
|
||||||
|
title: "[BUG]"
|
||||||
|
labels: ["bug"]
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe the bug
|
||||||
|
description: A clear and concise description of what the bug is.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: To Reproduce
|
||||||
|
description: Steps to reproduce the behavior.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
attributes:
|
||||||
|
label: Platform
|
||||||
|
options:
|
||||||
|
- Windows
|
||||||
|
- Linux
|
||||||
|
- MacOS
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: System Version
|
||||||
|
placeholder: "e.g. macOS 10.15.7"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Software Version
|
||||||
|
placeholder: "e.g. 1.4.3"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Log
|
||||||
|
description: "Log file content or screenshot"
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional Information
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: "[Feature]"
|
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
name: Feature request
|
||||||
|
description: Suggest an idea for this project
|
||||||
|
title: "[Feature]"
|
||||||
|
labels: ["enhancement"]
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Is your feature request related to a problem? Please describe.
|
||||||
|
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe the solution you'd like
|
||||||
|
description: A clear and concise description of what you want to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe alternatives you've considered
|
||||||
|
description: A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context or screenshots about the feature request here.
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
FROM rust:buster
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod a+x /entrypoint.sh
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
name: "Build for Linux"
|
||||||
|
branding:
|
||||||
|
icon: user-check
|
||||||
|
color: gray-dark
|
||||||
|
inputs:
|
||||||
|
target:
|
||||||
|
required: true
|
||||||
|
description: "Rust Target"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "docker"
|
||||||
|
image: "Dockerfile"
|
||||||
|
args:
|
||||||
|
- ${{ inputs.target }}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# pnpm install --resolution-only
|
||||||
|
pnpm install
|
||||||
|
pnpm check $INPUT_TARGET
|
||||||
|
sed -i "s/#openssl/openssl={version=\"0.10\",features=[\"vendored\"]}/g" src-tauri/Cargo.toml
|
||||||
|
if [ "$INPUT_TARGET" = "x86_64-unknown-linux-gnu" ] || [ "$INPUT_TARGET" = "i686-unknown-linux-gnu" ]; then
|
||||||
|
pnpm build --target $INPUT_TARGET
|
||||||
|
else
|
||||||
|
pnpm build --target $INPUT_TARGET -b deb
|
||||||
|
fi
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
wget https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz
|
||||||
|
tar -Jxvf ./node-v20.10.0-linux-x64.tar.xz
|
||||||
|
export PATH=$(pwd)/node-v20.10.0-linux-x64/bin:$PATH
|
||||||
|
npm install pnpm -g
|
||||||
|
|
||||||
|
rustup target add "$INPUT_TARGET"
|
||||||
|
|
||||||
|
if [ "$INPUT_TARGET" = "x86_64-unknown-linux-gnu" ]; then
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||||
|
elif [ "$INPUT_TARGET" = "i686-unknown-linux-gnu" ]; then
|
||||||
|
dpkg --add-architecture i386
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y libstdc++6:i386 libgdk-pixbuf2.0-dev:i386 libatomic1:i386 gcc-multilib g++-multilib libwebkit2gtk-4.0-dev:i386 libssl-dev:i386 libgtk-3-dev:i386 librsvg2-dev:i386 patchelf:i386 libayatana-appindicator3-dev:i386
|
||||||
|
export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH
|
||||||
|
export PKG_CONFIG_SYSROOT_DIR=/
|
||||||
|
elif [ "$INPUT_TARGET" = "aarch64-unknown-linux-gnu" ]; then
|
||||||
|
sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list | tee /etc/apt/sources.list.d/ports.list
|
||||||
|
sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list
|
||||||
|
dpkg --add-architecture arm64
|
||||||
|
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 --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
|
||||||
|
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=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 PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
|
||||||
|
export PKG_CONFIG_ALLOW_CROSS=1
|
||||||
|
elif [ "$INPUT_TARGET" = "armv7-unknown-linux-gnueabihf" ]; then
|
||||||
|
sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list | tee /etc/apt/sources.list.d/ports.list
|
||||||
|
sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list
|
||||||
|
dpkg --add-architecture armhf
|
||||||
|
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 --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
|
||||||
|
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=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 PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
|
||||||
|
export PKG_CONFIG_ALLOW_CROSS=1
|
||||||
|
else
|
||||||
|
echo "Unknown target: $INPUT_TARGET" && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash .github/build-for-linux/build.sh
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
name: Alpha CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
debug:
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
RUST_BACKTRACE: short
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [windows-latest, ubuntu-20.04, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
if: startsWith(github.repository, 'zzzgydi')
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: install Rust stable
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "16"
|
|
||||||
cache: "yarn"
|
|
||||||
|
|
||||||
- name: Delete current release assets
|
|
||||||
if: startsWith(matrix.os, 'ubuntu-')
|
|
||||||
uses: mknejp/delete-release-assets@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
tag: alpha
|
|
||||||
fail-if-no-assets: false
|
|
||||||
fail-if-no-release: false
|
|
||||||
assets: |
|
|
||||||
*.zip
|
|
||||||
*.gz
|
|
||||||
*.AppImage
|
|
||||||
*.deb
|
|
||||||
*.dmg
|
|
||||||
*.msi
|
|
||||||
*.sig
|
|
||||||
|
|
||||||
- name: Install Dependencies (ubuntu only)
|
|
||||||
if: startsWith(matrix.os, 'ubuntu-')
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf openssl
|
|
||||||
|
|
||||||
- name: Yarn install and check
|
|
||||||
run: |
|
|
||||||
yarn install --network-timeout 1000000 --frozen-lockfile
|
|
||||||
yarn run check
|
|
||||||
|
|
||||||
- name: Tauri build
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
with:
|
|
||||||
tagName: alpha
|
|
||||||
releaseName: "Clash Verge Alpha"
|
|
||||||
releaseBody: "Alpha Version (include debug)"
|
|
||||||
releaseDraft: false
|
|
||||||
prerelease: true
|
|
||||||
includeDebug: ${{ github.event.inputs.debug }}
|
|
||||||
|
|
||||||
- name: Portable Bundle
|
|
||||||
if: startsWith(matrix.os, 'windows-')
|
|
||||||
run: |
|
|
||||||
yarn build
|
|
||||||
yarn run portable
|
|
||||||
env:
|
|
||||||
TAG_NAME: alpha
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
VITE_WIN_PORTABLE: 1
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
name: Release CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- v**
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
RUST_BACKTRACE: short
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
if: startsWith(github.repository, 'zzzgydi')
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: install Rust stable
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "16"
|
|
||||||
cache: "yarn"
|
|
||||||
|
|
||||||
- name: Install Dependencies (ubuntu only)
|
|
||||||
if: startsWith(matrix.os, 'ubuntu-')
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf openssl
|
|
||||||
|
|
||||||
- name: Yarn install and check
|
|
||||||
run: |
|
|
||||||
yarn install --network-timeout 1000000 --frozen-lockfile
|
|
||||||
yarn run check
|
|
||||||
|
|
||||||
- name: Tauri build
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
# enable cache even though failed
|
|
||||||
# continue-on-error: true
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
with:
|
|
||||||
tagName: v__VERSION__
|
|
||||||
releaseName: "Clash Verge v__VERSION__"
|
|
||||||
releaseBody: "More new features are now supported."
|
|
||||||
releaseDraft: false
|
|
||||||
prerelease: true
|
|
||||||
|
|
||||||
- name: Portable Bundle
|
|
||||||
if: startsWith(matrix.os, 'windows-')
|
|
||||||
# rebuild with env settings
|
|
||||||
run: |
|
|
||||||
yarn build
|
|
||||||
yarn run portable
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
VITE_WIN_PORTABLE: 1
|
|
||||||
|
|
||||||
release-update:
|
|
||||||
needs: release
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: |
|
|
||||||
startsWith(github.repository, 'zzzgydi') &&
|
|
||||||
startsWith(github.ref, 'refs/tags/v')
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "16"
|
|
||||||
cache: "yarn"
|
|
||||||
|
|
||||||
- name: Yarn install
|
|
||||||
run: yarn install --network-timeout 1000000 --frozen-lockfile
|
|
||||||
|
|
||||||
- name: Release updater file
|
|
||||||
run: yarn run updater
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
name: Compatible CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
# push:
|
|
||||||
# tags:
|
|
||||||
# - v**
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
RUST_BACKTRACE: short
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
targets:
|
|
||||||
- tag: macOS-10.15
|
|
||||||
os: macos-10.15
|
|
||||||
- tag: Ubuntu18
|
|
||||||
os: ubuntu-18.04
|
|
||||||
- tag: Ubuntu22
|
|
||||||
os: ubuntu-22.04
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.targets.os }}
|
|
||||||
if: startsWith(github.repository, 'zzzgydi')
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Install Rust
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
profile: minimal
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: 16
|
|
||||||
|
|
||||||
# - name: Install Dependencies (ubuntu18 only)
|
|
||||||
# if: matrix.targets.os == 'ubuntu-18.04'
|
|
||||||
# run: |
|
|
||||||
# sudo apt-get update
|
|
||||||
# sudo apt-get install -y libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libappindicator3-dev librsvg2-dev libayatana-appindicator3-dev
|
|
||||||
|
|
||||||
- name: Install Dependencies (ubuntu22 only)
|
|
||||||
if: startsWith(matrix.targets.os, 'ubuntu-')
|
|
||||||
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
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
||||||
|
|
||||||
- name: Yarn Cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
|
|
||||||
- name: Yarn install and check
|
|
||||||
run: |
|
|
||||||
yarn install --network-timeout 1000000
|
|
||||||
yarn run check
|
|
||||||
|
|
||||||
- name: Tauri build
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
with:
|
|
||||||
tagName: ${{ matrix.targets.tag }}
|
|
||||||
releaseName: "Compatible For ${{ matrix.targets.tag }}"
|
|
||||||
releaseBody: "More new features are now supported."
|
|
||||||
releaseDraft: false
|
|
||||||
prerelease: false
|
|
||||||
|
|
||||||
# - name: Portable Bundle
|
|
||||||
# if: matrix.os == 'windows-latest'
|
|
||||||
# # rebuild with env settings
|
|
||||||
# run: |
|
|
||||||
# yarn build
|
|
||||||
# yarn run portable
|
|
||||||
# env:
|
|
||||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
# TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
# VITE_WIN_PORTABLE: 1
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
name: Dev Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- dev
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
RUST_BACKTRACE: short
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
if: startsWith(github.repository, 'keiko233')
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: install Rust stable
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "20"
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
|
||||||
name: Install pnpm
|
|
||||||
with:
|
|
||||||
version: 8
|
|
||||||
run_install: false
|
|
||||||
|
|
||||||
- name: Delete current release assets
|
|
||||||
if: startsWith(matrix.os, 'ubuntu-')
|
|
||||||
uses: mknejp/delete-release-assets@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GH_TOKEN }}
|
|
||||||
tag: dev
|
|
||||||
fail-if-no-assets: false
|
|
||||||
fail-if-no-release: false
|
|
||||||
assets: |
|
|
||||||
*.zip
|
|
||||||
*.gz
|
|
||||||
*.AppImage
|
|
||||||
*.deb
|
|
||||||
*.dmg
|
|
||||||
*.msi
|
|
||||||
*.sig
|
|
||||||
|
|
||||||
- name: Install Dependencies (Ubuntu Only)
|
|
||||||
if: startsWith(matrix.os, 'ubuntu-')
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf openssl
|
|
||||||
|
|
||||||
- name: Pnpm install and check
|
|
||||||
run: |
|
|
||||||
pnpm i
|
|
||||||
pnpm check
|
|
||||||
|
|
||||||
- name: Tauri build
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
with:
|
|
||||||
tagName: dev
|
|
||||||
releaseName: "Clash Nyanpasu Dev"
|
|
||||||
releaseBody: "More new features are now supported."
|
|
||||||
releaseDraft: false
|
|
||||||
prerelease: true
|
|
||||||
tauriScript: pnpm
|
|
||||||
args: -f default-meta
|
|
||||||
|
|
||||||
- name: Portable Bundle
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
run: |
|
|
||||||
pnpm build -f default-meta
|
|
||||||
pnpm portable
|
|
||||||
env:
|
|
||||||
TAG_NAME: dev
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
VITE_WIN_PORTABLE: 1
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
name: Meta CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- v**
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
RUST_BACKTRACE: short
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
if: startsWith(github.repository, 'zzzgydi')
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Install Rust
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
profile: minimal
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: 16
|
|
||||||
|
|
||||||
- name: Delete current release assets
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
uses: mknejp/delete-release-assets@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
tag: meta
|
|
||||||
fail-if-no-assets: false
|
|
||||||
fail-if-no-release: false
|
|
||||||
assets: |
|
|
||||||
*.zip
|
|
||||||
*.gz
|
|
||||||
*.AppImage
|
|
||||||
*.deb
|
|
||||||
*.dmg
|
|
||||||
*.msi
|
|
||||||
*.sig
|
|
||||||
|
|
||||||
- name: Install Dependencies (ubuntu only)
|
|
||||||
if: startsWith(matrix.os, 'ubuntu-')
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf openssl
|
|
||||||
|
|
||||||
- name: Get yarn cache dir path
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
||||||
|
|
||||||
- name: Yarn Cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
|
|
||||||
- name: Yarn install and check
|
|
||||||
run: |
|
|
||||||
yarn install --network-timeout 1000000
|
|
||||||
yarn run check
|
|
||||||
|
|
||||||
- name: Tauri build
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
with:
|
|
||||||
tagName: meta
|
|
||||||
releaseName: "Clash Verge Meta"
|
|
||||||
releaseBody: ""
|
|
||||||
releaseDraft: false
|
|
||||||
prerelease: true
|
|
||||||
args: -f default-meta
|
|
||||||
|
|
||||||
- name: Portable Bundle
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
run: |
|
|
||||||
yarn build -f default-meta
|
|
||||||
yarn run portable
|
|
||||||
env:
|
|
||||||
TAG_NAME: meta
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
VITE_WIN_PORTABLE: 1
|
|
||||||
@@ -3,9 +3,9 @@ name: Release Build
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- v**
|
||||||
|
permissions: write-all
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
RUST_BACKTRACE: short
|
RUST_BACKTRACE: short
|
||||||
@@ -13,25 +13,49 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
- os: windows-latest
|
||||||
|
target: i686-pc-windows-msvc
|
||||||
|
- os: windows-latest
|
||||||
|
target: aarch64-pc-windows-msvc
|
||||||
|
- os: macos-latest
|
||||||
|
target: aarch64-apple-darwin
|
||||||
|
- os: macos-latest
|
||||||
|
target: x86_64-apple-darwin
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
if: startsWith(github.repository, 'keiko233')
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: install Rust stable
|
- 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
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Add Rust Target
|
||||||
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Rust Cache
|
- name: Rust Cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: src-tauri
|
workspaces: src-tauri
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "20"
|
node-version: "20"
|
||||||
|
|
||||||
@@ -41,54 +65,93 @@ jobs:
|
|||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Install Dependencies (Ubuntu Only)
|
|
||||||
if: startsWith(matrix.os, 'ubuntu-')
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf openssl
|
|
||||||
|
|
||||||
- name: Pnpm install and check
|
- name: Pnpm install and check
|
||||||
run: |
|
run: |
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm check
|
pnpm check ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Tauri build
|
- name: Tauri build
|
||||||
uses: tauri-apps/tauri-action@v0
|
uses: tauri-apps/tauri-action@v0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
with:
|
with:
|
||||||
tagName: v__VERSION__
|
tagName: v__VERSION__
|
||||||
releaseName: "Clash Nyanpasu v__VERSION__"
|
releaseName: "Clash Verge v__VERSION__"
|
||||||
releaseBody: "More new features are now supported."
|
releaseBody: "More new features are now supported."
|
||||||
releaseDraft: false
|
releaseDraft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
tauriScript: pnpm
|
tauriScript: pnpm
|
||||||
args: -f default-meta
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Portable Bundle
|
- name: Portable Bundle
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: pnpm portable ${{ matrix.target }}
|
||||||
pnpm build -f default-meta
|
|
||||||
pnpm portable
|
|
||||||
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 }}
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
VITE_WIN_PORTABLE: 1
|
VITE_WIN_PORTABLE: 1
|
||||||
|
|
||||||
|
release-for-linux:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: i686-unknown-linux-gnu
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: aarch64-unknown-linux-gnu
|
||||||
|
# - os: ubuntu-latest
|
||||||
|
# target: armv7-unknown-linux-gnueabihf
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build for Linux
|
||||||
|
uses: ./.github/build-for-linux
|
||||||
|
env:
|
||||||
|
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
|
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
with:
|
||||||
|
target: ${{ matrix.target }}
|
||||||
|
- name: Get Version
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install jq
|
||||||
|
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||||
|
- name: Upload Release
|
||||||
|
if: startsWith(matrix.target, 'x86_64') || startsWith(matrix.target, 'i686')
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
tag_name: v${{env.VERSION}}
|
||||||
|
name: "Clash Verge v${{env.VERSION}}"
|
||||||
|
body: "More new features are now supported."
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage*
|
||||||
|
- name: Upload Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
tag_name: v${{env.VERSION}}
|
||||||
|
name: "Clash Verge v${{env.VERSION}}"
|
||||||
|
body: "More new features are now supported."
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
files: src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||||
|
|
||||||
release-update:
|
release-update:
|
||||||
needs: release
|
needs: [release]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: |
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
startsWith(github.repository, 'keiko233')
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "20"
|
node-version: "20"
|
||||||
|
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
name: Test CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
os:
|
|
||||||
description: "Runs on OS"
|
|
||||||
required: true
|
|
||||||
default: windows-latest
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- windows-latest
|
|
||||||
- ubuntu-latest
|
|
||||||
- macos-latest
|
|
||||||
- ubuntu-18.04
|
|
||||||
- ubuntu-20.04
|
|
||||||
- ubuntu-22.04
|
|
||||||
- macos-10.15
|
|
||||||
- macos-11
|
|
||||||
- macos-12
|
|
||||||
- windows-2019
|
|
||||||
- windows-2022
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
RUST_BACKTRACE: short
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
runs-on: ${{ github.event.inputs.os }}
|
|
||||||
if: startsWith(github.repository, 'zzzgydi')
|
|
||||||
steps:
|
|
||||||
- name: System Version
|
|
||||||
run: |
|
|
||||||
echo ${{ github.event.inputs.os }}
|
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: install Rust stable
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "16"
|
|
||||||
cache: "yarn"
|
|
||||||
|
|
||||||
- name: Install Dependencies (ubuntu only)
|
|
||||||
if: startsWith(github.event.inputs.os, 'ubuntu-')
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
|
|
||||||
|
|
||||||
- name: Yarn install and check
|
|
||||||
run: |
|
|
||||||
yarn install --network-timeout 1000000 --frozen-lockfile
|
|
||||||
yarn run check
|
|
||||||
|
|
||||||
- name: Tauri build
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
|
||||||
with:
|
|
||||||
tagName: alpha
|
|
||||||
releaseName: "Clash Verge Alpha"
|
|
||||||
releaseBody: "Alpha Version (include debug)"
|
|
||||||
releaseDraft: false
|
|
||||||
includeUpdaterJson: false
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
name: Updater CI
|
name: Updater CI
|
||||||
|
|
||||||
on: workflow_dispatch
|
on: workflow_dispatch
|
||||||
|
permissions: write-all
|
||||||
jobs:
|
jobs:
|
||||||
release-update:
|
release-update:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.repository, 'zzzgydi')
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -13,13 +12,18 @@ jobs:
|
|||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: "16"
|
node-version: "20"
|
||||||
cache: "yarn"
|
|
||||||
|
|
||||||
- name: Yarn install
|
- uses: pnpm/action-setup@v2
|
||||||
run: yarn install --network-timeout 1000000 --frozen-lockfile
|
name: Install pnpm
|
||||||
|
with:
|
||||||
|
version: 8
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Pnpm install
|
||||||
|
run: pnpm i
|
||||||
|
|
||||||
- name: Release updater file
|
- name: Release updater file
|
||||||
run: yarn run updater
|
run: pnpm updater
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -1,25 +1,58 @@
|
|||||||
<h1 align="center">
|
<h1 align="center">
|
||||||
<img src="./src/assets/image/logo.png" alt="Clash" width="128" />
|
<img src="./src/assets/image/logo.png" alt="Clash" width="128" />
|
||||||
<br>
|
<br>
|
||||||
Clash Nyanpasu
|
Continuation of <a href="https://github.com/zzzgydi/clash-verge">Clash Verge</a>
|
||||||
<br>
|
<br>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<h3 align="center">
|
<h3 align="center">
|
||||||
A <a href="https://github.com/Dreamacro/clash">Clash</a> 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>
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Full `clash` config supported, Partial `clash premium` config supported.
|
- Since the clash core has been removed. The project no longer maintains the clash core, but only the Clash Meta core.
|
||||||
- Profiles management and enhancement (by yaml and Javascript). [Doc](https://github.com/keiko233/clash-nyanpasu/wiki/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)
|
- Profiles management and enhancement (by yaml and Javascript). [Doc](https://github.com/clash-verge-rev/clash-verge-rev/wiki/%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)
|
||||||
- Simple UI and supports custom theme color.
|
- Simple UI and supports custom theme color.
|
||||||
- Built-in support [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta) core.
|
- Built-in support [Clash.Meta(mihomo)](https://github.com/MetaCubeX/mihomo) core.
|
||||||
- System proxy setting and guard.
|
- System proxy setting and guard.
|
||||||
|
|
||||||
|
#### TG Group: [@clash_verge_rev](https://t.me/clash_verge_rev)
|
||||||
|
|
||||||
|
## Promotion
|
||||||
|
|
||||||
|
[狗狗加速 —— 技术流机场 Doggygo VPN](https://狗狗加速.com)
|
||||||
|
|
||||||
|
- 高性能海外机场,免费试用,优惠套餐,解锁流媒体,全球首家支持 Hysteria 协议。
|
||||||
|
- 使用 Clash Verge 专属邀请链接注册送 3 天,每天 1G 流量免费试用:https://verge.狗狗加速.com/#/register?code=oaxsAGo6
|
||||||
|
- Clash Verge 专属 8 折优惠码: verge20 (仅有 500 份)
|
||||||
|
- 优惠套餐每月仅需 15.8 元,160G 流量,年付 8 折
|
||||||
|
- 海外团队,无跑路风险,高达 50% 返佣
|
||||||
|
- 集群负载均衡设计,高速专线(兼容老客户端),极低延迟,无视晚高峰,4K 秒开
|
||||||
|
- 全球首家 Hysteria 协议机场,现已上线更快的 `Hysteria2` 协议(Clash Verge 客户端最佳搭配)
|
||||||
|
- 解锁流媒体及 ChatGPT
|
||||||
|
- 官网:https://狗狗加速.com
|
||||||
|
|
||||||
|
## Preview
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Download from [release](https://github.com/keiko233/clash-nyanpasu/releases). Supports Windows x64, Linux x86_64 and macOS 11+
|
Download from [release](https://github.com/clash-verge-rev/clash-verge-rev/releases). Supports Windows (x64/x86), Linux (x64/arm64) and macOS 10.15+ (intel/apple).
|
||||||
|
|
||||||
|
- [Windows x64](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/Clash.Verge_1.4.4_x64-setup.exe)
|
||||||
|
- [Windows x86](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/Clash.Verge_1.4.4_x86-setup.exe)
|
||||||
|
- [Windows arm64](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/Clash.Verge_1.4.4_arm64-setup.exe)
|
||||||
|
|
||||||
|
- [macOS intel](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/Clash.Verge_1.4.4_x64.dmg)
|
||||||
|
- [macOS apple](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/Clash.Verge_1.4.4_aarch64.dmg)
|
||||||
|
|
||||||
|
- [Linux x64 AppImage](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/clash-verge_1.4.4_amd64.AppImage)
|
||||||
|
- [Linux x64 deb](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/clash-verge_1.4.4_amd64.deb)
|
||||||
|
- [Linux x86 AppImage](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/clash-verge_1.4.4_i386.AppImage)
|
||||||
|
- [Linux x86 deb](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/clash-verge_1.4.4_i386.deb)
|
||||||
|
- [Linux arm64 deb](https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v1.4.4/clash-verge_1.4.4_arm64.deb)
|
||||||
|
|
||||||
Or you can build it yourself. Supports Windows, Linux and macOS 10.15+
|
Or you can build it yourself. Supports Windows, Linux and macOS 10.15+
|
||||||
|
|
||||||
@@ -27,9 +60,9 @@ Notes: If you could not start the app on Windows, please check that you have [We
|
|||||||
|
|
||||||
### FAQ
|
### FAQ
|
||||||
|
|
||||||
#### 1. **macOS** "Clash Nyanpasu" is damaged and can't be opened
|
#### 1. **macOS** "Clash Verge" is damaged and can't be opened
|
||||||
|
|
||||||
open the terminal and run `sudo xattr -r -d com.apple.quarantine /Applications/Clash\ Nyanpasu.app`
|
open the terminal and run `sudo xattr -r -d com.apple.quarantine /Applications/Clash\ Verge.app`
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
@@ -39,7 +72,7 @@ You should install Rust and Nodejs, see [here](https://tauri.app/v1/guides/getti
|
|||||||
pnpm i
|
pnpm i
|
||||||
```
|
```
|
||||||
|
|
||||||
Then download the clash binary... Or you can download it from [clash premium release](https://github.com/Dreamacro/clash/releases/tag/premium) and rename it according to [tauri config](https://tauri.studio/docs/api/config/#tauri.bundle.externalBin).
|
Then download the clash binary... Or you can download it from [clash meta release](https://github.com/MetaCubeX/Clash.Meta/releases) and rename it according to [tauri config](https://tauri.studio/docs/api/config/#tauri.bundle.externalBin).
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# force update to latest version
|
# force update to latest version
|
||||||
@@ -77,8 +110,9 @@ Issue and PR welcome!
|
|||||||
|
|
||||||
## Acknowledgement
|
## Acknowledgement
|
||||||
|
|
||||||
Clash Nyanpasu was based on or inspired by these projects and so on:
|
Clash Verge rev was based on or inspired by these projects and so on:
|
||||||
|
|
||||||
|
- [keiko233/clash-nyanpasu](https://github.com/keiko233/clash-nyanpasu): A Clash Verge variant.
|
||||||
- [zzzgydi/clash-verge](https://github.com/zzzgydi/clash-verge): A Clash GUI based on tauri. Supports Windows, macOS and Linux.
|
- [zzzgydi/clash-verge](https://github.com/zzzgydi/clash-verge): A Clash GUI based on tauri. Supports Windows, macOS and Linux.
|
||||||
- [tauri-apps/tauri](https://github.com/tauri-apps/tauri): Build smaller, faster, and more secure desktop applications with a web frontend.
|
- [tauri-apps/tauri](https://github.com/tauri-apps/tauri): Build smaller, faster, and more secure desktop applications with a web frontend.
|
||||||
- [Dreamacro/clash](https://github.com/Dreamacro/clash): A rule-based tunnel in Go.
|
- [Dreamacro/clash](https://github.com/Dreamacro/clash): A rule-based tunnel in Go.
|
||||||
|
|||||||
@@ -1,23 +1,104 @@
|
|||||||
|
## v1.4.4
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- 支持 Windows aarch64(arm64) 版本
|
||||||
|
- 支持一键更新 GeoData
|
||||||
|
- 支持一键更新 Alpha 内核
|
||||||
|
- MacOS 支持在系统代理时显示不同的托盘图标
|
||||||
|
- Linux 支持在系统代理时显示不同的托盘图标
|
||||||
|
- 优化复制环境变量逻辑
|
||||||
|
|
||||||
|
### Bugs Fixes
|
||||||
|
|
||||||
|
- 修改 PID 文件的路径
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
- 优化创建窗口的速度
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v1.4.3
|
||||||
|
|
||||||
|
### Break Changes
|
||||||
|
|
||||||
|
- 更改配置文件路径到标准目录(可以保证卸载时没有残留)
|
||||||
|
- 更改 appid 为 `io.github.clash-verge-rev.clash-verge-rev`
|
||||||
|
- 建议卸载旧版本后再安装新版本,该版本安装后不会使用旧版配置文件,你可以手动将旧版配置文件迁移到新版配置文件目录下
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- 移除页面切换动画
|
||||||
|
- 更改 Tun 模式托盘图标颜色
|
||||||
|
- Portable 版本默认使用当前目录作为配置文件目录
|
||||||
|
- 禁用 Clash 字段过滤时隐藏 Clash 字段选项
|
||||||
|
- 优化拖拽时光标样式
|
||||||
|
|
||||||
|
### Bugs Fixes
|
||||||
|
|
||||||
|
- 修复 windows 下更新时没有关闭内核导致的更新失败的问题
|
||||||
|
- 修复打开文件报错的问题
|
||||||
|
- 修复 url 导入时无法获取中文配置名称的问题
|
||||||
|
- 修复 alpha 内核无法显示内存信息的问题
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v1.4.2
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- update clash meta core to mihomo 1.17.0
|
||||||
|
- support both clash meta stable release and prerelease-alpha release
|
||||||
|
- fixed the problem of not being able to set the system proxy when there is a dial-up link on windows system [#833](https://github.com/zzzgydi/clash-verge/issues/833)
|
||||||
|
- support new clash field
|
||||||
|
- support random mixed port
|
||||||
|
- add windows x86 and linux armv7 support
|
||||||
|
- support disable tray click event
|
||||||
|
- add download progress for updater
|
||||||
|
- support drag to reorder the profile
|
||||||
|
- embed emoji fonts
|
||||||
|
- update depends
|
||||||
|
- improve UI style
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v1.4.1
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- update clash meta core to newest 虚空终端(2023.11.23)
|
||||||
|
- delete clash core UI
|
||||||
|
- improve UI
|
||||||
|
- change Logo to original
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## v1.4.0
|
## v1.4.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- Default use Meta Core.
|
- update clash meta core to newest 虚空终端
|
||||||
- Support copy PowerShell, CMD and sh env command.
|
- delete clash core, no longer maintain
|
||||||
- Add Upload Traffic, Download Traffic and Active Connections to ConnectionsPage.
|
- merge Clash nyanpasu changes
|
||||||
- SettingPage use Grid layout.
|
- remove delay display different color
|
||||||
- Import LoadingButton & use when Download Profile.
|
- use Meta Country.mmdb
|
||||||
- New default theme color.
|
- update dependencies
|
||||||
- Add Nyanpasu Element. (Logo designer [@ReallySnow](https://github.com/ReallySnow))
|
- small changes here and there
|
||||||
- Default enable unified-delay & tcp-concurrent.
|
|
||||||
- Use Meta Country.mmdb.
|
---
|
||||||
- Disable IPv6 by default.
|
|
||||||
- Add Material You element.
|
## v1.3.8
|
||||||
- Add Router switch transition.
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- update clash meta core
|
||||||
|
- add default valid keys
|
||||||
|
- adjust the delay display interval and color
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- Fix touchpad scrolling causes blank area to appear.
|
- fix connections page undefined exception
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 6.7 MiB |
@@ -1,73 +1,75 @@
|
|||||||
{
|
{
|
||||||
"name": "clash-nyanpasu",
|
"name": "clash-verge",
|
||||||
"version": "1.4.0",
|
"version": "1.4.4",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tauri dev -f default-meta",
|
"dev": "tauri dev",
|
||||||
"dev:diff": "tauri dev -f verge-dev",
|
"dev:diff": "tauri dev -f verge-dev",
|
||||||
"build": "tauri build -f default-meta",
|
"build": "tauri build",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"web:dev": "vite",
|
"web:dev": "vite",
|
||||||
"web:build": "tsc && vite build",
|
"web:build": "tsc && vite build",
|
||||||
"web:serve": "vite preview",
|
"web:serve": "vite preview",
|
||||||
"aarch": "node scripts/aarch.mjs",
|
|
||||||
"check": "node scripts/check.mjs",
|
"check": "node scripts/check.mjs",
|
||||||
"updater": "node scripts/updater.mjs",
|
"updater": "node scripts/updater.mjs",
|
||||||
"publish": "node scripts/publish.mjs",
|
|
||||||
"portable": "node scripts/portable.mjs",
|
"portable": "node scripts/portable.mjs",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@dnd-kit/core": "^6.1.0",
|
||||||
|
"@dnd-kit/sortable": "^8.0.0",
|
||||||
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@emotion/react": "^11.11.1",
|
"@emotion/react": "^11.11.1",
|
||||||
"@emotion/styled": "^11.11.0",
|
"@emotion/styled": "^11.11.0",
|
||||||
"@juggle/resize-observer": "^3.4.0",
|
"@juggle/resize-observer": "^3.4.0",
|
||||||
"@mui/icons-material": "^5.14.14",
|
"@mui/icons-material": "^5.14.19",
|
||||||
"@mui/lab": "5.0.0-alpha.149",
|
"@mui/lab": "5.0.0-alpha.149",
|
||||||
"@mui/material": "^5.14.14",
|
"@mui/material": "^5.14.19",
|
||||||
"@mui/x-data-grid": "^6.16.3",
|
"@mui/x-data-grid": "^6.18.2",
|
||||||
"@tauri-apps/api": "^1.3.0",
|
"@tauri-apps/api": "^1.5.1",
|
||||||
"ahooks": "^3.7.2",
|
"ahooks": "^3.7.8",
|
||||||
"axios": "^1.1.3",
|
"axios": "^1.6.2",
|
||||||
"dayjs": "1.11.5",
|
"dayjs": "1.11.5",
|
||||||
"i18next": "^22.0.4",
|
"i18next": "^23.7.7",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"monaco-editor": "^0.34.1",
|
"monaco-editor": "^0.34.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-error-boundary": "^3.1.4",
|
"react-error-boundary": "^3.1.4",
|
||||||
"react-hook-form": "^7.39.5",
|
"react-hook-form": "^7.48.2",
|
||||||
"react-i18next": "^12.0.0",
|
"react-i18next": "^13.5.0",
|
||||||
"react-router-dom": "^6.4.3",
|
"react-router-dom": "^6.20.0",
|
||||||
"react-transition-group": "^4.4.5",
|
"react-transition-group": "^4.4.5",
|
||||||
"react-virtuoso": "^3.1.3",
|
"react-virtuoso": "^4.6.2",
|
||||||
"recoil": "^0.7.6",
|
"recoil": "^0.7.7",
|
||||||
"snarkdown": "^2.0.0",
|
"snarkdown": "^2.0.0",
|
||||||
"swr": "^1.3.0"
|
"swr": "^1.3.0",
|
||||||
|
"tar": "^6.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/github": "^5.0.3",
|
"@actions/github": "^5.1.1",
|
||||||
"@tauri-apps/cli": "^1.3.1",
|
"@tauri-apps/cli": "^1.5.6",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/js-cookie": "^3.0.2",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/lodash": "^4.14.180",
|
"@types/lodash": "^4.14.202",
|
||||||
"@types/lodash-es": "^4.17.7",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/react": "^18.2.37",
|
"@types/react": "^18.2.39",
|
||||||
"@types/react-dom": "^18.0.11",
|
"@types/react-dom": "^18.2.17",
|
||||||
"@types/react-transition-group": "^4.4.9",
|
"@types/react-transition-group": "^4.4.9",
|
||||||
"@vitejs/plugin-react": "^4.1.0",
|
"@vitejs/plugin-react": "^4.2.0",
|
||||||
"adm-zip": "^0.5.9",
|
"adm-zip": "^0.5.10",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^11.2.0",
|
||||||
"https-proxy-agent": "^5.0.1",
|
"https-proxy-agent": "^5.0.1",
|
||||||
"husky": "^7.0.0",
|
"husky": "^7.0.4",
|
||||||
"node-fetch": "^3.2.6",
|
"node-fetch": "^3.3.2",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.8.8",
|
||||||
"pretty-quick": "^3.1.3",
|
"pretty-quick": "^3.1.3",
|
||||||
"sass": "^1.54.0",
|
"sass": "^1.69.5",
|
||||||
"typescript": "^4.7.4",
|
"typescript": "^5.3.2",
|
||||||
"vite": "^4.5.0",
|
"vite": "^4.5.0",
|
||||||
"vite-plugin-monaco-editor": "^1.1.0",
|
"vite-plugin-monaco-editor": "^1.1.0",
|
||||||
"vite-plugin-svgr": "^4.1.0"
|
"vite-plugin-svgr": "^4.2.0"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
|
|||||||
@@ -0,0 +1,195 @@
|
|||||||
|
From 8b085aea2f11e64f433244eda092c178a2bb50bc 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 4c6dde5..5fd9ad8 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.29"
|
||||||
|
-rquickjs = "0.3" # 高版本不支持 Linux aarch64
|
||||||
|
serde_json = "1.0"
|
||||||
|
serde_yaml = "0.9"
|
||||||
|
auto-launch = "0.5"
|
||||||
|
@@ -34,6 +33,7 @@ port_scanner = "0.1.5"
|
||||||
|
delay_timer = "0.11"
|
||||||
|
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 6c207d9..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");
|
||||||
|
- }
|
||||||
|
- return Ok(serde_json::from_str::<Mapping>(result.as_str())?);
|
||||||
|
- });
|
||||||
|
-
|
||||||
|
- let mut out = outputs.lock().unwrap();
|
||||||
|
- match result {
|
||||||
|
- Ok(config) => Ok((use_lowercase(config), out.to_vec())),
|
||||||
|
- Err(err) => {
|
||||||
|
- out.push(("exception".into(), err.to_string()));
|
||||||
|
- Ok((config, out.to_vec()))
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+
|
||||||
|
+ 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
|
||||||
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
/**
|
|
||||||
* Build and upload assets
|
|
||||||
* for macOS(aarch)
|
|
||||||
*/
|
|
||||||
import fs from "fs-extra";
|
|
||||||
import path from "path";
|
|
||||||
import { exit } from "process";
|
|
||||||
import { execSync } from "child_process";
|
|
||||||
import { createRequire } from "module";
|
|
||||||
import { getOctokit, context } from "@actions/github";
|
|
||||||
|
|
||||||
// to `meta` tag
|
|
||||||
const META = process.argv.includes("--meta");
|
|
||||||
// to `alpha` tag
|
|
||||||
const ALPHA = process.argv.includes("--alpha");
|
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
|
|
||||||
async function resolve() {
|
|
||||||
if (!process.env.GITHUB_TOKEN) {
|
|
||||||
throw new Error("GITHUB_TOKEN is required");
|
|
||||||
}
|
|
||||||
if (!process.env.GITHUB_REPOSITORY) {
|
|
||||||
throw new Error("GITHUB_REPOSITORY is required");
|
|
||||||
}
|
|
||||||
if (!process.env.TAURI_PRIVATE_KEY) {
|
|
||||||
throw new Error("TAURI_PRIVATE_KEY is required");
|
|
||||||
}
|
|
||||||
if (!process.env.TAURI_KEY_PASSWORD) {
|
|
||||||
throw new Error("TAURI_KEY_PASSWORD is required");
|
|
||||||
}
|
|
||||||
|
|
||||||
const { version } = require("../package.json");
|
|
||||||
|
|
||||||
const tag = META ? "meta" : ALPHA ? "alpha" : `v${version}`;
|
|
||||||
const buildCmd = META ? `pnpm build -f default-meta` : `pnpm build`;
|
|
||||||
|
|
||||||
console.log(`[INFO]: Upload to tag "${tag}"`);
|
|
||||||
console.log(`[INFO]: Building app. "${buildCmd}"`);
|
|
||||||
|
|
||||||
execSync(buildCmd);
|
|
||||||
|
|
||||||
const cwd = process.cwd();
|
|
||||||
const bundlePath = path.join(cwd, "src-tauri/target/release/bundle");
|
|
||||||
const join = (p) => path.join(bundlePath, p);
|
|
||||||
|
|
||||||
const appPathList = [
|
|
||||||
join("macos/Clash Nyanpasu.aarch64.app.tar.gz"),
|
|
||||||
join("macos/Clash Nyanpasu.aarch64.app.tar.gz.sig"),
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const appPath of appPathList) {
|
|
||||||
if (fs.pathExistsSync(appPath)) {
|
|
||||||
fs.removeSync(appPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.copyFileSync(join("macos/Clash Nyanpasu.app.tar.gz"), appPathList[0]);
|
|
||||||
fs.copyFileSync(join("macos/Clash Nyanpasu.app.tar.gz.sig"), appPathList[1]);
|
|
||||||
|
|
||||||
const options = { owner: context.repo.owner, repo: context.repo.repo };
|
|
||||||
const github = getOctokit(process.env.GITHUB_TOKEN);
|
|
||||||
|
|
||||||
const { data: release } = await github.rest.repos.getReleaseByTag({
|
|
||||||
...options,
|
|
||||||
tag,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!release.id) throw new Error("failed to find the release");
|
|
||||||
|
|
||||||
await uploadAssets(release.id, [
|
|
||||||
join(`dmg/Clash Nyanpasu_${version}_aarch64.dmg`),
|
|
||||||
...appPathList,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// From tauri-apps/tauri-action
|
|
||||||
// https://github.com/tauri-apps/tauri-action/blob/dev/packages/action/src/upload-release-assets.ts
|
|
||||||
async function uploadAssets(releaseId, assets) {
|
|
||||||
const github = getOctokit(process.env.GITHUB_TOKEN);
|
|
||||||
|
|
||||||
// Determine content-length for header to upload asset
|
|
||||||
const contentLength = (filePath) => fs.statSync(filePath).size;
|
|
||||||
|
|
||||||
for (const assetPath of assets) {
|
|
||||||
const headers = {
|
|
||||||
"content-type": "application/zip",
|
|
||||||
"content-length": contentLength(assetPath),
|
|
||||||
};
|
|
||||||
|
|
||||||
const ext = path.extname(assetPath);
|
|
||||||
const filename = path.basename(assetPath).replace(ext, "");
|
|
||||||
const assetName = path.dirname(assetPath).includes(`target${path.sep}debug`)
|
|
||||||
? `${filename}-debug${ext}`
|
|
||||||
: `${filename}${ext}`;
|
|
||||||
|
|
||||||
console.log(`[INFO]: Uploading ${assetName}...`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await github.rest.repos.uploadReleaseAsset({
|
|
||||||
headers,
|
|
||||||
name: assetName,
|
|
||||||
data: fs.readFileSync(assetPath),
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
release_id: releaseId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.platform === "darwin" && process.arch === "arm64") {
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
console.error("invalid");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import zlib from "zlib";
|
import zlib from "zlib";
|
||||||
|
import tar from "tar";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import AdmZip from "adm-zip";
|
import AdmZip from "adm-zip";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
@@ -10,103 +11,118 @@ const cwd = process.cwd();
|
|||||||
const TEMP_DIR = path.join(cwd, "node_modules/.verge");
|
const TEMP_DIR = path.join(cwd, "node_modules/.verge");
|
||||||
const FORCE = process.argv.includes("--force");
|
const FORCE = process.argv.includes("--force");
|
||||||
|
|
||||||
const SIDECAR_HOST = execSync("rustc -vV")
|
const PLATFORM_MAP = {
|
||||||
.toString()
|
"x86_64-pc-windows-msvc": "win32",
|
||||||
.match(/(?<=host: ).+(?=\s*)/g)[0];
|
"i686-pc-windows-msvc": "win32",
|
||||||
|
"aarch64-pc-windows-msvc": "win32",
|
||||||
/* ======= clash ======= */
|
"x86_64-apple-darwin": "darwin",
|
||||||
const CLASH_STORAGE_PREFIX = "https://release.dreamacro.workers.dev/";
|
"aarch64-apple-darwin": "darwin",
|
||||||
const CLASH_URL_PREFIX =
|
"x86_64-unknown-linux-gnu": "linux",
|
||||||
"https://github.com/Dreamacro/clash/releases/download/premium/";
|
"i686-unknown-linux-gnu": "linux",
|
||||||
const CLASH_LATEST_DATE = "2023.08.17";
|
"aarch64-unknown-linux-gnu": "linux",
|
||||||
|
"armv7-unknown-linux-gnueabihf": "linux",
|
||||||
const CLASH_BACKUP_URL_PREFIX =
|
};
|
||||||
"https://github.com/zhongfly/Clash-premium-backup/releases/download/";
|
const ARCH_MAP = {
|
||||||
const CLASH_BACKUP_LATEST_DATE = "2023-09-05-gdcc8d87";
|
"x86_64-pc-windows-msvc": "x64",
|
||||||
|
"i686-pc-windows-msvc": "ia32",
|
||||||
//https://github.com/zhongfly/Clash-premium-backup/releases/download/2023-09-05-gdcc8d87/clash-windows-amd64-2023-09-05-gdcc8d87.zip
|
"aarch64-pc-windows-msvc": "arm64",
|
||||||
//https://github.com/zhongfly/Clash-premium-backup/releases/download/2023-09-05-gdcc8d87/clash-windows-amd64-n2023-09-05-gdcc8d87.zip
|
"x86_64-apple-darwin": "x64",
|
||||||
|
"aarch64-apple-darwin": "arm64",
|
||||||
const CLASH_MAP = {
|
"x86_64-unknown-linux-gnu": "x64",
|
||||||
"win32-x64": "clash-windows-amd64",
|
"i686-unknown-linux-gnu": "ia32",
|
||||||
"darwin-x64": "clash-darwin-amd64",
|
"aarch64-unknown-linux-gnu": "arm64",
|
||||||
"darwin-arm64": "clash-darwin-arm64",
|
"armv7-unknown-linux-gnueabihf": "arm",
|
||||||
"linux-x64": "clash-linux-amd64",
|
|
||||||
"linux-arm64": "clash-linux-arm64",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ======= clash meta ======= */
|
const arg1 = process.argv.slice(2)[0];
|
||||||
const META_URL_PREFIX = `https://github.com/MetaCubeX/Clash.Meta/releases/download/`;
|
const arg2 = process.argv.slice(2)[1];
|
||||||
const META_VERSION = "v1.16.0";
|
const target = arg1 === "--force" ? arg2 : arg1;
|
||||||
|
const { platform, arch } = target
|
||||||
|
? { platform: PLATFORM_MAP[target], arch: ARCH_MAP[target] }
|
||||||
|
: process;
|
||||||
|
|
||||||
|
const SIDECAR_HOST = target
|
||||||
|
? target
|
||||||
|
: execSync("rustc -vV")
|
||||||
|
.toString()
|
||||||
|
.match(/(?<=host: ).+(?=\s*)/g)[0];
|
||||||
|
|
||||||
|
/* ======= clash meta alpha======= */
|
||||||
|
const VERSION_URL =
|
||||||
|
"https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/version.txt";
|
||||||
|
const META_ALPHA_URL_PREFIX = `https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha`;
|
||||||
|
let META_ALPHA_VERSION;
|
||||||
|
|
||||||
|
const META_ALPHA_MAP = {
|
||||||
|
"win32-x64": "mihomo-windows-amd64-compatible",
|
||||||
|
"win32-ia32": "mihomo-windows-386",
|
||||||
|
"win32-arm64": "mihomo-windows-arm64",
|
||||||
|
"darwin-x64": "mihomo-darwin-amd64",
|
||||||
|
"darwin-arm64": "mihomo-darwin-arm64",
|
||||||
|
"linux-x64": "mihomo-linux-amd64-compatible",
|
||||||
|
"linux-ia32": "mihomo-linux-386",
|
||||||
|
"linux-arm64": "mihomo-linux-arm64",
|
||||||
|
"linux-arm": "mihomo-linux-armv7",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fetch the latest release version from the version.txt file
|
||||||
|
async function getLatestVersion() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(VERSION_URL, { method: "GET" });
|
||||||
|
let v = await response.text();
|
||||||
|
META_ALPHA_VERSION = v.trim(); // Trim to remove extra whitespaces
|
||||||
|
console.log(`Latest release version: ${META_ALPHA_VERSION}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching latest release version:", error.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ======= clash meta stable ======= */
|
||||||
|
const META_URL_PREFIX = `https://github.com/MetaCubeX/mihomo/releases/download`;
|
||||||
|
let META_VERSION = "v1.17.0";
|
||||||
|
|
||||||
const META_MAP = {
|
const META_MAP = {
|
||||||
"win32-x64": "clash.meta-windows-amd64-compatible",
|
"win32-x64": "mihomo-windows-amd64-compatible",
|
||||||
"darwin-x64": "clash.meta-darwin-amd64",
|
"win32-ia32": "mihomo-windows-386",
|
||||||
"darwin-arm64": "clash.meta-darwin-arm64",
|
"win32-arm64": "mihomo-windows-arm64",
|
||||||
"linux-x64": "clash.meta-linux-amd64-compatible",
|
"darwin-x64": "mihomo-darwin-amd64",
|
||||||
"linux-arm64": "clash.meta-linux-arm64",
|
"darwin-arm64": "mihomo-darwin-arm64",
|
||||||
|
"linux-x64": "mihomo-linux-amd64-compatible",
|
||||||
|
"linux-ia32": "mihomo-linux-386",
|
||||||
|
"linux-arm64": "mihomo-linux-arm64",
|
||||||
|
"linux-arm": "mihomo-linux-armv7",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* check available
|
* check available
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { platform, arch } = process;
|
|
||||||
if (!CLASH_MAP[`${platform}-${arch}`]) {
|
|
||||||
throw new Error(`clash unsupported platform "${platform}-${arch}"`);
|
|
||||||
}
|
|
||||||
if (!META_MAP[`${platform}-${arch}`]) {
|
if (!META_MAP[`${platform}-${arch}`]) {
|
||||||
throw new Error(`clash meta unsupported platform "${platform}-${arch}"`);
|
throw new Error(
|
||||||
|
`clash meta alpha unsupported platform "${platform}-${arch}"`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clash() {
|
if (!META_ALPHA_MAP[`${platform}-${arch}`]) {
|
||||||
const name = CLASH_MAP[`${platform}-${arch}`];
|
throw new Error(
|
||||||
|
`clash meta alpha unsupported platform "${platform}-${arch}"`
|
||||||
const isWin = platform === "win32";
|
);
|
||||||
const urlExt = isWin ? "zip" : "gz";
|
|
||||||
const downloadURL = `${CLASH_URL_PREFIX}${name}-${CLASH_LATEST_DATE}.${urlExt}`;
|
|
||||||
const exeFile = `${name}${isWin ? ".exe" : ""}`;
|
|
||||||
const zipFile = `${name}.${urlExt}`;
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: "clash",
|
|
||||||
targetFile: `clash-${SIDECAR_HOST}${isWin ? ".exe" : ""}`,
|
|
||||||
exeFile,
|
|
||||||
zipFile,
|
|
||||||
downloadURL,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clashBackup() {
|
/**
|
||||||
const name = CLASH_MAP[`${platform}-${arch}`];
|
* core info
|
||||||
|
*/
|
||||||
|
function clashMetaAlpha() {
|
||||||
|
const name = META_ALPHA_MAP[`${platform}-${arch}`];
|
||||||
const isWin = platform === "win32";
|
const isWin = platform === "win32";
|
||||||
const urlExt = isWin ? "zip" : "gz";
|
const urlExt = isWin ? "zip" : "gz";
|
||||||
const downloadURL = `${CLASH_BACKUP_URL_PREFIX}${CLASH_BACKUP_LATEST_DATE}/${name}-n${CLASH_BACKUP_LATEST_DATE}.${urlExt}`;
|
const downloadURL = `${META_ALPHA_URL_PREFIX}/${name}-${META_ALPHA_VERSION}.${urlExt}`;
|
||||||
const exeFile = `${name}${isWin ? ".exe" : ""}`;
|
const exeFile = `${name}${isWin ? ".exe" : ""}`;
|
||||||
const zipFile = `${name}.${urlExt}`;
|
const zipFile = `${name}-${META_ALPHA_VERSION}.${urlExt}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "clash",
|
name: "clash-meta-alpha",
|
||||||
targetFile: `clash-${SIDECAR_HOST}${isWin ? ".exe" : ""}`,
|
targetFile: `clash-meta-alpha-${SIDECAR_HOST}${isWin ? ".exe" : ""}`,
|
||||||
exeFile,
|
|
||||||
zipFile,
|
|
||||||
downloadURL,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function clashS3() {
|
|
||||||
const name = CLASH_MAP[`${platform}-${arch}`];
|
|
||||||
|
|
||||||
const isWin = platform === "win32";
|
|
||||||
const urlExt = isWin ? "zip" : "gz";
|
|
||||||
const downloadURL = `${CLASH_STORAGE_PREFIX}${CLASH_LATEST_DATE}/${name}-${CLASH_LATEST_DATE}.${urlExt}`;
|
|
||||||
const exeFile = `${name}${isWin ? ".exe" : ""}`;
|
|
||||||
const zipFile = `${name}.${urlExt}`;
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: "clash",
|
|
||||||
targetFile: `clash-${SIDECAR_HOST}${isWin ? ".exe" : ""}`,
|
|
||||||
exeFile,
|
exeFile,
|
||||||
zipFile,
|
zipFile,
|
||||||
downloadURL,
|
downloadURL,
|
||||||
@@ -117,7 +133,7 @@ function clashMeta() {
|
|||||||
const name = META_MAP[`${platform}-${arch}`];
|
const name = META_MAP[`${platform}-${arch}`];
|
||||||
const isWin = platform === "win32";
|
const isWin = platform === "win32";
|
||||||
const urlExt = isWin ? "zip" : "gz";
|
const urlExt = isWin ? "zip" : "gz";
|
||||||
const downloadURL = `${META_URL_PREFIX}${META_VERSION}/${name}-${META_VERSION}.${urlExt}`;
|
const downloadURL = `${META_URL_PREFIX}/${META_VERSION}/${name}-${META_VERSION}.${urlExt}`;
|
||||||
const exeFile = `${name}${isWin ? ".exe" : ""}`;
|
const exeFile = `${name}${isWin ? ".exe" : ""}`;
|
||||||
const zipFile = `${name}-${META_VERSION}.${urlExt}`;
|
const zipFile = `${name}-${META_VERSION}.${urlExt}`;
|
||||||
|
|
||||||
@@ -129,7 +145,6 @@ function clashMeta() {
|
|||||||
downloadURL,
|
downloadURL,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* download sidecar and rename
|
* download sidecar and rename
|
||||||
*/
|
*/
|
||||||
@@ -160,6 +175,26 @@ async function resolveSidecar(binInfo) {
|
|||||||
zip.extractAllTo(tempDir, true);
|
zip.extractAllTo(tempDir, true);
|
||||||
await fs.rename(tempExe, sidecarPath);
|
await fs.rename(tempExe, sidecarPath);
|
||||||
console.log(`[INFO]: "${name}" unzip finished`);
|
console.log(`[INFO]: "${name}" unzip finished`);
|
||||||
|
} else if (zipFile.endsWith(".tgz")) {
|
||||||
|
// tgz
|
||||||
|
await fs.mkdirp(tempDir);
|
||||||
|
await tar.extract({
|
||||||
|
cwd: tempDir,
|
||||||
|
file: tempZip,
|
||||||
|
//strip: 1, // 可能需要根据实际的 .tgz 文件结构调整
|
||||||
|
});
|
||||||
|
const files = await fs.readdir(tempDir);
|
||||||
|
console.log(`[DEBUG]: "${name}" files in tempDir:`, files);
|
||||||
|
const extractedFile = files.find((file) => file.startsWith("虚空终端-"));
|
||||||
|
if (extractedFile) {
|
||||||
|
const extractedFilePath = path.join(tempDir, extractedFile);
|
||||||
|
await fs.rename(extractedFilePath, sidecarPath);
|
||||||
|
console.log(`[INFO]: "${name}" file renamed to "${sidecarPath}"`);
|
||||||
|
execSync(`chmod 755 ${sidecarPath}`);
|
||||||
|
console.log(`[INFO]: "${name}" chmod binary finished`);
|
||||||
|
} else {
|
||||||
|
throw new Error(`Expected file not found in ${tempDir}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// gz
|
// gz
|
||||||
const readStream = fs.createReadStream(tempZip);
|
const readStream = fs.createReadStream(tempZip);
|
||||||
@@ -191,58 +226,6 @@ async function resolveSidecar(binInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* prepare clash core
|
|
||||||
* if the core version is not updated in time, use S3 storage as a backup.
|
|
||||||
*/
|
|
||||||
async function resolveClash() {
|
|
||||||
try {
|
|
||||||
return await resolveSidecar(clash());
|
|
||||||
} catch {
|
|
||||||
console.log(`[WARN]: clash core needs to be updated`);
|
|
||||||
return await resolveSidecar(clashS3());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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(TEMP_DIR, "wintun");
|
|
||||||
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}"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await fs.rename(wintunPath, targetPath);
|
|
||||||
await fs.remove(tempDir);
|
|
||||||
|
|
||||||
console.log(`[INFO]: resolve wintun.dll finished`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* download the file to the resources dir
|
* download the file to the resources dir
|
||||||
*/
|
*/
|
||||||
@@ -323,17 +306,37 @@ const resolveGeoIP = () =>
|
|||||||
file: "geoip.dat",
|
file: "geoip.dat",
|
||||||
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat`,
|
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat`,
|
||||||
});
|
});
|
||||||
|
const resolveEnableLoopback = () =>
|
||||||
|
resolveResource({
|
||||||
|
file: "enableLoopback.exe",
|
||||||
|
downloadURL: `https://github.com/Kuingsmile/uwp-tool/releases/download/latest/enableLoopback.exe`,
|
||||||
|
});
|
||||||
|
|
||||||
const tasks = [
|
const tasks = [
|
||||||
{ name: "clash", func: () => resolveSidecar(clashBackup()), retry: 5 },
|
// { name: "clash", func: resolveClash, retry: 5 },
|
||||||
{ name: "clash-meta", func: () => resolveSidecar(clashMeta()), retry: 5 },
|
{
|
||||||
{ name: "wintun", func: resolveWintun, retry: 5, winOnly: true },
|
name: "clash-meta-alpha",
|
||||||
|
func: () => getLatestVersion().then(() => resolveSidecar(clashMetaAlpha())),
|
||||||
|
retry: 5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "clash-meta",
|
||||||
|
func: () => resolveSidecar(clashMeta()),
|
||||||
|
retry: 5,
|
||||||
|
},
|
||||||
|
// { name: "wintun", func: resolveWintun, retry: 5, winOnly: true },
|
||||||
{ 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: "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 },
|
||||||
|
{
|
||||||
|
name: "enableLoopback",
|
||||||
|
func: resolveEnableLoopback,
|
||||||
|
retry: 5,
|
||||||
|
winOnly: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
async function runTask() {
|
async function runTask() {
|
||||||
|
|||||||
@@ -4,29 +4,44 @@ import AdmZip from "adm-zip";
|
|||||||
import { createRequire } from "module";
|
import { createRequire } from "module";
|
||||||
import { getOctokit, context } from "@actions/github";
|
import { getOctokit, context } from "@actions/github";
|
||||||
|
|
||||||
|
const target = process.argv.slice(2)[0];
|
||||||
|
|
||||||
|
const ARCH_MAP = {
|
||||||
|
"i686-pc-windows-msvc": "x86",
|
||||||
|
"x86_64-pc-windows-msvc": "x64",
|
||||||
|
"aarch64-pc-windows-msvc": "arm64",
|
||||||
|
};
|
||||||
|
|
||||||
/// Script for ci
|
/// Script for ci
|
||||||
/// 打包绿色版/便携版 (only Windows)
|
/// 打包绿色版/便携版 (only Windows)
|
||||||
async function resolvePortable() {
|
async function resolvePortable() {
|
||||||
if (process.platform !== "win32") return;
|
if (process.platform !== "win32") return;
|
||||||
|
|
||||||
const releaseDir = "./src-tauri/target/release";
|
const releaseDir = target
|
||||||
|
? `./src-tauri/target/${target}/release`
|
||||||
|
: `./src-tauri/target/release`;
|
||||||
|
const configDir = path.join(releaseDir, ".config");
|
||||||
|
|
||||||
if (!(await fs.pathExists(releaseDir))) {
|
if (!(await fs.pathExists(releaseDir))) {
|
||||||
throw new Error("could not found the release dir");
|
throw new Error("could not found the release dir");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await fs.mkdir(configDir);
|
||||||
|
await fs.createFile(path.join(configDir, "PORTABLE"));
|
||||||
|
|
||||||
const zip = new AdmZip();
|
const zip = new AdmZip();
|
||||||
|
|
||||||
zip.addLocalFile(path.join(releaseDir, "Clash Nyanpasu.exe"));
|
zip.addLocalFile(path.join(releaseDir, "Clash Verge.exe"));
|
||||||
zip.addLocalFile(path.join(releaseDir, "clash.exe"));
|
|
||||||
zip.addLocalFile(path.join(releaseDir, "clash-meta.exe"));
|
zip.addLocalFile(path.join(releaseDir, "clash-meta.exe"));
|
||||||
|
zip.addLocalFile(path.join(releaseDir, "clash-meta-alpha.exe"));
|
||||||
zip.addLocalFolder(path.join(releaseDir, "resources"), "resources");
|
zip.addLocalFolder(path.join(releaseDir, "resources"), "resources");
|
||||||
|
zip.addLocalFolder(configDir, ".config");
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
const packageJson = require("../package.json");
|
const packageJson = require("../package.json");
|
||||||
const { version } = packageJson;
|
const { version } = packageJson;
|
||||||
|
|
||||||
const zipFile = `Clash.Nyanpasu_${version}_x64_portable.zip`;
|
const zipFile = `Clash.Verge_${version}_${ARCH_MAP[target]}_portable.zip`;
|
||||||
zip.writeZip(zipFile);
|
zip.writeZip(zipFile);
|
||||||
|
|
||||||
console.log("[INFO]: create portable zip successfully");
|
console.log("[INFO]: create portable zip successfully");
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
import fs from "fs-extra";
|
|
||||||
import { createRequire } from "module";
|
|
||||||
import { execSync } from "child_process";
|
|
||||||
import { resolveUpdateLog } from "./updatelog.mjs";
|
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
|
|
||||||
// publish
|
|
||||||
async function resolvePublish() {
|
|
||||||
const flag = process.argv[2] ?? "patch";
|
|
||||||
const packageJson = require("../package.json");
|
|
||||||
const tauriJson = require("../src-tauri/tauri.conf.json");
|
|
||||||
|
|
||||||
let [a, b, c] = packageJson.version.split(".").map(Number);
|
|
||||||
|
|
||||||
if (flag === "major") {
|
|
||||||
a += 1;
|
|
||||||
b = 0;
|
|
||||||
c = 0;
|
|
||||||
} else if (flag === "minor") {
|
|
||||||
b += 1;
|
|
||||||
c = 0;
|
|
||||||
} else if (flag === "patch") {
|
|
||||||
c += 1;
|
|
||||||
} else throw new Error(`invalid flag "${flag}"`);
|
|
||||||
|
|
||||||
const nextVersion = `${a}.${b}.${c}`;
|
|
||||||
packageJson.version = nextVersion;
|
|
||||||
tauriJson.package.version = nextVersion;
|
|
||||||
|
|
||||||
// 发布更新前先写更新日志
|
|
||||||
const nextTag = `v${nextVersion}`;
|
|
||||||
await resolveUpdateLog(nextTag);
|
|
||||||
|
|
||||||
await fs.writeFile(
|
|
||||||
"./package.json",
|
|
||||||
JSON.stringify(packageJson, undefined, 2)
|
|
||||||
);
|
|
||||||
await fs.writeFile(
|
|
||||||
"./src-tauri/tauri.conf.json",
|
|
||||||
JSON.stringify(tauriJson, undefined, 2)
|
|
||||||
);
|
|
||||||
|
|
||||||
execSync("git add ./package.json");
|
|
||||||
execSync("git add ./src-tauri/tauri.conf.json");
|
|
||||||
execSync(`git commit -m "v${nextVersion}"`);
|
|
||||||
execSync(`git tag -a v${nextVersion} -m "v${nextVersion}"`);
|
|
||||||
execSync(`git push`);
|
|
||||||
execSync(`git push origin v${nextVersion}`);
|
|
||||||
console.log(`Publish Successfully...`);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolvePublish();
|
|
||||||
@@ -45,8 +45,12 @@ async function resolveUpdater() {
|
|||||||
"darwin-intel": { signature: "", url: "" },
|
"darwin-intel": { signature: "", url: "" },
|
||||||
"darwin-x86_64": { signature: "", url: "" },
|
"darwin-x86_64": { signature: "", url: "" },
|
||||||
"linux-x86_64": { signature: "", url: "" },
|
"linux-x86_64": { signature: "", url: "" },
|
||||||
|
"linux-i686": { signature: "", url: "" },
|
||||||
|
"linux-aarch64": { signature: "", url: "" },
|
||||||
|
"linux-armv7": { signature: "", url: "" },
|
||||||
"windows-x86_64": { signature: "", url: "" },
|
"windows-x86_64": { signature: "", url: "" },
|
||||||
"windows-i686": { signature: "", url: "" }, // no supported
|
"windows-i686": { signature: "", url: "" },
|
||||||
|
"windows-aarch64": { signature: "", url: "" },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,17 +58,37 @@ async function resolveUpdater() {
|
|||||||
const { name, browser_download_url } = asset;
|
const { name, browser_download_url } = asset;
|
||||||
|
|
||||||
// win64 url
|
// win64 url
|
||||||
if (name.endsWith(".msi.zip") && name.includes("en-US")) {
|
if (name.endsWith("x64-setup.nsis.zip")) {
|
||||||
updateData.platforms.win64.url = browser_download_url;
|
updateData.platforms.win64.url = browser_download_url;
|
||||||
updateData.platforms["windows-x86_64"].url = browser_download_url;
|
updateData.platforms["windows-x86_64"].url = browser_download_url;
|
||||||
}
|
}
|
||||||
// win64 signature
|
// win64 signature
|
||||||
if (name.endsWith(".msi.zip.sig") && name.includes("en-US")) {
|
if (name.endsWith("x64-setup.nsis.zip.sig")) {
|
||||||
const sig = await getSignature(browser_download_url);
|
const sig = await getSignature(browser_download_url);
|
||||||
updateData.platforms.win64.signature = sig;
|
updateData.platforms.win64.signature = sig;
|
||||||
updateData.platforms["windows-x86_64"].signature = sig;
|
updateData.platforms["windows-x86_64"].signature = sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// win32 url
|
||||||
|
if (name.endsWith("x86-setup.nsis.zip")) {
|
||||||
|
updateData.platforms["windows-i686"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// win32 signature
|
||||||
|
if (name.endsWith("x86-setup.nsis.zip.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms["windows-i686"].signature = sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
// win arm url
|
||||||
|
if (name.endsWith("arm64-setup.nsis.zip")) {
|
||||||
|
updateData.platforms["windows-aarch64"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// win arm signature
|
||||||
|
if (name.endsWith("arm64-setup.nsis.zip.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms["windows-aarch64"].signature = sig;
|
||||||
|
}
|
||||||
|
|
||||||
// darwin url (intel)
|
// darwin url (intel)
|
||||||
if (name.endsWith(".app.tar.gz") && !name.includes("aarch")) {
|
if (name.endsWith(".app.tar.gz") && !name.includes("aarch")) {
|
||||||
updateData.platforms.darwin.url = browser_download_url;
|
updateData.platforms.darwin.url = browser_download_url;
|
||||||
@@ -89,16 +113,32 @@ async function resolveUpdater() {
|
|||||||
updateData.platforms["darwin-aarch64"].signature = sig;
|
updateData.platforms["darwin-aarch64"].signature = sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// linux url
|
// linux x64 url
|
||||||
if (name.endsWith(".AppImage.tar.gz")) {
|
if (name.endsWith("amd64.AppImage.tar.gz")) {
|
||||||
updateData.platforms.linux.url = browser_download_url;
|
updateData.platforms.linux.url = browser_download_url;
|
||||||
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
||||||
|
// 暂时使用x64版本的url和sig,使得可以检查更新,但aarch64版本还不支持构建appimage
|
||||||
|
updateData.platforms["linux-aarch64"].url = browser_download_url;
|
||||||
|
updateData.platforms["linux-armv7"].url = browser_download_url;
|
||||||
}
|
}
|
||||||
// linux signature
|
// linux x64 signature
|
||||||
if (name.endsWith(".AppImage.tar.gz.sig")) {
|
if (name.endsWith("amd64.AppImage.tar.gz.sig")) {
|
||||||
const sig = await getSignature(browser_download_url);
|
const sig = await getSignature(browser_download_url);
|
||||||
updateData.platforms.linux.signature = sig;
|
updateData.platforms.linux.signature = sig;
|
||||||
updateData.platforms["linux-x86_64"].signature = sig;
|
updateData.platforms["linux-x86_64"].signature = sig;
|
||||||
|
// 暂时使用x64版本的url和sig,使得可以检查更新,但aarch64版本还不支持构建appimage
|
||||||
|
updateData.platforms["linux-aarch64"].signature = sig;
|
||||||
|
updateData.platforms["linux-armv7"].signature = sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
// linux x86 url
|
||||||
|
if (name.endsWith("i386.AppImage.tar.gz")) {
|
||||||
|
updateData.platforms["linux-i686"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// linux x86 signature
|
||||||
|
if (name.endsWith("i386.AppImage.tar.gz.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms["linux-i686"].signature = sig;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -120,7 +160,8 @@ async function resolveUpdater() {
|
|||||||
|
|
||||||
Object.entries(updateDataNew.platforms).forEach(([key, value]) => {
|
Object.entries(updateDataNew.platforms).forEach(([key, value]) => {
|
||||||
if (value.url) {
|
if (value.url) {
|
||||||
updateDataNew.platforms[key].url = "https://ghproxy.com/" + value.url;
|
updateDataNew.platforms[key].url =
|
||||||
|
"https://mirror.ghproxy.com/" + value.url;
|
||||||
} else {
|
} else {
|
||||||
console.log(`[Error]: updateDataNew.platforms.${key} is null`);
|
console.log(`[Error]: updateDataNew.platforms.${key} is null`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "clash-verge"
|
name = "clash-verge"
|
||||||
version = "0.1.0"
|
version = "1.4.4"
|
||||||
description = "clash verge"
|
description = "clash verge"
|
||||||
authors = ["zzzgydi"]
|
authors = ["zzzgydi", "wonfen", "MystiPanda"]
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
repository = "https://github.com/keiko233/clash-nyanpasu.git"
|
repository = "https://github.com/clash-verge-rev/clash-verge-rev.git"
|
||||||
default-run = "clash-verge"
|
default-run = "clash-verge"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
@@ -14,53 +14,46 @@ tauri-build = { version = "1", features = [] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
warp = "0.3"
|
warp = "0.3"
|
||||||
which = "4.2.2"
|
which = "5.0.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
dirs = "5.0.0"
|
dirs = "5.0"
|
||||||
open = "4.0.1"
|
open = "5.0"
|
||||||
log = "0.4.14"
|
log = "0.4"
|
||||||
ctrlc = "3.2.3"
|
ctrlc = "3.4"
|
||||||
dunce = "1.0.2"
|
dunce = "1.0"
|
||||||
log4rs = "1.0.0"
|
log4rs = "1"
|
||||||
nanoid = "0.4.0"
|
nanoid = "0.4"
|
||||||
chrono = "0.4.19"
|
chrono = "0.4"
|
||||||
sysinfo = "0.29"
|
sysinfo = "0.29"
|
||||||
sysproxy = "0.3"
|
rquickjs = "0.3" # 高版本不支持 Linux aarch64
|
||||||
rquickjs = "0.1.7"
|
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_yaml = "0.9"
|
serde_yaml = "0.9"
|
||||||
auto-launch = "0.5"
|
auto-launch = "0.5"
|
||||||
once_cell = "1.14.0"
|
once_cell = "1.18"
|
||||||
port_scanner = "0.1.5"
|
port_scanner = "0.1.5"
|
||||||
delay_timer = "0.11.1"
|
delay_timer = "0.11"
|
||||||
parking_lot = "0.12.0"
|
parking_lot = "0.12"
|
||||||
|
percent-encoding = "2.3.1"
|
||||||
|
window-shadows = { version = "0.2" }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
tauri = { version = "1.2.4", features = ["global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
|
sysproxy = { git="https://github.com/zzzgydi/sysproxy-rs", branch = "main" }
|
||||||
window-vibrancy = { version = "0.3.0" }
|
tauri = { version = "1.5", features = ["icon-png", "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
|
||||||
window-shadows = { version = "0.2.0" }
|
|
||||||
wry = { version = "0.24.3" }
|
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
runas = "1.1.0"
|
runas = "=1.0.0" # 高版本会返回错误 Status
|
||||||
deelevate = "0.2.0"
|
deelevate = "0.2.0"
|
||||||
winreg = { version = "0.50", features = ["transactions"] }
|
winreg = { version = "0.52", features = ["transactions"] }
|
||||||
windows-sys = { version = "0.48", features = ["Win32_System_LibraryLoader", "Win32_System_SystemInformation"] }
|
windows-sys = { version = "0.52", features = ["Win32_System_LibraryLoader", "Win32_System_SystemInformation"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies.tauri]
|
|
||||||
features = ["global-shortcut-all", "icon-png", "process-all", "shell-all", "system-tray", "updater", "window-all"]
|
|
||||||
|
|
||||||
[target.'cfg(linux)'.dependencies.tauri]
|
|
||||||
features = ["global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all", "native-tls-vendored", "reqwest-native-tls-vendored"]
|
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
#openssl
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["custom-protocol"]
|
default = ["custom-protocol"]
|
||||||
custom-protocol = ["tauri/custom-protocol"]
|
custom-protocol = ["tauri/custom-protocol"]
|
||||||
verge-dev = []
|
verge-dev = []
|
||||||
default-meta = []
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -30,6 +30,11 @@ pub async fn import_profile(url: String, option: Option<PrfOption>) -> CmdResult
|
|||||||
wrap_err!(Config::profiles().data().append_item(item))
|
wrap_err!(Config::profiles().data().append_item(item))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn reorder_profile(active_id: String, over_id: String) -> CmdResult {
|
||||||
|
wrap_err!(Config::profiles().data().reorder(active_id, over_id))
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn create_profile(item: PrfItem, file_data: Option<String>) -> CmdResult {
|
pub async fn create_profile(item: PrfItem, file_data: Option<String>) -> CmdResult {
|
||||||
let item = wrap_err!(PrfItem::from(item, file_data).await)?;
|
let item = wrap_err!(PrfItem::from(item, file_data).await)?;
|
||||||
@@ -80,7 +85,7 @@ pub fn patch_profile(index: String, profile: PrfItem) -> CmdResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn view_profile(index: String) -> CmdResult {
|
pub fn view_profile(app_handle: tauri::AppHandle, index: String) -> CmdResult {
|
||||||
let file = {
|
let file = {
|
||||||
wrap_err!(Config::profiles().latest().get_item(&index))?
|
wrap_err!(Config::profiles().latest().get_item(&index))?
|
||||||
.file
|
.file
|
||||||
@@ -93,7 +98,7 @@ pub fn view_profile(index: String) -> CmdResult {
|
|||||||
ret_err!("the file not found");
|
ret_err!("the file not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap_err!(help::open_file(path))
|
wrap_err!(help::open_file(app_handle, path))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -229,6 +234,28 @@ pub fn open_web_url(url: String) -> CmdResult<()> {
|
|||||||
wrap_err!(open::that(url))
|
wrap_err!(open::that(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub mod uwp {
|
||||||
|
use super::*;
|
||||||
|
use crate::core::win_uwp;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn invoke_uwp_tool() -> CmdResult {
|
||||||
|
wrap_err!(win_uwp::invoke_uwptools().await)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn clash_api_get_proxy_delay(
|
||||||
|
name: String,
|
||||||
|
url: Option<String>,
|
||||||
|
) -> CmdResult<clash_api::DelayRes> {
|
||||||
|
match clash_api::get_proxy_delay(name, url).await {
|
||||||
|
Ok(res) => Ok(res),
|
||||||
|
Err(err) => Err(format!("{}", err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub mod service {
|
pub mod service {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -267,3 +294,13 @@ pub mod service {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
pub mod uwp {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn invoke_uwp_tool() -> CmdResult {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,17 +24,12 @@ impl IClashTemp {
|
|||||||
pub fn template() -> Self {
|
pub fn template() -> Self {
|
||||||
let mut map = Mapping::new();
|
let mut map = Mapping::new();
|
||||||
|
|
||||||
map.insert("mixed-port".into(), 7890.into());
|
map.insert("mixed-port".into(), 7897.into());
|
||||||
map.insert("log-level".into(), "info".into());
|
map.insert("log-level".into(), "info".into());
|
||||||
map.insert("allow-lan".into(), false.into());
|
map.insert("allow-lan".into(), false.into());
|
||||||
map.insert("mode".into(), "rule".into());
|
map.insert("mode".into(), "rule".into());
|
||||||
map.insert("external-controller".into(), "127.0.0.1:9090".into());
|
map.insert("external-controller".into(), "127.0.0.1:9097".into());
|
||||||
map.insert("secret".into(), "".into());
|
map.insert("secret".into(), "".into());
|
||||||
#[cfg(feature = "default-meta")]
|
|
||||||
map.insert("unified-delay".into(), true.into());
|
|
||||||
#[cfg(feature = "default-meta")]
|
|
||||||
map.insert("tcp-concurrent".into(), true.into());
|
|
||||||
map.insert("ipv6".into(), false.into());
|
|
||||||
|
|
||||||
Self(map)
|
Self(map)
|
||||||
}
|
}
|
||||||
@@ -58,7 +53,7 @@ impl IClashTemp {
|
|||||||
help::save_yaml(
|
help::save_yaml(
|
||||||
&dirs::clash_path()?,
|
&dirs::clash_path()?,
|
||||||
&self.0,
|
&self.0,
|
||||||
Some("# Generated by Clash Nyanpasu"),
|
Some("# Generated by Clash Verge"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,9 +84,9 @@ impl IClashTemp {
|
|||||||
Value::Number(val_num) => val_num.as_u64().map(|u| u as u16),
|
Value::Number(val_num) => val_num.as_u64().map(|u| u as u16),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.unwrap_or(7890);
|
.unwrap_or(7897);
|
||||||
if port == 0 {
|
if port == 0 {
|
||||||
port = 7890;
|
port = 7897;
|
||||||
}
|
}
|
||||||
port
|
port
|
||||||
}
|
}
|
||||||
@@ -114,7 +109,7 @@ impl IClashTemp {
|
|||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
})
|
})
|
||||||
.unwrap_or("127.0.0.1:9090".into())
|
.unwrap_or("127.0.0.1:9097".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn guard_client_ctrl(config: &Mapping) -> String {
|
pub fn guard_client_ctrl(config: &Mapping) -> String {
|
||||||
@@ -126,7 +121,7 @@ impl IClashTemp {
|
|||||||
}
|
}
|
||||||
socket.to_string()
|
socket.to_string()
|
||||||
}
|
}
|
||||||
Err(_) => "127.0.0.1:9090".into(),
|
Err(_) => "127.0.0.1:9097".into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,12 +156,12 @@ fn test_clash_info() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
IClashTemp(IClashTemp::guard(Mapping::new())).get_client_info(),
|
IClashTemp(IClashTemp::guard(Mapping::new())).get_client_info(),
|
||||||
get_result(7890, "127.0.0.1:9090")
|
get_result(7897, "127.0.0.1:9097")
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(get_case("", ""), get_result(7890, "127.0.0.1:9090"));
|
assert_eq!(get_case("", ""), get_result(7897, "127.0.0.1:9097"));
|
||||||
|
|
||||||
assert_eq!(get_case(65537, ""), get_result(1, "127.0.0.1:9090"));
|
assert_eq!(get_case(65537, ""), get_result(1, "127.0.0.1:9097"));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_case(8888, "127.0.0.1:8888"),
|
get_case(8888, "127.0.0.1:8888"),
|
||||||
@@ -175,7 +170,7 @@ fn test_clash_info() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_case(8888, " :98888 "),
|
get_case(8888, " :98888 "),
|
||||||
get_result(8888, "127.0.0.1:9090")
|
get_result(8888, "127.0.0.1:9097")
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -200,7 +195,7 @@ fn test_clash_info() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_case(8888, "192.168.1.1:80800"),
|
get_case(8888, "192.168.1.1:80800"),
|
||||||
get_result(8888, "127.0.0.1:9090")
|
get_result(8888, "127.0.0.1:9097")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ impl Config {
|
|||||||
Self::global().runtime_config.clone()
|
Self::global().runtime_config.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 初始化配置
|
/// 初始化订阅
|
||||||
pub fn init_config() -> Result<()> {
|
pub fn init_config() -> Result<()> {
|
||||||
crate::log_err!(Self::generate());
|
crate::log_err!(Self::generate());
|
||||||
if let Err(err) = Self::generate_file(ConfigType::Run) {
|
if let Err(err) = Self::generate_file(ConfigType::Run) {
|
||||||
@@ -57,14 +57,14 @@ impl Config {
|
|||||||
help::save_yaml(
|
help::save_yaml(
|
||||||
&runtime_path,
|
&runtime_path,
|
||||||
&Config::clash().latest().0,
|
&Config::clash().latest().0,
|
||||||
Some("# Clash Nyanpasu Runtime"),
|
Some("# Clash Verge Runtime"),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 将配置丢到对应的文件中
|
/// 将订阅丢到对应的文件中
|
||||||
pub fn generate_file(typ: ConfigType) -> Result<PathBuf> {
|
pub fn generate_file(typ: ConfigType) -> Result<PathBuf> {
|
||||||
let path = match typ {
|
let path = match typ {
|
||||||
ConfigType::Run => dirs::app_home_dir()?.join(RUNTIME_CONFIG),
|
ConfigType::Run => dirs::app_home_dir()?.join(RUNTIME_CONFIG),
|
||||||
@@ -78,11 +78,11 @@ impl Config {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or(anyhow!("failed to get runtime config"))?;
|
.ok_or(anyhow!("failed to get runtime config"))?;
|
||||||
|
|
||||||
help::save_yaml(&path, &config, Some("# Generated by Clash Nyanpasu"))?;
|
help::save_yaml(&path, &config, Some("# Generated by Clash Verge"))?;
|
||||||
Ok(path)
|
Ok(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 生成配置存好
|
/// 生成订阅存好
|
||||||
pub fn generate() -> Result<()> {
|
pub fn generate() -> Result<()> {
|
||||||
let (config, exists_keys, logs) = enhance::enhance();
|
let (config, exists_keys, logs) = enhance::enhance();
|
||||||
|
|
||||||
|
|||||||
@@ -190,11 +190,14 @@ impl PrfItem {
|
|||||||
let self_proxy = opt_ref.map_or(false, |o| o.self_proxy.unwrap_or(false));
|
let self_proxy = opt_ref.map_or(false, |o| o.self_proxy.unwrap_or(false));
|
||||||
let user_agent = opt_ref.map_or(None, |o| o.user_agent.clone());
|
let user_agent = opt_ref.map_or(None, |o| o.user_agent.clone());
|
||||||
|
|
||||||
let mut builder = reqwest::ClientBuilder::new().use_rustls_tls().no_proxy();
|
let mut builder = reqwest::ClientBuilder::new().no_proxy();
|
||||||
|
|
||||||
// 使用软件自己的代理
|
// 使用软件自己的代理
|
||||||
if self_proxy {
|
if self_proxy {
|
||||||
let port = Config::clash().data().get_mixed_port();
|
let port = Config::verge()
|
||||||
|
.latest()
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port());
|
||||||
|
|
||||||
let proxy_scheme = format!("http://127.0.0.1:{port}");
|
let proxy_scheme = format!("http://127.0.0.1:{port}");
|
||||||
|
|
||||||
@@ -260,7 +263,17 @@ impl PrfItem {
|
|||||||
let filename = match header.get("Content-Disposition") {
|
let filename = match header.get("Content-Disposition") {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let filename = value.to_str().unwrap_or("");
|
let filename = value.to_str().unwrap_or("");
|
||||||
help::parse_str::<String>(filename, "filename=")
|
match help::parse_str::<String>(filename, "filename=") {
|
||||||
|
Some(filename) => Some(filename),
|
||||||
|
None => match help::parse_str::<String>(filename, "filename*=") {
|
||||||
|
Some(filename) => {
|
||||||
|
let iter = percent_encoding::percent_decode(filename.as_bytes());
|
||||||
|
let filename = iter.decode_utf8().unwrap_or_default();
|
||||||
|
filename.split("''").last().map(|s| s.to_string())
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,11 +55,7 @@ impl IProfiles {
|
|||||||
|
|
||||||
pub fn template() -> Self {
|
pub fn template() -> Self {
|
||||||
Self {
|
Self {
|
||||||
valid: Some(vec![
|
valid: Some(vec!["dns".into()]),
|
||||||
"dns".into(),
|
|
||||||
"unified-delay".into(),
|
|
||||||
"tcp-concurrent".into(),
|
|
||||||
]),
|
|
||||||
items: Some(vec![]),
|
items: Some(vec![]),
|
||||||
..Self::default()
|
..Self::default()
|
||||||
}
|
}
|
||||||
@@ -69,7 +65,7 @@ impl IProfiles {
|
|||||||
help::save_yaml(
|
help::save_yaml(
|
||||||
&dirs::profiles_path()?,
|
&dirs::profiles_path()?,
|
||||||
self,
|
self,
|
||||||
Some("# Profiles Config for Clash Nyanpasu"),
|
Some("# Profiles Config for Clash Verge"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,6 +151,30 @@ impl IProfiles {
|
|||||||
self.save_file()
|
self.save_file()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// reorder items
|
||||||
|
pub fn reorder(&mut self, active_id: String, over_id: String) -> Result<()> {
|
||||||
|
let mut items = self.items.take().unwrap_or(vec![]);
|
||||||
|
let mut old_index = None;
|
||||||
|
let mut new_index = None;
|
||||||
|
|
||||||
|
for i in 0..items.len() {
|
||||||
|
if items[i].uid == Some(active_id.clone()) {
|
||||||
|
old_index = Some(i);
|
||||||
|
}
|
||||||
|
if items[i].uid == Some(over_id.clone()) {
|
||||||
|
new_index = Some(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if old_index.is_none() || new_index.is_none() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let item = items.remove(old_index.unwrap());
|
||||||
|
items.insert(new_index.unwrap(), item);
|
||||||
|
self.items = Some(items);
|
||||||
|
self.save_file()
|
||||||
|
}
|
||||||
|
|
||||||
/// update the item value
|
/// update the item value
|
||||||
pub fn patch_item(&mut self, uid: String, item: PrfItem) -> Result<()> {
|
pub fn patch_item(&mut self, uid: String, item: PrfItem) -> Result<()> {
|
||||||
let mut items = self.items.take().unwrap_or(vec![]);
|
let mut items = self.items.take().unwrap_or(vec![]);
|
||||||
@@ -265,7 +285,7 @@ impl IProfiles {
|
|||||||
Ok(current == uid)
|
Ok(current == uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 获取current指向的配置内容
|
/// 获取current指向的订阅内容
|
||||||
pub fn current_mapping(&self) -> Result<Mapping> {
|
pub fn current_mapping(&self) -> Result<Mapping> {
|
||||||
match (self.current.as_ref(), self.items.as_ref()) {
|
match (self.current.as_ref(), self.items.as_ref()) {
|
||||||
(Some(current), Some(items)) => {
|
(Some(current), Some(items)) => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::collections::HashMap;
|
|||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct IRuntime {
|
pub struct IRuntime {
|
||||||
pub config: Option<Mapping>,
|
pub config: Option<Mapping>,
|
||||||
// 记录在配置中(包括merge和script生成的)出现过的keys
|
// 记录在订阅中(包括merge和script生成的)出现过的keys
|
||||||
// 这些keys不一定都生效
|
// 这些keys不一定都生效
|
||||||
pub exists_keys: Vec<String>,
|
pub exists_keys: Vec<String>,
|
||||||
pub chain_logs: HashMap<String, Vec<(String, String)>>,
|
pub chain_logs: HashMap<String, Vec<(String, String)>>,
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ pub struct IVerge {
|
|||||||
/// maybe be able to set the alpha
|
/// maybe be able to set the alpha
|
||||||
pub theme_blur: Option<bool>,
|
pub theme_blur: Option<bool>,
|
||||||
|
|
||||||
|
/// tray click event
|
||||||
|
pub tray_event: Option<String>,
|
||||||
|
|
||||||
|
/// copy env type
|
||||||
|
pub env_type: Option<String>,
|
||||||
|
|
||||||
/// enable traffic graph default is true
|
/// enable traffic graph default is true
|
||||||
pub traffic_graph: Option<bool>,
|
pub traffic_graph: Option<bool>,
|
||||||
|
|
||||||
@@ -74,7 +80,7 @@ pub struct IVerge {
|
|||||||
/// 默认的延迟测试连接
|
/// 默认的延迟测试连接
|
||||||
pub default_latency_test: Option<String>,
|
pub default_latency_test: Option<String>,
|
||||||
|
|
||||||
/// 支持关闭字段过滤,避免meta的新字段都被过滤掉,默认为真
|
/// 支持关闭字段过滤,避免meta的新字段都被过滤掉,默认为关闭
|
||||||
pub enable_clash_fields: Option<bool>,
|
pub enable_clash_fields: Option<bool>,
|
||||||
|
|
||||||
/// 是否使用内部的脚本支持,默认为真
|
/// 是否使用内部的脚本支持,默认为真
|
||||||
@@ -83,9 +89,19 @@ pub struct IVerge {
|
|||||||
/// proxy 页面布局 列数
|
/// proxy 页面布局 列数
|
||||||
pub proxy_layout_column: Option<i32>,
|
pub proxy_layout_column: Option<i32>,
|
||||||
|
|
||||||
|
/// 日志清理
|
||||||
|
/// 0: 不清理; 1: 7天; 2: 30天; 3: 90天
|
||||||
|
pub auto_log_clean: Option<i32>,
|
||||||
|
|
||||||
/// window size and position
|
/// window size and position
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub window_size_position: Option<Vec<f64>>,
|
pub window_size_position: Option<Vec<f64>>,
|
||||||
|
|
||||||
|
/// 是否启用随机端口
|
||||||
|
pub enable_random_port: Option<bool>,
|
||||||
|
|
||||||
|
/// verge mixed port 用于覆盖 clash 的 mixed port
|
||||||
|
pub verge_mixed_port: Option<u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
@@ -117,33 +133,34 @@ impl IVerge {
|
|||||||
|
|
||||||
pub fn template() -> Self {
|
pub fn template() -> Self {
|
||||||
Self {
|
Self {
|
||||||
clash_core: match cfg!(feature = "default-meta") {
|
clash_core: Some("clash-meta".into()),
|
||||||
false => Some("clash".into()),
|
language: Some("zh".into()),
|
||||||
true => Some("clash-meta".into()),
|
|
||||||
},
|
|
||||||
language: match cfg!(feature = "default-meta") {
|
|
||||||
false => Some("en".into()),
|
|
||||||
true => Some("zh".into()),
|
|
||||||
},
|
|
||||||
theme_mode: Some("system".into()),
|
theme_mode: Some("system".into()),
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
env_type: Some("bash".into()),
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
env_type: Some("powershell".into()),
|
||||||
theme_blur: Some(false),
|
theme_blur: Some(false),
|
||||||
traffic_graph: Some(true),
|
traffic_graph: Some(true),
|
||||||
enable_memory_usage: Some(true),
|
enable_memory_usage: Some(true),
|
||||||
enable_auto_launch: Some(false),
|
enable_auto_launch: Some(false),
|
||||||
enable_silent_start: Some(false),
|
enable_silent_start: Some(false),
|
||||||
enable_system_proxy: Some(false),
|
enable_system_proxy: Some(false),
|
||||||
|
enable_random_port: Some(false),
|
||||||
|
verge_mixed_port: Some(7897),
|
||||||
enable_proxy_guard: Some(false),
|
enable_proxy_guard: Some(false),
|
||||||
proxy_guard_duration: Some(30),
|
proxy_guard_duration: Some(30),
|
||||||
auto_close_connection: Some(true),
|
auto_close_connection: Some(true),
|
||||||
enable_builtin_enhanced: Some(true),
|
enable_builtin_enhanced: Some(true),
|
||||||
enable_clash_fields: Some(true),
|
enable_clash_fields: Some(false),
|
||||||
|
auto_log_clean: Some(3),
|
||||||
..Self::default()
|
..Self::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save IVerge App Config
|
/// Save IVerge App Config
|
||||||
pub fn save_file(&self) -> Result<()> {
|
pub fn save_file(&self) -> Result<()> {
|
||||||
help::save_yaml(&dirs::verge_path()?, &self, Some("# Clash Nyanpasu Config"))
|
help::save_yaml(&dirs::verge_path()?, &self, Some("# Clash Verge Config"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// patch verge config
|
/// patch verge config
|
||||||
@@ -161,6 +178,8 @@ impl IVerge {
|
|||||||
patch!(language);
|
patch!(language);
|
||||||
patch!(theme_mode);
|
patch!(theme_mode);
|
||||||
patch!(theme_blur);
|
patch!(theme_blur);
|
||||||
|
patch!(tray_event);
|
||||||
|
patch!(env_type);
|
||||||
patch!(traffic_graph);
|
patch!(traffic_graph);
|
||||||
patch!(enable_memory_usage);
|
patch!(enable_memory_usage);
|
||||||
|
|
||||||
@@ -168,6 +187,8 @@ impl IVerge {
|
|||||||
patch!(enable_service_mode);
|
patch!(enable_service_mode);
|
||||||
patch!(enable_auto_launch);
|
patch!(enable_auto_launch);
|
||||||
patch!(enable_silent_start);
|
patch!(enable_silent_start);
|
||||||
|
patch!(enable_random_port);
|
||||||
|
patch!(verge_mixed_port);
|
||||||
patch!(enable_system_proxy);
|
patch!(enable_system_proxy);
|
||||||
patch!(enable_proxy_guard);
|
patch!(enable_proxy_guard);
|
||||||
patch!(system_proxy_bypass);
|
patch!(system_proxy_bypass);
|
||||||
@@ -183,7 +204,7 @@ impl IVerge {
|
|||||||
patch!(enable_builtin_enhanced);
|
patch!(enable_builtin_enhanced);
|
||||||
patch!(proxy_layout_column);
|
patch!(proxy_layout_column);
|
||||||
patch!(enable_clash_fields);
|
patch!(enable_clash_fields);
|
||||||
|
patch!(auto_log_clean);
|
||||||
patch!(window_size_position);
|
patch!(window_size_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use reqwest::header::HeaderMap;
|
use reqwest::header::HeaderMap;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@@ -36,6 +37,32 @@ pub async fn patch_configs(config: &Mapping) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct DelayRes {
|
||||||
|
delay: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// GET /proxies/{name}/delay
|
||||||
|
/// 获取代理延迟
|
||||||
|
pub async fn get_proxy_delay(name: String, test_url: Option<String>) -> Result<DelayRes> {
|
||||||
|
let (url, headers) = clash_client_info()?;
|
||||||
|
let url = format!("{url}/proxies/{name}/delay");
|
||||||
|
|
||||||
|
let default_url = "http://1.1.1.1";
|
||||||
|
let test_url = test_url
|
||||||
|
.map(|s| if s.is_empty() { default_url.into() } else { s })
|
||||||
|
.unwrap_or(default_url.into());
|
||||||
|
|
||||||
|
let client = reqwest::ClientBuilder::new().no_proxy().build()?;
|
||||||
|
let builder = client
|
||||||
|
.get(&url)
|
||||||
|
.headers(headers)
|
||||||
|
.query(&[("timeout", "10000"), ("url", &test_url)]);
|
||||||
|
let response = builder.send().await?;
|
||||||
|
|
||||||
|
Ok(response.json::<DelayRes>().await?)
|
||||||
|
}
|
||||||
|
|
||||||
/// 根据clash info获取clash服务地址和请求头
|
/// 根据clash info获取clash服务地址和请求头
|
||||||
fn clash_client_info() -> Result<(String, HeaderMap)> {
|
fn clash_client_info() -> Result<(String, HeaderMap)> {
|
||||||
let client = { Config::clash().data().get_client_info() };
|
let client = { Config::clash().data().get_client_info() };
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ impl CoreManager {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 检查配置是否正确
|
/// 检查订阅是否正确
|
||||||
pub fn check_config(&self) -> Result<()> {
|
pub fn check_config(&self) -> Result<()> {
|
||||||
let config_path = Config::generate_file(ConfigType::Check)?;
|
let config_path = Config::generate_file(ConfigType::Check)?;
|
||||||
let config_path = dirs::path_to_str(&config_path)?;
|
let config_path = dirs::path_to_str(&config_path)?;
|
||||||
@@ -147,6 +147,7 @@ impl CoreManager {
|
|||||||
// fix #212
|
// fix #212
|
||||||
let args = match clash_core.as_str() {
|
let args = match clash_core.as_str() {
|
||||||
"clash-meta" => vec!["-m", "-d", app_dir, "-f", config_path],
|
"clash-meta" => vec!["-m", "-d", app_dir, "-f", config_path],
|
||||||
|
"clash-meta-alpha" => vec!["-m", "-d", app_dir, "-f", config_path],
|
||||||
_ => vec!["-d", app_dir, "-f", config_path],
|
_ => vec!["-d", app_dir, "-f", config_path],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -258,8 +259,9 @@ impl CoreManager {
|
|||||||
/// 切换核心
|
/// 切换核心
|
||||||
pub async fn change_core(&self, clash_core: Option<String>) -> Result<()> {
|
pub async fn change_core(&self, clash_core: Option<String>) -> Result<()> {
|
||||||
let clash_core = clash_core.ok_or(anyhow::anyhow!("clash core is null"))?;
|
let clash_core = clash_core.ok_or(anyhow::anyhow!("clash core is null"))?;
|
||||||
|
const CLASH_CORES: [&str; 3] = ["clash", "clash-meta", "clash-meta-alpha"];
|
||||||
|
|
||||||
if &clash_core != "clash" && &clash_core != "clash-meta" {
|
if !CLASH_CORES.contains(&clash_core.as_str()) {
|
||||||
bail!("invalid clash core name \"{clash_core}\"");
|
bail!("invalid clash core name \"{clash_core}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +269,7 @@ impl CoreManager {
|
|||||||
|
|
||||||
Config::verge().draft().clash_core = Some(clash_core);
|
Config::verge().draft().clash_core = Some(clash_core);
|
||||||
|
|
||||||
// 更新配置
|
// 更新订阅
|
||||||
Config::generate()?;
|
Config::generate()?;
|
||||||
|
|
||||||
self.check_config()?;
|
self.check_config()?;
|
||||||
@@ -295,13 +297,13 @@ impl CoreManager {
|
|||||||
pub async fn update_config(&self) -> Result<()> {
|
pub async fn update_config(&self) -> Result<()> {
|
||||||
log::debug!(target: "app", "try to update clash config");
|
log::debug!(target: "app", "try to update clash config");
|
||||||
|
|
||||||
// 更新配置
|
// 更新订阅
|
||||||
Config::generate()?;
|
Config::generate()?;
|
||||||
|
|
||||||
// 检查配置是否正常
|
// 检查订阅是否正常
|
||||||
self.check_config()?;
|
self.check_config()?;
|
||||||
|
|
||||||
// 更新运行时配置
|
// 更新运行时订阅
|
||||||
let path = Config::generate_file(ConfigType::Run)?;
|
let path = Config::generate_file(ConfigType::Run)?;
|
||||||
let path = dirs::path_to_str(&path)?;
|
let path = dirs::path_to_str(&path)?;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use once_cell::sync::OnceCell;
|
|||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
use tauri::{AppHandle, GlobalShortcutManager};
|
use tauri::{AppHandle, GlobalShortcutManager};
|
||||||
use wry::application::accelerator::Accelerator;
|
|
||||||
|
|
||||||
pub struct Hotkey {
|
pub struct Hotkey {
|
||||||
current: Arc<Mutex<Vec<String>>>, // 保存当前的热键设置
|
current: Arc<Mutex<Vec<String>>>, // 保存当前的热键设置
|
||||||
@@ -35,7 +34,7 @@ impl Hotkey {
|
|||||||
|
|
||||||
match (key, func) {
|
match (key, func) {
|
||||||
(Some(key), Some(func)) => {
|
(Some(key), Some(func)) => {
|
||||||
log_err!(Self::check_key(key).and_then(|_| self.register(key, func)));
|
log_err!(self.register(key, func));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let key = key.unwrap_or("None");
|
let key = key.unwrap_or("None");
|
||||||
@@ -50,16 +49,6 @@ impl Hotkey {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 检查一个键是否合法
|
|
||||||
fn check_key(hotkey: &str) -> Result<()> {
|
|
||||||
// fix #287
|
|
||||||
// tauri的这几个方法全部有Result expect,会panic,先检测一遍避免挂了
|
|
||||||
if hotkey.parse::<Accelerator>().is_err() {
|
|
||||||
bail!("invalid hotkey `{hotkey}`");
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_manager(&self) -> Result<impl GlobalShortcutManager> {
|
fn get_manager(&self) -> Result<impl GlobalShortcutManager> {
|
||||||
let app_handle = self.app_handle.lock();
|
let app_handle = self.app_handle.lock();
|
||||||
if app_handle.is_none() {
|
if app_handle.is_none() {
|
||||||
@@ -109,11 +98,6 @@ impl Hotkey {
|
|||||||
|
|
||||||
let (del, add) = Self::get_diff(old_map, new_map);
|
let (del, add) = Self::get_diff(old_map, new_map);
|
||||||
|
|
||||||
// 先检查一遍所有新的热键是不是可以用的
|
|
||||||
for (hotkey, _) in add.iter() {
|
|
||||||
Self::check_key(hotkey)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
del.iter().for_each(|key| {
|
del.iter().for_each(|key| {
|
||||||
let _ = self.unregister(key);
|
let _ = self.unregister(key);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub fn grant_permission(core: String) -> anyhow::Result<()> {
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let output = {
|
let output = {
|
||||||
// the path of clash /Applications/Clash Nyanpasu.app/Contents/MacOS/clash
|
// the path of clash /Applications/Clash Verge.app/Contents/MacOS/clash
|
||||||
// https://apple.stackexchange.com/questions/82967/problem-with-empty-spaces-when-executing-shell-commands-in-applescript
|
// https://apple.stackexchange.com/questions/82967/problem-with-empty-spaces-when-executing-shell-commands-in-applescript
|
||||||
// let path = escape(&path);
|
// let path = escape(&path);
|
||||||
let path = path.replace(' ', "\\\\ ");
|
let path = path.replace(' ', "\\\\ ");
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ pub mod sysopt;
|
|||||||
pub mod timer;
|
pub mod timer;
|
||||||
pub mod tray;
|
pub mod tray;
|
||||||
pub mod win_service;
|
pub mod win_service;
|
||||||
|
pub mod win_uwp;
|
||||||
|
|
||||||
pub use self::core::*;
|
pub use self::core::*;
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ static DEFAULT_BYPASS: &str = "localhost;127.*;192.168.*;10.*;172.16.*;<local>";
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
static DEFAULT_BYPASS: &str = "localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,::1";
|
static DEFAULT_BYPASS: &str = "localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,::1";
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
static DEFAULT_BYPASS: &str = "127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,localhost,*.local,*.crashlytics.com,<local>";
|
static DEFAULT_BYPASS: &str =
|
||||||
|
"127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,localhost,*.local,*.crashlytics.com,<local>";
|
||||||
|
|
||||||
impl Sysopt {
|
impl Sysopt {
|
||||||
pub fn global() -> &'static Sysopt {
|
pub fn global() -> &'static Sysopt {
|
||||||
@@ -43,7 +44,10 @@ impl Sysopt {
|
|||||||
|
|
||||||
/// init the sysproxy
|
/// init the sysproxy
|
||||||
pub fn init_sysproxy(&self) -> Result<()> {
|
pub fn init_sysproxy(&self) -> Result<()> {
|
||||||
let port = { Config::clash().latest().get_mixed_port() };
|
let port = Config::verge()
|
||||||
|
.latest()
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port());
|
||||||
|
|
||||||
let (enable, bypass) = {
|
let (enable, bypass) = {
|
||||||
let verge = Config::verge();
|
let verge = Config::verge();
|
||||||
@@ -158,7 +162,7 @@ impl Sysopt {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
let app_path = format!("\"{app_path}\"");
|
let app_path = format!("\"{app_path}\"");
|
||||||
|
|
||||||
// use the /Applications/Clash Nyanpasu.app path
|
// use the /Applications/Clash Verge.app path
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let app_path = (|| -> Option<String> {
|
let app_path = (|| -> Option<String> {
|
||||||
let path = std::path::PathBuf::from(&app_path);
|
let path = std::path::PathBuf::from(&app_path);
|
||||||
@@ -284,7 +288,12 @@ impl Sysopt {
|
|||||||
|
|
||||||
log::debug!(target: "app", "try to guard the system proxy");
|
log::debug!(target: "app", "try to guard the system proxy");
|
||||||
|
|
||||||
let port = { Config::clash().latest().get_mixed_port() };
|
let port = {
|
||||||
|
Config::verge()
|
||||||
|
.latest()
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port())
|
||||||
|
};
|
||||||
|
|
||||||
let sysproxy = Sysproxy {
|
let sysproxy = Sysproxy {
|
||||||
enable: true,
|
enable: true,
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ impl Tray {
|
|||||||
"direct_mode",
|
"direct_mode",
|
||||||
t!("Direct Mode", "直连模式"),
|
t!("Direct Mode", "直连模式"),
|
||||||
))
|
))
|
||||||
.add_item(CustomMenuItem::new(
|
|
||||||
"script_mode",
|
|
||||||
t!("Script Mode", "脚本模式"),
|
|
||||||
))
|
|
||||||
.add_native_item(SystemTrayMenuItem::Separator)
|
.add_native_item(SystemTrayMenuItem::Separator)
|
||||||
.add_item(CustomMenuItem::new(
|
.add_item(CustomMenuItem::new(
|
||||||
"system_proxy",
|
"system_proxy",
|
||||||
@@ -52,16 +48,8 @@ impl Tray {
|
|||||||
))
|
))
|
||||||
.add_item(CustomMenuItem::new("tun_mode", t!("TUN Mode", "Tun 模式")))
|
.add_item(CustomMenuItem::new("tun_mode", t!("TUN Mode", "Tun 模式")))
|
||||||
.add_item(CustomMenuItem::new(
|
.add_item(CustomMenuItem::new(
|
||||||
"copy_env_sh",
|
"copy_env",
|
||||||
t!("Copy Env (sh)", "复制环境变量(sh)"),
|
t!("Copy Env", "复制环境变量"),
|
||||||
))
|
|
||||||
.add_item(CustomMenuItem::new(
|
|
||||||
"copy_env_cmd",
|
|
||||||
t!("Copy Env (CMD)", "复制环境变量(CMD)"),
|
|
||||||
))
|
|
||||||
.add_item(CustomMenuItem::new(
|
|
||||||
"copy_env_ps",
|
|
||||||
t!("Copy Env (PS)", "复制环境变量(PS)"),
|
|
||||||
))
|
))
|
||||||
.add_submenu(SystemTraySubmenu::new(
|
.add_submenu(SystemTraySubmenu::new(
|
||||||
t!("Open Dir", "打开目录"),
|
t!("Open Dir", "打开目录"),
|
||||||
@@ -107,6 +95,20 @@ impl Tray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_part(app_handle: &AppHandle) -> Result<()> {
|
pub fn update_part(app_handle: &AppHandle) -> Result<()> {
|
||||||
|
let zh = { Config::verge().latest().language == Some("zh".into()) };
|
||||||
|
|
||||||
|
let version = app_handle.package_info().version.to_string();
|
||||||
|
|
||||||
|
macro_rules! t {
|
||||||
|
($en: expr, $zh: expr) => {
|
||||||
|
if zh {
|
||||||
|
$zh
|
||||||
|
} else {
|
||||||
|
$en
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let mode = {
|
let mode = {
|
||||||
Config::clash()
|
Config::clash()
|
||||||
.latest()
|
.latest()
|
||||||
@@ -122,46 +124,80 @@ impl Tray {
|
|||||||
let _ = tray.get_item("rule_mode").set_selected(mode == "rule");
|
let _ = tray.get_item("rule_mode").set_selected(mode == "rule");
|
||||||
let _ = tray.get_item("global_mode").set_selected(mode == "global");
|
let _ = tray.get_item("global_mode").set_selected(mode == "global");
|
||||||
let _ = tray.get_item("direct_mode").set_selected(mode == "direct");
|
let _ = tray.get_item("direct_mode").set_selected(mode == "direct");
|
||||||
let _ = tray.get_item("script_mode").set_selected(mode == "script");
|
|
||||||
|
|
||||||
let verge = Config::verge();
|
let verge = Config::verge();
|
||||||
let verge = verge.latest();
|
let verge = verge.latest();
|
||||||
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
||||||
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
let mut indication_icon = if *system_proxy {
|
||||||
{
|
#[cfg(not(target_os = "macos"))]
|
||||||
let indication_icon = if *system_proxy {
|
let icon = include_bytes!("../../icons/tray-icon-sys.png").to_vec();
|
||||||
include_bytes!("../../icons/win-tray-icon-activated.png").to_vec()
|
#[cfg(target_os = "macos")]
|
||||||
} else {
|
let icon = include_bytes!("../../icons/mac-tray-icon-sys.png").to_vec();
|
||||||
include_bytes!("../../icons/win-tray-icon.png").to_vec()
|
icon
|
||||||
};
|
} else {
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let icon = include_bytes!("../../icons/tray-icon.png").to_vec();
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let icon = include_bytes!("../../icons/icon.png").to_vec();
|
||||||
|
icon
|
||||||
|
};
|
||||||
|
|
||||||
let _ = tray.set_icon(tauri::Icon::Raw(indication_icon));
|
if *tun_mode {
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let icon = include_bytes!("../../icons/tray-icon-tun.png").to_vec();
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let icon = include_bytes!("../../icons/mac-tray-icon-tun.png").to_vec();
|
||||||
|
indication_icon = icon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _ = tray.set_icon(tauri::Icon::Raw(indication_icon));
|
||||||
|
|
||||||
let _ = tray.get_item("system_proxy").set_selected(*system_proxy);
|
let _ = tray.get_item("system_proxy").set_selected(*system_proxy);
|
||||||
let _ = tray.get_item("tun_mode").set_selected(*tun_mode);
|
let _ = tray.get_item("tun_mode").set_selected(*tun_mode);
|
||||||
|
|
||||||
|
let switch_map = {
|
||||||
|
let mut map = std::collections::HashMap::new();
|
||||||
|
map.insert(true, "on");
|
||||||
|
map.insert(false, "off");
|
||||||
|
map
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = tray.set_tooltip(&format!(
|
||||||
|
"Clash Verge {version}\n{}: {}\n{}: {}",
|
||||||
|
t!("System Proxy", "系统代理"),
|
||||||
|
switch_map[system_proxy],
|
||||||
|
t!("TUN Mode", "Tun 模式"),
|
||||||
|
switch_map[tun_mode]
|
||||||
|
));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn on_left_click(app_handle: &AppHandle) {
|
||||||
|
let tray_event = { Config::verge().latest().tray_event.clone() };
|
||||||
|
let tray_event = tray_event.unwrap_or("main_window".into());
|
||||||
|
match tray_event.as_str() {
|
||||||
|
"system_proxy" => feat::toggle_system_proxy(),
|
||||||
|
"tun_mode" => feat::toggle_tun_mode(),
|
||||||
|
"main_window" => resolve::create_window(app_handle),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn on_system_tray_event(app_handle: &AppHandle, event: SystemTrayEvent) {
|
pub fn on_system_tray_event(app_handle: &AppHandle, event: SystemTrayEvent) {
|
||||||
match event {
|
match event {
|
||||||
|
SystemTrayEvent::LeftClick { .. } => Tray::on_left_click(app_handle),
|
||||||
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
|
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
|
||||||
mode @ ("rule_mode" | "global_mode" | "direct_mode" | "script_mode") => {
|
mode @ ("rule_mode" | "global_mode" | "direct_mode") => {
|
||||||
let mode = &mode[0..mode.len() - 5];
|
let mode = &mode[0..mode.len() - 5];
|
||||||
feat::change_clash_mode(mode.into());
|
feat::change_clash_mode(mode.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
"open_window" => resolve::create_window(app_handle),
|
"open_window" => resolve::create_window(app_handle),
|
||||||
"system_proxy" => feat::toggle_system_proxy(),
|
"system_proxy" => feat::toggle_system_proxy(),
|
||||||
"tun_mode" => feat::toggle_tun_mode(),
|
"tun_mode" => feat::toggle_tun_mode(),
|
||||||
"copy_env_sh" => feat::copy_clash_env("sh"),
|
"copy_env" => feat::copy_clash_env(app_handle),
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
"copy_env_cmd" => feat::copy_clash_env("cmd"),
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
"copy_env_ps" => feat::copy_clash_env("ps"),
|
|
||||||
"open_app_dir" => crate::log_err!(cmds::open_app_dir()),
|
"open_app_dir" => crate::log_err!(cmds::open_app_dir()),
|
||||||
"open_core_dir" => crate::log_err!(cmds::open_core_dir()),
|
"open_core_dir" => crate::log_err!(cmds::open_core_dir()),
|
||||||
"open_logs_dir" => crate::log_err!(cmds::open_logs_dir()),
|
"open_logs_dir" => crate::log_err!(cmds::open_logs_dir()),
|
||||||
@@ -177,10 +213,6 @@ impl Tray {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
SystemTrayEvent::LeftClick { .. } => {
|
|
||||||
resolve::create_window(app_handle);
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub struct JsonResponse {
|
|||||||
pub data: Option<ResponseBody>,
|
pub data: Option<ResponseBody>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Install the Clash Nyanpasu Service
|
/// Install the Clash Verge Service
|
||||||
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
|
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
|
||||||
pub async fn install_service() -> Result<()> {
|
pub async fn install_service() -> Result<()> {
|
||||||
let binary_path = dirs::service_path()?;
|
let binary_path = dirs::service_path()?;
|
||||||
@@ -60,7 +60,7 @@ pub async fn install_service() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Uninstall the Clash Nyanpasu Service
|
/// Uninstall the Clash Verge Service
|
||||||
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
|
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
|
||||||
pub async fn uninstall_service() -> Result<()> {
|
pub async fn uninstall_service() -> Result<()> {
|
||||||
let binary_path = dirs::service_path()?;
|
let binary_path = dirs::service_path()?;
|
||||||
@@ -99,10 +99,10 @@ pub async fn check_service() -> Result<JsonResponse> {
|
|||||||
.get(url)
|
.get(url)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.context("failed to connect to the Clash Nyanpasu Service")?
|
.context("failed to connect to the Clash Verge Service")?
|
||||||
.json::<JsonResponse>()
|
.json::<JsonResponse>()
|
||||||
.await
|
.await
|
||||||
.context("failed to parse the Clash Nyanpasu Service response")?;
|
.context("failed to parse the Clash Verge Service response")?;
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ pub(super) async fn run_core_by_service(config_file: &PathBuf) -> Result<()> {
|
|||||||
.await?
|
.await?
|
||||||
.json::<JsonResponse>()
|
.json::<JsonResponse>()
|
||||||
.await
|
.await
|
||||||
.context("failed to connect to the Clash Nyanpasu Service")?;
|
.context("failed to connect to the Clash Verge Service")?;
|
||||||
|
|
||||||
if res.code != 0 {
|
if res.code != 0 {
|
||||||
bail!(res.msg);
|
bail!(res.msg);
|
||||||
@@ -168,7 +168,7 @@ pub(super) async fn stop_core_by_service() -> Result<()> {
|
|||||||
.await?
|
.await?
|
||||||
.json::<JsonResponse>()
|
.json::<JsonResponse>()
|
||||||
.await
|
.await
|
||||||
.context("failed to connect to the Clash Nyanpasu Service")?;
|
.context("failed to connect to the Clash Verge Service")?;
|
||||||
|
|
||||||
if res.code != 0 {
|
if res.code != 0 {
|
||||||
bail!(res.msg);
|
bail!(res.msg);
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#![cfg(target_os = "windows")]
|
||||||
|
|
||||||
|
use crate::utils::dirs;
|
||||||
|
use anyhow::{bail, Result};
|
||||||
|
use deelevate::{PrivilegeLevel, Token};
|
||||||
|
use runas::Command as RunasCommand;
|
||||||
|
use std::process::Command as StdCommand;
|
||||||
|
|
||||||
|
pub async fn invoke_uwptools() -> Result<()> {
|
||||||
|
let binary_path = dirs::service_path()?;
|
||||||
|
let tool_path = binary_path.with_file_name("enableLoopback.exe");
|
||||||
|
|
||||||
|
if !tool_path.exists() {
|
||||||
|
bail!("enableLoopback exe not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
let token = Token::with_current_process()?;
|
||||||
|
let level = token.privilege_level()?;
|
||||||
|
|
||||||
|
match level {
|
||||||
|
PrivilegeLevel::NotPrivileged => RunasCommand::new(tool_path).status()?,
|
||||||
|
_ => StdCommand::new(tool_path)
|
||||||
|
.status()?,
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ pub enum ChainType {
|
|||||||
pub enum ChainSupport {
|
pub enum ChainSupport {
|
||||||
Clash,
|
Clash,
|
||||||
ClashMeta,
|
ClashMeta,
|
||||||
|
ClashMetaAlpha,
|
||||||
All,
|
All,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,9 +61,19 @@ impl ChainItem {
|
|||||||
let hy_alpn =
|
let hy_alpn =
|
||||||
ChainItem::to_script("verge_hy_alpn", include_str!("./builtin/meta_hy_alpn.js"));
|
ChainItem::to_script("verge_hy_alpn", include_str!("./builtin/meta_hy_alpn.js"));
|
||||||
|
|
||||||
|
// meta 的一些处理
|
||||||
|
let meta_guard_alpha =
|
||||||
|
ChainItem::to_script("verge_meta_guard", include_str!("./builtin/meta_guard.js"));
|
||||||
|
|
||||||
|
// meta 1.13.2 alpn string 转 数组
|
||||||
|
let hy_alpn_alpha =
|
||||||
|
ChainItem::to_script("verge_hy_alpn", include_str!("./builtin/meta_hy_alpn.js"));
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
(ChainSupport::ClashMeta, hy_alpn),
|
(ChainSupport::ClashMeta, hy_alpn),
|
||||||
(ChainSupport::ClashMeta, meta_guard),
|
(ChainSupport::ClashMeta, meta_guard),
|
||||||
|
(ChainSupport::ClashMetaAlpha, hy_alpn_alpha),
|
||||||
|
(ChainSupport::ClashMetaAlpha, meta_guard_alpha),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +92,7 @@ impl ChainSupport {
|
|||||||
(ChainSupport::All, _) => true,
|
(ChainSupport::All, _) => true,
|
||||||
(ChainSupport::Clash, "clash") => true,
|
(ChainSupport::Clash, "clash") => true,
|
||||||
(ChainSupport::ClashMeta, "clash-meta") => true,
|
(ChainSupport::ClashMeta, "clash-meta") => true,
|
||||||
|
(ChainSupport::ClashMetaAlpha, "clash-meta-alpha") => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
None => true,
|
None => true,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub const DEFAULT_FIELDS: [&str; 5] = [
|
|||||||
"rule-providers",
|
"rule-providers",
|
||||||
];
|
];
|
||||||
|
|
||||||
pub const OTHERS_FIELDS: [&str; 30] = [
|
pub const OTHERS_FIELDS: [&str; 31] = [
|
||||||
"dns",
|
"dns",
|
||||||
"tun",
|
"tun",
|
||||||
"ebpf",
|
"ebpf",
|
||||||
@@ -50,6 +50,7 @@ pub const OTHERS_FIELDS: [&str; 30] = [
|
|||||||
"tcp-concurrent", // meta
|
"tcp-concurrent", // meta
|
||||||
"enable-process", // meta
|
"enable-process", // meta
|
||||||
"find-process-mode", // meta
|
"find-process-mode", // meta
|
||||||
|
"skip-auth-prefixes", // meta
|
||||||
"external-controller-tls", // meta
|
"external-controller-tls", // meta
|
||||||
"global-client-fingerprint", // meta
|
"global-client-fingerprint", // meta
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ use std::collections::HashSet;
|
|||||||
type ResultLog = Vec<(String, String)>;
|
type ResultLog = Vec<(String, String)>;
|
||||||
|
|
||||||
/// Enhance mode
|
/// Enhance mode
|
||||||
/// 返回最终配置、该配置包含的键、和script执行的结果
|
/// 返回最终订阅、该订阅包含的键、和script执行的结果
|
||||||
pub fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
pub fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
||||||
// config.yaml 的配置
|
// config.yaml 的订阅
|
||||||
let clash_config = { Config::clash().latest().0.clone() };
|
let clash_config = { Config::clash().latest().0.clone() };
|
||||||
|
|
||||||
let (clash_core, enable_tun, enable_builtin, enable_filter) = {
|
let (clash_core, enable_tun, enable_builtin, enable_filter) = {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use anyhow::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::{Context, Func, Runtime};
|
use rquickjs::{function::Func, Context, Runtime};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::log_err;
|
|||||||
use crate::utils::resolve;
|
use crate::utils::resolve;
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use serde_yaml::{Mapping, Value};
|
use serde_yaml::{Mapping, Value};
|
||||||
use wry::application::clipboard::Clipboard;
|
use tauri::{AppHandle, ClipboardManager};
|
||||||
|
|
||||||
// 打开面板
|
// 打开面板
|
||||||
pub fn open_dashboard() {
|
pub fn open_dashboard() {
|
||||||
@@ -47,7 +47,7 @@ pub fn change_clash_mode(mode: String) {
|
|||||||
|
|
||||||
match clash_api::patch_configs(&mapping).await {
|
match clash_api::patch_configs(&mapping).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// 更新配置
|
// 更新订阅
|
||||||
Config::clash().data().patch_config(mapping);
|
Config::clash().data().patch_config(mapping);
|
||||||
|
|
||||||
if Config::clash().data().save_config().is_ok() {
|
if Config::clash().data().save_config().is_ok() {
|
||||||
@@ -156,14 +156,19 @@ pub fn disable_tun_mode() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 修改clash的配置
|
/// 修改clash的订阅
|
||||||
pub async fn patch_clash(patch: Mapping) -> Result<()> {
|
pub async fn patch_clash(patch: Mapping) -> Result<()> {
|
||||||
Config::clash().draft().patch_config(patch.clone());
|
Config::clash().draft().patch_config(patch.clone());
|
||||||
|
|
||||||
match {
|
match {
|
||||||
let mixed_port = patch.get("mixed-port");
|
let mixed_port = patch.get("mixed-port");
|
||||||
if mixed_port.is_some() {
|
let enable_random_port = Config::verge().latest().enable_random_port.unwrap_or(false);
|
||||||
let changed = mixed_port != Config::clash().data().0.get("mixed-port");
|
if mixed_port.is_some() && !enable_random_port {
|
||||||
|
let changed = mixed_port.clone().unwrap()
|
||||||
|
!= Config::verge()
|
||||||
|
.latest()
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port());
|
||||||
// 检查端口占用
|
// 检查端口占用
|
||||||
if changed {
|
if changed {
|
||||||
if let Some(port) = mixed_port.clone().unwrap().as_u64() {
|
if let Some(port) = mixed_port.clone().unwrap().as_u64() {
|
||||||
@@ -175,7 +180,7 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 激活配置
|
// 激活订阅
|
||||||
if mixed_port.is_some()
|
if mixed_port.is_some()
|
||||||
|| patch.get("secret").is_some()
|
|| patch.get("secret").is_some()
|
||||||
|| patch.get("external-controller").is_some()
|
|| patch.get("external-controller").is_some()
|
||||||
@@ -210,7 +215,7 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 修改verge的配置
|
/// 修改verge的订阅
|
||||||
/// 一般都是一个个的修改
|
/// 一般都是一个个的修改
|
||||||
pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
||||||
Config::verge().draft().patch_config(patch.clone());
|
Config::verge().draft().patch_config(patch.clone());
|
||||||
@@ -278,7 +283,7 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 更新某个profile
|
/// 更新某个profile
|
||||||
/// 如果更新当前配置就激活配置
|
/// 如果更新当前订阅就激活订阅
|
||||||
pub async fn update_profile(uid: String, option: Option<PrfOption>) -> Result<()> {
|
pub async fn update_profile(uid: String, option: Option<PrfOption>) -> Result<()> {
|
||||||
let url_opt = {
|
let url_opt = {
|
||||||
let profiles = Config::profiles();
|
let profiles = Config::profiles();
|
||||||
@@ -316,7 +321,7 @@ pub async fn update_profile(uid: String, option: Option<PrfOption>) -> Result<()
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 更新配置
|
/// 更新订阅
|
||||||
async fn update_core_config() -> Result<()> {
|
async fn update_core_config() -> Result<()> {
|
||||||
match CoreManager::global().update_config().await {
|
match CoreManager::global().update_config().await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@@ -332,21 +337,34 @@ async fn update_core_config() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// copy env variable
|
/// copy env variable
|
||||||
pub fn copy_clash_env(option: &str) {
|
pub fn copy_clash_env(app_handle: &AppHandle) {
|
||||||
let port = { Config::clash().data().get_client_info().port };
|
let port = { Config::verge().latest().verge_mixed_port.unwrap_or(7897) };
|
||||||
let http_proxy = format!("http://127.0.0.1:{}", port);
|
let http_proxy = format!("http://127.0.0.1:{}", port);
|
||||||
let socks5_proxy = format!("socks5://127.0.0.1:{}", port);
|
let socks5_proxy = format!("socks5://127.0.0.1:{}", port);
|
||||||
|
|
||||||
let sh = format!("export https_proxy={http_proxy} http_proxy={http_proxy} all_proxy={socks5_proxy}");
|
let sh =
|
||||||
|
format!("export https_proxy={http_proxy} http_proxy={http_proxy} all_proxy={socks5_proxy}");
|
||||||
let cmd: String = format!("set http_proxy={http_proxy} \n set https_proxy={http_proxy}");
|
let cmd: String = format!("set http_proxy={http_proxy} \n set https_proxy={http_proxy}");
|
||||||
let ps: String = format!("$env:HTTP_PROXY=\"{http_proxy}\"; $env:HTTPS_PROXY=\"{http_proxy}\"");
|
let ps: String = format!("$env:HTTP_PROXY=\"{http_proxy}\"; $env:HTTPS_PROXY=\"{http_proxy}\"");
|
||||||
|
|
||||||
let mut cliboard = Clipboard::new();
|
let mut cliboard = app_handle.clipboard_manager();
|
||||||
|
|
||||||
match option {
|
let env_type = { Config::verge().latest().env_type.clone() };
|
||||||
"sh" => cliboard.write_text(sh),
|
let env_type = match env_type {
|
||||||
"cmd" => cliboard.write_text(cmd),
|
Some(env_type) => env_type,
|
||||||
"ps" => cliboard.write_text(ps),
|
None => {
|
||||||
_ => log::error!(target: "app", "copy_clash_env: Invalid option! {option}"),
|
#[cfg(not(target_os = "windows"))]
|
||||||
}
|
let default = "bash";
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
let default = "powershell";
|
||||||
|
|
||||||
|
default.to_string()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
match env_type.as_str() {
|
||||||
|
"bash" => cliboard.write_text(sh).unwrap_or_default(),
|
||||||
|
"cmd" => cliboard.write_text(cmd).unwrap_or_default(),
|
||||||
|
"powershell" => cliboard.write_text(ps).unwrap_or_default(),
|
||||||
|
_ => log::error!(target: "app", "copy_clash_env: Invalid env type! {env_type}"),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
cmds::get_runtime_yaml,
|
cmds::get_runtime_yaml,
|
||||||
cmds::get_runtime_exists,
|
cmds::get_runtime_exists,
|
||||||
cmds::get_runtime_logs,
|
cmds::get_runtime_logs,
|
||||||
|
cmds::uwp::invoke_uwp_tool,
|
||||||
// verge
|
// verge
|
||||||
cmds::get_verge_config,
|
cmds::get_verge_config,
|
||||||
cmds::patch_verge_config,
|
cmds::patch_verge_config,
|
||||||
@@ -58,6 +59,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
cmds::patch_profile,
|
cmds::patch_profile,
|
||||||
cmds::create_profile,
|
cmds::create_profile,
|
||||||
cmds::import_profile,
|
cmds::import_profile,
|
||||||
|
cmds::reorder_profile,
|
||||||
cmds::update_profile,
|
cmds::update_profile,
|
||||||
cmds::delete_profile,
|
cmds::delete_profile,
|
||||||
cmds::read_profile_file,
|
cmds::read_profile_file,
|
||||||
@@ -66,6 +68,8 @@ fn main() -> std::io::Result<()> {
|
|||||||
cmds::service::check_service,
|
cmds::service::check_service,
|
||||||
cmds::service::install_service,
|
cmds::service::install_service,
|
||||||
cmds::service::uninstall_service,
|
cmds::service::uninstall_service,
|
||||||
|
// clash api
|
||||||
|
cmds::clash_api_get_proxy_delay
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
@@ -101,6 +105,10 @@ fn main() -> std::io::Result<()> {
|
|||||||
api::process::kill_children();
|
api::process::kill_children();
|
||||||
app_handle.exit(0);
|
app_handle.exit(0);
|
||||||
}
|
}
|
||||||
|
tauri::RunEvent::Updater(tauri::UpdaterEvent::Downloaded) => {
|
||||||
|
resolve::resolve_reset();
|
||||||
|
api::process::kill_children();
|
||||||
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
tauri::RunEvent::WindowEvent { label, event, .. } => {
|
tauri::RunEvent::WindowEvent { label, event, .. } => {
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tauri::{
|
use tauri::{
|
||||||
api::path::{home_dir, resource_dir},
|
api::path::{data_dir, resource_dir},
|
||||||
Env, PackageInfo,
|
Env, PackageInfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "verge-dev"))]
|
#[cfg(not(feature = "verge-dev"))]
|
||||||
static APP_DIR: &str = "clash-verge";
|
static APP_ID: &str = "io.github.clash-verge-rev.clash-verge-rev";
|
||||||
#[cfg(feature = "verge-dev")]
|
#[cfg(feature = "verge-dev")]
|
||||||
static APP_DIR: &str = "clash-verge-dev";
|
static APP_ID: &str = "io.github.clash-verge-rev.clash-verge-rev.dev";
|
||||||
|
|
||||||
static CLASH_CONFIG: &str = "config.yaml";
|
static CLASH_CONFIG: &str = "config.yaml";
|
||||||
static VERGE_CONFIG: &str = "verge.yaml";
|
static VERGE_CONFIG: &str = "verge.yaml";
|
||||||
static PROFILE_YAML: &str = "profiles.yaml";
|
static PROFILE_YAML: &str = "profiles.yaml";
|
||||||
|
|
||||||
static mut RESOURCE_DIR: Option<PathBuf> = None;
|
static mut RESOURCE_DIR: Option<PathBuf> = None;
|
||||||
|
static mut APP_HOME_DIR: Option<PathBuf> = None;
|
||||||
|
|
||||||
/// portable flag
|
/// portable flag
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
@@ -42,30 +43,27 @@ pub unsafe fn init_portable_flag() -> Result<()> {
|
|||||||
|
|
||||||
/// get the verge app home dir
|
/// get the verge app home dir
|
||||||
pub fn app_home_dir() -> Result<PathBuf> {
|
pub fn app_home_dir() -> Result<PathBuf> {
|
||||||
#[cfg(target_os = "windows")]
|
use tauri::utils::platform::current_exe;
|
||||||
unsafe {
|
let app_exe = current_exe()?;
|
||||||
use tauri::utils::platform::current_exe;
|
let app_exe = dunce::canonicalize(app_exe)?;
|
||||||
|
let app_dir = app_exe
|
||||||
|
.parent()
|
||||||
|
.ok_or(anyhow::anyhow!("failed to get the portable app dir"))?;
|
||||||
|
|
||||||
if !PORTABLE_FLAG {
|
let portable_home_dir = PathBuf::from(app_dir).join(".config").join(APP_ID);
|
||||||
Ok(home_dir()
|
let home_dir = data_dir()
|
||||||
.ok_or(anyhow::anyhow!("failed to get app home dir"))?
|
.ok_or(anyhow::anyhow!("failed to get app home dir"))?
|
||||||
.join(".config")
|
.join(APP_ID);
|
||||||
.join(APP_DIR))
|
|
||||||
|
unsafe {
|
||||||
|
if PORTABLE_FLAG {
|
||||||
|
APP_HOME_DIR = Some(portable_home_dir.clone());
|
||||||
|
Ok(portable_home_dir)
|
||||||
} else {
|
} else {
|
||||||
let app_exe = current_exe()?;
|
APP_HOME_DIR = Some(home_dir.clone());
|
||||||
let app_exe = dunce::canonicalize(app_exe)?;
|
Ok(home_dir)
|
||||||
let app_dir = app_exe
|
|
||||||
.parent()
|
|
||||||
.ok_or(anyhow::anyhow!("failed to get the portable app dir"))?;
|
|
||||||
Ok(PathBuf::from(app_dir).join(".config").join(APP_DIR))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
|
||||||
Ok(home_dir()
|
|
||||||
.ok_or(anyhow::anyhow!("failed to get the app home dir"))?
|
|
||||||
.join(".config")
|
|
||||||
.join(APP_DIR))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get the resources dir
|
/// get the resources dir
|
||||||
@@ -118,9 +116,9 @@ pub fn app_res_dir() -> Result<PathBuf> {
|
|||||||
|
|
||||||
pub fn clash_pid_path() -> Result<PathBuf> {
|
pub fn clash_pid_path() -> Result<PathBuf> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Ok(RESOURCE_DIR
|
Ok(APP_HOME_DIR
|
||||||
.clone()
|
.clone()
|
||||||
.ok_or(anyhow::anyhow!("failed to get the resource dir"))?
|
.ok_or(anyhow::anyhow!("failed to get the app home dir"))?
|
||||||
.join("clash.pid"))
|
.join("clash.pid"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ use nanoid::nanoid;
|
|||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
use serde_yaml::{Mapping, Value};
|
use serde_yaml::{Mapping, Value};
|
||||||
use std::{fs, path::PathBuf, str::FromStr};
|
use std::{fs, path::PathBuf, str::FromStr};
|
||||||
|
use tauri::{
|
||||||
|
api::shell::{open, Program},
|
||||||
|
Manager,
|
||||||
|
};
|
||||||
|
|
||||||
/// read data from yaml as struct T
|
/// read data from yaml as struct T
|
||||||
pub fn read_yaml<T: DeserializeOwned>(path: &PathBuf) -> Result<T> {
|
pub fn read_yaml<T: DeserializeOwned>(path: &PathBuf) -> Result<T> {
|
||||||
@@ -81,18 +85,20 @@ pub fn parse_str<T: FromStr>(target: &str, key: &str) -> Option<T> {
|
|||||||
|
|
||||||
/// open file
|
/// open file
|
||||||
/// use vscode by default
|
/// use vscode by default
|
||||||
pub fn open_file(path: PathBuf) -> Result<()> {
|
pub fn open_file(app: tauri::AppHandle, path: PathBuf) -> Result<()> {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let code = "Visual Studio Code";
|
let code = "Visual Studio Code";
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
let code = "code";
|
let code = "code";
|
||||||
|
|
||||||
// use vscode first
|
let _ = match Program::from_str(code) {
|
||||||
if let Err(err) = open::with(&path, code) {
|
Ok(code) => open(&app.shell_scope(), &path.to_string_lossy(), Some(code)),
|
||||||
log::error!(target: "app", "failed to open file with VScode `{err}`");
|
Err(err) => {
|
||||||
// default open
|
log::error!(target: "app", "Can't find VScode `{err}`");
|
||||||
open::that(path)?;
|
// default open
|
||||||
}
|
open(&app.shell_scope(), &path.to_string_lossy(), None)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
use crate::config::*;
|
use crate::config::*;
|
||||||
use crate::utils::{dirs, help};
|
use crate::utils::{dirs, help};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use chrono::Local;
|
use chrono::{Local, TimeZone};
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use log4rs::append::console::ConsoleAppender;
|
use log4rs::append::console::ConsoleAppender;
|
||||||
use log4rs::append::file::FileAppender;
|
use log4rs::append::file::FileAppender;
|
||||||
use log4rs::config::{Appender, Logger, Root};
|
use log4rs::config::{Appender, Logger, Root};
|
||||||
use log4rs::encode::pattern::PatternEncoder;
|
use log4rs::encode::pattern::PatternEncoder;
|
||||||
use std::fs;
|
use std::fs::{self, DirEntry};
|
||||||
|
use std::str::FromStr;
|
||||||
use tauri::PackageInfo;
|
use tauri::PackageInfo;
|
||||||
|
|
||||||
/// initialize this instance's log file
|
/// initialize this instance's log file
|
||||||
@@ -69,6 +70,72 @@ fn init_log() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 删除log文件
|
||||||
|
pub fn delete_log() -> Result<()> {
|
||||||
|
let log_dir = dirs::app_logs_dir()?;
|
||||||
|
if !log_dir.exists() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let auto_log_clean = {
|
||||||
|
let verge = Config::verge();
|
||||||
|
let verge = verge.data();
|
||||||
|
verge.auto_log_clean.clone().unwrap_or(0)
|
||||||
|
};
|
||||||
|
|
||||||
|
let day = match auto_log_clean {
|
||||||
|
1 => 7,
|
||||||
|
2 => 30,
|
||||||
|
3 => 90,
|
||||||
|
_ => return Ok(()),
|
||||||
|
};
|
||||||
|
|
||||||
|
log::debug!(target: "app", "try to delete log files, day: {day}");
|
||||||
|
|
||||||
|
// %Y-%m-%d to NaiveDateTime
|
||||||
|
let parse_time_str = |s: &str| {
|
||||||
|
let sa: Vec<&str> = s.split('-').collect();
|
||||||
|
if sa.len() != 4 {
|
||||||
|
return Err(anyhow::anyhow!("invalid time str"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let year = i32::from_str(sa[0])?;
|
||||||
|
let month = u32::from_str(sa[1])?;
|
||||||
|
let day = u32::from_str(sa[2])?;
|
||||||
|
let time = chrono::NaiveDate::from_ymd_opt(year, month, day)
|
||||||
|
.ok_or(anyhow::anyhow!("invalid time str"))?
|
||||||
|
.and_hms_opt(0, 0, 0)
|
||||||
|
.ok_or(anyhow::anyhow!("invalid time str"))?;
|
||||||
|
Ok(time)
|
||||||
|
};
|
||||||
|
|
||||||
|
let process_file = |file: DirEntry| -> Result<()> {
|
||||||
|
let file_name = file.file_name();
|
||||||
|
let file_name = file_name.to_str().unwrap_or_default();
|
||||||
|
|
||||||
|
if file_name.ends_with(".log") {
|
||||||
|
let now = Local::now();
|
||||||
|
let created_time = parse_time_str(&file_name[0..file_name.len() - 4])?;
|
||||||
|
let file_time = Local.from_local_datetime(&created_time).single().ok_or(anyhow::anyhow!("invalid local datetime"))?;
|
||||||
|
|
||||||
|
let duration = now.signed_duration_since(file_time);
|
||||||
|
if duration.num_days() > day {
|
||||||
|
let file_path = file.path();
|
||||||
|
let _ = fs::remove_file(file_path);
|
||||||
|
log::info!(target: "app", "delete log file: {file_name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
};
|
||||||
|
|
||||||
|
for file in fs::read_dir(&log_dir)? {
|
||||||
|
if let Ok(file) = file {
|
||||||
|
let _ = process_file(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Initialize all the config files
|
/// Initialize all the config files
|
||||||
/// before tauri setup
|
/// before tauri setup
|
||||||
pub fn init_config() -> Result<()> {
|
pub fn init_config() -> Result<()> {
|
||||||
@@ -78,6 +145,7 @@ pub fn init_config() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _ = init_log();
|
let _ = init_log();
|
||||||
|
let _ = delete_log();
|
||||||
|
|
||||||
crate::log_err!(dirs::app_home_dir().map(|app_dir| {
|
crate::log_err!(dirs::app_home_dir().map(|app_dir| {
|
||||||
if !app_dir.exists() {
|
if !app_dir.exists() {
|
||||||
@@ -93,21 +161,21 @@ pub fn init_config() -> Result<()> {
|
|||||||
|
|
||||||
crate::log_err!(dirs::clash_path().map(|path| {
|
crate::log_err!(dirs::clash_path().map(|path| {
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
help::save_yaml(&path, &IClashTemp::template().0, Some("# Clash Nyanpasuasu"))?;
|
help::save_yaml(&path, &IClashTemp::template().0, Some("# Clash Vergeasu"))?;
|
||||||
}
|
}
|
||||||
<Result<()>>::Ok(())
|
<Result<()>>::Ok(())
|
||||||
}));
|
}));
|
||||||
|
|
||||||
crate::log_err!(dirs::verge_path().map(|path| {
|
crate::log_err!(dirs::verge_path().map(|path| {
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
help::save_yaml(&path, &IVerge::template(), Some("# Clash Nyanpasu"))?;
|
help::save_yaml(&path, &IVerge::template(), Some("# Clash Verge"))?;
|
||||||
}
|
}
|
||||||
<Result<()>>::Ok(())
|
<Result<()>>::Ok(())
|
||||||
}));
|
}));
|
||||||
|
|
||||||
crate::log_err!(dirs::profiles_path().map(|path| {
|
crate::log_err!(dirs::profiles_path().map(|path| {
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
help::save_yaml(&path, &IProfiles::template(), Some("# Clash Nyanpasu"))?;
|
help::save_yaml(&path, &IProfiles::template(), Some("# Clash Verge"))?;
|
||||||
}
|
}
|
||||||
<Result<()>>::Ok(())
|
<Result<()>>::Ok(())
|
||||||
}));
|
}));
|
||||||
@@ -129,7 +197,7 @@ pub fn init_resources(package_info: &PackageInfo) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat", "wintun.dll"];
|
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];
|
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,28 @@
|
|||||||
|
use crate::config::IVerge;
|
||||||
use crate::{config::Config, core::*, utils::init, utils::server};
|
use crate::{config::Config, core::*, utils::init, utils::server};
|
||||||
use crate::{log_err, trace_err};
|
use crate::{log_err, trace_err};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use serde_yaml::Mapping;
|
||||||
|
use std::net::TcpListener;
|
||||||
use tauri::{App, AppHandle, Manager};
|
use tauri::{App, AppHandle, Manager};
|
||||||
|
|
||||||
|
pub fn find_unused_port() -> Result<u16> {
|
||||||
|
match TcpListener::bind("127.0.0.1:0") {
|
||||||
|
Ok(listener) => {
|
||||||
|
let port = listener.local_addr()?.port();
|
||||||
|
Ok(port)
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
let port = Config::verge()
|
||||||
|
.latest()
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port());
|
||||||
|
log::warn!(target: "app", "use default port: {}", port);
|
||||||
|
Ok(port)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 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")]
|
#[cfg(target_os = "macos")]
|
||||||
@@ -12,6 +32,33 @@ pub fn resolve_setup(app: &mut App) {
|
|||||||
|
|
||||||
log_err!(init::init_resources(app.package_info()));
|
log_err!(init::init_resources(app.package_info()));
|
||||||
|
|
||||||
|
// 处理随机端口
|
||||||
|
let enable_random_port = Config::verge().latest().enable_random_port.unwrap_or(false);
|
||||||
|
|
||||||
|
let mut port = Config::verge()
|
||||||
|
.latest()
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port());
|
||||||
|
|
||||||
|
if enable_random_port {
|
||||||
|
port = find_unused_port().unwrap_or(
|
||||||
|
Config::verge()
|
||||||
|
.latest()
|
||||||
|
.verge_mixed_port
|
||||||
|
.unwrap_or(Config::clash().data().get_mixed_port()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Config::verge().data().patch_config(IVerge {
|
||||||
|
verge_mixed_port: Some(port),
|
||||||
|
..IVerge::default()
|
||||||
|
});
|
||||||
|
let _ = Config::verge().data().save_file();
|
||||||
|
let mut mapping = Mapping::new();
|
||||||
|
mapping.insert("mixed-port".into(), port.into());
|
||||||
|
Config::clash().data().patch_config(mapping);
|
||||||
|
let _ = Config::clash().data().save_config();
|
||||||
|
|
||||||
// 启动核心
|
// 启动核心
|
||||||
log::trace!("init config");
|
log::trace!("init config");
|
||||||
log_err!(Config::init_config());
|
log_err!(Config::init_config());
|
||||||
@@ -59,7 +106,8 @@ pub fn create_window(app_handle: &AppHandle) {
|
|||||||
"main".to_string(),
|
"main".to_string(),
|
||||||
tauri::WindowUrl::App("index.html".into()),
|
tauri::WindowUrl::App("index.html".into()),
|
||||||
)
|
)
|
||||||
.title("Clash Nyanpasu")
|
.title("Clash Verge")
|
||||||
|
.visible(false)
|
||||||
.fullscreen(false)
|
.fullscreen(false)
|
||||||
.min_inner_size(600.0, 520.0);
|
.min_inner_size(600.0, 520.0);
|
||||||
|
|
||||||
@@ -91,8 +139,6 @@ pub fn create_window(app_handle: &AppHandle) {
|
|||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use std::time::Duration;
|
|
||||||
use tokio::time::sleep;
|
|
||||||
use window_shadows::set_shadow;
|
use window_shadows::set_shadow;
|
||||||
|
|
||||||
match builder
|
match builder
|
||||||
@@ -126,19 +172,11 @@ pub fn create_window(app_handle: &AppHandle) {
|
|||||||
log::trace!("try to create window");
|
log::trace!("try to create window");
|
||||||
let app_handle = app_handle.clone();
|
let app_handle = app_handle.clone();
|
||||||
|
|
||||||
// 加点延迟避免界面闪一下
|
if let Some(window) = app_handle.get_window("main") {
|
||||||
tauri::async_runtime::spawn(async move {
|
trace_err!(set_shadow(&window, true), "set win shadow");
|
||||||
sleep(Duration::from_millis(888)).await;
|
} else {
|
||||||
|
log::error!(target: "app", "failed to create window, get_window is None")
|
||||||
if let Some(window) = app_handle.get_window("main") {
|
}
|
||||||
trace_err!(set_shadow(&window, true), "set win shadow");
|
|
||||||
trace_err!(window.show(), "set win visible");
|
|
||||||
trace_err!(window.unminimize(), "set win unminimize");
|
|
||||||
trace_err!(window.set_focus(), "set win focus");
|
|
||||||
} else {
|
|
||||||
log::error!(target: "app", "failed to create window, get_window is None")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Err(err) => log::error!(target: "app", "failed to create window, {err}"),
|
Err(err) => log::error!(target: "app", "failed to create window, {err}"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "Clash Nyanpasu",
|
"productName": "Clash Verge",
|
||||||
"version": "1.4.0"
|
"version": "1.4.4"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"distDir": "../dist",
|
"distDir": "../dist",
|
||||||
@@ -10,14 +10,9 @@
|
|||||||
"beforeBuildCommand": "pnpm run web:build"
|
"beforeBuildCommand": "pnpm run web:build"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"systemTray": {
|
|
||||||
"iconPath": "icons/tray-icon.ico",
|
|
||||||
"iconAsTemplate": true
|
|
||||||
},
|
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"targets": "all",
|
"identifier": "io.github.clash-verge-rev.clash-verge-rev",
|
||||||
"identifier": "moe.elaina.clash.nyanpasu",
|
|
||||||
"icon": [
|
"icon": [
|
||||||
"icons/32x32.png",
|
"icons/32x32.png",
|
||||||
"icons/128x128.png",
|
"icons/128x128.png",
|
||||||
@@ -26,38 +21,20 @@
|
|||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
],
|
||||||
"resources": ["resources"],
|
"resources": ["resources"],
|
||||||
"externalBin": ["sidecar/clash", "sidecar/clash-meta"],
|
"externalBin": ["sidecar/clash-meta", "sidecar/clash-meta-alpha"],
|
||||||
"copyright": "© 2022 zzzgydi All Rights Reserved",
|
"copyright": "© 2022 zzzgydi All Rights Reserved",
|
||||||
"category": "DeveloperTool",
|
"category": "DeveloperTool",
|
||||||
"shortDescription": "A Clash GUI based on tauri.",
|
"shortDescription": "A Clash Meta GUI based on tauri.",
|
||||||
"longDescription": "A Clash GUI based on tauri.",
|
"longDescription": "A Clash Meta GUI based on tauri."
|
||||||
"deb": {
|
|
||||||
"depends": ["openssl"]
|
|
||||||
},
|
|
||||||
"macOS": {
|
|
||||||
"frameworks": [],
|
|
||||||
"minimumSystemVersion": "",
|
|
||||||
"exceptionDomain": "",
|
|
||||||
"signingIdentity": null,
|
|
||||||
"entitlements": null
|
|
||||||
},
|
|
||||||
"windows": {
|
|
||||||
"certificateThumbprint": null,
|
|
||||||
"digestAlgorithm": "sha256",
|
|
||||||
"timestampUrl": "",
|
|
||||||
"wix": {
|
|
||||||
"language": ["zh-CN", "en-US", "ru-RU"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
"https://ghproxy.com/https://github.com/keiko233/clash-nyanpasu/releases/download/updater/update-proxy.json",
|
"https://mirror.ghproxy.com/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update-proxy.json",
|
||||||
"https://github.com/keiko233/clash-nyanpasu/releases/download/updater/update.json"
|
"https://github.com/clash-verge-rev/clash-verge-rev/releases/download/updater/update.json"
|
||||||
],
|
],
|
||||||
"dialog": false,
|
"dialog": false,
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDlBMUM0NjMxREZCNDRGMjYKUldRbVQ3VGZNVVljbW43N0FlWjA4UkNrbTgxSWxSSXJQcExXNkZjUTlTQkIyYkJzL0tsSWF2d0cK"
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEQyOEMyRjBCQkVGOUJEREYKUldUZnZmbStDeStNMHU5Mmo1N24xQXZwSVRYbXA2NUpzZE5oVzlqeS9Bc0t6RVV4MmtwVjBZaHgK"
|
||||||
},
|
},
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
"shell": {
|
"shell": {
|
||||||
@@ -71,6 +48,9 @@
|
|||||||
},
|
},
|
||||||
"globalShortcut": {
|
"globalShortcut": {
|
||||||
"all": true
|
"all": true
|
||||||
|
},
|
||||||
|
"clipboard": {
|
||||||
|
"all": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"windows": [],
|
"windows": [],
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"tauri": {
|
||||||
|
"systemTray": {
|
||||||
|
"iconPath": "icons/tray-icon.png"
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"targets": ["deb", "appimage", "updater"],
|
||||||
|
"deb": {
|
||||||
|
"depends": ["openssl"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"tauri": {
|
||||||
|
"systemTray": {
|
||||||
|
"iconPath": "icons/icon.png",
|
||||||
|
"iconAsTemplate": true
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"targets": ["app", "dmg", "updater"],
|
||||||
|
"macOS": {
|
||||||
|
"frameworks": [],
|
||||||
|
"minimumSystemVersion": "",
|
||||||
|
"exceptionDomain": "",
|
||||||
|
"signingIdentity": null,
|
||||||
|
"entitlements": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"tauri": {
|
||||||
|
"systemTray": {
|
||||||
|
"iconPath": "icons/tray-icon.png"
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"targets": ["nsis", "updater"],
|
||||||
|
"windows": {
|
||||||
|
"certificateThumbprint": null,
|
||||||
|
"digestAlgorithm": "sha256",
|
||||||
|
"timestampUrl": "",
|
||||||
|
"webviewInstallMode": {
|
||||||
|
"type": "embedBootstrapper",
|
||||||
|
"silent": true
|
||||||
|
},
|
||||||
|
"nsis": {
|
||||||
|
"displayLanguageSelector": true,
|
||||||
|
"installerIcon": "icons/icon.ico",
|
||||||
|
"languages": ["SimpChinese", "English"],
|
||||||
|
"license": "../LICENSE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 57 KiB |