Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d84fd23918 | ||
|
|
2e8ee2eb64 | ||
|
|
5c77b39239 | ||
|
|
7b27de7551 |
No files matched your search
+1
-1
@@ -51,7 +51,7 @@ ENV NODE_ENV=production
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV PORT=3000
|
||||
ENV DOCKER_ENV=true
|
||||
ENV NEXT_PUBLIC_SITE_VERSION=fixed68
|
||||
ENV NEXT_PUBLIC_SITE_VERSION=fixed71
|
||||
|
||||
# 从构建器中复制 standalone 输出
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
|
||||
@@ -48,29 +48,35 @@ async function fetchClass(api: string): Promise<any[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
// t=902(香港剧 direct)→ 源站真实 id;t=901(香港电影 agg)→ 源站电影 id + area=香港过滤
|
||||
async function resolveTop(sources: SrcCfg[], sp: URLSearchParams): Promise<{ extraArea: string }> {
|
||||
// t=901-907(顶层分类)→ 每个源各自的真实 type_id(各源分类表不同,不能拿第一个源的 id 发给全源)
|
||||
// t=902(香港剧):源站有“香港剧”类目则直取;没有则取电视剧类目 + area=香港 过滤,保证只出香港剧
|
||||
async function resolveTopPerSource(sources: SrcCfg[], sp: URLSearchParams): Promise<{ extraArea: string; nativeByApi: Map<string, string> }> {
|
||||
const t = sp.get('t');
|
||||
if (!t || !/^90[1-9]$/.test(t) || sp.get('wd')) return { extraArea: '' };
|
||||
const first = sources[0];
|
||||
if (!first) return { extraArea: '' };
|
||||
const cls = await fetchClass(first.api);
|
||||
const byN: Record<string, any> = {};
|
||||
cls.forEach((c) => { if (c && c.type_name != null) byN[String(c.type_name).trim()] = c; });
|
||||
const fd = (...names: string[]) => { for (const n of names) if (byN[n]) return byN[n]; return null; };
|
||||
const mv = fd('电影', '电影片');
|
||||
const tv = fd('连续剧', '电视剧', '剧集');
|
||||
const vy = fd('综艺', '综艺片');
|
||||
const an = fd('动漫', '动漫片');
|
||||
const to = fd('动画片', '动画电影', '动漫电影');
|
||||
const hk = fd('香港剧', '港澳剧', '港台剧', '港剧');
|
||||
const nat: Record<string, any> = { '901': mv, '902': hk, '903': mv, '904': tv, '905': vy, '906': to, '907': an };
|
||||
const hit = nat[t];
|
||||
if (hit) {
|
||||
sp.set('t', String(hit.type_id));
|
||||
if (t === '901') { sp.set('area', '香港'); return { extraArea: '香港' }; }
|
||||
}
|
||||
return { extraArea: '' };
|
||||
const nativeByApi = new Map<string, string>();
|
||||
if (!t || !/^90[1-9]$/.test(t) || sp.get('wd') || sp.get('ids')) return { extraArea: '', nativeByApi };
|
||||
const classes = await Promise.all(sources.map((s) => fetchClass(s.api)));
|
||||
sources.forEach((s, i) => {
|
||||
const byN: Record<string, any> = {};
|
||||
(classes[i] || []).forEach((c) => { if (c && c.type_name != null) byN[String(c.type_name).trim()] = c; });
|
||||
const fd = (...names: string[]) => { for (const n of names) if (byN[n]) return byN[n]; return null; };
|
||||
const mv = fd('电影', '电影片');
|
||||
const tv = fd('连续剧', '电视剧', '剧集');
|
||||
const vy = fd('综艺', '综艺片');
|
||||
const an = fd('动漫', '动漫片');
|
||||
const to = fd('动画片', '动画电影', '动漫电影');
|
||||
const hk = fd('香港剧', '港澳剧', '港台剧', '港剧');
|
||||
let hit = null;
|
||||
if (t === '901') hit = mv;
|
||||
else if (t === '902') hit = hk || tv;
|
||||
else if (t === '903') hit = mv;
|
||||
else if (t === '904') hit = tv;
|
||||
else if (t === '905') hit = vy;
|
||||
else if (t === '906') hit = to;
|
||||
else if (t === '907') hit = an;
|
||||
if (hit) nativeByApi.set(s.api, String(hit.type_id));
|
||||
});
|
||||
if (t === '901' || t === '902') return { extraArea: '香港', nativeByApi };
|
||||
return { extraArea: '', nativeByApi };
|
||||
}
|
||||
|
||||
async function aggregateAll(sources: SrcCfg[], sp: URLSearchParams) {
|
||||
@@ -96,15 +102,23 @@ async function aggregateAll(sources: SrcCfg[], sp: URLSearchParams) {
|
||||
return out;
|
||||
}
|
||||
|
||||
let q = 'ac=videolist&pg=' + pg;
|
||||
if (wd) q += '&wd=' + encodeURIComponent(wd);
|
||||
// 顶层 9xx 分类先映射到源站真实 type_id(旧补丁 P() tops 逻辑)
|
||||
const { extraArea } = await resolveTop(srcs, sp);
|
||||
const t2 = sp.get('t');
|
||||
if (t2) q += '&t=' + encodeURIComponent(t2);
|
||||
['st', 'year', 'area', 'by'].forEach((k) => { const v = sp.get(k); if (v) q += '&' + k + '=' + encodeURIComponent(v); });
|
||||
// 顶层 9xx 分类:每个源用自己的真实 type_id 查询(旧补丁 P() tops 逻辑,源码化时按源分别映射)
|
||||
const topT = sp.get('t');
|
||||
const isTop = topT && /^90[1-9]$/.test(topT) && !wd && !ids;
|
||||
const { extraArea, nativeByApi } = isTop
|
||||
? await resolveTopPerSource(srcs, sp)
|
||||
: { extraArea: '', nativeByApi: new Map<string, string>() };
|
||||
const baseExtra = ['st', 'year', 'area', 'by'].map((k) => { const v = sp.get(k); return v ? '&' + k + '=' + encodeURIComponent(v) : ''; }).join('');
|
||||
const queries = srcs.map((s) => {
|
||||
let q = 'ac=videolist&pg=' + pg;
|
||||
if (wd) q += '&wd=' + encodeURIComponent(wd);
|
||||
const nt = isTop ? nativeByApi.get(s.api) : topT;
|
||||
if (nt) q += '&t=' + encodeURIComponent(nt);
|
||||
q += baseExtra;
|
||||
return q;
|
||||
});
|
||||
|
||||
const results = await Promise.all(srcs.map((s) => subFetch(s.api, q)));
|
||||
const results = await Promise.all(srcs.map((s, i) => subFetch(s.api, queries[i])));
|
||||
const seen: Record<string, number> = {};
|
||||
let list: any[] = [];
|
||||
results.forEach((d, i) => {
|
||||
@@ -117,10 +131,20 @@ async function aggregateAll(sources: SrcCfg[], sp: URLSearchParams) {
|
||||
}
|
||||
});
|
||||
list.sort((a, b) => String(b.vod_time == null ? '' : b.vod_time).localeCompare(String(a.vod_time == null ? '' : a.vod_time)));
|
||||
// 902 香港剧硬性过滤:只保留地区含“香港”的条目(兜底:无地区但名字命中的保留,避免误杀)
|
||||
if (topT === '902') {
|
||||
const hkPat = /港剧|粤语|TVB|邵氏|香港/i;
|
||||
list = list.filter((x) => {
|
||||
const area = String(x.vod_area || '');
|
||||
if (area.indexOf('香港') >= 0 || area === '香港') return true;
|
||||
if (!area && hkPat.test(String(x.vod_name || ''))) return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
const fy = sp.get('year');
|
||||
const fa = sp.get('area') || extraArea;
|
||||
if (fy) list = list.filter((x) => String(x.vod_year || '').indexOf(fy) >= 0);
|
||||
if (fa) list = list.filter((x) => String(x.vod_area || '').indexOf(fa) >= 0);
|
||||
if (fa && topT !== '902') list = list.filter((x) => String(x.vod_area || '').indexOf(fa) >= 0);
|
||||
list = list.slice(0, 300);
|
||||
out.list = list; out.total = list.length; out.limit = list.length;
|
||||
const rep = results.find((d) => d && Array.isArray(d.class) && d.class.length);
|
||||
|
||||
@@ -12,8 +12,11 @@ type VodItem = {
|
||||
vod_time?: string;
|
||||
};
|
||||
|
||||
const SHOW_COUNT = 10;
|
||||
|
||||
export default function HkDramaRow() {
|
||||
const [items, setItems] = useState<VodItem[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/tvbox/all?ac=videolist&t=902&pg=1&by=time')
|
||||
@@ -28,12 +31,14 @@ export default function HkDramaRow() {
|
||||
String(a.vod_time || '')
|
||||
);
|
||||
});
|
||||
setItems(arr.slice(0, 5));
|
||||
setItems(arr.slice(0, SHOW_COUNT));
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch(() => {})
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
if (!items.length) return null;
|
||||
// 加载失败且无数据时不占位;加载中显示骨架占位,与其它栏目同时出现
|
||||
if (!loading && !items.length) return null;
|
||||
|
||||
return (
|
||||
<section className='mb-8'>
|
||||
@@ -49,7 +54,17 @@ export default function HkDramaRow() {
|
||||
</Link>
|
||||
</div>
|
||||
<div className='grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 relative'>
|
||||
{items.map((v) => {
|
||||
{loading
|
||||
? // 加载中显示10个占位,与热门电影/剧集同时出现,避免后半拍跳动
|
||||
Array.from({ length: SHOW_COUNT }).map((_, index) => (
|
||||
<div key={index} className='w-full'>
|
||||
<div className='relative aspect-[2/3] w-full overflow-hidden rounded-lg bg-purple-200 animate-pulse dark:bg-purple-800'>
|
||||
<div className='absolute inset-0 bg-purple-300 dark:bg-purple-700'></div>
|
||||
</div>
|
||||
<div className='mt-2 h-4 bg-purple-200 rounded animate-pulse dark:bg-purple-800'></div>
|
||||
</div>
|
||||
))
|
||||
: items.map((v) => {
|
||||
const key = String(v.vod_id || '');
|
||||
const sep = key.indexOf(':');
|
||||
const ks = sep > 0 ? key.slice(0, sep) : '';
|
||||
|
||||
@@ -37,7 +37,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 || 'fixed68'}
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed71'}
|
||||
</span>
|
||||
<HubBell />
|
||||
<TvboxButton />
|
||||
|
||||
@@ -34,6 +34,16 @@ export async function middleware(request: NextRequest) {
|
||||
});
|
||||
}
|
||||
|
||||
// 访问日志(源码化,替代旧 patches/patch_access_log.js 运行时注入 next 内部 start-server):
|
||||
// middleware 覆盖全部路由请求,跳过静态资源
|
||||
if (pathname.indexOf('/_next/static') !== 0 && pathname !== '/favicon.ico') {
|
||||
const ua = (request.headers.get('user-agent') || '-').slice(0, 90);
|
||||
const ref = request.headers.get('referer');
|
||||
console.log(
|
||||
`[ACCESS] ${new Date().toISOString()} ip=${ip} ${request.method} ${fullUrl} ua=${JSON.stringify(ua)}${ref ? ` ref=${ref.slice(0, 80)}` : ''}`
|
||||
);
|
||||
}
|
||||
|
||||
// 跳过不需要认证的路径
|
||||
if (shouldSkipAuth(pathname)) {
|
||||
return NextResponse.next();
|
||||
|
||||
Reference in new issue
Block a user