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"
|
||||
|
||||
+7
-5
@@ -82,7 +82,8 @@ function StackPage({ page, onBack, wide, top, bottomInset }: {
|
||||
|
||||
/* ============ 应用主体 ============ */
|
||||
function AppBody() {
|
||||
const { platform, tab, setTab, stack, pop, loginOpen, setLoginOpen, fs } = useStore();
|
||||
const { platform, tab, setTab, stack, pop, loginOpen, setLoginOpen, fs, clean } = useStore();
|
||||
const isMobile = platform === "android" || platform === "ios";
|
||||
const mainRef = useRef<HTMLDivElement>(null);
|
||||
const [wide, setWide] = useState(!isMobile);
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
@@ -117,7 +118,7 @@ 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 = isMobile ? (fs ? 0 : 40) : 14;
|
||||
const bottomInset = isMobile ? (fs || clean ? 0 : 40) : 14;
|
||||
/* 栈页(从搜索/分类/我的进入的播放页、图文页)没有底栏,
|
||||
底部只让出安全区。之前多留了 20px,视频底边会露出一条
|
||||
「底栏」似的窄缝(底部的压暗渐变到不了屏幕最底)。 */
|
||||
@@ -138,7 +139,7 @@ function AppBody() {
|
||||
</div>
|
||||
))}
|
||||
|
||||
{isMobile && !fs && stack.length === 0 && <TabBar />}
|
||||
{isMobile && !fs && !clean && stack.length === 0 && <TabBar />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -215,9 +216,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>
|
||||
|
||||
+548
-198
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { api, cover, fmt, fmtTime, isMobile, mediaUrl } from "../api";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { api, cover, fmt, fmtTime, isMobile } from "../api";
|
||||
import type { Detail, Episode, Post, VideoCard } from "../types";
|
||||
import { useStore } from "../store";
|
||||
import { Avatar, Img, Sheet } from "./ui";
|
||||
@@ -28,10 +29,6 @@ type Props = {
|
||||
startTime?: number;
|
||||
};
|
||||
|
||||
const RATES = [1, 1.25, 1.5, 2];
|
||||
|
||||
const stripHtml = (s: string) => s.replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/\s+/g, " ").trim();
|
||||
|
||||
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;
|
||||
@@ -43,7 +40,7 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
const [epMap, setEpMap] = useState<Record<number, number>>(() => (startEp ? { [videoIds[startIndex]]: startEp } : {}));
|
||||
const [details, setDetails] = useState<Record<number, Detail>>({});
|
||||
const [playUrls, setPlayUrls] = useState<Record<string, string>>({});
|
||||
const [cards, setCards] = useState<Record<number, VideoCard>>({});
|
||||
const [cards] = useState<Record<number, VideoCard>>({});
|
||||
const [posts, setPosts] = useState<Record<number, Post>>({});
|
||||
|
||||
const [time, setTime] = useState(0);
|
||||
@@ -68,6 +65,22 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
const setTheater = store.setTheater;
|
||||
const fs = store.fs;
|
||||
const setFs = store.setFs;
|
||||
const clean = store.clean;
|
||||
const setClean = store.setClean;
|
||||
|
||||
/* 追踪手机视口是否已处于物理/系统横屏状态(window.innerWidth > window.innerHeight) */
|
||||
const [vpLandscape, setVpLandscape] = useState(
|
||||
() => typeof window !== "undefined" && window.innerWidth > window.innerHeight,
|
||||
);
|
||||
|
||||
/* 单击清屏 vs 双击暂停计时器 */
|
||||
const lastTapRef = useRef<{ time: number; timer: number | null }>({ time: 0, timer: null });
|
||||
const clearTapTimer = () => {
|
||||
if (lastTapRef.current.timer) {
|
||||
window.clearTimeout(lastTapRef.current.timer);
|
||||
lastTapRef.current.timer = null;
|
||||
}
|
||||
};
|
||||
|
||||
/* 桌面:鼠标闲置 2.8s 自动隐藏播放器 UI(沉浸) */
|
||||
const [idle, setIdle] = useState(false);
|
||||
@@ -87,7 +100,7 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
}, [paused]);
|
||||
const [fullscreen, setFullscreen] = useState(false);
|
||||
const [heartBurst, setHeartBurst] = useState(0);
|
||||
/* —— 移动端手势 —— */
|
||||
/* —— 移动端手势 & 竖屏横片缩放 —— */
|
||||
const [holdSpeed, setHoldSpeed] = useState(false);
|
||||
const [speedLock, setSpeedLock] = useState(false);
|
||||
const [lockArmed, setLockArmed] = useState(false);
|
||||
@@ -95,12 +108,17 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
const lockArmedRef = useRef(false);
|
||||
const [scrub, setScrub] = useState<{ pct: number; target: number } | null>(null);
|
||||
const scrubTarget = useRef<number | null>(null);
|
||||
/* 竖屏下横屏视频适应模式 + 双指无级缩放/平移 */
|
||||
const [portraitFit, setPortraitFit] = useState<"contain" | "cover">("contain");
|
||||
const [zoom, setZoom] = useState({ scale: 1, x: 0, y: 0, gesturing: false });
|
||||
const pinchRef = useRef<{
|
||||
dist0: number; midX0: number; midY0: number; scale0: number; x0: number; y0: number;
|
||||
} | null>(null);
|
||||
/* 进度条拖动 */
|
||||
const barRef = useRef<HTMLDivElement>(null);
|
||||
const barScrub = useRef(false);
|
||||
const [barPct, setBarPct] = useState<number | null>(null);
|
||||
const gesture = useRef<{
|
||||
x: number; y: number; startY: number; t: number; timer: number | null;
|
||||
x: number; y: number; startX: number; startY: number; t: number; timer: number | null;
|
||||
mode: "idle" | "hold" | "scrub" | "pan"; base: number; width: number; playing: boolean;
|
||||
} | null>(null);
|
||||
|
||||
@@ -113,10 +131,12 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
const episodes = detail?.episodes || [];
|
||||
const post = posts[curId];
|
||||
|
||||
/* 观看进度:onTime 里每 5 秒落一次;退出播放页时再用 liveRef 兜一次 */
|
||||
/* 观看进度:onTime 里每 5 秒落一次;拖动进度条期间忽略底层 timeupdate 防止进度条回跳 */
|
||||
const onTimeTick = (t: number) => {
|
||||
liveRef.current = { id: curId, ep: curEp, dur: duration, t };
|
||||
setTime(t);
|
||||
if (!barScrub.current && gesture.current?.mode !== "scrub") {
|
||||
setTime(t);
|
||||
}
|
||||
const now = Date.now();
|
||||
if (duration > 0 && now - lastSaveRef.current > 5000) {
|
||||
lastSaveRef.current = now;
|
||||
@@ -179,18 +199,122 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
const effRate = holdSpeed || speedLock ? 2 : rate;
|
||||
/* 进度条显示百分比(拖动时用拖动值) */
|
||||
const barProgress = barPct ?? (duration ? time / duration : 0);
|
||||
/* 沉浸全屏 + 横屏视频 → 舞台旋转 90°,看起来就是横屏 */
|
||||
const rotated = !isDesktop && fs && vsize.w > vsize.h && vsize.h > 0;
|
||||
/* 是否为横屏视频(16:9 等宽大于高) */
|
||||
const isLandscapeVideo = vsize.w > vsize.h && vsize.h > 0;
|
||||
/* 仅当「全屏 + 横屏视频 + 手机系统视口尚未横过来 (!vpLandscape)」时才用 CSS 旋转 90° 兜底;
|
||||
一旦系统屏幕已经横过来了 (vpLandscape === true),不再叠加 CSS 旋转,彻底解决手机横置后视频反而竖过去的问题! */
|
||||
const rotated = !isDesktop && fs && isLandscapeVideo && !vpLandscape;
|
||||
|
||||
/* 滚动定位 */
|
||||
/* 借鉴 stclock1988/hghub-ios (PlayerView.swift keepPlayingThroughTransition):
|
||||
iOS 在横竖屏几何旋转或全屏视图层级切换期间,系统底层 AVPlayer / WebKit 视频层可能被短暂挂起暂停。
|
||||
在过渡窗口期内分批重申 play(),确保旋转/全屏切换不中断播放。 */
|
||||
const keepPlayingTimers = useRef<number[]>([]);
|
||||
const keepPlayingThroughTransition = useCallback(() => {
|
||||
keepPlayingTimers.current.forEach((id) => window.clearTimeout(id));
|
||||
keepPlayingTimers.current = [];
|
||||
const el = videoRef.current?.el();
|
||||
const shouldPlay = el ? !el.paused : !paused;
|
||||
if (!shouldPlay) return;
|
||||
for (const delay of [50, 150, 300, 500, 800, 1200]) {
|
||||
const tid = window.setTimeout(() => {
|
||||
const v = videoRef.current?.el();
|
||||
if (v && v.paused && !v.ended) {
|
||||
videoRef.current?.play();
|
||||
}
|
||||
}, delay);
|
||||
keepPlayingTimers.current.push(tid);
|
||||
}
|
||||
}, [paused]);
|
||||
|
||||
useEffect(() => () => {
|
||||
keepPlayingTimers.current.forEach((id) => window.clearTimeout(id));
|
||||
}, []);
|
||||
|
||||
/* 监听手机屏幕横竖屏变化:物理横置手机时自动进入全屏,竖回时自动退出全屏 */
|
||||
useEffect(() => {
|
||||
if (isDesktop) return undefined;
|
||||
const onViewportChange = () => {
|
||||
const isLand = window.innerWidth > window.innerHeight;
|
||||
setVpLandscape((prev) => {
|
||||
if (prev !== isLand && active) {
|
||||
setFs(isLand);
|
||||
keepPlayingThroughTransition();
|
||||
}
|
||||
return isLand;
|
||||
});
|
||||
};
|
||||
window.addEventListener("resize", onViewportChange);
|
||||
window.addEventListener("orientationchange", onViewportChange);
|
||||
return () => {
|
||||
window.removeEventListener("resize", onViewportChange);
|
||||
window.removeEventListener("orientationchange", onViewportChange);
|
||||
};
|
||||
}, [isDesktop, active, setFs, keepPlayingThroughTransition]);
|
||||
|
||||
/* 进入 / 退出全屏:对横屏视频直接调用原生屏幕方向切换,让手机系统界面真正横过来 */
|
||||
const enterFs = useCallback(() => {
|
||||
keepPlayingThroughTransition();
|
||||
setClean(false);
|
||||
setFs(true);
|
||||
if (isLandscapeVideo) {
|
||||
invoke("set_orientation", { landscape: true }).catch(() => {});
|
||||
try {
|
||||
(screen.orientation as unknown as { lock?: (o: string) => Promise<void> })?.lock?.("landscape")?.catch(() => {});
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}, [isLandscapeVideo, setClean, setFs, keepPlayingThroughTransition]);
|
||||
|
||||
const exitFs = useCallback(() => {
|
||||
keepPlayingThroughTransition();
|
||||
setClean(false);
|
||||
setFs(false);
|
||||
invoke("set_orientation", { landscape: false }).catch(() => {});
|
||||
try { screen.orientation?.unlock?.(); } catch { /* ignore */ }
|
||||
}, [setClean, setFs, keepPlayingThroughTransition]);
|
||||
|
||||
/* 全屏状态下若视频宽高刚加载出来且为横屏,自动补发一次横屏指令 */
|
||||
useEffect(() => {
|
||||
if (!isDesktop && fs && isLandscapeVideo) {
|
||||
invoke("set_orientation", { landscape: true }).catch(() => {});
|
||||
}
|
||||
}, [isDesktop, fs, isLandscapeVideo]);
|
||||
|
||||
/* 全屏切换或视口旋转后校准滚动容器 scrollTop:
|
||||
- 进入全屏时非当前项已隐藏,当前项位于顶部 scrollTop = 0;
|
||||
- 退出全屏回到竖屏列表时,立即将 scrollTop 重新对齐到 index * clientHeight,防止错位到其它视频封面。 */
|
||||
useEffect(() => {
|
||||
const el = boxRef.current;
|
||||
if (!el) return undefined;
|
||||
if (fs) {
|
||||
el.scrollTop = 0;
|
||||
return undefined;
|
||||
}
|
||||
const syncScroll = () => {
|
||||
const box = boxRef.current;
|
||||
if (!box || fs) return;
|
||||
box.scrollTop = index * (box.clientHeight || 1);
|
||||
};
|
||||
syncScroll();
|
||||
const raf = requestAnimationFrame(syncScroll);
|
||||
const t1 = window.setTimeout(syncScroll, 120);
|
||||
const t2 = window.setTimeout(syncScroll, 350);
|
||||
return () => {
|
||||
cancelAnimationFrame(raf);
|
||||
window.clearTimeout(t1);
|
||||
window.clearTimeout(t2);
|
||||
};
|
||||
}, [fs, vpLandscape, index]);
|
||||
|
||||
/* 滚动定位(全屏或缩放手势期间锁定索引,避免容器尺寸变化误触发翻页) */
|
||||
const onScroll = useCallback(() => {
|
||||
if (fs || pinchRef.current) return;
|
||||
const el = boxRef.current;
|
||||
if (!el) return;
|
||||
const h = el.clientHeight || 1;
|
||||
const i = Math.max(0, Math.min(videoIds.length - 1, Math.round(el.scrollTop / h)));
|
||||
setIndex((prev) => (prev === i ? prev : i));
|
||||
if (onNearEnd && i >= videoIds.length - 3) onNearEnd();
|
||||
}, [videoIds.length, onNearEnd]);
|
||||
}, [videoIds.length, onNearEnd, fs]);
|
||||
|
||||
const go = useCallback((delta: number) => {
|
||||
const el = boxRef.current;
|
||||
@@ -251,20 +375,35 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [curId, curEp]);
|
||||
|
||||
/* 切换条目/集数时重置播放状态 */
|
||||
/* 切换条目/集数时重置播放与缩放状态 */
|
||||
useEffect(() => {
|
||||
setTime(0); setDuration(0); setBuffered(0); setErr(""); setWaiting(true); setPaused(false); setDescOpen(false);
|
||||
setVsize({ w: 0, h: 0 });
|
||||
setPortraitFit("contain");
|
||||
setZoom({ scale: 1, x: 0, y: 0, gesturing: false });
|
||||
}, [playKey]);
|
||||
|
||||
/* 进出全屏时复位双指缩放并校准滚动条位置 */
|
||||
useEffect(() => {
|
||||
setZoom({ scale: 1, x: 0, y: 0, gesturing: false });
|
||||
if (!fs && boxRef.current) {
|
||||
const el = boxRef.current;
|
||||
requestAnimationFrame(() => {
|
||||
el.scrollTop = index * (el.clientHeight || 1);
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [fs]);
|
||||
|
||||
/* 音量/静音同步 */
|
||||
useEffect(() => { videoRef.current?.mute(muted); }, [muted]);
|
||||
useEffect(() => { videoRef.current?.volume(volume); }, [volume]);
|
||||
/* 倍速同步(长按 2x / 锁定 2x / 基准倍速) */
|
||||
useEffect(() => { videoRef.current?.rate(effRate); }, [effRate, playKey]);
|
||||
|
||||
/* 离开播放页时把最后位置落盘 */
|
||||
/* 离开播放页时把最后位置落盘并清理计时器 */
|
||||
useEffect(() => () => {
|
||||
clearTapTimer();
|
||||
const s = liveRef.current;
|
||||
if (s.id && s.dur) addHistory(s.id, s.ep, s.t, s.dur);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -318,19 +457,91 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
else el.requestFullscreen().catch(() => {});
|
||||
};
|
||||
|
||||
/* —— 长按 2x(上滑锁定) / 横拖定位 / 单击暂停 —— */
|
||||
/* —— 双指捏合缩放 & 平移(Pinch-to-Zoom & Pan) —— */
|
||||
const cancelSingleGesture = () => {
|
||||
clearTapTimer();
|
||||
const g = gesture.current;
|
||||
if (g?.timer) window.clearTimeout(g.timer);
|
||||
gesture.current = null;
|
||||
if (holdRef.current) {
|
||||
holdRef.current = false;
|
||||
setHoldSpeed(false);
|
||||
}
|
||||
lockArmedRef.current = false;
|
||||
setLockArmed(false);
|
||||
setScrub(null);
|
||||
scrubTarget.current = null;
|
||||
};
|
||||
|
||||
const onTouchStart = (e: React.TouchEvent<HTMLDivElement>) => {
|
||||
if (isDesktop || controlsLocked) return;
|
||||
if (e.touches.length === 2) {
|
||||
cancelSingleGesture();
|
||||
const t0 = e.touches[0];
|
||||
const t1 = e.touches[1];
|
||||
const dist0 = Math.max(12, Math.hypot(t1.clientX - t0.clientX, t1.clientY - t0.clientY));
|
||||
const midX0 = (t0.clientX + t1.clientX) / 2;
|
||||
const midY0 = (t0.clientY + t1.clientY) / 2;
|
||||
pinchRef.current = {
|
||||
dist0,
|
||||
midX0,
|
||||
midY0,
|
||||
scale0: zoom.scale,
|
||||
x0: zoom.x,
|
||||
y0: zoom.y,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const onTouchMove = (e: React.TouchEvent<HTMLDivElement>) => {
|
||||
if (isDesktop || controlsLocked) return;
|
||||
if (e.touches.length === 2 && pinchRef.current) {
|
||||
const p = pinchRef.current;
|
||||
const t0 = e.touches[0];
|
||||
const t1 = e.touches[1];
|
||||
const dist = Math.max(12, Math.hypot(t1.clientX - t0.clientX, t1.clientY - t0.clientY));
|
||||
const midX = (t0.clientX + t1.clientX) / 2;
|
||||
const midY = (t0.clientY + t1.clientY) / 2;
|
||||
const nextScale = Math.max(0.85, Math.min(3.5, p.scale0 * (dist / p.dist0)));
|
||||
const rawDx = midX - p.midX0;
|
||||
const rawDy = midY - p.midY0;
|
||||
const dx = rotated ? rawDy : rawDx;
|
||||
const dy = rotated ? -rawDx : rawDy;
|
||||
const maxX = Math.max(0, (nextScale - 1) * window.innerWidth * 0.55);
|
||||
const maxY = Math.max(0, (nextScale - 1) * window.innerHeight * 0.55);
|
||||
const nextX = Math.max(-maxX, Math.min(maxX, p.x0 + dx));
|
||||
const nextY = Math.max(-maxY, Math.min(maxY, p.y0 + dy));
|
||||
setZoom({ scale: nextScale, x: nextX, y: nextY, gesturing: true });
|
||||
}
|
||||
};
|
||||
|
||||
const onTouchEnd = (e: React.TouchEvent<HTMLDivElement>) => {
|
||||
if (isDesktop) return;
|
||||
if (pinchRef.current && e.touches.length < 2) {
|
||||
pinchRef.current = null;
|
||||
setZoom((prev) =>
|
||||
prev.scale < 1.08
|
||||
? { scale: 1, x: 0, y: 0, gesturing: false }
|
||||
: { ...prev, gesturing: false },
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/* —— 长按 2x(上滑锁定) / 横拖定位 / 单击清屏 / 双击暂停 —— */
|
||||
const onDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (isDesktop || controlsLocked || !active || gesture.current || e.button !== 0) return;
|
||||
if (isDesktop || controlsLocked || !active || !e.isPrimary || pinchRef.current || gesture.current || e.button !== 0) return;
|
||||
const el = e.currentTarget;
|
||||
const width = el.clientWidth || 1;
|
||||
const span = rotated ? (el.clientHeight || window.innerHeight || 1) : (el.clientWidth || 1);
|
||||
try { el.setPointerCapture(e.pointerId); } catch { /* ignore */ }
|
||||
const g = {
|
||||
x: e.clientX, y: e.clientY, startY: e.clientY, t: Date.now(), base: time, width,
|
||||
mode: "idle" as "idle" | "hold" | "scrub" | "pan",
|
||||
x: e.clientX, y: e.clientY, startX: e.clientX, startY: e.clientY,
|
||||
t: Date.now(), base: time, width: span,
|
||||
playing: videoRef.current?.el()?.paused === false,
|
||||
mode: "idle" as "idle" | "hold" | "scrub" | "pan",
|
||||
timer: window.setTimeout(() => {
|
||||
const cur = gesture.current;
|
||||
if (!cur || cur.mode !== "idle") return;
|
||||
if (!cur || cur.mode !== "idle" || pinchRef.current) return;
|
||||
clearTapTimer();
|
||||
cur.mode = "hold";
|
||||
holdRef.current = true;
|
||||
setHoldSpeed(true);
|
||||
@@ -343,14 +554,21 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
};
|
||||
|
||||
const onMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (pinchRef.current) {
|
||||
cancelSingleGesture();
|
||||
return;
|
||||
}
|
||||
const g = gesture.current;
|
||||
if (!g || isDesktop) return;
|
||||
const dx = e.clientX - g.x;
|
||||
const dy = e.clientY - g.y;
|
||||
if (!g || isDesktop || !e.isPrimary) return;
|
||||
const rawDx = e.clientX - g.x;
|
||||
const rawDy = e.clientY - g.y;
|
||||
const dx = rotated ? rawDy : rawDx;
|
||||
const dy = rotated ? -rawDx : rawDy;
|
||||
|
||||
/* 长按中:上滑 64px 进入「松开即锁定」 */
|
||||
if (g.mode === "hold") {
|
||||
const armed = g.startY - e.clientY > 64;
|
||||
const upDist = rotated ? (e.clientX - g.startX) : (g.startY - e.clientY);
|
||||
const armed = upDist > 64;
|
||||
if (armed !== lockArmedRef.current) {
|
||||
lockArmedRef.current = armed;
|
||||
setLockArmed(armed);
|
||||
@@ -359,11 +577,12 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
}
|
||||
|
||||
if (g.mode === "idle") {
|
||||
if (Math.abs(dx) > 14 && Math.abs(dx) > Math.abs(dy)) {
|
||||
if (Math.abs(dx) > 16 && Math.abs(dx) > Math.abs(dy) * 1.2) {
|
||||
clearTapTimer();
|
||||
if (g.timer) window.clearTimeout(g.timer);
|
||||
g.mode = "scrub";
|
||||
videoRef.current?.pause();
|
||||
} else if (Math.abs(dy) > 14) {
|
||||
} else if (Math.abs(dy) > 16) {
|
||||
clearTapTimer();
|
||||
if (g.timer) window.clearTimeout(g.timer);
|
||||
g.mode = "pan";
|
||||
}
|
||||
@@ -373,13 +592,14 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
if (g.mode === "scrub") {
|
||||
const total = duration || 0;
|
||||
if (!total) return;
|
||||
const target = Math.max(0, Math.min(total, g.base + (dx / g.width) * total));
|
||||
const target = Math.max(0, Math.min(total - 0.2, g.base + (dx / g.width) * total));
|
||||
scrubTarget.current = target;
|
||||
setScrub({ pct: (target / total) * 100, target });
|
||||
}
|
||||
};
|
||||
|
||||
const onUp = (cancelled = false) => {
|
||||
const onUp = (e?: React.PointerEvent<HTMLDivElement>, cancelled = false) => {
|
||||
if (pinchRef.current) return;
|
||||
const g = gesture.current;
|
||||
gesture.current = null;
|
||||
if (!g) return;
|
||||
@@ -398,17 +618,40 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
}
|
||||
if (g.mode === "scrub") {
|
||||
const target = scrubTarget.current;
|
||||
if (!cancelled && target != null) videoRef.current?.seek(target, "mobile_gesture");
|
||||
setScrub(null);
|
||||
scrubTarget.current = null;
|
||||
if (!cancelled && target != null) {
|
||||
setErr("");
|
||||
setTime(target);
|
||||
videoRef.current?.seek(target, "mobile_gesture");
|
||||
}
|
||||
if (g.playing && active) videoRef.current?.play();
|
||||
return;
|
||||
}
|
||||
if (!cancelled && g.mode === "idle" && Date.now() - g.t < 260) videoRef.current?.toggle();
|
||||
|
||||
if (cancelled || g.mode !== "idle") return;
|
||||
const moveDist = e ? Math.hypot(e.clientX - g.x, e.clientY - g.y) : 0;
|
||||
if (Date.now() - g.t < 260 && moveDist < 16) {
|
||||
const now = Date.now();
|
||||
if (now - lastTapRef.current.time < 280) {
|
||||
// 双击屏幕:切换暂停 / 播放
|
||||
clearTapTimer();
|
||||
lastTapRef.current.time = 0;
|
||||
videoRef.current?.toggle();
|
||||
} else {
|
||||
// 单击屏幕:切换清屏模式(消除或恢复所有界面控件,只显示视频内容)
|
||||
lastTapRef.current.time = now;
|
||||
clearTapTimer();
|
||||
lastTapRef.current.timer = window.setTimeout(() => {
|
||||
lastTapRef.current.timer = null;
|
||||
setClean((c) => !c);
|
||||
}, 250) as unknown as number;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!active || controlsLocked) onUp(true);
|
||||
if (!active || controlsLocked) onUp(undefined, true);
|
||||
// Cancel pending gestures when the page is hidden or controls are locked.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [active, controlsLocked]);
|
||||
@@ -420,28 +663,32 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
|
||||
const lockControls = () => { setPanel(null); setControlsLocked(true); };
|
||||
|
||||
/* 长按倍速期间禁止原生滚动,否则上滑会被列表吃掉、锁不住倍速 */
|
||||
/* 长按倍速 / 双指缩放 / 全屏期间禁止外层列表原生滚动 */
|
||||
useEffect(() => {
|
||||
if (isDesktop) return undefined;
|
||||
const el = boxRef.current;
|
||||
if (!el) return undefined;
|
||||
const fn = (e: TouchEvent) => { if (holdRef.current) e.preventDefault(); };
|
||||
const fn = (e: TouchEvent) => {
|
||||
if (holdRef.current || pinchRef.current || fs || e.touches.length >= 2) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
el.addEventListener("touchmove", fn, { passive: false });
|
||||
return () => el.removeEventListener("touchmove", fn);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isDesktop, videoIds.length]);
|
||||
}, [isDesktop, videoIds.length, fs]);
|
||||
|
||||
/* —— 进度条拖动(旋转舞台下按 Y 轴换算) —— */
|
||||
const barPctAt = (clientX: number, clientY: number) => {
|
||||
const r = barRef.current?.getBoundingClientRect();
|
||||
/* —— 进度条拖动(直接用当前触发元素的 BoundingRect,旋转舞台下按 Y 轴换算) —— */
|
||||
const barPctAt = (barEl: HTMLElement | null, clientX: number, clientY: number) => {
|
||||
const r = barEl?.getBoundingClientRect();
|
||||
if (!r) return null;
|
||||
const span = rotated ? r.height : r.width;
|
||||
if (!span) return null;
|
||||
const raw = rotated ? (clientY - r.top) / span : (clientX - r.left) / span;
|
||||
return Math.max(0, Math.min(1, raw));
|
||||
};
|
||||
const barSeekTo = (clientX: number, clientY: number) => {
|
||||
const pct = barPctAt(clientX, clientY);
|
||||
const barSeekTo = (barEl: HTMLElement | null, clientX: number, clientY: number) => {
|
||||
const pct = barPctAt(barEl, clientX, clientY);
|
||||
if (pct == null) return null;
|
||||
setBarPct(pct);
|
||||
return pct;
|
||||
@@ -450,27 +697,29 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
e.stopPropagation();
|
||||
videoRef.current?.trace("seek.input.down", { input: "mobile_bar" });
|
||||
barScrub.current = true;
|
||||
try { (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId); } catch { /* ignore */ }
|
||||
barSeekTo(e.clientX, e.clientY);
|
||||
const el = e.currentTarget as HTMLElement;
|
||||
try { el.setPointerCapture(e.pointerId); } catch { /* ignore */ }
|
||||
barSeekTo(el, e.clientX, e.clientY);
|
||||
};
|
||||
const onBarMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!barScrub.current) return;
|
||||
e.stopPropagation();
|
||||
videoRef.current?.trace("seek.input.move", { input: "mobile_bar" });
|
||||
barSeekTo(e.clientX, e.clientY);
|
||||
barSeekTo(e.currentTarget as HTMLElement, e.clientX, e.clientY);
|
||||
};
|
||||
const onBarUp = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!barScrub.current) return;
|
||||
barScrub.current = false;
|
||||
e.stopPropagation();
|
||||
const pct = barPctAt(e.clientX, e.clientY);
|
||||
if (pct != null && duration) {
|
||||
const target = pct * duration;
|
||||
const pct = barPctAt(e.currentTarget as HTMLElement, e.clientX, e.clientY) ?? barPct;
|
||||
setBarPct(null);
|
||||
if (pct != null && duration > 0) {
|
||||
const target = Math.max(0, Math.min(duration - 0.15, pct * duration));
|
||||
setErr("");
|
||||
setTime(target);
|
||||
videoRef.current?.trace("seek.input.up", { input: "mobile_bar", target });
|
||||
videoRef.current?.seek(target, "mobile_bar");
|
||||
setTime(target);
|
||||
}
|
||||
setBarPct(null);
|
||||
};
|
||||
|
||||
const togglePip = async () => {
|
||||
@@ -521,43 +770,194 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
return <div className="absolute inset-0 bg-black flex items-center justify-center"><div className="w-9 h-9 spinner" /></div>;
|
||||
}
|
||||
|
||||
const effectiveFit: "contain" | "cover" = isDesktop
|
||||
? "contain"
|
||||
: isLandscapeVideo
|
||||
? (fs || vpLandscape ? "contain" : portraitFit)
|
||||
: (vpLandscape ? "contain" : "cover");
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`hg-player-ui absolute inset-0 overflow-hidden bg-black player-root ${controlsLocked ? "is-locked" : ""} ${isDesktop ? "player-surface" : ""} ${theater ? "is-theater" : ""} ${rotated ? "fs-landscape" : ""} ${isDesktop && idle ? "is-idle" : ""}`}
|
||||
className={`hg-player-ui absolute inset-0 overflow-hidden bg-black player-root ${controlsLocked ? "is-locked" : ""} ${isDesktop ? "player-surface" : ""} ${theater ? "is-theater" : ""} ${isDesktop && idle ? "is-idle" : ""}`}
|
||||
onPointerMove={() => { if (isDesktop) wake(); }}>
|
||||
<div className="absolute inset-0" inert={controlsLocked}>
|
||||
{/* 氛围背景 */}
|
||||
<div className="absolute inset-0 scale-110 blur-3xl opacity-25 pointer-events-none">
|
||||
{posterUrl && <img src={posterUrl} alt="" className="w-full h-full object-cover" />}
|
||||
</div>
|
||||
{/* 氛围背景(全屏时隐藏,避免透出封面底图) */}
|
||||
{!fs && (
|
||||
<div className="absolute inset-0 scale-110 blur-3xl opacity-25 pointer-events-none">
|
||||
{posterUrl && <img src={posterUrl} alt="" className="w-full h-full object-cover" />}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div ref={boxRef} onScroll={onScroll}
|
||||
className="absolute inset-y-0 left-0 overflow-y-scroll no-bar snap-y snap-mandatory overscroll-y-contain"
|
||||
className={`absolute inset-y-0 left-0 no-bar ${fs ? "overflow-hidden" : "overflow-y-scroll snap-y snap-mandatory overscroll-y-contain"}`}
|
||||
style={{ right: isDesktop && panel ? 372 : 0, transition: "right .3s cubic-bezier(.2,0,0,1)" }}>
|
||||
{videoIds.map((vid, i) => {
|
||||
const isActive = i === index;
|
||||
return (
|
||||
<section key={vid} className="relative w-full h-full snap-start snap-always overflow-hidden">
|
||||
<section
|
||||
key={vid}
|
||||
style={!isActive && fs ? { display: "none" } : undefined}
|
||||
className={`relative w-full h-full snap-start snap-always ${fs && isActive ? "" : "overflow-hidden"}`}>
|
||||
{isActive && playUrl ? (
|
||||
<div className="absolute inset-0" style={{ touchAction: "pan-y" }}
|
||||
onPointerDown={onDown} onPointerMove={onMove} onPointerUp={() => onUp()} onPointerCancel={() => onUp(true)} onLostPointerCapture={() => onUp(true)}>
|
||||
<VideoSurface ref={videoRef} src={playUrl} poster={posterUrl} autoPlay active={active} muted={muted}
|
||||
diagnosticContext={{ active, view: mode, kind, video_id: curId, episode: curEp }}
|
||||
volume={volume} rate={effRate}
|
||||
fit={isDesktop || (vsize.w > 0 && vsize.w > vsize.h) ? "contain" : "cover"}
|
||||
onClick={() => { if (isDesktop) videoRef.current?.toggle(); }}
|
||||
onTime={onTimeTick}
|
||||
onDuration={onDurationTick}
|
||||
onSize={(w, h) => setVsize({ w, h })}
|
||||
onPlaying={() => { setPaused(false); setWaiting(false); }}
|
||||
onPause={() => setPaused(true)}
|
||||
onWaiting={() => setWaiting(true)}
|
||||
onEnded={() => { const next = episodes.find((e) => e.ep_num === curEp + 1); if (next) pickEp(next.ep_num); }}
|
||||
onError={(m) => setErr(m)} />
|
||||
<div className={rotated ? "fs-landscape" : (!isDesktop && fs ? "fs-immersive" : "absolute inset-0")}>
|
||||
<div
|
||||
className="absolute inset-0 overflow-hidden"
|
||||
style={{ touchAction: fs || zoom.scale > 1.05 ? "none" : "pan-y" }}
|
||||
onTouchStart={onTouchStart}
|
||||
onTouchMove={onTouchMove}
|
||||
onTouchEnd={onTouchEnd}
|
||||
onTouchCancel={onTouchEnd}
|
||||
onPointerDown={onDown}
|
||||
onPointerMove={onMove}
|
||||
onPointerUp={(e) => onUp(e, false)}
|
||||
onPointerCancel={(e) => onUp(e, true)}
|
||||
onLostPointerCapture={(e) => onUp(e, true)}>
|
||||
<VideoSurface
|
||||
ref={videoRef}
|
||||
src={playUrl}
|
||||
poster={fs ? undefined : posterUrl}
|
||||
autoPlay
|
||||
active={active}
|
||||
diagnosticContext={{ active, view: mode, kind, video_id: curId, episode: curEp }}
|
||||
muted={muted}
|
||||
volume={volume}
|
||||
rate={effRate}
|
||||
fit={effectiveFit}
|
||||
scale={zoom.scale}
|
||||
panX={zoom.x}
|
||||
panY={zoom.y}
|
||||
isGesturing={zoom.gesturing}
|
||||
onClick={() => { if (isDesktop) videoRef.current?.toggle(); }}
|
||||
onTime={onTimeTick}
|
||||
onDuration={onDurationTick}
|
||||
onSize={(w, h) => setVsize({ w, h })}
|
||||
onPlaying={() => { setPaused(false); setWaiting(false); setErr(""); }}
|
||||
onPause={() => setPaused(true)}
|
||||
onWaiting={() => setWaiting(true)}
|
||||
onEnded={() => { const next = episodes.find((e) => e.ep_num === curEp + 1); if (next) pickEp(next.ep_num); }}
|
||||
onError={(m) => setErr(m)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 横拖定位浮层 */}
|
||||
{!isDesktop && scrub && (
|
||||
<div className="absolute inset-0 z-30 flex flex-col items-center justify-center pointer-events-none" style={{ background: "rgba(0,0,0,.25)" }}>
|
||||
<span className="text-[26px] font-bold hg-ink tabular-nums hg-ov-shadow">{fmtTime(scrub.target)}</span>
|
||||
<span className="text-[11px] hg-ink-4 mt-1 tabular-nums">/ {fmtTime(duration)}</span>
|
||||
<div className="mt-4 w-[62%] h-[3px] rounded-full overflow-hidden" style={{ background: "rgba(255,255,255,.25)" }}>
|
||||
<div className="h-full bg-white" style={{ width: `${scrub.pct}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 暂停 / 缓冲 / 报错恢复 */}
|
||||
{paused && !err && (
|
||||
<div className="absolute inset-0 z-10 flex items-center justify-center pointer-events-none">
|
||||
<span className="w-[66px] h-[66px] rounded-full flex items-center justify-center backdrop-blur-md"
|
||||
style={{ background: "rgba(0,0,0,.55)", boxShadow: "inset 0 0 0 1px rgba(255,255,255,.12)" }}>
|
||||
<IPlayF size={28} className="hg-ink ml-0.5" />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{waiting && !err && !paused && (
|
||||
<div className="absolute inset-0 z-10 flex items-center justify-center pointer-events-none"><div className="w-9 h-9 spinner" /></div>
|
||||
)}
|
||||
{err && (
|
||||
<div className="absolute inset-0 z-30 flex items-center justify-center">
|
||||
<div className="rounded-xl p-5 flex flex-col items-center gap-3 text-[13px] hg-ink-2" style={{ background: "rgba(0,0,0,.74)" }}>
|
||||
<span>视频暂时无法加载</span>
|
||||
<span className="text-[10.5px] hg-ink-4 max-w-[240px] text-center break-all">{err}</span>
|
||||
<button className="px-4 py-1.5 rounded-full hg-chip-strong hg-link text-[12.5px] font-semibold pressable"
|
||||
onClick={() => { setErr(""); setWaiting(true); videoRef.current?.reload(); }}>
|
||||
重新加载
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 移动端:倍速状态 / 锁定提示 */}
|
||||
{!isDesktop && (!clean || holdSpeed) && (holdSpeed || speedLock || rate !== 1) && (
|
||||
<button
|
||||
onClick={() => {
|
||||
if (speedLock) { setSpeedLock(false); toast("已解除倍速锁定", "info"); }
|
||||
else if (rate !== 1 && !holdSpeed) setRate(1);
|
||||
}}
|
||||
className={`absolute left-1/2 -translate-x-1/2 z-30 flex items-center gap-1.5 px-3.5 h-8 rounded-full backdrop-blur-md text-[12px] font-bold elev-2 pressable ${speedLock ? "bg-primary text-on-primary" : "hg-chip hg-gold"}`}
|
||||
style={{ top: rotated || vpLandscape ? 14 : "calc(var(--sat, 0px) + 54px)" }}>
|
||||
<IBoltF size={13} />
|
||||
{effRate}x {speedLock ? "已锁定 · 点按解除" : holdSpeed ? "倍速中 · 松开恢复" : "倍速"}
|
||||
</button>
|
||||
)}
|
||||
{!isDesktop && holdSpeed && (
|
||||
<div
|
||||
className={`absolute left-1/2 -translate-x-1/2 z-30 flex items-center gap-2 px-4 h-10 rounded-xl backdrop-blur-md elev-2 transition-all duration-200 ${lockArmed ? "bg-primary text-on-primary scale-110" : "hg-chip-strong hg-ink-2"}`}
|
||||
style={{ top: "38%" }}>
|
||||
<ILockF size={16} />
|
||||
<span className="text-[12.5px] font-bold">{lockArmed ? "松开锁定 2.0x" : "上滑到此锁定倍速"}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 移动端:沉浸全屏控制栏(清屏 clean 模式下隐藏,单击屏幕可呼出/隐藏) */}
|
||||
{!isDesktop && fs && !clean && !controlsLocked && (
|
||||
<>
|
||||
<div className="absolute right-4 z-40 flex items-center gap-2"
|
||||
style={{ top: rotated || vpLandscape ? 14 : "calc(var(--sat, 0px) + 8px)" }}>
|
||||
<button onClick={lockControls} aria-label="锁定播放控制" title="锁定播放控制" aria-pressed={false}
|
||||
className="hg-chip-strong w-9 h-9 rounded-full backdrop-blur-md flex items-center justify-center pressable elev-1">
|
||||
<ILockF size={17} />
|
||||
</button>
|
||||
<button onClick={exitFs} aria-label="退出全屏"
|
||||
className="hg-chip-strong w-9 h-9 rounded-full backdrop-blur-md flex items-center justify-center pressable elev-1">
|
||||
<ICompress size={18} />
|
||||
</button>
|
||||
</div>
|
||||
{zoom.scale > 1.05 && (
|
||||
<button
|
||||
onClick={() => setZoom({ scale: 1, x: 0, y: 0, gesturing: false })}
|
||||
className="hg-chip-strong absolute left-4 z-40 px-3 h-8 rounded-full backdrop-blur-md text-[11.5px] font-semibold flex items-center gap-1 pressable elev-1"
|
||||
style={{ top: rotated || vpLandscape ? 14 : "calc(var(--sat, 0px) + 8px)" }}>
|
||||
还原画面 ({zoom.scale.toFixed(1)}x)
|
||||
</button>
|
||||
)}
|
||||
<div className="absolute inset-x-0 z-30 px-4" style={{ bottom: rotated || vpLandscape ? 46 : "calc(var(--sab, 0px) + 52px)", height: 26 }}>
|
||||
<div className="relative h-full" style={{ touchAction: "none" }}
|
||||
onPointerDown={onBarDown} onPointerMove={onBarMove} onPointerUp={onBarUp} onPointerCancel={onBarUp}>
|
||||
<div className={`absolute inset-x-0 bottom-[10px] rounded-full transition-all ${barPct !== null ? "h-[5px]" : "h-[3px]"}`}
|
||||
style={{ background: "rgba(255,255,255,.3)" }}>
|
||||
<div className="h-full rounded-full bg-white" style={{ width: `${barProgress * 100}%` }} />
|
||||
</div>
|
||||
{barPct !== null && (
|
||||
<div className="absolute left-1/2 -translate-x-1/2 -top-8 px-2.5 py-1 rounded-md hg-chip-strong backdrop-blur-md text-[12px] font-bold tabular-nums whitespace-nowrap">
|
||||
{fmtTime(barPct * (duration || 0))} / {fmtTime(duration)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="absolute inset-x-0 z-40 flex items-center gap-3 px-4"
|
||||
style={{ bottom: rotated || vpLandscape ? 10 : "calc(var(--sab, 0px) + 10px)" }}>
|
||||
<button onClick={() => videoRef.current?.toggle()}
|
||||
className="hg-chip shrink-0 w-9 h-9 rounded-full flex items-center justify-center pressable">
|
||||
{paused ? <IPlayF size={18} /> : <IPauseF size={17} />}
|
||||
</button>
|
||||
<span className="shrink-0 text-[11.5px] font-semibold hg-ink-2 tabular-nums">{fmtTime(time)}</span>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (speedLock) { setSpeedLock(false); return; }
|
||||
const seq = [1, 1.25, 1.5, 2];
|
||||
const idx = seq.indexOf(rate);
|
||||
setRate(seq[(idx + 1) % seq.length]);
|
||||
}}
|
||||
className={`ml-auto shrink-0 flex items-center gap-1 px-2.5 h-8 rounded-full text-[12px] font-bold pressable ${effRate !== 1 ? "bg-primary text-on-primary" : "hg-chip hg-ink-2"}`}>
|
||||
<IBoltF size={12} />{effRate}x
|
||||
</button>
|
||||
<span className="shrink-0 text-[11.5px] hg-ink-4 tabular-nums">{fmtTime(duration)}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="absolute inset-0">
|
||||
<Img src={detail?.cover || cards[vid]?.cover || posts[vid]?.cover || ""} eager={Math.abs(i - index) <= 1} />
|
||||
<Img src={cards[vid]?.cover || posts[vid]?.cover || details[vid]?.cover || (isActive ? detail?.cover : "") || ""} eager={Math.abs(i - index) <= 1} />
|
||||
<div className="absolute inset-0" style={{ background: "rgba(0,0,0,.25)" }} />
|
||||
</div>
|
||||
)}
|
||||
@@ -573,12 +973,57 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 渐变压暗,保证文字可读 */}
|
||||
<div className="absolute inset-0 pointer-events-none"
|
||||
style={{ background: "linear-gradient(0deg, rgba(8,11,15,.86) 0, rgba(11,14,20,.18) 26%, transparent 48%)" }} />
|
||||
{/* 渐变压暗,保证文字可读(清屏模式下不加压暗遮罩,只显示纯视频内容) */}
|
||||
{!fs && !clean && (
|
||||
<div className="absolute inset-0 pointer-events-none"
|
||||
style={{ background: "linear-gradient(0deg, rgba(8,11,15,.86) 0, rgba(11,14,20,.18) 26%, transparent 48%)" }} />
|
||||
)}
|
||||
|
||||
{/* 竖屏下观看横屏视频:快捷「放大铺满 / 完整显示 / 全屏横屏」与双指缩放复位胶囊 */}
|
||||
{isActive && !fs && !clean && !isDesktop && (isLandscapeVideo || zoom.scale > 1.05) && (
|
||||
<div
|
||||
className="absolute left-1/2 -translate-x-1/2 z-20 flex items-center gap-2"
|
||||
style={{ top: "64%" }}>
|
||||
{isLandscapeVideo && (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (zoom.scale > 1.05) {
|
||||
setZoom({ scale: 1, x: 0, y: 0, gesturing: false });
|
||||
setPortraitFit("contain");
|
||||
} else {
|
||||
setPortraitFit((f) => (f === "contain" ? "cover" : "contain"));
|
||||
}
|
||||
}}
|
||||
className="hg-chip-strong backdrop-blur-md px-3 h-7 rounded-full text-[11.5px] font-semibold flex items-center gap-1.5 pressable elev-1">
|
||||
{zoom.scale > 1.05
|
||||
? `还原缩放 (${zoom.scale.toFixed(1)}x)`
|
||||
: portraitFit === "contain"
|
||||
? "放大铺满"
|
||||
: "完整适应"}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={enterFs}
|
||||
className="hg-chip-strong backdrop-blur-md px-3 h-7 rounded-full text-[11.5px] font-semibold flex items-center gap-1 pressable elev-1">
|
||||
<IExpand size={12} />横屏全屏
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{!isLandscapeVideo && zoom.scale > 1.05 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setZoom({ scale: 1, x: 0, y: 0, gesturing: false })}
|
||||
className="hg-chip-strong backdrop-blur-md px-3 h-7 rounded-full text-[11.5px] font-semibold flex items-center gap-1 pressable elev-1">
|
||||
还原画面 ({zoom.scale.toFixed(1)}x)
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 顶部 */}
|
||||
{!fs && mode === "context" ? (
|
||||
{!fs && !clean && mode === "context" ? (
|
||||
isDesktop ? (
|
||||
<div className="desktop-context-header">
|
||||
<button onClick={onBack} aria-label="返回"><IBack size={17} /></button>
|
||||
@@ -596,7 +1041,7 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
|
||||
{/* 右侧操作栏(移动端):收藏 / 评论 / 全屏 / 分享
|
||||
颜色写死不跟主题走:浅色主题下这些字必须仍是白色 */}
|
||||
{!fs && !isDesktop && (
|
||||
{!fs && !clean && !isDesktop && (
|
||||
<div className="absolute right-3 z-20 flex flex-col items-center gap-[16px]"
|
||||
style={{ bottom: `calc(var(--sab, 0px) + ${bottomInset + 92}px)` }}>
|
||||
<button onClick={onFav} className="flex flex-col items-center gap-1 pressable" aria-pressed={isFav(curId)} aria-label="收藏">
|
||||
@@ -607,7 +1052,7 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
<ICommentF size={26} className="hg-ink hg-ov-shadow" />
|
||||
<span className="text-[10.5px] hg-ink-2 hg-ov-shadow">评论</span>
|
||||
</button>
|
||||
<button onClick={() => setFs(true)} className="flex flex-col items-center gap-1 pressable" aria-label="全屏">
|
||||
<button onClick={enterFs} className="flex flex-col items-center gap-1 pressable" aria-label="全屏">
|
||||
<IExpand size={26} className="hg-ink hg-ov-shadow" />
|
||||
<span className="text-[10.5px] hg-ink-2 hg-ov-shadow">全屏</span>
|
||||
</button>
|
||||
@@ -692,63 +1137,32 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 移动端:标题 + 详情标签 + 进度线(不加底色,只铺一层柔和压暗保证可读) */}
|
||||
{!fs && !isDesktop && (
|
||||
{/* 移动端:标题 + 详情标签 + 进度线(清屏 clean 模式下隐藏) */}
|
||||
{!fs && !clean && !isDesktop && (
|
||||
<div className="absolute inset-x-0 z-20" style={{ bottom: `calc(var(--sab, 0px) + ${bottomInset}px)` }}>
|
||||
<div className="absolute inset-x-0 bottom-0 h-[190px] pointer-events-none"
|
||||
style={{ background: "linear-gradient(0deg, rgba(0,0,0,.82) 0%, rgba(0,0,0,.42) 45%, transparent 100%)" }} />
|
||||
<p className="relative px-4 pb-2 text-[14px] font-semibold leading-snug hg-ink hg-ov-shadow clamp-2">{meta.title}</p>
|
||||
<div className="relative pt-1.5 pb-2.5">
|
||||
<div className="relative pt-1.5 pb-2">
|
||||
<button onClick={() => setPanel("detail")}
|
||||
className="px-4 flex items-center gap-0.5 text-[10.5px] font-medium hg-ink hg-ov-shadow pressable">
|
||||
详情 · 第 {curEp} 集<IChevR size={11} />
|
||||
</button>
|
||||
<div ref={barRef} className="mx-4 mt-2 relative" style={{ height: 14, touchAction: "none" }}
|
||||
onPointerDown={onBarDown} onPointerMove={onBarMove} onPointerUp={onBarUp} onPointerCancel={onBarUp}>
|
||||
<div className="absolute inset-x-0 top-1/2 -translate-y-1/2 h-[2.5px] rounded-full" style={{ background: "rgba(255,255,255,.3)" }}>
|
||||
<div className="h-full rounded-full bg-white"
|
||||
style={{ width: `${barProgress * 100}%`, transition: barPct !== null ? "none" : "width .25s linear" }} />
|
||||
</div>
|
||||
{barPct !== null && (
|
||||
<div className="absolute left-1/2 -translate-x-1/2 -top-8 px-2.5 py-1 rounded-md hg-chip-strong backdrop-blur-md text-[12px] font-bold tabular-nums whitespace-nowrap">
|
||||
{fmtTime(barPct * (duration || 0))}
|
||||
{isActive && (
|
||||
<div className="mx-4 mt-1.5 relative" style={{ height: 22, touchAction: "none" }}
|
||||
onPointerDown={onBarDown} onPointerMove={onBarMove} onPointerUp={onBarUp} onPointerCancel={onBarUp}>
|
||||
<div className={`absolute inset-x-0 top-1/2 -translate-y-1/2 rounded-full transition-all ${barPct !== null ? "h-[5px]" : "h-[2.5px]"}`}
|
||||
style={{ background: "rgba(255,255,255,.3)" }}>
|
||||
<div className="h-full rounded-full bg-white"
|
||||
style={{ width: `${barProgress * 100}%`, transition: barPct !== null ? "none" : "width .25s linear" }} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{/* 横拖定位浮层 */}
|
||||
{!isDesktop && scrub && (
|
||||
<div className="absolute inset-0 z-30 flex flex-col items-center justify-center pointer-events-none" style={{ background: "rgba(0,0,0,.25)" }}>
|
||||
<span className="text-[26px] font-bold hg-ink tabular-nums hg-ov-shadow">{fmtTime(scrub.target)}</span>
|
||||
<span className="text-[11px] hg-ink-4 mt-1 tabular-nums">/ {fmtTime(duration)}</span>
|
||||
<div className="mt-4 w-[62%] h-[3px] rounded-full overflow-hidden" style={{ background: "rgba(255,255,255,.25)" }}>
|
||||
<div className="h-full bg-white" style={{ width: `${scrub.pct}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 暂停 / 缓冲 */}
|
||||
{isActive && paused && !err && (
|
||||
<div className="absolute inset-0 z-10 flex items-center justify-center pointer-events-none">
|
||||
<span className="w-[66px] h-[66px] rounded-full flex items-center justify-center backdrop-blur-md"
|
||||
style={{ background: "rgba(0,0,0,.55)", boxShadow: "inset 0 0 0 1px rgba(255,255,255,.12)" }}>
|
||||
<IPlayF size={28} className="hg-ink ml-0.5" />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{isActive && waiting && !err && !paused && (
|
||||
<div className="absolute inset-0 z-10 flex items-center justify-center pointer-events-none"><div className="w-9 h-9 spinner" /></div>
|
||||
)}
|
||||
{isActive && err && (
|
||||
<div className="absolute inset-0 z-20 flex items-center justify-center">
|
||||
<div className="rounded-xl p-5 flex flex-col items-center gap-3 text-[13px] hg-ink-2" style={{ background: "rgba(0,0,0,.7)" }}>
|
||||
<span>视频暂时无法加载</span>
|
||||
<span className="text-[10.5px] hg-ink-4 max-w-[240px] text-center break-all">{err}</span>
|
||||
<button className="hg-link text-[12.5px]" onClick={() => { setErr(""); setWaiting(true); videoRef.current?.play(); }}>重试</button>
|
||||
{barPct !== null && (
|
||||
<div className="absolute left-1/2 -translate-x-1/2 -top-8 px-2.5 py-1 rounded-md hg-chip-strong backdrop-blur-md text-[12px] font-bold tabular-nums whitespace-nowrap">
|
||||
{fmtTime(barPct * (duration || 0))} / {fmtTime(duration)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@@ -785,70 +1199,6 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 移动端:倍速状态 / 锁定提示 */}
|
||||
{!isDesktop && (holdSpeed || speedLock || rate !== 1) && (
|
||||
<button
|
||||
onClick={() => {
|
||||
if (speedLock) { setSpeedLock(false); toast("已解除倍速锁定", "info"); }
|
||||
else if (rate !== 1 && !holdSpeed) setRate(1);
|
||||
}}
|
||||
className={`absolute left-1/2 -translate-x-1/2 z-30 flex items-center gap-1.5 px-3.5 h-8 rounded-full backdrop-blur-md text-[12px] font-bold elev-2 pressable ${speedLock ? "bg-primary text-on-primary" : "hg-chip hg-gold"}`}
|
||||
style={{ top: "calc(var(--sat, 0px) + 54px)" }}>
|
||||
<IBoltF size={13} />
|
||||
{effRate}x {speedLock ? "已锁定 · 点按解除" : holdSpeed ? "倍速中 · 松开恢复" : "倍速"}
|
||||
</button>
|
||||
)}
|
||||
{!isDesktop && holdSpeed && (
|
||||
<div
|
||||
className={`absolute left-1/2 -translate-x-1/2 z-30 flex items-center gap-2 px-4 h-10 rounded-xl backdrop-blur-md elev-2 transition-all duration-200 ${lockArmed ? "bg-primary text-on-primary scale-110" : "hg-chip-strong hg-ink-2"}`}
|
||||
style={{ top: "38%" }}>
|
||||
<ILockF size={16} />
|
||||
<span className="text-[12.5px] font-bold">{lockArmed ? "松开锁定 2.0x" : "上滑到此锁定倍速"}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 移动端全屏模式下的进度条(普通模式的进度条在底部灰块里) */}
|
||||
{!isDesktop && fs && (
|
||||
<div className="absolute inset-x-0 z-30 px-4" style={{ bottom: "calc(var(--sab, 0px) + 52px)", height: 22 }}>
|
||||
<div ref={barRef} className="relative h-full" style={{ touchAction: "none" }}
|
||||
onPointerDown={onBarDown} onPointerMove={onBarMove} onPointerUp={onBarUp} onPointerCancel={onBarUp}>
|
||||
<div className="absolute inset-x-0 bottom-[8px] h-[2.5px] rounded-full" style={{ background: "rgba(255,255,255,.3)" }}>
|
||||
<div className="h-full rounded-full bg-white" style={{ width: `${barProgress * 100}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 移动端:沉浸全屏(安卓 WebView 不支持 Fullscreen API,改用应用内沉浸层) */}
|
||||
{!isDesktop && fs && (
|
||||
<>
|
||||
<button onClick={() => setFs(false)} aria-label="退出全屏"
|
||||
className="hg-chip-strong absolute right-3 z-40 w-9 h-9 rounded-full backdrop-blur-md flex items-center justify-center pressable elev-1"
|
||||
style={{ top: "calc(var(--sat, 0px) + 6px)" }}>
|
||||
<ICompress size={18} />
|
||||
</button>
|
||||
<div className="absolute inset-x-0 z-40 flex items-center gap-3 px-4"
|
||||
style={{ bottom: "calc(var(--sab, 0px) + 10px)" }}>
|
||||
<button onClick={() => videoRef.current?.toggle()}
|
||||
className="hg-chip shrink-0 w-9 h-9 rounded-full flex items-center justify-center pressable">
|
||||
{paused ? <IPlayF size={18} /> : <IPauseF size={17} />}
|
||||
</button>
|
||||
<span className="shrink-0 text-[11.5px] font-semibold hg-ink-2 tabular-nums">{fmtTime(time)}</span>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (speedLock) { setSpeedLock(false); return; }
|
||||
const seq = [1, 1.25, 1.5, 2];
|
||||
const i = seq.indexOf(rate);
|
||||
setRate(seq[(i + 1) % seq.length]);
|
||||
}}
|
||||
className={`ml-auto shrink-0 flex items-center gap-1 px-2.5 h-8 rounded-full text-[12px] font-bold pressable ${effRate !== 1 ? "bg-primary text-on-primary" : "hg-chip hg-ink-2"}`}>
|
||||
<IBoltF size={12} />{effRate}x
|
||||
</button>
|
||||
<span className="shrink-0 text-[11.5px] hg-ink-4 tabular-nums">{fmtTime(duration)}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 选集 / 评论:桌面停靠在右侧(画面让位),移动端底部弹层 */}
|
||||
{isDesktop ? (
|
||||
<div className={`desktop-dock-panel ${panel ? "is-open" : ""}`}>
|
||||
@@ -945,16 +1295,16 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{!isDesktop && !controlsLocked && active && (
|
||||
<div className={`absolute z-40 flex items-center gap-2 ${fs ? "right-14" : "right-3"}`} style={{ top: "calc(var(--sat, 0px) + 6px)" }}>
|
||||
{!fs && <button onClick={() => setMuted(m => !m)} aria-label={muted ? "取消静音" : "静音"}
|
||||
{!isDesktop && !fs && !clean && !controlsLocked && active && (
|
||||
<div className="absolute right-3 z-40 flex items-center gap-2" style={{ top: "calc(var(--sat, 0px) + 6px)" }}>
|
||||
<button onClick={() => setMuted(m => !m)} aria-label={muted ? "取消静音" : "静音"}
|
||||
className="hg-chip w-9 h-9 rounded-full flex items-center justify-center pressable elev-1">
|
||||
{muted ? <IVolMute size={17} /> : <IVol size={17} />}
|
||||
</button>}
|
||||
</button>
|
||||
<button onClick={lockControls} aria-label="锁定播放控制" title="锁定播放控制" aria-pressed={false}
|
||||
className="hg-chip w-9 h-9 rounded-full flex items-center justify-center pressable elev-1"><ILockF size={17} /></button>
|
||||
{!fs && <button onClick={() => store.setTab("search")} aria-label="搜索"
|
||||
className="hg-chip w-9 h-9 rounded-full flex items-center justify-center pressable elev-1"><ISearch size={18} /></button>}
|
||||
<button onClick={() => store.setTab("search")} aria-label="搜索"
|
||||
className="hg-chip w-9 h-9 rounded-full flex items-center justify-center pressable elev-1"><ISearch size={18} /></button>
|
||||
</div>
|
||||
)}
|
||||
{controlsLocked && <PlaybackLock active={active} onUnlock={() => { setControlsLocked(false); wake(); }} />}
|
||||
|
||||
+21
-4
@@ -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;
|
||||
@@ -152,7 +153,7 @@ html.theme-light .elev-3 { box-shadow: 0 10px 30px rgba(0,0,0,.1); }
|
||||
.a-panel-out { animation: kf-panel-out .2s ease-in both; }
|
||||
@keyframes kf-scale-in { from{opacity:0;transform:scale(.92)} to{opacity:1;transform:scale(1)} }
|
||||
.a-scale-in { animation: kf-scale-in .22s cubic-bezier(.2,0,0,1) both; }
|
||||
@keyframes kf-page-in { from{transform:translateX(100%)} to{transform:translateX(0)} }
|
||||
@keyframes kf-page-in { from{transform:translateX(100%)} to{transform:none} }
|
||||
.a-page-in { animation: kf-page-in .3s cubic-bezier(.2,0,0,1) both; }
|
||||
@keyframes kf-page-out { from{transform:translateX(0)} to{transform:translateX(100%)} }
|
||||
.a-page-out { animation: kf-page-out .22s cubic-bezier(.3,0,.8,.15) both; }
|
||||
@@ -250,7 +251,8 @@ input[type="range"].hg-range::-webkit-slider-thumb { -webkit-appearance: none; w
|
||||
原生全屏时红绿灯被系统隐藏(is-native-fs),让位收回,避免留一条空白。 */
|
||||
.plat-macos .win-titlebar { padding-left: 84px; }
|
||||
.plat-macos .win-titlebar.is-native-fs { padding-left: 14px; }
|
||||
.plat-android .win-main { background: var(--p-bg); overflow: hidden; }
|
||||
.plat-android .win-main,
|
||||
.plat-ios .win-main { background: var(--p-bg); overflow: hidden; }
|
||||
.win-page-in { animation: kf-page-in .26s cubic-bezier(.2,0,0,1) both; }
|
||||
.win-page-out { animation: kf-page-out .2s ease-in both; }
|
||||
|
||||
@@ -483,13 +485,28 @@ input[type="range"].hg-range::-webkit-slider-thumb { -webkit-appearance: none; w
|
||||
.player-surface .player-root,
|
||||
.player-root { background: #15181d; }
|
||||
|
||||
/* —— 安卓沉浸全屏:横屏视频把舞台旋转 90°(不依赖系统旋转) —— */
|
||||
/* —— 移动端沉浸全屏:固定铺满全屏视口,脱离外层滚动容器 scrollTop 影响 —— */
|
||||
.fs-immersive {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
width: 100vw; height: 100vh;
|
||||
width: 100dvw; height: 100dvh;
|
||||
z-index: 45;
|
||||
background: #000;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* —— 移动端沉浸全屏(系统仍处于竖屏时的 CSS 90° 旋转兜底) —— */
|
||||
.fs-landscape {
|
||||
position: absolute;
|
||||
position: fixed;
|
||||
top: 50%; left: 50%; right: auto; bottom: auto;
|
||||
width: 100vh; height: 100vw;
|
||||
width: 100dvh; height: 100dvw;
|
||||
transform: translate(-50%, -50%) rotate(90deg);
|
||||
transform-origin: center center;
|
||||
z-index: 45;
|
||||
background: #000;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.desktop-dock-panel {
|
||||
|
||||
+25
-5
@@ -1,4 +1,5 @@
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { api, platform as envPlatform } from "./api";
|
||||
import { isStrictSecurity, setStrictSecurity as setHtmlStrictSecurity } from "./html";
|
||||
import type { User } from "./types";
|
||||
@@ -120,6 +121,8 @@ type Store = {
|
||||
toggleFollowLocal: (uid: number) => boolean;
|
||||
theater: boolean; setTheater: (v: boolean | ((p: boolean) => boolean)) => void;
|
||||
fs: boolean; setFs: (v: boolean | ((p: boolean) => boolean)) => void;
|
||||
/** 清屏模式(单击屏幕消除所有控件,只保留纯视频内容) */
|
||||
clean: boolean; setClean: (v: boolean | ((p: boolean) => boolean)) => void;
|
||||
muted: boolean; setMuted: (v: boolean | ((p: boolean) => boolean)) => void;
|
||||
muteOnStartup: boolean; setMuteOnStartup: (on: boolean) => void;
|
||||
volume: number; setVolume: (v: number) => void;
|
||||
@@ -142,6 +145,7 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
const [toasts, setToasts] = useState<Toast[]>([]);
|
||||
const [theater, setTheaterState] = useState(false);
|
||||
const [fs, setFsState] = useState(false);
|
||||
const [clean, setCleanState] = useState(false);
|
||||
const [strictSecurity, setStrictSecurityState] = useState<boolean>(isStrictSecurity);
|
||||
const [cliRelaxed, setCliRelaxed] = useState(false);
|
||||
const [strictSecurityReady, setStrictSecurityReady] = useState(false);
|
||||
@@ -189,11 +193,15 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
window.setTimeout(() => setToasts((t) => t.filter((x) => x.id !== id)), 2200);
|
||||
}, []);
|
||||
|
||||
const setTab = useCallback((t: Tab) => { setTabRaw(t); setStack([]); }, []);
|
||||
const setTab = useCallback((t: Tab) => { setTabRaw(t); setStack([]); setCleanState(false); }, []);
|
||||
const push = useCallback((pg: PageInput) => {
|
||||
setCleanState(false);
|
||||
setStack((s) => [...s, { ...pg, key: `p${++seq}` } as Page]);
|
||||
}, []);
|
||||
const pop = useCallback(() => setStack((s) => s.slice(0, -1)), []);
|
||||
const pop = useCallback(() => {
|
||||
setCleanState(false);
|
||||
setStack((s) => s.slice(0, -1));
|
||||
}, []);
|
||||
|
||||
const toggleLikeLocal = useCallback((id: number) => {
|
||||
let on = false;
|
||||
@@ -253,7 +261,18 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
}, []);
|
||||
|
||||
const setFs = useCallback((v: boolean | ((prev: boolean) => boolean)) => {
|
||||
setFsState((prev) => (typeof v === "function" ? (v as (p: boolean) => boolean)(prev) : v));
|
||||
setFsState((prev) => {
|
||||
const next = typeof v === "function" ? (v as (p: boolean) => boolean)(prev) : v;
|
||||
if (!next) {
|
||||
invoke("set_orientation", { landscape: false }).catch(() => {});
|
||||
try { screen.orientation?.unlock?.(); } catch { /* ignore */ }
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const setClean = useCallback((v: boolean | ((prev: boolean) => boolean)) => {
|
||||
setCleanState((prev) => (typeof v === "function" ? (v as (p: boolean) => boolean)(prev) : v));
|
||||
}, []);
|
||||
|
||||
const setMuted = useCallback((v: boolean | ((prev: boolean) => boolean)) => {
|
||||
@@ -276,7 +295,8 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
isLiked: (id) => p.likes.includes(id),
|
||||
isFav: (id) => p.favs.includes(id),
|
||||
toggleLikeLocal, toggleFavLocal, toggleFollowLocal, addHistory, clearHistory,
|
||||
muted: p.muted, setMuted, volume: p.volume, setVolume, theater, setTheater, fs, setFs,
|
||||
muted: p.muted, setMuted, volume: p.volume, setVolume,
|
||||
theater, setTheater, fs, setFs, clean, setClean,
|
||||
muteOnStartup: p.muteOnStartup, setMuteOnStartup,
|
||||
searchHist: p.searchHist, addSearch, clearSearchHist,
|
||||
strictSecurity, strictSecurityReady, securityPending, cliRelaxed, setStrictSecurity,
|
||||
@@ -284,7 +304,7 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
}), [theme, tab, setTab, stack, push, pop, user, loginOpen, logout,
|
||||
p, toggleLikeLocal, toggleFavLocal, toggleFollowLocal, addHistory, clearHistory,
|
||||
setMuted, setMuteOnStartup, setVolume, addSearch, clearSearchHist, strictSecurity, strictSecurityReady, securityPending, cliRelaxed, setStrictSecurity,
|
||||
toasts, toast, theater, setTheater, fs, setFs]);
|
||||
toasts, toast, theater, setTheater, fs, setFs, clean, setClean]);
|
||||
|
||||
return <Ctx.Provider value={value}>{children}</Ctx.Provider>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user