Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18953ebc9a | ||
|
|
566ee297d9 | ||
|
|
b734661e47 | ||
|
|
9dbe231c79 | ||
|
|
2b3582b4ff | ||
|
|
c29f5395ac | ||
|
|
d5443d97c9 | ||
|
|
2c8a68b064 | ||
|
|
9ffb113ca5 | ||
|
|
e34ec79d5a | ||
|
|
e766391534 | ||
|
|
776f915db5 | ||
|
|
142cf135a5 | ||
|
|
421328c6cb | ||
|
|
395a8fd3f5 | ||
|
|
53cc479f0f | ||
|
|
1df73ed0bf | ||
|
|
eb93b3f062 | ||
|
|
7a99890425 | ||
|
|
574fa99fb4 | ||
|
|
428b4b73d0 | ||
|
|
8c0a1e209b | ||
|
|
940c34a560 | ||
|
|
70b2cacc20 | ||
|
|
7d698273d0 | ||
|
|
d508f84954 |
No files matched your search
@@ -2,6 +2,27 @@
|
||||
|
||||
本文档记录 KatelyaTV 项目的重要更新和功能变更。
|
||||
|
||||
## [fixed96] - 2026-11-09
|
||||
|
||||
### ✨ 新增
|
||||
- **动漫独立页 `/anime`(源码化)**
|
||||
- 聚合各资源站全部动漫内容,地区切换:全部 / 国产 / 日韩 / 欧美 / 港台 / 海外
|
||||
- 后端 `/api/anime`:多源并行抓取 → 地区归一化(国产剧/港台/韩国/日本/欧美/动漫… → 动漫域分类)
|
||||
→ 按 title+year 去重 → 按 `update_time` 降序 → 分页 `pg/next_pg/has_more`
|
||||
- 顶部菜单与移动端底部导航均新增「动漫」入口(源码内 `PageLayout` / `MobileBottomNav`)
|
||||
- **第三方分类浏览接口 `/api/browse`(源码化)**
|
||||
- 统一 `kind=tv|movie|show|anime` + `cat`(分类,支持 `|` 多选)+ `area`(地区)+ `pg`
|
||||
- 新增 `src/lib/vodcat.ts` 集中维护八大分类与地区选项
|
||||
- 三类页签分类全量切到第三方分类语义(电影/剧集/综艺),不再用豆瓣分类值
|
||||
|
||||
### 🐛 修复
|
||||
- **动漫页首次进入永远空列表**:`reset=true` 时 `base` 被置成空数组,新到的 `arr` 没有拼进去,
|
||||
导致接口 200、页面却显示「暂无动漫内容」;改为 `base = [...arr]`
|
||||
|
||||
### 🔄 变更
|
||||
- `/douban` 电影/剧集/综艺 三类选择器改走 `/api/browse`,与 `/api/anime` 共用排序去重逻辑
|
||||
- 版本号 `NEXT_PUBLIC_SITE_VERSION` → `fixed96`(Dockerfile 构建期注入,已验证镜像内 chunk 与页头一致)
|
||||
|
||||
## [fixed44] - 2026-11-06
|
||||
|
||||
### 🐛 修复
|
||||
|
||||
+7
-1
@@ -33,6 +33,10 @@ COPY . .
|
||||
RUN find ./src -type f -name "route.ts" -print0 \
|
||||
| xargs -0 sed -i "s/export const runtime = 'edge';/export const runtime = 'nodejs';/g"
|
||||
ENV DOCKER_ENV=true
|
||||
# 海报走站内 /api/image-proxy(浏览器直连豆瓣图被拦导致全裂)
|
||||
ENV NEXT_PUBLIC_IMAGE_PROXY=/api/image-proxy
|
||||
ENV NEXT_PUBLIC_SITE_VERSION=fixed117
|
||||
ENV NEXT_PUBLIC_ENABLE_REGISTER=true
|
||||
|
||||
# For Docker builds, force dynamic rendering to read runtime environment variables.
|
||||
RUN sed -i "/const inter = Inter({ subsets: \['latin'] });/a export const dynamic = 'force-dynamic';" src/app/layout.tsx
|
||||
@@ -51,7 +55,9 @@ ENV NODE_ENV=production
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV PORT=3000
|
||||
ENV DOCKER_ENV=true
|
||||
ENV NEXT_PUBLIC_SITE_VERSION=fixed73
|
||||
ENV NEXT_PUBLIC_IMAGE_PROXY=/api/image-proxy
|
||||
ENV NEXT_PUBLIC_SITE_VERSION=fixed117
|
||||
ENV NEXT_PUBLIC_ENABLE_REGISTER=true
|
||||
|
||||
# 从构建器中复制 standalone 输出
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
|
||||
@@ -80,6 +80,31 @@
|
||||
- **缓存穿透防护**:chunk 文件按内容 hash 命名,内容变了文件名跟着变,浏览器当新文件拉取,避免陈旧缓存
|
||||
- **Redis 缓存**:支持 Redis/Kvrocks 存储,缓存搜索结果
|
||||
|
||||
### 7. 动漫聚合页
|
||||
|
||||
**页面**:`/anime`
|
||||
|
||||
聚合各资源站全部动漫内容,无需逐站翻找:
|
||||
|
||||
| 功能 | 说明 |
|
||||
|------|------|
|
||||
| 地区切换 | 全部 / 国产 / 日韩 / 欧美 / 港台 / 海外 |
|
||||
| 多源并行 | 一次请求并行抓取多个资源站的 `ac=videaclass t=动漫` |
|
||||
| 归一去重 | 豆瓣式分类(国产剧/港台/韩国/日本/欧美/动漫)统一映射到动漫域,按 `title+年份` 去重 |
|
||||
| 更新排序 | 按 `update_time` 降序,最新更新在前 |
|
||||
| 分页 | `pg/next_pg/has_more`,触底自动加载 |
|
||||
|
||||
顶部菜单与移动端底部导航均有「动漫」入口,路由 `/anime`。
|
||||
|
||||
### 8. 第三方分类浏览(电影/剧集/综艺)
|
||||
|
||||
**页面**:`/douban?type=movie|tv|show` **接口**:`/api/browse`
|
||||
|
||||
- 分类全量使用第三方分类语义:电影 8 类、剧集 7 类、综艺 4 类,地区 7 档
|
||||
- 请求参数 `kind=tv|movie|show|anime` + `cat`(`|` 分隔多选)+ `area` + `pg`
|
||||
- 与 `/api/anime` 共用同一套归一化、去重、`update_time` 排序、分页逻辑
|
||||
- 分类选项集中在 `src/lib/vodcat.ts`,改分类只需改这一处
|
||||
|
||||
## 🚀 快速安装
|
||||
|
||||
### Docker 单容器(最简单)
|
||||
@@ -108,6 +133,85 @@ cp .env.redis.example .env
|
||||
docker compose -f docker-compose.redis.yml up -d
|
||||
```
|
||||
|
||||
### 方式二:Docker Compose部署
|
||||
|
||||
上面「Docker + Redis」用到的 `docker-compose.redis.yml` 完整内容(与仓库文件一致,含全部 ports / volumes / environment):
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# KatelyaTV 应用服务
|
||||
katelyatv:
|
||||
image: ghcr.io/katelya77/katelyatv:latest
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
# 数据库配置 - 使用 Redis
|
||||
NEXT_PUBLIC_STORAGE_TYPE: redis
|
||||
REDIS_URL: redis://katelyatv-redis:6379
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
REDIS_DATABASE: 0
|
||||
|
||||
# 站点访问密码配置
|
||||
PASSWORD: ${PASSWORD:-}
|
||||
|
||||
# 其他必要的环境变量
|
||||
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
|
||||
NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3000}
|
||||
depends_on:
|
||||
- katelyatv-redis
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- katelyatv-network
|
||||
|
||||
# Redis 数据库服务
|
||||
katelyatv-redis:
|
||||
image: redis:7-alpine
|
||||
container_name: katelyatv-redis
|
||||
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
||||
volumes:
|
||||
# 持久化数据存储
|
||||
- katelyatv-redis-data:/data
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- katelyatv-network
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
volumes:
|
||||
# Redis 数据卷
|
||||
katelyatv-redis-data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
katelyatv-network:
|
||||
driver: bridge
|
||||
```
|
||||
|
||||
启动 / 停止:
|
||||
|
||||
```bash
|
||||
# 1. 下载编排文件与环境变量模板
|
||||
curl -O https://gitea.88531.cn/jinghui/katelyatv/raw/branch/main/docker-compose.redis.yml
|
||||
curl -O https://gitea.88531.cn/jinghui/katelyatv/raw/branch/main/.env.redis.example
|
||||
cp .env.redis.example .env
|
||||
# 编辑 .env,设置 PASSWORD、NEXTAUTH_SECRET 等
|
||||
|
||||
# 2. 启动
|
||||
docker compose -f docker-compose.redis.yml up -d
|
||||
|
||||
# 3. 查看状态 / 停止
|
||||
docker compose -f docker-compose.redis.yml ps
|
||||
docker compose -f docker-compose.redis.yml down
|
||||
```
|
||||
|
||||
> 不想用 Compose 时,用上面「方式一:Docker 单容器」的 `docker run` 即可(仅省略 Redis,此时把存储类型设为 `localstorage`)。
|
||||
|
||||
### 环境变量
|
||||
|
||||
| 变量 | 必填 | 说明 |
|
||||
@@ -124,6 +228,7 @@ docker compose -f docker-compose.redis.yml up -d
|
||||
|
||||
## 📋 更新日志
|
||||
|
||||
- **v-fixed96**:新增动漫独立页 `/anime`(多源聚合+地区切换+更新排序+分页)与 `/api/browse` 第三方分类浏览接口;电影/剧集/综艺分类全量切第三方分类;修复动漫页首次进入空列表(`reset` 丢数据)
|
||||
- **v-fixed43**:IPv6 探测改 4443 端口(家宽封 443 导致误判),双端口探测 + 强制使用 IPv6 按钮;恢复右上角按钮断点;chunk 按内容改名防陈旧缓存;源码迁移开始
|
||||
- **v-fixed42**:IPv6 检测改严格模式(cors + 校验 JSON),缓存 2 分钟,新增重新检测按钮
|
||||
- **v-fixed41**:源码迁移,/ipv6 页面 React 化,中间件白名单
|
||||
@@ -137,9 +242,16 @@ docker compose -f docker-compose.redis.yml up -d
|
||||
## 🐳 Docker 镜像
|
||||
|
||||
```bash
|
||||
docker pull gitea.88531.cn/jinghui/katelyatv:latest
|
||||
# 公网可拉(匿名)
|
||||
docker pull gitea.88531.cn/jinghui/katelyatv:latest # 固定版本
|
||||
docker pull gitea.88531.cn/jinghui/katelyatv:fixed96
|
||||
|
||||
# 腾讯云 TCR(东京,公网匿名)
|
||||
docker pull jpccr.ccs.tencentyun.com/jinghui/katelyatv:latest
|
||||
```
|
||||
|
||||
当前版本:**v-fixed96**
|
||||
|
||||
## 🔗 源码
|
||||
|
||||
- Gitea:https://gitea.88531.cn/jinghui/katelyatv
|
||||
|
||||
+16
-16
@@ -1,30 +1,30 @@
|
||||
{
|
||||
"cache_time": 7200,
|
||||
"api_site": {
|
||||
"hnzy": {
|
||||
"api": "https://hnzyapi.com/api.php/provide/vod",
|
||||
"name": "火鸟资源",
|
||||
"wjzy": {
|
||||
"api": "https://api.wujinapi.me/api.php/provide/vod",
|
||||
"name": "无尽资源",
|
||||
"is_adult": false
|
||||
},
|
||||
"lzzy": {
|
||||
"api": "https://api.liangzizy.com/inc/apijson_vod.php",
|
||||
"name": "量子资源",
|
||||
"hhzy": {
|
||||
"api": "https://hhzyapi.com/api.php/provide/vod",
|
||||
"name": "彗星资源",
|
||||
"is_adult": false
|
||||
},
|
||||
"ffzy": {
|
||||
"api": "https://ffzyapi.com/api.php/provide/vod",
|
||||
"name": "非凡资源",
|
||||
"bfzy": {
|
||||
"api": "https://bfzyapi.com/api.php/provide/vod",
|
||||
"name": "暴风资源",
|
||||
"is_adult": false
|
||||
},
|
||||
"ykzy": {
|
||||
"api": "https://api.yongjiuzy.cc/provide/vod",
|
||||
"name": "永久资源",
|
||||
"jyzy": {
|
||||
"api": "https://jyzyapi.com/api.php/provide/vod",
|
||||
"name": "极速资源",
|
||||
"is_adult": false
|
||||
},
|
||||
"bdzy": {
|
||||
"api": "https://api.1080zyku.com/inc/apijson_vod.php",
|
||||
"name": "百度资源",
|
||||
"bz360": {
|
||||
"api": "https://360zy.com/api.php/provide/vod",
|
||||
"name": "360资源",
|
||||
"is_adult": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-5
@@ -29,17 +29,28 @@ const all=await liveEpgAll();
|
||||
const key=EPG_MAP[name]||(all[name]?name:null);
|
||||
if(!key)return{has:false,list:[]};
|
||||
return{has:true,epg_key:key,list:all[key]||[]}}
|
||||
async function liveText(u,ms){const c=new AbortController();const t=setTimeout(()=>c.abort(),ms||15000);
|
||||
try{const r=await fetch(u,{redirect:"follow",signal:c.signal,headers:{"User-Agent":LIVE_UA,"Referer":LIVE_UP+"/"}});return await r.text()}finally{clearTimeout(t)}}
|
||||
async function liveText(u,ms){const timeout=ms||25000;let lastErr=null;
|
||||
for(let attempt=1;attempt<=3;attempt++){
|
||||
const c=new AbortController();const t=setTimeout(()=>c.abort(),timeout);
|
||||
try{const r=await fetch(u,{redirect:"follow",signal:c.signal,headers:{"User-Agent":LIVE_UA,"Referer":LIVE_UP+"/"}});
|
||||
if(!r.ok)throw new Error("http "+r.status);
|
||||
const txt=await r.text();clearTimeout(t);return txt}
|
||||
catch(e){clearTimeout(t);lastErr=e;console.log("[LIVE-FETCH-RETRY]",attempt+"/3",(u||"").slice(0,60),e&&e.message);
|
||||
if(attempt<3)await new Promise(r=>setTimeout(r,800*attempt))}}
|
||||
throw lastErr||new Error("fetch failed")}
|
||||
function liveRegion(n){if(/澳门|澳門|澳[視视]|澳亚|莲花/.test(n))return"澳门";
|
||||
if(/凤凰|TVB|有线|有線|NOW|ViuTV|HOY|港台|香港|明珠|HKS/.test(n))return"香港";
|
||||
if(/中天|东森|東森|中视|中視|台视|台視|三立|非凡|民视|民視|华视|華視|镜电视|鏡電視|寰宇|TVBS|纬来|緯來|ELEVEN|DAZN|爱尔达|愛爾達/.test(n))return"台湾";return"其他"}
|
||||
async function liveChannels(){
|
||||
if(liveCh.list&&Date.now()-liveCh.ts<3600e3)return liveCh.list;
|
||||
try{
|
||||
const h=await liveText(LIVE_UP+"/?tid=gt");const seen=new Set(),list=[];
|
||||
for(const m of h.matchAll(/href="\?act=play&(?:amp;)?tid=gt&(?:amp;)?id=(\d+)"[^>]*>\s*([^<]+?)\s*</g)){
|
||||
if(!seen.has(m[1])){seen.add(m[1]);list.push({id:m[1],name:m[2]})}}
|
||||
if(list.length){list.forEach(function(c){c.region=liveRegion(c.name)});liveCh.list=list;liveCh.ts=Date.now()}return list||[]}
|
||||
if(list.length){list.forEach(function(c){c.region=liveRegion(c.name)});liveCh.list=list;liveCh.ts=Date.now();return list}
|
||||
throw new Error("channels empty")}catch(e){console.log("[LIVE-CH-ERR]",e&&e.message);
|
||||
if(liveCh.list&&liveCh.list.length){console.log("[LIVE-CH-STALE] use stale list n="+liveCh.list.length);return liveCh.list}
|
||||
return[]}}
|
||||
async function liveLines(id){
|
||||
const c=liveLn.get(id);if(c&&Date.now()-c.ts<1800e3)return c.lines;
|
||||
const h=await liveText(LIVE_UP+"/?act=play&tid=gt&id="+encodeURIComponent(id));
|
||||
@@ -152,7 +163,7 @@ select{background:#171b24;color:#e5e7eb;border:1px solid #2a3140;border-radius:6
|
||||
.sec{font-size:13px;color:#6b7280;margin:2px 0 8px}
|
||||
.empty{color:#6b7280;font-size:13px;padding:20px 0;text-align:center}
|
||||
</style></head><body>
|
||||
<div class="hd"><a href="/" >‹</a><h1>电视直播 · 港澳台</h1><span style="flex:1"></span><a class="ghLink" href="https://gitea.88531.cn/jinghui/katelyatv" target="_blank" rel="noopener">⭐ 开源地址</a><button class="tvboxBtn" id="tvboxBtn">📺 TVBOX接入</button>
|
||||
<div class="hd"><a href="/" target="_top" >‹</a><h1>电视直播 · 港澳台</h1><span style="flex:1"></span><a class="ghLink" href="https://gitea.88531.cn/jinghui/katelyatv" target="_blank" rel="noopener">⭐ 开源地址</a><button class="tvboxBtn" id="tvboxBtn">📺 TVBOX接入</button>
|
||||
<div class="tvboxPop" id="tvboxPop">
|
||||
<div class="tvboxPopTitle">TVBox / 影视仓 · 接入直播</div>
|
||||
<div class="tvboxRow"><span class="tvboxLbl">配置地址(含直播,推荐)</span><code id="tbCfg">—</code><button id="tbCfgCopy">复制</button></div>
|
||||
@@ -295,7 +306,7 @@ function loadChs(retry){fetch(API+'channels').then(function(r){return r.json()})
|
||||
grid.appendChild(h);grid.appendChild(box);
|
||||
});
|
||||
var DEF=chs.find(function(c){return c.id==='5'})||chs.find(function(c){return (c.name||'').indexOf('翡翠')>=0})||chs[0];
|
||||
if(DEF){pick(DEF.id,1)}
|
||||
if(DEF){pick(DEF.id,0)}
|
||||
}).catch(function(){if(retry<3){grid.innerHTML='<div class="empty">加载中…</div>';setTimeout(function(){loadChs(retry+1)},3000)}else{grid.innerHTML='<div class="empty">加载失败,请刷新</div>'}})}
|
||||
loadChs(0);
|
||||
</script></body></html>`;
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
if(!self.define){let e,s={};const n=(n,a)=>(n=new URL(n+".js",a).href,s[n]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()}).then(()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(a,i)=>{const c=e||("document"in self?document.currentScript.src:"")||location.href;if(s[c])return;let t={};const o=e=>n(e,c),r={module:{uri:c},exports:t,require:o};s[c]=Promise.all(a.map(e=>r[e]||o(e))).then(e=>(i(...e),t))}}define(["./workbox-e9849328"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"be9d54592fea46176d680a09da2f8b03"},{url:"/_next/static/6pApvoOMGhTBhMnIA6395/_buildManifest.js",revision:"85aecd8a55db42fc901f52386fd2a680"},{url:"/_next/static/6pApvoOMGhTBhMnIA6395/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/151-8711dd3ec7fbfa61.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/234-c7c5e76b3553af41.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/242-5a0502f47346ed4a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/273-fffc7e5390a1c642.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/547-65bdb23e16942a03.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/609-46d66c37b95adf6a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/78-b091442d784a205f.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/866-7f5b3d6941560701.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/_not-found/page-2f2263c5b98c190a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/admin/page-759806afdd5b7523.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/config/page-e7450485f43e42b7.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/douban/page-72adc56cdd9fa67a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/filter/page-4cebc2f48c3257a1.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/ipv6/page-4396f8cd57b55d3b.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/layout-abad67b72f2d607d.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/live/page-83b49175a0a9d775.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/login/page-b2957b92254ae889.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/page-984f6128015dda92.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/play/page-4b74435a3843991f.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/search/page-62b12f466a432302.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/settings/page-137dd16f391763b9.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/tvbox/page-125bca4b61639acb.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/warning/page-e6b20b93b37dc516.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/b145b63a-d75d6adf389a7589.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/c72274ce-909438a8a5dd87a5.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/da9543df-c2ce5269243dd748.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/framework-6e06c675866dc992.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/main-68795df77d27d928.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/main-app-734bbab0f54e7373.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/pages/_app-3fcac1a2c632f1ef.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/pages/_error-d3fe151bf402c134.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-f732225cafd52a05.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/css/083d238e0b356531.css",revision:"083d238e0b356531"},{url:"/_next/static/css/23100062f5d4aac0.css",revision:"23100062f5d4aac0"},{url:"/_next/static/css/da6e9b4a73108890.css",revision:"da6e9b4a73108890"},{url:"/_next/static/media/19cfc7226ec3afaa-s.woff2",revision:"9dda5cfc9a46f256d0e131bb535e46f8"},{url:"/_next/static/media/21350d82a1f187e9-s.woff2",revision:"4e2553027f1d60eff32898367dd4d541"},{url:"/_next/static/media/8e9860b6e62d6359-s.woff2",revision:"01ba6c2a184b8cba08b0d57167664d75"},{url:"/_next/static/media/ba9851c3c22cd980-s.woff2",revision:"9e494903d6b0ffec1a1e14d34427d44d"},{url:"/_next/static/media/c5fe6dc8356a8c31-s.woff2",revision:"027a89e9ab733a145db70f09b8a18b42"},{url:"/_next/static/media/df0a9ae256c0569c-s.woff2",revision:"d54db44de5ccb18886ece2fda72bdfe0"},{url:"/_next/static/media/e4af272ccee01ff0-s.p.woff2",revision:"65850a373e258f1c897a2b3d75eb74de"},{url:"/favicon.ico",revision:"c5deLine truncated
|
||||
if(!self.define){let e,s={};const i=(i,a)=>(i=new URL(i+".js",a).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(a,n)=>{const c=e||("document"in self?document.currentScript.src:"")||location.href;if(s[c])return;let t={};const u=e=>i(e,c),r={module:{uri:c},exports:t,require:u};s[c]=Promise.all(a.map(e=>r[e]||u(e))).then(e=>(n(...e),t))}}define(["./workbox-e9849328"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"25e66d74fe8e173a352f137403fc1b41"},{url:"/_next/static/ZESVig0uAX5meOOL1E-0u/_buildManifest.js",revision:"85aecd8a55db42fc901f52386fd2a680"},{url:"/_next/static/ZESVig0uAX5meOOL1E-0u/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/234-b108db3d3cb1eaf9.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/242-5a0502f47346ed4a.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/273-fffc7e5390a1c642.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/609-46d66c37b95adf6a.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/732-ccd095260c41a876.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/78-b091442d784a205f.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/866-7f5b3d6941560701.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/_not-found/page-2f2263c5b98c190a.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/admin/page-20830ba52baaf531.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/anime/page-da4e609a40d81799.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/config/page-affbe8c5ef4d1058.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/douban/page-031ac55e075e253c.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/filter/page-4b5af6e51fd51bb5.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/ipv6/page-a35328d302bb65d6.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/layout-abad67b72f2d607d.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/live/page-9ed579d82b48211a.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/login/page-b2957b92254ae889.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/page-1635d434ad57af23.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/play/page-d9e8b68743f4288a.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/search/page-ba0b744cf689fe40.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/settings/page-136d93ac82c90f3c.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/tvbox/page-aee2e8c0cbeb259a.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/app/warning/page-e6b20b93b37dc516.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/b145b63a-d75d6adf389a7589.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/c72274ce-909438a8a5dd87a5.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/da9543df-c2ce5269243dd748.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/framework-6e06c675866dc992.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/main-0d408c4099fe4491.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/main-app-734bbab0f54e7373.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/pages/_app-3fcac1a2c632f1ef.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/pages/_error-d3fe151bf402c134.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-f732225cafd52a05.js",revision:"ZESVig0uAX5meOOL1E-0u"},{url:"/_next/static/css/23100062f5d4aac0.css",revision:"23100062f5d4aac0"},{url:"/_next/static/css/3b3ab5132de7694d.css",revision:"3b3ab5132de7694d"},{url:"/_next/static/css/da6e9b4a73108890.css",revision:"da6e9b4a73108890"},{url:"/_next/static/media/19cfc7226ec3afaa-s.woff2",revision:"9dda5cfc9a46f256d0e131bb535e46f8"},{url:"/_next/static/media/21350d82a1f187e9-s.woff2",revision:"4e2553027f1d60eff32898367dd4d541"},{url:"/_next/static/media/8e9860b6e62d6359-s.woff2",revision:"01ba6c2a184b8cba08b0d57167664d75"},{url:"/_next/static/media/ba9851c3c22cd980-s.woff2",revision:"9e494903d6b0ffec1a1e14d34427d44d"},{url:"/_next/static/media/c5fe6dc8356a8c31-s.woff2",revision:"027a89e9ab733a145db70f09b8a18b42"},{url:"/_next/static/media/df0a9ae256c0569c-s.woff2",revision:"d54db44de5ccb18886ece2fda72bdfe0"},{url:"/_next/static/media/e4af272ccee01ff0-s.p.woff2",revision:"65850a373e258f1c897a2b3d75eb74de"},{url:"/favicon.ico",revLine truncated
|
||||
@@ -470,6 +470,18 @@ const UserConfig = ({ config, role, refreshConfig }: UserConfigProps) => {
|
||||
>
|
||||
状态
|
||||
</th>
|
||||
<th
|
||||
scope='col'
|
||||
className='px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider'
|
||||
>
|
||||
注册时间
|
||||
</th>
|
||||
<th
|
||||
scope='col'
|
||||
className='px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider'
|
||||
>
|
||||
最后登录
|
||||
</th>
|
||||
<th
|
||||
scope='col'
|
||||
className='px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider'
|
||||
@@ -548,6 +560,16 @@ const UserConfig = ({ config, role, refreshConfig }: UserConfigProps) => {
|
||||
{!user.banned ? '正常' : '已封禁'}
|
||||
</span>
|
||||
</td>
|
||||
<td className='px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400'>
|
||||
{user.created_at
|
||||
? `${new Date(user.created_at).toLocaleString('zh-CN', { hour12: false })}${user.created_at_estimated ? '*' : ''}`
|
||||
: '-'}
|
||||
</td>
|
||||
<td className='px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400'>
|
||||
{user.last_login_at
|
||||
? `${new Date(user.last_login_at).toLocaleString('zh-CN', { hour12: false })}${user.last_login_estimated ? '*' : ''}`
|
||||
: '-'}
|
||||
</td>
|
||||
<td className='px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2'>
|
||||
{/* 修改密码按钮 */}
|
||||
{canChangePassword && (
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
'use client';
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { Suspense, useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import PageLayout from '@/components/PageLayout';
|
||||
import VideoCard from '@/components/VideoCard';
|
||||
|
||||
// ---------- /anime 动漫频道(数据来自第三方采集站全量动漫分类) ----------
|
||||
// 后端:src/app/api/anime/route.ts -> { list:[...], next_pg, has_more }
|
||||
|
||||
type Item = {
|
||||
id: string;
|
||||
title: string;
|
||||
poster: string;
|
||||
episodes: number;
|
||||
source: string;
|
||||
source_name: string;
|
||||
year: string;
|
||||
area: string;
|
||||
type_name: string;
|
||||
douban_id?: number | string;
|
||||
};
|
||||
|
||||
const REGION_OPTS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '国产', value: '国产' },
|
||||
{ label: '日韩', value: '日韩' },
|
||||
{ label: '欧美', value: '欧美' },
|
||||
{ label: '港台', value: '港台' },
|
||||
{ label: '海外', value: '海外' },
|
||||
];
|
||||
|
||||
function AnimeClient() {
|
||||
const searchParams = useSearchParams();
|
||||
const [region, setRegion] = useState(() => searchParams.get('region') || '');
|
||||
const [items, setItems] = useState<Item[]>([]);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const [nextPg, setNextPg] = useState(1);
|
||||
const [hasMore, setHasMore] = useState(true);
|
||||
const [err, setErr] = useState('');
|
||||
const reqId = useRef(0);
|
||||
|
||||
const load = useCallback(
|
||||
async (pg: number, reset: boolean) => {
|
||||
const id = ++reqId.current;
|
||||
if (reset) {
|
||||
setRefreshing(true);
|
||||
setErr('');
|
||||
}
|
||||
try {
|
||||
const q = new URLSearchParams({ pg: String(pg) });
|
||||
if (region) q.set('region', region);
|
||||
const r = await fetch('/api/anime?' + q.toString());
|
||||
const j = await r.json();
|
||||
if (id !== reqId.current) return;
|
||||
if (j?.error) {
|
||||
setErr(j.error);
|
||||
return;
|
||||
}
|
||||
const arr: Item[] = Array.isArray(j?.list) ? j.list : [];
|
||||
setItems((prev) => {
|
||||
const base = reset ? [...arr] : [...prev, ...arr];
|
||||
const seen = new Set<string>();
|
||||
return base.filter((x) => {
|
||||
const k = x.title + '|' + x.year;
|
||||
if (seen.has(k)) return false;
|
||||
seen.add(k);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
setNextPg(j?.next_pg || pg + 1);
|
||||
setHasMore(!!j?.has_more && arr.length > 0);
|
||||
} catch {
|
||||
if (id === reqId.current) setErr('加载失败,请稍后重试');
|
||||
} finally {
|
||||
if (id === reqId.current) setRefreshing(false);
|
||||
}
|
||||
},
|
||||
[region]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setItems([]);
|
||||
setNextPg(1);
|
||||
setHasMore(true);
|
||||
load(1, true);
|
||||
}, [region]);
|
||||
|
||||
const goPage = (pg: number) => {
|
||||
if (pg < 1) return;
|
||||
setItems([]);
|
||||
setNextPg(pg);
|
||||
load(pg, true);
|
||||
};
|
||||
|
||||
return (
|
||||
<PageLayout activePath='/anime'>
|
||||
<div className='px-4 sm:px-8 lg:px-12 py-4 sm:py-8'>
|
||||
<h1 className='text-xl font-bold text-gray-800 dark:text-gray-200 mb-1'>动漫</h1>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 mb-4'>
|
||||
聚合各资源站全部动漫内容(国产 / 日韩 / 欧美 / 港台)
|
||||
</p>
|
||||
|
||||
<div className='flex flex-col sm:flex-row sm:items-center gap-2 mb-6'>
|
||||
<span className='text-xs sm:text-sm font-medium text-gray-600 dark:text-gray-400 min-w-[48px]'>
|
||||
地区
|
||||
</span>
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
{REGION_OPTS.map((o) => {
|
||||
const on = region === o.value;
|
||||
return (
|
||||
<button
|
||||
key={o.value || 'all'}
|
||||
onClick={() => setRegion(o.value)}
|
||||
className={
|
||||
'px-3 py-1.5 text-xs sm:text-sm font-medium rounded-full transition-all duration-200 whitespace-nowrap ' +
|
||||
(on
|
||||
? 'bg-purple-500 text-white shadow-sm'
|
||||
: 'bg-gray-200/60 text-gray-700 hover:bg-gray-300/60 dark:bg-gray-700/60 dark:text-gray-300 dark:hover:bg-gray-600/60')
|
||||
}
|
||||
>
|
||||
{o.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{err ? <div className='text-sm text-red-500 mb-4'>{err}</div> : null}
|
||||
{refreshing && items.length === 0 ? (
|
||||
<div className='text-sm text-gray-500 dark:text-gray-400'>加载中…</div>
|
||||
) : items.length === 0 ? (
|
||||
<div className='text-sm text-gray-500 dark:text-gray-400'>
|
||||
暂无动漫内容,试试切换地区
|
||||
</div>
|
||||
) : (
|
||||
<div className='grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4'>
|
||||
{items.map((v) => (
|
||||
<VideoCard
|
||||
key={v.source + ':' + v.id}
|
||||
id={v.id}
|
||||
source={v.source}
|
||||
source_name={v.source_name}
|
||||
title={v.title}
|
||||
poster={v.poster}
|
||||
episodes={v.episodes}
|
||||
year={v.year}
|
||||
douban_id={v.douban_id ? String(v.douban_id) : ''}
|
||||
from='search'
|
||||
type={v.episodes > 1 ? 'tv' : 'movie'}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='py-6 flex items-center justify-center gap-3 text-sm'>
|
||||
<button
|
||||
onClick={() => goPage(nextPg - 2)}
|
||||
disabled={nextPg <= 2}
|
||||
className='px-3 py-1.5 rounded bg-gray-200/60 dark:bg-gray-700/60 disabled:opacity-40'
|
||||
>
|
||||
上一页
|
||||
</button>
|
||||
<span className='text-gray-500 dark:text-gray-400'>第 {Math.max(1, nextPg - 1)} 页</span>
|
||||
<button
|
||||
onClick={() => goPage(nextPg)}
|
||||
disabled={!hasMore}
|
||||
className='px-3 py-1.5 rounded bg-gray-200/60 dark:bg-gray-700/60 disabled:opacity-40'
|
||||
>
|
||||
下一页
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
export default function AnimePage() {
|
||||
return (
|
||||
<Suspense>
|
||||
<AnimeClient />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -132,11 +132,13 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
await storage.registerUser(targetUsername!, targetPassword);
|
||||
// 更新配置
|
||||
// 更新配置(带注册时间,避免列表显示空白)
|
||||
adminConfig.UserConfig.Users.push({
|
||||
username: targetUsername!,
|
||||
role: 'user',
|
||||
});
|
||||
created_at: new Date().toISOString(),
|
||||
created_at_estimated: false,
|
||||
} as any);
|
||||
targetEntry =
|
||||
adminConfig.UserConfig.Users[
|
||||
adminConfig.UserConfig.Users.length - 1
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { getAvailableApiSites, getCacheTime } from '@/lib/config';
|
||||
import { fetchSiteKind, mapItem, Site } from '@/lib/vodcat';
|
||||
|
||||
// ---------- /api/anime 动漫聚合接口(源码化) ----------
|
||||
// 数据来源:各第三方采集站(maccms 10 协议),非豆瓣精选
|
||||
// 逻辑:按「动漫/动画/卡通」分类名跨站筛分类 -> 逐类取分页 -> 合并去重(全量)
|
||||
// 参数:region('' | 国产 | 日韩 | 欧美 | 港台 | 海外)、pg
|
||||
|
||||
const EXCLUDE_SITES = new Set(['xiaojizy', '155api']);
|
||||
|
||||
// 地区 -> 各站分类名里的关键词(国产动漫 / 中国动漫 / 国产动漫…)
|
||||
const REGION_MAP: Record<string, string> = {
|
||||
国产: '国产',
|
||||
日韩: '日韩',
|
||||
欧美: '欧美',
|
||||
港台: '港台',
|
||||
海外: '海外',
|
||||
};
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const region = searchParams.get('region') || '';
|
||||
const pg = Math.max(1, parseInt(searchParams.get('pg') || '1', 10));
|
||||
try {
|
||||
const all = await getAvailableApiSites(true);
|
||||
const sites = all.filter(
|
||||
(s) => !EXCLUDE_SITES.has(s.key) && !String(s.name || '').startsWith('AV-')
|
||||
) as unknown as Site[];
|
||||
const cacheTime = await getCacheTime();
|
||||
const cat = REGION_MAP[region] || '';
|
||||
|
||||
const settled = await Promise.all(
|
||||
sites.map(async (s) => {
|
||||
try {
|
||||
return await fetchSiteKind(s, 'anime', cat, pg);
|
||||
} catch {
|
||||
return { items: [] as any[], hasMore: false };
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const seen = new Set<string>();
|
||||
const list: any[] = [];
|
||||
let hasMore = false;
|
||||
settled.forEach((r, i) => {
|
||||
if (r.hasMore) hasMore = true;
|
||||
const site = sites[i];
|
||||
r.items.forEach((it) => {
|
||||
const m = mapItem(it, site);
|
||||
if (!m.title) return;
|
||||
const k = `${m.title}|${m.year}`;
|
||||
if (seen.has(k)) return;
|
||||
seen.add(k);
|
||||
list.push(m);
|
||||
});
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{ source: 'all', region, pg, list, next_pg: pg + 1, has_more: hasMore },
|
||||
{
|
||||
headers: {
|
||||
'Cache-Control': `public, max-age=${Math.min(cacheTime, 300)}, s-maxage=${Math.min(cacheTime, 300)}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (e: any) {
|
||||
return NextResponse.json(
|
||||
{ error: '动漫聚合请求失败', details: e?.message || String(e) },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function OPTIONS() {
|
||||
return new NextResponse(null, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
||||
'Access-Control-Allow-Headers': 'Content-Type',
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { getAvailableApiSites, getCacheTime } from '@/lib/config';
|
||||
import { fetchSiteKind, mapItem, Site } from '@/lib/vodcat';
|
||||
|
||||
// ---------- /api/browse 第三方分类聚合接口(源码化) ----------
|
||||
// 数据来源:各第三方采集站(maccms 10 协议),按分类名跨站聚合,全部数据而非精选
|
||||
// 参数:kind=tv|show|movie|anime(剧集/综艺/电影/动漫)、cat=细分分类名(可空)、pg=页码
|
||||
|
||||
const EXCLUDE_SITES = new Set(['xiaojizy', '155api']);
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const kind = (searchParams.get('kind') || 'tv') as string;
|
||||
const cat = searchParams.get('cat') || '';
|
||||
const area = searchParams.get('area') || '';
|
||||
const pg = Math.max(1, parseInt(searchParams.get('pg') || '1', 10));
|
||||
|
||||
try {
|
||||
const all = await getAvailableApiSites(true);
|
||||
const sites = all.filter(
|
||||
(s) => !EXCLUDE_SITES.has(s.key) && !String(s.name || '').startsWith('AV-')
|
||||
) as unknown as Site[];
|
||||
const cacheTime = await getCacheTime();
|
||||
|
||||
const settled = await Promise.all(
|
||||
sites.map(async (s) => {
|
||||
try {
|
||||
return await fetchSiteKind(s, kind, cat, pg);
|
||||
} catch {
|
||||
return { items: [] as any[], hasMore: false };
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// area 支持多选('中国|大陆|香港'),命中任一即保留
|
||||
const areaKeys = area ? area.split('|').filter(Boolean) : [];
|
||||
const seen = new Set<string>();
|
||||
const list: any[] = [];
|
||||
let hasMore = false;
|
||||
settled.forEach((r, i) => {
|
||||
if (r.hasMore) hasMore = true;
|
||||
const site = sites[i];
|
||||
r.items.forEach((it) => {
|
||||
const m = mapItem(it, site);
|
||||
if (!m.title) return;
|
||||
if (areaKeys.length) {
|
||||
const ar = m.area || '';
|
||||
if (!ar || !areaKeys.some((k) => ar.includes(k))) return;
|
||||
}
|
||||
const k = `${m.title}|${m.year}`;
|
||||
if (seen.has(k)) return;
|
||||
seen.add(k);
|
||||
list.push(m);
|
||||
});
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{ kind, cat, area, pg, list, next_pg: pg + 1, has_more: hasMore },
|
||||
{
|
||||
headers: {
|
||||
'Cache-Control': `public, max-age=${Math.min(cacheTime, 300)}, s-maxage=${Math.min(cacheTime, 300)}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (e: any) {
|
||||
return NextResponse.json(
|
||||
{ error: '分类聚合请求失败', details: e?.message || String(e) },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function OPTIONS() {
|
||||
return new NextResponse(null, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
||||
'Access-Control-Allow-Headers': 'Content-Type',
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
interface DoubanComment {
|
||||
id: string;
|
||||
user: string;
|
||||
avatar: string;
|
||||
rating: number;
|
||||
content: string;
|
||||
time: string;
|
||||
location: string;
|
||||
}
|
||||
|
||||
// 从豆瓣 rexxar 移动 API 获取短评(热门优先)
|
||||
export async function GET(req: NextRequest) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const id = (searchParams.get('id') || '').trim();
|
||||
const sort = (searchParams.get('sort') || 'hot').trim(); // hot | new
|
||||
const count = Math.min(parseInt(searchParams.get('count') || '10') || 10, 20);
|
||||
if (!id) return NextResponse.json({ code: 0, msg: '缺少豆瓣ID', list: [] });
|
||||
|
||||
const order = sort === 'new' ? 'time' : 'hot';
|
||||
const url = `https://m.douban.com/rexxar/api/v2/movie/${id}/interests?count=${count}&order_by=${order}&status=done`;
|
||||
|
||||
try {
|
||||
const r = await fetch(url, {
|
||||
headers: {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1',
|
||||
Referer: `https://m.douban.com/movie/subject/${id}/`,
|
||||
Accept: 'application/json',
|
||||
},
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
||||
const d: any = await r.json();
|
||||
const list: DoubanComment[] = (Array.isArray(d?.interests) ? d.interests : [])
|
||||
.map((x: any) => ({
|
||||
id: String(x?.id || ''),
|
||||
user: String(x?.user?.name || ''),
|
||||
avatar: String(x?.user?.avatar || ''),
|
||||
rating: Number(x?.rating?.value || 0),
|
||||
content: String(x?.comment || '').trim(),
|
||||
time: String(x?.create_time || ''),
|
||||
location: String(x?.ip_location || ''),
|
||||
}))
|
||||
.filter((c: DoubanComment) => c.content.length > 0);
|
||||
|
||||
return NextResponse.json({ code: 1, msg: 'ok', total: d?.total || list.length, list });
|
||||
} catch (e: any) {
|
||||
return NextResponse.json({ code: 0, msg: e?.message || 'fetch fail', list: [] });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
// 从豆瓣 rexxar 获取条目详情(评分/演员/导演等)
|
||||
export async function GET(req: NextRequest) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const id = (searchParams.get('id') || '').trim();
|
||||
if (!id) return NextResponse.json({ code: 0, msg: '缺少豆瓣ID' });
|
||||
|
||||
const ua =
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1';
|
||||
|
||||
for (const kind of ['movie', 'tv']) {
|
||||
try {
|
||||
const r = await fetch(`https://m.douban.com/rexxar/api/v2/${kind}/${id}`, {
|
||||
headers: { 'User-Agent': ua, Referer: `https://m.douban.com/${kind}/subject/${id}/`, Accept: 'application/json' },
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!r.ok) continue;
|
||||
const d: any = await r.json();
|
||||
if (!d || !d.id) continue;
|
||||
const actors = (Array.isArray(d.actors) ? d.actors : [])
|
||||
.map((a: any) => a?.name || a?.title)
|
||||
.filter(Boolean);
|
||||
const directors = (Array.isArray(d.directors) ? d.directors : [])
|
||||
.map((a: any) => a?.name || a?.title)
|
||||
.filter(Boolean);
|
||||
return NextResponse.json({
|
||||
code: 1,
|
||||
msg: 'ok',
|
||||
title: d.title || '',
|
||||
rating: Number(d?.rating?.value || 0),
|
||||
ratingCount: Number(d?.rating?.count || 0),
|
||||
actors,
|
||||
directors,
|
||||
area: Array.isArray(d.regions) ? d.regions.join(' / ') : d.regions || '',
|
||||
year: d.year || '',
|
||||
duration: Array.isArray(d.durations) ? d.durations.join(' / ') : d.durations || '',
|
||||
languages: Array.isArray(d.languages) ? d.languages.join(' / ') : d.languages || '',
|
||||
intro: d.intro || '',
|
||||
});
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return NextResponse.json({ code: 0, msg: '未找到', rating: 0, actors: [], directors: [] });
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const id = (searchParams.get('id') || '').trim();
|
||||
const type = (searchParams.get('type') || 'movie').trim();
|
||||
if (!id) return NextResponse.json({ code: 0, msg: '缺少豆瓣ID' });
|
||||
|
||||
const ua =
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1';
|
||||
const kind = type === 'tv' ? 'tv' : 'movie';
|
||||
|
||||
try {
|
||||
const r = await fetch(
|
||||
`https://m.douban.com/rexxar/api/v2/${kind}/${id}/recommendations?count=10&start=0`,
|
||||
{
|
||||
headers: { 'User-Agent': ua, Referer: `https://m.douban.com/${kind}/subject/${id}/`, Accept: 'application/json' },
|
||||
signal: AbortSignal.timeout(15000),
|
||||
}
|
||||
);
|
||||
if (!r.ok) return NextResponse.json({ code: 0, msg: '请求失败' });
|
||||
const arr: any = await r.json();
|
||||
if (!Array.isArray(arr)) return NextResponse.json({ code: 0, msg: '无数据' });
|
||||
const list = arr.slice(0, 10).map((x: any) => ({
|
||||
id: String(x.id || ''),
|
||||
title: x.title || '',
|
||||
poster: x?.pic?.large || x?.pic?.normal || '',
|
||||
rating: Number(x?.rating?.value || 0),
|
||||
subtitle: x.card_subtitle || '',
|
||||
url: x.url || '',
|
||||
}));
|
||||
return NextResponse.json({ code: 1, msg: 'ok', list });
|
||||
} catch (e: any) {
|
||||
return NextResponse.json({ code: 0, msg: e?.message || 'error' });
|
||||
}
|
||||
}
|
||||
@@ -97,11 +97,13 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
await db.registerUser(username, password);
|
||||
|
||||
// 添加到配置中并保存
|
||||
// 添加到配置中并保存(带注册时间,避免列表显示空白)
|
||||
config.UserConfig.Users.push({
|
||||
username,
|
||||
role: 'user',
|
||||
});
|
||||
created_at: new Date().toISOString(),
|
||||
created_at_estimated: false,
|
||||
} as any);
|
||||
await db.saveAdminConfig(config);
|
||||
|
||||
// 注册成功,设置认证cookie
|
||||
|
||||
@@ -152,10 +152,21 @@ async function aggregateAll(sources: SrcCfg[], sp: URLSearchParams) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// 进程内响应缓存:相同查询 60s 内直接返回,避免每次刷新都重新聚合上游(最新港剧等栏目秒开)
|
||||
const respCache = new Map<string, [number, any]>();
|
||||
export async function GET(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const cacheKey = searchParams.toString();
|
||||
const now = Date.now();
|
||||
const c = respCache.get(cacheKey);
|
||||
if (c && now - c[0] < 60000) {
|
||||
return NextResponse.json(c[1], { headers: { 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'public, max-age=60', 'X-Cache': 'HIT' } });
|
||||
}
|
||||
const config = await getConfig();
|
||||
const sourceConfigs: SrcCfg[] = (config.SourceConfig || []).filter((s: any) => !s.disabled);
|
||||
const r = await aggregateAll(sourceConfigs, searchParams);
|
||||
respCache.set(cacheKey, [now, r]);
|
||||
// 防止缓存无限增长:超过 200 条清空
|
||||
if (respCache.size > 200) respCache.clear();
|
||||
return NextResponse.json(r, { headers: { 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'public, max-age=60' } });
|
||||
}
|
||||
@@ -8,6 +8,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
export default function ConfigPage() {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [copiedLive, setCopiedLive] = useState(false);
|
||||
const [format, setFormat] = useState<'json' | 'base64'>('json');
|
||||
|
||||
const getConfigUrl = useCallback(() => {
|
||||
@@ -16,6 +17,12 @@ export default function ConfigPage() {
|
||||
return `${baseUrl}/api/tvbox?format=${format}`;
|
||||
}, [format]);
|
||||
|
||||
const getLiveUrl = useCallback(() => {
|
||||
if (typeof window === 'undefined') return '';
|
||||
const baseUrl = window.location.origin;
|
||||
return `${baseUrl}/api/tvbox?live=txt`;
|
||||
}, []);
|
||||
|
||||
const handleCopy = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(getConfigUrl());
|
||||
@@ -26,6 +33,16 @@ export default function ConfigPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopyLive = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(getLiveUrl());
|
||||
setCopiedLive(true);
|
||||
setTimeout(() => setCopiedLive(false), 2000);
|
||||
} catch {
|
||||
// Copy failed silently
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<TopRightButtons variant='float' />
|
||||
@@ -72,6 +89,31 @@ export default function ConfigPage() {
|
||||
{copied ? '已复制' : '复制'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h2 className="text-xl font-semibold mt-6 mb-2 text-gray-900 dark:text-white">
|
||||
直播源地址
|
||||
</h2>
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 mb-4">
|
||||
仅含电视直播,可单独填入 TVBox 直播源(TXT 格式)。
|
||||
</p>
|
||||
<div className="flex items-center space-x-2">
|
||||
<input
|
||||
type="text"
|
||||
readOnly
|
||||
value={getLiveUrl()}
|
||||
className="flex-1 p-3 border border-gray-300 dark:border-gray-600 rounded-md bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white font-mono text-sm"
|
||||
/>
|
||||
<button
|
||||
onClick={handleCopyLive}
|
||||
className={`px-4 py-3 rounded-md font-medium transition-colors ${
|
||||
copiedLive
|
||||
? 'bg-green-500 text-white'
|
||||
: 'bg-blue-500 hover:bg-blue-600 text-white'
|
||||
}`}
|
||||
>
|
||||
{copiedLive ? '已复制' : '复制'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 mb-6">
|
||||
|
||||
+101
-74
@@ -6,17 +6,26 @@ import { useSearchParams } from 'next/navigation';
|
||||
import { Suspense } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { getDoubanCategories } from '@/lib/douban.client';
|
||||
import { DoubanItem } from '@/lib/types';
|
||||
|
||||
import DoubanCardSkeleton from '@/components/DoubanCardSkeleton';
|
||||
import DoubanSelector from '@/components/DoubanSelector';
|
||||
import PageLayout from '@/components/PageLayout';
|
||||
import VideoCard from '@/components/VideoCard';
|
||||
|
||||
// 第三方采集站聚合条目(/api/browse 返回)
|
||||
type BrowseItem = {
|
||||
id: string;
|
||||
title: string;
|
||||
poster: string;
|
||||
year: string;
|
||||
area: string;
|
||||
episodes: number;
|
||||
source: string;
|
||||
source_name: string;
|
||||
};
|
||||
|
||||
function DoubanPageClient() {
|
||||
const searchParams = useSearchParams();
|
||||
const [doubanData, setDoubanData] = useState<DoubanItem[]>([]);
|
||||
const [browseData, setBrowseData] = useState<BrowseItem[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [currentPage, setCurrentPage] = useState(0);
|
||||
const [hasMore, setHasMore] = useState(true);
|
||||
@@ -27,12 +36,14 @@ function DoubanPageClient() {
|
||||
const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
const type = searchParams.get('type') || 'movie';
|
||||
const catParam = searchParams.get('cat') || '';
|
||||
|
||||
// 选择器状态 - 完全独立,不依赖URL参数
|
||||
const [primarySelection, setPrimarySelection] = useState<string>(() => {
|
||||
return type === 'movie' ? '热门' : '';
|
||||
return type === 'movie' ? '全部' : '';
|
||||
});
|
||||
const [secondarySelection, setSecondarySelection] = useState<string>(() => {
|
||||
if (catParam) return catParam;
|
||||
if (type === 'movie') return '全部';
|
||||
if (type === 'tv') return 'tv';
|
||||
if (type === 'show') return 'show';
|
||||
@@ -41,29 +52,27 @@ function DoubanPageClient() {
|
||||
|
||||
// 初始化时标记选择器为准备好状态
|
||||
useEffect(() => {
|
||||
// 短暂延迟确保初始状态设置完成
|
||||
const timer = setTimeout(() => {
|
||||
setSelectorsReady(true);
|
||||
}, 50);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, []); // 只在组件挂载时执行一次
|
||||
}, []);
|
||||
|
||||
// type变化时立即重置selectorsReady(最高优先级)
|
||||
useEffect(() => {
|
||||
setSelectorsReady(false);
|
||||
setLoading(true); // 立即显示loading状态
|
||||
}, [type]);
|
||||
}, [type, catParam]);
|
||||
|
||||
// 当type变化时重置选择器状态
|
||||
useEffect(() => {
|
||||
// 批量更新选择器状态
|
||||
if (type === 'movie') {
|
||||
setPrimarySelection('热门');
|
||||
setSecondarySelection('全部');
|
||||
setPrimarySelection('全部');
|
||||
setSecondarySelection(catParam || '全部');
|
||||
} else if (type === 'tv') {
|
||||
setPrimarySelection('');
|
||||
setSecondarySelection('tv');
|
||||
setSecondarySelection(catParam || 'tv');
|
||||
} else if (type === 'show') {
|
||||
setPrimarySelection('');
|
||||
setSecondarySelection('show');
|
||||
@@ -72,75 +81,100 @@ function DoubanPageClient() {
|
||||
setSecondarySelection('全部');
|
||||
}
|
||||
|
||||
// 使用短暂延迟确保状态更新完成后标记选择器准备好
|
||||
const timer = setTimeout(() => {
|
||||
setSelectorsReady(true);
|
||||
}, 50);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [type]);
|
||||
}, [type, catParam]);
|
||||
|
||||
// 生成骨架屏数据
|
||||
const skeletonData = Array.from({ length: 25 }, (_, index) => index);
|
||||
|
||||
// 生成API请求参数的辅助函数
|
||||
const getRequestParams = useCallback(
|
||||
(pageStart: number) => {
|
||||
// 当type为tv或show时,kind统一为'tv',category使用type本身
|
||||
if (type === 'tv' || type === 'show') {
|
||||
return {
|
||||
kind: 'tv' as const,
|
||||
category: type,
|
||||
type: secondarySelection,
|
||||
pageLimit: 25,
|
||||
pageStart,
|
||||
};
|
||||
}
|
||||
|
||||
// 电影类型保持原逻辑
|
||||
// 选择器 -> 第三方聚合接口参数映射
|
||||
const getBrowseParams = useCallback((): { kind: string; cat: string; area: string } => {
|
||||
if (type === 'movie') {
|
||||
// 二级为地区,映射到 vod_area 关键词
|
||||
const areaMap: Record<string, string> = {
|
||||
全部: '',
|
||||
华语: '中国|大陆|香港|台湾|澳门',
|
||||
欧美: '美国|英国|法国|德国|加拿大|西班牙|意大利|荷兰|俄罗斯',
|
||||
韩国: '韩国',
|
||||
日本: '日本',
|
||||
泰国: '泰国',
|
||||
};
|
||||
return {
|
||||
kind: type as 'tv' | 'movie',
|
||||
category: primarySelection,
|
||||
type: secondarySelection,
|
||||
pageLimit: 25,
|
||||
pageStart,
|
||||
kind: 'movie',
|
||||
cat: primarySelection === '全部' || primarySelection === '热门' ? '' : primarySelection,
|
||||
area: areaMap[secondarySelection] ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 'tv') {
|
||||
// 二级为剧集地区/类型
|
||||
const tvMap: Record<string, { kind: string; cat: string }> = {
|
||||
tv: { kind: 'tv', cat: '' },
|
||||
tv_domestic: { kind: 'tv', cat: '国产剧' },
|
||||
tv_american: { kind: 'tv', cat: '欧美剧' },
|
||||
tv_japanese: { kind: 'tv', cat: '日本剧' },
|
||||
tv_korean: { kind: 'tv', cat: '韩国剧' },
|
||||
tv_animation: { kind: 'anime', cat: '' },
|
||||
tv_documentary: { kind: 'tv', cat: '纪录' },
|
||||
};
|
||||
const m = tvMap[secondarySelection] || { kind: 'tv', cat: '' };
|
||||
return { kind: m.kind, cat: m.cat, area: '' };
|
||||
}
|
||||
|
||||
// 综艺
|
||||
const showMap: Record<string, string> = {
|
||||
show: '',
|
||||
show_domestic: '大陆|国内|港台',
|
||||
show_foreign: '日韩|欧美|海外|国外',
|
||||
};
|
||||
return { kind: 'show', cat: showMap[secondarySelection] ?? '', area: '' };
|
||||
}, [type, primarySelection, secondarySelection]);
|
||||
|
||||
const fetchPage = useCallback(
|
||||
async (pg: number) => {
|
||||
const { kind, cat, area } = getBrowseParams();
|
||||
const params = new URLSearchParams({ kind, pg: String(pg) });
|
||||
if (cat) params.set('cat', cat);
|
||||
if (area) params.set('area', area);
|
||||
const res = await fetch(`/api/browse?${params.toString()}`);
|
||||
if (!res.ok) throw new Error(`浏览接口请求失败: ${res.status}`);
|
||||
return (await res.json()) as {
|
||||
list: BrowseItem[];
|
||||
has_more: boolean;
|
||||
};
|
||||
},
|
||||
[type, primarySelection, secondarySelection]
|
||||
[getBrowseParams]
|
||||
);
|
||||
|
||||
// 防抖的数据加载函数
|
||||
const loadInitialData = useCallback(async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await getDoubanCategories(getRequestParams(0));
|
||||
|
||||
if (data.code === 200) {
|
||||
setDoubanData(data.list);
|
||||
setHasMore(data.list.length === 25);
|
||||
setLoading(false);
|
||||
} else {
|
||||
throw new Error(data.message || '获取数据失败');
|
||||
}
|
||||
const data = await fetchPage(1);
|
||||
setBrowseData(data.list);
|
||||
setHasMore(data.has_more && data.list.length > 0);
|
||||
setLoading(false);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
setLoading(false);
|
||||
}
|
||||
}, [type, primarySelection, secondarySelection, getRequestParams]);
|
||||
}, [fetchPage]);
|
||||
|
||||
// 只在选择器准备好后才加载数据
|
||||
useEffect(() => {
|
||||
// 只有在选择器准备好时才开始加载
|
||||
if (!selectorsReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 重置页面状态
|
||||
setDoubanData([]);
|
||||
setBrowseData([]);
|
||||
setCurrentPage(0);
|
||||
setHasMore(true);
|
||||
setIsLoadingMore(false);
|
||||
|
||||
// 清除之前的防抖定时器
|
||||
if (debounceTimeoutRef.current) {
|
||||
clearTimeout(debounceTimeoutRef.current);
|
||||
}
|
||||
@@ -148,9 +182,8 @@ function DoubanPageClient() {
|
||||
// 使用防抖机制加载数据,避免连续状态更新触发多次请求
|
||||
debounceTimeoutRef.current = setTimeout(() => {
|
||||
loadInitialData();
|
||||
}, 100); // 100ms 防抖延迟
|
||||
}, 100);
|
||||
|
||||
// 清理函数
|
||||
return () => {
|
||||
if (debounceTimeoutRef.current) {
|
||||
clearTimeout(debounceTimeoutRef.current);
|
||||
@@ -171,16 +204,9 @@ function DoubanPageClient() {
|
||||
try {
|
||||
setIsLoadingMore(true);
|
||||
|
||||
const data = await getDoubanCategories(
|
||||
getRequestParams(currentPage * 25)
|
||||
);
|
||||
|
||||
if (data.code === 200) {
|
||||
setDoubanData((prev) => [...prev, ...data.list]);
|
||||
setHasMore(data.list.length === 25);
|
||||
} else {
|
||||
throw new Error(data.message || '获取数据失败');
|
||||
}
|
||||
const data = await fetchPage(currentPage + 1);
|
||||
setBrowseData((prev) => [...prev, ...data.list]);
|
||||
setHasMore(data.has_more && data.list.length > 0);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
@@ -194,12 +220,10 @@ function DoubanPageClient() {
|
||||
|
||||
// 设置滚动监听
|
||||
useEffect(() => {
|
||||
// 如果没有更多数据或正在加载,则不设置监听
|
||||
if (!hasMore || isLoadingMore || loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 确保 loadingRef 存在
|
||||
if (!loadingRef.current) {
|
||||
return;
|
||||
}
|
||||
@@ -226,7 +250,6 @@ function DoubanPageClient() {
|
||||
// 处理选择器变化
|
||||
const handlePrimaryChange = useCallback(
|
||||
(value: string) => {
|
||||
// 只有当值真正改变时才设置loading状态
|
||||
if (value !== primarySelection) {
|
||||
setLoading(true);
|
||||
setPrimarySelection(value);
|
||||
@@ -237,7 +260,6 @@ function DoubanPageClient() {
|
||||
|
||||
const handleSecondaryChange = useCallback(
|
||||
(value: string) => {
|
||||
// 只有当值真正改变时才设置loading状态
|
||||
if (value !== secondarySelection) {
|
||||
setLoading(true);
|
||||
setSecondarySelection(value);
|
||||
@@ -247,7 +269,7 @@ function DoubanPageClient() {
|
||||
);
|
||||
|
||||
const getPageTitle = () => {
|
||||
// 根据 type 生成标题
|
||||
if (type === 'tv' && catParam === 'tv_animation') return '动漫';
|
||||
return type === 'movie' ? '电影' : type === 'tv' ? '电视剧' : '综艺';
|
||||
};
|
||||
|
||||
@@ -271,7 +293,7 @@ function DoubanPageClient() {
|
||||
{getPageTitle()}
|
||||
</h1>
|
||||
<p className='text-sm sm:text-base text-gray-600 dark:text-gray-400'>
|
||||
来自豆瓣的精选内容
|
||||
全网资源站聚合,按分类实时更新
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -295,14 +317,19 @@ function DoubanPageClient() {
|
||||
? // 显示骨架屏
|
||||
skeletonData.map((index) => <DoubanCardSkeleton key={index} />)
|
||||
: // 显示实际数据
|
||||
doubanData.map((item, index) => (
|
||||
<div key={`${item.title}-${index}`} className='w-full'>
|
||||
browseData.map((item, index) => (
|
||||
<div
|
||||
key={`${item.source}-${item.id}-${index}`}
|
||||
className='w-full'
|
||||
>
|
||||
<VideoCard
|
||||
from='douban'
|
||||
from='search'
|
||||
id={item.id}
|
||||
source={item.source}
|
||||
source_name={item.source_name}
|
||||
title={item.title}
|
||||
poster={item.poster}
|
||||
douban_id={item.id}
|
||||
rate={item.rate}
|
||||
episodes={item.episodes}
|
||||
year={item.year}
|
||||
type={type === 'movie' ? 'movie' : ''} // 电影类型严格控制,tv 不控
|
||||
/>
|
||||
@@ -332,12 +359,12 @@ function DoubanPageClient() {
|
||||
)}
|
||||
|
||||
{/* 没有更多数据提示 */}
|
||||
{!hasMore && doubanData.length > 0 && (
|
||||
{!hasMore && browseData.length > 0 && (
|
||||
<div className='text-center text-gray-500 py-8'>已加载全部内容</div>
|
||||
)}
|
||||
|
||||
{/* 空状态 */}
|
||||
{!loading && doubanData.length === 0 && (
|
||||
{!loading && browseData.length === 0 && (
|
||||
<div className='text-center text-gray-500 py-8'>暂无相关内容</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+32
-45
@@ -1,11 +1,11 @@
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { Suspense, useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import PageLayout from '@/components/PageLayout';
|
||||
import VideoCard from '@/components/VideoCard';
|
||||
|
||||
// ---------- /filter 筛选页(源码化,原运行时补丁 filter-page-chunk.js) ----------
|
||||
// 数据约定对应 src/app/api/filter/route.ts:
|
||||
@@ -25,6 +25,7 @@ type Item = {
|
||||
year: string;
|
||||
area: string;
|
||||
type_name: string;
|
||||
douban_id?: number | string;
|
||||
};
|
||||
|
||||
const AREA_OPTS = [
|
||||
@@ -199,7 +200,7 @@ function FilterClient() {
|
||||
}
|
||||
const arr: Item[] = Array.isArray(j?.list) ? j.list : [];
|
||||
setItems((prev) => {
|
||||
const base = reset ? [] : [...prev, ...arr];
|
||||
const base = reset ? [...arr] : [...prev, ...arr];
|
||||
const seen = new Set<string>();
|
||||
return base.filter((x) => {
|
||||
const k = x.title + '|' + x.year;
|
||||
@@ -230,21 +231,19 @@ function FilterClient() {
|
||||
load(1, true);
|
||||
}, [source, cat, area, year]);
|
||||
|
||||
// 触底加载更多
|
||||
// 兜底:首次挂载确保加载一次(避免条件 effect 漏触发)
|
||||
useEffect(() => {
|
||||
const el = loadingRef.current;
|
||||
if (!el) return;
|
||||
const ob = new IntersectionObserver(
|
||||
(es) => {
|
||||
if (es[0]?.isIntersecting && hasMore && !refreshing && !loadingMore) {
|
||||
load(nextPg, false);
|
||||
}
|
||||
},
|
||||
{ rootMargin: '400px' }
|
||||
);
|
||||
ob.observe(el);
|
||||
return () => ob.disconnect();
|
||||
}, [hasMore, refreshing, loadingMore, nextPg, load]);
|
||||
load(1, true);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// 分页:上一页/下一页
|
||||
const goPage = (pg: number) => {
|
||||
if (pg < 1) return;
|
||||
setItems([]);
|
||||
setNextPg(pg);
|
||||
load(pg, true);
|
||||
};
|
||||
|
||||
const resetAll = () => {
|
||||
setCat('');
|
||||
@@ -307,41 +306,29 @@ function FilterClient() {
|
||||
) : (
|
||||
<div className='grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4'>
|
||||
{items.map((v) => {
|
||||
const pic = v.poster ? '/api/image-proxy?url=' + encodeURIComponent(v.poster) : '';
|
||||
const dbId = v.douban_id ? String(v.douban_id) : '';
|
||||
return (
|
||||
<Link
|
||||
<VideoCard
|
||||
key={v.source + ':' + v.id}
|
||||
href={`/play?source=${encodeURIComponent(v.source)}&id=${encodeURIComponent(v.id)}&title=${encodeURIComponent(v.title)}${v.year ? '&year=' + encodeURIComponent(v.year) : ''}`}
|
||||
className='group block'
|
||||
>
|
||||
<div className='relative aspect-[2/3] w-full overflow-hidden rounded-lg bg-gray-200 dark:bg-gray-800'>
|
||||
{pic ? (
|
||||
<img
|
||||
src={pic}
|
||||
alt={v.title}
|
||||
loading='lazy'
|
||||
className='absolute inset-0 w-full h-full object-cover group-hover:scale-105 transition-transform duration-300'
|
||||
/>
|
||||
) : null}
|
||||
{v.episodes > 1 ? (
|
||||
<span className='absolute bottom-1 right-1 px-1.5 py-0.5 text-xs bg-black/65 text-white rounded'>
|
||||
{v.episodes}集
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className='mt-2 text-sm font-medium text-gray-800 dark:text-gray-200 truncate'>
|
||||
{v.title}
|
||||
</div>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 truncate'>
|
||||
{[v.year, v.source_name].filter(Boolean).join(' · ')}
|
||||
</div>
|
||||
</Link>
|
||||
id={v.id}
|
||||
source={v.source}
|
||||
source_name={v.source_name}
|
||||
title={v.title}
|
||||
poster={v.poster}
|
||||
episodes={v.episodes}
|
||||
year={v.year}
|
||||
douban_id={dbId}
|
||||
from='search'
|
||||
type={v.episodes > 1 ? 'tv' : 'movie'}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<div ref={loadingRef} className='py-6 text-center text-sm text-gray-500 dark:text-gray-400'>
|
||||
{loadingMore ? '加载中…' : hasMore && items.length > 0 ? '下拉加载更多' : items.length > 0 ? '已加载全部内容' : ''}
|
||||
<div className='py-6 flex items-center justify-center gap-3 text-sm'>
|
||||
<button onClick={() => goPage(nextPg - 2)} disabled={nextPg <= 2} className='px-3 py-1.5 rounded bg-gray-200/60 dark:bg-gray-700/60 disabled:opacity-40'>上一页</button>
|
||||
<span className='text-gray-500 dark:text-gray-400'>第 {Math.max(1, nextPg - 1)} 页</span>
|
||||
<button onClick={() => goPage(nextPg)} disabled={!hasMore} className='px-3 py-1.5 rounded bg-gray-200/60 dark:bg-gray-700/60 disabled:opacity-40'>下一页</button>
|
||||
</div>
|
||||
</div>
|
||||
</PageLayout>
|
||||
|
||||
+117
-34
@@ -8,15 +8,21 @@ const H = {
|
||||
v6: 'https://tv6.88531.cn:4443',
|
||||
};
|
||||
|
||||
// 第一步:纯 IPv6 端点(仅 AAAA 记录),用于判断"客户端自己是否有 IPv6 出口"
|
||||
const IPV6_TEST = 'https://api6.ipify.org?format=json';
|
||||
// 第二步:我们自己的 IPv6 入口
|
||||
const URLS = [
|
||||
'https://tv6.88531.cn:4443/api/license-config?_=',
|
||||
'https://tv6.88531.cn/api/license-config?_=',
|
||||
];
|
||||
|
||||
type ProbeState = 'checking' | 'ok' | 'fail';
|
||||
type FailReason = 'no-ipv6' | 'entry' | 'unknown';
|
||||
|
||||
export default function IPv6Page() {
|
||||
const [state, setState] = useState<ProbeState>('checking');
|
||||
const [reason, setReason] = useState<FailReason>('unknown');
|
||||
const [detail, setDetail] = useState('');
|
||||
const [back, setBack] = useState('/');
|
||||
|
||||
useEffect(() => {
|
||||
@@ -35,6 +41,8 @@ export default function IPv6Page() {
|
||||
const cached = JSON.parse(localStorage.getItem('__v6probe') || 'null');
|
||||
if (cached && Date.now() - cached.t < 120000) {
|
||||
setState(cached.ok ? 'ok' : 'fail');
|
||||
setReason(cached.reason || 'unknown');
|
||||
setDetail(cached.detail || '');
|
||||
return;
|
||||
}
|
||||
} catch (e) { // ignore
|
||||
@@ -42,51 +50,81 @@ export default function IPv6Page() {
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
|
||||
const fetchJson = (url: string, timeout = 5000) => {
|
||||
const c = new AbortController();
|
||||
const ti = setTimeout(() => c.abort(), timeout);
|
||||
return fetch(url, { mode: 'cors', signal: c.signal, cache: 'no-store', credentials: 'omit' })
|
||||
.then((r) => { clearTimeout(ti); return r.json(); })
|
||||
.catch((e) => { clearTimeout(ti); throw e; });
|
||||
};
|
||||
|
||||
const fail = (r: FailReason, d: string) => {
|
||||
if (cancelled) return;
|
||||
try { localStorage.setItem('__v6probe', JSON.stringify({ t: Date.now(), ok: false, reason: r, detail: d })); } catch (e) { /* ignore */ }
|
||||
setReason(r);
|
||||
setDetail(d);
|
||||
setState('fail');
|
||||
};
|
||||
|
||||
// 单一检测点:我们自己的 v6 入口(纯 IPv6,AAAA 记录)
|
||||
// 能通 ⇒ 客户端有 IPv6 出口且 v6 入口可达;不通 ⇒ 其中一方有问题
|
||||
let i = 0;
|
||||
const probe = () => {
|
||||
const probeEntry = () => {
|
||||
if (i >= URLS.length) {
|
||||
if (!cancelled) {
|
||||
try { localStorage.setItem('__v6probe', JSON.stringify({ t: Date.now(), ok: false })); } catch (e) { // ignore
|
||||
// ignore
|
||||
}
|
||||
setState('fail');
|
||||
}
|
||||
fail('entry', 'v6 入口 ' + URLS.join(' / ') + ' 全部失败:客户端没有可用的 IPv6 出口,或服务端 v6 入口被防火墙/运营商拦截。');
|
||||
return;
|
||||
}
|
||||
const c = new AbortController();
|
||||
const ti = setTimeout(() => c.abort(), 5000);
|
||||
fetch(URLS[i] + Date.now(), { mode: 'cors', signal: c.signal, cache: 'no-store', credentials: 'omit' })
|
||||
.then((r) => r.json())
|
||||
.then((j) => {
|
||||
clearTimeout(ti);
|
||||
fetchJson(URLS[i] + Date.now(), 5000)
|
||||
.then((jj) => {
|
||||
if (cancelled) return;
|
||||
if (j && j.code === 200 && j.data) {
|
||||
try { localStorage.setItem('__v6probe', JSON.stringify({ t: Date.now(), ok: true })); } catch (e) { // ignore
|
||||
// ignore
|
||||
}
|
||||
if (jj && jj.code === 200 && jj.data) {
|
||||
try { localStorage.setItem('__v6probe', JSON.stringify({ t: Date.now(), ok: true })); } catch (e) { /* ignore */ }
|
||||
setState('ok');
|
||||
} else {
|
||||
i++;
|
||||
probe();
|
||||
probeEntry();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
clearTimeout(ti);
|
||||
.catch((e) => {
|
||||
if (cancelled) return;
|
||||
i++;
|
||||
probe();
|
||||
probeEntry();
|
||||
});
|
||||
};
|
||||
probe();
|
||||
probeEntry();
|
||||
|
||||
return () => { cancelled = true; };
|
||||
}, []);
|
||||
|
||||
const choose = (which: 'v4' | 'v6') => {
|
||||
const dest = which === 'v4' ? H.v4 : H.v6;
|
||||
let targetBack = back;
|
||||
try {
|
||||
const s = sessionStorage.getItem('__v6back');
|
||||
if (s) { targetBack = s; sessionStorage.removeItem('__v6back'); }
|
||||
} catch (e) { /* ignore */ }
|
||||
try { localStorage.setItem('__v6dest', which); } catch (e) { // ignore
|
||||
// ignore
|
||||
}
|
||||
window.location.href = dest + back + window.location.search + window.location.hash;
|
||||
document.cookie = `__v6dest=${which}; path=/; max-age=31536000; samesite=lax`;
|
||||
// 去掉 search 里的 back 参数,避免透传到目标地址
|
||||
const qs = new URLSearchParams(window.location.search);
|
||||
qs.delete('back');
|
||||
const searchStr = qs.toString() ? '?' + qs.toString() : '';
|
||||
const u = new URL(dest);
|
||||
const m = /^([^?#]*)(\?[^#]*)?(#.*)?$/.exec(targetBack) || [];
|
||||
u.pathname = m[1] || '/';
|
||||
if (m[2]) {
|
||||
const q2 = new URLSearchParams(m[2].slice(1));
|
||||
q2.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
|
||||
}
|
||||
if (searchStr) {
|
||||
const q3 = new URLSearchParams(searchStr.slice(1));
|
||||
q3.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
|
||||
}
|
||||
if (m[3]) u.hash = m[3];
|
||||
window.location.href = u.toString();
|
||||
};
|
||||
|
||||
const reprobe = () => {
|
||||
@@ -104,7 +142,24 @@ export default function IPv6Page() {
|
||||
try { localStorage.setItem('__v6dest', 'v6'); } catch (e) { // ignore
|
||||
// ignore
|
||||
}
|
||||
window.location.href = H.v6 + back + window.location.search + window.location.hash;
|
||||
document.cookie = '__v6dest=v6; path=/; max-age=31536000; samesite=lax';
|
||||
let targetBack = back;
|
||||
try {
|
||||
const s = sessionStorage.getItem('__v6back');
|
||||
if (s) { targetBack = s; sessionStorage.removeItem('__v6back'); }
|
||||
} catch (e) { /* ignore */ }
|
||||
const u = new URL(H.v6);
|
||||
const m = /^([^?#]*)(\?[^#]*)?(#.*)?$/.exec(targetBack) || [];
|
||||
u.pathname = m[1] || '/';
|
||||
if (m[2]) {
|
||||
const q2 = new URLSearchParams(m[2].slice(1));
|
||||
q2.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
|
||||
}
|
||||
const qs = new URLSearchParams(window.location.search);
|
||||
qs.delete('back');
|
||||
qs.forEach((v, k) => { if (!u.searchParams.has(k)) u.searchParams.set(k, v); });
|
||||
if (m[3]) u.hash = m[3];
|
||||
window.location.href = u.toString();
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -125,14 +180,35 @@ export default function IPv6Page() {
|
||||
<p style={{ color: 'rgba(255,255,255,.5)', marginBottom: 32 }}>选择访问线路</p>
|
||||
|
||||
{state === 'checking' && (
|
||||
<p style={{ color: 'rgba(255,255,255,.45)' }}>正在检测 IPv6…</p>
|
||||
<p style={{ color: 'rgba(255,255,255,.45)' }}>正在检测 IPv6(客户端出口 + v6 入口)…</p>
|
||||
)}
|
||||
|
||||
{state === 'ok' && (
|
||||
<div style={{ display: 'flex', gap: 16, flexWrap: 'wrap', justifyContent: 'center' }}>
|
||||
<button onClick={() => choose('v4')} style={btnStyle}>IPv4 线路</button>
|
||||
<button onClick={() => choose('v6')} style={btnStyle}>IPv6 线路</button>
|
||||
</div>
|
||||
<>
|
||||
<div style={{
|
||||
background: 'rgba(80,220,120,.10)',
|
||||
border: '1px solid rgba(80,220,120,.3)',
|
||||
borderRadius: 12,
|
||||
padding: '14px 20px',
|
||||
maxWidth: 520,
|
||||
textAlign: 'center',
|
||||
marginBottom: 24,
|
||||
}}>
|
||||
<p style={{ margin: 0, fontWeight: 600, color: '#7ef0a0' }}>✅ 检测到你的网络支持 IPv6</p>
|
||||
<p style={{ margin: '8px 0 0', color: 'rgba(255,255,255,.6)', fontSize: 13, lineHeight: 1.5 }}>
|
||||
推荐选择「IPv6 线路」,观影更流畅;如遇 IPv6 无法访问再切回 IPv4。
|
||||
</p>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 16, flexWrap: 'wrap', justifyContent: 'center' }}>
|
||||
<button onClick={() => choose('v6')} style={{
|
||||
...btnStyle,
|
||||
background: 'rgba(80,220,120,.16)',
|
||||
border: '1px solid rgba(80,220,120,.55)',
|
||||
fontWeight: 600,
|
||||
}}>IPv6 线路(推荐)</button>
|
||||
<button onClick={() => choose('v4')} style={btnStyle}>IPv4 线路</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{state === 'fail' && (
|
||||
@@ -142,13 +218,20 @@ export default function IPv6Page() {
|
||||
border: '1px solid rgba(255,180,0,.3)',
|
||||
borderRadius: 12,
|
||||
padding: '16px 20px',
|
||||
maxWidth: 480,
|
||||
textAlign: 'center',
|
||||
maxWidth: 520,
|
||||
textAlign: 'left',
|
||||
marginBottom: 24,
|
||||
}}>
|
||||
<p style={{ margin: 0, fontWeight: 600 }}>⚠️ 检测到你的网络不支持 IPv6 访问</p>
|
||||
<p style={{ margin: '8px 0 0', color: 'rgba(255,255,255,.6)', fontSize: 14 }}>
|
||||
已隐藏 IPv6 线路。请使用 IPv4 线路访问。
|
||||
<p style={{ margin: 0, fontWeight: 600 }}>
|
||||
{reason === 'no-ipv6' ? '⚠️ 你的浏览器/网络没有可用的 IPv6 出口' : '⚠️ 你的网络支持 IPv6,但我们的 v6 入口不可达'}
|
||||
</p>
|
||||
<p style={{ margin: '8px 0 0', color: 'rgba(255,255,255,.6)', fontSize: 13, lineHeight: 1.5, wordBreak: 'break-word' }}>
|
||||
{detail}
|
||||
</p>
|
||||
<p style={{ margin: '10px 0 0', color: 'rgba(255,255,255,.45)', fontSize: 12 }}>
|
||||
{reason === 'no-ipv6'
|
||||
? '常见原因:系统代理/VPN 只走 IPv4;路由器未分配 IPv6;浏览器禁用 IPv6。'
|
||||
: '常见原因:路由器/光猫 IPv6 防火墙拦截入向 4443;运营商阻断;或服务端 IPv6 地址已变更。'}
|
||||
</p>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', justifyContent: 'center' }}>
|
||||
|
||||
+4
-2
@@ -7,13 +7,14 @@ import 'sweetalert2/dist/sweetalert2.min.css';
|
||||
import { getConfig } from '@/lib/config';
|
||||
|
||||
import { SiteProvider } from '../components/SiteProvider';
|
||||
import Ipv6FirstVisitGate from '../components/Ipv6FirstVisitGate';
|
||||
import { ThemeProvider } from '../components/ThemeProvider';
|
||||
|
||||
const inter = Inter({ subsets: ['latin'] });
|
||||
|
||||
// 动态生成 metadata,支持配置更新后的标题变化
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
let siteName = process.env.SITE_NAME || 'KatelyaTV';
|
||||
let siteName = process.env.SITE_NAME || '米视TV';
|
||||
|
||||
try {
|
||||
// 只有在非 d1 和 upstash 存储类型时才尝试获取配置
|
||||
@@ -57,7 +58,7 @@ export default async function RootLayout({
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
let siteName = process.env.SITE_NAME || 'KatelyaTV';
|
||||
let siteName = process.env.SITE_NAME || '米视TV';
|
||||
let announcement =
|
||||
process.env.ANNOUNCEMENT ||
|
||||
'本网站仅提供影视信息搜索服务,所有内容均来自第三方网站。本站不存储任何视频资源,不对任何内容的准确性、合法性、完整性负责。Link Me TG:@katelya77';
|
||||
@@ -114,6 +115,7 @@ export default async function RootLayout({
|
||||
disableTransitionOnChange
|
||||
>
|
||||
<SiteProvider siteName={siteName} announcement={announcement}>
|
||||
<Ipv6FirstVisitGate />
|
||||
{children}
|
||||
</SiteProvider>
|
||||
</ThemeProvider>
|
||||
|
||||
+12
-12
@@ -7,18 +7,18 @@ export default function LivePage() {
|
||||
<>
|
||||
<TopRightButtons variant='float' />
|
||||
<iframe
|
||||
src='/api/tvbox?live=page'
|
||||
title='港澳台电视直播'
|
||||
allow='autoplay; fullscreen; encrypted-media'
|
||||
allowFullScreen
|
||||
style={{
|
||||
width: '100%',
|
||||
height: 'calc(100vh - 64px)',
|
||||
minHeight: 480,
|
||||
border: 'none',
|
||||
display: 'block',
|
||||
background: '#0f1115',
|
||||
}}
|
||||
src='/api/tvbox?live=page'
|
||||
title='港澳台电视直播'
|
||||
allow='autoplay; fullscreen; encrypted-media'
|
||||
allowFullScreen
|
||||
style={{
|
||||
width: '100%',
|
||||
height: 'calc(100vh - 64px)',
|
||||
minHeight: 480,
|
||||
border: 'none',
|
||||
display: 'block',
|
||||
background: '#0f1115',
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
+7
-5
@@ -20,11 +20,12 @@ import { DoubanItem } from '@/lib/types';
|
||||
import CapsuleSwitch from '@/components/CapsuleSwitch';
|
||||
import ContinueWatching from '@/components/ContinueWatching';
|
||||
import HkDramaRow from '@/components/HkDramaRow';
|
||||
import LineRecommender from '@/components/LineRecommender';
|
||||
import PageLayout from '@/components/PageLayout';
|
||||
import PaginatedRow from '@/components/PaginatedRow';
|
||||
import VideoCard from '@/components/VideoCard';
|
||||
|
||||
// 主内容区大型 KatelyaTV Logo 组件
|
||||
// 主内容区大型 米视TV Logo 组件
|
||||
const MainKatelyaLogo = () => {
|
||||
return (
|
||||
<div className='main-logo-container'>
|
||||
@@ -32,7 +33,7 @@ const MainKatelyaLogo = () => {
|
||||
<div className='logo-background-glow'></div>
|
||||
|
||||
{/* 主 Logo */}
|
||||
<div className='main-katelya-logo'>KatelyaTV</div>
|
||||
<div className='main-katelya-logo'>米视TV</div>
|
||||
|
||||
{/* 副标题 */}
|
||||
<div className='mt-3 text-center'>
|
||||
@@ -52,7 +53,7 @@ const MainKatelyaLogo = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// KatelyaTV 底部 Logo 组件
|
||||
// 米视TV 底部 Logo 组件
|
||||
const BottomKatelyaLogo = () => {
|
||||
return (
|
||||
<div className='bottom-logo-container'>
|
||||
@@ -65,9 +66,9 @@ const BottomKatelyaLogo = () => {
|
||||
</div>
|
||||
|
||||
<div className='text-center'>
|
||||
<div className='bottom-logo'>KatelyaTV</div>
|
||||
<div className='bottom-logo'>米视TV</div>
|
||||
<div className='mt-2 text-sm text-gray-500 dark:text-gray-400 opacity-75'>
|
||||
Powered by KatelyaTV Core
|
||||
Powered by 米视TV Core
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -540,6 +541,7 @@ export default function Home() {
|
||||
return (
|
||||
<Suspense>
|
||||
<HomeClient />
|
||||
<LineRecommender />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
+14
-2
@@ -1500,13 +1500,24 @@ function PlayPageClient() {
|
||||
<div className='flex flex-col gap-3 py-4 px-5 lg:px-[3rem] 2xl:px-20'>
|
||||
{/* 第一行:影片标题和操作按钮 */}
|
||||
<div className='py-1 flex items-center justify-between'>
|
||||
<h1 className='text-xl font-semibold text-gray-900 dark:text-gray-100'>
|
||||
<h1 className='text-xl font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2'>
|
||||
{videoTitle || '影片标题'}
|
||||
{totalEpisodes > 1 && (
|
||||
<span className='text-gray-500 dark:text-gray-400'>
|
||||
{` > 第 ${currentEpisodeIndex + 1} 集`}
|
||||
</span>
|
||||
)}
|
||||
{detail?.douban_id && (
|
||||
<a
|
||||
href={`https://movie.douban.com/subject/${detail.douban_id}/`}
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
title='跳转到豆瓣'
|
||||
className='inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-600 hover:bg-green-700 text-white text-xs font-medium transition-colors'
|
||||
>
|
||||
豆瓣 →
|
||||
</a>
|
||||
)}
|
||||
</h1>
|
||||
|
||||
{/* 跳过设置按钮 */}
|
||||
@@ -1694,7 +1705,7 @@ function PlayPageClient() {
|
||||
{detail?.type_name && <span>{detail.type_name}</span>}
|
||||
</div>
|
||||
{/* 剧情简介 */}
|
||||
{detail?.desc && (
|
||||
{detail?.desc && !detail?.douban_id && (
|
||||
<div
|
||||
className='mt-0 text-base leading-relaxed opacity-90 overflow-y-auto pr-2 flex-1 min-h-0 scrollbar-hide'
|
||||
style={{ whiteSpace: 'pre-line' }}
|
||||
@@ -1714,6 +1725,7 @@ function PlayPageClient() {
|
||||
doubanId={detail.douban_id}
|
||||
area={detail.area}
|
||||
lang={detail.lang}
|
||||
desc={detail.desc}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -39,6 +39,8 @@ function SearchPageClient() {
|
||||
|
||||
// 分组标签页状态
|
||||
const [activeTab, setActiveTab] = useState<'regular' | 'adult'>('regular');
|
||||
const [searchPage, setSearchPage] = useState(1);
|
||||
const PAGE_SIZE = 50;
|
||||
|
||||
// 获取默认聚合设置:只读取用户本地设置,默认为 true
|
||||
const getDefaultAggregate = () => {
|
||||
@@ -357,6 +359,11 @@ function SearchPageClient() {
|
||||
: groupedResults.regular;
|
||||
}
|
||||
|
||||
const totalPages = Math.max(1, Math.ceil(displayResults.length / PAGE_SIZE));
|
||||
const page = Math.min(searchPage, totalPages);
|
||||
const pagedResults = displayResults.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
|
||||
displayResults = pagedResults;
|
||||
|
||||
// 聚合显示模式
|
||||
if (viewMode === 'agg') {
|
||||
const aggregated = aggregateResults(displayResults);
|
||||
@@ -406,6 +413,13 @@ function SearchPageClient() {
|
||||
未找到相关结果
|
||||
</div>
|
||||
)}
|
||||
{searchResults.length > 0 && (
|
||||
<div className='col-span-full flex items-center justify-center gap-3 py-6 text-sm'>
|
||||
<button onClick={() => setSearchPage((p) => Math.max(1, p - 1))} disabled={searchPage <= 1} className='px-3 py-1.5 rounded bg-gray-200/60 dark:bg-gray-700/60 disabled:opacity-40'>上一页</button>
|
||||
<span className='text-gray-500 dark:text-gray-400'>第 {searchPage} / {Math.max(1, Math.ceil(searchResults.length / 50))} 页</span>
|
||||
<button onClick={() => setSearchPage((p) => p + 1)} disabled={searchPage >= Math.ceil(searchResults.length / 50)} className='px-3 py-1.5 rounded bg-gray-200/60 dark:bg-gray-700/60 disabled:opacity-40'>下一页</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
) : searchHistory.length > 0 ? (
|
||||
|
||||
@@ -39,21 +39,27 @@ const DoubanSelector: React.FC<DoubanSelectorProps> = ({
|
||||
width: number;
|
||||
}>({ left: 0, width: 0 });
|
||||
|
||||
// 电影的一级选择器选项
|
||||
// 电影的一级选择器选项(第三方采集站分类)
|
||||
const moviePrimaryOptions: SelectorOption[] = [
|
||||
{ label: '热门电影', value: '热门' },
|
||||
{ label: '最新电影', value: '最新' },
|
||||
{ label: '豆瓣高分', value: '豆瓣高分' },
|
||||
{ label: '冷门佳片', value: '冷门佳片' },
|
||||
{ label: '全部电影', value: '全部' },
|
||||
{ label: '动作片', value: '动作片' },
|
||||
{ label: '喜剧片', value: '喜剧片' },
|
||||
{ label: '爱情片', value: '爱情片' },
|
||||
{ label: '科幻片', value: '科幻片' },
|
||||
{ label: '恐怖片', value: '恐怖片' },
|
||||
{ label: '剧情片', value: '剧情片' },
|
||||
{ label: '战争片', value: '战争片' },
|
||||
{ label: '纪录片', value: '纪录' },
|
||||
];
|
||||
|
||||
// 电影的二级选择器选项
|
||||
// 电影的二级选择器选项(地区)
|
||||
const movieSecondaryOptions: SelectorOption[] = [
|
||||
{ label: '全部', value: '全部' },
|
||||
{ label: '华语', value: '华语' },
|
||||
{ label: '欧美', value: '欧美' },
|
||||
{ label: '韩国', value: '韩国' },
|
||||
{ label: '日本', value: '日本' },
|
||||
{ label: '泰国', value: '泰国' },
|
||||
];
|
||||
|
||||
// 电视剧选择器选项
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import VideoCard from './VideoCard';
|
||||
|
||||
type VodItem = {
|
||||
vod_id?: string | number;
|
||||
vod_name?: string;
|
||||
@@ -10,6 +12,8 @@ type VodItem = {
|
||||
vod_remarks?: string;
|
||||
vod_year?: string;
|
||||
vod_time?: string;
|
||||
vod_douban_id?: number;
|
||||
vod_area?: string;
|
||||
};
|
||||
|
||||
const SHOW_COUNT = 10;
|
||||
@@ -69,38 +73,23 @@ export default function HkDramaRow() {
|
||||
const sep = key.indexOf(':');
|
||||
const ks = sep > 0 ? key.slice(0, sep) : '';
|
||||
const kid = sep > 0 ? key.slice(sep + 1) : key;
|
||||
const pic = v.vod_pic
|
||||
? '/api/image-proxy?url=' + encodeURIComponent(v.vod_pic)
|
||||
: '';
|
||||
const epMatch = String(v.vod_remarks || '').match(/(\d+)/);
|
||||
const epCount = epMatch ? parseInt(epMatch[1], 10) : 1;
|
||||
const dbId = v.vod_douban_id ? String(v.vod_douban_id) : '';
|
||||
return (
|
||||
<Link
|
||||
<VideoCard
|
||||
key={key}
|
||||
href={`/play?source=${encodeURIComponent(
|
||||
ks
|
||||
)}&id=${encodeURIComponent(kid)}&stitle=${encodeURIComponent(
|
||||
v.vod_name || ''
|
||||
)}&stype=tv`}
|
||||
className='group block'
|
||||
>
|
||||
<div className='relative aspect-[2/3] w-full overflow-hidden rounded-lg bg-gray-200 dark:bg-gray-800'>
|
||||
{pic ? (
|
||||
<img
|
||||
src={pic}
|
||||
alt={v.vod_name || ''}
|
||||
loading='lazy'
|
||||
className='absolute inset-0 w-full h-full object-cover group-hover:scale-105 transition-transform duration-300'
|
||||
/>
|
||||
) : null}
|
||||
{v.vod_remarks ? (
|
||||
<span className='absolute bottom-1 right-1 px-1.5 py-0.5 text-xs bg-black/65 text-white rounded'>
|
||||
{v.vod_remarks}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className='mt-2 text-sm font-medium text-gray-800 dark:text-gray-200 truncate'>
|
||||
{v.vod_name}
|
||||
</div>
|
||||
</Link>
|
||||
id={kid}
|
||||
source={ks}
|
||||
source_name={ks}
|
||||
title={v.vod_name || ''}
|
||||
poster={v.vod_pic || ''}
|
||||
episodes={epCount}
|
||||
year={v.vod_year || ''}
|
||||
douban_id={dbId}
|
||||
from='search'
|
||||
type='tv'
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,7 @@ export default function Ipv6Button({ forceShow = false, compact = false, light =
|
||||
return (
|
||||
<button
|
||||
onClick={() => {
|
||||
try { sessionStorage.setItem('__v6back', location.pathname + location.search + location.hash); } catch {}
|
||||
location.href = '/ipv6';
|
||||
}}
|
||||
title='切换 IPv4 / IPv6 线路'
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
'use client';
|
||||
|
||||
// 首次访问公网入口:若用户支持 IPv6,则跳转到 tv6 线路选择页让用户选择
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function Ipv6FirstVisitGate() {
|
||||
useEffect(() => {
|
||||
try {
|
||||
if (location.hostname !== 'tv.88531.cn') return;
|
||||
if (/(^|;\s*)__v6dest=/.test(document.cookie)) return;
|
||||
if (localStorage.getItem('__v6dest')) return;
|
||||
// 探测 IPv6 可达性,可达才跳转
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), 1500);
|
||||
fetch('https://tv6.88531.cn:4443/api/license-config?_=', { mode: 'no-cors', signal: ctrl.signal })
|
||||
.then(() => {
|
||||
clearTimeout(t);
|
||||
sessionStorage.setItem('__v6back', location.pathname + location.search + location.hash);
|
||||
location.replace('https://tv6.88531.cn:4443/ipv6');
|
||||
})
|
||||
.catch(() => { clearTimeout(t); });
|
||||
} catch {}
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const V6 = 'https://tv6.88531.cn:4443';
|
||||
const PROBE_URL = 'https://tv6.88531.cn:4443/api/license-config?_=';
|
||||
|
||||
// 首次访问的线路推荐:不阻塞数据加载,检测到支持 IPv6 时浮层提示用户可切换
|
||||
export default function LineRecommender() {
|
||||
const [show, setShow] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
// 已记住线路 / 不在 v6 入口 / 已提示过 → 不再弹
|
||||
if (window.location.hostname === 'tv6.88531.cn') return;
|
||||
if (localStorage.getItem('__v6dest')) return;
|
||||
if (localStorage.getItem('__v6hint')) return;
|
||||
|
||||
const cached = JSON.parse(localStorage.getItem('__v6probe') || 'null');
|
||||
if (cached && Date.now() - cached.t < 120000) {
|
||||
if (cached.ok) setShow(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const c = new AbortController();
|
||||
const ti = setTimeout(() => c.abort(), 5000);
|
||||
fetch(PROBE_URL + Date.now(), { mode: 'cors', signal: c.signal, cache: 'no-store', credentials: 'omit' })
|
||||
.then((r) => { clearTimeout(ti); return r.json(); })
|
||||
.then((jj) => {
|
||||
const ok = !!(jj && jj.code === 200 && jj.data);
|
||||
try { localStorage.setItem('__v6probe', JSON.stringify({ t: Date.now(), ok })); } catch (e) { /* ignore */ }
|
||||
if (ok) setShow(true);
|
||||
})
|
||||
.catch(() => { clearTimeout(ti); });
|
||||
} catch (e) { /* ignore */ }
|
||||
}, []);
|
||||
|
||||
if (!show) return null;
|
||||
|
||||
const dismiss = (pick?: 'v6' | 'v4') => {
|
||||
try {
|
||||
localStorage.setItem('__v6hint', '1');
|
||||
if (pick === 'v6') {
|
||||
localStorage.setItem('__v6dest', 'v6');
|
||||
document.cookie = '__v6dest=v6; path=/; max-age=31536000; samesite=lax';
|
||||
window.location.href = V6 + window.location.pathname + window.location.search;
|
||||
return;
|
||||
}
|
||||
if (pick === 'v4') {
|
||||
localStorage.setItem('__v6dest', 'v4');
|
||||
document.cookie = '__v6dest=v4; path=/; max-age=31536000; samesite=lax';
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
setShow(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
position: 'fixed',
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
zIndex: 9999,
|
||||
maxWidth: 340,
|
||||
background: 'rgba(20,24,20,.96)',
|
||||
border: '1px solid rgba(80,220,120,.45)',
|
||||
borderRadius: 14,
|
||||
padding: '14px 16px',
|
||||
color: '#fff',
|
||||
fontFamily: 'system-ui, -apple-system, sans-serif',
|
||||
boxShadow: '0 8px 30px rgba(0,0,0,.45)',
|
||||
}}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 8 }}>
|
||||
<p style={{ margin: 0, fontWeight: 600, color: '#7ef0a0', fontSize: 14 }}>
|
||||
✅ 检测到你的网络支持 IPv6
|
||||
</p>
|
||||
<button onClick={() => dismiss()} aria-label='关闭' style={{
|
||||
background: 'none', border: 'none', color: 'rgba(255,255,255,.5)',
|
||||
fontSize: 16, cursor: 'pointer', lineHeight: 1, padding: 0,
|
||||
}}>×</button>
|
||||
</div>
|
||||
<p style={{ margin: '8px 0 12px', color: 'rgba(255,255,255,.65)', fontSize: 13, lineHeight: 1.5 }}>
|
||||
推荐切换到 IPv6 线路,观影更流畅。
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<button onClick={() => dismiss('v6')} style={{
|
||||
flex: 1, padding: '8px 10px', borderRadius: 9,
|
||||
border: '1px solid rgba(80,220,120,.55)', background: 'rgba(80,220,120,.18)',
|
||||
color: '#fff', fontSize: 13, fontWeight: 600, cursor: 'pointer',
|
||||
}}>切换 IPv6</button>
|
||||
<button onClick={() => dismiss('v4')} style={{
|
||||
flex: 1, padding: '8px 10px', borderRadius: 9,
|
||||
border: '1px solid rgba(255,255,255,.18)', background: 'rgba(255,255,255,.06)',
|
||||
color: 'rgba(255,255,255,.8)', fontSize: 13, cursor: 'pointer',
|
||||
}}>保持 IPv4</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { Clover, Film, Filter, Home, Radio, Search, Tv } from 'lucide-react';
|
||||
import { Clover, Film, Filter, Home, Radio, Search, Sparkles, Tv } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
@@ -30,6 +30,11 @@ const MobileBottomNav = ({ activePath }: MobileBottomNavProps) => {
|
||||
label: '剧集',
|
||||
href: '/douban?type=tv',
|
||||
},
|
||||
{
|
||||
icon: Sparkles,
|
||||
label: '动漫',
|
||||
href: '/anime',
|
||||
},
|
||||
{
|
||||
icon: Clover,
|
||||
label: '综艺',
|
||||
@@ -50,6 +55,7 @@ const MobileBottomNav = ({ activePath }: MobileBottomNavProps) => {
|
||||
const isActive = (href: string) => {
|
||||
if (href === '/filter') return currentActive.startsWith('/filter');
|
||||
const typeMatch = href.match(/type=([^&]+)/)?.[1];
|
||||
const catMatch = href.match(/cat=([^&]+)/)?.[1];
|
||||
|
||||
// 解码URL以进行正确的比较
|
||||
const decodedActive = decodeURIComponent(currentActive);
|
||||
@@ -58,7 +64,8 @@ const MobileBottomNav = ({ activePath }: MobileBottomNavProps) => {
|
||||
return (
|
||||
decodedActive === decodedItemHref ||
|
||||
(decodedActive.startsWith('/douban') &&
|
||||
decodedActive.includes(`type=${typeMatch}`))
|
||||
decodedActive.includes(`type=${typeMatch}`) &&
|
||||
(catMatch ? decodedActive.includes(`cat=${catMatch}`) : !decodedActive.includes('cat=')))
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const MobileHeader = ({ showBackButton = false }: MobileHeaderProps) => {
|
||||
className='shrink-0 select-none rounded-md px-1.5 py-0.5 text-[10px] font-bold tracking-wide text-purple-600 dark:text-purple-400 bg-purple-500/10 border border-purple-500/20'
|
||||
title='米视TV 当前版本'
|
||||
>
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed73'}
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed75'}
|
||||
</span>
|
||||
<ThemeToggle />
|
||||
<UserMenu />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Clover, Film, Filter, Home, Play, Radio, Search, Tv } from 'lucide-react';
|
||||
import { Clover, Film, Filter, Home, Play, Radio, Search, Sparkles, Tv } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
@@ -66,6 +66,11 @@ const TopNavbar = ({ activePath = '/' }: { activePath?: string }) => {
|
||||
label: '剧集',
|
||||
href: '/douban?type=tv',
|
||||
},
|
||||
{
|
||||
icon: Sparkles,
|
||||
label: '动漫',
|
||||
href: '/anime',
|
||||
},
|
||||
{
|
||||
icon: Clover,
|
||||
label: '综艺',
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function TopRightButtons({ variant = 'bar' }: TopRightButtonsProp
|
||||
className='shrink-0 select-none rounded-md px-1.5 py-1 text-[10px] font-bold tracking-wide text-purple-300 bg-purple-500/20 border border-purple-400/30'
|
||||
title='米视TV 当前版本'
|
||||
>
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed73'}
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed75'}
|
||||
</span>
|
||||
<HubBell forceShow />
|
||||
<TvboxButton forceShow compact />
|
||||
@@ -43,7 +43,7 @@ export default function TopRightButtons({ variant = 'bar' }: TopRightButtonsProp
|
||||
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 当前版本'
|
||||
>
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed73'}
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed75'}
|
||||
</span>
|
||||
<HubBell />
|
||||
<TvboxButton />
|
||||
|
||||
@@ -5,7 +5,25 @@ import { useState } from 'react';
|
||||
export default function TvboxButton({ forceShow = false, compact = false }: { forceShow?: boolean; compact?: boolean }) {
|
||||
const [label, setLabel] = useState('📺 TVBOX接口');
|
||||
|
||||
const showModal = (title: string, body: string, link?: string) => {
|
||||
const copyText = (t: string, btn?: HTMLButtonElement) => {
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(t).then(() => {
|
||||
if (btn) { btn.textContent = '✓ 已复制'; setTimeout(() => (btn.textContent = '复制'), 1600); }
|
||||
}).catch(() => {});
|
||||
return;
|
||||
}
|
||||
} catch {}
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = t;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
try { document.execCommand('copy'); } catch {}
|
||||
document.body.removeChild(ta);
|
||||
if (btn) { btn.textContent = '✓ 已复制'; setTimeout(() => (btn.textContent = '复制'), 1600); }
|
||||
};
|
||||
|
||||
const showTvboxModal = (cfg: string, live: string) => {
|
||||
const ov = document.createElement('div');
|
||||
ov.className =
|
||||
'fixed inset-0 z-[9999] flex items-center justify-center bg-black/50 p-4';
|
||||
@@ -18,7 +36,7 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
const h3 = document.createElement('h3');
|
||||
h3.className =
|
||||
'text-base font-bold text-gray-900 dark:text-gray-100 truncate mr-2';
|
||||
h3.textContent = title;
|
||||
h3.textContent = '📺 TVBOX 接入';
|
||||
const xb = document.createElement('button');
|
||||
xb.className =
|
||||
'text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-lg leading-none flex-shrink-0';
|
||||
@@ -27,8 +45,51 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
head.appendChild(xb);
|
||||
const bd = document.createElement('div');
|
||||
bd.className =
|
||||
'px-6 pb-4 overflow-y-auto text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap';
|
||||
bd.textContent = body;
|
||||
'px-6 pb-4 overflow-y-auto text-sm text-gray-700 dark:text-gray-300';
|
||||
const mkRow = (label: string, url: string) => {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.style.marginBottom = '14px';
|
||||
const lb = document.createElement('div');
|
||||
lb.style.fontWeight = '700';
|
||||
lb.style.marginBottom = '6px';
|
||||
lb.textContent = label;
|
||||
const urlDiv = document.createElement('div');
|
||||
urlDiv.style.wordBreak = 'break-all';
|
||||
urlDiv.style.background = 'rgba(127,127,127,.12)';
|
||||
urlDiv.style.borderRadius = '8px';
|
||||
urlDiv.style.padding = '8px 10px';
|
||||
urlDiv.style.fontSize = '12px';
|
||||
urlDiv.textContent = url;
|
||||
const row = document.createElement('div');
|
||||
row.style.display = 'flex';
|
||||
row.style.gap = '8px';
|
||||
row.style.marginTop = '8px';
|
||||
const cp = document.createElement('button');
|
||||
cp.textContent = '复制';
|
||||
cp.className =
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-white bg-purple-600 hover:bg-purple-700';
|
||||
cp.onclick = () => copyText(url, cp);
|
||||
const op = document.createElement('a');
|
||||
op.href = url;
|
||||
op.target = '_blank';
|
||||
op.rel = 'noopener';
|
||||
op.textContent = '打开 →';
|
||||
op.className =
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-purple-600 dark:text-purple-400 hover:bg-purple-500/10';
|
||||
row.appendChild(cp);
|
||||
row.appendChild(op);
|
||||
wrap.appendChild(lb);
|
||||
wrap.appendChild(urlDiv);
|
||||
wrap.appendChild(row);
|
||||
return wrap;
|
||||
};
|
||||
bd.appendChild(mkRow('配置地址(含直播,推荐)', cfg));
|
||||
bd.appendChild(mkRow('直播源地址(仅直播)', live));
|
||||
const tip = document.createElement('div');
|
||||
tip.style.fontSize = '12px';
|
||||
tip.style.opacity = '0.75';
|
||||
tip.textContent = '影视仓/TVBox「设置 → 配置地址」粘贴保存即可';
|
||||
bd.appendChild(tip);
|
||||
card.appendChild(head);
|
||||
card.appendChild(bd);
|
||||
const foot = document.createElement('div');
|
||||
@@ -39,16 +100,6 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600';
|
||||
kb.textContent = '我知道了';
|
||||
foot.appendChild(kb);
|
||||
if (link) {
|
||||
const la = document.createElement('a');
|
||||
la.href = link;
|
||||
la.target = '_blank';
|
||||
la.rel = 'noopener';
|
||||
la.className =
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-purple-600 dark:text-purple-400 hover:bg-purple-500/10';
|
||||
la.textContent = '查看详情 →';
|
||||
foot.insertBefore(la, kb);
|
||||
}
|
||||
card.appendChild(foot);
|
||||
const close = () => {
|
||||
if (ov && ov.parentNode) ov.parentNode.removeChild(ov);
|
||||
@@ -63,25 +114,16 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
};
|
||||
|
||||
const onClick = (ev: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const u = location.origin + '/api/tvbox';
|
||||
const cfg = location.origin + '/api/tvbox';
|
||||
const live = location.origin + '/api/tvbox?live=txt';
|
||||
const bt = ev.currentTarget;
|
||||
const ok = () => {
|
||||
setLabel('✓ 已复制');
|
||||
setTimeout(() => setLabel('📺 TVBOX接口'), 1600);
|
||||
};
|
||||
const tip = '影视仓/TVBox「设置 → 配置地址」粘贴保存即可';
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard
|
||||
.writeText(u)
|
||||
.then(ok)
|
||||
.catch(() =>
|
||||
showModal('📺 TVBOX 接入', '配置地址: ' + u + ' —— ' + tip, u)
|
||||
);
|
||||
return;
|
||||
}
|
||||
} catch {}
|
||||
showModal('📺 TVBOX 接入', '配置地址: ' + u + ' —— ' + tip, u);
|
||||
void bt;
|
||||
void ok;
|
||||
showTvboxModal(cfg, live);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -100,7 +100,7 @@ export default function VideoCard({
|
||||
const actualSource = aggregateData?.first.source ?? source;
|
||||
const actualId = aggregateData?.first.id ?? id;
|
||||
const actualDoubanId = String(
|
||||
aggregateData?.mostFrequentDoubanId ?? douban_id
|
||||
aggregateData?.mostFrequentDoubanId ?? douban_id ?? ''
|
||||
);
|
||||
const actualEpisodes = aggregateData?.mostFrequentEpisodes ?? episodes;
|
||||
const actualYear = aggregateData?.first.year ?? year;
|
||||
@@ -248,9 +248,9 @@ export default function VideoCard({
|
||||
showSourceName: true,
|
||||
showProgress: false,
|
||||
showPlayButton: true,
|
||||
showHeart: !isAggregate,
|
||||
showHeart: true,
|
||||
showCheckCircle: false,
|
||||
showDoubanLink: !!actualDoubanId,
|
||||
showDoubanLink: !!actualDoubanId && actualDoubanId !== '0',
|
||||
showRating: false,
|
||||
},
|
||||
douban: {
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
interface HotComment {
|
||||
title: string;
|
||||
interface DoubanComment {
|
||||
id: string;
|
||||
user: string;
|
||||
avatar: string;
|
||||
rating: number;
|
||||
content: string;
|
||||
url: string;
|
||||
source: string;
|
||||
time: string;
|
||||
location: string;
|
||||
}
|
||||
|
||||
// 演员 / 评分 / 全网热评(详情页简介下方)
|
||||
@@ -21,6 +24,8 @@ export default function VideoMetaExtra({
|
||||
doubanId,
|
||||
area,
|
||||
lang,
|
||||
isTv,
|
||||
desc,
|
||||
}: {
|
||||
title: string;
|
||||
actor?: string;
|
||||
@@ -31,15 +36,19 @@ export default function VideoMetaExtra({
|
||||
doubanId?: number;
|
||||
area?: string;
|
||||
lang?: string;
|
||||
isTv?: boolean;
|
||||
desc?: string;
|
||||
}) {
|
||||
const [comments, setComments] = useState<HotComment[]>([]);
|
||||
const [comments, setComments] = useState<DoubanComment[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [dbDetail, setDbDetail] = useState<any>(null);
|
||||
const [related, setRelated] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!title) return;
|
||||
if (!doubanId) return;
|
||||
let alive = true;
|
||||
setLoading(true);
|
||||
fetch(`/api/hot-comments?title=${encodeURIComponent(title)}`)
|
||||
fetch(`/api/douban-comments?id=${encodeURIComponent(String(doubanId))}`)
|
||||
.then((r) => r.json())
|
||||
.then((d) => {
|
||||
if (alive && d?.code === 1) setComments(d.list || []);
|
||||
@@ -48,34 +57,53 @@ export default function VideoMetaExtra({
|
||||
.finally(() => {
|
||||
if (alive) setLoading(false);
|
||||
});
|
||||
// 豆瓣详情(评分/演员兜底)
|
||||
fetch(`/api/douban-detail?id=${encodeURIComponent(String(doubanId))}`)
|
||||
.then((r) => r.json())
|
||||
.then((d) => {
|
||||
if (alive && d?.code === 1) setDbDetail(d);
|
||||
})
|
||||
.catch(() => {});
|
||||
// 相关推荐
|
||||
fetch(`/api/douban-related?id=${encodeURIComponent(String(doubanId))}&type=${isTv ? 'tv' : 'movie'}`)
|
||||
.then((r) => r.json())
|
||||
.then((d) => {
|
||||
if (alive && d?.code === 1) setRelated(d.list || []);
|
||||
})
|
||||
.catch(() => {});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [title]);
|
||||
}, [doubanId]);
|
||||
|
||||
const actors = (actor || '')
|
||||
const actors = (actor || (dbDetail?.actors || []).join(','))
|
||||
.split(/[,,、\/|]/)
|
||||
.map((s) => s.trim())
|
||||
.map((s: string) => s.trim())
|
||||
.filter(Boolean)
|
||||
.slice(0, 20);
|
||||
const scoreNum1 = parseFloat(score || '') || 0;
|
||||
const dbNum = parseFloat(doubanScore || '') || 0;
|
||||
const dbNum = parseFloat(doubanScore || '') || dbDetail?.rating || 0;
|
||||
const showScore = scoreNum1 > 0 ? scoreNum1.toFixed(1) : dbNum > 0 ? dbNum.toFixed(1) : '';
|
||||
|
||||
if (!actors.length && !director && !showScore && !area && !loading && !comments.length) return null;
|
||||
const showDirector = director || (dbDetail?.directors || []).join('、');
|
||||
const showArea = area || dbDetail?.area || '';
|
||||
const showLang = lang || dbDetail?.languages || '';
|
||||
const showDuration = dbDetail?.duration || '';
|
||||
if (!actors.length && !showDirector && !showScore && !showArea && !loading && !comments.length) return null;
|
||||
|
||||
return (
|
||||
<div className='mt-4 space-y-4'>
|
||||
{/* 导演 / 地区 / 语言 */}
|
||||
{(director || area || lang) && (
|
||||
{(showDirector || showArea || showLang || showDuration) && (
|
||||
<div className='text-sm opacity-80 space-x-4'>
|
||||
{director && (
|
||||
{showDirector && (
|
||||
<span>
|
||||
导演:<span className='font-medium'>{director}</span>
|
||||
导演:<span className='font-medium'>{showDirector}</span>
|
||||
</span>
|
||||
)}
|
||||
{area && <span>地区:{area}</span>}
|
||||
{lang && <span>语言:{lang}</span>}
|
||||
{showArea && <span>地区:{showArea}</span>}
|
||||
{showLang && <span>语言:{showLang}</span>}
|
||||
{showDuration && <span>片长:{showDuration}</span>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -105,12 +133,19 @@ export default function VideoMetaExtra({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(dbDetail?.intro || desc) && (
|
||||
<div className='text-sm leading-relaxed opacity-90 whitespace-pre-line'>
|
||||
<span className='font-semibold'>剧情简介:</span>
|
||||
{dbDetail?.intro || desc}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 演员列表 */}
|
||||
{actors.length > 0 && (
|
||||
<div>
|
||||
<div className='text-sm font-semibold mb-2 opacity-80'>演员({actors.length})</div>
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
{actors.map((a) => (
|
||||
{actors.map((a: string) => (
|
||||
<Link
|
||||
key={a}
|
||||
href={`/search?q=${encodeURIComponent(a)}`}
|
||||
@@ -124,10 +159,20 @@ export default function VideoMetaExtra({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 全网热评 Top10 */}
|
||||
{/* 豆瓣短评 */}
|
||||
<div>
|
||||
<div className='text-sm font-semibold mb-2 opacity-80'>
|
||||
全网热评 Top10 <span className='font-normal opacity-60'>(来自网上公开影评聚合)</span>
|
||||
<div className='text-sm font-semibold mb-2 opacity-80 flex items-center gap-2'>
|
||||
豆瓣短评
|
||||
{doubanId ? (
|
||||
<a
|
||||
href={`https://movie.douban.com/subject/${doubanId}/comments`}
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
className='text-xs text-green-600 hover:underline font-normal'
|
||||
>
|
||||
查看全部 →
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
{loading && comments.length === 0 && (
|
||||
<div className='space-y-2'>
|
||||
@@ -137,29 +182,60 @@ export default function VideoMetaExtra({
|
||||
</div>
|
||||
)}
|
||||
{!loading && comments.length === 0 && (
|
||||
<div className='text-sm opacity-50'>暂无全网热评,换个片名或稍后再试。</div>
|
||||
<div className='text-sm opacity-50'>暂无豆瓣短评。</div>
|
||||
)}
|
||||
<div className='space-y-2'>
|
||||
{comments.map((c, i) => (
|
||||
<a
|
||||
key={i}
|
||||
href={c.url}
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
className='block rounded-lg bg-gray-100/80 dark:bg-gray-800/60 p-3 hover:bg-gray-200/80 dark:hover:bg-gray-700/60 transition-colors'
|
||||
{comments.map((c) => (
|
||||
<div
|
||||
key={c.id}
|
||||
className='rounded-lg bg-gray-100/80 dark:bg-gray-800/60 p-3'
|
||||
>
|
||||
<div className='flex items-center gap-2 mb-1'>
|
||||
<span className='text-xs font-bold text-white bg-amber-500 rounded px-1.5 py-0.5'>
|
||||
{i + 1}
|
||||
</span>
|
||||
<span className='text-sm font-medium truncate flex-1'>{c.title}</span>
|
||||
<span className='text-xs opacity-50 flex-shrink-0'>{c.source}</span>
|
||||
{c.avatar ? (
|
||||
<img src={c.avatar} alt={c.user} className='w-6 h-6 rounded-full' />
|
||||
) : null}
|
||||
<span className='text-sm font-medium truncate flex-1'>{c.user}</span>
|
||||
{c.rating > 0 && (
|
||||
<span className='text-xs text-amber-500'>{'★'.repeat(c.rating)}</span>
|
||||
)}
|
||||
<span className='text-xs opacity-50 flex-shrink-0'>{c.time.slice(0, 10)}</span>
|
||||
</div>
|
||||
<div className='text-sm opacity-80 leading-relaxed line-clamp-3'>{c.content}</div>
|
||||
</a>
|
||||
<div className='text-sm opacity-80 leading-relaxed'>{c.content}</div>
|
||||
{c.location ? (
|
||||
<div className='text-xs opacity-40 mt-1'>{c.location}</div>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{related.length > 0 && (
|
||||
<div className='mt-4'>
|
||||
<div className='text-sm font-semibold mb-2 opacity-80'>相关推荐</div>
|
||||
<div className='grid grid-cols-5 gap-3'>
|
||||
{related.map((r: any) => (
|
||||
<a
|
||||
key={r.id}
|
||||
href={`/search?q=${encodeURIComponent(r.title)}`}
|
||||
target='_self'
|
||||
rel='noreferrer'
|
||||
className='group block'
|
||||
>
|
||||
{r.poster ? (
|
||||
<img
|
||||
src={`/api/image-proxy?url=${encodeURIComponent(r.poster)}`}
|
||||
alt={r.title}
|
||||
className='w-full aspect-[2/3] object-cover rounded-md mb-1'
|
||||
/>
|
||||
) : null}
|
||||
<div className='text-xs truncate group-hover:text-blue-500'>{r.title}</div>
|
||||
{r.rating > 0 && (
|
||||
<div className='text-xs text-amber-500'>{r.rating.toFixed(1)}</div>
|
||||
)}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,10 @@ export interface AdminConfig {
|
||||
username: string;
|
||||
role: 'user' | 'admin' | 'owner';
|
||||
banned?: boolean;
|
||||
created_at?: string;
|
||||
created_at_estimated?: boolean;
|
||||
last_login_at?: string;
|
||||
last_login_estimated?: boolean;
|
||||
}[];
|
||||
};
|
||||
SourceConfig: {
|
||||
|
||||
+80
-12
@@ -73,16 +73,41 @@ async function initConfig() {
|
||||
adminConfig = await (storage as any).getAdminConfig();
|
||||
}
|
||||
|
||||
// 获取所有用户名,用于补全 Users
|
||||
// 获取所有用户(含注册/最后登录时间),用于补全 Users
|
||||
let userNames: string[] = [];
|
||||
const userTimeMap = new Map<
|
||||
string,
|
||||
{
|
||||
created_at?: string;
|
||||
created_at_estimated?: boolean;
|
||||
last_login_at?: string;
|
||||
last_login_estimated?: boolean;
|
||||
}
|
||||
>();
|
||||
if (storage && typeof (storage as any).getAllUsers === 'function') {
|
||||
try {
|
||||
const rawUsers = await (storage as any).getAllUsers();
|
||||
// getAllUsers 返回的是 User 对象数组,这里统一取用户名字符串,
|
||||
// 否则会把整个对象写入 Users[].username(导致管理页渲染对象报 React #31)
|
||||
userNames = (Array.isArray(rawUsers) ? rawUsers : [])
|
||||
.map((u: any) => (typeof u === 'string' ? u : u && typeof u.username === 'string' ? u.username : ''))
|
||||
.filter((n: string) => !!n);
|
||||
// 同时保留时间字段,供用户列表展示注册/最后登录时间
|
||||
(Array.isArray(rawUsers) ? rawUsers : []).forEach((u: any) => {
|
||||
const n =
|
||||
typeof u === 'string'
|
||||
? u
|
||||
: u && typeof u.username === 'string'
|
||||
? u.username
|
||||
: '';
|
||||
if (!n) return;
|
||||
userNames.push(n);
|
||||
if (typeof u === 'object' && u) {
|
||||
userTimeMap.set(n, {
|
||||
created_at: u.created_at || undefined,
|
||||
created_at_estimated: !!u.created_at_estimated,
|
||||
last_login_at: u.last_login_at || undefined,
|
||||
last_login_estimated: !!u.last_login_estimated,
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('获取用户列表失败:', e);
|
||||
}
|
||||
@@ -132,7 +157,24 @@ async function initConfig() {
|
||||
adminConfig!.UserConfig.Users.push({
|
||||
username: uname,
|
||||
role: 'user',
|
||||
...(userTimeMap.get(uname) || {}),
|
||||
});
|
||||
} else {
|
||||
// 已存在用户也回填时间字段(老配置升级时补上)
|
||||
const exist = adminConfig!.UserConfig.Users.find(
|
||||
(u) => u.username === uname
|
||||
);
|
||||
const t = userTimeMap.get(uname);
|
||||
if (exist && t) {
|
||||
if (!exist.created_at && t.created_at) {
|
||||
exist.created_at = t.created_at;
|
||||
exist.created_at_estimated = t.created_at_estimated;
|
||||
}
|
||||
if (!exist.last_login_at && t.last_login_at) {
|
||||
exist.last_login_at = t.last_login_at;
|
||||
exist.last_login_estimated = t.last_login_estimated;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 站长
|
||||
@@ -151,6 +193,7 @@ async function initConfig() {
|
||||
let allUsers = userNames.map((uname) => ({
|
||||
username: uname,
|
||||
role: 'user',
|
||||
...(userTimeMap.get(uname) || {}),
|
||||
}));
|
||||
const ownerUser = process.env.USERNAME;
|
||||
if (ownerUser) {
|
||||
@@ -162,7 +205,7 @@ async function initConfig() {
|
||||
}
|
||||
adminConfig = {
|
||||
SiteConfig: {
|
||||
SiteName: process.env.SITE_NAME || 'KatelyaTV',
|
||||
SiteName: process.env.SITE_NAME || '米视TV',
|
||||
Announcement:
|
||||
process.env.ANNOUNCEMENT ||
|
||||
'本网站仅提供影视信息搜索服务,所有内容均来自第三方网站。本站不存储任何视频资源,不对任何内容的准确性、合法性、完整性负责。',
|
||||
@@ -202,7 +245,7 @@ async function initConfig() {
|
||||
// 本地存储直接使用文件配置
|
||||
cachedConfig = {
|
||||
SiteConfig: {
|
||||
SiteName: process.env.SITE_NAME || 'KatelyaTV',
|
||||
SiteName: process.env.SITE_NAME || '米视TV',
|
||||
Announcement:
|
||||
process.env.ANNOUNCEMENT ||
|
||||
'本网站仅提供影视信息搜索服务,所有内容均来自第三方网站。本站不存储任何视频资源,不对任何内容的准确性、合法性、完整性负责。',
|
||||
@@ -247,7 +290,7 @@ export async function getConfig(): Promise<AdminConfig> {
|
||||
|
||||
if (adminConfig) {
|
||||
// 合并一些环境变量配置
|
||||
adminConfig.SiteConfig.SiteName = process.env.SITE_NAME || 'KatelyaTV';
|
||||
adminConfig.SiteConfig.SiteName = process.env.SITE_NAME || '米视TV';
|
||||
adminConfig.SiteConfig.Announcement =
|
||||
process.env.ANNOUNCEMENT ||
|
||||
'本网站仅提供影视信息搜索服务,所有内容均来自第三方网站。本站不存储任何视频资源,不对任何内容的准确性、合法性、完整性负责。';
|
||||
@@ -325,14 +368,38 @@ export async function getConfig(): Promise<AdminConfig> {
|
||||
|
||||
export async function resetConfig() {
|
||||
const storage = getStorage();
|
||||
// 获取所有用户名,用于补全 Users
|
||||
// 获取所有用户(含注册/最后登录时间),用于补全 Users
|
||||
let userNames: string[] = [];
|
||||
const userTimeMap = new Map<
|
||||
string,
|
||||
{
|
||||
created_at?: string;
|
||||
created_at_estimated?: boolean;
|
||||
last_login_at?: string;
|
||||
last_login_estimated?: boolean;
|
||||
}
|
||||
>();
|
||||
if (storage && typeof (storage as any).getAllUsers === 'function') {
|
||||
try {
|
||||
const rawUsers = await (storage as any).getAllUsers();
|
||||
userNames = (Array.isArray(rawUsers) ? rawUsers : [])
|
||||
.map((u: any) => (typeof u === 'string' ? u : u && typeof u.username === 'string' ? u.username : ''))
|
||||
.filter((n: string) => !!n);
|
||||
(Array.isArray(rawUsers) ? rawUsers : []).forEach((u: any) => {
|
||||
const n =
|
||||
typeof u === 'string'
|
||||
? u
|
||||
: u && typeof u.username === 'string'
|
||||
? u.username
|
||||
: '';
|
||||
if (!n) return;
|
||||
userNames.push(n);
|
||||
if (typeof u === 'object' && u) {
|
||||
userTimeMap.set(n, {
|
||||
created_at: u.created_at || undefined,
|
||||
created_at_estimated: !!u.created_at_estimated,
|
||||
last_login_at: u.last_login_at || undefined,
|
||||
last_login_estimated: !!u.last_login_estimated,
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('获取用户列表失败:', e);
|
||||
}
|
||||
@@ -358,6 +425,7 @@ export async function resetConfig() {
|
||||
let allUsers = userNames.map((uname) => ({
|
||||
username: uname,
|
||||
role: 'user',
|
||||
...(userTimeMap.get(uname) || {}),
|
||||
}));
|
||||
const ownerUser = process.env.USERNAME;
|
||||
if (ownerUser) {
|
||||
@@ -369,7 +437,7 @@ export async function resetConfig() {
|
||||
}
|
||||
const adminConfig = {
|
||||
SiteConfig: {
|
||||
SiteName: process.env.SITE_NAME || 'KatelyaTV',
|
||||
SiteName: process.env.SITE_NAME || '米视TV',
|
||||
Announcement:
|
||||
process.env.ANNOUNCEMENT ||
|
||||
'本网站仅提供影视信息搜索服务,所有内容均来自第三方网站。本站不存储任何视频资源,不对任何内容的准确性、合法性、完整性负责。',
|
||||
|
||||
@@ -349,6 +349,10 @@ export class RedisStorage implements IStorage {
|
||||
return match ? ensureString(match[1]) : undefined;
|
||||
})
|
||||
.filter((u): u is string => typeof u === 'string');
|
||||
// 站长(owner)不一定有密码记录,但需显示其最后登录时间
|
||||
if (!usernames.includes(ownerUsername)) {
|
||||
usernames.push(ownerUsername);
|
||||
}
|
||||
|
||||
// 获取用户创建时间、最后登录时间并构造 User 对象
|
||||
const users = await Promise.all(
|
||||
|
||||
+4
-1
@@ -37,7 +37,10 @@ export function processImageUrl(originalUrl: string): string {
|
||||
const proxyUrl = getImageProxyUrl();
|
||||
if (!proxyUrl) return originalUrl;
|
||||
|
||||
return `${proxyUrl}${encodeURIComponent(originalUrl)}`;
|
||||
// 代理地址若未自带查询参数(如 /api/image-proxy),补 ?url=,否则拼出的 URL 非法
|
||||
if (proxyUrl.includes('url=')) return `${proxyUrl}${encodeURIComponent(originalUrl)}`;
|
||||
const sep = proxyUrl.includes('?') ? '&' : '?url=';
|
||||
return `${proxyUrl}${sep}${encodeURIComponent(originalUrl)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
// ---------- 第三方采集站分类取数共享模块(源码化) ----------
|
||||
// 各站 maccms 10 协议:?ac=list 取 class 分类;?ac=videolist&t=<type_id>&pg=<页> 取分类数据
|
||||
// 注意:各站 type_id 互不相同(360zy 国产剧=13,lziapi=13,hongniuzy3=12…),
|
||||
// 所以必须先按分类名筛选 type_id,再逐类取数,绝不能写死 ID。
|
||||
|
||||
export interface Site {
|
||||
key: string;
|
||||
name: string;
|
||||
api: string;
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
export const UA =
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36';
|
||||
|
||||
export interface ClassItem {
|
||||
type_id: string;
|
||||
type_name: string;
|
||||
}
|
||||
|
||||
// ---------- 分类名归类规则 ----------
|
||||
export const KIND_RULES: Record<string, { match: string[]; exclude: string[] }> = {
|
||||
// 剧集:连续剧 + 各地区剧(不含动漫/综艺/伦理/解说)
|
||||
tv: {
|
||||
match: ['连续剧', '国产剧', '香港剧', '港澳剧', '韩国剧', '韩剧', '欧美剧', '台湾剧', '日本剧', '日剧', '海外剧', '泰国剧', '短剧', '纪录'],
|
||||
exclude: ['动漫', '动画', '综艺', '伦理', '解说', '预告片', '赛事'],
|
||||
},
|
||||
// 综艺
|
||||
show: {
|
||||
match: ['综艺'],
|
||||
exclude: ['动漫', '动画', '伦理', '解说'],
|
||||
},
|
||||
// 电影:电影/电影片 + 各类型片(排除剧集、动漫、综艺)
|
||||
movie: {
|
||||
match: ['电影', '动作片', '喜剧片', '爱情片', '科幻片', '恐怖片', '剧情片', '战争片', '悬疑片', '犯罪片', '灾难片', '惊悚片', '古装片', '历史片', '家庭片', '西部片', '纪录', '短片', '预告片'],
|
||||
exclude: ['动漫', '动画', '伦理', '解说', '剧集', '连续剧', '综艺', '爽文'],
|
||||
},
|
||||
// 动漫
|
||||
anime: {
|
||||
match: ['动漫', '动画', '卡通'],
|
||||
exclude: ['动漫解说', '动漫周边'],
|
||||
},
|
||||
};
|
||||
|
||||
const classCache = new Map<string, [number, ClassItem[], boolean]>();
|
||||
|
||||
/** 拉某站的分类列表(带缓存;失败时用空数组缓存 30s 避免反复打超时站) */
|
||||
export async function fetchClass(site: Site): Promise<ClassItem[]> {
|
||||
const now = Date.now();
|
||||
const c = classCache.get(site.api);
|
||||
if (c && (c[2] ? now - c[0] < 30000 : now - c[0] < 1800000)) return c[1];
|
||||
|
||||
const mk = async (u: string) => {
|
||||
try {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), 8000);
|
||||
const r = await fetch(u, {
|
||||
headers: { 'User-Agent': UA, Accept: 'application/json' },
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
clearTimeout(t);
|
||||
if (!r.ok) return null;
|
||||
const j = await r.json();
|
||||
if (j && Array.isArray(j.class) && j.class.length)
|
||||
return j.class.map((x: any) => ({
|
||||
type_id: String(x.type_id),
|
||||
type_name: String(x.type_name || ''),
|
||||
}));
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const base = site.api + (site.api.includes('?') ? '&' : '?');
|
||||
const rs = await Promise.all([mk(site.api), mk(base + 'ac=list'), mk(base + 'ac=videolist&pg=1')]);
|
||||
const hit: ClassItem[] = rs.find(Boolean) || [];
|
||||
classCache.set(site.api, [now, hit, !hit.length]);
|
||||
return hit;
|
||||
}
|
||||
|
||||
/** 按 kind(tv/show/movie/anime)筛出该站对应的分类;cat 为可选的进一步细分(如 '国产剧') */
|
||||
export function pickClasses(classes: ClassItem[], kind: string, cat = ''): ClassItem[] {
|
||||
const rule = KIND_RULES[kind] || KIND_RULES.tv;
|
||||
let out = classes.filter(
|
||||
(c) =>
|
||||
rule.match.some((k) => c.type_name.includes(k)) &&
|
||||
!rule.exclude.some((k) => c.type_name.includes(k))
|
||||
);
|
||||
if (cat) {
|
||||
// 支持多关键词('日韩综艺|欧美综艺'),命中任一即保留
|
||||
const keys = cat.split('|').filter(Boolean);
|
||||
const narrowed = out.filter((c) => keys.some((k) => c.type_name.includes(k)));
|
||||
if (narrowed.length) out = narrowed;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 取某站某分类的一页数据 */
|
||||
export async function fetchTypePage(site: Site, tid: string, pg: number): Promise<any[]> {
|
||||
const base = site.api + (site.api.includes('?') ? '&' : '?');
|
||||
const u = `${base}ac=videolist&t=${encodeURIComponent(tid)}&pg=${pg}`;
|
||||
try {
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 12000);
|
||||
const r = await fetch(u, {
|
||||
headers: { 'User-Agent': UA, Accept: 'application/json' },
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
clearTimeout(timer);
|
||||
if (!r.ok) return [];
|
||||
const j = await r.json();
|
||||
return Array.isArray(j?.list) ? j.list : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function epCount(playUrl: string): number {
|
||||
if (!playUrl) return 1;
|
||||
let max = 0;
|
||||
String(playUrl)
|
||||
.split('$$$')
|
||||
.forEach((g) => {
|
||||
const n = g.split('#').filter((s) => s.trim()).length;
|
||||
if (n > max) max = n;
|
||||
});
|
||||
return max > 0 ? max : 1;
|
||||
}
|
||||
|
||||
/** 统一映射为前端 VideoCard 可用的结构 */
|
||||
export function mapItem(item: any, site: Site) {
|
||||
return {
|
||||
id: String(item.vod_id),
|
||||
title: String(item.vod_name || '').trim().replace(/\s+/g, ' '),
|
||||
poster: item.vod_pic || '',
|
||||
episodes: epCount(item.vod_play_url),
|
||||
source: site.key,
|
||||
source_name: site.name,
|
||||
year: (item.vod_year && String(item.vod_year).match(/\d{4}/)?.[0]) || '',
|
||||
area: item.vod_area || '',
|
||||
type_name: item.type_name || '',
|
||||
douban_id: item.vod_douban_id,
|
||||
};
|
||||
}
|
||||
|
||||
/** 单站取数:按 kind/cat 筛分类 -> 逐类取一页 -> 返回条目与是否有下一页 */
|
||||
export async function fetchSiteKind(site: Site, kind: string, cat: string, pg: number) {
|
||||
const classes = await fetchClass(site);
|
||||
const targets = pickClasses(classes, kind, cat);
|
||||
if (!targets.length) return { items: [] as any[], hasMore: false };
|
||||
const pages = await Promise.all(targets.map((c) => fetchTypePage(site, c.type_id, pg)));
|
||||
const items: any[] = [];
|
||||
let hasMore = false;
|
||||
pages.forEach((list) => {
|
||||
if (list.length >= 20) hasMore = true;
|
||||
list.forEach((it) => items.push(it));
|
||||
});
|
||||
return { items, hasMore };
|
||||
}
|
||||
+8
-4
@@ -49,12 +49,13 @@ export async function middleware(request: NextRequest) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// 首次访问不再强制跳转 /ipv6 选线路页:首页直接加载数据,线路由顶栏「IPV4/IPV6」切换
|
||||
|
||||
const storageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
|
||||
|
||||
if (!process.env.AUTH_PASSWORD) {
|
||||
// 如果没有设置密码,重定向到警告页面
|
||||
const warningUrl = new URL('/warning', request.url);
|
||||
return NextResponse.redirect(warningUrl);
|
||||
// 未配置 AUTH_PASSWORD 时直接放行,不强制访问控制
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// 从cookie获取认证信息
|
||||
@@ -170,6 +171,9 @@ function shouldSkipAuth(pathname: string): boolean {
|
||||
'/api/tvbox',
|
||||
'/api/filter',
|
||||
'/api/license-config',
|
||||
'/api/douban-comments',
|
||||
'/api/douban-detail',
|
||||
'/api/douban-related',
|
||||
];
|
||||
|
||||
return skipPaths.some((path) => pathname.startsWith(path));
|
||||
@@ -178,6 +182,6 @@ function shouldSkipAuth(pathname: string): boolean {
|
||||
// 配置middleware匹配规则
|
||||
export const config = {
|
||||
matcher: [
|
||||
'/((?!_next/static|_next/image|favicon.ico|login|warning|hls.min.js|mpegts.min.js|api/login|api/register|api/logout|api/cron|api/server-config|api/search|api/detail|api/image-proxy|api/license-config).*)',
|
||||
'/((?!_next/static|_next/image|favicon.ico|login|warning|hls.min.js|mpegts.min.js|api/login|api/register|api/logout|api/cron|api/server-config|api/search|api/detail|api/image-proxy|api/license-config|api/douban-comments|api/douban-detail|api/douban-related).*)',
|
||||
],
|
||||
};
|
||||
Reference in new issue
Block a user