Skip to content

new clone#394

Open
guizhouwudao wants to merge 40 commits into
mtvpls:mainfrom
guizhouwudao:main
Open

new clone#394
guizhouwudao wants to merge 40 commits into
mtvpls:mainfrom
guizhouwudao:main

Conversation

@guizhouwudao

Copy link
Copy Markdown

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces video aspect ratio controls to the play page, allowing users to change and persist their preferred aspect ratio in localStorage. It also updates module resolution for edge-tts-universal and adds a teamId to vercel.json. The review feedback highlights three key issues: first, marking edge-tts-universal as external unconditionally in next.config.js will cause Cloudflare Workers to crash; second, hardcoding teamId in vercel.json leaks internal IDs and reduces configuration reusability; and third, the aspect ratio selector UI does not dynamically reflect the restored value from localStorage due to a hardcoded default.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread next.config.js Outdated
Comment on lines +153 to +156
if (isServer) {
config.externals = config.externals || [];
config.externals.push('edge-tts-universal');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

在 Cloudflare Pages/Workers 环境中,运行时不支持外部 CommonJS 模块的 require 调用。如果将 edge-tts-universal 设为 external,Webpack 会在打包产物中保留 require('edge-tts-universal'),这会导致 Cloudflare Worker 在启动时直接崩溃。

另外,如果不在 Cloudflare 环境下将其设为 external,由于 edge-tts-universal 是一个可选依赖(可能未安装),Webpack 在编译时会因为找不到该模块而报错导致构建失败。

推荐的完整解决方案:

  1. 在非 Cloudflare 环境下设为 external(以便 Vercel NFT 追踪)。
  2. 在 Cloudflare 环境下将其重定向(Alias)到 unsupported shim(避免 Webpack 编译失败和运行时崩溃):在 next.config.jsisCloudflare 别名配置数组中(约第 98-106 行),将 'edge-tts-universal' 加入到重定向列表中。
Suggested change
if (isServer) {
config.externals = config.externals || [];
config.externals.push('edge-tts-universal');
}
if (isServer && !isCloudflare) {
config.externals = config.externals || [];
config.externals.push('edge-tts-universal');
}

Comment thread vercel.json
@@ -1,4 +1,5 @@
{
"teamId": "team_aaUXT1bIwepAFjlRBCUaOCH9",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

vercel.json 中硬编码特定的 teamId 会导致该配置文件无法在其他团队或个人账号下复用,同时也泄露了团队的内部 ID。建议移除此配置,改用 Vercel CLI 或环境变量来指定部署团队。

Comment thread src/app/play/page.tsx
Comment on lines +7369 to +7377
selector: [
{ html: '原始', value: 'original', default: true },
{ html: '填充', value: 'contain' },
{ html: '拉伸', value: 'fill' },
{ html: '裁剪', value: 'cover' },
{ html: '16:10', value: '16/10' },
{ html: '16:9', value: '16/9' },
{ html: '4:3', value: '4/3' },
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

当前画面比例的选择器硬编码了 default: trueoriginal 上。这会导致即使从 localStorage 中成功恢复了用户之前保存的画面比例(例如 16:9),播放器的设置菜单中依然会显示当前选择为 原始,造成 UI 状态与实际视频画面比例不一致。建议根据 localStorage 中保存的值动态设置 default 属性。

                selector: (() => {
                    let savedAr = 'original';
                    try { savedAr = localStorage.getItem('aspectRatio') || 'original'; } catch (_) {}
                    return [
                        { html: '原始', value: 'original' },
                        { html: '填充', value: 'contain' },
                        { html: '拉伸', value: 'fill' },
                        { html: '裁剪', value: 'cover' },
                        { html: '16:10', value: '16/10' },
                        { html: '16:9', value: '16/9' },
                        { html: '4:3', value: '4/3' },
                    ].map(opt => ({ ...opt, default: opt.value === savedAr }));
                })(),

- Rebased on upstream v223.2 (528ded1)
- Preserved: aspect ratio selector (填充/拉伸/裁剪/16:10/16:9/4:3/原始)
- Preserved: vercel.json teamId config
- edge-tts-universal: already included in upstream (src/lib/book-tts.ts)
guizhouwudao and others added 27 commits June 26, 2026 11:17
1. 直播播放页面设置面板新增画面比例选项(原始/填充/拉伸/裁剪/16:10/16:9/4:3)
   - 在画面翻转后面显示
   - 设置持久化到 localStorage
   - 播放器就绪后自动恢复

2. 修复 edge-tts-universal 在 EdgeOne Pages 边缘运行时报错
   - resolveEdgeTtsModule() 改为返回 null 而非抛异常
   - 调用方检查 null 后给出清晰错误提示
   - 避免整个 API route crash
- next.config.js: 添加 serverExternalPackages 声明 edge-tts-universal 为外部依赖
- book-tts.ts: eval('require') → 普通 require(),让 webpack 正确追踪模块

eval('require') 绕过了 webpack 的静态分析,导致模块未被包含在 EdgeOne 部署产物中。
配合 serverExternalPackages,webpack 不会尝试打包该模块,但会确保它在运行时可用。
上一次 require('edge-tts-universal') + serverExternalPackages 在 EdgeOne Cloud Function
中导致 503 崩溃。恢复原来的 eval('require') 方式,它能优雅处理模块不存在的情况。
- 新增 edge-tts-inline.ts:使用 Node.js 22+ 内置 WebSocket API 实现 Edge TTS 协议
- 修改 resolveEdgeTtsModule():优先用 edge-tts-universal,不可用时 fallback 到内联实现
- 兼容 Docker / Vercel / EdgeOne Cloud Function 等所有 Node.js 运行时
- 无需 serverExternalPackages 或 eval('require') hack
- EdgeOne Cloud Function 不支持出站 WebSocket,改用 HTTP 方案
- Google Translate TTS 作为 fallback(每段 200 字,自动分段拼接)
- WebSocket 优先(Docker 环境),HTTP 兜底(EdgeOne 等 serverless)
- 音质略低于 Edge TTS,但保证可用性
- maxCharsPerChunk: 1200 -> 300
- maxTextLengthPerRequest: 2000 -> 500
Proxy: hc.wwszxc.tax:20543
Configurable via TTS_HTTP_PROXY env var
Try proxy first, fall back to direct if proxy fails.
- 移除非文本内容的 directplay-only 限制,所有源的 MP4/直链走二进制透传
- 新增 isDirectPlayLikeSource() 将 netdisk-baidu 等网盘类源纳入直链代理
- 网盘源的分片 URL 通过 /api/proxy/vod/segment 代理避免 CORS 问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant