v-fixed43: 修复窄屏右上角IPV4/IPV6按钮被挤出视口(菜单可收缩+按钮组shrink-0+TVBOX/开源地址延后显示)
This commit is contained in:
1 parent
abd546b960
commit
a47487293f
4 files changed
+50
-4
No files matched your search
@@ -41,6 +41,10 @@ echo "[4e/5] 顶部/底部菜单加入 AI短剧 入口..."
|
||||
docker cp "$DIR/patch-aidrama-menu.js" "$C:/tmp/patch-aidrama-menu.js"
|
||||
docker exec "$C" node /tmp/patch-aidrama-menu.js || true
|
||||
|
||||
echo "[4e2/5] 导航菜单可收缩(避免把右侧按钮挤出视口)..."
|
||||
docker cp "$DIR/patch_nav_shrink.js" "$C:/tmp/patch_nav_shrink.js"
|
||||
docker exec "$C" node /tmp/patch_nav_shrink.js || true
|
||||
|
||||
echo "[4f/5] 注入 /ipv6 线路选择页 + 首页 IPV4/IPV6 切换按钮..."
|
||||
python3 "$DIR/inject_ipv6.py" || echo "ipv6 inject failed (non-fatal)"
|
||||
python3 "$DIR/patch_middleware_whitelist.py" || echo "middleware whitelist failed (non-fatal)"
|
||||
|
||||
@@ -60,8 +60,15 @@ if not target:
|
||||
print("WARN: header chunk not found, skip toggle button")
|
||||
else:
|
||||
c = read(target)
|
||||
BTN = '(0,a.jsx)("button",{onClick:()=>{location.href="/ipv6"},title:"切换 IPv4 / IPv6 线路",className:"hidden md:flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium text-gray-700 hover:bg-purple-100/30 hover:text-purple-600 dark:text-gray-300 dark:hover:bg-purple-500/10 transition-colors duration-200",children:"🌐 IPV4/IPV6"}),'
|
||||
if 'IPV4/IPV6' in c and 'location.href="/ipv6"' in c:
|
||||
BTN = '(0,a.jsx)("button",{onClick:()=>{location.href="/ipv6"},title:"切换 IPv4 / IPv6 线路",className:"hidden md:flex shrink-0 items-center gap-1.5 rounded-lg px-2.5 py-2 text-sm font-medium text-gray-700 hover:bg-purple-100/30 hover:text-purple-600 dark:text-gray-300 dark:hover:bg-purple-500/10 transition-colors duration-200",children:"🌐 IPV4/IPV6"}),'
|
||||
# 幂等:先移除旧按钮(含旧样式),再重新注入
|
||||
import re as _re
|
||||
_old = _re.compile(r'\(0,a\.jsx\)\("button",\{onClick:\(\)=>\{location\.href="/ipv6"\}[^)]*children:"🌐 IPV4/IPV6"\}\),')
|
||||
c2, _n = _old.subn('', c)
|
||||
if _n:
|
||||
c = c2
|
||||
print(f"removed {_n} stale toggle button(s)")
|
||||
if 'IPV4/IPV6' in c:
|
||||
print("toggle button already present")
|
||||
else:
|
||||
# 注入到开源地址按钮(gitea)之前
|
||||
|
||||
@@ -175,8 +175,8 @@ function writeChecked(p, s) {
|
||||
const oi = s.indexOf("var _=");
|
||||
const ci = oi >= 0 ? s.lastIndexOf(combo, oi) : -1;
|
||||
if (ci < 0) { failures.push("nav combo anchor missing"); return; }
|
||||
const tvboxBtn = '(0,a.jsx)("button",{onClick:(ev)=>{const u=location.origin+"/api/tvbox";const bt=ev.currentTarget;const t0=bt.textContent;const ok=()=>{bt.textContent="✓ 已复制";setTimeout(()=>{bt.textContent=t0},1600)};const tip="影视仓/TVBox「设置 → 配置地址」粘贴保存即可";try{if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(u).then(ok).catch(()=>mvModal("📺 TVBOX 接入","配置地址: "+u+" —— "+tip,u));return}}catch(x){}mvModal("📺 TVBOX 接入","配置地址: "+u+" —— "+tip,u)},title:"TVBOX接口 · 点击复制配置地址",className:"hidden md:flex items-center rounded-lg px-3 py-2 text-sm font-medium text-gray-700 hover:bg-purple-100/30 hover:text-purple-600 dark:text-gray-300 dark:hover:bg-purple-500/10 transition-colors duration-200",children:"📺 TVBOX接口"}),';
|
||||
const gated = '"/"===(e.activePath||"/")&&(0,a.jsxs)("span",{className:"hidden md:flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"hidden lg:inline-flex items-center select-none rounded-lg px-2 py-1.5 text-xs font-bold tracking-wide text-purple-600 dark:text-purple-400 bg-purple-500/10 border border-purple-500/20",title:"米视TV 当前版本",children:"v' + VERSION + '"}),(0,a.jsx)(HubBell,{}),' + tvboxBtn + '(0,a.jsx)("a",{href:"https://gitea.88531.cn/jinghui/katelyatv",target:"_blank",rel:"noopener",className:"hidden lg:flex items-center rounded-lg px-3 py-2 text-sm font-medium text-gray-700 hover:bg-purple-100/30 hover:text-purple-600 dark:text-gray-300 dark:hover:bg-purple-500/10 transition-colors duration-200",children:"⭐ 开源地址"})]}),';;
|
||||
const tvboxBtn = '(0,a.jsx)("button",{onClick:(ev)=>{const u=location.origin+"/api/tvbox";const bt=ev.currentTarget;const t0=bt.textContent;const ok=()=>{bt.textContent="✓ 已复制";setTimeout(()=>{bt.textContent=t0},1600)};const tip="影视仓/TVBox「设置 → 配置地址」粘贴保存即可";try{if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(u).then(ok).catch(()=>mvModal("📺 TVBOX 接入","配置地址: "+u+" —— "+tip,u));return}}catch(x){}mvModal("📺 TVBOX 接入","配置地址: "+u+" —— "+tip,u)},title:"TVBOX接口 · 点击复制配置地址",className:"hidden xl:flex shrink-0 items-center rounded-lg px-3 py-2 text-sm font-medium text-gray-700 hover:bg-purple-100/30 hover:text-purple-600 dark:text-gray-300 dark:hover:bg-purple-500/10 transition-colors duration-200",children:"📺 TVBOX接口"}),';
|
||||
const gated = '"/"===(e.activePath||"/")&&(0,a.jsxs)("span",{className:"hidden md:flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"hidden 2xl:inline-flex shrink-0 items-center select-none rounded-lg px-2 py-1.5 text-xs font-bold tracking-wide text-purple-600 dark:text-purple-400 bg-purple-500/10 border border-purple-500/20",title:"米视TV 当前版本",children:"v' + VERSION + '"}),(0,a.jsx)(HubBell,{}),' + tvboxBtn + '(0,a.jsx)("a",{href:"https://gitea.88531.cn/jinghui/katelyatv",target:"_blank",rel:"noopener",className:"hidden xl:flex shrink-0 items-center rounded-lg px-3 py-2 text-sm font-medium text-gray-700 hover:bg-purple-100/30 hover:text-purple-600 dark:text-gray-300 dark:hover:bg-purple-500/10 transition-colors duration-200",children:"⭐ 开源地址"})]}),';;
|
||||
s = s.slice(0, ci) + gated + s.slice(ci);
|
||||
log("chunk: injected gated trio (home only)");
|
||||
writeChecked(target, s);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// 导航菜单容器加收缩能力:min-w-0 + 横向滚动,避免把右侧按钮组挤出视口
|
||||
const fs = require("fs");
|
||||
const dir = "/app/.next/static/chunks/";
|
||||
const files = fs.readdirSync(dir).filter(f => /^402-.*\.js$/.test(f));
|
||||
if (files.length !== 1) { console.log("expected 1 402 chunk, found", files); process.exit(0); }
|
||||
const t = dir + files[0];
|
||||
let s = fs.readFileSync(t, "utf8");
|
||||
|
||||
// 1) 菜单容器:可收缩 + 横向滚动
|
||||
const OLD = 'className:"hidden md:block",children:(0,a.jsx)("div",{className:"ml-10 flex items-baseline space-x-4"';
|
||||
const NEW = 'className:"hidden md:block min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:(0,a.jsx)("div",{className:"ml-10 flex items-baseline space-x-4 whitespace-nowrap"';
|
||||
if (s.includes('min-w-0 flex-1 overflow-x-auto')) {
|
||||
console.log("nav-shrink: skip (already)");
|
||||
} else if (!s.includes(OLD)) {
|
||||
console.error("nav-shrink: anchor not found");
|
||||
process.exit(1);
|
||||
} else {
|
||||
s = s.replace(OLD, NEW, 1);
|
||||
console.log("nav-shrink: applied");
|
||||
}
|
||||
|
||||
// 2) 右侧按钮组:shrink-0 防压缩
|
||||
const OLD2 = 'className:"flex items-center gap-3 -mr-2"';
|
||||
const NEW2 = 'className:"flex shrink-0 items-center gap-3 -mr-2"';
|
||||
if (s.includes('flex shrink-0 items-center gap-3')) {
|
||||
console.log("btn-group: skip (already)");
|
||||
} else if (s.includes(OLD2)) {
|
||||
s = s.replace(OLD2, NEW2, 1);
|
||||
console.log("btn-group: shrink-0 applied");
|
||||
} else {
|
||||
console.log("btn-group: anchor not found (non-fatal)");
|
||||
}
|
||||
|
||||
fs.writeFileSync(t, s);
|
||||
console.log("nav-shrink: written", files[0]);
|
||||
Reference in new issue
Block a user