Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41f0b9d4a4 | ||
|
|
f5de70a07e | ||
|
|
e9fc359553 | ||
|
|
bb54de7b11 | ||
|
|
2adea77a44 | ||
|
|
e920e878b3 | ||
|
|
d92b9eb100 | ||
|
|
c1e3e7b667 | ||
|
|
78f302ce55 | ||
|
|
bad253452c | ||
|
|
a8e61ff75e | ||
|
|
b48a526935 | ||
|
|
f9b248fd07 |
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
sha256:dbb7d866a1c1f4cfd4c427cda65634c956cf391fb0144a8e667c08fedc9717dc
|
||||||
@@ -2,6 +2,58 @@
|
|||||||
|
|
||||||
格式参考本机发版惯例:按日期分条,`🐛修复` / `✨新功能`。
|
格式参考本机发版惯例:按日期分条,`🐛修复` / `✨新功能`。
|
||||||
|
|
||||||
|
## v-fixed71 (2026-11-07)
|
||||||
|
|
||||||
|
### 🐛 修复
|
||||||
|
- 🎬 **最新港剧只出香港剧**:此前聚合拿第一个源的分类 ID 查全源,各源分类表 ID 不同导致串进内地剧;现每个源按自己的分类表映射(有香港剧类目直取,无则取电视剧类目+地区过滤),结果再硬过滤地区含香港,实测 51 条全香港,最新的排最前
|
||||||
|
|
||||||
|
## v-fixed70 (2026-11-07)
|
||||||
|
|
||||||
|
### ✨ 新功能
|
||||||
|
- 🎬 **最新港剧 10 个显示**:此前写死 5 个,现取前 10;加载中显示 10 个骨架占位,与热门电影/剧集同时出现,不再后半拍
|
||||||
|
- 🔢 版本号对齐 fixed70
|
||||||
|
|
||||||
|
## v-fixed69 (2026-11-07)
|
||||||
|
|
||||||
|
### ✨ 新功能
|
||||||
|
- 📋 **访问日志源码化**:middleware 内 `[ACCESS]` 日志(IP/方法/路径/UA/Referer,跳过 `_next/static` 与 favicon),替代旧 `patches/patch_access_log.js` 运行时注入 next 内部 start-server.js;上线验证日志行正常输出
|
||||||
|
- 📝 README 更新:版本号对齐 fixed69,「补丁固化」小节改为源码构建流程说明(补丁已全部源码化,apply.sh 无活跃注入)
|
||||||
|
|
||||||
|
## v-fixed68 (2026-11-07)
|
||||||
|
|
||||||
|
### ✨ 新功能
|
||||||
|
- 🧩 **右上角四件套每一页常驻**:新建 `TopRightButtons` 共用组件(版本角标 + 🔔通知铃铛 + 📺TVBOX接口 + 🌍IPV4/IPv6 + ⭐开源地址);PageLayout 去掉首页条件整块换共用组件;`/live` `/ipv6` `/config` `/settings` `/tvbox` 加 float 悬浮条;login/warning 为登录前页跳过;11 页验证全过
|
||||||
|
- 🗑️ `patch_cachebust.js` 过时停用(Next 构建自带 contenthash,容器内无 402 chunk),apply.sh 仅保留注释说明
|
||||||
|
|
||||||
|
### 🐛 修复
|
||||||
|
- 🔢 版本号双点对齐:Dockerfile ENV 与 TopRightButtons fallback 同为 fixed68(此前分别滞后 fixed54/fixed53)
|
||||||
|
|
||||||
|
## v-fixed44-hub-r3 (2026-11-07)
|
||||||
|
|
||||||
|
### ✨ 新功能
|
||||||
|
- 👤 **记录用户最后登录时间**:登录成功即写入 Redis `u:<用户名>:last_login`(毫秒时间戳),管理面板用户列表「最后登录」列直接显示;从未登录过的显示「从未登录」。
|
||||||
|
此前一直不记录——源码 `src/lib/redis.db.ts` 有 `touchLogin()`,但线上 `.next` 是旧编译产物,这段逻辑没被编译进去。
|
||||||
|
实现:`patches/last-login.js`(不依赖 node_modules 的最小 Redis RESP 客户端)+ `patches/inject_last_login.py`,注入 login 路由的**两条**成功分支(环境变量 owner 分支、用户库分支)与 `admin/users` 返回。写入失败静默,绝不影响登录。
|
||||||
|
已并入 `patches/apply.sh`(步骤 4h),`npm run build` 覆盖 `.next` 后重跑即可恢复。
|
||||||
|
|
||||||
|
### 🐛 修复
|
||||||
|
- 🕒 管理面板的时间列对毫秒时间戳会显示成裸数字(`1793985861570`)→ 前端 `toDate/fmtDate/fmtDateTime` 同时兼容毫秒时间戳与 ISO 字符串。
|
||||||
|
- ⚠️ `backfill_user_times.py` 改为**默认演练,不写入**:Redis 重启/RDB 重载后所有键的 IDLETIME 从加载时刻统一起算,用它估算"最后登录"会把全部账号写成同一时间(实测 18 个账号全部 00:24,已清理)。需要实跑加 `--force`。
|
||||||
|
|
||||||
|
## v-fixed44-hub-r2 (2026-11-07)
|
||||||
|
|
||||||
|
### ✨ 新功能
|
||||||
|
- 📢 公告弹窗可按 ID 屏蔽 / 本地覆盖:`public-live/announcement.json`
|
||||||
|
```json
|
||||||
|
{ "block_ids": [13], "override": { "enabled": true, "title": "标题", "content": "正文", "is_popup": 1 } }
|
||||||
|
```
|
||||||
|
`block_ids` 里的公告不再显示;`override` 填了就用它当弹窗内容;文件热改即生效(无需重启容器)。
|
||||||
|
默认写入 `block_ids: [13]`,即下线旧的「所有资源免费观看,请勿信片中的广告!」公告弹窗。
|
||||||
|
|
||||||
|
### 🐛 修复
|
||||||
|
- 🔔 只有 `is_popup=1` 的公告才弹窗;此前会把列表里第一条普通公告也当作弹窗弹出。
|
||||||
|
- 🔁 授权中心返回空公告时正确清空弹窗(不再残留上一次结果)。
|
||||||
|
|
||||||
## v-fixed44 (2026-11-06)
|
## v-fixed44 (2026-11-06)
|
||||||
|
|
||||||
### ✨ 新功能
|
### ✨ 新功能
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ git clone https://gitea.88531.cn/jinghui/katelyatv.git && cd katelyatv
|
|||||||
docker pull gitea.88531.cn/jinghui/katelyatv:latest
|
docker pull gitea.88531.cn/jinghui/katelyatv:latest
|
||||||
# 国内慢可换腾讯云镜像(东京):
|
# 国内慢可换腾讯云镜像(东京):
|
||||||
# docker pull jpccr.ccs.tencentyun.com/jinghui/katelyatv:latest
|
# docker pull jpccr.ccs.tencentyun.com/jinghui/katelyatv:latest
|
||||||
docker tag gitea.88531.cn/jinghui/katelyatv:latest katelyatv:fixed44 # 对齐 compose 的 image 名
|
docker tag gitea.88531.cn/jinghui/katelyatv:latest katelyatv:fixed71 # 对齐 compose 的 image 名
|
||||||
|
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
vi .env # 至少填:PASSWORD(站点密码)、NEXTAUTH_SECRET(随机串)
|
vi .env # 至少填:PASSWORD(站点密码)、NEXTAUTH_SECRET(随机串)
|
||||||
@@ -86,6 +86,10 @@ docker restart katelyatv
|
|||||||
|
|
||||||
## 📝 更新日志(最近)
|
## 📝 更新日志(最近)
|
||||||
|
|
||||||
|
- **2026-11-07 v-fixed71**:最新港剧只出香港剧(聚合接口按每个源各自的分类表映射香港剧/电视剧类目,不再拿第一个源的 ID 查全源;结果硬过滤地区含香港,之前串进内地剧;排序年份+更新时间双降序,最新排最前)
|
||||||
|
- **2026-11-07 v-fixed70**:最新港剧改为 10 个显示(此前写死 5 个);加载中显示 10 个骨架占位,与热门电影/剧集同时出现,不再后半拍跳动
|
||||||
|
- **2026-11-07 v-fixed69**:访问日志源码化(middleware 内 `[ACCESS]` 日志,替代注入 next 内部 start-server);版本号对齐 fixed69;四件套每一页常驻+11 页验证全过保持
|
||||||
|
- **2026-11-07 v-fixed68**:右上角四件套(版本角标 + 🔔通知铃铛 + 📺TVBOX接口 + 🌍IPV4/IPv6 + ⭐开源地址)每一页常驻 —— 新建 `TopRightButtons` 共用组件,11 页验证全过;`patch_cachebust.js` 过时停用(Next 构建自带 contenthash)
|
||||||
- **2026-11-06 v-fixed44**:管理页「用户配置」点击崩溃(React #31)彻底修复 —— 根因是配置模块把用户对象当用户名写进列表,已修编译产物与源码并清理 18 条脏数据;新增**全新「用户管理」面板**(用户列表 / 添加 / 改密 / 设为管理 / 封禁 / 删除)
|
- **2026-11-06 v-fixed44**:管理页「用户配置」点击崩溃(React #31)彻底修复 —— 根因是配置模块把用户对象当用户名写进列表,已修编译产物与源码并清理 18 条脏数据;新增**全新「用户管理」面板**(用户列表 / 添加 / 改密 / 设为管理 / 封禁 / 删除)
|
||||||
- **2026-11-01 v-fixed43**:IPv6 智能跳转恢复(家宽有 IPv6 自动切到 tv6 高速线路);电脑端与移动端新增「AI短剧」入口;`/live` 直播页点击画面可暂停/继续;首页公告改为授权中心动态推送
|
- **2026-11-01 v-fixed43**:IPv6 智能跳转恢复(家宽有 IPv6 自动切到 tv6 高速线路);电脑端与移动端新增「AI短剧」入口;`/live` 直播页点击画面可暂停/继续;首页公告改为授权中心动态推送
|
||||||
- **2026-10-30 v-fixed38**:首页右上角新增「📺 TVBOX接口」一键复制配置地址;⭐ 开源地址与菜单版本按钮改指自建 Gitea(`https://gitea.88531.cn/jinghui/katelyatv`)
|
- **2026-10-30 v-fixed38**:首页右上角新增「📺 TVBOX接口」一键复制配置地址;⭐ 开源地址与菜单版本按钮改指自建 Gitea(`https://gitea.88531.cn/jinghui/katelyatv`)
|
||||||
@@ -135,15 +139,11 @@ docker/katelyatv/
|
|||||||
| `patch_access_log.js` | 访问日志注入([ACCESS] IP/UA/路径,供 `usage-stats.sh` 统计使用人数) |
|
| `patch_access_log.js` | 访问日志注入([ACCESS] IP/UA/路径,供 `usage-stats.sh` 统计使用人数) |
|
||||||
| `patch_license.js` | 授权系统:CardAuth 装机/心跳/公告/版本推送、`/api/license-config` 路由、首页右上角四件套(版本角标+🔔通知铃铛+📺TVBOX接口一键复制配置地址+⭐开源地址指向自建Gitea,仅首页显示;直播页移除开源按钮)、每 IP 限流 429;运行时组件见 `license-hub.js` |
|
| `patch_license.js` | 授权系统:CardAuth 装机/心跳/公告/版本推送、`/api/license-config` 路由、首页右上角四件套(版本角标+🔔通知铃铛+📺TVBOX接口一键复制配置地址+⭐开源地址指向自建Gitea,仅首页显示;直播页移除开源按钮)、每 IP 限流 429;运行时组件见 `license-hub.js` |
|
||||||
|
|
||||||
补丁固化在本地镜像(compose 引用,当前 `katelyatv:fixed44`)。上游大版本升级后重放补丁:
|
补丁已全部源码化,运行时注入仅保留注释说明(`patches/apply.sh` 无活跃 `docker cp/exec`,执行仅重启容器)。镜像构建:`source/` 源码构建 → `katelyatv:fixed71`(compose 引用)。上游大版本升级后:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash patches/apply.sh # 重放补丁
|
pnpm --dir source build && docker build -t katelyatv:fixedXX ./source # 源码构建(新功能一律先改 source/ 再 build)
|
||||||
python3 patches/inject_live.py # 重放直播注入(幂等)
|
docker compose -f docker-compose.redis.yml up -d --force-recreate
|
||||||
docker cp license-hub.js katelyatv:/app/license-hub.js
|
|
||||||
node patches/patch_license.js # 重放授权/角标/限流(幂等)
|
|
||||||
docker commit katelyatv katelyatv:fixed44 # 固化新镜像
|
|
||||||
docker compose -f docker-compose.redis.yml up -d
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🙏 致谢
|
## 🙏 致谢
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ version: '3.8'
|
|||||||
services:
|
services:
|
||||||
# KatelyaTV 应用服务
|
# KatelyaTV 应用服务
|
||||||
katelyatv:
|
katelyatv:
|
||||||
image: katelyatv:fixed44
|
image: katelyatv:fixed71
|
||||||
container_name: katelyatv
|
container_name: katelyatv
|
||||||
ports:
|
ports:
|
||||||
- "3030:3000"
|
- "3030:3000"
|
||||||
@@ -36,7 +36,7 @@ services:
|
|||||||
HUB_PROJECT_ID: ${HUB_PROJECT_ID:-11}
|
HUB_PROJECT_ID: ${HUB_PROJECT_ID:-11}
|
||||||
HUB_DISABLED: ${HUB_DISABLED:-0}
|
HUB_DISABLED: ${HUB_DISABLED:-0}
|
||||||
# 当前版本号(右上角角标 + 授权中心自检上报)
|
# 当前版本号(右上角角标 + 授权中心自检上报)
|
||||||
SITE_VERSION: ${SITE_VERSION:-fixed41}
|
SITE_VERSION: ${SITE_VERSION:-fixed44}
|
||||||
depends_on:
|
depends_on:
|
||||||
- katelyatv-redis
|
- katelyatv-redis
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
+21
-2
@@ -119,6 +119,16 @@ async function heartbeat() {
|
|||||||
} catch (e) { state.hub_ok = false; console.log("[LICENSE] heartbeat err " + String(e && e.message || e)); }
|
} catch (e) { state.hub_ok = false; console.log("[LICENSE] heartbeat err " + String(e && e.message || e)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 本地公告控制:/app/announcement.json(可热改,无需重启)
|
||||||
|
// { "block_ids": [13], "override": { "enabled": true, "title": "...", "content": "...", "is_popup": 1 } }
|
||||||
|
function loadLocalAnnouncement() {
|
||||||
|
try {
|
||||||
|
const p = process.env.LOCAL_ANNOUNCEMENT_FILE || "/app/public/announcement.json";
|
||||||
|
if (!FS.existsSync(p)) return null;
|
||||||
|
return JSON.parse(FS.readFileSync(p, "utf8")) || null;
|
||||||
|
} catch (e) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchAnnouncements() {
|
async function fetchAnnouncements() {
|
||||||
const ctl = new AbortController();
|
const ctl = new AbortController();
|
||||||
const tm = setTimeout(() => ctl.abort(), TIMEOUT);
|
const tm = setTimeout(() => ctl.abort(), TIMEOUT);
|
||||||
@@ -128,8 +138,17 @@ async function fetchAnnouncements() {
|
|||||||
const j = await r.json();
|
const j = await r.json();
|
||||||
if (j && j.code === 200 && j.data) {
|
if (j && j.code === 200 && j.data) {
|
||||||
const ok = (arr) => (Array.isArray(arr) ? arr.filter(x => x && (x.project_id == null || String(x.project_id) === PROJECT_ID)) : []);
|
const ok = (arr) => (Array.isArray(arr) ? arr.filter(x => x && (x.project_id == null || String(x.project_id) === PROJECT_ID)) : []);
|
||||||
state.announcements = ok(j.data.list);
|
const local = loadLocalAnnouncement() || {};
|
||||||
state.popup = ok(j.data.popup)[0] || state.announcements[0] || null; // 授权中心返回空列表即覆盖为空
|
const blockIds = Array.isArray(local.block_ids) ? local.block_ids.map(String) : [];
|
||||||
|
const keep = (arr) => ok(arr).filter(x => !blockIds.includes(String(x.id)));
|
||||||
|
state.announcements = keep(j.data.list);
|
||||||
|
const ov = local.override;
|
||||||
|
if (ov && ov.enabled !== false && (ov.title || ov.content)) {
|
||||||
|
state.popup = { id: "local", title: ov.title || "", content: ov.content || "", is_popup: ov.is_popup == null ? 1 : ov.is_popup, project_id: PROJECT_ID, local: true };
|
||||||
|
} else {
|
||||||
|
const wantPopup = (x) => Number(x.is_popup) === 1;
|
||||||
|
state.popup = keep(j.data.popup).filter(wantPopup)[0] || state.announcements.filter(wantPopup)[0] || null;
|
||||||
|
}
|
||||||
state.hub_ok = true;
|
state.hub_ok = true;
|
||||||
console.log("[LICENSE] announcements n=" + state.announcements.length + " popup=" + (state.popup ? String(state.popup.title || "").slice(0, 30) : "-"));
|
console.log("[LICENSE] announcements n=" + state.announcements.length + " popup=" + (state.popup ? String(state.popup.title || "").slice(0, 30) : "-"));
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-33
@@ -13,49 +13,56 @@ docker ps --filter "name=^${C}$" --format '{{.Names}} {{.Image}}' | grep -q . \
|
|||||||
echo "[2/5] 校验产物版本(需含 TVBOX 补丁标记或同源 fixed13 产物)..."
|
echo "[2/5] 校验产物版本(需含 TVBOX 补丁标记或同源 fixed13 产物)..."
|
||||||
# 目标文件必须存在且是可解析 JS
|
# 目标文件必须存在且是可解析 JS
|
||||||
docker exec "$C" node --check /app/.next/server/app/api/tvbox/route.js
|
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
|
docker exec "$C" node --check /app/.next/server/app/api/filter/route.js || echo "filter路由为源码构建产物,跳过旧补丁校验"
|
||||||
|
|
||||||
echo "[3/5] 复制补丁文件 ..."
|
echo "[3/5] 复制补丁文件 ... 已源码化(fixed58 tvbox直播透传/fixed63 filter前后端+菜单入口):不再覆盖 tvbox/filter 路由、routes-manifest、filter页面chunk"
|
||||||
docker cp "$DIR/app-api-tvbox-route.js" "$C:/app/.next/server/app/api/tvbox/route.js"
|
# docker cp "$DIR/app-api-tvbox-route.js" "$C:/app/.next/server/app/api/tvbox/route.js"
|
||||||
docker cp "$DIR/app-api-filter-route.js" "$C:/app/.next/server/app/api/filter/route.js"
|
# docker cp "$DIR/app-api-filter-route.js" "$C:/app/.next/server/app/api/filter/route.js"
|
||||||
docker cp "$DIR/routes-manifest.json" "$C:/app/.next/routes-manifest.json"
|
# docker cp "$DIR/routes-manifest.json" "$C:/app/.next/routes-manifest.json"
|
||||||
docker cp "$DIR/filter-page-chunk.js" "$C:/app/.next/static/chunks/app/filter/page-4d01a87b20ac1a73.js"
|
# docker cp "$DIR/filter-page-chunk.js" "$C:/app/.next/static/chunks/app/filter/page-4d01a87b20ac1a73.js"
|
||||||
|
|
||||||
echo "[4/5] 语法校验 ..."
|
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/tvbox/route.js
|
||||||
docker exec "$C" node --check /app/.next/server/app/api/filter/route.js
|
# docker exec "$C" node --check /app/.next/server/app/api/filter/route.js
|
||||||
|
|
||||||
echo "[4a/5] 授权系统补丁(角标/铃铛/TVBOX按钮/IPv6探针)..."
|
echo "[4a/5] 授权系统补丁(角标/铃铛/TVBOX按钮/IPv6探针)... 已源码化(fixed54: HubBell/HubNotice/TvboxButton/版本角标/layout公告),跳过运行时注入"
|
||||||
docker cp "$DIR/patch_license.js" "$C:/tmp/patch_license.js"
|
# docker cp "$DIR/patch_license.js" "$C:/tmp/patch_license.js"
|
||||||
docker exec "$C" node /tmp/patch_license.js || true
|
# docker exec "$C" node /tmp/patch_license.js || true
|
||||||
|
|
||||||
echo "[4b/5] 应用公告补丁(免责声明→CardAuth公告)..."
|
echo "[4b/5] 应用公告补丁(免责声明→CardAuth公告)... 已源码化(fixed54: layout.tsx读hub.getNotice),跳过运行时注入"
|
||||||
docker cp "$DIR/patch-announcement.js" "$C:/tmp/patch-announcement.js"
|
# docker cp "$DIR/patch-announcement.js" "$C:/tmp/patch-announcement.js"
|
||||||
docker exec "$C" node /tmp/patch-announcement.js || true
|
# docker exec "$C" node /tmp/patch-announcement.js || true
|
||||||
docker exec "$C" node --check /app/.next/server/chunks/8583.js || { echo "8583.js 语法失败"; exit 1; }
|
# docker exec "$C" node --check /app/.next/server/chunks/8583.js || { echo "8583.js 语法失败"; exit 1; }
|
||||||
|
|
||||||
echo "[4c/5] 移除重复的 HubNotice 弹窗..."
|
echo "[4c/5] 移除重复的 HubNotice 弹窗... 已源码化(HubNotice组件挂载于PageLayout,无重复注入),跳过"
|
||||||
docker cp "$DIR/patch-hubnotice-remove.js" "$C:/tmp/patch-hubnotice-remove.js"
|
# docker cp "$DIR/patch-hubnotice-remove.js" "$C:/tmp/patch-hubnotice-remove.js"
|
||||||
docker exec "$C" node /tmp/patch-hubnotice-remove.js || true
|
# docker exec "$C" node /tmp/patch-hubnotice-remove.js || true
|
||||||
|
|
||||||
echo "[4d/5] 注入直播 /live 功能..."
|
echo "[4d/5] 注入直播 /live 功能... 已源码化(fixed58: live-inject.js随镜像发布+tvbox路由透传Response),跳过运行时注入"
|
||||||
python3 "$DIR/inject_live.py" || echo "live inject failed (non-fatal)"
|
# python3 "$DIR/inject_live.py" || echo "live inject failed (non-fatal)"
|
||||||
|
|
||||||
echo "[4e/5] 顶部/底部菜单加入 AI短剧 入口..."
|
echo "[4e/5] 顶部/底部菜单加入 AI短剧 入口... 已源码化(PageLayout菜单含AI短剧),跳过运行时注入"
|
||||||
docker cp "$DIR/patch-aidrama-menu.js" "$C:/tmp/patch-aidrama-menu.js"
|
# docker cp "$DIR/patch-aidrama-menu.js" "$C:/tmp/patch-aidrama-menu.js"
|
||||||
docker exec "$C" node /tmp/patch-aidrama-menu.js || true
|
# docker exec "$C" node /tmp/patch-aidrama-menu.js || true
|
||||||
|
|
||||||
echo "[4e2/5] 导航菜单可收缩(避免把右侧按钮挤出视口)..."
|
echo "[4e2/5] 导航菜单可收缩(避免把右侧按钮挤出视口)... 已源码化(PageLayout导航min-w-0/flex-1/overflow-x-auto),跳过运行时注入"
|
||||||
docker cp "$DIR/patch_nav_shrink.js" "$C:/tmp/patch_nav_shrink.js"
|
# docker cp "$DIR/patch_nav_shrink.js" "$C:/tmp/patch_nav_shrink.js"
|
||||||
docker exec "$C" node /tmp/patch_nav_shrink.js || true
|
# docker exec "$C" node /tmp/patch_nav_shrink.js || true
|
||||||
|
|
||||||
echo "[4f/5] 注入 /ipv6 线路选择页 + 首页 IPV4/IPV6 切换按钮..."
|
echo "[4f/5] 注入 /ipv6 线路选择页 + 首页 IPV4/IPV6 切换按钮... 已源码化(ipv6页+Iipv6Button+middleware白名单),跳过运行时注入"
|
||||||
python3 "$DIR/inject_ipv6.py" || echo "ipv6 inject failed (non-fatal)"
|
# python3 "$DIR/inject_ipv6.py" || echo "ipv6 inject failed (non-fatal)"
|
||||||
python3 "$DIR/patch_middleware_whitelist.py" || echo "middleware whitelist failed (non-fatal)"
|
# python3 "$DIR/patch_middleware_whitelist.py" || echo "middleware whitelist failed (non-fatal)"
|
||||||
|
|
||||||
echo "[4g/5] 前端资源防陈旧缓存(chunk按内容改名)..."
|
echo "[4h/5] 用户最后登录/注册时间记录... 已源码化(redis.db touchLogin+login调用+admin回填),跳过运行时注入"
|
||||||
docker cp "$DIR/patch_cachebust.js" "$C:/tmp/patch_cachebust.js"
|
# python3 "$DIR/inject_last_login.py" || echo "last_login inject failed (non-fatal)"
|
||||||
docker exec "$C" node /tmp/patch_cachebust.js || true
|
|
||||||
|
echo "[4g/5] 前端资源防陈旧缓存... 已过时停用(Next构建自带contenthash,容器内无402 chunk),跳过运行时改名"
|
||||||
|
# docker cp "$DIR/patch_cachebust.js" "$C:/tmp/patch_cachebust.js"
|
||||||
|
# docker exec "$C" node /tmp/patch_cachebust.js || true
|
||||||
|
|
||||||
|
echo "[4i/5] 访问日志... 已源码化(middleware内console.log [ACCESS],替代注入next内部start-server.js),跳过运行时注入"
|
||||||
|
# docker cp "$DIR/patch_access_log.js" "$C:/tmp/patch_access_log.js"
|
||||||
|
# docker exec "$C" node /tmp/patch_access_log.js || true
|
||||||
|
|
||||||
echo "[5/5] 重启 ..."
|
echo "[5/5] 重启 ..."
|
||||||
docker restart "$C" >/dev/null
|
docker restart "$C" >/dev/null
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""回填用户时间字段(默认演练,不写入):
|
||||||
|
|
||||||
|
⚠️ 教训:Redis 重启/RDB 重载后所有键的 IDLETIME 会从加载时刻统一起算,
|
||||||
|
此时「用空闲时长估算上次登录」会把所有账号写成同一个时间(假数据)。
|
||||||
|
实测本机就是这种情况,因此不推荐实跑;last_login 由 inject_last_login.py 从此刻起真实记录。
|
||||||
|
|
||||||
|
- 缺失 created_at 的老账号:写入首次记录时间并标记 created_at_est=1(面板显示「约」)
|
||||||
|
- 缺失 last_login 的账号:用 u:<name>:pwd 的空闲时长估算,标记 last_login_est=1
|
||||||
|
|
||||||
|
用法:python3 backfill_user_times.py [--dry|--force] (默认 --dry)
|
||||||
|
环境变量:KAT_REDIS(默认 katelyatv-redis)
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
REDIS = os.environ.get("KAT_REDIS", "katelyatv-redis")
|
||||||
|
DRY = "--force" not in sys.argv
|
||||||
|
|
||||||
|
|
||||||
|
def rc(*args):
|
||||||
|
r = subprocess.run(
|
||||||
|
["docker", "exec", REDIS, "redis-cli", "--raw", *args],
|
||||||
|
capture_output=True, text=True,
|
||||||
|
)
|
||||||
|
return r.stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
cfg_raw = rc("GET", "admin:config")
|
||||||
|
users = set()
|
||||||
|
try:
|
||||||
|
cfg = json.loads(cfg_raw)
|
||||||
|
for u in (cfg.get("UserConfig") or {}).get("Users") or []:
|
||||||
|
n = u.get("username")
|
||||||
|
if isinstance(n, dict):
|
||||||
|
n = n.get("username")
|
||||||
|
if n:
|
||||||
|
users.add(str(n))
|
||||||
|
except Exception as e:
|
||||||
|
print("读取 admin:config 失败,仅按 pwd 键回填:", e)
|
||||||
|
|
||||||
|
pwd_keys = [k for k in rc("KEYS", "u:*:pwd").splitlines() if k.strip()]
|
||||||
|
pwd_users = {}
|
||||||
|
for k in pwd_keys:
|
||||||
|
parts = k.split(":")
|
||||||
|
if len(parts) == 3:
|
||||||
|
pwd_users[parts[1]] = k
|
||||||
|
users |= set(pwd_users.keys())
|
||||||
|
|
||||||
|
now_ms = int(time.time() * 1000)
|
||||||
|
created = last = 0
|
||||||
|
for name in sorted(users):
|
||||||
|
# created_at
|
||||||
|
if not rc("GET", f"u:{name}:created_at"):
|
||||||
|
if not DRY:
|
||||||
|
rc("SET", f"u:{name}:created_at", str(now_ms))
|
||||||
|
rc("SET", f"u:{name}:created_at_est", "1")
|
||||||
|
created += 1
|
||||||
|
# last_login
|
||||||
|
if not rc("GET", f"u:{name}:last_login"):
|
||||||
|
key = pwd_users.get(name)
|
||||||
|
if key:
|
||||||
|
idle = rc("OBJECT", "IDLETIME", key)
|
||||||
|
try:
|
||||||
|
idle_s = int(idle)
|
||||||
|
except ValueError:
|
||||||
|
idle_s = None
|
||||||
|
if idle_s is not None and idle_s >= 0:
|
||||||
|
ts = now_ms - idle_s * 1000
|
||||||
|
if not DRY:
|
||||||
|
rc("SET", f"u:{name}:last_login", str(ts))
|
||||||
|
rc("SET", f"u:{name}:last_login_est", "1")
|
||||||
|
last += 1
|
||||||
|
print(f"users={len(users)} created_filled={created} last_login_filled={last} dry={DRY}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""注入 IPv4/IPv6 线路选择页 /ipv6 + 右上角切换按钮(幂等可重跑)"""
|
"""注入 IPv4/IPv6 线路选择页 /ipv6 + 右上角切换按钮(幂等可重跑)"""
|
||||||
|
import os
|
||||||
import subprocess, json, tempfile, os
|
import subprocess, json, tempfile, os
|
||||||
|
|
||||||
|
CT = os.environ.get("KAT_CONTAINER", "katelyatv")
|
||||||
|
|
||||||
P = "/app/.next/server/app/api/tvbox/route.js"
|
P = "/app/.next/server/app/api/tvbox/route.js"
|
||||||
RM = "/app/.next/routes-manifest.json"
|
RM = "/app/.next/routes-manifest.json"
|
||||||
MC_DIR = "/app/.next/static/chunks"
|
MC_DIR = "/app/.next/static/chunks"
|
||||||
@@ -9,9 +12,9 @@ MARK_S, MARK_E = "/* ==== IPV6PAGE:", "/* ==== IPV6PAGE END ==== */"
|
|||||||
HOOK = 'try{let _ipv6p=new URL(e.url);if(_ipv6p.pathname==="/ipv6"||_ipv6p.searchParams.get("ipv6")==="page")return IPV6PAGE(e)}catch(_ie){console.log("[IPV6-HOOK]",_ie&&_ie.message)}'
|
HOOK = 'try{let _ipv6p=new URL(e.url);if(_ipv6p.pathname==="/ipv6"||_ipv6p.searchParams.get("ipv6")==="page")return IPV6PAGE(e)}catch(_ie){console.log("[IPV6-HOOK]",_ie&&_ie.message)}'
|
||||||
|
|
||||||
def read(p):
|
def read(p):
|
||||||
return subprocess.run(["docker","exec","-u","root","katelyatv","cat",p],capture_output=True,check=True).stdout.decode()
|
return subprocess.run(["docker","exec","-u","root",CT,"cat",p],capture_output=True,check=True).stdout.decode()
|
||||||
def write(p, data):
|
def write(p, data):
|
||||||
r=subprocess.run(["docker","exec","-u","root","-i","katelyatv","sh","-c",f"cat > {p}"],input=data.encode(),capture_output=True)
|
r=subprocess.run(["docker","exec","-u","root","-i",CT,"sh","-c",f"cat > {p}"],input=data.encode(),capture_output=True)
|
||||||
assert r.returncode==0, r.stderr.decode()[:300]
|
assert r.returncode==0, r.stderr.decode()[:300]
|
||||||
|
|
||||||
# ---- 1) route.js: 注入 IPV6PAGE 函数 + 入口钩子 ----
|
# ---- 1) route.js: 注入 IPV6PAGE 函数 + 入口钩子 ----
|
||||||
@@ -50,10 +53,10 @@ if not any(x.get("source") == "/ipv6" for x in af):
|
|||||||
|
|
||||||
# ---- 3) 右上角 IPV4/IPV6 切换按钮(注入 402 chunk,样式对齐 TVBOX接口按钮)----
|
# ---- 3) 右上角 IPV4/IPV6 切换按钮(注入 402 chunk,样式对齐 TVBOX接口按钮)----
|
||||||
target = None
|
target = None
|
||||||
files = subprocess.run(["docker","exec","katelyatv","ls",MC_DIR],capture_output=True,check=True).stdout.decode().split()
|
files = subprocess.run(["docker","exec",CT,"ls",MC_DIR],capture_output=True,check=True).stdout.decode().split()
|
||||||
for fn in files:
|
for fn in files:
|
||||||
if not fn.endswith(".js"): continue
|
if not fn.endswith(".js"): continue
|
||||||
c = subprocess.run(["docker","exec","katelyatv","cat",f"{MC_DIR}/{fn}"],capture_output=True).stdout.decode()
|
c = subprocess.run(["docker","exec",CT,"cat",f"{MC_DIR}/{fn}"],capture_output=True).stdout.decode()
|
||||||
if 'gitea.88531.cn/jinghui/katelyatv' in c and 'mvModal' in c:
|
if 'gitea.88531.cn/jinghui/katelyatv' in c and 'mvModal' in c:
|
||||||
target = f"{MC_DIR}/{fn}"; break
|
target = f"{MC_DIR}/{fn}"; break
|
||||||
if not target:
|
if not target:
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""LASTLOGIN-V1 —— 让线上编译产物记录「最后登录时间」
|
||||||
|
|
||||||
|
问题:源码 src/lib/redis.db.ts 已实现 touchLogin(),但运行中的 .next 是旧版编译产物,
|
||||||
|
login 路由里没有这段逻辑 → Redis 中不存在 u:<user>:last_login,管理端最后登录时间恒为空。
|
||||||
|
|
||||||
|
做法(不改 .next 结构,不重建镜像):
|
||||||
|
1. 安装最小 Redis 客户端到 /app/last-login.js(源文件 patches/last-login.js)
|
||||||
|
2. login/route.js:登录校验通过后写入 u:<user>:last_login = 当前毫秒时间戳(失败静默,不影响登录)
|
||||||
|
3. admin/users/route.js:返回用户列表时回填 last_login_at 字段
|
||||||
|
|
||||||
|
幂等:以 /*LASTLOGIN-V1*/ 标记判定,已注入则只刷新 /app/last-login.js。
|
||||||
|
用法:python3 patches/inject_last_login.py
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
MARK = "/*LASTLOGIN-V1*/"
|
||||||
|
CONTAINER = os.environ.get("KAT_CONTAINER", "katelyatv")
|
||||||
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
HELPER = os.path.join(HERE, "last-login.js")
|
||||||
|
HELPER_DEST = "/app/last-login.js"
|
||||||
|
|
||||||
|
LOGIN = "/app/.next/server/app/api/login/route.js"
|
||||||
|
ADMINS = "/app/.next/server/app/api/admin/users/route.js"
|
||||||
|
|
||||||
|
LOGIN_ANCHOR = 'let e=i.NextResponse.json({ok:!0}),n=await g(t,r,s?.role||"user",!1),a=new Date;'
|
||||||
|
# 环境变量 owner 分支(.env 里的 USERNAME 登录走这里)
|
||||||
|
LOGIN_OWNER_ANCHOR = 'let e=i.NextResponse.json({ok:!0}),s=await g(t,r,"owner",!1),n=new Date;'
|
||||||
|
LOGIN_INJECT = (
|
||||||
|
MARK
|
||||||
|
+ 'try{require("/app/last-login.js").touch(t)}catch(_e){}'
|
||||||
|
)
|
||||||
|
|
||||||
|
ADMIN_ANCHOR = "return i.NextResponse.json({users:n,total:n.length})"
|
||||||
|
ADMIN_INJECT = (
|
||||||
|
MARK
|
||||||
|
+ 'try{const __kaM=await require("/app/last-login.js").readMany('
|
||||||
|
"n.map(function(x){return x.username}));"
|
||||||
|
"n.forEach(function(x){const v=__kaM[x.username]||{};"
|
||||||
|
"if(v.last_login){x.last_login_at=Number(v.last_login);"
|
||||||
|
"if(v.last_login_est)x.last_login_estimated=true}"
|
||||||
|
"if(!x.created_at&&v.created_at){x.created_at=Number(v.created_at);"
|
||||||
|
"if(v.created_at_est)x.created_at_estimated=true}});}catch(_e){}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def strip_old(src):
|
||||||
|
"""移除本补丁早先注入的片段,保证可重复执行不叠加。"""
|
||||||
|
while MARK in src:
|
||||||
|
i = src.index(MARK)
|
||||||
|
j = src.find("catch(_e){}", i)
|
||||||
|
if j < 0:
|
||||||
|
break
|
||||||
|
src = src[:i] + src[j + len("catch(_e){}"):]
|
||||||
|
return src
|
||||||
|
|
||||||
|
|
||||||
|
def sh(cmd):
|
||||||
|
return subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
||||||
|
|
||||||
|
|
||||||
|
def install_helper():
|
||||||
|
if not os.path.exists(HELPER):
|
||||||
|
print(" ✗ 缺少 %s" % HELPER)
|
||||||
|
return False
|
||||||
|
r = sh("docker cp %s %s:%s" % (HELPER, CONTAINER, HELPER_DEST))
|
||||||
|
if r.returncode:
|
||||||
|
print(" ✗ 复制 helper 失败: %s" % r.stderr.strip())
|
||||||
|
return False
|
||||||
|
fix_perm(HELPER_DEST)
|
||||||
|
print(" ✓ 已安装 %s" % HELPER_DEST)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def fix_perm(path):
|
||||||
|
sh("docker exec -u root %s sh -c 'chown 1001:1001 %s 2>/dev/null; chmod 644 %s'" % (CONTAINER, path, path))
|
||||||
|
|
||||||
|
|
||||||
|
def read_container(path):
|
||||||
|
tmp = tempfile.mktemp(suffix=".js")
|
||||||
|
r = sh("docker cp %s:%s %s" % (CONTAINER, path, tmp))
|
||||||
|
if r.returncode:
|
||||||
|
print(" ✗ 读取 %s 失败: %s" % (path, r.stderr.strip()))
|
||||||
|
return None, tmp
|
||||||
|
with open(tmp, encoding="utf-8") as f:
|
||||||
|
return f.read(), tmp
|
||||||
|
|
||||||
|
|
||||||
|
def write_container(src, path):
|
||||||
|
r = sh("docker cp %s %s:%s" % (src, CONTAINER, path))
|
||||||
|
if r.returncode:
|
||||||
|
print(" ✗ 写回 %s 失败: %s" % (path, r.stderr.strip()))
|
||||||
|
return False
|
||||||
|
fix_perm(path)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def patch_file(path, pairs, label):
|
||||||
|
"""pairs: [(anchor, inject), ...] —— 一次读取、一次写回,避免多锚点互相覆盖。"""
|
||||||
|
src, tmp = read_container(path)
|
||||||
|
if src is None:
|
||||||
|
return False
|
||||||
|
src = strip_old(src)
|
||||||
|
for anchor, inject in pairs:
|
||||||
|
if anchor not in src:
|
||||||
|
print(" ✗ %s 锚点未找到: %s" % (label, anchor[:60]))
|
||||||
|
return False
|
||||||
|
src = src.replace(anchor, inject + anchor, 1)
|
||||||
|
tmp_js = tmp + ".patched.js"
|
||||||
|
with open(tmp_js, "w", encoding="utf-8") as f:
|
||||||
|
f.write(src)
|
||||||
|
chk = sh("node --check %s" % tmp_js)
|
||||||
|
if chk.returncode:
|
||||||
|
print(" ✗ %s 语法检查失败: %s" % (label, chk.stderr.strip()[:300]))
|
||||||
|
return False
|
||||||
|
if not write_container(tmp_js, path):
|
||||||
|
return False
|
||||||
|
print(" ✓ %s 已注入" % label)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("== LASTLOGIN-V1 ==")
|
||||||
|
ok = install_helper()
|
||||||
|
ok = patch_file(LOGIN, [(LOGIN_ANCHOR, LOGIN_INJECT), (LOGIN_OWNER_ANCHOR, LOGIN_INJECT)],
|
||||||
|
"login/route.js(普通用户 + owner 两条登录分支)") and ok
|
||||||
|
ok = patch_file(ADMINS, [(ADMIN_ANCHOR, ADMIN_INJECT)], "admin/users/route.js(回填最后登录/注册时间)") and ok
|
||||||
|
if not ok:
|
||||||
|
print("!! 有步骤失败")
|
||||||
|
return 1
|
||||||
|
print("完成,重启容器后生效:docker restart %s" % CONTAINER)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""注入直播功能到运行中容器(幂等可重跑):LIVE 函数块 + 入口拦截 + /live rewrite + 菜单项"""
|
"""注入直播功能到运行中容器(幂等可重跑):LIVE 函数块 + 入口拦截 + /live rewrite + 菜单项"""
|
||||||
|
import os
|
||||||
import subprocess, json, tempfile, os
|
import subprocess, json, tempfile, os
|
||||||
|
|
||||||
|
CT = os.environ.get("KAT_CONTAINER", "katelyatv")
|
||||||
|
|
||||||
P = "/app/.next/server/app/api/tvbox/route.js"
|
P = "/app/.next/server/app/api/tvbox/route.js"
|
||||||
RM = "/app/.next/routes-manifest.json"
|
RM = "/app/.next/routes-manifest.json"
|
||||||
MC = "/app/.next/static/chunks/402-42ae253cc67eee98.js"
|
MC = "/app/.next/static/chunks/402-42ae253cc67eee98.js"
|
||||||
@@ -11,10 +14,10 @@ HOOK_OLD = 'try{let _lv=new URL(e.url).searchParams.get("live");if(_lv)return aw
|
|||||||
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)}'
|
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):
|
def read(p):
|
||||||
return subprocess.run(["docker","exec","-u","root","katelyatv","cat",p],capture_output=True,check=True).stdout.decode()
|
return subprocess.run(["docker","exec","-u","root",CT,"cat",p],capture_output=True,check=True).stdout.decode()
|
||||||
|
|
||||||
def write(p, data):
|
def write(p, data):
|
||||||
r=subprocess.run(["docker","exec","-u","root","-i","katelyatv","sh","-c",f"cat > {p}"],input=data.encode(),capture_output=True)
|
r=subprocess.run(["docker","exec","-u","root","-i",CT,"sh","-c",f"cat > {p}"],input=data.encode(),capture_output=True)
|
||||||
assert r.returncode==0, r.stderr.decode()[:300]
|
assert r.returncode==0, r.stderr.decode()[:300]
|
||||||
|
|
||||||
# ---- 1) route.js: 删旧块+插新块+入口钩子 ----
|
# ---- 1) route.js: 删旧块+插新块+入口钩子 ----
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
/* LASTLOGIN-V1 —— 记录/读取用户最后登录时间(Redis: u:<username>:last_login,毫秒时间戳)
|
||||||
|
*
|
||||||
|
* 背景:源码 src/lib/redis.db.ts 已有 touchLogin,但线上 .next 是旧版编译产物,没有这段逻辑。
|
||||||
|
* 本文件是补丁用的最小 Redis(RESP) 客户端,不依赖 node_modules,供 patches/inject_last_login.py
|
||||||
|
* 注入到 /app/.next/server/app/api/login/route.js 与 .../admin/users/route.js 使用。
|
||||||
|
*/
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const net = require("net");
|
||||||
|
|
||||||
|
function target() {
|
||||||
|
const raw = process.env.REDIS_URL || "redis://katelyatv-redis:6379";
|
||||||
|
const u = new URL(raw);
|
||||||
|
return {
|
||||||
|
host: u.hostname || "katelyatv-redis",
|
||||||
|
port: Number(u.port || 6379),
|
||||||
|
pass: process.env.REDIS_PASSWORD || (u.password ? decodeURIComponent(u.password) : ""),
|
||||||
|
db: String(process.env.REDIS_DATABASE || (u.pathname || "/0").replace(/^\//, "") || "0"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function enc(v) {
|
||||||
|
v = String(v);
|
||||||
|
return "$" + Buffer.byteLength(v) + "\r\n" + v + "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function build(cmd) {
|
||||||
|
return "*" + cmd.length + "\r\n" + cmd.map(enc).join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function parse(s, i) {
|
||||||
|
if (i >= s.length) return null;
|
||||||
|
const t = s[i];
|
||||||
|
const nl = s.indexOf("\r\n", i);
|
||||||
|
if (nl < 0) return null;
|
||||||
|
const head = s.slice(i + 1, nl);
|
||||||
|
if (t === "+" || t === "-") return [head, nl + 2];
|
||||||
|
if (t === ":") return [Number(head), nl + 2];
|
||||||
|
if (t === "$") {
|
||||||
|
const n = Number(head);
|
||||||
|
if (n < 0) return [null, nl + 2];
|
||||||
|
const end = nl + 2 + n;
|
||||||
|
if (s.length < end + 2) return null;
|
||||||
|
return [s.slice(nl + 2, end), end + 2];
|
||||||
|
}
|
||||||
|
if (t === "*") {
|
||||||
|
const n = Number(head);
|
||||||
|
if (n < 0) return [null, nl + 2];
|
||||||
|
let p = nl + 2;
|
||||||
|
const arr = [];
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const r = parse(s, p);
|
||||||
|
if (!r) return null;
|
||||||
|
arr.push(r[0]);
|
||||||
|
p = r[1];
|
||||||
|
}
|
||||||
|
return [arr, p];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(commands, timeout) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let cfg;
|
||||||
|
try {
|
||||||
|
cfg = target();
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const pre = [];
|
||||||
|
if (cfg.pass) pre.push(["AUTH", cfg.pass]);
|
||||||
|
pre.push(["SELECT", cfg.db]);
|
||||||
|
let payload = "";
|
||||||
|
for (const c of pre) payload += build(c);
|
||||||
|
for (const c of commands) payload += build(c);
|
||||||
|
const want = pre.length + commands.length;
|
||||||
|
const sock = net.createConnection({ host: cfg.host, port: cfg.port });
|
||||||
|
let buf = "";
|
||||||
|
let settled = false;
|
||||||
|
const done = (err, val) => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
try {
|
||||||
|
sock.destroy();
|
||||||
|
} catch (e) {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
if (err) reject(err);
|
||||||
|
else resolve(val);
|
||||||
|
};
|
||||||
|
sock.setTimeout(timeout || 2000, () => done(new Error("redis timeout")));
|
||||||
|
sock.on("error", (e) => done(e));
|
||||||
|
sock.on("data", (d) => {
|
||||||
|
buf += d.toString("utf8");
|
||||||
|
const out = [];
|
||||||
|
let p = 0;
|
||||||
|
for (let k = 0; k < want; k++) {
|
||||||
|
const r = parse(buf, p);
|
||||||
|
if (!r) return;
|
||||||
|
out.push(r[0]);
|
||||||
|
p = r[1];
|
||||||
|
}
|
||||||
|
done(null, out.slice(pre.length));
|
||||||
|
});
|
||||||
|
sock.write(payload);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录成功后调用,失败静默(绝不影响登录)
|
||||||
|
function touch(username) {
|
||||||
|
if (!username) return Promise.resolve(false);
|
||||||
|
return run([["SET", "u:" + username + ":last_login", String(Date.now())]])
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量读取,返回 { username: { last_login, created_at, last_login_est, created_at_est } }
|
||||||
|
function readMany(usernames) {
|
||||||
|
const list = (usernames || []).filter(Boolean);
|
||||||
|
if (!list.length) return Promise.resolve({});
|
||||||
|
const fields = ["last_login", "created_at", "last_login_est", "created_at_est"];
|
||||||
|
const cmds = [];
|
||||||
|
for (const u of list) for (const f of fields) cmds.push(["GET", "u:" + u + ":" + f]);
|
||||||
|
return run(cmds)
|
||||||
|
.then((vals) => {
|
||||||
|
const m = {};
|
||||||
|
list.forEach((u, i) => {
|
||||||
|
const o = {};
|
||||||
|
fields.forEach((f, j) => {
|
||||||
|
const v = vals[i * fields.length + j];
|
||||||
|
if (v) o[f] = v;
|
||||||
|
});
|
||||||
|
m[u] = o;
|
||||||
|
});
|
||||||
|
return m;
|
||||||
|
})
|
||||||
|
.catch(() => ({}));
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { touch, readMany, _run: run };
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 在临时容器上重放全部补丁(不动生产容器),用于出新的 fixedNN 镜像
|
||||||
|
# 用法: bash patches/stage_release.sh <源镜像> <临时容器名> <宿主端口>
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
IMG="${1:?源镜像}"
|
||||||
|
C="${2:?临时容器名}"
|
||||||
|
PORT="${3:?宿主端口}"
|
||||||
|
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
DEPLOY="$(dirname "$DIR")"
|
||||||
|
|
||||||
|
docker rm -f "$C" >/dev/null 2>&1 || true
|
||||||
|
docker run -d --name "$C" \
|
||||||
|
--network katelyatv_katelyatv-network \
|
||||||
|
-p "${PORT}:3000" \
|
||||||
|
--env-file "$DEPLOY/.env" \
|
||||||
|
-v "$DEPLOY/config.json:/app/config.json:ro" \
|
||||||
|
-v "$DEPLOY/public-live:/app/public" \
|
||||||
|
"$IMG" >/dev/null
|
||||||
|
|
||||||
|
echo "[stage] 等待启动 ..."
|
||||||
|
for i in $(seq 1 40); do
|
||||||
|
code=$(curl -s -o /dev/null -w '%{http_code}' -m 3 "http://127.0.0.1:${PORT}/login" || true)
|
||||||
|
[ "$code" = "200" ] && break
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "[stage] /login -> $code"
|
||||||
|
|
||||||
|
export KAT_CONTAINER="$C"
|
||||||
|
KAT_REDIS=katelyatv-redis bash "$DIR/apply.sh" "$C"
|
||||||
|
python3 "$DIR/fix_userlist_usernames.py" || echo "[stage] userlist fix skipped"
|
||||||
|
echo "[stage] 补丁完成,容器 $C 运行在 :$PORT"
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"_说明": "站点公告控制:block_ids 里的公告ID不再显示;override 填写后会替换授权中心公告作为弹窗内容(enabled=false 可停用)",
|
||||||
|
"block_ids": [13],
|
||||||
|
"override": null
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
var API_CFG = '/api/admin/config';
|
var API_CFG = '/api/admin/config';
|
||||||
var API_USER = '/api/admin/user';
|
var API_USER = '/api/admin/user';
|
||||||
|
var API_USERS = '/api/admin/users';
|
||||||
var state = { users: [], allowRegister: false, loading: false, open: false };
|
var state = { users: [], allowRegister: false, loading: false, open: false };
|
||||||
|
|
||||||
function el(tag, attrs, kids) {
|
function el(tag, attrs, kids) {
|
||||||
@@ -44,18 +45,37 @@
|
|||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
state.loading = true; render();
|
state.loading = true; render();
|
||||||
return fetch(API_CFG, { headers: { 'Cache-Control': 'no-cache' } })
|
var times = {};
|
||||||
|
// 时间信息(注册/最后登录)来自 /api/admin/users
|
||||||
|
var pTimes = fetch(API_USERS, { headers: { 'Cache-Control': 'no-cache' } })
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.then(function (j) {
|
||||||
|
var arr = (j && Array.isArray(j.users)) ? j.users : [];
|
||||||
|
arr.forEach(function (x) {
|
||||||
|
if (x && x.username) times[String(x.username)] = x;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function () { });
|
||||||
|
return pTimes
|
||||||
|
.then(function () {
|
||||||
|
return fetch(API_CFG, { headers: { 'Cache-Control': 'no-cache' } });
|
||||||
|
})
|
||||||
.then(function (r) { return r.json(); })
|
.then(function (r) { return r.json(); })
|
||||||
.then(function (cfg) {
|
.then(function (cfg) {
|
||||||
var root = (cfg && cfg.Config) ? cfg.Config : (cfg || {});
|
var root = (cfg && cfg.Config) ? cfg.Config : (cfg || {});
|
||||||
var uc = root.UserConfig || {};
|
var uc = root.UserConfig || {};
|
||||||
var list = Array.isArray(uc.Users) ? uc.Users : [];
|
var list = Array.isArray(uc.Users) ? uc.Users : [];
|
||||||
state.users = list.filter(function (u) { return u && typeof u === 'object'; }).map(function (u) {
|
state.users = list.filter(function (u) { return u && typeof u === 'object'; }).map(function (u) {
|
||||||
|
var name = String(typeof u.username === 'object' && u.username ? (u.username.username || '') : (u.username || ''));
|
||||||
|
var t = times[name] || {};
|
||||||
return {
|
return {
|
||||||
username: String(typeof u.username === 'object' && u.username ? (u.username.username || '') : (u.username || '')),
|
username: name,
|
||||||
role: String(u.role || 'user'),
|
role: String(u.role || t.role || 'user'),
|
||||||
banned: !!u.banned,
|
banned: !!u.banned,
|
||||||
created_at: u.created_at ? String(u.created_at) : ''
|
created_at: t.created_at ? String(t.created_at) : (u.created_at ? String(u.created_at) : ''),
|
||||||
|
created_at_estimated: !!(t.created_at_estimated || u.created_at_estimated),
|
||||||
|
last_login_at: t.last_login_at ? String(t.last_login_at) : '',
|
||||||
|
last_login_estimated: !!(t.last_login_estimated || u.last_login_estimated)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
state.allowRegister = !!uc.AllowRegister;
|
state.allowRegister = !!uc.AllowRegister;
|
||||||
@@ -66,10 +86,25 @@
|
|||||||
|
|
||||||
function roleLabel(r) { return r === 'owner' ? '站长' : r === 'admin' ? '管理员' : '普通用户'; }
|
function roleLabel(r) { return r === 'owner' ? '站长' : r === 'admin' ? '管理员' : '普通用户'; }
|
||||||
|
|
||||||
|
function toDate(v) {
|
||||||
|
if (!v) return null;
|
||||||
|
var s = String(v);
|
||||||
|
var d = /^\d+$/.test(s) ? new Date(Number(s)) : new Date(v);
|
||||||
|
return isNaN(d.getTime()) ? null : d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fmtDateTime(v) {
|
||||||
|
if (!v) return '从未登录';
|
||||||
|
var d = toDate(v);
|
||||||
|
if (!d) return String(v).slice(0, 16).replace('T', ' ');
|
||||||
|
var p = function (n) { return (n < 10 ? '0' : '') + n; };
|
||||||
|
return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes());
|
||||||
|
}
|
||||||
|
|
||||||
function fmtDate(v) {
|
function fmtDate(v) {
|
||||||
if (!v) return '-';
|
if (!v) return '-';
|
||||||
var d = new Date(v);
|
var d = toDate(v);
|
||||||
if (isNaN(d.getTime())) return String(v).slice(0, 10);
|
if (!d) return String(v).slice(0, 10);
|
||||||
var p = function (n) { return (n < 10 ? '0' : '') + n; };
|
var p = function (n) { return (n < 10 ? '0' : '') + n; };
|
||||||
return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate());
|
return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate());
|
||||||
}
|
}
|
||||||
@@ -135,7 +170,7 @@
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
var table = el('table', { style: 'width:100%;border-collapse:collapse;font-size:13px' });
|
var table = el('table', { style: 'width:100%;border-collapse:collapse;font-size:13px' });
|
||||||
var thead = el('thead', {}, [el('tr', {}, ['用户名', '角色', '状态', '注册时间', '操作'].map(function (h) {
|
var thead = el('thead', {}, [el('tr', {}, ['用户名', '角色', '状态', '注册时间', '最后登录', '操作'].map(function (h) {
|
||||||
return el('th', { text: h, style: 'text-align:left;padding:8px 6px;color:#6b7280;font-weight:600;border-bottom:1px solid #e5e7eb;white-space:nowrap' });
|
return el('th', { text: h, style: 'text-align:left;padding:8px 6px;color:#6b7280;font-weight:600;border-bottom:1px solid #e5e7eb;white-space:nowrap' });
|
||||||
}))]);
|
}))]);
|
||||||
table.appendChild(thead);
|
table.appendChild(thead);
|
||||||
@@ -185,7 +220,8 @@
|
|||||||
el('td', { text: u.username, style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;font-weight:500;color:#111827;white-space:nowrap' }),
|
el('td', { text: u.username, style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;font-weight:500;color:#111827;white-space:nowrap' }),
|
||||||
el('td', { text: roleLabel(u.role), style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;color:#374151;white-space:nowrap' }),
|
el('td', { text: roleLabel(u.role), style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;color:#374151;white-space:nowrap' }),
|
||||||
el('td', { text: u.banned ? '已封禁' : '正常', style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;color:' + (u.banned ? '#dc2626' : '#059669') + ';white-space:nowrap' }),
|
el('td', { text: u.banned ? '已封禁' : '正常', style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;color:' + (u.banned ? '#dc2626' : '#059669') + ';white-space:nowrap' }),
|
||||||
el('td', { text: fmtDate(u.created_at), style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;color:#6b7280;white-space:nowrap' }),
|
el('td', { text: (u.created_at ? (u.created_at_estimated ? '约 ' : '') + fmtDate(u.created_at) : '未记录'), style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;color:#6b7280;white-space:nowrap', title: u.created_at_estimated ? '该账号早于时间记录功能上线,此处为首次记录时间' : '' }),
|
||||||
|
el('td', { text: (u.last_login_at && u.last_login_estimated ? '约 ' : '') + fmtDateTime(u.last_login_at), title: u.last_login_estimated ? '按账号活跃记录推算的近似时间' : '', style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6;color:' + (u.last_login_at ? '#6b7280' : '#9ca3af') + ';white-space:nowrap' }),
|
||||||
el('td', { style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6' }, [ops])
|
el('td', { style: 'padding:8px 6px;border-bottom:1px solid #f3f4f6' }, [ops])
|
||||||
]);
|
]);
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
|
|||||||
Reference in new issue
Block a user