From 090e4d3cfa05b49ff6df62dbe505b99f087b8a23 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Thu, 8 Aug 2024 10:09:38 +0800 Subject: [PATCH] adjust resources path --- .github/workflows/build.yml | 8 +++- aur/mihomo-party-electron/PKGBUILD | 38 +++++++++++++++++++ .../mihomo-party.desktop | 10 +++++ .../mihomo-party.install | 14 +++++++ aur/mihomo-party-electron/mihomo-party.sh | 12 ++++++ package.json | 2 +- src/main/utils/dirs.ts | 2 +- 7 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 aur/mihomo-party-electron/PKGBUILD create mode 100644 aur/mihomo-party-electron/mihomo-party.desktop create mode 100644 aur/mihomo-party-electron/mihomo-party.install create mode 100644 aur/mihomo-party-electron/mihomo-party.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0ed872..267ce3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,6 +101,9 @@ jobs: dist/*.deb dist/*.rpm if-no-files-found: error + - name: Rename + if: startsWith(github.ref, 'refs/tags/v') + run: mv dist/linux-unpacked/resources/app.asar dist/mihomo-party-linux-$(echo ${{ github.ref }} | tr -d 'refs/tags/v')-${{ matrix.arch }}.asar - name: Publish Release if: startsWith(github.ref, 'refs/tags/v') uses: softprops/action-gh-release@v2 @@ -108,6 +111,7 @@ jobs: files: | dist/*.deb dist/*.rpm + dist/*.asar token: ${{ secrets.GITHUB_TOKEN }} macos: @@ -162,6 +166,7 @@ jobs: fail-fast: false matrix: pkgname: + - mihomo-party-electron - mihomo-party-bin - mihomo-party if: startsWith(github.ref, 'refs/tags/v') @@ -175,10 +180,11 @@ jobs: sed -i "s/pkgver=.*/pkgver=$(echo ${{ github.ref }} | tr -d 'refs/tags/v')/" aur/mihomo-party-bin/PKGBUILD sed -i "s/pkgver=.*/pkgver=$(echo ${{ github.ref }} | tr -d 'refs/tags/v')/" aur/mihomo-party/PKGBUILD - name: Update Checksums - if: ${{ matrix.pkgname == 'mihomo-party' }} + if: matrix.pkgname == 'mihomo-party' || matrix.pkgname == 'mihomo-party-electron' run: | wget https://github.com/pompurin404/mihomo-party/archive/refs/tags/$(echo ${{ github.ref }} | tr -d 'refs/tags/').tar.gz -O release.tar.gz sed -i "s/sha256sums=.*/sha256sums=(\"$(sha256sum ./release.tar.gz | awk '{print $1}')\")/" aur/mihomo-party/PKGBUILD + sed -i "s/sha256sums=.*/sha256sums=(\"$(sha256sum ./release.tar.gz | awk '{print $1}')\")/" aur/mihomo-party-electron/PKGBUILD - name: Update Checksums if: ${{ matrix.pkgname == 'mihomo-party-bin' }} run: | diff --git a/aur/mihomo-party-electron/PKGBUILD b/aur/mihomo-party-electron/PKGBUILD new file mode 100644 index 0000000..8c59694 --- /dev/null +++ b/aur/mihomo-party-electron/PKGBUILD @@ -0,0 +1,38 @@ +pkgname=mihomo-party-electron +_pkgname=mihomo-party +pkgver=0.1.3 +pkgrel=1 +pkgdesc="Another Mihomo GUI." +arch=('x86_64' 'aarch64') +url="https://github.com/pompurin404/mihomo-party" +license=('GPL3') +conflicts=("mihomo-party-git" 'mihomo-party-bin' 'mihomo-party') +depends=('electron' 'gtk3' 'libnotify' 'nss' 'libxss' 'libxtst' 'xdg-utils' 'at-spi2-core' 'util-linux-libs' 'libsecret') +optdepends=('libappindicator-gtk3: Allow mihomo-party to extend a menu via Ayatana indicators in Unity, KDE or Systray (GTK+ 3 library).') +makedepends=('nodejs' 'pnpm' 'libxcrypt-compat' 'asar') +install=$_pkgname.install +source=("${_pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz") +sha256sums=("52d761e9432e17477acb8adb5744676df946476e0eb5210fee2b6d45f497f218") +options=('!lto') + +prepare(){ + cd $srcdir/${_pkgname}-${pkgver} + pnpm install +} + +build(){ + cd $srcdir/${_pkgname}-${pkgver} + pnpm build:linux deb +} + +package() { + asar extract $srcdir/${_pkgname}-${pkgver}/dist/linux-unpacked/resources/app.asar ${pkgdir}/opt/mihomo-party + chmod +x ${pkgdir}/opt/mihomo-party/resources/sidecar/mihomo + chmod +x ${pkgdir}/opt/mihomo-party/resources/sidecar/mihomo-alpha + cd ${pkgdir}/../.. + install -Dm755 "${_pkgname}.sh" "${pkgdir}/usr/bin/${_pkgname}" + install -Dm644 "${_pkgname}.desktop" "${pkgdir}/usr/share/applications/${_pkgname}.desktop" + install -Dm644 "$srcdir/${_pkgname}-${pkgver}/dist/linux-unpacked/resources/icon.png" "${pkgdir}/usr/share/icons/hicolor/512x512/apps/${_pkgname}.png" + + chown -R root:root ${pkgdir} +} \ No newline at end of file diff --git a/aur/mihomo-party-electron/mihomo-party.desktop b/aur/mihomo-party-electron/mihomo-party.desktop new file mode 100644 index 0000000..1f82b0d --- /dev/null +++ b/aur/mihomo-party-electron/mihomo-party.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=mihomo-party +Exec=mihomo-party %U +Terminal=false +Type=Application +Icon=mihomo-party +StartupWMClass=mihomo-party +MimeType=x-scheme-handler/clash;x-scheme-handler/mihomo; +Comment=Mihomo Party +Categories=Utility; diff --git a/aur/mihomo-party-electron/mihomo-party.install b/aur/mihomo-party-electron/mihomo-party.install new file mode 100644 index 0000000..218d794 --- /dev/null +++ b/aur/mihomo-party-electron/mihomo-party.install @@ -0,0 +1,14 @@ +# Colored makepkg-like functions +note() { + printf "${_blue}==>${_yellow} NOTE:${_bold} %s${_all_off}\n" "$1" +} + +_all_off="$(tput sgr0)" +_bold="${_all_off}$(tput bold)" +_blue="${_bold}$(tput setaf 4)" +_yellow="${_bold}$(tput setaf 3)" + +post_install() { + note "Custom flags should be put directly in: ~/.config/mihomo-party-flags.conf" + note "The launcher is called: 'mihomo-party'" +} \ No newline at end of file diff --git a/aur/mihomo-party-electron/mihomo-party.sh b/aur/mihomo-party-electron/mihomo-party.sh new file mode 100644 index 0000000..f4ca383 --- /dev/null +++ b/aur/mihomo-party-electron/mihomo-party.sh @@ -0,0 +1,12 @@ +#!/usr/bin/bash + +XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-~/.config} + +# Allow users to override command-line options +if [[ -f "${XDG_CONFIG_HOME}/mihomo-party-flags.conf" ]]; then + mapfile -t MIHOMO_PARTY_USER_FLAGS <<<"$(grep -v '^#' "${XDG_CONFIG_HOME}/mihomo-party-flags.conf")" + echo "User flags:" ${MIHOMO_PARTY_USER_FLAGS[@]} +fi + +# Launch +exec electron /opt/mihomo-party ${MIHOMO_PARTY_USER_FLAGS[@]} "$@" diff --git a/package.json b/package.json index 6d3f81c..83a0b1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mihomo-party", - "version": "0.2.0", + "version": "0.2.1", "description": "Mihomo Party", "main": "./out/main/index.js", "author": "mihomo-party", diff --git a/src/main/utils/dirs.ts b/src/main/utils/dirs.ts index b7a60e4..2883f52 100644 --- a/src/main/utils/dirs.ts +++ b/src/main/utils/dirs.ts @@ -12,7 +12,7 @@ export function resourcesDir(): string { if (is.dev) { return path.join(__dirname, '../../resources') } else { - return path.join(process.resourcesPath) + return path.join(app.getAppPath(), 'resources') } }