v-fixed43: 恢复右上角开源地址/TVBOX按钮断点(开源地址lg→md);新增chunk按内容改名防陈旧缓存;apply.sh补全4a/4g步骤
This commit is contained in:
1 parent
4f71088fe0
commit
aa7652118c
3 files changed
+62
-2
No files matched your search
@@ -25,6 +25,10 @@ echo "[4/5] 语法校验 ..."
|
||||
docker exec "$C" node --check /app/.next/server/app/api/tvbox/route.js
|
||||
docker exec "$C" node --check /app/.next/server/app/api/filter/route.js
|
||||
|
||||
echo "[4a/5] 授权系统补丁(角标/铃铛/TVBOX按钮/IPv6探针)..."
|
||||
docker cp "$DIR/patch_license.js" "$C:/tmp/patch_license.js"
|
||||
docker exec "$C" node /tmp/patch_license.js || true
|
||||
|
||||
echo "[4b/5] 应用公告补丁(免责声明→CardAuth公告)..."
|
||||
docker cp "$DIR/patch-announcement.js" "$C:/tmp/patch-announcement.js"
|
||||
docker exec "$C" node /tmp/patch-announcement.js || true
|
||||
@@ -49,6 +53,10 @@ 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)"
|
||||
|
||||
echo "[4g/5] 前端资源防陈旧缓存(chunk按内容改名)..."
|
||||
docker cp "$DIR/patch_cachebust.js" "$C:/tmp/patch_cachebust.js"
|
||||
docker exec "$C" node /tmp/patch_cachebust.js || true
|
||||
|
||||
echo "[5/5] 重启 ..."
|
||||
docker restart "$C" >/dev/null
|
||||
sleep 5
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// 前端资源防陈旧缓存:chunk 内容变化 → 文件名跟着变(内容 hash 前 8 位),
|
||||
// 浏览器按文件名缓存 immutable 一年,改名后会当新文件拉取。
|
||||
// 幂等:内容未变则文件名已匹配,直接跳过。
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const crypto = require("crypto");
|
||||
|
||||
const CHUNK_DIR = "/app/.next/static/chunks";
|
||||
const NEXT_DIR = "/app/.next";
|
||||
|
||||
function findChunk() {
|
||||
const files = fs.readdirSync(CHUNK_DIR).filter(f => /^402-.*\.js$/.test(f));
|
||||
if (files.length !== 1) { console.log("cachebust: expected 1 402 chunk, found", files); return null; }
|
||||
return path.join(CHUNK_DIR, files[0]);
|
||||
}
|
||||
|
||||
const oldPath = findChunk();
|
||||
if (!oldPath) process.exit(0);
|
||||
|
||||
const content = fs.readFileSync(oldPath, "utf8");
|
||||
const hash = crypto.createHash("md5").update(content).digest("hex").slice(0, 8);
|
||||
const oldName = path.basename(oldPath);
|
||||
const newName = "402-" + hash + ".js";
|
||||
|
||||
// 已按内容 hash 命名 → 无需处理
|
||||
if (oldName === newName) { console.log("cachebust: up-to-date", newName); process.exit(0); }
|
||||
|
||||
const newPath = path.join(CHUNK_DIR, newName);
|
||||
fs.writeFileSync(newPath, content);
|
||||
console.log("cachebust: wrote", newName);
|
||||
|
||||
// 替换所有引用
|
||||
let refs = 0, files = 0;
|
||||
function walk(dir) {
|
||||
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const p = path.join(dir, e.name);
|
||||
if (e.isDirectory()) { walk(p); continue; }
|
||||
if (!/\.(js|json)$/.test(e.name)) continue;
|
||||
if (p === newPath) continue;
|
||||
let s;
|
||||
try { s = fs.readFileSync(p, "utf8"); } catch (err) { continue; }
|
||||
if (!s.includes(oldName)) continue;
|
||||
fs.writeFileSync(p, s.split(oldName).join(newName));
|
||||
refs++; files++;
|
||||
}
|
||||
}
|
||||
walk(NEXT_DIR);
|
||||
console.log("cachebust: replaced refs in", files, "file(s)");
|
||||
|
||||
// 删旧文件(放在最后,避免中途失败导致引用悬空)
|
||||
fs.unlinkSync(oldPath);
|
||||
console.log("cachebust: removed", oldName, "->", newName);
|
||||
@@ -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 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:"⭐ 开源地址"})]}),';;
|
||||
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 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 lg: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 md: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);
|
||||
|
||||
Reference in new issue
Block a user