17 changed files with 386 additions and 72 deletions
+139
View File
@@ -0,0 +1,139 @@
name: Build iOS IPA
on:
workflow_dispatch:
push:
branches: ["main"]
tags: ["v*"]
jobs:
ios:
name: iOS Build (IPA)
runs-on: macos-latest
permissions:
contents: write
env:
APPLE_DEVELOPMENT_TEAM: "ABCDE12345"
steps:
- uses: actions/checkout@v4
- name: 对齐版本号
id: ver
shell: bash
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
V="${GITHUB_REF_NAME#v}"
else
V="$(node -p "require('./src-tauri/tauri.conf.json').version")"
fi
echo "version=$V" >> "$GITHUB_OUTPUT"
node -e "const fs=require('fs');for(const p of ['src-tauri/tauri.conf.json','package.json']){const j=JSON.parse(fs.readFileSync(p));j.version=process.argv[1];fs.writeFileSync(p,JSON.stringify(j,null,2)+'\n')}" "$V"
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios,aarch64-apple-ios-sim
- uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
key: ios-build
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 初始化 iOS Xcode 工程
run: |
pnpm tauri ios init --ci || pnpm tauri ios init
env:
APPLE_DEVELOPMENT_TEAM: "ABCDE12345"
- name: 构建 iOS 应用与打包 IPA
shell: bash
env:
APPLE_DEVELOPMENT_TEAM: "ABCDE12345"
run: |
V="${{ steps.ver.outputs.version }}"
mkdir -p artifacts
# 1. 确保前端编译产物就绪
pnpm build
# 2. 执行 Tauri iOS 自动化构建(免证书签名)
echo "=== 执行 Tauri iOS 构建 (--no-sign) ==="
pnpm tauri ios build --no-sign --ci || true
# 3. 检查是否已直接生成 IPA
IPA_PATH=$(find src-tauri/gen/apple -name "*.ipa" 2>/dev/null | head -n 1 || true)
if [ -n "$IPA_PATH" ] && [ -f "$IPA_PATH" ]; then
echo "=== 发现生成的 IPA: $IPA_PATH ==="
cp "$IPA_PATH" "artifacts/HGhub_${V}_ios.ipa"
fi
# 4. 若未直接生成 IPA,寻找 .app 或通过 xcodebuild 归档编译
if [ ! -s "artifacts/HGhub_${V}_ios.ipa" ]; then
APP_PATH=$(find src-tauri/gen/apple -name "*.app" -type d 2>/dev/null | head -n 1 || true)
if [ -z "$APP_PATH" ]; then
echo "=== 未在 gen/apple 找到 .app,调用 xcodebuild 编译 Release ==="
PROJECT_PATH=$(find src-tauri/gen/apple -name "*.xcodeproj" 2>/dev/null | head -n 1 || true)
SCHEME_NAME=$(xcodebuild -list -project "$PROJECT_PATH" 2>/dev/null | awk '/Schemes:/{flag=1;next} flag && NF{print $1;exit}' || true)
if [ -z "$SCHEME_NAME" ]; then
SCHEME_NAME="huangguo-client_iOS"
fi
echo "项目: $PROJECT_PATH, Scheme: $SCHEME_NAME"
xcodebuild build \
-project "$PROJECT_PATH" \
-scheme "$SCHEME_NAME" \
-configuration Release \
-destination "generic/platform=iOS" \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
-derivedDataPath build_output
APP_PATH=$(find build_output -name "*.app" -type d 2>/dev/null | head -n 1 || true)
fi
if [ -n "$APP_PATH" ] && [ -d "$APP_PATH" ]; then
echo "=== 打包 APP 目录: $APP_PATH 为 IPA ==="
rm -rf Payload
mkdir -p Payload
cp -r "$APP_PATH" Payload/
zip -qr "artifacts/HGhub_${V}_ios.ipa" Payload
rm -rf Payload
fi
fi
if [ -s "artifacts/HGhub_${V}_ios.ipa" ]; then
echo "=== IPA 打包成功 ==="
ls -lh artifacts/
else
echo "::error::未能生成有效的 iOS IPA 文件"
exit 1
fi
- name: 上传 IPA 产物
uses: actions/upload-artifact@v4
with:
name: HGhub-iOS-IPA
path: artifacts/*
if-no-files-found: error
- name: 发布 iOS GitHub Release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
V="${{ steps.ver.outputs.version }}"
TAG="v${V}-ios"
gh release create "$TAG" artifacts/*.ipa \
--title "HGhub v${V} iOS 版" \
--notes "HGhub iOS 移动端无证书安装包 (.ipa)。支持 TrollStore、AltStore、Sideloadly 或第三方签名工具安装运行。" \
--prerelease || gh release upload "$TAG" artifacts/*.ipa --clobber
+148
View File
@@ -0,0 +1,148 @@
name: Build macOS Release
on:
workflow_dispatch:
push:
branches: ["main"]
tags: ["v*"]
jobs:
macos:
name: macOS (${{ matrix.name }})
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
name: Apple Silicon (arm64)
arch: arm64
- target: x86_64-apple-darwin
name: Intel (x64)
arch: x64
- target: universal-apple-darwin
name: Universal (通用版)
arch: universal
steps:
- uses: actions/checkout@v4
- name: 对齐版本号
id: ver
shell: bash
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
V="${GITHUB_REF_NAME#v}"
else
V="$(node -p "require('./src-tauri/tauri.conf.json').version")"
fi
echo "version=$V" >> "$GITHUB_OUTPUT"
node -e "const fs=require('fs');for(const p of ['src-tauri/tauri.conf.json','package.json']){const j=JSON.parse(fs.readFileSync(p));j.version=process.argv[1];fs.writeFileSync(p,JSON.stringify(j,null,2)+'\n')}" "$V"
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin
- uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
key: macos-${{ matrix.target }}
- name: 安装前端依赖
run: pnpm install --frozen-lockfile
- name: 构建 macOS 应用 (DMG + APP)
run: |
pnpm tauri build --config src-tauri/tauri.macos.conf.json --target ${{ matrix.target }}
- name: 整理构建产物
shell: bash
run: |
V="${{ steps.ver.outputs.version }}"
mkdir -p artifacts
# 收集 dmg 安装包
found_dmg=0
for f in $(find src-tauri/target -name '*.dmg'); do
echo "发现 DMG: $f"
cp "$f" "artifacts/HGhub_${V}_${{ matrix.arch }}.dmg"
found_dmg=1
done
# 打包 .app 绿色压缩包(便于不需要 DMG 安装的用户直接拖拽)
for app in $(find src-tauri/target -name 'HGhub.app' -type d); do
echo "发现 APP: $app"
tar -czf "artifacts/HGhub_${V}_${{ matrix.arch }}.app.tar.gz" -C "$(dirname "$app")" "HGhub.app"
done
ls -lh artifacts/
if [ "$found_dmg" -eq 0 ]; then
echo "::error::未找到 DMG 构建产物"
exit 1
fi
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: HGhub-macOS-${{ matrix.arch }}
path: artifacts/*
if-no-files-found: error
publish-release:
name: 发布 GitHub Release
needs: [macos]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: 下载所有 macOS 产物
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: 查看产物列表
run: ls -lh artifacts
- name: 获取版本号
id: ver
run: |
V="$(node -p "require('./src-tauri/tauri.conf.json').version")"
echo "version=$V" >> "$GITHUB_OUTPUT"
- name: 发布 Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.ver.outputs.version }}-macos
name: HGhub v${{ steps.ver.outputs.version }} macOS 专属版
body: |
## HGhub macOS 编译发布版 (v${{ steps.ver.outputs.version }})
本项目为 [Minireel/HGhub](https://github.com/Minireel/HGhub) 官方源码针对 macOS 平台的编译产物。
原项目已在 PR #1 完成 macOS 适配支持,但官方尚未在 Release 页面发布 Mac 版产物。
### 下载说明
- **Apple Silicon (M1/M2/M3/M4 系列芯片)**: 推荐下载 `HGhub_${{ steps.ver.outputs.version }}_arm64.dmg`
- **Intel 芯片**: 推荐下载 `HGhub_${{ steps.ver.outputs.version }}_x64.dmg`
- **通用双架构版 (全机型支持)**: 推荐下载 `HGhub_${{ steps.ver.outputs.version }}_universal.dmg`
### macOS 首次打开说明(绕过未签名提示)
由于开源个人构建未购买苹果开发者企业证书签名与公证,首次打开若提示“已损坏”或“无法打开”,请在「终端」中执行以下命令清除隔离属性:
```bash
sudo xattr -rd com.apple.quarantine /Applications/HGhub.app
```
files: artifacts/*
fail_on_unmatched_files: true
draft: false
prerelease: false
+2
View File
@@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="theme-color" content="#1a1a1a" />
<title>HGhub · 黄果短剧</title>
<script>
+5 -2
View File
@@ -14,7 +14,10 @@
"android:init": "tauri android init",
"android:icons": "node scripts/sync-android-icons.mjs",
"android:dev": "tauri android dev",
"android:build": "tauri android build"
"android:build": "tauri android build",
"ios:init": "tauri ios init",
"ios:dev": "tauri ios dev",
"ios:build": "tauri ios build"
},
"dependencies": {
"@tauri-apps/api": "^2.12.4",
@@ -26,7 +29,7 @@
},
"devDependencies": {
"@tailwindcss/vite": "4.1.17",
"@tauri-apps/cli": "2.10.1",
"@tauri-apps/cli": "2.12.4",
"@types/node": "22.19.17",
"@types/react": "19.2.7",
"@types/react-dom": "19.2.3",
+54 -49
View File
@@ -31,8 +31,8 @@ importers:
specifier: 4.1.17
version: 4.1.17(vite@7.3.2(@types/node@22.19.17)(jiti@2.7.0)(lightningcss@1.30.2))
'@tauri-apps/cli':
specifier: 2.10.1
version: 2.10.1
specifier: 2.12.4
version: 2.12.4
'@types/node':
specifier: 22.19.17
version: 22.19.17
@@ -544,74 +544,79 @@ packages:
'@tauri-apps/api@2.12.4':
resolution: {integrity: sha512-pVmfis+4zT8H0Qhp3xPZx9Ju7kpzvA6rr/PSJPyuwfvucTQ8sVt61NYU9KMkK703UFlYadFmjKA4HhybOtN0gg==}
'@tauri-apps/cli-darwin-arm64@2.10.1':
resolution: {integrity: sha512-Z2OjCXiZ+fbYZy7PmP3WRnOpM9+Fy+oonKDEmUE6MwN4IGaYqgceTjwHucc/kEEYZos5GICve35f7ZiizgqEnQ==}
'@tauri-apps/cli-darwin-arm64@2.12.4':
resolution: {integrity: sha512-OxqKSckIkoJ6vX2AjifIJpTasFC0Hbdoo7gEiCmAjauABO3U8m2MRsLWe+QTiBwDx1mIrvgA+rvI7tvDnbnHVg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
'@tauri-apps/cli-darwin-x64@2.10.1':
resolution: {integrity: sha512-V/irQVvjPMGOTQqNj55PnQPVuH4VJP8vZCN7ajnj+ZS8Kom1tEM2hR3qbbIRoS3dBKs5mbG8yg1WC+97dq17Pw==}
'@tauri-apps/cli-darwin-x64@2.12.4':
resolution: {integrity: sha512-fz76/77wMMJOaaUN6n3CybRG0P/MTEjjqYk81mGPyhi9m6Ue5T+LWBnJP/AkPooNatBPI2vtulGqomyMJ44lCQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
'@tauri-apps/cli-linux-arm-gnueabihf@2.10.1':
resolution: {integrity: sha512-Hyzwsb4VnCWKGfTw+wSt15Z2pLw2f0JdFBfq2vHBOBhvg7oi6uhKiF87hmbXOBXUZaGkyRDkCHsdzJcIfoJC2w==}
'@tauri-apps/cli-linux-arm-gnueabihf@2.12.4':
resolution: {integrity: sha512-K0w8Bof6Lt8QKLAYhRy0yy36ZH5iA/35VuSOvnxyjvCUZ+A3JKsUTlALviH/sVgAlisaPzzmeJSH8XOn4Q2HBA==}
engines: {node: '>= 10'}
cpu: [arm]
os: [linux]
'@tauri-apps/cli-linux-arm64-gnu@2.10.1':
resolution: {integrity: sha512-OyOYs2t5GkBIvyWjA1+h4CZxTcdz1OZPCWAPz5DYEfB0cnWHERTnQ/SLayQzncrT0kwRoSfSz9KxenkyJoTelA==}
'@tauri-apps/cli-linux-arm64-gnu@2.12.4':
resolution: {integrity: sha512-j5rOnjmRUwWrm1oosf0zBYl4D+fqydgUROFCk0hvKZxvbTT8SOERes0QB7rBV/XWNy+kM6pCKzb3oSm2sRglzg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@tauri-apps/cli-linux-arm64-musl@2.10.1':
resolution: {integrity: sha512-MIj78PDDGjkg3NqGptDOGgfXks7SYJwhiMh8SBoZS+vfdz7yP5jN18bNaLnDhsVIPARcAhE1TlsZe/8Yxo2zqg==}
'@tauri-apps/cli-linux-arm64-musl@2.12.4':
resolution: {integrity: sha512-aOue3Fy6Jb7+oWcfAVUsVHfeTybSCt2CZoU06aO4jv4d2Ks/KnaTPwMAK3CLEduGOvBLY1lbBBrIyomqLLH5Sg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@tauri-apps/cli-linux-riscv64-gnu@2.10.1':
resolution: {integrity: sha512-X0lvOVUg8PCVaoEtEAnpxmnkwlE1gcMDTqfhbefICKDnOTJ5Est3qL0SrWxizDackIOKBcvtpejrSiVpuJI1kw==}
'@tauri-apps/cli-linux-riscv64-gnu@2.12.4':
resolution: {integrity: sha512-Fx6GShY/RvST+t6LMlTHAwd66+1tEaAAGrnU7cysVfaiRP1BKng5Vl6rVmO6rSLOA1Sp1dRzNYM4f0OWQGb7qA==}
engines: {node: '>= 10'}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@tauri-apps/cli-linux-x64-gnu@2.10.1':
resolution: {integrity: sha512-2/12bEzsJS9fAKybxgicCDFxYD1WEI9kO+tlDwX5znWG2GwMBaiWcmhGlZ8fi+DMe9CXlcVarMTYc0L3REIRxw==}
'@tauri-apps/cli-linux-x64-gnu@2.12.4':
resolution: {integrity: sha512-tNzZSa79Z1nRpHxEpQ38lsAFpKlFlYvoXzjTV+lRRn/zSf3wrdUC3wnLcq2XEadchPu4ttK0zivhYzr+XGD19Q==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@tauri-apps/cli-linux-x64-musl@2.10.1':
resolution: {integrity: sha512-Y8J0ZzswPz50UcGOFuXGEMrxbjwKSPgXftx5qnkuMs2rmwQB5ssvLb6tn54wDSYxe7S6vlLob9vt0VKuNOaCIQ==}
'@tauri-apps/cli-linux-x64-musl@2.12.4':
resolution: {integrity: sha512-jmZ1pr0xEqUhuEusWtt9Yt+GF6lCnGHUmIL+KIknpbjK/XQ2qkhDBhaxK/JMHM2A8dAacVXCxXJk2EXpwhQUfA==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [musl]
'@tauri-apps/cli-win32-arm64-msvc@2.10.1':
resolution: {integrity: sha512-iSt5B86jHYAPJa/IlYw++SXtFPGnWtFJriHn7X0NFBVunF6zu9+/zOn8OgqIWSl8RgzhLGXQEEtGBdR4wzpVgg==}
'@tauri-apps/cli-win32-arm64-msvc@2.12.4':
resolution: {integrity: sha512-fGo8pgEHZxdSYgZ/J98m1usJ7NHKmKbq7k6uT0x1rpOq6Bg2YVzzpaAblWk710f5LHYBJIL5QIFS5IrD+4gmTg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
'@tauri-apps/cli-win32-ia32-msvc@2.10.1':
resolution: {integrity: sha512-gXyxgEzsFegmnWywYU5pEBURkcFN/Oo45EAwvZrHMh+zUSEAvO5E8TXsgPADYm31d1u7OQU3O3HsYfVBf2moHw==}
'@tauri-apps/cli-win32-ia32-msvc@2.12.4':
resolution: {integrity: sha512-ezl8sQIcjYsye3TUnTH5VcWmWzccZASlQm7hlZt0dYyj1XD0qpVW47u2xYVrIKui0F8uQv/7QGZixdWiClBsbg==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
'@tauri-apps/cli-win32-x64-msvc@2.10.1':
resolution: {integrity: sha512-6Cn7YpPFwzChy0ERz6djKEmUehWrYlM+xTaNzGPgZocw3BD7OfwfWHKVWxXzdjEW2KfKkHddfdxK1XXTYqBRLg==}
'@tauri-apps/cli-win32-x64-msvc@2.12.4':
resolution: {integrity: sha512-DJhDeCqjLDNMWYFy7ZS8cfeAHX2RK0RbQMLiA3bMVVkXRDJ4NBYiHriGqsUhsr9iG41aTb+dJGkFPmPw1gWwVw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
'@tauri-apps/cli@2.10.1':
resolution: {integrity: sha512-jQNGF/5quwORdZSSLtTluyKQ+o6SMa/AUICfhf4egCGFdMHqWssApVgYSbg+jmrZoc8e1DscNvjTnXtlHLS11g==}
'@tauri-apps/cli@2.12.4':
resolution: {integrity: sha512-JI9bHfudSRJikGOrjbXEm6RjzzvmKuLc+JixB1NE8hNzQkNlCCIC3pTES3uypkR9lxHrsbxzcnSwhI2IxBQphw==}
engines: {node: '>= 10'}
hasBin: true
@@ -1303,52 +1308,52 @@ snapshots:
'@tauri-apps/api@2.12.4': {}
'@tauri-apps/cli-darwin-arm64@2.10.1':
'@tauri-apps/cli-darwin-arm64@2.12.4':
optional: true
'@tauri-apps/cli-darwin-x64@2.10.1':
'@tauri-apps/cli-darwin-x64@2.12.4':
optional: true
'@tauri-apps/cli-linux-arm-gnueabihf@2.10.1':
'@tauri-apps/cli-linux-arm-gnueabihf@2.12.4':
optional: true
'@tauri-apps/cli-linux-arm64-gnu@2.10.1':
'@tauri-apps/cli-linux-arm64-gnu@2.12.4':
optional: true
'@tauri-apps/cli-linux-arm64-musl@2.10.1':
'@tauri-apps/cli-linux-arm64-musl@2.12.4':
optional: true
'@tauri-apps/cli-linux-riscv64-gnu@2.10.1':
'@tauri-apps/cli-linux-riscv64-gnu@2.12.4':
optional: true
'@tauri-apps/cli-linux-x64-gnu@2.10.1':
'@tauri-apps/cli-linux-x64-gnu@2.12.4':
optional: true
'@tauri-apps/cli-linux-x64-musl@2.10.1':
'@tauri-apps/cli-linux-x64-musl@2.12.4':
optional: true
'@tauri-apps/cli-win32-arm64-msvc@2.10.1':
'@tauri-apps/cli-win32-arm64-msvc@2.12.4':
optional: true
'@tauri-apps/cli-win32-ia32-msvc@2.10.1':
'@tauri-apps/cli-win32-ia32-msvc@2.12.4':
optional: true
'@tauri-apps/cli-win32-x64-msvc@2.10.1':
'@tauri-apps/cli-win32-x64-msvc@2.12.4':
optional: true
'@tauri-apps/cli@2.10.1':
'@tauri-apps/cli@2.12.4':
optionalDependencies:
'@tauri-apps/cli-darwin-arm64': 2.10.1
'@tauri-apps/cli-darwin-x64': 2.10.1
'@tauri-apps/cli-linux-arm-gnueabihf': 2.10.1
'@tauri-apps/cli-linux-arm64-gnu': 2.10.1
'@tauri-apps/cli-linux-arm64-musl': 2.10.1
'@tauri-apps/cli-linux-riscv64-gnu': 2.10.1
'@tauri-apps/cli-linux-x64-gnu': 2.10.1
'@tauri-apps/cli-linux-x64-musl': 2.10.1
'@tauri-apps/cli-win32-arm64-msvc': 2.10.1
'@tauri-apps/cli-win32-ia32-msvc': 2.10.1
'@tauri-apps/cli-win32-x64-msvc': 2.10.1
'@tauri-apps/cli-darwin-arm64': 2.12.4
'@tauri-apps/cli-darwin-x64': 2.12.4
'@tauri-apps/cli-linux-arm-gnueabihf': 2.12.4
'@tauri-apps/cli-linux-arm64-gnu': 2.12.4
'@tauri-apps/cli-linux-arm64-musl': 2.12.4
'@tauri-apps/cli-linux-riscv64-gnu': 2.12.4
'@tauri-apps/cli-linux-x64-gnu': 2.12.4
'@tauri-apps/cli-linux-x64-musl': 2.12.4
'@tauri-apps/cli-win32-arm64-msvc': 2.12.4
'@tauri-apps/cli-win32-ia32-msvc': 2.12.4
'@tauri-apps/cli-win32-x64-msvc': 2.12.4
'@types/babel__core@7.20.5':
dependencies:
+3
View File
@@ -42,6 +42,9 @@
],
"android": {
"minSdkVersion": 24
},
"iOS": {
"developmentTeam": "ABCDE12345"
}
}
}
+11 -8
View File
@@ -82,8 +82,9 @@ function StackPage({ page, onBack, wide, top, bottomInset }: {
/* ============ 应用主体 ============ */
function AppBody() {
const { platform, tab, setTab, stack, pop, loginOpen, setLoginOpen, fs } = useStore();
const isMobile = platform === "android" || platform === "ios";
const mainRef = useRef<HTMLDivElement>(null);
const [wide, setWide] = useState(platform !== "android");
const [wide, setWide] = useState(!isMobile);
const [collapsed, setCollapsed] = useState(false);
useLayoutEffect(() => {
@@ -116,15 +117,15 @@ function AppBody() {
const vis = (k: Tab) => (tab === k ? "absolute inset-0" : "absolute inset-0 invisible pointer-events-none");
const pageActive = stack.length === 0 && !loginOpen;
const bottomInset = platform === "android" ? (fs ? 0 : 40) : 14;
const bottomInset = isMobile ? (fs ? 0 : 40) : 14;
/* 栈页(从搜索/分类/我的进入的播放页、图文页)没有底栏,
底部只让出安全区。之前多留了 20px,视频底边会露出一条
「底栏」似的窄缝(底部的压暗渐变到不了屏幕最底)。 */
const stackInset = platform === "android" ? 0 : 14;
const stackInset = isMobile ? 0 : 14;
return (
<div className={`absolute inset-0 flex bg-canvas plat-${platform}`}>
{platform !== "android" && <DesktopRail collapsed={collapsed} />}
{!isMobile && <DesktopRail collapsed={collapsed} />}
<div ref={mainRef} className="relative flex-1 min-w-0 overflow-hidden win-main">
<div className={vis("home")}><Home active={pageActive && tab === "home"} bottomInset={bottomInset} /></div>
<div className={vis("search")}><Search active={pageActive && tab === "search"} wide={wide} /></div>
@@ -137,7 +138,7 @@ function AppBody() {
</div>
))}
{platform === "android" && !fs && stack.length === 0 && <TabBar />}
{isMobile && !fs && stack.length === 0 && <TabBar />}
</div>
</div>
);
@@ -214,9 +215,10 @@ function ShellInner({ collapsed, theater }: { collapsed: boolean; theater: boole
/* ============ 移动端(无壳) ============ */
function MobileShell() {
const { platform } = useStore();
return (
<div className="absolute inset-0 flex flex-col bg-canvas plat-android"
style={{ "--sat": "max(env(safe-area-inset-top), 8px)", "--sab": "max(env(safe-area-inset-bottom), 6px)" } as React.CSSProperties}>
<div className={`absolute inset-0 flex flex-col bg-canvas plat-${platform}`}
style={{ "--sat": "max(env(safe-area-inset-top), 12px)", "--sab": "max(env(safe-area-inset-bottom), 16px)" } as React.CSSProperties}>
<div className="relative flex-1 min-h-0">
<AppBody />
</div>
@@ -227,6 +229,7 @@ function MobileShell() {
/* ============ 入口 ============ */
export default function App() {
const { platform, loginOpen, setLoginOpen, tab, setTab, stack, pop, fs, setFs } = useStore();
const isMobile = platform === "android" || platform === "ios";
/* —— 安卓硬件返回键 ——
层级:全屏 → 面板/弹层 → 登录框 → 页面栈 → 回首页 → 退出应用。
@@ -271,7 +274,7 @@ export default function App() {
return (
<>
{platform === "android" ? <MobileShell /> : <DesktopShell />}
{isMobile ? <MobileShell /> : <DesktopShell />}
<LoginModal />
<ToastHost />
{/* 登录遮罩键盘处理占位 */}
+13 -3
View File
@@ -9,15 +9,25 @@ import type {
export const APP_VERSION = __APP_VERSION__;
const ua = navigator.userAgent;
export const isIos =
/iPhone|iPad|iPod/i.test(ua) ||
(typeof navigator.platform === "string" && navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
export const isAndroid = /Android/i.test(ua);
export const isMacos = /Macintosh|Mac OS X/i.test(ua);
export const platform: "android" | "windows" | "macos" = isAndroid ? "android" : isMacos ? "macos" : "windows";
export const isMobile = isIos || isAndroid;
export const isMacos = !isIos && /Macintosh|Mac OS X/i.test(ua);
export const platform: "android" | "ios" | "windows" | "macos" = isIos
? "ios"
: isAndroid
? "android"
: isMacos
? "macos"
: "windows";
/** 自定义协议地址随平台不同(见 tauri `register_asynchronous_uri_scheme_protocol` 文档):
* Windows / Android → `http://<scheme>.localhost`
* macOS / iOS / Linux → `<scheme>://localhost`
* Rust 侧 `src-tauri/src/lib.rs` 里改写 m3u8 用的 scheme 必须与此一致。 */
export const LOCAL = isMacos ? "hg://localhost" : "http://hg.localhost";
export const LOCAL = isMacos || isIos ? "hg://localhost" : "http://hg.localhost";
/** src 是否已是本地协议地址(避免在详情页把代理地址再包一层) */
export const isLocalMedia = (src: string) => src.startsWith(`${LOCAL}/`);
+1 -1
View File
@@ -35,7 +35,7 @@ const stripHtml = (s: string) => s.replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, "
export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind = "video", active, bottomInset, onBack, onNearEnd, startEp, startTime }: Props) {
const store = useStore();
const { isLiked, isFav, toggleLikeLocal, toggleFavLocal, toggleFollowLocal, muted, setMuted, volume, setVolume, toast, addHistory, user, setLoginOpen } = store;
const isDesktop = platform !== "android";
const isDesktop = platform !== "android" && platform !== "ios";
const boxRef = useRef<HTMLDivElement>(null);
const videoRef = useRef<VideoHandle>(null);
+2 -2
View File
@@ -103,7 +103,7 @@ export default function LinePicker({ open, onClose }: { open: boolean; onClose:
const busyAll = !!probing || !!switching;
const body = (
<div className="flex flex-col min-h-0" style={{ maxHeight: platform === "android" ? "74vh" : "min(72vh, 620px)" }}>
<div className="flex flex-col min-h-0" style={{ maxHeight: (platform === "android" || platform === "ios") ? "74vh" : "min(72vh, 620px)" }}>
<div className="shrink-0 flex items-center gap-2 px-4 pt-3 pb-2">
<span className="w-8 h-8 rounded-full bg-s3 flex items-center justify-center text-primary"><ISettings size={16} /></span>
<div className="flex-1 min-w-0">
@@ -170,7 +170,7 @@ export default function LinePicker({ open, onClose }: { open: boolean; onClose:
</div>
);
return platform === "android"
return (platform === "android" || platform === "ios")
? <Sheet open={open} onClose={onClose}>{body}</Sheet>
: <Modal open={open} onClose={onClose} width={460}>{body}</Modal>;
}
+1 -1
View File
@@ -73,7 +73,7 @@ export default function LoginModal() {
</div>
);
return platform === "android"
return (platform === "android" || platform === "ios")
? <Sheet open={loginOpen} onClose={() => setLoginOpen(false)}>{body}</Sheet>
: <Modal open={loginOpen} onClose={() => setLoginOpen(false)} width={360}>{body}</Modal>;
}
+1
View File
@@ -34,6 +34,7 @@
}
.plat-windows { --r-sm: 4px; --r-md: 8px; --r-lg: 8px; --r-ctl: 4px; --nav-h: 0px; }
.plat-macos { --r-sm: 6px; --r-md: 10px; --r-lg: 12px; --r-ctl: 6px; --nav-h: 0px; }
.plat-ios { --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-ctl: 999px; -webkit-touch-callout: none; }
html.theme-light {
color-scheme: light;
--p-canvas: #f3f3f3;
+1 -1
View File
@@ -48,7 +48,7 @@ export default function Home({ active, bottomInset }: { active: boolean; bottomI
)}
{/* 移动端:静音 + 搜索(压在视频上,固定白字 + 半透明黑底) */}
{platform === "android" && !fs && (
{(platform === "android" || platform === "ios") && !fs && (
<div className="absolute inset-x-0 z-20 flex items-center px-3 pointer-events-none hg-player-ui" style={{ top: "calc(var(--sat, 0px) + 6px)" }}>
<div className="ml-auto flex items-center gap-2">
<button onClick={() => setMuted((m) => !m)} aria-label={muted ? "取消静音" : "静音"}
+1 -1
View File
@@ -102,7 +102,7 @@ export function PostDetail({ id, onBack }: { id: number; onBack: () => void }) {
return (
<div className="absolute inset-0 bg-bg flex flex-col">
<div className="shrink-0 flex items-center gap-2 px-2 bg-s1" style={{ paddingTop: platform === "android" ? "var(--sat, 0px)" : 0, height: platform === "android" ? "calc(44px + var(--sat, 0px))" : 44 }}>
<div className="shrink-0 flex items-center gap-2 px-2 bg-s1" style={{ paddingTop: (platform === "android" || platform === "ios") ? "var(--sat, 0px)" : 0, height: (platform === "android" || platform === "ios") ? "calc(44px + var(--sat, 0px))" : 44 }}>
<button onClick={onBack} className="w-9 h-9 rounded-full flex items-center justify-center text-on hover:bg-s3 pressable"><IBack size={19} /></button>
<span className="text-[13.5px] font-semibold text-on">吃瓜详情</span>
</div>
+2 -2
View File
@@ -34,7 +34,7 @@ export default function Profile({ wide }: { wide: boolean }) {
<div className="absolute inset-0 bg-bg flex flex-col">
<div className="shrink-0 px-4 pb-2 flex items-center" style={{ paddingTop: "calc(var(--sat, 0px) + 14px)" }}>
<div className="text-[24px] font-bold text-on leading-none">我的</div>
{platform === "android" && (
{(platform === "android" || platform === "ios") && (
<button onClick={() => push({ kind: "settings" })} aria-label="设置"
className="ml-auto w-9 h-9 rounded-full bg-s3 flex items-center justify-center text-mut pressable">
<ISettings size={17} strokeWidth={1.7} />
@@ -126,7 +126,7 @@ export default function Profile({ wide }: { wide: boolean }) {
)}
</div>
<div className="text-center text-[10px] text-dim mt-5">HGhub {APP_VERSION} · {platform === "android" ? "Android" : platform === "macos" ? "macOS" : "Windows"} 客户端</div>
<div className="text-center text-[10px] text-dim mt-5">HGhub {APP_VERSION} · {platform === "android" ? "Android" : platform === "ios" ? "iOS" : platform === "macos" ? "macOS" : "Windows"} 客户端</div>
</div>
</div>
);
+1 -1
View File
@@ -139,7 +139,7 @@ export default function Settings({ onBack, wide }: { onBack: () => void; wide: b
</button>
</Section>
<div className="text-center text-[10px] text-dim mt-5">HGhub {APP_VERSION} · {platform === "android" ? "Android" : platform === "macos" ? "macOS" : "Windows"} 客户端</div>
<div className="text-center text-[10px] text-dim mt-5">HGhub {APP_VERSION} · {platform === "android" ? "Android" : platform === "ios" ? "iOS" : platform === "macos" ? "macOS" : "Windows"} 客户端</div>
</div>
</div>
+1 -1
View File
@@ -2,7 +2,7 @@ import React, { createContext, useCallback, useContext, useEffect, useMemo, useR
import { api, platform as envPlatform } from "./api";
import type { User } from "./types";
export type Platform = "android" | "windows" | "macos";
export type Platform = "android" | "ios" | "windows" | "macos";
export type Theme = "dark" | "light";
export type Tab = "home" | "search" | "category" | "profile";