8 changed files with 59 additions and 361 deletions
-189
View File
@@ -1,189 +0,0 @@
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
-147
View File
@@ -1,147 +0,0 @@
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
View File
@@ -3,8 +3,6 @@
<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>
-4
View File
@@ -11,10 +11,6 @@ rust-version = "1.90"
name = "huangguo_client_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[features]
default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
+6 -1
View File
@@ -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);
});
+53 -12
View File
@@ -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"),
-3
View File
@@ -43,9 +43,6 @@
],
"android": {
"minSdkVersion": 24
},
"iOS": {
"developmentTeam": "ABCDE12345"
}
}
}
-3
View File
@@ -1,8 +1,5 @@
{
"$schema": "https://schema.tauri.app/config/2",
"build": {
"devUrl": null
},
"bundle": {
"iOS": {
"minimumSystemVersion": "15.0"