Compare commits

...
7 Commits
Author SHA1 Message Date
谢宇宁 9b418929e2 修改关闭按钮逻辑 2026-10-29 20:00:37 +07:00
谢宇宁 faf1b3d210 广告点击添加 2026-10-29 16:37:54 +07:00
谢宇宁 654257a2d2 广告修改 2026-10-28 17:07:32 +07:00
谢宇宁 d5d28c92ce yandex和google统计修改 2026-10-26 21:28:11 +07:00
谢宇宁 ff95c1bdbd 更新脚本修改,福利应用删除 2026-10-26 21:14:28 +07:00
谢宇宁 d2c8c63a36 福利应用删除 2026-10-26 20:31:41 +07:00
root 6c66b792aa 部署 2026-10-26 21:00:16 +08:00
73 changed files with 725 additions and 1128 deletions
+2
View File
@@ -25,7 +25,9 @@
/dist.zip
/dist.zip.sha256
/web_hjsq_h5.tar.gz
/web_hghl_h5.tar.gz
/web_hjsq_h5.md5
/web_hghl_h5.md5
config/*.local.env
# misc
+1 -1
View File
@@ -1,6 +1,6 @@
APP_ENV=production
NEXT_PUBLIC_API_BASE_URL=
API_PROXY_TARGET=https://webhghlapi.mfcg.me
PORT=3000
PORT=20123
NEXT_PUBLIC_SITE_URL=https://huangguohl.com
NEXT_PUBLIC_APP_VERSION=1.0.0
+161 -43
View File
@@ -1,23 +1,23 @@
#!/bin/bash
# 正式服:构建 → Linux 运行包 + MD5 → 跳板机 running.sh(对齐 hkdj-web)。
# 黄果黑料正式服:构建 → Linux 运行包 + MD5 → 上传 → 切换 next/ → Supervisor 重启 → 健康检查(失败回滚)。
# 本地打包沿用上一版(对齐 hkdj-web);服务器沿用现有结构:next/ + next.prev/,Supervisor 程序 web_hghl_h5(端口以其配置为准)。
set -euo pipefail
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
cd "$SCRIPT_DIR"
JUMP_HOST="${DEPLOY_JUMP_HOST:-server@34.92.204.175}"
JUMP_DIR="${DEPLOY_JUMP_DIR:-/home/server/web_hjsq/h5}"
SCP_PORT="${DEPLOY_SCP_PORT:-22889}"
SSH_PORT="${DEPLOY_SSH_PORT:-22889}"
REMOTE_SCRIPT="${DEPLOY_REMOTE_SCRIPT:-rsupdate.sh}"
SSH_IDENTITY="${DEPLOY_SSH_IDENTITY:-$HOME/.ssh/id_ed25519}"
HOST="${DEPLOY_HOST:-root@172.104.166.87}"
SSH_PORT="${DEPLOY_SSH_PORT:-22}"
REMOTE_DIR="${DEPLOY_DIR:-/server/web_hghl/h5}"
PROGRAM="${DEPLOY_PROGRAM:-web_hghl_h5}"
TARGET_ARCH="${DEPLOY_TARGET_ARCH:-x64}"
TARGET_LIBC="${DEPLOY_TARGET_LIBC:-glibc}"
PACKAGE_NAME=web_hjsq_h5.tar.gz
MD5_NAME=web_hjsq_h5.md5
PACKAGE_NAME=web_hghl_h5.tar.gz
MD5_NAME=web_hghl_h5.md5
PACKAGE="$SCRIPT_DIR/$PACKAGE_NAME"
MD5_FILE="$SCRIPT_DIR/$MD5_NAME"
RELEASE="$SCRIPT_DIR/dist/production-linux-$TARGET_ARCH-$TARGET_LIBC"
PACKAGE_ONLY=0
DRY_RUN=0
fail() { printf '错误:%s\n' "$*" >&2; exit 1; }
step() { printf '\n▸ %s\n' "$*"; }
@@ -25,24 +25,22 @@ step() { printf '\n▸ %s\n' "$*"; }
for argument in "$@"; do
case "$argument" in
--) ;;
--dry-run) DEPLOY_DRY_RUN=1 ;;
--dry-run) DRY_RUN=1 ;;
--package-only) PACKAGE_ONLY=1 ;;
-h|--help)
printf '用法:%s [--dry-run | --package-only]\n' "$0"
printf '默认跳板:%s 端口 %s,远程脚本 %s\n' "$JUMP_HOST" "$SCP_PORT" "$REMOTE_SCRIPT"
printf '可选:DEPLOY_JUMP_HOST / DEPLOY_JUMP_DIR / DEPLOY_SCP_PORT / DEPLOY_SSH_PORT\n'
printf ' DEPLOY_REMOTE_SCRIPT / DEPLOY_SSH_IDENTITY / DEPLOY_TARGET_ARCH / DEPLOY_TARGET_LIBC\n'
printf '默认上传 %s:%s/,切换 next/ 后重启 Supervisor 程序 %s。\n' "$HOST" "$REMOTE_DIR" "$PROGRAM"
printf '可覆盖 DEPLOY_HOST、DEPLOY_SSH_PORT、DEPLOY_DIR、DEPLOY_PROGRAM、DEPLOY_TARGET_ARCH、DEPLOY_TARGET_LIBC。\n'
exit 0 ;;
*) fail "不支持的参数 $argument;使用 --help 查看用法" ;;
*) fail "不支持的参数 ${argument};使用 --help 查看用法" ;;
esac
done
[[ "$JUMP_HOST" =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.@-]*$ ]] || fail 'DEPLOY_JUMP_HOST 格式无效'
[[ "$JUMP_DIR" =~ ^/[a-zA-Z0-9_-]+(/[a-zA-Z0-9_-]+)*/?$ ]] || fail 'DEPLOY_JUMP_DIR 必须是普通绝对路径'
JUMP_DIR="${JUMP_DIR%/}"
for port in "$SCP_PORT" "$SSH_PORT"; do
[[ "$port" =~ ^[0-9]+$ ]] && [ "$port" -ge 1 ] && [ "$port" -le 65535 ] || fail 'SCP/SSH 端口必须在 1–65535 内'
done
[[ "$HOST" =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.@-]*$ ]] || fail 'DEPLOY_HOST 格式无效'
[[ "$REMOTE_DIR" =~ ^/[a-zA-Z0-9_-]+(/[a-zA-Z0-9_-]+)*/?$ ]] || fail 'DEPLOY_DIR 必须是普通绝对路径'
REMOTE_DIR="${REMOTE_DIR%/}"
[[ "$PROGRAM" =~ ^[a-zA-Z0-9_-]+$ ]] || fail 'DEPLOY_PROGRAM 格式无效'
[[ "$SSH_PORT" =~ ^[0-9]+$ ]] && [ "$SSH_PORT" -ge 1 ] && [ "$SSH_PORT" -le 65535 ] || fail 'SSH 端口必须在 1–65535 内'
case "$TARGET_ARCH" in x64|arm64) ;; *) fail 'DEPLOY_TARGET_ARCH 仅支持 x64 或 arm64' ;; esac
case "$TARGET_LIBC" in glibc|musl) ;; *) fail 'DEPLOY_TARGET_LIBC 仅支持 glibc 或 musl' ;; esac
@@ -56,28 +54,26 @@ for file in config/production.env package.json scripts/prepare-production-runtim
done
[ -x node_modules/.bin/tsx ] || fail '请先执行 pnpm install'
if [ "${DEPLOY_DRY_RUN:-0}" = 1 ]; then
printf 'DRY RUN:正式环境;Linux %s/%s\n' "$TARGET_ARCH" "$TARGET_LIBC"
node --input-type=module -e 'import {readFileSync} from "node:fs"; import {parse} from "dotenv"; const c=parse(readFileSync("config/production.env")); console.log(` PORT=${c.PORT} API=${c.API_PROXY_TARGET||c.NEXT_PUBLIC_API_BASE_URL}`)'
printf ' pnpm build → bundle → bundle:linux -- %s %s\n' "$TARGET_ARCH" "$TARGET_LIBC"
printf ' 生成 %s + %s\n' "$PACKAGE_NAME" "$MD5_NAME"
if [ "$PACKAGE_ONLY" = 1 ]; then
printf ' --package-only:生成后结束,不上传。\n'
else
printf ' scp -P %s → %s:%s/\n' "$SCP_PORT" "$JUMP_HOST" "$JUMP_DIR"
printf ' ssh -p %s %s bash %s/%s\n' "$SSH_PORT" "$JUMP_HOST" "$JUMP_DIR" "$REMOTE_SCRIPT"
if [ "$DRY_RUN" = 1 ]; then
printf 'DRY RUN:正式环境;Linux %s/%s;只核对,不构建、不连接服务器。\n' "$TARGET_ARCH" "$TARGET_LIBC"
node --input-type=module -e 'import {readFileSync} from "node:fs"; import {parse} from "dotenv"; const c=parse(readFileSync("config/production.env")); console.log(` PORT=${c.PORT} API=${c.API_PROXY_TARGET||c.NEXT_PUBLIC_API_BASE_URL} SITE=${c.NEXT_PUBLIC_SITE_URL}`)'
printf ' pnpm build → bundle → bundle:linux -- %s %s → %s + %s\n' "$TARGET_ARCH" "$TARGET_LIBC" "$PACKAGE_NAME" "$MD5_NAME"
if [ "$PACKAGE_ONLY" = 0 ]; then
printf ' scp → %s:%s/;解压到 next.new,保留服务器上的 *.local.env\n' "$HOST" "$REMOTE_DIR"
printf ' next → next.prev,next.new → next;不改动已有 Supervisor 配置,restart %s;/healthz 失败则回滚\n' "$PROGRAM"
fi
exit 0
fi
if [ "$PACKAGE_ONLY" = 0 ]; then
for tool in ssh scp tee; do command -v "$tool" >/dev/null || fail "缺少命令 $tool"; done
[ -f "$SSH_IDENTITY" ] || fail "缺少 SSH 私钥:$SSH_IDENTITY"
for tool in ssh scp; do command -v "$tool" >/dev/null || fail "缺少命令 $tool"; done
fi
SSH=(ssh -p "$SSH_PORT" -o ConnectTimeout=15 "$HOST")
# 同仓库只允许一次构建/上传,避免并发覆盖同名包。
mkdir -p "$SCRIPT_DIR/dist"
DEPLOY_LOCK="$SCRIPT_DIR/dist/.production-deploy.lock"
mkdir "$DEPLOY_LOCK" 2>/dev/null || fail "已有正式发布进程或残留锁:${DEPLOY_LOCK}"
mkdir "$DEPLOY_LOCK" 2>/dev/null || fail "已有正式发布进程或残留锁:${DEPLOY_LOCK};请先确认该进程已结束"
trap 'rmdir "$DEPLOY_LOCK" 2>/dev/null || true' EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
@@ -88,14 +84,22 @@ pnpm run bundle
step "准备 Linux $TARGET_ARCH/$TARGET_LIBC 运行包"
pnpm run bundle:linux -- "$TARGET_ARCH" "$TARGET_LIBC"
for file in start.mjs server.js .next/BUILD_ID config/production.env runtime-target.json ecosystem.config.cjs; do
for file in start.mjs server.js .next/BUILD_ID config/production.env runtime-target.json; do
[ -s "$RELEASE/$file" ] || fail "正式运行包缺少 $file"
done
for directory in node_modules .next/static public; do
[ -d "$RELEASE/$directory" ] || fail "正式运行包缺少目录 $directory"
done
# 软链必须是相对路径,指向本机绝对路径的软链上传到服务器后会失效(Cannot find module)
ABSOLUTE_LINKS=$(find "$RELEASE" -type l -lname '/*' | head -n 5)
[ -z "$ABSOLUTE_LINKS" ] || fail "运行包含有指向本机绝对路径的软链:
$ABSOLUTE_LINKS"
BROKEN_LINKS=$(find -L "$RELEASE" -type l | head -n 5)
[ -z "$BROKEN_LINKS" ] || fail "运行包含有失效软链:
$BROKEN_LINKS"
step "打包 $PACKAGE_NAME"
# -C 保持产物直接位于 tar 根部;禁止 AppleDouble、环境覆盖和日志混入。
COPYFILE_DISABLE=1 COPY_EXTENDED_ATTRIBUTES_DISABLE=1 tar \
--no-xattrs \
--exclude='._*' --exclude='.DS_Store' --exclude='.env*' \
@@ -108,15 +112,129 @@ else
md5 -q "$PACKAGE" > "$MD5_FILE"
fi
tar -tzf "$PACKAGE" >/dev/null
printf '运行包已生成:%s;校验:%s\n' "$PACKAGE_NAME" "$MD5_NAME"
node -e 'console.log(`运行包已生成,体积 ${(require("node:fs").statSync(process.argv[1]).size / 1024 / 1024).toFixed(2)} MiB`)' "$PACKAGE"
if [ "$PACKAGE_ONLY" = 1 ]; then exit 0; fi
SSH_OPTS=(-i "$SSH_IDENTITY" -o IdentitiesOnly=yes -o BatchMode=yes)
step "上传到跳板机 $JUMP_HOST:$JUMP_DIR/"
scp -P "$SCP_PORT" "${SSH_OPTS[@]}" "$PACKAGE" "$JUMP_HOST:$JUMP_DIR/"
step "执行正式服 $REMOTE_SCRIPT"
RUN_LOG=$(mktemp "$SCRIPT_DIR/dist/production-running.XXXXXX")
if ! ssh -p "$SSH_PORT" "${SSH_OPTS[@]}" "$JUMP_HOST" "bash $JUMP_DIR/$REMOTE_SCRIPT" 2>&1 | tee "$RUN_LOG"; then
fail "正式服 $REMOTE_SCRIPT 执行失败;日志:${RUN_LOG}"
step "上传到 $HOST:$REMOTE_DIR/"
"${SSH[@]}" "mkdir -p '$REMOTE_DIR'"
scp -P "$SSH_PORT" "$PACKAGE" "$MD5_FILE" "$HOST:$REMOTE_DIR/"
step "切换版本并重启 $PROGRAM"
"${SSH[@]}" "bash -s -- '$REMOTE_DIR' '$PROGRAM' '$PACKAGE_NAME' '$MD5_NAME'" <<'REMOTE'
set -euo pipefail
DIR=$1 PROGRAM=$2 PACKAGE=$3 MD5=$4
cd "$DIR"
for tool in md5sum tar curl supervisorctl; do
command -v "$tool" >/dev/null || { echo "服务器缺少命令 $tool"; exit 1; }
done
# ssh 非登录 shell 不加载 nvm 等环境:依次找 PATH、同机花魁的 Supervisor 配置、nvm、常见安装目录
find_node() {
command -v node 2>/dev/null && return 0
local from_conf
from_conf=$(sed -n 's/^command=\([^ ]*node\) .*/\1/p' /etc/supervisor/conf.d/*.conf 2>/dev/null | head -n 1)
[ -n "$from_conf" ] && [ -x "$from_conf" ] && { echo "$from_conf"; return 0; }
local candidate
for candidate in /root/.nvm/versions/node/*/bin/node /usr/local/bin/node /usr/bin/node /opt/node*/bin/node; do
[ -x "$candidate" ] && { echo "$candidate"; return 0; }
done
return 1
}
NODE_BIN=$(find_node) || { echo "服务器上找不到 node(Node.js >=20.9),请先安装"; exit 1; }
echo "使用 node:$NODE_BIN($("$NODE_BIN" -v))"
[ "$(md5sum "$PACKAGE" | awk '{print $1}')" = "$(tr -d '[:space:]' < "$MD5")" ] || { echo "MD5 校验失败"; exit 1; }
# 目录沿用服务器现有结构(与 deploy/up_next_h5.sh 一致):next/ 为当前版本,next.prev/ 为上一版
CURRENT=next PREVIOUS=next.prev STAGING=next.new
CONF="/etc/supervisor/conf.d/$PROGRAM.conf"
# 自愈:之前误写过指向 app/ 的配置时,恢复最近一次备份(原配置)
if [ -f "$CONF" ] && grep -qx "directory=$DIR/app" "$CONF"; then
LATEST_BACKUP=$(ls -t "$CONF".bak.* 2>/dev/null | head -n 1 || true)
if [ -n "$LATEST_BACKUP" ] && grep -qx "directory=$DIR/$CURRENT" "$LATEST_BACKUP"; then
cp -p "$LATEST_BACKUP" "$CONF"
echo "已从 $LATEST_BACKUP 恢复原 Supervisor 配置"
fi
fi
printf '\n正式服发布完成;日志:%s\n' "$RUN_LOG"
# 清理之前误建的 app 系列目录(服务器原本没有)
rm -rf app app.new app.prev app.failed
rm -rf "$STAGING" && mkdir "$STAGING"
tar -xzf "$PACKAGE" -C "$STAGING"
[ -s "$STAGING/start.mjs" ] && [ -s "$STAGING/.next/BUILD_ID" ] || { echo "运行包内容不完整"; exit 1; }
# 服务器上的本地覆盖配置优先于包内文件,且不随发布丢失。
if [ -d "$CURRENT" ]; then
for file in "$CURRENT"/config/*.local.env; do [ -f "$file" ] && cp -p "$file" "$STAGING/config/"; done
fi
# 已有 Supervisor 配置不改动;端口以配置里的 PORT 为准(进程环境变量优先于包内 production.env)
PACKAGE_PORT=$(sed -n 's/^PORT=//p' "$STAGING/config/production.env" | tail -n 1)
if [ -f "$CONF" ]; then
PORT=$(grep -o 'PORT="[0-9]*"' "$CONF" | head -n 1 | grep -o '[0-9]*' || true)
PORT=${PORT:-$PACKAGE_PORT}
[ "$PORT" = "$PACKAGE_PORT" ] || echo "提示:Supervisor 配置端口 $PORT 与包内 PORT=$PACKAGE_PORT 不同,以配置为准"
else
PORT=${PACKAGE_PORT:-20123}
cat > "$CONF" <<CONF
[program:$PROGRAM]
directory=$DIR/$CURRENT
command=$NODE_BIN $DIR/$CURRENT/start.mjs
environment=HOSTNAME="0.0.0.0",PORT="$PORT",APP_ENV="production",NODE_ENV="production",PATH="/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
autostart=true
autorestart=true
startsecs=5
stopasgroup=true
killasgroup=true
stopwaitsecs=15
stdout_logfile=/var/log/$PROGRAM.log
stderr_logfile=/var/log/${PROGRAM}_error.log
stdout_logfile_maxbytes=500MB
stdout_logfile_backups=5
CONF
echo "首次部署:已创建 Supervisor 配置 $CONF"
fi
rm -rf "$PREVIOUS"
[ -d "$CURRENT" ] && mv "$CURRENT" "$PREVIOUS"
mv "$STAGING" "$CURRENT"
supervisorctl reread >/dev/null && supervisorctl update >/dev/null
supervisorctl restart "$PROGRAM" >/dev/null || true
healthy() {
for _ in $(seq 1 30); do
if curl -fsS -m 4 "http://127.0.0.1:$PORT/healthz" 2>/dev/null | grep -q '"status":"ok"'; then return 0; fi
sleep 2
done
return 1
}
diagnose() {
echo "---- 诊断信息 ----"
supervisorctl status "$PROGRAM" || true
local pid
pid=$(supervisorctl pid "$PROGRAM" 2>/dev/null | grep -E '^[0-9]+$' || true)
if [ -n "$pid" ] && command -v ss >/dev/null; then
echo "进程 pid=$pid 实际监听:"
ss -ltnpH 2>/dev/null | grep "pid=$pid," | awk '{print " " $4}' || true
fi
echo "最近错误日志:"
tail -n 30 "/var/log/${PROGRAM}_error.log" 2>/dev/null || true
echo "最近输出日志:"
tail -n 200 "/var/log/$PROGRAM.log" 2>/dev/null | grep -vE "^\s|^\[home/base\]|^}" | tail -n 20 || true
echo "------------------"
}
if healthy && curl -fsS -m 10 -o /dev/null "http://127.0.0.1:$PORT/"; then
supervisorctl status "$PROGRAM"
echo "DEPLOY_OK BUILD_ID=$(cat "$CURRENT/.next/BUILD_ID") PORT=$PORT"
exit 0
fi
echo "新版本健康检查失败(127.0.0.1:$PORT/healthz 无响应)"
diagnose
if [ -d "$PREVIOUS" ]; then
echo "回滚到 $PREVIOUS"
rm -rf next.failed && mv "$CURRENT" next.failed && mv "$PREVIOUS" "$CURRENT"
supervisorctl restart "$PROGRAM" >/dev/null || true
healthy && echo "已回滚并恢复服务;失败版本保留在 next.failed" || echo "回滚后服务仍未恢复,请立即人工检查"
else
echo "没有可回滚的上一版,新版本保留在 $CURRENT/"
fi
exit 1
REMOTE
printf '\n正式服发布完成。\n'
-5
View File
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
# 测试服:委托 scripts/package-test.sh(web_hjsq_h5.tar.gz → scp → run.sh)
set -euo pipefail
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
exec bash "$SCRIPT_DIR/scripts/package-test.sh" "$@"
-3
View File
@@ -1,3 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.60471 11.5419C7.60471 13.3238 6.1602 14.7683 4.37829 14.7683C2.59638 14.7683 1.15186 13.3238 1.15186 11.5419C1.15186 9.75997 2.59638 8.31546 4.37829 8.31546H6.52923H7.60471V9.39094V11.5419ZM8.32171 11.5419C8.32171 13.3238 9.76622 14.7683 11.5481 14.7683C13.33 14.7683 14.7746 13.3238 14.7746 11.5419C14.7746 9.75997 13.33 8.31546 11.5481 8.31546H9.39719H8.32171V9.39094V11.5419ZM7.60471 4.37205C7.60471 2.59012 6.1602 1.14563 4.37829 1.14563C2.59638 1.14563 1.15186 2.59012 1.15186 4.37205C1.15186 6.15398 2.59638 7.59847 4.37829 7.59847H6.52923H7.60471V6.52299V4.37205ZM8.32171 4.37205C8.32171 2.59012 9.76622 1.14563 11.5481 1.14563C13.33 1.14563 14.7746 2.59014 14.7746 4.37205C14.7746 6.15396 13.33 7.59847 11.5481 7.59847H9.39719H8.32171V6.52299V4.37205Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 891 B

-3
View File
@@ -1,3 +0,0 @@
<svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.19629 9L0.000136209 -2.51245e-08L10.3924 8.834e-07L5.19629 9Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 191 B

+2 -1
View File
@@ -80,7 +80,8 @@ if (!buildId) throw new Error(`${buildDirectory}/BUILD_ID 为空,请先 pnpm b
await rm(destination, { recursive: true, force: true });
await mkdir(destination, { recursive: true });
await cp(resolve(buildDirectory, "standalone"), destination, { recursive: true });
// verbatimSymlinks:保留 pnpm 的相对软链;默认 cp 会改写成本机绝对路径,上传到服务器后软链失效
await cp(resolve(buildDirectory, "standalone"), destination, { recursive: true, verbatimSymlinks: true });
await cp(resolve("public"), resolve(destination, "public"), { recursive: true });
await cp(
resolve(buildDirectory, "static"),
+2
View File
@@ -108,8 +108,10 @@ for (const entry of packages) {
await rm(target, { recursive: true, force: true });
// 必须保留 standalone/pnpm 软链布局;dereference 会拆掉 @swc/helpers 等嵌套路径
// verbatimSymlinks:软链保持相对路径,否则会被改写成本机绝对路径
await cp(source, target, {
recursive: true,
verbatimSymlinks: true,
filter: (path) => {
const name = basename(path);
if (
+4 -2
View File
@@ -2,15 +2,16 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import Script from "next/script";
import { Suspense } from "react";
import { AdClickReporter } from "@/components/ad/ad-click-reporter";
import { AdDialogSlot } from "@/components/ad/ad-dialog-slot";
import { AddressDialogSlot } from "@/components/address/address-dialog-slot";
import { AgeGateDialogHost } from "@/components/age-gate/age-gate-dialog";
import { SiteAnalytics } from "@/components/analytics/site-analytics";
import { RequestHeadersPrime } from "@/components/api/request-headers-prime";
import { AuthUnauthorizedBridge } from "@/components/auth/auth-unauthorized-bridge";
import { GuestAuthBootstrap } from "@/components/auth/guest-auth-bootstrap";
import { LoginDialogHost } from "@/components/auth/login-dialog";
import { ToastHost } from "@/components/common/toast-host";
import { HomeBaseDebugSlot } from "@/components/debug/home-base-debug-slot";
import { DownloadDialogSlot } from "@/components/download/download-dialog-slot";
import { SiteShell } from "@/components/layout/site-shell";
import { browserCompatScript } from "@/lib/browser/compat-inline";
@@ -94,11 +95,12 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
<RequestHeadersPrime />
</Suspense>
<Suspense fallback={null}>
<HomeBaseDebugSlot />
<SiteAnalytics />
</Suspense>
<SiteShell>{children}</SiteShell>
<GuestAuthBootstrap />
<AuthUnauthorizedBridge />
<AdClickReporter />
<LoginDialogHost />
<Suspense fallback={null}>
<DownloadDialogSlot />
-2
View File
@@ -1,7 +1,6 @@
import type { Metadata } from "next";
import { cache } from "react";
import { HomeDataDebug } from "@/components/home/home-data-debug";
import { HomePage } from "@/components/home/home-page";
import { JsonLd } from "@/components/seo/json-ld";
import { dramaHref } from "@/components/short-drama/data";
@@ -75,7 +74,6 @@ export default async function Home() {
return (
<>
<HomeDataDebug home={merged} base={base} />
<JsonLd
data={buildWebPageJSONLD({
path: "/",
@@ -48,7 +48,7 @@ import {
import type { PlayletThemeItem } from "@/lib/api/types";
import { buildServerForwardHeaders } from "@/lib/api/client-headers";
import { primeRequestForwardHeaders } from "@/lib/api/request-context";
import { AdBannersSlot, AdIconsSlot } from "@/components/common/ads/slots";
import { AdBannersSlot, AdSquaresSlot } from "@/components/common/ads/slots";
import {
buildPlayletDetailJSONLD,
buildPlayletPlayJSONLD,
@@ -387,9 +387,9 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
<DramaDetailPage
detail={mapped.detail}
related={mapped.related}
adIcons={<AdIconsSlot variant="pc" />}
adIcons={<AdSquaresSlot slot="AList" variant="pc" />}
promo={<AdBannersSlot variant="pc" />}
adGrid={<AdIconsSlot variant="h5" />}
adGrid={<AdSquaresSlot slot="AList" variant="h5" />}
bannerAds={<AdBannersSlot variant="h5" />}
/>
</>
@@ -428,8 +428,10 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
episode={play.episode}
src={play.src}
related={play.related}
adIcons={<AdIconsSlot variant="pc" />}
promo={<AdBannersSlot variant="pc" />}
topAds={<AdSquaresSlot slot="AList" variant="pc" />}
h5Ads={<AdSquaresSlot slot="AList" variant="h5" />}
h5Banners={<AdBannersSlot variant="h5" />}
/>
</>
);
+3 -3
View File
@@ -48,7 +48,7 @@ import {
resolvePageMetadata,
} from "@/lib/seo";
import { videoHref } from "@/components/video/video-card";
import { AdBannersSlot, AdIconsSlot } from "@/components/common/ads/slots";
import { AdBannersSlot, AdSquaresSlot } from "@/components/common/ads/slots";
type Params = Promise<{ sort: string; page?: string[] }>;
@@ -307,9 +307,9 @@ async function VideoRouteContent({ params }: { params: Params }) {
detail={mapped.detail}
src={mapped.src}
related={mapped.related}
adIcons={<AdIconsSlot variant="pc" labels={false} />}
promo={<AdBannersSlot variant="pc" />}
adGrid={<AdIconsSlot variant="h5" />}
topAds={<AdSquaresSlot slot="AList" variant="pc" />}
h5Ads={<AdSquaresSlot slot="AList" variant="h5" />}
bannerAds={<AdBannersSlot variant="h5" />}
/>
</>
-58
View File
@@ -1,58 +0,0 @@
import type { Metadata } from "next";
import { Suspense } from "react";
import { PageLoading } from "@/components/common/page-loading";
import { JsonLd } from "@/components/seo/json-ld";
import { WelfarePage } from "@/components/welfare/welfare-page";
import { buildWelfareCategories, type WelfareCategory } from "@/components/welfare/data";
import { getAppListCached } from "@/lib/api/applist";
import { buildWebPageJSONLD, getHomeBaseSEOCached, resolvePageMetadata } from "@/lib/seo";
export async function generateMetadata(): Promise<Metadata> {
return resolvePageMetadata({
seoInfo: {
title: "福利应用",
description: "黄果黑料福利应用与精选推荐。",
keyworld: ["黄果黑料", "福利应用"],
},
canonical: "/welfare",
});
}
async function WelfareContent() {
let categories: WelfareCategory[] = [];
try {
const data = await getAppListCached(0);
categories = buildWelfareCategories(data);
} catch (error) {
console.error("[welfare]", error);
}
const siteSeo = await getHomeBaseSEOCached();
return (
<>
<JsonLd
data={buildWebPageJSONLD({
path: "/welfare",
title: "福利应用",
description: "黄果黑料福利应用与精选推荐。",
type: "CollectionPage",
breadcrumbs: [
["首页", "/"],
["福利应用", "/welfare"],
],
siteName: siteSeo.siteName,
})}
/>
<WelfarePage categories={categories} />
</>
);
}
export default function Page() {
return (
<Suspense fallback={<PageLoading />}>
<WelfareContent />
</Suspense>
);
}
+29
View File
@@ -0,0 +1,29 @@
"use client";
import { useEffect } from "react";
import { adClickPayload, reportAdClick } from "@/lib/api/ads-actions";
import { getAuthToken } from "@/lib/auth/session";
/**
* 全站广告点击上报:document 捕获阶段监听 click / auxclick(中键),
* 命中带 data-ads-id 的元素即异步上报;失败静默,不阻塞也不拦截广告跳转。
*/
export function AdClickReporter() {
useEffect(() => {
const onClick = (event: MouseEvent) => {
if (event.type === "auxclick" && event.button !== 1) return;
const payload = adClickPayload(event.target);
if (!payload) return;
void reportAdClick(payload, getAuthToken()).catch(() => {});
};
document.addEventListener("click", onClick, true);
document.addEventListener("auxclick", onClick, true);
return () => {
document.removeEventListener("click", onClick, true);
document.removeEventListener("auxclick", onClick, true);
};
}, []);
return null;
}
+126 -18
View File
@@ -5,14 +5,22 @@ import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore
import { getAgeGateOpen, subscribeAgeGate } from "@/components/age-gate/age-gate-dialog";
import { DecryptedImage } from "@/components/common/decrypted-image";
import { useChromeless } from "@/components/layout/route-visibility";
import { lockBodyScroll } from "@/lib/browser/scroll-lock";
import { adClickData } from "@/lib/api/ads-actions";
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
/** 对齐 jha-1043 dialogAd.js:签名队列 + session 进度 / 关闭态 */
const QUEUE_VERSION = "2";
const DISMISSED_KEY = "dialogAdDismissed";
const PROGRESS_KEY = "dialogAdProgress";
/** 九宫格弹窗关闭态(按广告内容签名,内容变化后重新弹出) */
const GRID_DISMISSED_KEY = "gridAdDismissed";
let queueIdle = true;
/**
* 启动弹窗链是否已结束(弹窗广告 + 九宫格都处理完)。
* 初始为未结束:等弹窗组件判断完再放行,避免最新地址弹窗抢先和九宫格同时弹出。
*/
let queueIdle = false;
const listeners = new Set<() => void>();
function emit() {
@@ -101,12 +109,27 @@ function rememberProgress(signature: string, index: number) {
writeSession(PROGRESS_KEY, JSON.stringify({ signature, index }));
}
function pickGridAds(advitise?: AdvitiseData | null) {
return (advitise?.nineGridList ?? []).filter((item): item is AdvertiseInfo & { images: string } =>
Boolean(item.images?.trim()),
);
}
function buildGridSignature(ads: AdvertiseInfo[]) {
return ads.length ? JSON.stringify(ads.map((item) => [item.id, item.images, item.link, item.title])) : "";
}
function pickDialogAds(items?: AdvertiseInfo[] | null, advitise?: AdvitiseData | null) {
const source = items ?? advitise?.dialogList ?? [];
return source.filter((item): item is AdvertiseInfo & { images: string } => Boolean(item.images?.trim()));
}
/** 弹窗广告:使用 advitise.dialogList,全站队列展示(对齐 jha-1043) */
/**
* 启动弹窗链(对齐 huangguocg.com):年龄确认 → 弹窗广告 → 九宫格弹窗 → (首页)最新地址。
* 弹窗广告:advitise.dialogList(后台位置 1「弹窗」,素材 600×800),依次展示;
* 九宫格:advitise.nineGridList(后台位置 2「9宫格」,小方块),弹窗广告结束后弹出一次,
* 点任一应用或关闭即不再弹(同一会话、内容不变时)。
*/
export function AdDialogHost({
items,
advitise,
@@ -119,22 +142,41 @@ export function AdDialogHost({
const ads = useMemo(() => pickDialogAds(items, advitise), [items, advitise]);
const signature = useMemo(() => buildSignature(ads), [ads]);
const gridAds = useMemo(() => pickGridAds(advitise), [advitise]);
const gridSignature = useMemo(() => buildGridSignature(gridAds), [gridAds]);
const [index, setIndex] = useState(-1);
const [gridOpen, setGridOpen] = useState(false);
const hasDisplayedRef = useRef(false);
const enabled = !chromeless && !ageGateOpen && ads.length > 0;
const ready = !chromeless && !ageGateOpen;
const enabled = ready && ads.length > 0;
/** 弹窗广告结束(或没有)后:未关闭过九宫格则弹出,否则整条链结束 */
const startGrid = useCallback(() => {
if (gridAds.length && readSession(GRID_DISMISSED_KEY) !== gridSignature) {
setGridOpen(true);
setQueueIdle(false);
return;
}
setGridOpen(false);
setQueueIdle(true);
}, [gridAds.length, gridSignature]);
const dismissGrid = useCallback(() => {
writeSession(GRID_DISMISSED_KEY, gridSignature);
setGridOpen(false);
setQueueIdle(true);
}, [gridSignature]);
useEffect(() => {
let cancelled = false;
void (async () => {
await Promise.resolve();
if (cancelled) return;
if (!enabled) {
if (!ads.length) setQueueIdle(true);
return;
}
if (isAdQueueDone(signature)) {
if (!ready) return;
if (!enabled || isAdQueueDone(signature)) {
setIndex(-1);
setQueueIdle(true);
startGrid();
return;
}
const start = readProgress(signature);
@@ -142,7 +184,7 @@ export function AdDialogHost({
if (hasDisplayedRef.current) writeSession(DISMISSED_KEY, signature);
removeSession(PROGRESS_KEY);
setIndex(-1);
setQueueIdle(true);
startGrid();
return;
}
setIndex(start);
@@ -151,15 +193,15 @@ export function AdDialogHost({
return () => {
cancelled = true;
};
}, [enabled, signature, ads.length]);
}, [ready, enabled, signature, ads.length, startGrid]);
const finishQueue = useCallback(() => {
if (hasDisplayedRef.current) writeSession(DISMISSED_KEY, signature);
else removeSession(DISMISSED_KEY);
removeSession(PROGRESS_KEY);
setIndex(-1);
setQueueIdle(true);
}, [signature]);
startGrid();
}, [signature, startGrid]);
const showNext = useCallback(() => {
setIndex((current) => {
@@ -184,29 +226,43 @@ export function AdDialogHost({
setQueueIdle(false);
}, [index, ads.length, signature]);
useEffect(() => {
if (!gridOpen || index >= 0) return;
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") dismissGrid();
};
const unlockScroll = lockBodyScroll();
window.addEventListener("keydown", onKeyDown);
return () => {
unlockScroll();
window.removeEventListener("keydown", onKeyDown);
};
}, [gridOpen, index, dismissGrid]);
useEffect(() => {
if (index < 0) return;
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") showNext();
};
const { overflow } = document.body.style;
document.body.style.overflow = "hidden";
const unlockScroll = lockBodyScroll();
window.addEventListener("keydown", onKeyDown);
return () => {
document.body.style.overflow = overflow;
unlockScroll();
window.removeEventListener("keydown", onKeyDown);
};
}, [index, showNext]);
const ad = index >= 0 && index < ads.length ? ads[index] : null;
if (!ad?.images) return null;
if (!ad?.images) {
return gridOpen ? <NineGridDialog ads={gridAds} onClose={dismissGrid} /> : null;
}
const picture = (
<DecryptedImage
src={ad.images}
alt={ad.title || "广告"}
priority
className="h-[468px] w-[300px] rounded-3xl object-cover lg:h-[602px] lg:w-[400px] lg:rounded-[40px]"
className="h-[400px] w-[300px] rounded-3xl object-cover lg:h-[560px] lg:w-[420px] lg:rounded-[32px]"
onError={skipBroken}
/>
);
@@ -229,6 +285,7 @@ export function AdDialogHost({
href={ad.link}
target="_blank"
rel="noopener noreferrer sponsored"
{...adClickData(ad)}
className="block"
>
{picture}
@@ -251,3 +308,54 @@ export function AdDialogHost({
</div>
);
}
/** 九宫格弹窗:4 列应用图标宫格 + 底部关闭按钮;点任一应用或空白处即关闭 */
function NineGridDialog({ ads, onClose }: { ads: Array<AdvertiseInfo & { images: string }>; onClose: () => void }) {
return (
<div
data-component="nine-grid-dialog"
className="fixed inset-0 z-50 flex flex-col items-center justify-center bg-black/85 px-6 py-10 backdrop-blur-md"
onClick={(event) => event.target === event.currentTarget && onClose()}
>
<div
role="dialog"
aria-modal="true"
aria-label="推荐应用"
className="flex w-full max-w-[360px] flex-col items-center gap-6 lg:max-w-[520px]"
onClick={(event) => event.target === event.currentTarget && onClose()}
>
<ul className="grid max-h-[70vh] w-full grid-cols-4 gap-x-3 gap-y-5 overflow-y-auto overscroll-contain lg:gap-x-6 lg:gap-y-7">
{ads.map((item, i) => (
<li key={item.id || `${item.images}-${i}`} className="min-w-0">
<a
href={item.link || undefined}
target="_blank"
rel="sponsored nofollow noopener noreferrer"
title={item.title || undefined}
{...adClickData(item)}
onClick={onClose}
className="flex flex-col items-center gap-2"
>
<DecryptedImage
src={item.images}
alt={item.title || "推荐应用"}
priority
className="aspect-square w-full max-w-[70px] rounded-2xl object-cover lg:max-w-20"
/>
<span className="max-w-full truncate text-[13px] leading-[18px] text-white lg:text-[15px] lg:leading-[22px]">
{item.title || "推荐应用"}
</span>
</a>
</li>
))}
</ul>
<button type="button" aria-label="关闭" onClick={onClose} className="size-9 cursor-pointer">
<svg viewBox="0 0 36 36" className="size-full" aria-hidden="true">
<circle cx="18" cy="18" r="16" fill="none" stroke="white" strokeWidth="2" />
<path d="M12.5 12.5l11 11M23.5 12.5l-11 11" stroke="white" strokeWidth="2" strokeLinecap="round" />
</svg>
</button>
</div>
</div>
);
}
+3 -3
View File
@@ -6,6 +6,7 @@ import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from
import { getAdOpen, hasAdShown, subscribeAd } from "@/components/ad/ad-dialog";
import { getAgeGateOpen, subscribeAgeGate } from "@/components/age-gate/age-gate-dialog";
import { useChromeless } from "@/components/layout/route-visibility";
import { lockBodyScroll } from "@/lib/browser/scroll-lock";
import type { AnnouncementInfo, ConfigInfo } from "@/lib/api/types";
import { OFFICIAL_TG_URL, SITE_DOMAIN } from "@/lib/seo/metadata";
@@ -95,10 +96,9 @@ export function AddressDialogHost({
useEffect(() => {
if (!open) return;
const { overflow } = document.body.style;
document.body.style.overflow = "hidden";
const unlockScroll = lockBodyScroll();
return () => {
document.body.style.overflow = overflow;
unlockScroll();
};
}, [open]);
+5 -4
View File
@@ -1,6 +1,7 @@
"use client";
import { useEffect, useSyncExternalStore } from "react";
import { lockBodyScroll } from "@/lib/browser/scroll-lock";
import { useChromeless } from "@/components/layout/route-visibility";
/** 对齐 jha-1043 eightPop.js:sessionStorage + 关闭/退出均离开站点 */
@@ -65,10 +66,9 @@ export function AgeGateDialogHost() {
useEffect(() => {
if (!open) return;
const { overflow } = document.body.style;
document.body.style.overflow = "hidden";
const unlockScroll = lockBodyScroll();
return () => {
document.body.style.overflow = overflow;
unlockScroll();
};
}, [open]);
@@ -115,7 +115,8 @@ export function AgeGateDialogHost() {
</button>
</div>
</section>
<button type="button" aria-label="退出" onClick={exitSite} className="cursor-pointer size-9">
{/* 关闭按钮(X)与“我已年满18岁-进入”一致:确认年龄并进入网站。 */}
<button type="button" aria-label="关闭并进入网站" onClick={confirmAge} className="cursor-pointer size-9">
<svg viewBox="0 0 44 44" className="size-full" aria-hidden="true">
<circle cx="22" cy="22" r="21" fill="none" stroke="white" strokeWidth="2" />
<path d="M16 16l12 12M28 16L16 28" stroke="white" strokeWidth="2" strokeLinecap="round" />
@@ -0,0 +1,66 @@
"use client";
import { usePathname, useSearchParams } from "next/navigation";
import Script from "next/script";
import { useEffect, useRef } from "react";
/** Google Analytics 4 */
const GA_ID = "G-5XKDE5QPTF";
/** Yandex.Metrika 计数器 */
const YM_ID = 113808100;
declare global {
interface Window {
ym?: (id: number, action: string, ...args: unknown[]) => void;
}
}
/**
* 站点统计:GA4 + Yandex.Metrika。
* GA4 增强型衡量会按浏览器历史变化自动记录浏览量;
* Metrika 在客户端路由切换时需手动发送 hit(首屏由 init 统计,不重复发)。
*/
export function SiteAnalytics() {
const pathname = usePathname();
const searchParams = useSearchParams();
const lastUrl = useRef<string | null>(null);
useEffect(() => {
const query = searchParams.toString();
const url = `${pathname}${query ? `?${query}` : ""}`;
if (lastUrl.current === null) {
lastUrl.current = url;
return;
}
if (lastUrl.current === url) return;
const referer = new URL(lastUrl.current, location.origin).href;
lastUrl.current = url;
window.ym?.(YM_ID, "hit", location.href, { referer, title: document.title });
}, [pathname, searchParams]);
return (
<>
<Script src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`} strategy="afterInteractive" />
<Script id="ga4" strategy="afterInteractive">
{`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}');`}
</Script>
<Script id="yandex-metrika" strategy="afterInteractive">
{`(function(m,e,t,r,i,k,a){
m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=${YM_ID}', 'ym');
ym(${YM_ID}, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});`}
</Script>
<noscript>
<div>
<img src={`https://mc.yandex.ru/watch/${YM_ID}`} style={{ position: "absolute", left: "-9999px" }} alt="" />
</div>
</noscript>
</>
);
}
+3 -3
View File
@@ -3,6 +3,7 @@
import Link from "next/link";
import { useCallback, useEffect, useId, useState, useSyncExternalStore, type FormEvent, type ReactNode } from "react";
import { lockBodyScroll } from "@/lib/browser/scroll-lock";
import { useMockUser } from "@/components/auth/use-mock-user";
import {
ACCOUNT_RULE_HINT,
@@ -96,11 +97,10 @@ export function LoginDialogHost() {
useEffect(() => {
if (!mode) return;
const onKeyDown = (event: KeyboardEvent) => event.key === "Escape" && close();
const { overflow } = document.body.style;
document.body.style.overflow = "hidden";
const unlockScroll = lockBodyScroll();
window.addEventListener("keydown", onKeyDown);
return () => {
document.body.style.overflow = overflow;
unlockScroll();
window.removeEventListener("keydown", onKeyDown);
};
}, [mode, close]);
+19 -8
View File
@@ -16,7 +16,10 @@ type AdIconMarqueeProps = {
contentKey?: string;
};
/** Icon 广告从右向左无缝自动滚动(内容复制两段,translateX -50%) */
/**
* Icon 广告从右向左无缝自动滚动(内容复制两段,translateX -50%)。
* 一行放得下时不复制、不滚动,避免广告少时出现重复图标。
*/
export function AdIconMarquee({
children,
className = "",
@@ -24,42 +27,50 @@ export function AdIconMarquee({
spacerClassName = "w-3",
contentKey = "",
}: AdIconMarqueeProps) {
const containerRef = useRef<HTMLDivElement>(null);
const segmentRef = useRef<HTMLDivElement>(null);
const [durationSec, setDurationSec] = useState(20);
const [overflowing, setOverflowing] = useState(false);
useLayoutEffect(() => {
const container = containerRef.current;
const el = segmentRef.current;
if (!el) return;
if (!container || !el) return;
const update = () => {
const width = el.getBoundingClientRect().width;
if (width <= 0) return;
setOverflowing(width > container.clientWidth + 1);
setDurationSec(Math.max(width / SCROLL_PX_PER_SEC, 8));
};
update();
const observer = new ResizeObserver(update);
observer.observe(container);
observer.observe(el);
return () => observer.disconnect();
}, [contentKey]);
return (
<div
ref={containerRef}
data-component="ad-icon-marquee"
className={`overflow-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden ${className}`}
>
<div
className="ad-icon-marquee-track flex w-max items-start"
style={{ animationDuration: `${durationSec}s` }}
className={`flex w-max items-start ${overflowing ? "ad-icon-marquee-track" : ""}`}
style={overflowing ? { animationDuration: `${durationSec}s` } : undefined}
>
<div ref={segmentRef} className={`flex shrink-0 items-start ${gapClassName}`}>
{children}
<span className={`${spacerClassName} shrink-0`} aria-hidden />
</div>
<div className={`flex shrink-0 items-start ${gapClassName}`} aria-hidden>
{children}
<span className={`${spacerClassName} shrink-0`} aria-hidden />
</div>
{overflowing ? (
<div className={`flex shrink-0 items-start ${gapClassName}`} aria-hidden>
{children}
<span className={`${spacerClassName} shrink-0`} aria-hidden />
</div>
) : null}
</div>
</div>
);
-18
View File
@@ -1,18 +0,0 @@
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { AdIcons } from "./ads/ad-icons";
/** @deprecated 使用 AdIcons;保留别名兼容旧引用 */
export function AdIconRow({
labels = true,
items,
advitise,
className = "",
}: {
labels?: boolean;
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
className?: string;
}) {
return <AdIcons variant="pc" labels={labels} items={items} advitise={advitise} className={className} />;
}
+6 -3
View File
@@ -1,4 +1,5 @@
import { DecryptedImage } from "@/components/common/decrypted-image";
import { adClickData } from "@/lib/api/ads-actions";
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
@@ -11,7 +12,7 @@ type AdBannersProps = {
className?: string;
};
/** 公共 Banner 广告:对接 advitise.detailbannerList;无数据不渲染 */
/** 公共 Banner 广告:对接 advitise.detailbannerList(后台位置 3「详情横幅」,素材 720×150);无数据不渲染 */
export function AdBanners({
variant = "pc",
items,
@@ -38,7 +39,8 @@ export function AdBanners({
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
className="block h-10 overflow-hidden rounded-xl"
{...adClickData(ad)}
className="block aspect-[720/150] overflow-hidden rounded-xl"
>
<DecryptedImage
src={ad.images || null}
@@ -68,7 +70,8 @@ export function AdBanners({
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
className="block h-[97px] overflow-hidden rounded-xl"
{...adClickData(ad)}
className="block aspect-[720/150] overflow-hidden rounded-xl"
>
<DecryptedImage
src={ad.images || null}
-70
View File
@@ -1,70 +0,0 @@
import { DecryptedImage } from "@/components/common/decrypted-image";
import { AdIconMarquee } from "@/components/common/ad-icon-marquee";
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
import { adContentKey, adHref, pickIconAds } from "./pick";
type AdIconsProps = {
variant?: "pc" | "h5";
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
/** PC 是否显示标题;H5 始终显示 */
labels?: boolean;
className?: string;
};
/** 公共 Icon 广告:对接 advitise.nineGridList,无数据不渲染;从右向左无缝滚动 */
export function AdIcons({
variant = "pc",
items,
advitise,
labels = true,
className = "",
}: AdIconsProps) {
const isH5 = variant === "h5";
const apiList = pickIconAds(items, advitise, variant);
if (!apiList.length) return null;
const showLabels = isH5 || labels;
const iconClass = isH5
? "flex w-12 shrink-0 flex-col items-center gap-1"
: "flex w-20 shrink-0 flex-col items-center gap-1";
const imgClass = isH5
? "aspect-square size-12 rounded-xl border border-white/30 object-cover"
: "size-20 rounded-xl border border-white/30 object-cover";
const titleClass = isH5
? "max-w-full truncate text-xs leading-[18px] text-white/90"
: "text-center text-sm leading-5 text-white/90";
return (
<AdIconMarquee
className={className}
gapClassName={isH5 ? "gap-2" : "gap-3"}
spacerClassName={isH5 ? "w-2" : "w-3"}
contentKey={adContentKey(apiList)}
>
{apiList.map((ad, index) => {
const href = adHref(ad.link, isH5 ? "#h5-download" : "#download");
const external = Boolean(ad.link?.trim());
return (
<a
key={ad.id || `ad-${index}`}
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
className={iconClass}
>
<DecryptedImage
src={ad.images || null}
fallback={IMG_PLACEHOLDER}
alt={ad.title || ""}
className={imgClass}
/>
{showLabels ? <span className={titleClass}>{ad.title || "广告"}</span> : null}
</a>
);
})}
</AdIconMarquee>
);
}
+69
View File
@@ -0,0 +1,69 @@
import { AdIconMarquee } from "@/components/common/ad-icon-marquee";
import { DecryptedImage } from "@/components/common/decrypted-image";
import { adClickData } from "@/lib/api/ads-actions";
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
import { adContentKey, adHref, pickSquareAds, type SquareAdSlot } from "./pick";
type AdSquaresProps = {
/** BList:首页小图标;AList:播放页小图标 */
slot: SquareAdSlot;
variant?: "pc" | "h5";
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
className?: string;
};
/**
* 小方块广告(方形素材),无数据不渲染;一行放不下时自动滚动。
* 首页用 BList(位置 13「首页小图标」),播放页用 AList(位置 12「播放页小图标」)。
*/
export function AdSquares({ slot, variant = "pc", items, advitise, className = "" }: AdSquaresProps) {
const isH5 = variant === "h5";
const list = pickSquareAds(slot, items, advitise);
if (!list.length) return null;
return (
<section
data-component="ad-squares"
aria-label="推广"
className={`flex flex-col ${isH5 ? "gap-1.5" : "gap-2.5"} ${className}`}
>
<p className={`text-[#6F6C7B] ${isH5 ? "text-[11px] leading-4" : "text-xs leading-[18px]"}`}>推广</p>
<AdIconMarquee
gapClassName={isH5 ? "gap-2.5" : "gap-4"}
spacerClassName={isH5 ? "w-2.5" : "w-4"}
contentKey={adContentKey(list)}
>
{list.map((ad, index) => {
const href = adHref(ad.link, isH5 ? "#h5-download" : "#download");
const external = Boolean(ad.link?.trim());
return (
<a
key={ad.id || `square-${index}`}
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
title={ad.title || undefined}
{...adClickData(ad)}
className={`group flex shrink-0 flex-col items-center gap-1.5 ${isH5 ? "w-[72px]" : "w-[120px]"}`}
>
<DecryptedImage
src={ad.images || null}
fallback={IMG_PLACEHOLDER}
alt={ad.title || "推广"}
className={`aspect-square w-full rounded-lg object-cover outline outline-1 -outline-offset-1 outline-white/10 transition-[outline-color] group-hover:outline-[#FFB020]/80 ${
isH5 ? "" : "rounded-xl"
}`}
/>
<span className={`max-w-full truncate text-[#D8D6DF] ${isH5 ? "text-[11px] leading-4" : "text-sm leading-5"}`}>
{ad.title || "推广"}
</span>
</a>
);
})}
</AdIconMarquee>
</section>
);
}
+2 -2
View File
@@ -1,4 +1,4 @@
/** 仅导出可进 Client Component 的广告 UI;Slot 请从 `@/components/common/ads/slots` 引入 */
export { AdIcons } from "./ad-icons";
export { AdBanners } from "./ad-banners";
export { pickIconAds, pickBannerAds, pickFriendAds } from "./pick";
export { AdSquares } from "./ad-squares";
export { pickBannerAds, pickSquareAds } from "./pick";
+9 -15
View File
@@ -1,18 +1,18 @@
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
export function hasAdVisual(item: AdvertiseInfo) {
return Boolean(item.images?.trim() || item.title?.trim());
}
/**
* 小方块广告(后台「站点」广告位):
* BList = 位置 13「首页小图标」,AList = 位置 12「播放页小图标」
*/
export type SquareAdSlot = "BList" | "AList";
/** Icon:统一对接 advitise.nineGridList(可显式传 items 覆盖) */
export function pickIconAds(
export function pickSquareAds(
slot: SquareAdSlot,
items?: AdvertiseInfo[] | null,
advitise?: AdvitiseData | null,
_variant: "pc" | "h5" = "pc",
) {
void _variant;
const source = items ?? advitise?.nineGridList ?? [];
return source.filter(hasAdVisual);
const source = items ?? advitise?.[slot] ?? [];
return source.filter((item) => Boolean(item.images?.trim()));
}
/** Banner:detailbannerList(需有图) */
@@ -21,12 +21,6 @@ export function pickBannerAds(items?: AdvertiseInfo[] | null, advitise?: Advitis
return source.filter((item) => Boolean(item.images?.trim()));
}
/** 友情链接:friendList(需有标题) */
export function pickFriendAds(items?: AdvertiseInfo[] | null, advitise?: AdvitiseData | null) {
const source = items ?? advitise?.friendList ?? [];
return source.filter((item): item is AdvertiseInfo & { title: string } => Boolean(item.title?.trim()));
}
export function adHref(link?: string, fallback = "#download") {
const value = link?.trim();
if (!value) return fallback;
+7 -19
View File
@@ -1,21 +1,21 @@
import { getAdvitiseCached } from "@/lib/api/home";
import { AdBanners } from "./ad-banners";
import { AdIcons } from "./ad-icons";
import { FriendLinks, H5FriendLinks } from "../friend-links";
import { AdSquares } from "./ad-squares";
import type { SquareAdSlot } from "./pick";
/** 服务端:Icon 广告(home/base → advitise) */
export async function AdIconsSlot({
/** 服务端:小方块广告(BList 首页小图标 / AList 播放页小图标) */
export async function AdSquaresSlot({
slot,
variant = "pc",
labels = true,
className = "",
}: {
slot: SquareAdSlot;
variant?: "pc" | "h5";
labels?: boolean;
className?: string;
}) {
const advitise = await getAdvitiseCached();
return <AdIcons variant={variant} advitise={advitise} labels={labels} className={className} />;
return <AdSquares slot={slot} variant={variant} advitise={advitise} className={className} />;
}
/** 服务端:Banner 广告 */
@@ -29,15 +29,3 @@ export async function AdBannersSlot({
const advitise = await getAdvitiseCached();
return <AdBanners variant={variant} advitise={advitise} className={className} />;
}
/** 服务端:PC 友情链接 */
export async function FriendLinksSlot() {
const advitise = await getAdvitiseCached();
return <FriendLinks advitise={advitise} />;
}
/** 服务端:H5 友情链接 */
export async function H5FriendLinksSlot() {
const advitise = await getAdvitiseCached();
return <H5FriendLinks advitise={advitise} />;
}
@@ -1 +0,0 @@
export { FriendLinksSlot, H5FriendLinksSlot } from "./ads/slots";
-75
View File
@@ -1,75 +0,0 @@
import { H5SectionHeading } from "@/components/home/h5-cards";
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { adHref, pickFriendAds } from "./ads/pick";
/** PC 友情链接:对接 advitise.friendList,无数据不渲染 */
export function FriendLinks({
items,
advitise,
}: {
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
}) {
const apiList = pickFriendAds(items, advitise);
if (!apiList.length) return null;
// 不用 design-unscaled:嵌套 zoom 会在 Chrome 把热区错位叠到上方分页上
return (
<section data-component="friend-links" id="links" className="border-t border-white/10 pt-1">
<h2 className="text-2xl leading-8 font-semibold text-white/90">友情链接</h2>
<div className="mt-[18px] flex flex-wrap gap-3">
{apiList.map((item, index) => {
const href = adHref(item.link, "#links");
const external = Boolean(item.link?.trim());
return (
<a
key={item.id || `${item.title}-${index}`}
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
className="inline-flex min-w-[146px] items-center justify-center rounded-md bg-white/5 px-2 py-[9px] text-base leading-[22px] text-white/55"
>
{item.title}
</a>
);
})}
</div>
</section>
);
}
/** H5 友情链接:对接 advitise.friendList,无数据不渲染 */
export function H5FriendLinks({
items,
advitise,
}: {
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
}) {
const apiList = pickFriendAds(items, advitise);
if (!apiList.length) return null;
return (
<section id="h5-links" className="flex flex-col gap-3">
<H5SectionHeading title="友情链接" more={false} />
<div className="flex flex-wrap gap-[18px]">
{apiList.map((item, index) => {
const href = adHref(item.link, "#h5-links");
const external = Boolean(item.link?.trim());
return (
<a
key={item.id || `${item.title}-${index}`}
href={href}
target={external ? "_blank" : undefined}
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
className="rounded-md border border-white/5 bg-white/10 px-3 py-[9px] text-xs leading-[18px] text-white/90"
>
{item.title}
</a>
);
})}
</div>
</section>
);
}
@@ -1,6 +0,0 @@
import { AdIconsSlot } from "./ads/slots";
/** @deprecated 使用 AdIconsSlot */
export async function H5AdGridSlot({ className = "" }: { className?: string }) {
return <AdIconsSlot variant="h5" className={className} />;
}
-16
View File
@@ -1,16 +0,0 @@
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { AdIcons } from "./ads/ad-icons";
/** @deprecated 使用 AdIcons variant="h5";保留别名兼容旧引用 */
export function H5AdGrid({
items,
advitise,
className = "",
}: {
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
className?: string;
}) {
return <AdIcons variant="h5" items={items} advitise={advitise} className={className} />;
}
@@ -1,6 +0,0 @@
import { AdBannersSlot } from "./ads/slots";
/** @deprecated 使用 AdBannersSlot */
export async function H5BannerAdsSlot({ className = "" }: { className?: string }) {
return <AdBannersSlot variant="h5" className={className} />;
}
-16
View File
@@ -1,16 +0,0 @@
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { AdBanners } from "./ads/ad-banners";
/** @deprecated 使用 AdBanners variant="h5";保留别名兼容旧引用 */
export function H5BannerAds({
items,
advitise,
className = "",
}: {
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
className?: string;
}) {
return <AdBanners variant="h5" items={items} advitise={advitise} className={className} />;
}
@@ -1,17 +0,0 @@
import { connection } from "next/server";
import { getHomeBaseCached } from "@/lib/api/home";
import { HomeBaseDebug } from "./home-base-debug";
/** 调试插槽:拉取 home/base 并在浏览器控制台打印 */
export async function HomeBaseDebugSlot() {
await connection();
let data: Awaited<ReturnType<typeof getHomeBaseCached>> = {};
try {
data = await getHomeBaseCached();
} catch {
data = {};
}
return <HomeBaseDebug data={data} />;
}
-14
View File
@@ -1,14 +0,0 @@
"use client";
import { useEffect } from "react";
import type { HomeBaseResp } from "@/lib/api/types";
/** 浏览器控制台打印 /api/app/home/base 返回数据(调试用) */
export function HomeBaseDebug({ data }: { data: HomeBaseResp }) {
useEffect(() => {
console.info("[home/base]", data);
}, [data]);
return null;
}
+3 -3
View File
@@ -1,5 +1,6 @@
"use client";
import { lockBodyScroll } from "@/lib/browser/scroll-lock";
import { QRCodeSVG } from "qrcode.react";
import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type MouseEvent } from "react";
@@ -132,11 +133,10 @@ export function DownloadDialogHost({ appAddr }: { appAddr?: string | null }) {
useEffect(() => {
if (!open) return;
const onKeyDown = (event: KeyboardEvent) => event.key === "Escape" && close();
const { overflow } = document.body.style;
document.body.style.overflow = "hidden";
const unlockScroll = lockBodyScroll();
window.addEventListener("keydown", onKeyDown);
return () => {
document.body.style.overflow = overflow;
unlockScroll();
window.removeEventListener("keydown", onKeyDown);
};
}, [open, close]);
@@ -4,7 +4,7 @@ import { toast } from "@heroui/react";
import { useEffect, useState, type ReactNode } from "react";
import { openLoginDialog } from "@/components/auth/login-dialog";
import { AdBanners, AdIcons } from "@/components/common/ads";
import { AdBanners } from "@/components/common/ads";
import { BackButton } from "@/components/common/back-button";
import { pickPlayletCardTags } from "@/components/common/card-tags";
import { DecryptedImage } from "@/components/common/decrypted-image";
@@ -70,9 +70,9 @@ export function DramaDetailPage({
related?: RelatedDrama[];
/** 服务端渲染的 PC banner */
promo?: ReactNode;
/** 服务端渲染的 PC icon */
/** 服务端渲染的播放页小图标(AList):PC */
adIcons?: ReactNode;
/** 服务端渲染的 H5 icon */
/** 服务端渲染的播放页小图标(AList):H5 */
adGrid?: ReactNode;
/** 服务端渲染的 H5 banner */
bannerAds?: ReactNode;
@@ -254,7 +254,7 @@ export function DramaDetailPage({
</figure>
</article>
{adIcons ?? <AdIcons variant="pc" />}
{adIcons}
<EpisodeDirectory detail={detail} variant="panel" />
@@ -298,7 +298,7 @@ export function DramaDetailPage({
) : null}
</article>
{adGrid ?? <AdIcons variant="h5" />}
{adGrid}
<EpisodeDirectory detail={detail} variant="h5" />
+13 -4
View File
@@ -5,7 +5,7 @@ import Link from "next/link";
import { useEffect, useState, type ReactNode } from "react";
import { openLoginDialog } from "@/components/auth/login-dialog";
import { AdBanners, AdIcons } from "@/components/common/ads";
import { AdBanners } from "@/components/common/ads";
import { pickPlayletCardTags } from "@/components/common/card-tags";
import {
dramaDetailHref,
@@ -67,15 +67,22 @@ export function DramaPlayPage({
episode,
src,
related = [],
adIcons,
promo,
topAds,
h5Ads,
h5Banners,
}: {
detail: DramaDetail;
episode: number;
src: string;
related?: RelatedDrama[];
adIcons?: ReactNode;
promo?: ReactNode;
/** 服务端渲染的播放页小图标(AList):PC 顶部 */
topAds?: ReactNode;
/** 服务端渲染的播放页小图标(AList):H5 正文下方 */
h5Ads?: ReactNode;
/** 服务端渲染的详情横幅(detailbannerList):H5 */
h5Banners?: ReactNode;
}) {
const [liked, setLiked] = useState(Boolean(detail.isLike));
const [displayCountLike, setDisplayCountLike] = useState(() => initialDisplayCountLike(detail));
@@ -229,6 +236,7 @@ export function DramaPlayPage({
className={`relative hidden flex-col gap-8 pb-14 lg:flex ${expanded ? "" : `pt-6 ${pcFrame}`}`}
>
{!expanded ? <PageBreadcrumb items={crumbs} /> : null}
{!expanded ? topAds : null}
<div className={expanded ? "contents" : "flex flex-col gap-8"}>
<div className={expanded ? "contents" : "flex h-[648px] gap-5"}>
@@ -294,7 +302,6 @@ export function DramaPlayPage({
{expanded ? <EpisodeDirectory detail={detail} current={episode} variant="panel" /> : null}
{adIcons ?? <AdIcons variant="pc" />}
<DramaRecommend items={related} />
@@ -317,6 +324,8 @@ export function DramaPlayPage({
onLike={toggleLike}
onCollect={toggleCollect}
onShare={share}
ads={h5Ads}
bannerAds={h5Banners}
/>
<div className="max-lg:hidden">
+10
View File
@@ -64,6 +64,10 @@ type H5PlayProps = {
onCollect: () => void;
onShare: () => void;
onPlaySuccess?: () => void;
/** 播放页小图标广告(AList) */
ads?: ReactNode;
/** 详情横幅广告(detailbannerList) */
bannerAds?: ReactNode;
};
function LockedNotice() {
@@ -152,6 +156,8 @@ export function H5Play({
onCollect,
onShare,
onPlaySuccess,
ads,
bannerAds,
}: H5PlayProps) {
const router = useRouter();
const playerRef = useRef<XgPlayerInstance | null>(null);
@@ -316,9 +322,13 @@ export function H5Play({
</nav>
</article>
{ads}
<EpisodeDirectory detail={detail} current={episode} variant="h5" />
<DramaRecommend items={related} compact />
{bannerAds}
</div>
<BottomSheet open={sheet === "speed"} onClose={closeSheet} label="倍速" className="gap-3 px-4 py-[18px]">
-14
View File
@@ -1,6 +1,5 @@
import Link from "next/link";
import { AdBanners } from "@/components/common/ads/ad-banners";
import { CardTags } from "@/components/common/card-tags";
import {
MEDIA_CARD_COVER,
@@ -12,7 +11,6 @@ import {
MEDIA_CARD_TITLE_PC_MD,
} from "@/components/common/media-card-hover";
import { dramaHref } from "@/components/short-drama/data";
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import type { Drama } from "./data";
import { Badge } from "./section-heading";
@@ -80,15 +78,3 @@ export function ThemeBlock({ title, subtitle, cover }: { title: string; subtitle
</article>
);
}
/** @deprecated 使用 AdBanners;covers 保留兼容,有接口数据时优先接口 */
export function PromoRow({
items,
advitise,
}: {
covers?: readonly string[];
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
}) {
return <AdBanners variant="pc" items={items} advitise={advitise} />;
}
-14
View File
@@ -1,14 +0,0 @@
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
import { AdIcons } from "@/components/common/ads/ad-icons";
/** @deprecated 使用 AdIcons;保留别名兼容首页旧引用 */
export function HomeAdRow({
items,
advitise,
}: {
items?: AdvertiseInfo[] | null;
advitise?: AdvitiseData | null;
}) {
return <AdIcons variant="pc" items={items} advitise={advitise} />;
}
-21
View File
@@ -1,21 +0,0 @@
"use client";
import { useEffect } from "react";
import type { AdvitiseData, ConfigInfo, HomePlayletResponse } from "@/lib/api/types";
/** 调试:把首页接口数据打到浏览器控制台 */
export function HomeDataDebug({
home,
base,
}: {
home?: HomePlayletResponse | null;
base?: { advitise?: AdvitiseData; config?: ConfigInfo };
}) {
useEffect(() => {
console.log("[home] playlet/home", home);
console.log("[home] home/base", base);
}, [home, base]);
return null;
}
+2 -6
View File
@@ -1,5 +1,4 @@
import { AdBanners, AdIcons } from "@/components/common/ads";
import { H5FriendLinks } from "@/components/common/friend-links";
import { AdSquares } from "@/components/common/ads";
import type { HomePlayletResponse } from "@/lib/api/types";
import { DownloadBannerH5 } from "./page-sections";
@@ -16,13 +15,10 @@ export function HomePageH5({ home }: { home?: HomePlayletResponse | null }) {
<NoticeMarquee items={home?.announcements} variant="h5" />
<AdIcons variant="h5" advitise={home?.advitise} />
<AdBanners variant="h5" advitise={home?.advitise} />
<AdSquares slot="BList" variant="h5" advitise={home?.advitise} />
{hasModules ? <HomeModules modules={home?.modules} variant="h5" /> : null}
<H5FriendLinks advitise={home?.advitise} />
<DownloadBannerH5 />
</main>
);
+2 -4
View File
@@ -1,5 +1,4 @@
import { AdIcons } from "@/components/common/ads";
import { FriendLinks } from "@/components/common/friend-links";
import { AdSquares } from "@/components/common/ads";
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
import type { HomePlayletResponse } from "@/lib/api/types";
@@ -31,12 +30,11 @@ export function HomePage({
<main data-component="home-page" className="design-frame hidden flex-col gap-8 pt-8 pb-10 lg:flex">
<HeroBanner banners={home?.homeBannerData} />
<NoticeMarquee items={home?.announcements} />
<AdIcons variant="pc" advitise={home?.advitise} />
<AdSquares slot="BList" variant="pc" advitise={home?.advitise} />
{hasModules ? <HomeModules modules={home?.modules} /> : null}
<DownloadBanner />
<FriendLinks advitise={home?.advitise} />
</main>
<FloatingActions />
</>
+6 -1
View File
@@ -1,5 +1,7 @@
import type { AppTranslationInfo, TranslationInfo } from "@/lib/api/types";
import { isRemovedNavItem } from "./nav-href";
/** 接口失败时兜底:PC「关于平台」(与 home/base → bottonTranslations 对齐) */
export const BOTTOM_NAV_FALLBACK_NAMES = ["用户条款", "隐私政策", "联系我们", "常见问题"] as const;
@@ -19,5 +21,8 @@ export function footerNavItems(bottonTranslations?: AppTranslationInfo | null):
const source = bottomCats.length ? bottomCats : categories;
return source
.flatMap((category) => category.translationList ?? [])
.filter((item): item is TranslationInfo => Boolean(item.name?.trim()) && !isCustomerServiceName(item.name));
.filter(
(item): item is TranslationInfo =>
Boolean(item.name?.trim()) && !isCustomerServiceName(item.name) && !isRemovedNavItem(item),
);
}
+3 -3
View File
@@ -6,6 +6,7 @@ import { useEffect, useState, type ReactNode } from "react";
import { openAppDownload, useAppDownloadHref } from "@/components/download/download-dialog";
import { footerNavItems } from "@/components/layout/footer-nav-items";
import { lockBodyScroll } from "@/lib/browser/scroll-lock";
import type { AppTranslationInfo, ConfigInfo, TranslationCategory, TranslationInfo } from "@/lib/api/types";
import { OFFICIAL_TG_HANDLE, OFFICIAL_TG_URL } from "@/lib/seo/metadata";
@@ -77,11 +78,10 @@ export function MobileMenu({
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") onClose();
};
const { overflow } = document.body.style;
document.body.style.overflow = "hidden";
const unlockScroll = lockBodyScroll();
window.addEventListener("keydown", onKeyDown);
return () => {
document.body.style.overflow = overflow;
unlockScroll();
window.removeEventListener("keydown", onKeyDown);
};
}, [open, onClose]);
+14 -1
View File
@@ -57,7 +57,6 @@ export function resolveNavHref(urlValue?: string | null): string {
const path = raw.startsWith("/") ? raw : `/${raw}`;
if (path === "/" || path === "/#top") return "/";
if (path === "/application" || path.startsWith("/application/")) return "/welfare";
if (path === "/drama-rank") return "/ranking/drama";
if (path === "/video-rank") return "/ranking/video";
if (path.startsWith("/drama/")) return `/short-drama${path.slice("/drama".length)}`;
@@ -66,6 +65,20 @@ export function resolveNavHref(urlValue?: string | null): string {
return path;
}
/** 已下线的福利应用入口(接口仍可能下发 /application 或「福利应用」):导航中不展示 */
export function isRemovedNavItem(item: { name?: string | null; urlValue?: string | null }) {
const name = item.name?.trim() || "";
const url = (item.urlValue || "").trim().replace(/^https?:\/\/[^/]+/i, "");
const path = url.startsWith("/") ? url : `/${url}`;
return (
name.includes("福利") ||
path === "/application" ||
path.startsWith("/application/") ||
path === "/welfare" ||
path.startsWith("/welfare/")
);
}
/** 底部导航 / 页脚:优先接口 urlValue,无配置时再按 name 兜底 */
export function resolveAboutPlatformHref(item: { name?: string; urlValue?: string | null }): string {
const name = item.name?.trim();
+7 -1
View File
@@ -5,6 +5,7 @@ import { getNavigationHeaderCached } from "@/lib/api/navigation";
import type { AppTranslationInfo, ConfigInfo, TranslationCategory } from "@/lib/api/types";
import { DesktopNav } from "./desktop-nav";
import { isRemovedNavItem } from "./nav-href";
import { HideOnChromeless, HideOnMobileChromeless } from "./route-visibility";
import { SiteFooter } from "./site-footer";
import { SiteHeader } from "./site-header";
@@ -13,7 +14,12 @@ import { SiteHeader } from "./site-header";
async function loadNavigationCategories(): Promise<TranslationCategory[]> {
try {
const data = await getNavigationHeaderCached();
return data.categoryList?.filter((item) => item.name?.trim()) ?? [];
return (data.categoryList ?? [])
.filter((item) => item.name?.trim() && !isRemovedNavItem(item))
.map((item) => ({
...item,
translationList: item.translationList?.filter((child) => !isRemovedNavItem(child)) ?? item.translationList,
}));
} catch {
return [];
}
-7
View File
@@ -1,4 +1,3 @@
import { AdBannersSlot, AdIconsSlot, FriendLinksSlot, H5FriendLinksSlot } from "@/components/common/ads/slots";
import type { ReactNode } from "react";
import { ChannelHeader, H5ChannelHeader } from "@/components/common/channel-header";
@@ -68,7 +67,6 @@ export function MorePage({ data }: { data: MorePageData }) {
<SeoBreadcrumb items={[{ name: "首页", href: "/" }, { name: data.title || "更多内容" }]} />
<main data-component="more-page" className="flex w-full min-w-0 flex-col gap-[18px] overflow-x-clip px-4 py-3 lg:hidden">
<H5ChannelHeader {...header} />
<AdIconsSlot variant="h5" />
<TopicGrid topics={data.topics} dataType={data.dataType} compact />
@@ -80,14 +78,11 @@ export function MorePage({ data }: { data: MorePageData }) {
{hrefMap ? <Pagination page={data.page} total={data.totalPages} hrefMap={hrefMap} className="[&_form]:hidden" /> : null}
<AdBannersSlot variant="h5" />
<H5FriendLinksSlot />
</main>
<main className="hidden lg:block">
<div className="design-frame flex flex-col gap-6 py-[43px]">
<ChannelHeader {...header} />
<AdIconsSlot variant="pc" />
<TopicGrid topics={data.topics} dataType={data.dataType} />
@@ -106,9 +101,7 @@ export function MorePage({ data }: { data: MorePageData }) {
</div>
) : null}
<div className="design-frame flex flex-col gap-6 pb-[43px]">
<AdBannersSlot variant="pc" />
<DownloadBanner />
<FriendLinksSlot />
</div>
</main>
<FloatingActions />
-1
View File
@@ -57,7 +57,6 @@ function buildShortcuts(config?: ConfigInfo | null): Shortcut[] {
config?.appAddr?.trim()
? { label: "APP", icon: "/logo2.png", href: hrefOf(config.appAddr), external: true }
: { label: "APP", icon: "/logo2.png" },
{ label: "福利应用", icon: "/images/nav_flyy.svg", href: "/welfare" },
];
}
+2 -12
View File
@@ -40,18 +40,8 @@ export function formatHeat(count?: number | null) {
}
export function mapContentListItem(item: PlayletContentListItem, dataType: 1 | 2): ShortDramaItem | null {
if (item.type === 2) {
const ad = item.advertise;
if (!ad) return null;
return {
kind: "ad",
id: `ad-${ad.id || ad.link || "unknown"}`,
title: (ad.title || "").trim() || "广告",
subtitle: "",
cover: (ad.images || "").trim(),
href: (ad.link || "").trim() || undefined,
};
}
// 信息流广告(type=2)不展示:网页只保留后台 5 个站点广告位
if (item.type === 2) return null;
if (dataType === 1) {
const playlet = item.playlet;
-7
View File
@@ -1,4 +1,3 @@
import { AdBannersSlot, AdIconsSlot, FriendLinksSlot, H5FriendLinksSlot } from "@/components/common/ads/slots";
import type { ReactNode } from "react";
import { ChannelHeader, H5ChannelHeader } from "@/components/common/channel-header";
@@ -66,7 +65,6 @@ export function RankingPage({ tab, list }: { tab: RankingTab; list: RankingListR
/>
<main data-component="ranking-page" className="flex w-full min-w-0 flex-col gap-[18px] overflow-x-clip px-4 py-3 lg:hidden">
<H5ChannelHeader {...header} />
<AdIconsSlot variant="h5" />
<section id="h5-list" className="flex scroll-mt-16 flex-col gap-[18px]">
<RankingTabs tabs={rankingTabs} tab={tab} />
@@ -94,14 +92,11 @@ export function RankingPage({ tab, list }: { tab: RankingTab; list: RankingListR
)}
</section>
<AdBannersSlot variant="h5" />
<H5FriendLinksSlot />
</main>
<main className="hidden lg:block">
<div className="design-frame flex flex-col gap-6 py-[43px]">
<ChannelHeader {...header} />
<AdIconsSlot variant="pc" />
<div id="pc-list" className="scroll-mt-24 flex flex-col gap-6">
<RankingTabs tabs={rankingTabs} tab={tab} />
@@ -126,9 +121,7 @@ export function RankingPage({ tab, list }: { tab: RankingTab; list: RankingListR
</div>
) : null}
<div className="design-frame flex flex-col gap-6 pb-[43px]">
<AdBannersSlot variant="pc" />
<DownloadBanner />
<FriendLinksSlot />
</div>
</main>
<FloatingActions />
-9
View File
@@ -1,6 +1,5 @@
import Form from "next/form";
import { AdBannersSlot, AdIconsSlot } from "@/components/common/ads/slots";
import { EmptyState } from "@/components/common/empty-state";
import { TabLink } from "@/components/common/filter-link";
import { Pagination } from "@/components/common/pagination";
@@ -138,14 +137,6 @@ export function SearchPage({ list }: { list: SearchListResult }) {
/>
)}
<div className="hidden lg:block">
<AdIconsSlot variant="pc" />
<AdBannersSlot variant="pc" />
</div>
<div className="flex flex-col gap-[18px] lg:hidden">
<AdIconsSlot variant="h5" />
<AdBannersSlot variant="h5" />
</div>
</div>
<FloatingActions />
</main>
+19 -64
View File
@@ -24,32 +24,23 @@ export type Genre = (typeof genres)[number];
export type Sort = (typeof sorts)[number];
export type Region = (typeof regions)[number];
export type ShortDramaItem =
| {
kind: "drama";
id: string;
slug?: string;
title: string;
subtitle: string;
/** 左下角标签,最多 3 个(优先带 id 以便跳转) */
tags: CardTagItem[];
heat: string;
episodes: string;
badge?: BadgeTone;
cover: string;
/** 发布时间(接口原值,视频卡展示日期用) */
date?: string;
/** 覆盖默认详情/播放链接(如历史继续看到某集) */
href?: string;
}
| {
kind: "ad";
id: string;
title: string;
subtitle: string;
cover: string;
href?: string;
};
export type ShortDramaItem = {
kind: "drama";
id: string;
slug?: string;
title: string;
subtitle: string;
/** 左下角标签,最多 3 个(优先带 id 以便跳转) */
tags: CardTagItem[];
heat: string;
episodes: string;
badge?: BadgeTone;
cover: string;
/** 发布时间(接口原值,视频卡展示日期用) */
date?: string;
/** 覆盖默认详情/播放链接(如历史继续看到某集) */
href?: string;
};
export const PAGE_SIZE = 24;
export const TOTAL_PAGES = 11;
@@ -59,16 +50,8 @@ export function shortDramaSortType(sort: Sort): 1 | 2 {
}
export function mapPlayletListItem(item: PlayletListItem): ShortDramaItem | null {
if (item.type === 2) {
return {
kind: "ad",
id: `ad-${item.advertiseId || item.id || item.link || "unknown"}`,
title: (item.title || "").trim() || "广告",
subtitle: "",
cover: (item.cover || "").trim(),
href: (item.link || "").trim() || undefined,
};
}
// 信息流广告(type=2)不展示:网页只保留后台 5 个站点广告位
if (item.type === 2) return null;
if (!item.id) return null;
const tags = pickPlayletCardTags(item);
@@ -124,34 +107,6 @@ export function buildShortDramaList(
};
}
/** @deprecated 本地 mock,供「更多」等未接接口页面临时使用 */
const adSlots = new Set([4, 9, 14, 18, 23]);
const freshSlots = new Set([3, 11, 21]);
export function getShortDramas(genre: Genre, sort: Sort, page: number, region: Region = "全部"): ShortDramaItem[] {
const seed = `${genres.indexOf(genre)}-${sorts.indexOf(sort)}-${regions.indexOf(region)}-${page}`;
return Array.from({ length: PAGE_SIZE }, (_, index): ShortDramaItem => {
const id = `short-${seed}-${index}`;
const cover = "";
if (adSlots.has(index)) {
return { kind: "ad", id, title: "广告文案", subtitle: "我是副标题", cover };
}
return {
kind: "drama",
id,
title: "有恩必报",
subtitle: "权谋交锋爱意藏在局中",
tags: [{ name: genre === "全部" ? "标签" : genre }],
heat: "25.8万 热度",
episodes: "30集",
badge: freshSlots.has(index) ? "fresh" : "original",
cover,
};
});
}
/** 有 slug 时路径用 slug,否则回退 id */
export function dramaPathKey(id: string | number, slug?: string | null) {
@@ -16,7 +16,7 @@ function RankLabel({ rank, className = "" }: { rank?: number; className?: string
}
/** 短剧卡元信息:集数 + 热度(文字行,不叠在封面上) */
function DramaMeta({ item, className }: { item: Extract<ShortDramaItem, { kind: "drama" }>; className: string }) {
function DramaMeta({ item, className }: { item: ShortDramaItem; className: string }) {
return (
<p className={`flex min-w-0 items-center gap-2 text-[#8E8C99] ${className}`}>
{item.episodes ? <span className="shrink-0 text-[#D9C59A]">共{item.episodes}</span> : null}
@@ -31,27 +31,7 @@ function DramaMeta({ item, className }: { item: Extract<ShortDramaItem, { kind:
);
}
function AdDramaCard({ item, compact }: { item: ShortDramaItem; compact?: boolean }) {
return (
<a
href={item.href || (compact ? "#h5-download" : "#download")}
target={item.href ? "_blank" : undefined}
rel={item.href ? "sponsored nofollow noopener noreferrer" : undefined}
className={`group flex flex-col ${compact ? "gap-1.5" : "w-[266px] gap-2.5"}`}
>
<span className={`${HL_COVER} aspect-[2/3]`}>
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt={item.title} className={HL_COVER_IMG} />
<span className="absolute top-0 left-0 rounded-br-md bg-white/85 px-1.5 py-0.5 text-[10px] leading-[14px] text-black">
推广
</span>
</span>
<span className={`truncate text-white ${compact ? "text-sm leading-5" : "media-card-title-md"}`}>{item.title}</span>
</a>
);
}
export function ShortDramaCard({ item, rank }: { item: ShortDramaItem; rank?: number }) {
if (item.kind === "ad") return <AdDramaCard item={item} />;
const href = item.href || dramaHref(item.id, item.slug);
return (
@@ -84,7 +64,6 @@ export function H5ShortDramaCard({
/** @deprecated 新卡片不在封面显示集数,保留参数兼容调用方 */
showEpisodes?: boolean;
}) {
if (item.kind === "ad") return <AdDramaCard item={item} compact />;
const href = item.href || dramaHref(item.id, item.slug);
return (
@@ -1,4 +1,3 @@
import { AdBannersSlot, AdIconsSlot, FriendLinksSlot, H5FriendLinksSlot } from "@/components/common/ads/slots";
import { ChannelHeader, H5ChannelHeader } from "@/components/common/channel-header";
import { EmptyState } from "@/components/common/empty-state";
import { FilterChipLink, FilterOptionLink } from "@/components/common/filter-link";
@@ -25,7 +24,6 @@ export function ShortDramaPage({ list }: { list: ShortDramaListResult }) {
<SeoBreadcrumb items={[{ name: "首页", href: "/" }, { name: "短剧" }]} />
<main data-component="short-drama-page" className="flex w-full min-w-0 flex-col gap-[18px] overflow-x-clip px-4 py-3 lg:hidden">
<H5ChannelHeader title="短剧" />
<AdIconsSlot variant="h5" />
<div
id="h5-list"
@@ -89,14 +87,11 @@ export function ShortDramaPage({ list }: { list: ShortDramaListResult }) {
)}
</section>
<AdBannersSlot variant="h5" />
<H5FriendLinksSlot />
</main>
<main className="hidden lg:block">
<div className="design-frame flex flex-col gap-6 py-[43px]">
<ChannelHeader title="短剧" />
<AdIconsSlot variant="pc" />
<div
id="pc-list"
@@ -155,9 +150,7 @@ export function ShortDramaPage({ list }: { list: ShortDramaListResult }) {
</div>
) : null}
<div className="design-frame flex flex-col gap-6 pb-[43px]">
<AdBannersSlot variant="pc" />
<DownloadBanner />
<FriendLinksSlot />
</div>
</main>
<FloatingActions />
-9
View File
@@ -1,6 +1,5 @@
import Link from "next/link";
import { AdBannersSlot, AdIconsSlot } from "@/components/common/ads/slots";
import { EmptyState } from "@/components/common/empty-state";
import { Pagination } from "@/components/common/pagination";
import { buildPageHrefMap } from "@/components/common/pagination-map";
@@ -101,14 +100,6 @@ export function TagPage({ data }: { data: TagPageData }) {
<Pagination page={page} total={totalPages} hrefMap={hrefMap} className="max-lg:[&_form]:hidden" />
) : null}
<div className="hidden space-y-5 lg:block">
<AdIconsSlot variant="pc" />
<AdBannersSlot variant="pc" />
</div>
<div className="flex flex-col gap-[18px] lg:hidden">
<AdIconsSlot variant="h5" />
<AdBannersSlot variant="h5" />
</div>
</div>
<FloatingActions />
</main>
-7
View File
@@ -1,5 +1,4 @@
import { AdBannersSlot, AdIconsSlot, FriendLinksSlot, H5FriendLinksSlot } from "@/components/common/ads/slots";
import { ChannelHeader, H5ChannelHeader } from "@/components/common/channel-header";
import { FilterChipLink, FilterOptionLink } from "@/components/common/filter-link";
import { Pagination } from "@/components/common/pagination";
@@ -165,7 +164,6 @@ export function TopicPage({ data }: { data: TopicPageData }) {
className="flex w-full min-w-0 flex-col gap-[18px] overflow-x-clip px-4 py-3 lg:hidden"
>
<H5ChannelHeader eyebrow={layout.eyebrow} title={name} subtitle={subtitle} />
<AdIconsSlot variant="h5" />
<div className="flex scroll-mt-16 flex-col gap-[9px] rounded-2xl border border-[#292138] bg-[#110D19] px-[19px] py-4">
<TopicSortBar pathKey={pathKey} dataType={dataType} sortType={sortType} compact />
@@ -181,14 +179,11 @@ export function TopicPage({ data }: { data: TopicPageData }) {
gridClassName={layout.morePcClassName}
/>
<AdBannersSlot variant="h5" />
<H5FriendLinksSlot />
</main>
<main data-component="topic-page" data-datatype={dataType} className="hidden lg:block">
<div className="design-frame flex flex-col gap-6 py-[43px]">
<ChannelHeader eyebrow={layout.eyebrow} title={name} subtitle={subtitle} />
<AdIconsSlot variant="pc" />
<div className="flex scroll-mt-24 flex-col gap-4 rounded-[17px] border border-[#34304B] bg-[#151326] px-5 py-4">
<TopicSortBar pathKey={pathKey} dataType={dataType} sortType={sortType} />
@@ -204,9 +199,7 @@ export function TopicPage({ data }: { data: TopicPageData }) {
<div className="design-frame flex flex-col gap-6 pb-[43px]">
<MoreTopicGrid topics={moreTopics} dataType={dataType} gridClassName={layout.morePcClassName} />
<AdBannersSlot variant="pc" />
<DownloadBanner />
<FriendLinksSlot />
</div>
</main>
<FloatingActions />
+5 -4
View File
@@ -2,7 +2,7 @@
import type { ReactNode } from "react";
import { AdBanners, AdIcons } from "@/components/common/ads";
import { AdBanners } from "@/components/common/ads";
import { BackButton } from "@/components/common/back-button";
import { HlAction, InfoList, SectionTitle, TagLinks, VideoRecommend, type InfoRow, type TagLinkItem } from "@/components/media-page/parts";
import { XgPlayer } from "@/components/player/xg-player";
@@ -30,8 +30,8 @@ export function H5VideoPlay({
infoRows,
tags,
onPlaySuccess,
adGrid,
bannerAds,
squareAds,
liked,
likeNum,
collected,
@@ -46,8 +46,9 @@ export function H5VideoPlay({
infoRows: InfoRow[];
tags: TagLinkItem[];
onPlaySuccess?: () => void;
adGrid?: ReactNode;
bannerAds?: ReactNode;
/** 播放页小图标广告(AList) */
squareAds?: ReactNode;
}) {
const title = detail.title || "视频";
const desc = detail.desc?.trim() || "";
@@ -91,7 +92,7 @@ export function H5VideoPlay({
) : null}
</article>
{adGrid ?? <AdIcons variant="h5" />}
{squareAds}
<VideoRecommend items={related} compact />
@@ -4,7 +4,7 @@ import { toast } from "@heroui/react";
import { useEffect, useState, type ReactNode } from "react";
import { openLoginDialog } from "@/components/auth/login-dialog";
import { AdBanners, AdIcons } from "@/components/common/ads";
import { AdBanners } from "@/components/common/ads";
import { formatDay, formatDuration } from "@/components/common/media-meta";
import { PcPlayer } from "@/components/drama-play/pc-player";
import { FloatingActions } from "@/components/home/floating-actions";
@@ -56,16 +56,18 @@ export function VideoPlayPage({
src,
related = [],
promo,
adIcons,
adGrid,
topAds,
h5Ads,
bannerAds,
}: {
detail: VideoDetail;
src: string;
related?: ShortDramaItem[];
promo?: ReactNode;
adIcons?: ReactNode;
adGrid?: ReactNode;
/** 服务端渲染的播放页小图标(AList):PC 顶部 */
topAds?: ReactNode;
/** 服务端渲染的播放页小图标(AList):H5 正文下方 */
h5Ads?: ReactNode;
bannerAds?: ReactNode;
}) {
const [liked, setLiked] = useState(Boolean(detail.isLike));
@@ -226,6 +228,7 @@ export function VideoPlayPage({
className="relative mx-auto hidden w-[1700px] flex-col gap-8 pt-6 pb-14 [zoom:var(--page-scale,1)] lg:flex"
>
<PageBreadcrumb items={crumbs} />
{topAds}
<PcPlayer
src={src}
@@ -263,7 +266,6 @@ export function VideoPlayPage({
) : null}
</article>
{adIcons ?? <AdIcons variant="pc" labels={false} />}
<VideoRecommend items={related} />
@@ -283,8 +285,8 @@ export function VideoPlayPage({
onLike={liking ? () => undefined : toggleLike}
onCollect={collecting ? () => undefined : toggleCollect}
onShare={share}
adGrid={adGrid}
bannerAds={bannerAds}
squareAds={h5Ads}
/>
<div className="max-lg:hidden">
+3 -37
View File
@@ -1,5 +1,5 @@
import { pickVideoCardTags } from "@/components/common/card-tags";
import { genres, regions, sorts, type Genre, type Region, type ShortDramaItem, type Sort } from "@/components/short-drama/data";
import { sorts, type ShortDramaItem, type Sort } from "@/components/short-drama/data";
import { formatHeat } from "@/components/ranking/data";
import type { VideoCategoryListItem, VideoListItem, VideoListResp } from "@/lib/api/types";
@@ -13,16 +13,8 @@ export function videoSortType(sort: VideoSort): 1 | 2 {
}
export function mapVideoListItem(item: VideoListItem): ShortDramaItem | null {
if (item.type === 2) {
return {
kind: "ad",
id: `ad-${item.advertiseId || item.id || item.link || "unknown"}`,
title: (item.title || "").trim() || "广告",
subtitle: "",
cover: (item.coverImg || "").trim(),
href: (item.link || "").trim() || undefined,
};
}
// 信息流广告(type=2)不展示:网页只保留后台 5 个站点广告位
if (item.type === 2) return null;
if (!item.id) return null;
const slug = (item.slug || "").trim();
@@ -77,29 +69,3 @@ export function buildVideoList(
};
}
/** @deprecated 本地 mock,供「更多」等未接接口页面临时使用 */
const adSlots = new Set([5, 11, 17, 24, 25]);
export function getVideos(genre: Genre, sort: Sort, page: number, region: Region = "全部"): ShortDramaItem[] {
const seed = `${genres.indexOf(genre)}-${sorts.indexOf(sort)}-${regions.indexOf(region)}-${page}`;
return Array.from({ length: VIDEO_PAGE_SIZE }, (_, index): ShortDramaItem => {
const id = `video-${seed}-${index}`;
const cover = "";
if (adSlots.has(index)) {
return { kind: "ad", id, title: "广告文案", subtitle: "我是副标题", cover };
}
return {
kind: "drama",
id,
title: "有恩必报",
subtitle: "权谋交锋爱意藏在局中",
tags: [{ name: genre === "全部" ? "标签" : genre }],
heat: "25.8万 热度",
episodes: "30集",
badge: "original",
cover,
};
});
}
+1 -22
View File
@@ -26,7 +26,7 @@ function RankLabel({ rank, className = "" }: { rank?: number; className?: string
}
/** 视频卡元信息:观看数 + 发布日期 */
function VideoMeta({ item, className }: { item: Extract<ShortDramaItem, { kind: "drama" }>; className: string }) {
function VideoMeta({ item, className }: { item: ShortDramaItem; className: string }) {
const day = formatDay(item.date);
return (
<p className={`flex min-w-0 items-center gap-2 text-[#8E8C99] ${className}`}>
@@ -42,27 +42,7 @@ function VideoMeta({ item, className }: { item: Extract<ShortDramaItem, { kind:
);
}
function AdVideoCard({ item, compact }: { item: ShortDramaItem; compact?: boolean }) {
return (
<a
href={item.href || (compact ? "#h5-download" : "#download")}
target={item.href ? "_blank" : undefined}
rel={item.href ? "sponsored nofollow noopener noreferrer" : undefined}
className={`group flex flex-col ${compact ? "gap-1.5" : "w-[324px] gap-2.5"}`}
>
<span className={`${HL_COVER} aspect-[16/10]`}>
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt={item.title} className={HL_COVER_IMG} />
<span className="absolute top-0 left-0 rounded-br-md bg-white/85 px-1.5 py-0.5 text-[10px] leading-[14px] text-black">
推广
</span>
</span>
<span className={`line-clamp-2 text-white ${compact ? "text-sm leading-5" : "media-card-title-md"}`}>{item.title}</span>
</a>
);
}
export function VideoCard({ item, rank }: { item: ShortDramaItem; rank?: number }) {
if (item.kind === "ad") return <AdVideoCard item={item} />;
const href = item.href || videoHref(item.id, item.slug);
return (
@@ -92,7 +72,6 @@ export function H5VideoCard({
/** @deprecated 新卡片不在封面显示集数,保留参数兼容调用方 */
showEpisodes?: boolean;
}) {
if (item.kind === "ad") return <AdVideoCard item={item} compact />;
const href = item.href || videoHref(item.id, item.slug);
return (
-7
View File
@@ -1,4 +1,3 @@
import { AdBannersSlot, AdIconsSlot, FriendLinksSlot, H5FriendLinksSlot } from "@/components/common/ads/slots";
import { ChannelHeader, H5ChannelHeader } from "@/components/common/channel-header";
import { EmptyState } from "@/components/common/empty-state";
import { FilterChipLink, FilterOptionLink } from "@/components/common/filter-link";
@@ -27,7 +26,6 @@ export function VideoPage({ list }: { list: VideoListResult }) {
<SeoBreadcrumb items={[{ name: "首页", href: "/" }, { name: "视频" }]} />
<main data-component="video-page" className="flex w-full min-w-0 flex-col gap-[18px] overflow-x-clip px-4 py-3 lg:hidden">
<H5ChannelHeader title="视频" />
<AdIconsSlot variant="h5" />
<div
id="h5-list"
@@ -91,14 +89,11 @@ export function VideoPage({ list }: { list: VideoListResult }) {
)}
</section>
<AdBannersSlot variant="h5" />
<H5FriendLinksSlot />
</main>
<main className="hidden lg:block">
<div className="design-frame flex flex-col gap-6 py-[43px]">
<ChannelHeader title="视频" />
<AdIconsSlot variant="pc" />
<div
id="pc-list"
@@ -157,9 +152,7 @@ export function VideoPage({ list }: { list: VideoListResult }) {
</div>
) : null}
<div className="design-frame flex flex-col gap-6 pb-[43px]">
<AdBannersSlot variant="pc" />
<DownloadBanner />
<FriendLinksSlot />
</div>
</main>
<FloatingActions />
-64
View File
@@ -1,64 +0,0 @@
import type { AppCategoryInfo, AppListResp } from "@/lib/api/types";
export type WelfareApp = {
id: string;
title: string;
subtitle: string;
icon: string;
href: string;
};
export type WelfareCategory = {
id: string;
title: string;
description: string;
apps: WelfareApp[];
};
/** PC 默认展示 12,移动端 8 */
export const WELFARE_DESKTOP_COLLAPSE_LIMIT = 12;
export const WELFARE_MOBILE_COLLAPSE_LIMIT = 8;
/**
* 按接口返回的 categoryList / appList 顺序组装,不做二次排序。
* 规则对齐 jha-1043 applistser.BuildPageVM。
*/
export function buildWelfareCategories(data: AppListResp | null | undefined): WelfareCategory[] {
if (!data) return [];
let list = data.categoryList ?? [];
if (!list.length && data.category?.id) {
list = [data.category];
}
if (!list.length) return [];
return list.map((cat) => mapCategory(cat));
}
function mapCategory(cat: AppCategoryInfo): WelfareCategory {
const apps: WelfareApp[] = [];
for (const app of cat.appList ?? []) {
const name = (app.name || "").trim();
if (!name) continue;
const href = (app.url || "").trim() || "#";
const intro = (app.intro || "").trim() || (app.description || "").trim();
apps.push({
id: String(app.id),
title: name,
subtitle: intro,
icon: (app.logo || "").trim(),
href,
});
}
const title = (cat.title || "").trim() || "应用分类";
return {
id: `app-category-${cat.id}`,
title,
description: (cat.intro || "").trim(),
apps,
};
}
@@ -1,132 +0,0 @@
"use client";
import { useState } from "react";
import { DecryptedImage } from "@/components/common/decrypted-image";
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
import {
WELFARE_DESKTOP_COLLAPSE_LIMIT,
WELFARE_MOBILE_COLLAPSE_LIMIT,
type WelfareCategory,
} from "./data";
type Variant = "pc" | "h5";
const variants = {
pc: {
rowSize: WELFARE_DESKTOP_COLLAPSE_LIMIT,
section: "scroll-mt-24 gap-6",
heading: "gap-3",
title: "text-4xl leading-[50px] font-normal text-white/90",
description: "text-lg leading-6 text-white/55",
descriptionFirst: "font-semibold text-white/70",
grid: "grid-cols-6 gap-x-4 gap-y-6 xl:grid-cols-12",
icon: "aspect-square w-full max-w-[120px] rounded-[18px]",
appTitle: "text-base leading-[22px] font-medium text-white/90",
appSubtitle: "text-xs leading-[18px] text-white/55",
tile: "gap-2",
button: "h-[50px] rounded-full px-6 text-lg leading-6",
showExpandIcon: true,
},
h5: {
rowSize: WELFARE_MOBILE_COLLAPSE_LIMIT,
section: "scroll-mt-16 gap-3",
heading: "w-full gap-3",
title: "text-lg leading-6 font-semibold text-white/90",
description: "text-sm leading-5 font-normal text-white/55",
descriptionFirst: "",
grid: "grid-cols-[repeat(4,77px)] justify-between gap-y-3",
icon: "size-[77px] overflow-hidden rounded-[18px]",
appTitle: "text-sm leading-5 font-medium text-white",
appSubtitle: "text-xs leading-[18px] font-normal text-white",
tile: "w-[77px] gap-1 rounded-xl",
button: "rounded-[25px] px-[18px] py-2.5 text-xs leading-[18px]",
showExpandIcon: false,
},
} as const;
export function WelfareCategorySection({
category,
variant,
isFirst,
}: {
category: WelfareCategory;
variant: Variant;
isFirst: boolean;
}) {
const styles = variants[variant];
const [expanded, setExpanded] = useState(false);
const limit = styles.rowSize;
const total = category.apps.length;
const expandable = total > limit;
const apps = expandable && !expanded ? category.apps.slice(0, limit) : category.apps;
return (
<section
id={variant === "h5" ? `h5-${category.id}` : category.id}
className={`flex w-full flex-col items-center ${styles.section}`}
>
<div className={`flex flex-col items-center text-center ${styles.heading}`}>
<h2 className={styles.title}>{category.title}</h2>
{category.description ? (
<p
className={`w-full whitespace-pre-line ${styles.description} ${
isFirst ? styles.descriptionFirst : ""
}`}
>
{category.description}
</p>
) : null}
</div>
{apps.length ? (
<div className={`grid w-full ${styles.grid}`}>
{apps.map((app) => (
<a
key={app.id}
href={app.href}
target="_blank"
rel="sponsored nofollow noopener noreferrer"
aria-label={app.title}
className={`flex min-w-0 flex-col items-center text-center ${styles.tile}`}
>
<DecryptedImage
src={app.icon || null}
fallback={IMG_PLACEHOLDER}
alt={app.title}
title={app.title}
className={`object-cover ${styles.icon}`}
/>
<span className={`w-full truncate ${styles.appTitle}`}>{app.title}</span>
{app.subtitle ? (
<span className={`w-full truncate ${styles.appSubtitle}`}>{app.subtitle}</span>
) : null}
</a>
))}
</div>
) : (
<p className="text-sm leading-5 text-white/45">该分类暂无应用</p>
)}
{expandable ? (
<button
type="button"
aria-expanded={expanded}
onClick={() => setExpanded((value) => !value)}
className={`cursor-pointer inline-flex items-center justify-center gap-2.5 bg-[#F12B9E] text-white ${styles.button}`}
>
<span>{expanded ? "收起" : `显示全部${total}个站点`}</span>
{styles.showExpandIcon ? (
<img
src="/images/trangle_down.svg"
alt=""
aria-hidden="true"
className={`size-3 shrink-0 transition-transform ${expanded ? "rotate-180" : ""}`}
/>
) : null}
</button>
) : null}
</section>
);
}
-56
View File
@@ -1,56 +0,0 @@
import { AdBannersSlot, AdIconsSlot, FriendLinksSlot, H5FriendLinksSlot } from "@/components/common/ads/slots";
import { FloatingActions } from "@/components/home/floating-actions";
import { DownloadBanner } from "@/components/home/page-sections";
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
import type { WelfareCategory } from "./data";
import { WelfareCategorySection } from "./welfare-category-section";
import { WelfareCategoryTabs } from "./welfare-tabs";
export function WelfarePage({ categories }: { categories: WelfareCategory[] }) {
if (!categories.length) {
return (
<div data-component="welfare-page" className="flex min-h-[200px] flex-col items-center justify-center gap-2 text-sm leading-5 text-white/45">
<SeoBreadcrumb items={[{ name: "首页", href: "/" }, { name: "福利应用" }]} />
<h1 className="text-base font-semibold text-white/70">福利应用</h1>
<p>暂无福利应用</p>
</div>
);
}
return (
<>
<SeoBreadcrumb items={[{ name: "首页", href: "/" }, { name: "福利应用" }]} />
<h1 className="sr-only">福利应用</h1>
<main
data-component="welfare-page"
className="flex w-full min-w-0 flex-col items-center gap-[18px] overflow-x-clip bg-[#07080B] px-4 pt-3 pb-[18px] lg:hidden"
>
<WelfareCategoryTabs variant="h5" categories={categories} />
{categories.map((category, index) => (
<WelfareCategorySection key={category.id} category={category} variant="h5" isFirst={index === 0} />
))}
<AdIconsSlot variant="h5" />
<AdBannersSlot variant="h5" />
<H5FriendLinksSlot />
</main>
<main className="hidden lg:block">
<div className="mx-auto flex w-[calc(100%-64px)] max-w-[1700px] flex-col gap-5 pt-10 pb-9">
<div className="flex flex-col items-center gap-9">
<WelfareCategoryTabs variant="pc" categories={categories} />
{categories.map((category, index) => (
<WelfareCategorySection key={category.id} category={category} variant="pc" isFirst={index === 0} />
))}
</div>
<AdIconsSlot variant="pc" />
<AdBannersSlot variant="pc" />
<DownloadBanner />
<FriendLinksSlot />
</div>
</main>
<FloatingActions />
</>
);
}
-66
View File
@@ -1,66 +0,0 @@
"use client";
import { useState } from "react";
import type { WelfareCategory } from "./data";
type Variant = "pc" | "h5";
const tabStyles = {
pc: {
tabs: "flex w-full flex-wrap items-center justify-center gap-[18px]",
tab: "min-h-[50px] max-w-full px-5 py-2 text-lg leading-6 whitespace-normal",
tabActive: "bg-[#F12B9E] text-white",
tabIdle: "bg-black/5 text-[#999999] outline outline-black/10 -outline-offset-1 hover:text-white",
},
h5: {
tabs: "flex w-full gap-1.5 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
tab: "shrink-0 rounded-[25px] px-3 py-1.5 text-xs leading-[18px]",
tabActive: "bg-[#F12B9E] text-white",
tabIdle:
"bg-white/5 text-white/55 outline outline-1 -outline-offset-1 outline-white/10",
},
} as const;
export function WelfareCategoryTabs({
variant,
categories,
}: {
variant: Variant;
categories: WelfareCategory[];
}) {
const [activeId, setActiveId] = useState(categories[0]?.id ?? "");
const styles = tabStyles[variant];
const validActive =
categories.some((item) => item.id === activeId) ? activeId : (categories[0]?.id ?? "");
if (validActive !== activeId) {
setActiveId(validActive);
}
const jumpTo = (id: string) => {
setActiveId(id);
const prefix = variant === "h5" ? "h5-" : "";
document.getElementById(`${prefix}${id}`)?.scrollIntoView({ behavior: "smooth" });
};
return (
<div className={styles.tabs}>
{categories.map((category) => {
const active = category.id === validActive;
return (
<button
key={category.id}
type="button"
aria-pressed={active}
onClick={() => jumpTo(category.id)}
className={`cursor-pointer text-center break-words transition-colors ${variant === "pc" ? "rounded-full shrink-0" : ""} ${styles.tab} ${
active ? styles.tabActive : styles.tabIdle
}`}
>
{category.title}
</button>
);
})}
</div>
);
}
+54
View File
@@ -0,0 +1,54 @@
import { apiRequest } from "./client";
import type { AdvertiseInfo } from "./types";
/** 广告服务里本站的 appId */
export const AD_APP_ID = 12;
/** POST /api/app/ads/click 请求体(后端三个字段均必填,int64) */
export type AdClickReq = {
appId: number;
adsId: number;
location: number;
};
/** 后端 id 为数字字符串(如 "1138200002");非正整数视为无效 */
function positiveId(value: unknown) {
const number =
typeof value === "number"
? value
: typeof value === "string" && /^\d+$/.test(value.trim())
? Number(value.trim())
: NaN;
return Number.isSafeInteger(number) && number > 0 ? number : 0;
}
/**
* 广告链接上的上报数据(展开到 <a> 上)。
* id / location 任一无效时返回空对象,点击不上报。
*/
export function adClickData(ad: Pick<AdvertiseInfo, "id" | "location">) {
const adsId = positiveId(ad.id);
const location = positiveId(ad.location);
if (!adsId || !location) return {};
return { "data-ads-id": String(adsId), "data-ads-location": String(location) };
}
/** 从点击目标向上找最近的广告元素,组装上报参数 */
export function adClickPayload(target: EventTarget | null): AdClickReq | null {
if (!(target instanceof Element)) return null;
const el = target.closest<HTMLElement>("[data-ads-id]");
if (!el) return null;
const adsId = positiveId(el.dataset.adsId);
const location = positiveId(el.dataset.adsLocation);
return adsId && location ? { appId: AD_APP_ID, adsId, location } : null;
}
/** 客户端:广告点击上报 POST /api/app/ads/click(keepalive,页面跳走也能发出) */
export function reportAdClick(payload: AdClickReq, token?: string | null) {
return apiRequest<null>("/api/app/ads/click", {
method: "POST",
body: payload,
token,
keepalive: true,
});
}
-22
View File
@@ -1,22 +0,0 @@
import { cacheLife, cacheTag } from "next/cache";
import { apiRequest } from "./client";
import { serverFetchJson } from "./server-fetch";
import type { AppListResp } from "./types";
/** categoryId=0 表示默认(返回全部分类列表);浏览器端可用 */
export function fetchAppList(categoryId = 0, token?: string | null) {
return apiRequest<AppListResp>(`/api/app/applist/list?categoryId=${categoryId}`, {
method: "GET",
token,
});
}
/** 服务端渲染拉取应用列表(带缓存) */
export async function getAppListCached(categoryId = 0): Promise<AppListResp> {
"use cache";
cacheLife("hours");
cacheTag("applist");
return serverFetchJson<AppListResp>(`/api/app/applist/list?categoryId=${categoryId}`);
}
+4 -1
View File
@@ -30,6 +30,8 @@ type RequestOptions = {
token?: string | null;
headers?: Record<string, string>;
signal?: AbortSignal;
/** 页面卸载后仍发出(上报类接口) */
keepalive?: boolean;
};
function withClientHeaders(extra?: Record<string, string>) {
@@ -41,7 +43,7 @@ function withClientHeaders(extra?: Record<string, string>) {
}
export async function apiRequest<T>(path: string, options: RequestOptions = {}): Promise<T> {
const { method = "GET", body, token, headers = {}, signal } = options;
const { method = "GET", body, token, headers = {}, signal, keepalive } = options;
const requestHeaders: Record<string, string> = withClientHeaders(headers);
if (body !== undefined) {
@@ -56,6 +58,7 @@ export async function apiRequest<T>(path: string, options: RequestOptions = {}):
headers: requestHeaders,
body: body === undefined ? undefined : JSON.stringify(body),
signal,
keepalive,
});
const text = await response.text();
-2
View File
@@ -14,8 +14,6 @@ export async function getHomeBaseCached(): Promise<HomeBaseResp> {
timeoutMs: 8_000,
maxAttempts: 2,
});
// 调试:服务端终端打印 home/base
console.info("[home/base]", data);
return data;
} catch {
return {};
+13 -47
View File
@@ -48,40 +48,6 @@ export type UpdateProfileReq = {
newPassword?: string;
};
export type ImageUploadData = {
id?: string;
sourceNameFs?: string;
url?: string;
};
/** GET /api/app/applist/list */
export type AppInfoData = {
id: number;
categoryId?: number;
name: string;
intro?: string;
description?: string;
logo?: string;
url?: string;
sort?: number;
advitiseId?: string;
location?: number;
};
export type AppCategoryInfo = {
id: number;
code?: number;
title: string;
intro?: string;
sort?: number;
appList?: AppInfoData[];
};
export type AppListResp = {
category?: AppCategoryInfo;
categoryList?: AppCategoryInfo[];
};
/** GET /api/app/playlet/content/list */
export type PlayletData = {
id: number;
@@ -659,21 +625,21 @@ export type AnnouncementItem = {
};
/** GET /api/app/home/base → AdvitiseData(广告位列表) */
/**
* home/base → advitise:网页只使用后台「站点」的 5 个广告位
* (接口还会返回 App 用的其它广告位,网页不读取)。
*/
export type AdvitiseData = {
homeList?: AdvertiseInfo[];
detailTopList?: AdvertiseInfo[];
nineGridList?: AdvertiseInfo[];
detailbannerList?: AdvertiseInfo[];
launchScreenList?: AdvertiseInfo[];
floatingList?: AdvertiseInfo[];
AList?: AdvertiseInfo[];
BList?: AdvertiseInfo[];
/** 位置 1「弹窗」,素材 600×800 */
dialogList?: AdvertiseInfo[];
postList?: AdvertiseInfo[];
mustAppList?: AdvertiseInfo[];
titleAppList?: AdvertiseInfo[];
friendList?: AdvertiseInfo[];
videoList?: AdvertiseInfo[];
/** 位置 2「9宫格」,小方块 */
nineGridList?: AdvertiseInfo[];
/** 位置 3「详情横幅」,素材 720×150 */
detailbannerList?: AdvertiseInfo[];
/** 位置 12「播放页小图标」,小方块 */
AList?: AdvertiseInfo[];
/** 位置 13「首页小图标」,小方块 */
BList?: AdvertiseInfo[];
};
/** GET /api/app/home/base → AnnouncementInfo(回家的路 / 公告地址) */
+24
View File
@@ -0,0 +1,24 @@
/**
* 全站弹窗共用的页面滚动锁(引用计数)。
* 各弹窗不再各自记录 / 恢复 body.overflow:多个弹窗同时打开、以任意顺序关闭时,
* 只有最后一个关闭才恢复滚动,避免「后关的弹窗把 hidden 当成原值恢复」导致全站无法滚动。
*/
let lockCount = 0;
let previousOverflow = "";
export function lockBodyScroll(): () => void {
if (typeof document === "undefined") return () => undefined;
if (lockCount === 0) {
previousOverflow = document.body.style.overflow === "hidden" ? "" : document.body.style.overflow;
document.body.style.overflow = "hidden";
}
lockCount += 1;
let released = false;
return () => {
if (released) return;
released = true;
lockCount = Math.max(0, lockCount - 1);
if (lockCount === 0) document.body.style.overflow = previousOverflow;
};
}