Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f508f97909 | ||
|
|
9241b772f9 | ||
|
|
be877066b6 | ||
|
|
a892cb15d6 | ||
|
|
2b93b6ec8d | ||
|
|
acb2b0f858 | ||
|
|
e35b8adbe0 | ||
|
|
18d19b7f9d | ||
|
|
adf106a575 | ||
|
|
cdb4e50f8b | ||
|
|
6616a5e146 | ||
|
|
7671c739c2 | ||
|
|
4061be2966 | ||
|
|
c3eee624bf |
@@ -0,0 +1,189 @@
|
||||
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
|
||||
# 确保 iOS Info.plist(含 ~iphone / ~ipad 变体)支持横竖屏切换及 ATS
|
||||
for plist in $(find src-tauri/gen/apple -name "Info.plist" 2>/dev/null); do
|
||||
for key in "UISupportedInterfaceOrientations" "UISupportedInterfaceOrientations~iphone" "UISupportedInterfaceOrientations~ipad"; do
|
||||
/usr/libexec/PlistBuddy -c "Delete :${key}" "$plist" 2>/dev/null || true
|
||||
/usr/libexec/PlistBuddy -c "Add :${key} array" "$plist"
|
||||
/usr/libexec/PlistBuddy -c "Add :${key}:0 string UIInterfaceOrientationPortrait" "$plist"
|
||||
/usr/libexec/PlistBuddy -c "Add :${key}:1 string UIInterfaceOrientationLandscapeLeft" "$plist"
|
||||
/usr/libexec/PlistBuddy -c "Add :${key}:2 string UIInterfaceOrientationLandscapeRight" "$plist"
|
||||
done
|
||||
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" "$plist" 2>/dev/null || true
|
||||
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "$plist"
|
||||
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" "$plist"
|
||||
done
|
||||
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 自动化构建(免证书签名,激活 custom-protocol 确保为生产打包模式)
|
||||
echo "=== 执行 Tauri iOS 构建 (--no-sign --features custom-protocol) ==="
|
||||
pnpm tauri ios build --no-sign --ci --features custom-protocol || 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/
|
||||
|
||||
# 5. 校验 IPA 是否为真正的生产包(验证不含 localhost:1420 且静态资源嵌入)
|
||||
echo "=== 校验生产包模式 ==="
|
||||
mkdir -p /tmp/verify_ipa
|
||||
unzip -q -o "artifacts/HGhub_${V}_ios.ipa" -d /tmp/verify_ipa
|
||||
BIN_PATH=$(find /tmp/verify_ipa -type f -name "HGhub" | head -n 1 || true)
|
||||
if [ -n "$BIN_PATH" ]; then
|
||||
if strings "$BIN_PATH" | grep -q "localhost:1420"; then
|
||||
echo "::error::警告:构建产物依然包含 localhost:1420,处于 dev 模式!"
|
||||
exit 1
|
||||
fi
|
||||
echo "=== 生产模式校验通过:未包含 devUrl,静态前端资源已内置 ==="
|
||||
fi
|
||||
rm -rf /tmp/verify_ipa
|
||||
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"
|
||||
NOTES="## HGhub iOS 增强版 (v${V})
|
||||
|
||||
### ✨ 核心特性
|
||||
- **沉浸式竖屏刷剧流**:支持首页无限推荐流、题材分类、三大榜单(热门/推荐/潜力)、搜索、吃瓜社区图文与视频帖、选集与历史续播。
|
||||
- **原生横竖屏智能切换**:横屏视频支持一键「横屏全屏」(调用 iOS 原生屏幕方向旋转),支持手机物理横置自动全屏、竖回自动退出,独立固定舞台层渲染不跑偏、不闪封面。
|
||||
- **丰富触控手势**:
|
||||
- **双指自由缩放(1x~4x)与平移**:竖屏观看横屏视频可自由缩放,并提供「放大铺满 / 完整适应 / 还原缩放」胶囊按钮;
|
||||
- **单击清屏 / 双击暂停**:单击屏幕隐藏所有控件与遮罩纯享画面,双击屏幕暂停/播放;
|
||||
- **长按 2.0x 倍速 + 上滑锁定**:长按画面开启 2.0x 倍速,上滑即可锁定倍速;
|
||||
- **左右横滑预览定位**:任意位置横滑精准跳转进度。
|
||||
- **HLS 播放稳定性加固**:内置 AES Key 与分片内存缓存、拖动进度条防卡死自愈重连、全屏旋转过渡期持续保活与片尾自动连播下一集。
|
||||
- **多线路与镜像测速**:内置固定主备线路 + 自动抓取最新镜像域名 + 一键延迟测速切换。
|
||||
|
||||
### 📲 安装说明(免证书生产包 \`.ipa\`)
|
||||
1. **TrollStore(巨魔商店)**:下载 \`HGhub_${V}_ios.ipa\` 后直接导入巨魔永久安装。
|
||||
2. **AltStore / SideStore / Sideloadly**:使用个人 Apple ID 自签安装。
|
||||
3. **轻松签(ESign)/ 牛蛙助手 / Feather / 全能签**:导入证书签名后直接安装。"
|
||||
|
||||
if gh release view "$TAG" >/dev/null 2>&1; then
|
||||
gh release upload "$TAG" artifacts/*.ipa --clobber
|
||||
gh release edit "$TAG" --title "HGhub v${V} iOS 正式版" --notes "$NOTES" --prerelease=false --latest
|
||||
else
|
||||
gh release create "$TAG" artifacts/*.ipa \
|
||||
--title "HGhub v${V} iOS 正式版" \
|
||||
--notes "$NOTES" \
|
||||
--latest
|
||||
fi
|
||||
@@ -0,0 +1,147 @@
|
||||
name: Build macOS Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ["main"]
|
||||
|
||||
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,8 +2,6 @@ name: Release
|
||||
|
||||
# 打 tag(v1.2.3)即自动出包并发布 Release;也可以在 Actions 页手动跑一次只出产物。
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
|
||||
@@ -28,6 +28,7 @@ Thumbs.db
|
||||
|
||||
# API
|
||||
docs/API.md
|
||||
downloads/
|
||||
|
||||
# Agent instructions (local)
|
||||
AGENTS.md
|
||||
|
||||
@@ -1,182 +1,142 @@
|
||||
*关于本项目:HGhub 只是我体验 Tuari2 移动端开发时做的小玩具,开源几天后不知为何收到了大量star。*
|
||||
|
||||
*意识到可能存在的潜在危险后,我立刻更换了开源协议为 **PolyForm Noncommercial 1.0.0** ,并在 Readme 中写入了大量保护自己的文段。目前 HGhub收到的star实际上德不配位。*
|
||||
|
||||
*在之后的更新中,我不再会维护任何获取上游数据的工作,维护方向将偏重于 UI/UX 与使用体验,同时仍会低频率的响应 PR 与 Issues。如果版权方或其授权代表认为本项目涉及其合法权益,欢迎通过 GitHub 仓库留言联系。收到明确的权利方通知后,我会第一时间积极响应,并根据对方诉求立即归档项目或将仓库转为私有,停止公开访问。*
|
||||
|
||||
|
||||
<div align="center">
|
||||
|
||||
# HGhub
|
||||
<img src="src-tauri/icons/128x128@2x.png" width="96" height="96" alt="HGhub" />
|
||||
|
||||
**黄果短剧第三方客户端 · Rust + Tauri 2**
|
||||
# HGhub · macOS & iOS 增强版
|
||||
|
||||
Windows / macOS / Android 三端 · Fluent 设计 · 沉浸式竖屏播放
|
||||
**黄果短剧跨平台客户端 —— 原生支持 macOS · iOS · Windows · Android**
|
||||
|
||||
[-007AFF?style=flat-square&logo=apple)](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases/tag/v1.2.0-ios)
|
||||
[](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases/tag/v1.2.0-macos)
|
||||
[](https://v2.tauri.app/)
|
||||
[](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases)
|
||||
|
||||
[📥 下载 iOS 版 (.ipa)](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases/tag/v1.2.0-ios) · [💻 下载 macOS 版 (.dmg)](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases/tag/v1.2.0-macos) · [📦 查看全部 Releases](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases)
|
||||
|
||||
</div>
|
||||
|
||||
> ⚠️ 本项目仅供 **学习与技术交流**,不提供、不存储、不分发任何音视频内容。
|
||||
> 所有内容均来自第三方站点,版权归原作者与上游站点所有。
|
||||
---
|
||||
|
||||
**使用须知**
|
||||
## 📖 项目简介
|
||||
|
||||
- **以访客身份正常使用**:像普通访客一样浏览就好,请勿滥用本项目。
|
||||
- **不要给上游增加压力**:本项目本身不提供下载功能,请勿改动代码去做批量下载 / 批量抓取,也不要高频轮询、并发轰炸接口或挂机刷播放量;内置的封面与播放列表缓存请不要改小或关掉。
|
||||
- **尊重上游版权**:不要去除水印与站点标识,不要把剧集搬运、转码、修改后二次分发到别处(网盘、资源站、其他 App 等),更不能改完拿出去出售。
|
||||
- **不要公开传播接口与直链**:接口地址、播放直链、解密方式请勿公开张贴或打包成「资源站」——上游一旦封禁,所有人都没法再用。
|
||||
- **不要商业化**:禁止打包出售、接入广告 / 会员 / 付费点播,或作为收费服务的一部分分发(详见 [LICENSE](LICENSE))。
|
||||
- **合理使用**:仅供个人学习、研究与自用;请在 24 小时内删除相关资源,并支持正版。
|
||||
- **遵守当地法律**:使用者应自行判断并承担合规责任。
|
||||
本项目基于 [Minireel/HGhub](https://github.com/Minireel/HGhub)(Tauri 2 + React 19 + Rust)深度适配与增强,同步最新上游 **v1.2.0** 内核,专为 **Apple 生态(iOS / iPadOS 与 macOS)** 提供开箱即用的编译产物与移动端深度交互体验优化。
|
||||
|
||||
> ⚖️ 许可证自 v1.1.0 版本起改为 **PolyForm Noncommercial 1.0.0**:**禁止任何商业用途**——
|
||||
> 包括打包出售、接入付费/会员/广告变现、作为收费产品或服务的一部分分发。
|
||||
> 个人学习、研究、自用与非营利使用不受限制,详见 [LICENSE](LICENSE)。
|
||||
通过内置 Rust 媒体网关(`hg://localhost` 自定义协议),在客户端本地完成**封面图 AES-128-CBC 实时解密**、**HLS (`.m3u8`) 播放列表分片与密钥代理改写**、**IPv6 优先连接**与**内存级缓存加速**,彻底解决 WebView 跨域(CORS)、防盗链拦截与进度条拖动卡死问题。
|
||||
|
||||
---
|
||||
|
||||
## 官方渠道与仿冒提醒
|
||||
## ✨ 核心功能特性
|
||||
|
||||
- **唯一官方仓库**:[github.com/Minireel/HGhub](https://github.com/Minireel/HGhub)
|
||||
- **唯一下载渠道**:[GitHub Releases](https://github.com/Minireel/HGhub/releases)。仓库源码页不放任何可执行文件,
|
||||
其余网站、网盘、QQ 群、公众号、第三方下载站分发的「HGhub」安装包**一律非官方**,作者不保证其安全性与完整性。
|
||||
### 🆕 v1.2.0 新增特性
|
||||
- **播放控制锁(防误触)**:播放界面新增一键锁屏按钮,锁定后屏蔽手势、进度条、选集与快捷键误触,仅保留半透明解锁入口。
|
||||
- **启动默认静音开关**:在「设置」中新增启动时默认静音开关,自动保存个人偏好。
|
||||
- **IPv6 优先与网络加固**:DNS 解析优先尝试 IPv6 地址,内置 30 秒连接池复用、非重试型 `4xx` 快速失败以及严格安全模式(SSRF 防护与 HTML 净化)开关。
|
||||
- **macOS 原生红绿灯居中与 Ad-hoc 签名**:根据系统标题栏高度动态计算并垂直居中 macOS 窗口红绿灯按钮,打包产物内置 Ad-hoc 签名,并移除横屏视频伪圆角黑框。
|
||||
- **播放诊断日志与代理分流规则**:设置页支持一键开启/导出播放诊断日志,仓库内置 Mihomo (Clash) 与 sing-box 分流规则([`rules/`](rules))。
|
||||
|
||||
> 🚫 **已发现的恶意修改版**:[`hichuv/HGhub`](https://github.com/hichuv/HGhub)
|
||||
>
|
||||
> 该仓库与本项目无关,是在旧版本源码基础上擅自加入**卡密验证、VIP 付费解锁**等变现功能的修改版,
|
||||
> 代码改动不透明、安全性无法验证。**请勿下载、勿注册、勿付费**;如已安装,建议立即卸载,改用官方 Release 包安装。
|
||||
>
|
||||
> 本项目**从未、也不会**加入任何卡密 / VIP / 付费解锁 / 广告功能。如果你遇到的「HGhub」要求输入卡密或付费开通,那一定不是官方版本。
|
||||
### 📱 iOS / iPadOS 专属增强
|
||||
- **原生横竖屏智能切换**:
|
||||
- 观看横屏视频时提供一键**「横屏全屏」**胶囊按钮,直接调用 iOS 16+ `UIWindowScene.requestGeometryUpdate` 原生旋转屏幕方向;
|
||||
- 支持**手机物理横置自动进入全屏、竖回自动退出全屏**,杜绝“画面横了屏幕没横”或“手机横过来视频反而竖过去”的错位问题;
|
||||
- 采用独立固定舞台层(`.fs-immersive` / `.fs-landscape`)渲染全屏画面,并在旋转过渡窗口期自动保活播放,彻底解决横屏全屏闪现封面或跑偏到其他剧集的问题。
|
||||
- **丝滑触控手势体系**:
|
||||
- **单击清屏 / 双击暂停**:播放中**单击屏幕**一键隐藏所有控件与渐变遮罩(纯享视频内容),**双击屏幕**切换暂停/播放;
|
||||
- **双指无级缩放(1x ~ 3.5x)与自由平移**:竖屏观看横屏视频支持双指捏合放大与拖拽平移,并提供「放大铺满 / 完整适应 / 还原缩放」快捷切换;
|
||||
- **长按 2.0x 倍速 + 上滑锁定**:长按屏幕开启 2.0x 倍速快进,长按同时上滑即可锁定 2.0x 倍速;
|
||||
- **全屏任意位置横滑定位**:手指左右滑动实时预览目标时间点并精准 Seek。
|
||||
- **iOS WebKit 播放链路深度调优**:
|
||||
- 针对 iOS `WKWebView` 自定义协议专门关闭 HLS WebWorker 跨线程死锁风险,加大分片缓冲池并内置 **AES Key 与 TS 分片内存缓存**;
|
||||
- 拖动进度条或遇到网络波动时,支持非致命卡顿自动重连与最高 4 次静默解码恢复,片尾自动触发下一集连播。
|
||||
|
||||
### 💻 macOS 桌面端体验
|
||||
- **三架构完整构建**:同时提供 **Apple Silicon (`arm64`)**、**Intel (`x64`)** 与 **Universal (`通用双架构`)** `.dmg` 安装包及 `.app.tar.gz` 免安装版。
|
||||
- **原生 Overlay 沉浸式标题栏**:适配 macOS 原生圆角窗口与交通灯(红绿灯)按钮垂直居中,支持深色 / 浅色 Fluent 主题切换、影院模式、画中画(PiP)、侧边选集/评论停靠栏与全键盘快捷键控制。
|
||||
|
||||
## 技术栈
|
||||
### 🎬 全功能内容聚合
|
||||
- **无限推荐流 & 题材分类**:沉浸式上下滑刷剧,涵盖都市、古装、逆袭、虐恋、甜宠、悬疑等全部分类频道。
|
||||
- **三大实时榜单 & 全局搜索**:热门榜、推荐榜、潜力榜实时同步,支持关键词搜索与搜索历史记录。
|
||||
- **吃瓜社区(图文 + 视频)**:内置「黄果吃瓜」爆料流,支持富文本图文浏览与内嵌视频播放。
|
||||
- **选集连播 & 观看历史续播**:自动记录每部短剧观看集数与秒级进度,从个人中心或历史记录点开即可无缝续播。
|
||||
- **多线路切换 & 镜像域名测速**:内置固定主备线路,支持从地址发布页动态抓取最新可用镜像域名并一键并发测速。
|
||||
|
||||
| 层 | 选型 |
|
||||
| --- | --- |
|
||||
| 壳 | Tauri 2(Rust 1.90+) |
|
||||
| 前端 | React 19 + TypeScript + Vite 7 + Tailwind CSS 4 |
|
||||
| 播放 | hls.js(HLS / AES-128) |
|
||||
| 网络 | reqwest + rustls |
|
||||
---
|
||||
|
||||
## 目录
|
||||
## 📥 下载与安装指南
|
||||
|
||||
```
|
||||
.
|
||||
├─ src/ 前端
|
||||
│ ├─ api.ts 接口封装 + 本地媒体协议 URL
|
||||
│ ├─ store.tsx 全局状态(导航栈 / 用户 / 本地收藏 / 主题)
|
||||
│ ├─ html.ts 吃瓜正文清洗与图片代理
|
||||
│ ├─ components/ Feed(播放页)/ VideoSurface / PlayerControls / Panels / UI
|
||||
│ └─ pages/ Home / Search / Category / Profile / Posts
|
||||
├─ src-tauri/ Rust 后端
|
||||
│ └─ src/
|
||||
│ ├─ net.rs 请求层(边缘信封 + 重试)
|
||||
│ ├─ api.rs 业务命令
|
||||
│ ├─ media.rs 封面解密 + HLS 代理 + 缓存
|
||||
│ └─ session.rs token 持久化
|
||||
└─ docs/API.md 接口文档
|
||||
```
|
||||
请前往 [**GitHub Releases 页面**](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases) 下载对应平台的最新安装包:
|
||||
|
||||
## 开发 / 构建
|
||||
### 1. iOS / iPadOS 安装说明([`HGhub_1.2.0_ios.ipa`](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases/tag/v1.2.0-ios))
|
||||
|
||||
> Release 提供的 `.ipa` 为已内嵌完整静态前端资源的**免签名生产包(Unsigned Production IPA)**,支持以下任意方式安装(系统要求 iOS / iPadOS 15.0+):
|
||||
|
||||
| 安装工具 | 适用设备 | 安装步骤 |
|
||||
| :--- | :--- | :--- |
|
||||
| **TrollStore(巨魔商店)** | iOS 14.0 – 17.0 支持巨魔设备 | 下载 `HGhub_1.2.0_ios.ipa` → 在「文件」中共享给 **TrollStore** 直接永久安装(推荐) |
|
||||
| **AltStore / SideStore** | 任意 iOS 设备(免费 Apple ID) | 打开 AltStore / SideStore → 点击 `+` 导入 `.ipa` 自签安装(每 7 天自动刷新) |
|
||||
| **Sideloadly** | 任意 iOS 设备(电脑辅助自签) | 连接电脑打开 Sideloadly → 拖入 `.ipa` 输入 Apple ID 签名安装 |
|
||||
| **轻松签 (ESign) / Feather / 牛蛙助手** | 拥有个人或企业证书设备 | 导入 `.ipa` 至签名工具 → 选择自有证书签名后直接安装 |
|
||||
|
||||
### 2. macOS 安装说明([`v1.2.0-macos`](https://github.com/LNPANDY/HGhub-MacOS-iOS-Version/releases/tag/v1.2.0-macos))
|
||||
|
||||
- **Apple Silicon (M1 / M2 / M3 / M4 系列芯片)**:推荐下载 `HGhub_1.2.0_arm64.dmg`
|
||||
- **Intel 处理器 Mac**:推荐下载 `HGhub_1.2.0_x64.dmg`
|
||||
- **Universal 通用版**:下载 `HGhub_1.2.0_universal.dmg`
|
||||
|
||||
> **💡 macOS 首次打开提示「已损坏」或「无法验证开发者」解决方法:**
|
||||
> 由于开源版本未挂载付费 Apple Developer ID 公证(仅做 Ad-hoc 签名),将 `HGhub.app` 拖入「应用程序(Applications)」后,若首次打开被 Gatekeeper 拦截,请在「终端(Terminal)」执行以下命令清除隔离属性即可正常打开:
|
||||
> ```bash
|
||||
> sudo xattr -rd com.apple.quarantine /Applications/HGhub.app
|
||||
> ```
|
||||
|
||||
---
|
||||
|
||||
## ⌨️ 快捷键与手势速查
|
||||
|
||||
| 平台 | 操作 | 功能说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| **iOS / 移动端** | **单击屏幕** | 清屏模式(隐藏/显示全部界面控件与底部导航栏,只看视频) |
|
||||
| **iOS / 移动端** | **双击屏幕** | 暂停 / 继续播放 |
|
||||
| **iOS / 移动端** | **右上角锁形图标** | 锁定播放控制(防误触,锁屏后点按屏幕唤醒解锁按钮) |
|
||||
| **iOS / 移动端** | **双指捏合 / 拖动** | 自由缩放画面(`0.85x` ~ `3.5x`)与任意方向平移画面 |
|
||||
| **iOS / 移动端** | **长按屏幕** | 开启 `2.0x` 倍速快进(长按同时**上滑**可锁定 `2.0x` 倍速) |
|
||||
| **iOS / 移动端** | **屏幕左右横滑** | 实时预览并跳转播放进度 |
|
||||
| **iOS / 移动端** | **手机横置 / 点「横屏全屏」** | 原生旋转屏幕进入横屏全屏(手机竖回或点右上角按钮退出) |
|
||||
| **macOS / 桌面端** | `Space`(空格) | 播放 / 暂停 |
|
||||
| **macOS / 桌面端** | `↑` / `↓` | 切换上一部 / 下一部短剧 |
|
||||
| **macOS / 桌面端** | `←` / `→` | 快退 5 秒 / 快进 5 秒 |
|
||||
| **macOS / 桌面端** | `F` / `T` / `M` | 全屏 (`F`) / 影院模式 (`T`) / 静音 (`M`) |
|
||||
| **macOS / 桌面端** | `E` / `C` / `L` / `S` | 选集面板 (`E`) / 评论面板 (`C`) / 点赞 (`L`) / 收藏 (`S`) |
|
||||
| **macOS / 桌面端** | `1` `2` `3` `4` / `/` | 切换主导航栏标签 / 聚焦搜索页 (`/`) |
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ 本地开发与构建
|
||||
|
||||
### 环境要求
|
||||
- **Node.js** 22+ & **pnpm** 10+
|
||||
- **Rust** 1.90+ (`rustup`)
|
||||
- **macOS / iOS 构建**:需 macOS 系统与 Xcode 16+
|
||||
|
||||
```bash
|
||||
pnpm install # 首次安装
|
||||
pnpm app:dev # 桌面端热重载
|
||||
pnpm app:build # 打包:Windows → NSIS 安装程序;macOS → .app + .dmg
|
||||
# 1. 安装前端依赖
|
||||
pnpm install
|
||||
|
||||
# 2. 启动桌面开发调试
|
||||
pnpm tauri dev
|
||||
|
||||
# 3. 编译 macOS 安装包 (.dmg / .app)
|
||||
pnpm tauri build --config src-tauri/tauri.macos.conf.json --target aarch64-apple-darwin
|
||||
|
||||
# 4. 初始化并编译 iOS 免签名生产包
|
||||
pnpm tauri ios init
|
||||
pnpm build
|
||||
pnpm tauri ios build --no-sign --ci --features custom-protocol
|
||||
```
|
||||
|
||||
macOS 先装 Xcode Command Line Tools(`xcode-select --install`),打包目标写在
|
||||
`src-tauri/tauri.macos.conf.json`(`app` + `dmg`,窗口用系统标题栏 Overlay)。
|
||||
---
|
||||
|
||||
Android(需 Android SDK + NDK,并配置 `ANDROID_HOME` / `NDK_HOME`):
|
||||
## 📄 开源许可与致谢
|
||||
|
||||
```bash
|
||||
pnpm android:init # 首次生成 android 工程
|
||||
pnpm android:dev # 真机 / 模拟器调试
|
||||
pnpm android:build # 产出 APK
|
||||
```
|
||||
|
||||
iOS(需 Xcode、xcodegen、CocoaPods 与 Apple 开发者账号;自行签名安装到自己的设备):
|
||||
|
||||
```bash
|
||||
export APPLE_DEVELOPMENT_TEAM=<你的 Team ID>
|
||||
pnpm tauri ios init --ci # 首次生成 Xcode 工程(src-tauri/gen/apple)
|
||||
pnpm tauri ios build --export-method debugging # 产出 src-tauri/gen/apple/build/arm64/HGhub.ipa
|
||||
xcrun devicectl device install app --device <UDID> <解压后的 Payload/HGhub.app>
|
||||
```
|
||||
|
||||
最低系统版本写在 `src-tauri/tauri.ios.conf.json`(iOS 15)。iOS 复用安卓的触屏界面;自定义协议与 macOS 相同,为 `hg://localhost`。
|
||||
|
||||
### 环境注意
|
||||
|
||||
- 工程若放在 **exFAT** 盘(不支持符号链接),需保留 `.npmrc` 中的 `node-linker=hoisted`。
|
||||
- pnpm 10 靠 `package.json` 的 `pnpm.onlyBuiltDependencies` 放行 `esbuild`,否则 `vite build` 缺少二进制;
|
||||
pnpm 11 起该字段失效,白名单改在 `pnpm-workspace.yaml` 的 `allowBuilds`(两处都保留)。
|
||||
|
||||
## 实现要点
|
||||
|
||||
「设置 → 播放 → 启动时静音」默认开启,每次启动应用均静音,播放时可手动开启声音。关闭此选项后,下次启动恢复上次的静音状态;音量仍会记忆。
|
||||
|
||||
安全加固后的正文处理、FakeIP/内网限制、账号线路隔离及本地回归方法,见 [客户端内容与网络安全](docs/security.md)。镜像线路仅支持游客浏览,跨站点切换和首次升级后需要重新登录。
|
||||
|
||||
Mihomo 与 sing-box 分流规则、已知域名统计及导入方法,见 [网络分流规则](rules/README.md)。
|
||||
|
||||
1. **统一边缘信封**:站点把 `/api/**` 收敛为 `POST /api/edge/request`(`method/path/body(base64)/content_type` + `Authorization: Bearer`),本项目只对接这一个入口,无需处理 Cookie。
|
||||
2. **封面解密**:封面为 AES-128-CBC 密文,Rust 侧解密后经自定义协议输出,前端 `<img>` 直接使用。
|
||||
3. **HLS 代理**:m3u8 与分片经自定义协议转发并改写 `#EXT-X-KEY` / 分片地址,绕开 WebView 的 CORS 与防盗链。
|
||||
4. **自定义协议**:Windows / Android 为 `http://hg.localhost/*`,macOS 为 `hg://localhost/*`(Tauri 的平台差异)。
|
||||
Rust 侧 `lib.rs` 与前端 `api.ts` 各自按平台生成一次基址,两处必须一致,否则封面与视频全部加载失败。
|
||||
5. **不做签名逆向**:只复用浏览器同源行为,接口字段均有文档与实测样本。
|
||||
|
||||
|
||||
## 免责声明
|
||||
|
||||
- 本项目与内容提供方无任何关联,作者不参与内容的制作、上传与分发。
|
||||
- 本项目仅在上述官方渠道发布;任何第三方修改版(尤其是加卡密、VIP 变现的版本)均与作者无关,请自行甄别。
|
||||
- 使用者应自行遵守所在地法律法规;因使用本项目产生的任何后果由使用者自行承担。
|
||||
- 若相关权利方认为本项目存在侵权,请通过 Issue 联系,我们会及时处理。
|
||||
|
||||
## License
|
||||
|
||||
[PolyForm Noncommercial License 1.0.0](LICENSE) —— **仅限非商业用途**。
|
||||
|
||||
- **允许**:个人学习、研究、自用、爱好项目,以及在非营利组织内部使用;可以自由修改、二次开发。
|
||||
- **禁止**:任何商业用途。包括但不限于打包出售、接入付费/会员/广告变现、作为收费服务或商业产品的一部分分发。
|
||||
- **保留声明**:分发本项目或其修改版时,必须附带本许可证全文(或上面的链接)以及 `Required Notice` 声明行。
|
||||
- 商业授权请通过 Issue 联系作者单独洽谈。
|
||||
|
||||
> 历史说明:v1.0.1 及更早版本以 MIT 发布,已发出的副本继续按 MIT 授权;自 **v1.1.0** 起的新版本一律适用 PolyForm Noncommercial 1.0.0。
|
||||
|
||||
## 常见问题
|
||||
|
||||
**1. `pnpm install` 报 `ERR_PNPM_EISDIR ... symlink`**
|
||||
|
||||
工程放在 exFAT / FAT32 盘时无法创建符号链接,保留 `.npmrc` 里的 `node-linker=hoisted` 即可。
|
||||
|
||||
**2. `tauri android build` 报 `Failed to create a symbolic link ... jniLibs`**
|
||||
|
||||
同样是 exFAT 不支持符号链接。可手动把 Rust 产物拷进 jniLibs,再直接跑 Gradle:
|
||||
|
||||
```bash
|
||||
cp src-tauri/target/aarch64-linux-android/debug/libhuangguo_client_lib.so \
|
||||
src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a/
|
||||
|
||||
cd src-tauri/gen/android
|
||||
./gradlew assembleDebug # Windows: gradlew.bat assembleDebug
|
||||
```
|
||||
|
||||
产物在 `src-tauri/gen/android/app/build/outputs/apk/`。
|
||||
|
||||
**3. Android 构建提示找不到 SDK / NDK**
|
||||
|
||||
需要设置 `ANDROID_HOME`(Android SDK 根目录)、`NDK_HOME`(`$ANDROID_HOME/ndk/<版本>`)与 `JAVA_HOME`(JDK 17)。
|
||||
|
||||
**4. macOS 打开时提示「已损坏」或「无法验证开发者」**
|
||||
|
||||
Release 里的 dmg 没有用 Apple 开发者证书签名和公证,从网上下载后会被 Gatekeeper 拦下。
|
||||
把 HGhub 拖进「应用程序」后,在终端执行一次:
|
||||
|
||||
```bash
|
||||
xattr -cr /Applications/HGhub.app
|
||||
```
|
||||
|
||||
## LinuxDO
|
||||
https://linux.do/
|
||||
- 感谢上游项目 [Minireel/HGhub](https://github.com/Minireel/HGhub) 提供的核心架构与跨平台基础。
|
||||
- 感谢 [stclock1988/hghub-ios](https://github.com/stclock1988/hghub-ios) 在 iOS 播放器过渡保活与片尾连播机制上的参考启发。
|
||||
- 本仓库遵循 [PolyForm Noncommercial License 1.0.0](LICENSE) 协议,仅供个人学习与非商业交流使用。
|
||||
|
||||
@@ -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>
|
||||
|
||||
+7
-3
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "huangguo-client",
|
||||
"name": "hghub-macos-ios",
|
||||
"description": "HGhub · 黄果短剧跨平台客户端 (macOS & iOS 增强版)",
|
||||
"private": true,
|
||||
"version": "1.2.0",
|
||||
"license": "PolyForm-Noncommercial-1.0.0",
|
||||
@@ -16,7 +17,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",
|
||||
@@ -29,7 +33,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",
|
||||
|
||||
Generated
+49
-49
@@ -34,8 +34,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
|
||||
@@ -568,79 +568,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
|
||||
|
||||
@@ -1347,52 +1347,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:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "huangguo-client"
|
||||
version = "1.2.0"
|
||||
description = "HGhub · 黄果短剧客户端"
|
||||
description = "HGhub · 黄果短剧跨平台客户端 (macOS & iOS 增强版)"
|
||||
authors = ["HGhub"]
|
||||
license = "PolyForm-Noncommercial-1.0.0"
|
||||
edition = "2021"
|
||||
@@ -14,6 +14,10 @@ crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[features]
|
||||
default = ["custom-protocol"]
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-opener = "=2.7.2"
|
||||
|
||||
+109
-1
@@ -87,7 +87,7 @@ pub async fn line_probe(urls: Vec<String>) -> Result<Value, String> {
|
||||
|
||||
/* ───────────────────────── 更新检查 ───────────────────────── */
|
||||
|
||||
const REPO: &str = "Minireel/HGhub";
|
||||
const REPO: &str = "LNPANDY/HGhub-MacOS-iOS-Version";
|
||||
|
||||
fn ver_parts(v: &str) -> Vec<u64> {
|
||||
v.trim()
|
||||
@@ -170,6 +170,114 @@ pub async fn open_url(app: tauri::AppHandle, url: String) -> Result<(), String>
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// 切换移动端屏幕方向(iOS 原生旋转屏幕方向:横屏 Landscape / 竖屏 Portrait)。
|
||||
#[tauri::command]
|
||||
pub async fn set_orientation(app: tauri::AppHandle, landscape: bool) -> Result<(), String> {
|
||||
#[cfg(target_os = "ios")]
|
||||
{
|
||||
let _ = app.run_on_main_thread(move || {
|
||||
request_ios_orientation(landscape);
|
||||
});
|
||||
}
|
||||
#[cfg(not(target_os = "ios"))]
|
||||
{
|
||||
let _ = (&app, landscape);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
fn request_ios_orientation(landscape: bool) {
|
||||
use std::ffi::{c_char, c_void};
|
||||
extern "C" {
|
||||
fn objc_getClass(name: *const c_char) -> *mut c_void;
|
||||
fn sel_registerName(name: *const c_char) -> *mut c_void;
|
||||
fn objc_msgSend();
|
||||
}
|
||||
unsafe {
|
||||
let msg0: unsafe extern "C" fn(*mut c_void, *mut c_void) -> *mut c_void =
|
||||
std::mem::transmute(objc_msgSend as *const ());
|
||||
let msg0_usize: unsafe extern "C" fn(*mut c_void, *mut c_void) -> usize =
|
||||
std::mem::transmute(objc_msgSend as *const ());
|
||||
let msg1_usize: unsafe extern "C" fn(*mut c_void, *mut c_void, usize) -> *mut c_void =
|
||||
std::mem::transmute(objc_msgSend as *const ());
|
||||
let msg2_ptr: unsafe extern "C" fn(*mut c_void, *mut c_void, *mut c_void, *mut c_void) =
|
||||
std::mem::transmute(objc_msgSend as *const ());
|
||||
let msg1_void: unsafe extern "C" fn(*mut c_void, *mut c_void) =
|
||||
std::mem::transmute(objc_msgSend as *const ());
|
||||
|
||||
// 1. iOS 16+ UIWindowScene.requestGeometryUpdateWithPreferences:errorHandler:
|
||||
// UIInterfaceOrientationMaskPortrait = 1 << 1 = 2
|
||||
// UIInterfaceOrientationMaskLandscapeRight = 1 << 3 = 8
|
||||
let mask: usize = if landscape { 8 } else { 2 };
|
||||
let prefs_cls = objc_getClass(b"UIWindowSceneGeometryPreferencesIOS\0".as_ptr() as *const c_char);
|
||||
let app_cls = objc_getClass(b"UIApplication\0".as_ptr() as *const c_char);
|
||||
if !prefs_cls.is_null() && !app_cls.is_null() {
|
||||
let sel_alloc = sel_registerName(b"alloc\0".as_ptr() as *const c_char);
|
||||
let sel_init = sel_registerName(b"initWithInterfaceOrientations:\0".as_ptr() as *const c_char);
|
||||
let raw_prefs = msg0(prefs_cls, sel_alloc);
|
||||
let prefs = if !raw_prefs.is_null() {
|
||||
msg1_usize(raw_prefs, sel_init, mask)
|
||||
} else {
|
||||
std::ptr::null_mut()
|
||||
};
|
||||
|
||||
let sel_shared = sel_registerName(b"sharedApplication\0".as_ptr() as *const c_char);
|
||||
let app = msg0(app_cls, sel_shared);
|
||||
if !app.is_null() && !prefs.is_null() {
|
||||
let sel_scenes = sel_registerName(b"connectedScenes\0".as_ptr() as *const c_char);
|
||||
let scenes_set = msg0(app, sel_scenes);
|
||||
if !scenes_set.is_null() {
|
||||
let sel_all = sel_registerName(b"allObjects\0".as_ptr() as *const c_char);
|
||||
let arr = msg0(scenes_set, sel_all);
|
||||
if !arr.is_null() {
|
||||
let sel_count = sel_registerName(b"count\0".as_ptr() as *const c_char);
|
||||
let sel_at = sel_registerName(b"objectAtIndex:\0".as_ptr() as *const c_char);
|
||||
let sel_req = sel_registerName(
|
||||
b"requestGeometryUpdateWithPreferences:errorHandler:\0".as_ptr() as *const c_char,
|
||||
);
|
||||
let sel_responds = sel_registerName(b"respondsToSelector:\0".as_ptr() as *const c_char);
|
||||
let msg_responds: unsafe extern "C" fn(*mut c_void, *mut c_void, *mut c_void) -> bool =
|
||||
std::mem::transmute(objc_msgSend as *const ());
|
||||
let count = msg0_usize(arr, sel_count);
|
||||
for i in 0..count {
|
||||
let scene = msg1_usize(arr, sel_at, i);
|
||||
if !scene.is_null() && msg_responds(scene, sel_responds, sel_req) {
|
||||
msg2_ptr(scene, sel_req, prefs, std::ptr::null_mut());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Fallback: UIDevice setValue:forKey:@"orientation" + attemptRotationToDeviceOrientation
|
||||
let dev_cls = objc_getClass(b"UIDevice\0".as_ptr() as *const c_char);
|
||||
let num_cls = objc_getClass(b"NSNumber\0".as_ptr() as *const c_char);
|
||||
let str_cls = objc_getClass(b"NSString\0".as_ptr() as *const c_char);
|
||||
let vc_cls = objc_getClass(b"UIViewController\0".as_ptr() as *const c_char);
|
||||
if !dev_cls.is_null() && !num_cls.is_null() && !str_cls.is_null() {
|
||||
let sel_cur = sel_registerName(b"currentDevice\0".as_ptr() as *const c_char);
|
||||
let dev = msg0(dev_cls, sel_cur);
|
||||
let sel_num = sel_registerName(b"numberWithInteger:\0".as_ptr() as *const c_char);
|
||||
let orient_val: usize = if landscape { 3 } else { 1 };
|
||||
let num = msg1_usize(num_cls, sel_num, orient_val);
|
||||
let sel_str = sel_registerName(b"stringWithUTF8String:\0".as_ptr() as *const c_char);
|
||||
let msg_str: unsafe extern "C" fn(*mut c_void, *mut c_void, *const c_char) -> *mut c_void =
|
||||
std::mem::transmute(objc_msgSend as *const ());
|
||||
let key = msg_str(str_cls, sel_str, b"orientation\0".as_ptr() as *const c_char);
|
||||
if !dev.is_null() && !num.is_null() && !key.is_null() {
|
||||
let sel_set_val = sel_registerName(b"setValue:forKey:\0".as_ptr() as *const c_char);
|
||||
msg2_ptr(dev, sel_set_val, num, key);
|
||||
}
|
||||
if !vc_cls.is_null() {
|
||||
let sel_attempt = sel_registerName(b"attemptRotationToDeviceOrientation\0".as_ptr() as *const c_char);
|
||||
msg1_void(vc_cls, sel_attempt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ───────────────────────── 会话 ───────────────────────── */
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
@@ -29,7 +29,7 @@ fn allowed_dev_host(host: &str) -> bool {
|
||||
fn allowed_frontend_origin(origin: &str) -> bool {
|
||||
if matches!(
|
||||
origin,
|
||||
"tauri://localhost" | "http://tauri.localhost" | "https://tauri.localhost"
|
||||
"tauri://localhost" | "http://tauri.localhost" | "https://tauri.localhost" | "null"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -121,6 +121,11 @@ pub fn run() {
|
||||
.insert("Access-Control-Allow-Origin", origin);
|
||||
resp.headers_mut()
|
||||
.insert("Vary", tauri::http::HeaderValue::from_static("Origin"));
|
||||
} else {
|
||||
resp.headers_mut().insert(
|
||||
"Access-Control-Allow-Origin",
|
||||
tauri::http::HeaderValue::from_static("*"),
|
||||
);
|
||||
}
|
||||
responder.respond(resp);
|
||||
});
|
||||
@@ -140,6 +145,7 @@ pub fn run() {
|
||||
api::line_probe,
|
||||
api::check_update,
|
||||
api::open_url,
|
||||
api::set_orientation,
|
||||
api::api_login,
|
||||
api::api_register,
|
||||
api::api_logout,
|
||||
|
||||
+53
-12
@@ -30,9 +30,16 @@ static IMG_CACHE: Lazy<Mutex<HashMap<String, Arc<Vec<u8>>>>> =
|
||||
Lazy::new(|| Mutex::new(HashMap::new()));
|
||||
static PL_CACHE: Lazy<Mutex<HashMap<String, Arc<String>>>> =
|
||||
Lazy::new(|| Mutex::new(HashMap::new()));
|
||||
static KEY_CACHE: Lazy<Mutex<HashMap<String, (String, Arc<Vec<u8>>)>>> =
|
||||
Lazy::new(|| Mutex::new(HashMap::new()));
|
||||
static SEG_CACHE: Lazy<Mutex<HashMap<String, (String, Arc<Vec<u8>>)>>> =
|
||||
Lazy::new(|| Mutex::new(HashMap::new()));
|
||||
|
||||
const IMG_CACHE_MAX: usize = 240;
|
||||
const PL_CACHE_MAX: usize = 60;
|
||||
const KEY_CACHE_MAX: usize = 120;
|
||||
const SEG_CACHE_MAX: usize = 36;
|
||||
const SEG_CACHE_MAX_BYTES: usize = 4 * 1024 * 1024;
|
||||
|
||||
fn cache_put<V: Clone>(map: &Mutex<HashMap<String, V>>, key: String, val: V, max: usize) {
|
||||
let mut m = map.lock().unwrap();
|
||||
@@ -184,9 +191,10 @@ fn rewrite_uri_attr(line: &str, prefix: &str) -> String {
|
||||
map_uri_attributes(line, |uri| format!("{prefix}/seg?u={}", enc(uri)))
|
||||
}
|
||||
|
||||
/// 取 m3u8 并把 key / 分片地址改写到本地协议。
|
||||
/// 取 m3u8 并把 key / 子列表 / 分片地址改写到本地协议。
|
||||
pub async fn load_playlist(url: &str, prefix: &str) -> Result<Arc<String>, String> {
|
||||
if let Some(hit) = PL_CACHE.lock().unwrap().get(url).cloned() {
|
||||
let cache_key = format!("{prefix}|{url}");
|
||||
if let Some(hit) = PL_CACHE.lock().unwrap().get(&cache_key).cloned() {
|
||||
return Ok(hit);
|
||||
}
|
||||
let (_, bytes) = fetch_bytes(url).await?;
|
||||
@@ -195,7 +203,7 @@ pub async fn load_playlist(url: &str, prefix: &str) -> Result<Arc<String>, Strin
|
||||
return Err("响应不是 HLS 播放列表".into());
|
||||
}
|
||||
let arc = Arc::new(rewrite_playlist(url, text, prefix));
|
||||
cache_put(&PL_CACHE, url.to_string(), arc.clone(), PL_CACHE_MAX);
|
||||
cache_put(&PL_CACHE, cache_key, arc.clone(), PL_CACHE_MAX);
|
||||
Ok(arc)
|
||||
}
|
||||
|
||||
@@ -251,23 +259,54 @@ fn absolutize_uri_in_attr(base: &str, line: &str) -> String {
|
||||
map_uri_attributes(line, |uri| absolutize(base, uri))
|
||||
}
|
||||
|
||||
/// 清空封面 / 播放列表内存缓存
|
||||
/// 加载分片或 AES Key(带内存缓存,避免拖动进度条时重复拉取同一 Key 或分片导致卡顿)。
|
||||
pub async fn load_segment(url: &str) -> Result<(Option<String>, Arc<Vec<u8>>), String> {
|
||||
if let Some((ctype, hit)) = KEY_CACHE.lock().unwrap().get(url).cloned() {
|
||||
return Ok((Some(ctype), hit));
|
||||
}
|
||||
if let Some((ctype, hit)) = SEG_CACHE.lock().unwrap().get(url).cloned() {
|
||||
return Ok((Some(ctype), hit));
|
||||
}
|
||||
let (ctype, bytes) = fetch_bytes(url).await?;
|
||||
let mime = ctype.clone().unwrap_or_else(|| {
|
||||
let p = url.split('?').next().unwrap_or(url).to_ascii_lowercase();
|
||||
if p.ends_with(".ts") {
|
||||
"video/mp2t".to_string()
|
||||
} else if p.ends_with(".m4s") || p.ends_with(".mp4") {
|
||||
"video/mp4".to_string()
|
||||
} else {
|
||||
"application/octet-stream".to_string()
|
||||
}
|
||||
});
|
||||
let len = bytes.len();
|
||||
let arc = Arc::new(bytes);
|
||||
if len <= 65536 {
|
||||
cache_put(&KEY_CACHE, url.to_string(), (mime.clone(), arc.clone()), KEY_CACHE_MAX);
|
||||
} else if len <= SEG_CACHE_MAX_BYTES {
|
||||
cache_put(&SEG_CACHE, url.to_string(), (mime.clone(), arc.clone()), SEG_CACHE_MAX);
|
||||
}
|
||||
Ok((Some(mime), arc))
|
||||
}
|
||||
|
||||
/// 清空封面 / 播放列表 / 分片内存缓存
|
||||
pub fn clear_caches() {
|
||||
if let Ok(mut g) = IMG_CACHE.lock() {
|
||||
g.clear();
|
||||
}
|
||||
if let Ok(mut g) = PL_CACHE.lock() {
|
||||
g.clear();
|
||||
}
|
||||
if let Ok(mut g) = IMG_CACHE.lock() { g.clear(); }
|
||||
if let Ok(mut g) = PL_CACHE.lock() { g.clear(); }
|
||||
if let Ok(mut g) = KEY_CACHE.lock() { g.clear(); }
|
||||
if let Ok(mut g) = SEG_CACHE.lock() { g.clear(); }
|
||||
}
|
||||
|
||||
/* ───────────────────────── 协议响应 ───────────────────────── */
|
||||
|
||||
fn respond(status: u16, ctype: &str, body: Vec<u8>, cache: &str) -> Response<Vec<u8>> {
|
||||
let len = body.len().to_string();
|
||||
Response::builder()
|
||||
.status(StatusCode::from_u16(status).unwrap_or(StatusCode::OK))
|
||||
.header("Content-Type", ctype)
|
||||
.header("Content-Length", len)
|
||||
.header("Accept-Ranges", "bytes")
|
||||
.header("X-Content-Type-Options", "nosniff")
|
||||
.header("Access-Control-Expose-Headers", "Content-Length, Content-Type, Accept-Ranges")
|
||||
.header("Cache-Control", cache)
|
||||
.body(body)
|
||||
.unwrap_or_else(|_| Response::new(Vec::new()))
|
||||
@@ -350,8 +389,10 @@ pub async fn handle(path: &str, query: &str, origin: &str) -> Response<Vec<u8>>
|
||||
),
|
||||
Err(e) => respond(502, "text/plain", e.into_bytes(), "no-store"),
|
||||
},
|
||||
"/seg" => match fetch_bytes(&target).await {
|
||||
Ok((ctype, bytes)) => segment_response(&target, ctype.as_deref(), bytes, origin),
|
||||
"/seg" => match load_segment(&target).await {
|
||||
Ok((ctype, bytes)) => {
|
||||
segment_response(&target, ctype.as_deref(), bytes.as_ref().clone(), origin)
|
||||
}
|
||||
Err(e) => respond(502, "text/plain", e.into_bytes(), "no-store"),
|
||||
},
|
||||
_ => respond(404, "text/plain", b"not found".to_vec(), "no-store"),
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
],
|
||||
"android": {
|
||||
"minSdkVersion": 24
|
||||
},
|
||||
"iOS": {
|
||||
"developmentTeam": "ABCDE12345"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"build": {
|
||||
"devUrl": null
|
||||
},
|
||||
"bundle": {
|
||||
"iOS": {
|
||||
"minimumSystemVersion": "15.0"
|
||||
|
||||
+5
-2
@@ -9,9 +9,12 @@ import type {
|
||||
export const APP_VERSION = __APP_VERSION__;
|
||||
|
||||
const ua = navigator.userAgent;
|
||||
export const isAndroid = /Android/i.test(ua);
|
||||
/** iPhone 的 UA 也带「like Mac OS X」,必须先于 macOS 判断;iPadOS 默认伪装成 Mac,用触点数区分。 */
|
||||
export const isIos = /iPhone|iPad|iPod/i.test(ua) || (/Macintosh/i.test(ua) && navigator.maxTouchPoints > 1);
|
||||
export const isIos =
|
||||
/iPhone|iPad|iPod/i.test(ua) ||
|
||||
(/Macintosh/i.test(ua) && navigator.maxTouchPoints > 1) ||
|
||||
(typeof navigator.platform === "string" && navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
|
||||
export const isAndroid = /Android/i.test(ua);
|
||||
export const isMacos = !isIos && /Macintosh|Mac OS X/i.test(ua);
|
||||
export const platform: "android" | "ios" | "windows" | "macos" =
|
||||
isAndroid ? "android" : isIos ? "ios" : isMacos ? "macos" : "windows";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import Hls from "hls.js";
|
||||
import { fmtTime, playlist } from "../api";
|
||||
import { fmtTime, platform, playlist } from "../api";
|
||||
import { mediaResource, observeHls, usePlayerDiagnostics } from "../playbackDiagnostics";
|
||||
import { usePlaybackActivity } from "../usePlaybackActivity";
|
||||
import { useSeekInput } from "../useSeekInput";
|
||||
@@ -30,6 +30,7 @@ export default function Player({
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
const wrapRef = useRef<HTMLDivElement>(null);
|
||||
const hlsRef = useRef<Hls | null>(null);
|
||||
const recoverCountRef = useRef(0);
|
||||
const { trace, requestSeek } = usePlayerDiagnostics(videoRef, hlsRef, { view: "post_detail", ...diagnosticContext, active, resource: mediaResource(src) });
|
||||
const activity = usePlaybackActivity(videoRef, hlsRef, { active, autoPlay: !!autoPlay, src, trace });
|
||||
const [playing, setPlaying] = useState(false);
|
||||
@@ -46,6 +47,10 @@ export default function Player({
|
||||
const video = videoRef.current;
|
||||
if (!video || !activity.isActive()) return;
|
||||
requestSeek(target, `legacy_${input}`);
|
||||
setWaiting(true);
|
||||
if (hlsRef.current) {
|
||||
try { hlsRef.current.startLoad(target); } catch { /* ignore */ }
|
||||
}
|
||||
video.currentTime = target;
|
||||
trace("seek.assigned", { target });
|
||||
setTime(video.currentTime);
|
||||
@@ -56,6 +61,8 @@ export default function Player({
|
||||
const video = videoRef.current;
|
||||
if (!video || !src) return;
|
||||
const url = playlist(src);
|
||||
recoverCountRef.current = 0;
|
||||
setErrMsg("");
|
||||
trace("source.load", { engine: Hls.isSupported() ? "hls.js" : "native", auto_play: autoPlay });
|
||||
|
||||
if (hlsRef.current) { hlsRef.current.destroy(); hlsRef.current = null; }
|
||||
@@ -66,16 +73,22 @@ export default function Player({
|
||||
interstitialsController: undefined,
|
||||
contentSteeringController: undefined,
|
||||
enableInterstitialPlayback: false,
|
||||
enableWorker: true,
|
||||
enableWorker: platform !== "ios",
|
||||
// Keep the same macOS seek workaround as the shared player.
|
||||
preferManagedMediaSource: false,
|
||||
autoStartLoad: false,
|
||||
lowLatencyMode: false,
|
||||
maxBufferLength: 24,
|
||||
maxBufferLength: 30,
|
||||
maxMaxBufferLength: 60,
|
||||
backBufferLength: 30,
|
||||
maxBufferHole: 0.5,
|
||||
nudgeOffset: 0.25,
|
||||
nudgeMaxRetry: 6,
|
||||
manifestLoadingTimeOut: 20000,
|
||||
manifestLoadingMaxRetry: 3,
|
||||
fragLoadingMaxRetry: 4,
|
||||
manifestLoadingMaxRetry: 4,
|
||||
fragLoadingTimeOut: 25000,
|
||||
fragLoadingMaxRetry: 6,
|
||||
fragLoadingRetryDelay: 400,
|
||||
});
|
||||
hlsRef.current = hls;
|
||||
observeHls(hls, trace);
|
||||
@@ -85,12 +98,34 @@ export default function Player({
|
||||
if (activity.isActive()) hls.startLoad();
|
||||
if (autoPlay) activity.play("manifest_autoplay", true);
|
||||
});
|
||||
hls.on(Hls.Events.FRAG_BUFFERED, () => {
|
||||
recoverCountRef.current = 0;
|
||||
setErrMsg("");
|
||||
});
|
||||
hls.on(Hls.Events.ERROR, (_e, data) => {
|
||||
if (!data.fatal) return;
|
||||
if (!data.fatal) {
|
||||
if (
|
||||
data.details === Hls.ErrorDetails.BUFFER_STALLED_ERROR ||
|
||||
data.details === Hls.ErrorDetails.FRAG_LOAD_ERROR
|
||||
) {
|
||||
try { hls.startLoad(video.currentTime || -1); } catch { /* ignore */ }
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!activity.isActive()) return;
|
||||
if (data.type === Hls.ErrorTypes.NETWORK_ERROR && recoverCountRef.current < 4) {
|
||||
recoverCountRef.current += 1;
|
||||
try { hls.startLoad(video.currentTime || -1); } catch { /* ignore */ }
|
||||
return;
|
||||
}
|
||||
if (data.type === Hls.ErrorTypes.MEDIA_ERROR && recoverCountRef.current < 4) {
|
||||
recoverCountRef.current += 1;
|
||||
try { hls.recoverMediaError(); video.play().catch(() => {}); } catch { /* ignore */ }
|
||||
return;
|
||||
}
|
||||
const detail = `${data.type}/${data.details}/${data.response?.code ?? ""}/${String(data.reason ?? "").slice(0, 80)}`;
|
||||
(window as unknown as { __hlsErr?: string }).__hlsErr = detail;
|
||||
setErrMsg(detail);
|
||||
if (!activity.isActive()) return;
|
||||
if (data.type === Hls.ErrorTypes.NETWORK_ERROR) hls.startLoad();
|
||||
else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) hls.recoverMediaError();
|
||||
else { hls.destroy(); hlsRef.current = null; }
|
||||
@@ -151,6 +186,8 @@ export default function Player({
|
||||
ref={videoRef}
|
||||
poster={poster}
|
||||
playsInline
|
||||
webkit-playsinline="true"
|
||||
preload="auto"
|
||||
muted={muted}
|
||||
loop={loop}
|
||||
className="w-full h-full object-contain bg-black"
|
||||
@@ -158,7 +195,8 @@ export default function Player({
|
||||
onPlay={() => { if (activity.isActive()) { setPlaying(true); onTogglePlay?.(true); } }}
|
||||
onPause={() => { setPlaying(false); onTogglePlay?.(false); }}
|
||||
onWaiting={() => setWaiting(true)}
|
||||
onPlaying={() => { if (activity.isActive()) { setWaiting(false); onPlaying?.(); } }}
|
||||
onPlaying={() => { if (activity.isActive()) { setWaiting(false); setErrMsg(""); onPlaying?.(); } }}
|
||||
onSeeked={() => setWaiting(false)}
|
||||
onTimeUpdate={(e) => setTime((e.target as HTMLVideoElement).currentTime)}
|
||||
onLoadedMetadata={(e) => setDuration((e.target as HTMLVideoElement).duration || 0)}
|
||||
onEnded={() => { if (activity.isActive()) onEnded?.(); }}
|
||||
|
||||
Reference in New Issue
Block a user