v-fixed16:修复 /live 显示 JSON(rewrite 丢 query 改按 pathname 识别);布局改为左侧选台右侧播放;修播放中加载遮罩误显示

This commit is contained in:
jinghui committed 2026-10-26 10:31:08 +08:00
1 parent a9fc000f70
commit d885670cfe
4 files changed
+22 -8

No files matched your search

+7
View File
@@ -2,6 +2,13 @@
格式参考本机发版惯例:按日期分条,`🐛修复` / `✨新功能`。
## 2026-10-26 → v-fixed16
- 🐛 **修复 `/live` 打开是代码(JSON)**:Next 的 rewrite 到 API 路由时保留原 URL `/live`、静态 query 全丢,导致直播钩子不触发而返回 TVBOX config JSON;改为按 `pathname === "/live"` 识别(实测登录态返回 `text/html`)
- ✨ **布局改为左台右播**:频道列表固定左侧(320px、可滚动、51 频道),播放器右侧 16:9;手机端频道列表限高 36vh 在上、点选后自动平滑滚动到播放器
- 🐛 修复播放中仍盖"加载中"遮罩的问题(缓冲波动时误显示;现在仅在真正暂停时显示)
- 🔧 频道列表标题加「点击切换」提示
## 2026-10-26 → v-fixed15
- ✨ **直播接入 TVBOX/影视仓**:配置接口 `/api/tvbox` 的 `lives` 字段(原指向不存在的死链)改指频道文本源 `?live=txt` —— 影视仓里现有配置地址不用改,重新加载即自动多出「电视直播」直播栏
+1 -1
View File
@@ -3,7 +3,7 @@ version: '3.8'
services:
# KatelyaTV 应用服务
katelyatv:
image: katelyatv:fixed15
image: katelyatv:fixed16
container_name: katelyatv
ports:
- "3030:3000"
+8 -3
View File
@@ -7,7 +7,8 @@ RM = "/app/.next/routes-manifest.json"
MC = "/app/.next/static/chunks/402-42ae253cc67eee98.js"
BASE = os.path.dirname(os.path.abspath(__file__))
MARK_S, MARK_E = "/* ==== LIVE:", "/* ==== LIVE END ==== */"
HOOK = 'try{let _lv=new URL(e.url).searchParams.get("live");if(_lv)return await LIVE(_lv,e)}catch(_le){console.log("[LIVE-HOOK]",_le&&_le.message)}'
HOOK_OLD = 'try{let _lv=new URL(e.url).searchParams.get("live");if(_lv)return await LIVE(_lv,e)}catch(_le){console.log("[LIVE-HOOK]",_le&&_le.message)}'
HOOK = 'try{let _lurl=new URL(e.url),_lv=_lurl.searchParams.get("live");if(!_lv&&_lurl.pathname==="/live")_lv="page";if(_lv)return await LIVE(_lv,e)}catch(_le){console.log("[LIVE-HOOK]",_le&&_le.message)}'
def read(p):
return subprocess.run(["docker","exec","katelyatv","cat",p],capture_output=True,check=True).stdout.decode()
@@ -31,8 +32,12 @@ if MARK_S not in src:
a = 'async function u(e){console.log("[TVBOX-REQ]",e.method,e.url);'
assert src.count(a) == 1, "anchor B"
if HOOK not in src:
src = src.replace(a, a + HOOK, 1)
print("entry hook injected")
if HOOK_OLD in src:
src = src.replace(HOOK_OLD, HOOK, 1)
print("entry hook upgraded (pathname /live)")
else:
src = src.replace(a, a + HOOK, 1)
print("entry hook injected")
with tempfile.NamedTemporaryFile('w', suffix='.js', delete=False) as f:
f.write(src); tmp = f.name
r = subprocess.run(['node', '--check', tmp], capture_output=True, text=True)
+6 -4
View File
@@ -63,8 +63,9 @@ body{background:#0f1115;color:#e5e7eb;font-family:-apple-system,BlinkMacSystemFo
.hd{position:sticky;top:0;z-index:9;background:rgba(15,17,21,.92);backdrop-filter:blur(8px);padding:10px 14px;display:flex;align-items:center;gap:10px;border-bottom:1px solid #1f2430}
.hd a{color:#9ca3af;text-decoration:none;font-size:24px;line-height:1}
.hd h1{font-size:17px;font-weight:600}
.wrap{max-width:1100px;margin:0 auto;padding:14px;display:flex;flex-direction:column;gap:14px}
@media(min-width:820px){.wrap{flex-direction:row}.side{width:300px;flex:none;max-height:78vh;overflow:auto}.main{flex:1}}
.wrap{max-width:1180px;margin:0 auto;padding:14px;display:flex;flex-direction:column;gap:14px}
.side{max-height:36vh;overflow:auto;padding-right:2px}
@media(min-width:820px){.wrap{flex-direction:row;align-items:flex-start}.side{width:320px;flex:none;max-height:78vh}.main{flex:1;min-width:0}}
.player-box{background:#000;border-radius:10px;overflow:hidden;aspect-ratio:16/9;position:relative}
video{width:100%;height:100%;display:block;background:#000}
.tip{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#6b7280;font-size:14px;pointer-events:none;background:rgba(0,0,0,.35)}
@@ -80,12 +81,12 @@ select{background:#171b24;color:#e5e7eb;border:1px solid #2a3140;border-radius:6
</style></head><body>
<div class="hd"><a href="/" >‹</a><h1>电视直播 · 港澳台</h1></div>
<div class="wrap">
<div class="side"><div class="sec">频道列表 <span style="color:#4b5563">点击切换</span></div><div class="grid" id="grid"><div class="empty">加载中…</div></div></div>
<div class="main">
<div class="player-box"><video id="v" playsinline></video><div class="tip" id="tip">选择频道开始观看</div></div>
<div class="bar" style="margin-top:10px"><span class="cur" id="cur">未选择</span><span style="flex:1"></span>
<label>线路 <select id="lineSel" onchange="playLine(this.value)"></select></label></div>
</div>
<div class="side"><div class="sec">频道列表</div><div class="grid" id="grid"><div class="empty">加载中…</div></div></div>
</div>
<script src="/hls.min.js"></script><script src="/mpegts.min.js"></script><script>
var hls=null,mp=null,chs=[],curId=null;
@@ -104,7 +105,7 @@ function playSrc(u,flv){
hls.on(Hls.Events.ERROR,function(e,d){if(d.fatal){if(d.type===Hls.ErrorTypes.NETWORK_ERROR){hls.startLoad()}else if(d.type===Hls.ErrorTypes.MEDIA_ERROR){hls.recoverMediaError()}else{nextLine()}}})}
}else if(/\\.flv/.test(u)&&window.mpegts){try{mp=mpegts.createPlayer({type:'flv',isLive:true,url:u});mp.attachMediaElement(v);mp.load()}catch(e){}}
v.play().catch(function(){});
setTimeout(function(){if(v.readyState<2)tip.style.display='flex'},2500);
setTimeout(function(){if(v.readyState<2&&v.paused)tip.style.display='flex'},2500);
v.onplaying=function(){tip.style.display='none'};
}
function nextLine(){if(sel.options.length&&+sel.value<sel.options.length-1){sel.value=+sel.value+1;playLine(sel.value)}else{tip.textContent='所有线路暂不可用';tip.style.display='flex'}}
@@ -123,6 +124,7 @@ function pick(id){
document.querySelectorAll('.ch.on').forEach(function(e){e.classList.remove('on')});
var el=document.querySelector('.ch[data-id="'+id+'"]');if(el)el.classList.add('on');
sel.innerHTML='';tip.textContent='加载线路…';tip.style.display='flex';
if(window.innerWidth<820){var pb=document.querySelector('.player-box');if(pb)pb.scrollIntoView({behavior:'smooth',block:'center'})}
fetch(API+'lines&id='+id).then(function(r){return r.json()}).then(function(j){
(j.lines||[]).forEach(function(l,i){var o=document.createElement('option');o.value=i;o.textContent=l.name;sel.appendChild(o)});
if((j.lines||[]).length){sel.value=0;playLine(0)}else{tip.textContent='暂无可用线路'}