Compare commits

...
9 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
谢宇宁 eeb9986923 整体UI调整 2026-10-26 19:51:59 +07:00
谢宇宁 c8895f407c 整体UI调整 2026-10-26 19:51:53 +07:00
212 changed files with 2176 additions and 9431 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
@@ -36,7 +36,7 @@ pnpm dev:test # test.env
| `config/test.env` | 测试构建 / 测试服 |
| `config/production.env` | 正式构建 / 正式服 |
关键变量示例:`API_PROXY_TARGET` / `NEXT_PUBLIC_API_BASE_URL`、`PORT`、`NEXT_PUBLIC_SITE_URL`、`NEXT_PUBLIC_GTAG_ID`、`NEXT_PUBLIC_TRACKER_APP_ID`。
关键变量示例:`API_PROXY_TARGET` / `NEXT_PUBLIC_API_BASE_URL`、`PORT`、`NEXT_PUBLIC_SITE_URL`。
## 打包与部署
+2 -4
View File
@@ -2,9 +2,7 @@ APP_ENV=development
# 浏览器走同源 /api/*(配合 next.config rewrites)
NEXT_PUBLIC_API_BASE_URL=
# 上游地址:rewrites + 服务端直连
API_PROXY_TARGET=https://mdcom-wz.80sygtm.com
API_PROXY_TARGET=https://webhghlapi.mfcg.me
PORT=26122
NEXT_PUBLIC_TRACKER_APP_ID=JHA-1046
NEXT_PUBLIC_GTAG_ID=G-748CPNEVP5
NEXT_PUBLIC_SITE_URL=https://haijiaosq.net
NEXT_PUBLIC_SITE_URL=https://huangguohl.com
NEXT_PUBLIC_APP_VERSION=1.0.0
+3 -5
View File
@@ -1,8 +1,6 @@
APP_ENV=production
NEXT_PUBLIC_API_BASE_URL=
API_PROXY_TARGET=http://139.162.44.29:26119
PORT=3000
NEXT_PUBLIC_TRACKER_APP_ID=JHA-1046
NEXT_PUBLIC_GTAG_ID=G-748CPNEVP5
NEXT_PUBLIC_SITE_URL=https://denv08sep7brv.cloudfront.net
API_PROXY_TARGET=https://webhghlapi.mfcg.me
PORT=20123
NEXT_PUBLIC_SITE_URL=https://huangguohl.com
NEXT_PUBLIC_APP_VERSION=1.0.0
+2 -4
View File
@@ -1,8 +1,6 @@
APP_ENV=test
NEXT_PUBLIC_API_BASE_URL=
API_PROXY_TARGET=https://mdcom-wz.80sygtm.com
API_PROXY_TARGET=https://webhghlapi.mfcg.me
PORT=26122
NEXT_PUBLIC_TRACKER_APP_ID=JHA-1046
NEXT_PUBLIC_GTAG_ID=G-748CPNEVP5
NEXT_PUBLIC_SITE_URL=https://haijiaosq.net
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
printf '\n正式服发布完成;日志:%s\n' "$RUN_LOG"
fi
# 清理之前误建的 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" "$@"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 117 KiB

+1 -18
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 434 KiB

After

Width:  |  Height:  |  Size: 65 KiB

-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="M11.9457 9.54601C11.773 9.71335 11.6937 9.95535 11.733 10.1927L12.3257 13.4727C12.3757 13.7507 12.2584 14.032 12.0257 14.1927C11.7977 14.3593 11.4944 14.3793 11.2457 14.246L8.29305 12.706C8.19038 12.6513 8.07638 12.622 7.95971 12.6187H7.77905C7.71638 12.628 7.65505 12.648 7.59905 12.6787L4.64571 14.226C4.49971 14.2993 4.33438 14.3253 4.17238 14.2993C3.77771 14.2247 3.51438 13.8487 3.57905 13.452L4.17238 10.172C4.21171 9.93268 4.13238 9.68935 3.95971 9.51935L1.55238 7.18602C1.35105 6.99068 1.28105 6.69735 1.37305 6.43268C1.46238 6.16868 1.69038 5.97602 1.96571 5.93268L5.27905 5.45202C5.53105 5.42602 5.75238 5.27268 5.86571 5.04602L7.32571 2.05268C7.36038 1.98602 7.40505 1.92468 7.45905 1.87268L7.51905 1.82602C7.55038 1.79135 7.58638 1.76268 7.62638 1.73935L7.69905 1.71268L7.81238 1.66602H8.09305C8.34371 1.69202 8.56438 1.84202 8.67971 2.06602L10.159 5.04602C10.2657 5.26402 10.473 5.41535 10.7124 5.45202L14.0257 5.93268C14.3057 5.97268 14.5397 6.16602 14.6324 6.43268C14.7197 6.70002 14.6444 6.99335 14.439 7.18602L11.9457 9.54601Z" fill="#EBE5F2"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

-3
View File
@@ -1,3 +0,0 @@
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.5037 4H8.49635C6.08759 4 4 6.1581 4 8.64822V17.9447C4 20.4348 6.08759 22.5929 8.49635 22.5929H8.9781C8.9781 22.5929 8.9781 22.7589 9.13869 22.7589L10.9051 24.751C11.2263 25.083 11.708 25.083 11.8686 24.751L13.4745 22.9249L13.635 22.7589H21.5037C23.9124 22.7589 26 20.6008 26 18.1107V8.64822C26 6.1581 23.9124 4 21.5037 4ZM8.81752 15.1225C7.85401 15.1225 7.21168 14.2925 7.21168 13.2964C7.21168 12.3004 8.0146 11.4704 8.9781 11.4704C9.94161 11.4704 10.7445 12.3004 10.7445 13.2964C10.5839 14.2925 9.78102 15.1225 8.81752 15.1225ZM14.9197 15.1225C13.9562 15.1225 13.1533 14.2925 13.1533 13.2964C13.1533 12.3004 13.9562 11.4704 14.9197 11.4704C15.8832 11.4704 16.6861 12.3004 16.6861 13.2964C16.6861 14.2925 15.8832 15.1225 14.9197 15.1225ZM21.1825 15.1225C20.219 15.1225 19.4161 14.2925 19.4161 13.2964C19.4161 12.3004 20.219 11.4704 21.1825 11.4704C22.146 11.4704 22.9489 12.3004 22.9489 13.2964C22.7883 14.2925 21.9854 15.1225 21.1825 15.1225Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 164 KiB

-6
View File
@@ -1,6 +0,0 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14.1631 4L17.9639 7.80081L7.80081 17.9639L4.00357 17.9603L4 14.1631L14.1631 4Z" stroke="white" stroke-width="1.5" stroke-linecap="square"/>
<path d="M14.7239 10.207L11.7377 7.22084" stroke="white" stroke-width="1.5" stroke-linecap="square"/>
<path d="M17.4989 20.3018H17.5089" stroke="#E5365C" stroke-width="1.5" stroke-linecap="square" stroke-linejoin="round"/>
<path d="M17.4219 17.4603C17.8468 17.4591 18.259 17.3278 18.5925 17.0874C18.926 16.847 19.1615 16.5115 19.2613 16.1345C19.3611 15.7575 19.3195 15.3609 19.1431 15.0081C18.9667 14.6552 18.6657 14.3666 18.2882 14.1884C17.9111 14.0121 17.4798 13.9574 17.0643 14.0333C16.6489 14.1092 16.2737 14.3111 16 14.6063" stroke="#E5365C" stroke-width="1.38889" stroke-linecap="square" stroke-linejoin="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 873 B

-3
View File
@@ -1,3 +0,0 @@
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M22.5937 9.02503H23.7499C24.0815 9.02503 24.3994 9.15673 24.6338 9.39115C24.8682 9.62557 24.9999 9.94351 24.9999 10.275V16.525C24.9999 16.8566 24.8682 17.1745 24.6338 17.4089C24.3994 17.6433 24.0815 17.775 23.7499 17.775H21.4743L16.2437 10.2188L15.6356 9.35753L11.9131 11.0763C11.6725 11.1873 11.4028 11.2191 11.1431 11.1669C10.0068 10.9388 9.62556 10.5413 9.99931 9.97378C10.3612 9.42441 11.9012 8.31941 14.6199 6.65753C14.6912 6.61378 14.7649 6.57628 14.8406 6.54628C15.9824 6.00878 17.2856 6.20253 18.7493 7.12816C19.9594 7.89544 21.248 8.53133 22.5931 9.02503H22.5937ZM5.85369 17.7107C5.60502 17.6275 5.38878 17.4683 5.23556 17.2556C5.08235 17.0428 4.99992 16.7872 4.99994 16.525V10.275C4.99994 9.94351 5.13163 9.62557 5.36606 9.39115C5.60048 9.15673 5.91842 9.02503 6.24994 9.02503H9.13244L9.12744 9.02941C8.95343 9.18616 8.8155 9.3788 8.72318 9.59403C8.63086 9.80927 8.58634 10.042 8.5927 10.2761C8.59905 10.5102 8.65614 10.7401 8.76 10.9501C8.86387 11.16 9.01205 11.3448 9.19431 11.4919C9.64481 11.8555 10.1817 12.0965 10.7527 12.1914C11.3238 12.2864 11.9098 12.2321 12.4537 12.0338L15.2656 11.0088L17.2374 13.8588C17.2981 13.9169 17.3527 13.981 17.4006 14.05L20.8568 19.045C20.9589 19.1926 21.028 19.3604 21.0595 19.5371C21.0909 19.7138 21.084 19.8951 21.0391 20.0689C20.9942 20.2426 20.9124 20.4046 20.7993 20.544C20.6862 20.6833 20.5445 20.7966 20.3837 20.8763L14.8624 23.6082C14.6062 23.735 14.3249 23.7663 14.0624 23.7132L14.2668 23.5063C14.7294 23.0383 14.9888 22.4068 14.9888 21.7488C14.9888 21.0908 14.7294 20.4593 14.2668 19.9913L10.2668 15.9438C10.0924 15.7673 9.88473 15.6272 9.65578 15.5315C9.42684 15.4359 9.18118 15.3866 8.93306 15.3866C8.68494 15.3866 8.43929 15.4359 8.21034 15.5315C7.9814 15.6272 7.77371 15.7673 7.59931 15.9438L5.85306 17.7107H5.85369ZM9.77244 17.1732L13.3199 20.7619C13.4729 20.9168 13.5828 21.1089 13.6387 21.3192C13.6946 21.5296 13.6946 21.7509 13.6387 21.9613L13.4599 22.6382C13.4197 22.7899 13.343 22.9296 13.2364 23.045C13.1299 23.1603 12.9968 23.2479 12.8487 23.3001C12.7005 23.3523 12.5419 23.3675 12.3866 23.3444C12.2313 23.3213 12.0839 23.2606 11.9574 23.1675L7.39619 19.8125C7.25165 19.7062 7.1317 19.57 7.0445 19.4131C6.9573 19.2563 6.90489 19.0825 6.89084 18.9036C6.87679 18.7247 6.90142 18.5449 6.96306 18.3763C7.0247 18.2078 7.1219 18.0545 7.24806 17.9269L7.99369 17.1719C8.10995 17.0543 8.24839 16.9609 8.40101 16.8971C8.55362 16.8334 8.71736 16.8006 8.88275 16.8006C9.04814 16.8006 9.21188 16.8334 9.3645 16.8971C9.51711 16.9609 9.65556 17.0543 9.77181 17.1719L9.77244 17.1732Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

-3
View File
@@ -1,3 +0,0 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.244 2.25H21.552L14.325 10.51L22.827 21.75H16.17L10.956 14.933L4.99001 21.75H1.68003L9.41002 12.915L1.25403 2.25H8.08004L12.793 8.481L18.244 2.25ZM17.083 19.77H18.916L7.08401 4.12601H5.117L17.083 19.77Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 334 B

-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 fill-rule="evenodd" clip-rule="evenodd" d="M8.00004 14.6673C4.32004 14.6673 1.33337 11.6873 1.33337 8.00065C1.33337 4.32065 4.32004 1.33398 8.00004 1.33398C11.6867 1.33398 14.6667 4.32065 14.6667 8.00065C14.6667 11.6873 11.6867 14.6673 8.00004 14.6673ZM10.1267 10.474C10.2067 10.5207 10.2934 10.5473 10.3867 10.5473C10.5534 10.5473 10.72 10.4607 10.8134 10.3007C10.9534 10.0673 10.88 9.76065 10.64 9.61398L8.26671 8.20065V5.12065C8.26671 4.84065 8.04004 4.62065 7.76671 4.62065C7.49337 4.62065 7.26671 4.84065 7.26671 5.12065V8.48732C7.26671 8.66065 7.36004 8.82065 7.51337 8.91398L10.1267 10.474Z" fill="#EBE5F2"/>
</svg>

Before

Width:  |  Height:  |  Size: 725 B

-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="M8.68029 1.8439L13.569 5.35274C13.8054 5.52246 13.9981 5.74604 14.131 6.005C14.2639 6.26395 14.3333 6.55083 14.3333 6.8419V12.5002C14.3333 13.5127 13.5125 14.3336 12.5 14.3336H9.99996V11.6669C9.99996 10.5624 9.10446 9.6669 7.99996 9.6669C6.89546 9.6669 5.99996 10.5624 5.99996 11.6669V14.3336H3.49996C2.48746 14.3336 1.66663 13.5127 1.66663 12.5002V6.84207C1.66664 6.55097 1.73597 6.26406 1.86888 6.00507C2.00179 5.74609 2.19447 5.52247 2.43096 5.35274L7.31963 1.8439C7.51792 1.70156 7.75587 1.625 7.99996 1.625C8.24405 1.625 8.482 1.70156 8.68029 1.8439Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 684 B

-3
View File
@@ -1,3 +0,0 @@
<svg width="22" height="21" viewBox="0 0 22 21" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.25731 0.913926C9.45132 0.632201 9.71152 0.401732 10.0154 0.242481C10.3192 0.08323 10.6575 0 11.001 0C11.3445 0 11.6828 0.08323 11.9867 0.242481C12.2905 0.401732 12.5507 0.632201 12.7447 0.913926L15.3437 4.68251C15.5195 4.93642 15.7769 5.12351 16.0737 5.21037L20.4841 6.50189C20.8135 6.59856 21.1142 6.7735 21.3603 7.01158C21.6064 7.24966 21.7904 7.54373 21.8965 7.86835C22.0026 8.19298 22.0276 8.53841 21.9693 8.87477C21.9109 9.21114 21.7711 9.52832 21.5617 9.79892L18.7581 13.4195C18.5689 13.6639 18.47 13.9655 18.4796 14.2729L18.6054 18.8405C18.6148 19.1817 18.5404 19.52 18.3886 19.8263C18.2369 20.1325 18.0124 20.3974 17.7346 20.598C17.4567 20.7987 17.1339 20.9291 16.794 20.978C16.4541 21.0268 16.1073 20.9926 15.7836 20.8784L11.452 19.3473C11.16 19.2441 10.8411 19.2441 10.5491 19.3473L6.21747 20.8784C5.89381 20.9929 5.54696 21.0272 5.20694 20.9785C4.86692 20.9297 4.54398 20.7993 4.26607 20.5986C3.98816 20.3979 3.76366 20.1329 3.61199 19.8266C3.46033 19.5202 3.38607 19.1817 3.39565 18.8405L3.52243 14.2729C3.53106 13.9651 3.43269 13.6637 3.24389 13.4195L0.43936 9.79892C0.229598 9.52832 0.0893836 9.21098 0.0308657 8.87438C-0.0276522 8.53778 -0.00270912 8.19208 0.103534 7.86722C0.209777 7.54237 0.394116 7.24816 0.640579 7.01008C0.887043 6.772 1.1882 6.59724 1.51795 6.50093L5.92741 5.20847C6.22515 5.12256 6.48255 4.93546 6.65736 4.68155L9.25731 0.912972V0.913926Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

-3
View File
@@ -1,3 +0,0 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 5.18754L12.7463 0L0 12.5857L0.00468579 17.7687H0.0103087V17.9991L17.4049 18V16.612H6.42984L18 5.18754Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 275 B

-3
View File
@@ -1,3 +0,0 @@
<svg width="18" height="16" viewBox="0 0 18 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.86557 15.7314C9.3385 16.0897 8.66224 16.0897 8.13564 15.7304C6.6909 14.745 5.6664 14.1472 3.75858 12.524C-4.52307 6.04287 2.54537 -3.88171 8.99967 1.58305C15.4375 -3.87772 22.5318 6.0274 14.2408 12.524C12.3447 14.1387 11.3042 14.7529 9.86557 15.7314Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 382 B

-3
View File
@@ -1,3 +0,0 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.5208 7.77456C16.017 7.77325 15.5197 7.66441 15.0635 7.45569C14.6074 7.24696 14.2036 6.94338 13.8803 6.56623L9.53973 8.58588C9.76828 9.12026 9.88395 9.69419 9.87982 10.2733C9.87569 10.8523 9.75184 11.4247 9.51569 11.9559L12.9487 13.6921C13.418 12.9583 14.1511 12.4222 15.0043 12.1887C15.8576 11.9552 16.7693 12.0413 17.5609 12.4301C18.3525 12.8189 18.9668 13.4823 19.2834 14.2902C19.6 15.0982 19.596 15.9925 19.2723 16.7978C18.9485 17.603 18.3284 18.2612 17.5334 18.6432C16.7384 19.0253 15.8258 19.1037 14.9747 18.863C14.1236 18.6223 13.3953 18.08 12.9325 17.3423C12.4697 16.6045 12.3058 15.7247 12.4731 14.8751L8.81557 13.0228C8.22859 13.7043 7.44038 14.1921 6.55866 14.4196C5.67695 14.6472 4.74476 14.6034 3.88953 14.2941C3.0343 13.9849 2.29777 13.4253 1.78061 12.692C1.26345 11.9586 0.990907 11.0872 1.00023 10.1969C1.00956 9.30659 1.3003 8.44082 1.83271 7.71793C2.36512 6.99504 3.11322 6.45032 3.97474 6.15822C4.83627 5.86611 5.76918 5.84089 6.64594 6.08599C7.52271 6.3311 8.30054 6.83457 8.87312 7.52758L13.2497 5.49002C13.0102 4.8109 12.998 4.07504 13.2149 3.38871C13.4318 2.70238 13.8665 2.10113 14.4563 1.67179C15.0461 1.24245 15.7605 1.00725 16.4961 1.00016C17.2318 0.993081 17.9507 1.21448 18.5491 1.63238C19.1475 2.05028 19.5943 2.64305 19.825 3.32506C20.0557 4.00708 20.0584 4.74304 19.8326 5.42664C19.6069 6.11024 19.1644 6.70609 18.5691 7.12813C17.9738 7.55017 17.2565 7.77654 16.5208 7.77456Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

-3
View File
@@ -1,3 +0,0 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 4L9 7L6 10" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke="#8F8F9F"/>
</svg>

Before

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

-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="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.9024 1.90607H13.9699L9.45307 7.06857L14.7668 14.0936H10.6062L7.34744 9.83294L3.61868 14.0936H1.54994L6.38119 8.57169L1.28369 1.90607H5.54995L8.49557 5.80044L11.9024 1.90607ZM11.1768 12.8561H12.3224L4.92743 3.07857H3.69805L11.1768 12.8561Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 14 KiB

-5
View File
@@ -1,5 +0,0 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 15V5" stroke="#F12B9E" stroke-width="1.66667" stroke-linecap="round"/>
<path d="M10 15.0003L10 10.417" stroke="#F12B9E" stroke-width="1.66667" stroke-linecap="round"/>
<path d="M5 15.0003V9.16699" stroke="#F12B9E" stroke-width="1.66667" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 378 B

-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.99963 10.1162C10.8921 10.1162 13.3336 10.587 13.3336 12.4004C13.3332 14.2141 10.8758 14.667 7.99963 14.667C5.10803 14.667 2.66663 14.1971 2.66663 12.3838C2.66678 10.57 5.12345 10.1162 7.99963 10.1162ZM7.99963 1.33398C9.95903 1.33398 11.5289 2.90332 11.5289 4.86133C11.5289 6.81935 9.95904 8.38965 7.99963 8.38965C6.04105 8.38947 4.47034 6.81924 4.47034 4.86133C4.47035 2.90343 6.04106 1.33416 7.99963 1.33398Z" fill="#EBE5F2"/>
</svg>

Before

Width:  |  Height:  |  Size: 543 B

-5
View File
@@ -1,5 +0,0 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="3" width="18" height="18" rx="3" stroke="white" stroke-width="2"/>
<path d="M12 7H15C16.1046 7 17 7.89543 17 9V12" stroke="white" stroke-width="2" stroke-linecap="round"/>
<path d="M12 17L9 17C7.89543 17 7 16.1046 7 15L7 12" stroke="white" stroke-width="2" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 400 B

-3
View File
@@ -1,3 +0,0 @@
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.25 18.5004C16.25 17.9481 15.8023 17.5004 15.25 17.5004H13.75C11.6995 17.4996 9.68779 18.0593 7.93234 19.119C6.46694 20.0036 5.22666 21.2085 4.30157 22.6382C4.14181 22.8851 3.74985 22.7944 3.75 22.5004C3.75 15.9332 8.81391 10.5491 15.2501 10.0398C15.8007 9.99619 16.25 9.55264 16.25 9.00035V5.83098C16.25 4.99247 17.2199 4.5263 17.8747 5.05011L27.7739 12.9695C28.2743 13.3698 28.2743 14.1309 27.7739 14.5312L17.8747 22.4506C17.2199 22.9744 16.25 22.5082 16.25 21.6697V18.5004Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 328 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

-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

-5
View File
@@ -1,5 +0,0 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="3" width="18" height="18" rx="3" stroke="white" stroke-width="2"/>
<path d="M18 11L15 11C13.8954 11 13 10.1046 13 9L13 6" stroke-width="2" stroke-linecap="round" stroke="white"/>
<path d="M6 13H9C10.1046 13 11 13.8954 11 15V18" stroke-width="2" stroke-linecap="round" stroke="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 403 B

-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 fill-rule="evenodd" clip-rule="evenodd" d="M1.33337 8.01067C1.33337 4.49873 4.14004 1.33398 8.01337 1.33398C11.8 1.33398 14.6667 4.43864 14.6667 7.99064C14.6667 12.1101 11.3067 14.6673 8.00004 14.6673C6.90671 14.6673 5.69337 14.3735 4.72004 13.7993C4.38004 13.5924 4.09337 13.4388 3.72671 13.559L2.38004 13.9596C2.04004 14.0664 1.73337 13.7993 1.83337 13.4388L2.28004 11.9432C2.35337 11.7363 2.34004 11.5159 2.23337 11.3423C1.66004 10.2874 1.33337 9.13235 1.33337 8.01067ZM7.13337 8.01067C7.13337 8.48471 7.51337 8.86528 7.98671 8.87196C8.46004 8.87196 8.84004 8.48471 8.84004 8.01734C8.84004 7.5433 8.46004 7.16273 7.98671 7.16273C7.52004 7.15605 7.13337 7.5433 7.13337 8.01067ZM10.2067 8.01734C10.2067 8.48471 10.5867 8.87196 11.06 8.87196C11.5334 8.87196 11.9134 8.48471 11.9134 8.01734C11.9134 7.5433 11.5334 7.16273 11.06 7.16273C10.5867 7.16273 10.2067 7.5433 10.2067 8.01734ZM4.91337 8.87196C4.44671 8.87196 4.06004 8.48471 4.06004 8.01734C4.06004 7.5433 4.44004 7.16273 4.91337 7.16273C5.38671 7.16273 5.76671 7.5433 5.76671 8.01734C5.76671 8.48471 5.38671 8.86528 4.91337 8.87196Z" fill="#EBE5F2"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

File diff suppressed because one or more lines are too long
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

+1 -34
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 35 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 15 KiB

+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 (
+2 -2
View File
@@ -8,7 +8,7 @@ export async function generateMetadata(): Promise<Metadata> {
return resolvePageMetadata({
seoInfo: {
title: "关于我们",
description: "了解海角社区的品牌、产品与服务。",
description: "了解黄果黑料的品牌、产品与服务。",
},
canonical: "/about",
});
@@ -22,7 +22,7 @@ export default async function Page() {
data={buildWebPageJSONLD({
path: "/about",
title: "关于我们",
description: "了解海角社区的品牌、产品与服务。",
description: "了解黄果黑料的品牌、产品与服务。",
type: "AboutPage",
breadcrumbs: [
["首页", "/"],
-12
View File
@@ -1,12 +0,0 @@
import type { Metadata } from "next";
import { FavoritesPage } from "@/components/favorites/favorites-page";
export const metadata: Metadata = {
title: "我的收藏 - 海角社区",
robots: { index: false, follow: false },
};
export default function Page() {
return <FavoritesPage />;
}
-31
View File
@@ -1,31 +0,0 @@
import type { Metadata } from "next";
import { FeedbackPage } from "@/components/feedback/feedback-page";
import { JsonLd } from "@/components/seo/json-ld";
import { buildWebPageJSONLD, getHomeBaseSEOCached } from "@/lib/seo";
export const metadata: Metadata = {
title: "问题反馈 - 海角社区",
robots: { index: false, follow: false },
};
export default async function Page() {
const siteSeo = await getHomeBaseSEOCached();
return (
<>
<JsonLd
data={buildWebPageJSONLD({
path: "/feedback",
title: "问题反馈",
description: "向海角社区提交问题反馈与建议。",
breadcrumbs: [
["首页", "/"],
["问题反馈", "/feedback"],
],
siteName: siteSeo.siteName,
})}
/>
<FeedbackPage gmailAddr={siteSeo.config?.gmailAddr} />
</>
);
}
-58
View File
@@ -1,58 +0,0 @@
import type { Metadata } from "next";
import { Suspense } from "react";
import { PageLoading } from "@/components/common/page-loading";
import { HelpPage } from "@/components/help/help-page";
import { HELP_RICHTEXT_TITLES, loadRichTextFirst } from "@/components/richtext/load-richtext";
import { JsonLd } from "@/components/seo/json-ld";
import { buildWebPageJSONLD, getHomeBaseSEOCached, mergeSEO, resolvePageMetadata } from "@/lib/seo";
export async function generateMetadata(): Promise<Metadata> {
const data = await loadRichTextFirst([...HELP_RICHTEXT_TITLES]);
return resolvePageMetadata({
seoInfo: mergeSEO(data?.seoInfo, {
title: "帮助中心",
description:
data?.seoInfo?.description?.trim() ||
data?.desc?.trim() ||
"查看海角社区常见问题、播放帮助与客服支持信息。",
}),
canonical: "/help",
});
}
async function HelpRouteContent() {
const data = await loadRichTextFirst([...HELP_RICHTEXT_TITLES]);
const siteSeo = await getHomeBaseSEOCached();
const seo = mergeSEO(data?.seoInfo, siteSeo.seo);
return (
<>
<JsonLd
data={buildWebPageJSONLD({
path: "/help",
title: seo.title || "帮助中心",
description:
seo.description ||
data?.desc ||
data?.title ||
"查看海角社区常见问题、播放帮助与客服支持信息。",
type: "WebPage",
breadcrumbs: [
["首页", "/"],
["帮助中心", "/help"],
],
siteName: siteSeo.siteName,
})}
/>
<HelpPage data={data} />
</>
);
}
export default function Page() {
return (
<Suspense fallback={<PageLoading />}>
<HelpRouteContent />
</Suspense>
);
}
-12
View File
@@ -1,12 +0,0 @@
import type { Metadata } from "next";
import { HistoryPage } from "@/components/history/history-page";
export const metadata: Metadata = {
title: "观看历史 - 海角社区",
robots: { index: false, follow: false },
};
export default function Page() {
return <HistoryPage />;
}
+8 -29
View File
@@ -2,16 +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 { TrackerHost } from "@/components/analytics/tracker-host";
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";
@@ -40,20 +40,17 @@ const pageScaleScript = `(function () {
window.addEventListener("resize", update);
})();`;
/** GA4 测量 ID(全站 head 注入) */
const GA4_MEASUREMENT_ID = "G-748CPNEVP5";
/** metadataBase 随请求 Host 变化,保证 rel=canonical 与访问地址一致 */
export async function generateMetadata(): Promise<Metadata> {
const origin = await getRequestOrigin();
return {
metadataBase: new URL(origin),
title: {
default: "海角社区",
default: "黄果黑料",
template: "%s",
},
description: "发现好故事,开启追剧时光",
applicationName: "海角社区",
applicationName: "黄果黑料",
verification: {
google: "0Bby47n1AEIB3W8wtLZ-oFQ3l8xRqRT78oA0JVRJ5pM",
yandex: "69b55a6aa9ee9a5f",
@@ -64,8 +61,8 @@ export async function generateMetadata(): Promise<Metadata> {
openGraph: {
type: "website",
locale: "zh_CN",
siteName: "海角社区",
images: [{ url: OG_DEFAULT_IMAGE, alt: "海角社区" }],
siteName: "黄果黑料",
images: [{ url: OG_DEFAULT_IMAGE, alt: "黄果黑料" }],
},
twitter: {
card: "summary_large_image",
@@ -93,35 +90,17 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
// beforeInteractive 会给 html 加 is-cn-browser 等 class,需压制告警
suppressHydrationWarning
>
<head>
{/* Google Analytics (GA4) */}
<Script
async
src={`https://www.googletagmanager.com/gtag/js?id=${GA4_MEASUREMENT_ID}`}
strategy="afterInteractive"
/>
<Script id="ga4-gtag" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA4_MEASUREMENT_ID}');
`.trim()}
</Script>
</head>
<body className="flex min-h-full flex-col">
<Suspense fallback={null}>
<RequestHeadersPrime />
</Suspense>
<Suspense fallback={null}>
<TrackerHost />
</Suspense>
<Suspense fallback={null}>
<HomeBaseDebugSlot />
<SiteAnalytics />
</Suspense>
<SiteShell>{children}</SiteShell>
<GuestAuthBootstrap />
<AuthUnauthorizedBridge />
<AdClickReporter />
<LoginDialogHost />
<Suspense fallback={null}>
<DownloadDialogSlot />
-12
View File
@@ -1,12 +0,0 @@
import type { Metadata } from "next";
import { LikesPage } from "@/components/likes/likes-page";
export const metadata: Metadata = {
title: "我的点赞 - 海角社区",
robots: { index: false, follow: false },
};
export default function Page() {
return <LikesPage />;
}
+3 -3
View File
@@ -30,8 +30,8 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
return resolvePageMetadata({
seoInfo: {
title: data.title,
description: data.subtitle || `浏览海角社区「${data.title}」更多精选内容。`,
keyworld: ["海角社区", data.title],
description: data.subtitle || `浏览黄果黑料「${data.title}」更多精选内容。`,
keyworld: ["黄果黑料", data.title],
},
page: pageNum,
canonical: moreListHref(pathKey, pageNum),
@@ -72,7 +72,7 @@ export default async function Page({ params }: { params: Params }) {
data={buildWebPageJSONLD({
path: moreListHref(pathKey, page),
title: data.title,
description: data.subtitle || `浏览海角社区「${data.title}」更多精选内容。`,
description: data.subtitle || `浏览黄果黑料「${data.title}」更多精选内容。`,
type: "CollectionPage",
breadcrumbs: [
["首页", "/"],
+1 -1
View File
@@ -9,7 +9,7 @@ import { moreListHref } from "@/components/more/route";
/** 无 id 的空壳页;正式内容在 /more/{id},本页不索引 */
export const metadata: Metadata = {
title: "更多内容 - 海角社区",
title: "更多内容 - 黄果黑料",
robots: { index: false, follow: false },
};
+6 -6
View File
@@ -4,7 +4,7 @@ import { NavPage } from "@/components/nav/nav-page";
import { JsonLd } from "@/components/seo/json-ld";
import { getHomeBaseCached } from "@/lib/api/home";
import type { AppTranslationInfo, ConfigInfo } from "@/lib/api/types";
import { buildWebPageJSONLD, mergeSEO, resolvePageMetadata } from "@/lib/seo";
import { buildWebPageJSONLD, mergeSEO, resolvePageMetadata, SITE_NAME } from "@/lib/seo";
async function loadNavBase(): Promise<{
config?: ConfigInfo;
@@ -31,17 +31,17 @@ export async function generateMetadata(): Promise<Metadata> {
description: config?.dhDescription,
keyworld: config?.dhKeyworld,
},
siteName: config?.dhSiteName?.trim() || undefined,
fallbackTitle: `${config?.dhSiteName?.trim() || "海角社区"} · 官方导航`,
fallbackDescription: `${config?.dhSiteName?.trim() || "海角社区"}官方导航页,提供最新访问线路、永久地址、APP 下载与官方联系方式。`,
fallbackKeywords: [config?.dhSiteName || "海角社区", "官方导航", "最新地址"].filter(Boolean) as string[],
siteName: SITE_NAME,
fallbackTitle: `${SITE_NAME} · 官方导航`,
fallbackDescription: `${SITE_NAME}官方导航页,提供最新访问线路、永久地址、APP 下载与官方联系方式。`,
fallbackKeywords: [SITE_NAME, "官方导航", "最新地址"],
canonical: "/nav",
});
}
export default async function Page() {
const { config, bottonTranslations } = await loadNavBase();
const siteName = config?.dhSiteName?.trim() || config?.webSiteName?.trim() || "海角社区";
const siteName = SITE_NAME;
const seo = mergeSEO(
{ title: config?.dhTitle, description: config?.dhDescription, keyworld: config?.dhKeyworld },
{ title: config?.webTitle, description: config?.webDescription, keyworld: config?.webKeyworld },
+1 -1
View File
@@ -5,7 +5,7 @@ import { GoBackButton } from "@/components/not-found/go-back-button";
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
export const metadata: Metadata = {
title: "页面不存在 - 海角社区",
title: "页面不存在 - 黄果黑料",
robots: { index: false, follow: false },
};
+5 -7
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";
@@ -48,9 +47,9 @@ export async function generateMetadata(): Promise<Metadata> {
// seoInfo → home/base 公共 web* → 代码兜底
return resolvePageMetadata({
seoInfo: home?.seoInfo,
fallbackTitle: "海角社区 - 热门短剧在线看",
fallbackDescription: "海角社区汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。",
fallbackKeywords: ["海角社区", "短剧", "在线短剧", "热门短剧"],
fallbackTitle: "黄果黑料 - 热门短剧在线看",
fallbackDescription: "黄果黑料汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。",
fallbackKeywords: ["黄果黑料", "短剧", "在线短剧", "热门短剧"],
canonical: "/",
});
}
@@ -64,9 +63,9 @@ export default async function Home() {
: null;
const seo = mergeSEO(home?.seoInfo, siteSeo.seo);
const homeTitle = seo.title || "海角社区 - 热门短剧在线看";
const homeTitle = seo.title || "黄果黑料 - 热门短剧在线看";
const homeDescription =
seo.description || "海角社区汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。";
seo.description || "黄果黑料汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。";
const itemListUrls =
home?.homeBannerData
?.filter((item): item is PlayletData & { id: number } => Boolean(item?.id))
@@ -75,7 +74,6 @@ export default async function Home() {
return (
<>
<HomeDataDebug home={merged} base={base} />
<JsonLd
data={buildWebPageJSONLD({
path: "/",
+2 -2
View File
@@ -8,7 +8,7 @@ export async function generateMetadata(): Promise<Metadata> {
return resolvePageMetadata({
seoInfo: {
title: "隐私政策",
description: "查看海角社区隐私政策与个人信息保护说明。",
description: "查看黄果黑料隐私政策与个人信息保护说明。",
},
canonical: "/privacy",
});
@@ -22,7 +22,7 @@ export default async function Page() {
data={buildWebPageJSONLD({
path: "/privacy",
title: "隐私政策",
description: "查看海角社区隐私政策与个人信息保护说明。",
description: "查看黄果黑料隐私政策与个人信息保护说明。",
type: "WebPage",
breadcrumbs: [
["首页", "/"],
-12
View File
@@ -1,12 +0,0 @@
import type { Metadata } from "next";
import { ProfilePage } from "@/components/profile/profile-page";
export const metadata: Metadata = {
title: "个人中心 - 海角社区",
robots: { index: false, follow: false },
};
export default function Page() {
return <ProfilePage />;
}
+3 -3
View File
@@ -39,8 +39,8 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
return resolvePageMetadata({
seoInfo: {
title: `${tabText}排行榜`,
description: `查看海角社区实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
keyworld: ["海角社区", "排行榜", tabText],
description: `查看黄果黑料实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
keyworld: ["黄果黑料", "排行榜", tabText],
},
page: pageNum,
canonical: rankingHref(tab, pageNum),
@@ -100,7 +100,7 @@ async function RankingContent({ params }: { params: Params }) {
data={buildWebPageJSONLD({
path: rankingHref(tab, page),
title: `${tabText}排行榜`,
description: `查看海角社区实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
description: `查看黄果黑料实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
type: "CollectionPage",
breadcrumbs: [
["首页", "/"],
+2 -22
View File
@@ -1,37 +1,17 @@
import type { MetadataRoute } from "next";
import { getHomeBaseCached } from "@/lib/api/home";
import { getRequestOrigin, getSiteOrigin } from "@/lib/seo/site";
/** 从地址字符串解析 origin(支持无协议域名) */
function originFromAddr(value?: string | null) {
const text = value?.trim();
if (!text) return undefined;
try {
const withProto = /^https?:\/\//i.test(text) ? text : `https://${text}`;
return new URL(withProto).origin;
} catch {
return undefined;
}
}
/** 基础 robots:私有页 / 搜索 disallow,并声明 sitemap(永久域名取 config.foreverUrlAddr) */
/** 基础 robots:私有页 / 搜索 disallow,并声明 sitemap(取本站域名) */
export default async function robots(): Promise<MetadataRoute.Robots> {
const forever = originFromAddr((await getHomeBaseCached()).config?.foreverUrlAddr);
const configured = process.env.NEXT_PUBLIC_SITE_URL?.trim();
const origin = forever || (configured ? getSiteOrigin() : await getRequestOrigin());
const origin = configured ? getSiteOrigin() : await getRequestOrigin();
return {
rules: [
{
userAgent: "*",
allow: "/",
disallow: [
"/profile",
"/history",
"/favorites",
"/likes",
"/settings",
"/feedback",
// 前缀匹配:/search、/search/短剧/... 均不抓
"/search",
],
+2 -2
View File
@@ -27,8 +27,8 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
return resolvePageMetadata({
seoInfo: {
title: `搜索「${parsed.query}」`,
description: `在海角社区搜索「${parsed.query}」的${parsed.type}结果。`,
keyworld: ["海角社区", "搜索", parsed.query, parsed.type],
description: `在黄果黑料搜索「${parsed.query}」的${parsed.type}结果。`,
keyworld: ["黄果黑料", "搜索", parsed.query, parsed.type],
},
page: parsed.page,
canonical: searchListHref(parsed.query, parsed.type, parsed.page),
+2 -2
View File
@@ -17,8 +17,8 @@ function first(value: string | string[] | undefined) {
export async function generateMetadata(): Promise<Metadata> {
return resolvePageMetadata({
fallbackTitle: "搜索",
fallbackDescription: "搜索海角社区短剧与视频。",
fallbackKeywords: ["海角社区", "搜索"],
fallbackDescription: "搜索黄果黑料短剧与视频。",
fallbackKeywords: ["黄果黑料", "搜索"],
canonical: "/search",
// 搜索入口不收录;robots.txt 同步 Disallow /search
robots: { index: false, follow: false },
-12
View File
@@ -1,12 +0,0 @@
import type { Metadata } from "next";
import { SettingsPage } from "@/components/settings/settings-page";
export const metadata: Metadata = {
title: "账号设置 - 海角社区",
robots: { index: false, follow: false },
};
export default function Page() {
return <SettingsPage />;
}
-12
View File
@@ -1,12 +0,0 @@
import type { Metadata } from "next";
import { EditProfilePage } from "@/components/settings/edit-profile-page";
export const metadata: Metadata = {
title: "编辑个人资料 - 海角社区",
robots: { index: false, follow: false },
};
export default function Page() {
return <EditProfilePage />;
}
+47 -25
View File
@@ -13,12 +13,12 @@ import {
playHref,
RECOMMEND_DISPLAY_COUNT,
resolvePlayURL,
totalEpisodeOf,
type DramaDetail,
type DramaPlayView,
type RelatedDrama,
} from "@/components/drama-detail/data";
import { DramaDetailPage } from "@/components/drama-detail/drama-detail-page";
import { RelatedAside } from "@/components/drama-detail/related-aside";
import { DramaPlayPage } from "@/components/drama-play/drama-play-page";
import { JsonLd } from "@/components/seo/json-ld";
import {
@@ -39,6 +39,7 @@ import {
import { ShortDramaPage } from "@/components/short-drama/short-drama-page";
import {
getPlayletChapterInfoCached,
getPlayletGuessListCached,
getPlayletInfoCached,
getPlayletListCached,
getPlayletRecommendListCached,
@@ -47,11 +48,12 @@ 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,
buildWebPageJSONLD,
clipText,
getHomeBaseSEOCached,
mergeSEO,
resolveContentMetadata,
@@ -80,7 +82,10 @@ function playletLookup(idOrSlug: string): { id?: string; slug?: string } {
return { slug: idOrSlug };
}
/** 更多好剧:GET /api/app/playlet/recommend/list(sortList=1 推荐) */
/**
* 同类短剧推荐:先取 GET /api/app/playlet/recommend/list(sortList=1 推荐);
* 后台未配置推荐时为空,回退「猜你喜欢」(按当前短剧取相似)。
*/
async function loadPlayletRecommend(excludeId?: number | string | null): Promise<RelatedDrama[]> {
try {
const data = await getPlayletRecommendListCached({
@@ -88,9 +93,20 @@ async function loadPlayletRecommend(excludeId?: number | string | null): Promise
pageSize: RECOMMEND_PAGE_SIZE,
sortList: 1,
});
return mapPlayletRecommendList(data, { excludeId, limit: RECOMMEND_DISPLAY_COUNT });
const list = mapPlayletRecommendList(data, { excludeId, limit: RECOMMEND_DISPLAY_COUNT });
if (list.length) return list;
} catch (error) {
console.error("[short-drama/recommend]", error);
}
try {
const guess = await getPlayletGuessListCached({
id: excludeId ?? undefined,
pageNum: 1,
pageSize: RECOMMEND_PAGE_SIZE,
});
return mapPlayletRecommendList(guess, { excludeId, limit: RECOMMEND_DISPLAY_COUNT });
} catch (error) {
console.error("[short-drama/guess]", error);
return [];
}
}
@@ -140,9 +156,9 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
seoInfo: theme?.seoInfo,
fallbackTitle: themeName ? `短剧·${themeName}·${sortText}` : `短剧·${sortText}`,
fallbackDescription: themeName
? `浏览海角社区短剧「${themeName}」题材,按${sortText}发现精彩作品。`
: `浏览海角社区短剧列表,按${sortText}发现精彩作品。`,
fallbackKeywords: ["海角社区", "短剧", themeName, sortText].filter(Boolean),
? `浏览黄果黑料短剧「${themeName}」题材,按${sortText}发现精彩作品。`
: `浏览黄果黑料短剧列表,按${sortText}发现精彩作品。`,
fallbackKeywords: ["黄果黑料", "短剧", themeName, sortText].filter(Boolean),
page: pageNum,
canonical: shortDramaListHref(sortKey, pageNum, themeSlug),
});
@@ -151,20 +167,23 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
// 播放页 title:短剧标题 + 第几集 + 网页标题(站点名由 withSiteSuffix 追加)
if (page?.length === 1) {
const play = await loadPlayletPlay(decodeSegment(sort), page[0]);
if (!play) return resolveContentMetadata({ fallbackTitle: "海角社区" });
if (!play) return resolveContentMetadata({ fallbackTitle: "黄果黑料" });
const dramaTitle = play.detail.title?.trim() || "短剧";
const playTitle = `${dramaTitle} 第${play.episode}集`;
const { title: _seoTitle, ...playSeoRest } = play.detail.seoInfo ?? {};
// 播放页不用后台 title / description:每集都要带集数,避免同剧所有分集 TDK 完全相同
const { title: _seoTitle, description: seoDescription, ...playSeoRest } = play.detail.seoInfo ?? {};
void _seoTitle;
return resolveContentMetadata({
seoInfo: play.detail.seoInfo ? playSeoRest : null,
fallbackTitle: playTitle,
fallbackDescription:
play.detail.desc || `在线观看《${dramaTitle}》第${play.episode}集`,
fallbackDescription: [
`《${dramaTitle}》第${play.episode}集(共${totalEpisodeOf(play.detail)}集)`,
clipText(seoDescription || play.detail.desc, 70) || "按集收看,分集目录与同类短剧推荐见本页。",
].join(":"),
fallbackKeywords: [
"海角社区",
"黄果黑料",
"短剧",
"在线播放",
"分集",
dramaTitle,
playTitle,
...(play.detail.tagNames ?? []),
@@ -173,16 +192,19 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
canonical: playHref(play.detail.id, play.episode, play.detail.slug),
});
}
if (page?.length) return resolvePageMetadata({ fallbackTitle: "海角社区" });
if (page?.length) return resolvePageMetadata({ fallbackTitle: "黄果黑料" });
// 详情页:TDK 用短剧详情(playlet/info)
const detail = await loadPlayletDetail(decodeSegment(sort));
if (!detail) return resolveContentMetadata({ fallbackTitle: "海角社区" });
if (!detail) return resolveContentMetadata({ fallbackTitle: "黄果黑料" });
return resolveContentMetadata({
seoInfo: detail.seoInfo,
fallbackTitle: detail.title,
fallbackDescription: detail.desc || `在线观看《${detail.title}》,查看选集、剧情信息与相关推荐。`,
fallbackKeywords: ["海角社区", "短剧", detail.title || "", ...(detail.tagNames ?? [])].filter(
fallbackTitle: detail.title ? `${detail.title}(全${totalEpisodeOf(detail)}集)` : undefined,
fallbackDescription: [
`《${detail.title || "短剧"}》全${totalEpisodeOf(detail)}集${detail.themeNames?.[0] ? `·${detail.themeNames[0]}` : ""}`,
clipText(detail.desc, 90) || "剧情介绍、分集目录与同类短剧推荐。",
].join("|"),
fallbackKeywords: ["黄果黑料", "短剧", detail.title || "", ...(detail.tagNames ?? [])].filter(
Boolean,
),
canonical: dramaDetailHref(detail),
@@ -317,8 +339,8 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
const listDescription =
listSeo.description ||
(themeName
? `浏览海角社区短剧「${themeName}」题材,按${sortText}发现精彩作品。`
: `浏览海角社区短剧列表,按${sortText}发现精彩作品。`);
? `浏览黄果黑料短剧「${themeName}」题材,按${sortText}发现精彩作品。`
: `浏览黄果黑料短剧列表,按${sortText}发现精彩作品。`);
return (
<>
<JsonLd
@@ -365,10 +387,9 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
<DramaDetailPage
detail={mapped.detail}
related={mapped.related}
relatedAside={<RelatedAside items={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" />}
/>
</>
@@ -407,9 +428,10 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
episode={play.episode}
src={play.src}
related={play.related}
relatedAside={<RelatedAside items={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" />}
/>
</>
);
+5 -5
View File
@@ -87,7 +87,7 @@ export async function generateMetadata({
const query = await searchParams;
const parsed = parseTagSlug((await params).slug, query.kind, query.page);
if (!parsed) {
return resolvePageMetadata({ seoInfo: { title: "标签", keyworld: ["海角社区", "标签"] } });
return resolvePageMetadata({ seoInfo: { title: "标签", keyworld: ["黄果黑料", "标签"] } });
}
const { key, page, kind: preferredKind } = parsed;
@@ -98,15 +98,15 @@ export async function generateMetadata({
return resolvePageMetadata({
seoInfo: {
title: `${data.name}标签`,
description: `浏览海角社区「${data.name}」标签相关${unit}。`,
keyworld: ["海角社区", "标签", data.name, unit],
description: `浏览黄果黑料「${data.name}」标签相关${unit}。`,
keyworld: ["黄果黑料", "标签", data.name, unit],
},
page,
canonical: tagListHref(pathKey, page, data.kind),
});
} catch {
return resolvePageMetadata({
seoInfo: { title: key, keyworld: ["海角社区", "标签", key] },
seoInfo: { title: key, keyworld: ["黄果黑料", "标签", key] },
page,
canonical: tagListHref(key, page, preferredKind ?? "playlet"),
});
@@ -163,7 +163,7 @@ export default async function Page({
data={buildWebPageJSONLD({
path: tagListHref(pathKey, page, data.kind),
title: `${data.name}标签`,
description: `浏览海角社区「${data.name}」标签相关${unit}。`,
description: `浏览黄果黑料「${data.name}」标签相关${unit}。`,
type: "CollectionPage",
breadcrumbs: [
["首页", "/"],
+2 -2
View File
@@ -8,7 +8,7 @@ export async function generateMetadata(): Promise<Metadata> {
return resolvePageMetadata({
seoInfo: {
title: "用户协议",
description: "查看海角社区用户服务条款及平台使用规则。",
description: "查看黄果黑料用户服务条款及平台使用规则。",
},
canonical: "/terms",
});
@@ -22,7 +22,7 @@ export default async function Page() {
data={buildWebPageJSONLD({
path: "/terms",
title: "用户协议",
description: "查看海角社区用户服务条款及平台使用规则。",
description: "查看黄果黑料用户服务条款及平台使用规则。",
type: "WebPage",
breadcrumbs: [
["首页", "/"],
+3 -3
View File
@@ -166,8 +166,8 @@ export async function generateMetadata({
return resolvePageMetadata({
seoInfo: data.seoInfo ?? {
title: name,
description: (data.desc || "").trim() || `浏览海角社区专题「${name}」。`,
keyworld: ["海角社区", name],
description: (data.desc || "").trim() || `浏览黄果黑料专题「${name}」。`,
keyworld: ["黄果黑料", name],
},
page: parsed.page,
canonical,
@@ -229,7 +229,7 @@ export default async function Page({
data={buildWebPageJSONLD({
path: topicListHref(pathKey, { dataType: resolvedDataType, page, sortType }),
title: `${name} · ${topicSortLabel(sortType)}`,
description: desc || `浏览海角社区专题「${name}」。`,
description: desc || `浏览黄果黑料专题「${name}」。`,
type: "CollectionPage",
breadcrumbs: [
["首页", "/"],
+40 -15
View File
@@ -7,6 +7,7 @@ import { PageLoading } from "@/components/common/page-loading";
import { sortLabels } from "@/components/short-drama/data";
import {
buildVideoList,
mapVideoListItem,
VIDEO_PAGE_SIZE,
videoSorts,
videoSortType,
@@ -25,7 +26,6 @@ import {
VIDEO_RECOMMEND_DISPLAY_COUNT,
type VideoPlayView,
} from "@/components/video-play/data";
import { VideoRelatedAside } from "@/components/video-play/related-aside";
import { VideoPlayPage } from "@/components/video-play/video-play-page";
import { JsonLd } from "@/components/seo/json-ld";
import {
@@ -41,13 +41,14 @@ import { primeRequestForwardHeaders } from "@/lib/api/request-context";
import {
buildVideoPlayJSONLD,
buildWebPageJSONLD,
clipText,
getHomeBaseSEOCached,
mergeSEO,
resolveContentMetadata,
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[] }>;
@@ -98,7 +99,28 @@ async function loadVideoDetailWithRecommend(idOrSlug: string): Promise<VideoPlay
const mapped = await loadVideoDetail(idOrSlug);
if (!mapped) return null;
const related = await loadVideoRecommend(mapped.detail.id);
return { ...mapped, related: related.length ? related : mapped.related };
if (related.length) return { ...mapped, related };
if (mapped.related.length) return mapped;
return { ...mapped, related: await loadHotVideoFallback(mapped.detail.id) };
}
/** 推荐与 hotVideoList 都为空时:取视频库热度列表兜底,排除当前视频 */
async function loadHotVideoFallback(excludeId: number | string): Promise<ShortDramaItem[]> {
try {
const data = await getVideoListCached({
pageNum: 1,
pageSize: VIDEO_RECOMMEND_DISPLAY_COUNT + 4,
sortType: videoSortType("hot"),
});
return (data.list ?? [])
.filter((item) => item.type !== 2 && item.id && Number(item.id) !== Number(excludeId))
.map(mapVideoListItem)
.filter((item): item is ShortDramaItem => Boolean(item))
.slice(0, VIDEO_RECOMMEND_DISPLAY_COUNT);
} catch (error) {
console.error("[video/hot-fallback]", error);
return [];
}
}
export async function generateMetadata({ params }: { params: Params }): Promise<Metadata> {
@@ -119,23 +141,27 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
seoInfo: category?.seoInfo,
fallbackTitle: categoryName ? `视频·${categoryName}·${sortText}` : `视频·${sortText}`,
fallbackDescription: categoryName
? `浏览海角社区视频「${categoryName}」分类,按${sortText}发现精彩内容。`
: `浏览海角社区视频列表,按${sortText}发现精彩内容。`,
fallbackKeywords: ["海角社区", "视频", categoryName, sortText].filter(Boolean),
? `浏览黄果黑料视频「${categoryName}」分类,按${sortText}发现精彩内容。`
: `浏览黄果黑料视频列表,按${sortText}发现精彩内容。`,
fallbackKeywords: ["黄果黑料", "视频", categoryName, sortText].filter(Boolean),
page: pageNum,
canonical: videoListHref(sortKey, pageNum, categorySlug),
});
}
if (page?.length) return resolvePageMetadata({ fallbackTitle: "海角社区" });
if (page?.length) return resolvePageMetadata({ fallbackTitle: "黄果黑料" });
// 视频播放页:TDK 用视频详情(video/info)
const mapped = await loadVideoDetail(decodeSegment(sort));
const detail = mapped?.detail;
if (!detail) return resolveContentMetadata({ fallbackTitle: "海角社区" });
if (!detail) return resolveContentMetadata({ fallbackTitle: "黄果黑料" });
const tagNames = (detail.tags ?? []).map((tag) => tag.name?.trim() || "").filter(Boolean);
return resolveContentMetadata({
fallbackTitle: detail.title,
fallbackDescription: detail.desc || (detail.title ? `在线观看《${detail.title}》` : undefined),
fallbackKeywords: ["海角社区", "视频", detail.title || "", ...tagNames].filter(Boolean),
// 描述带发布日期与标签,避免与其它站点同文案
fallbackDescription: [
`视频《${detail.title || "未命名"}》${/^\d{4}-\d{2}-\d{2}/.test(detail.addedTime || "") ? `·${(detail.addedTime || "").slice(0, 10)}发布` : ""}${tagNames.length ? `·${tagNames.slice(0, 3).join("/")}` : ""}`,
clipText(detail.desc, 90) || "视频介绍与相关视频推荐。",
].join("|"),
fallbackKeywords: ["黄果黑料", "视频库", detail.title || "", ...tagNames].filter(Boolean),
ogType: "video.episode",
canonical: videoHref(String(detail.id), detail.slug),
});
@@ -231,8 +257,8 @@ async function VideoRouteContent({ params }: { params: Params }) {
const listDescription =
listSeo.description ||
(categoryName
? `浏览海角社区视频「${categoryName}」分类,按${sortText}发现精彩内容。`
: `浏览海角社区视频列表,按${sortText}发现精彩内容。`);
? `浏览黄果黑料视频「${categoryName}」分类,按${sortText}发现精彩内容。`
: `浏览黄果黑料视频列表,按${sortText}发现精彩内容。`);
return (
<>
<JsonLd
@@ -281,10 +307,9 @@ async function VideoRouteContent({ params }: { params: Params }) {
detail={mapped.detail}
src={mapped.src}
related={mapped.related}
relatedAside={<VideoRelatedAside items={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" />}
/>
</>
+8 -12
View File
@@ -4,16 +4,13 @@ import { cache } from "react";
import { JsonLd } from "@/components/seo/json-ld";
import { WayHomePage } from "@/components/way-home/way-home-page";
import { getHomeBaseCached } from "@/lib/api/home";
import type { AnnouncementInfo, ConfigInfo } from "@/lib/api/types";
import { buildWebPageJSONLD, resolvePageMetadata } from "@/lib/seo";
import type { AnnouncementInfo } from "@/lib/api/types";
import { buildWebPageJSONLD, resolvePageMetadata, SITE_NAME } from "@/lib/seo";
const loadWayHomeBase = cache(async (): Promise<{
announcement?: AnnouncementInfo;
config?: ConfigInfo;
}> => {
const loadWayHomeBase = cache(async (): Promise<{ announcement?: AnnouncementInfo }> => {
try {
const base = await getHomeBaseCached();
return { announcement: base.announcement, config: base.config };
return { announcement: base.announcement };
} catch (error) {
console.warn("[way-home] home/base failed", error);
return {};
@@ -21,8 +18,7 @@ const loadWayHomeBase = cache(async (): Promise<{
});
export async function generateMetadata(): Promise<Metadata> {
const { config } = await loadWayHomeBase();
const siteName = config?.webSiteName?.trim() || config?.dhSiteName?.trim() || "海角社区";
const siteName = SITE_NAME;
return resolvePageMetadata({
siteName,
seoInfo: {
@@ -35,8 +31,8 @@ export async function generateMetadata(): Promise<Metadata> {
}
export default async function Page() {
const { announcement, config } = await loadWayHomeBase();
const siteName = config?.webSiteName?.trim() || config?.dhSiteName?.trim() || "海角社区";
const { announcement } = await loadWayHomeBase();
const siteName = SITE_NAME;
return (
<>
<JsonLd
@@ -52,7 +48,7 @@ export default async function Page() {
siteName,
})}
/>
<WayHomePage announcement={announcement} config={config} />
<WayHomePage announcement={announcement} />
</>
);
}
-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>
);
}
+1 -2
View File
@@ -18,8 +18,7 @@ const sections: { title: string; paragraphs: string[]; slogan?: boolean }[] = [
{
title: "联系我们",
paragraphs: [
"商务合作:business@qimengshorts.com",
"用户反馈:support@qimengshorts.com",
"官方TG:@jbd125",
"服务时间:工作日 10:00–18:00",
],
},
+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 -70
View File
@@ -4,16 +4,23 @@ 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 { adTrackProps } from "@/components/common/ads/pick";
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() {
@@ -102,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,
@@ -120,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);
@@ -143,7 +184,7 @@ export function AdDialogHost({
if (hasDisplayedRef.current) writeSession(DISMISSED_KEY, signature);
removeSession(PROGRESS_KEY);
setIndex(-1);
setQueueIdle(true);
startGrid();
return;
}
setIndex(start);
@@ -152,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) => {
@@ -185,57 +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;
const adId = ad ? String(ad.advertiseCode || ad.id || "") : "";
const trackAttrs = ad
? adTrackProps(ad, {
slotKey: "dialog_ad",
slotName: "弹窗广告位",
adType: "interstitial",
})
: {};
useEffect(() => {
if (!ad?.images || !adId) return;
document.dispatchEvent(
new CustomEvent("dialog-ad:track", {
detail: {
eventType: "show",
element: Object.assign(document.createElement("div"), {
dataset: {
advertisingKey: "dialog_ad",
advertisingName: "弹窗广告",
advertisingId: adId,
dialogAdId: adId,
},
}),
},
}),
);
}, [ad, adId]);
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}
/>
);
@@ -252,35 +279,14 @@ export function AdDialogHost({
aria-label={ad.title || "广告"}
className="my-auto flex flex-col items-center gap-9 lg:gap-6"
onClick={(event) => event.target === event.currentTarget && showNext()}
data-advertising-key="dialog_ad"
data-advertising-name="弹窗广告"
data-advertising-id={adId}
data-dialog-ad-id={adId}
>
{ad.link ? (
<a
href={ad.link}
target="_blank"
rel="noopener noreferrer sponsored"
{...adClickData(ad)}
className="block"
{...trackAttrs}
onClick={() => {
document.dispatchEvent(
new CustomEvent("dialog-ad:track", {
detail: {
eventType: "click",
element: Object.assign(document.createElement("div"), {
dataset: {
advertisingKey: "dialog_ad",
advertisingName: "弹窗广告",
advertisingId: adId,
dialogAdId: adId,
},
}),
},
}),
);
}}
>
{picture}
</a>
@@ -290,7 +296,6 @@ export function AdDialogHost({
<button
type="button"
aria-label="关闭广告"
data-dialog-ad-close=""
onClick={showNext}
className="size-9 cursor-pointer"
>
@@ -303,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>
);
}
+22 -55
View File
@@ -6,7 +6,9 @@ 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";
/** 对齐 FOYA latestAddrPop(1041/1038):倒计时结束后才允许关闭,默认 3 秒 */
const CLOSE_DELAY_SECONDS = 3;
@@ -17,47 +19,26 @@ export type AddressDialogInfo = {
permanent: string;
latest: string;
telegram: string;
email: string;
mirrors: string[];
publishPage: string;
};
/** 从 home/base 的 announcement / config 组装地址弹窗文案(不改字段名映射,只做展示拼装) */
/**
* 组装地址弹窗文案:地址固定本站域名、联系方式固定官方 TG,不取接口字段
* (保留参数兼容调用方)。
*/
export function buildAddressDialogInfo(
announcement?: AnnouncementInfo | null,
config?: ConfigInfo | null,
_announcement?: AnnouncementInfo | null,
_config?: ConfigInfo | null,
): AddressDialogInfo | null {
const permanent = (announcement?.foreverUrlAddr || config?.foreverUrlAddr || "").trim();
const latest = (announcement?.newUrlAddr || config?.newUrlAddr || "").trim();
const telegram = (config?.tgGroup || config?.telegramAdd || config?.telegram || "").trim();
const email = (config?.gmailAddr || "").trim();
const mirrors = [
announcement?.newUrlAddr1,
announcement?.newUrlAddr2,
config?.newUrlAddr1,
config?.newUrlAddr2,
...(config?.useIngAddress ?? []),
]
.map((item) => item?.trim() || "")
.filter(Boolean)
.filter((item, index, list) => list.indexOf(item) === index);
const publishPage = (
announcement?.translationAddr ||
config?.translationAddr ||
config?.webAddr ||
"/way-home"
).trim();
if (!permanent && !latest && !mirrors.length && !telegram && !email) return null;
void _announcement;
void _config;
return {
permanent: permanent || latest,
latest: latest || permanent,
telegram,
email,
mirrors,
publishPage,
permanent: SITE_DOMAIN,
latest: SITE_DOMAIN,
telegram: OFFICIAL_TG_URL,
mirrors: [],
publishPage: "/way-home",
};
}
@@ -115,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]);
@@ -208,28 +188,17 @@ function AddressCard({
{info.latest ? <p>最新地址: {info.latest}</p> : null}
{info.telegram ? (
<p>
TG交流群:{" "}
官方TG:{" "}
<a
href={info.telegram}
target="_blank"
rel="noopener noreferrer"
className="text-[#FF2D55] hover:underline lg:font-medium"
>
点击加入官方TG群!
点击联系官方TG!
</a>
</p>
) : null}
{info.email ? (
<>
<p>
官方邮箱:{" "}
<a href={`mailto:${info.email}`} className="hover:underline">
{info.email}
</a>
</p>
<p className="text-sm/5">(发送任意邮件,自动回复最新地址)</p>
</>
) : null}
{info.mirrors.length > 0 ? (
<>
<p>
@@ -301,10 +270,8 @@ function saveAddressImage(info: AddressDialogInfo) {
...(info.permanent ? [[{ text: `永久地址: ${info.permanent}` }]] : []),
...(info.latest ? [[{ text: `最新地址: ${info.latest}` }]] : []),
...(info.telegram
? [[{ text: "TG交流群: " }, { text: info.telegram, color: ACCENT }]]
? [[{ text: "官方TG: " }, { text: "@jbd125", color: ACCENT }]]
: []),
...(info.email ? [[{ text: `官方邮箱: ${info.email}` }]] : []),
...(info.email ? [[{ text: "(发送任意邮件,自动回复最新地址)" }]] : []),
...(info.publishPage
? [[{ text: "地址发布页: " }, { text: info.publishPage, color: ACCENT }]]
: []),
@@ -353,7 +320,7 @@ function saveAddressImage(info: AddressDialogInfo) {
ctx.fillStyle = "#FFFFFF";
ctx.font = '500 20px "PingFang SC", "Microsoft YaHei", sans-serif';
ctx.fillText("海角社区 · 最新地址", padding, padding + titleHeight / 2);
ctx.fillText("黄果黑料 · 最新地址", padding, padding + titleHeight / 2);
ctx.font = font;
let y = padding + titleHeight + 18 + lineHeight / 2;
@@ -368,7 +335,7 @@ function saveAddressImage(info: AddressDialogInfo) {
}
const link = document.createElement("a");
link.download = "海角社区地址.png";
link.download = "黄果黑料地址.png";
link.href = canvas.toDataURL("image/png");
link.click();
}
+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" />
@@ -1,223 +0,0 @@
"use client";
import { usePathname } from "next/navigation";
import { useEffect, useRef, type ReactNode } from "react";
import { resolveChannel } from "@/lib/analytics/channel";
import {
externalAd,
inferPage,
initializeTracker,
navigation,
pageClick,
pageView,
setPage,
track,
tracker,
type TrackerBoot,
} from "@/components/analytics/tracker";
const SDK_SRC = "/js/web-sdk-v1.2.0.js?v=1";
function loadScript(src: string): Promise<void> {
return new Promise((resolve) => {
const existing = document.querySelector<HTMLScriptElement>(`script[src="${src}"]`);
if (existing) {
resolve();
return;
}
const script = document.createElement("script");
script.src = src;
script.async = true;
script.onload = () => resolve();
script.onerror = () => resolve();
document.head.append(script);
});
}
function bootThirdParty() {
const google = (process.env.NEXT_PUBLIC_GTAG_ID || "").trim();
const yandexRaw = (process.env.NEXT_PUBLIC_YANDEX_METRIKA_ID || "").trim();
const yandex = yandexRaw ? Number(yandexRaw) : 0;
// layout 已注入 GA4 时勿重复加载
if (
google &&
!document.querySelector(`script[src*="googletagmanager.com/gtag/js?id=${google}"]`)
) {
window.dataLayer ||= [];
window.gtag ||= function gtag(...args: unknown[]) {
window.dataLayer!.push(args);
};
window.gtag("js", new Date());
window.gtag("config", google);
void loadScript(`https://www.googletagmanager.com/gtag/js?id=${google}`);
}
if (yandex) {
window.ym ||= Object.assign(
function ym(...args: unknown[]) {
(window.ym!.a ||= []).push(args);
},
{ a: [] as unknown[][], l: Date.now() },
);
window.ym(yandex, "init", {
ssr: true,
webvisor: true,
clickmap: true,
ecommerce: "dataLayer",
referrer: document.referrer,
url: location.href,
accurateTrackBounce: true,
trackLinks: true,
});
void loadScript(`https://mc.yandex.ru/metrika/tag.js?id=${yandex}`);
}
}
export function TrackerProvider({
boot: explicitBoot,
children,
}: {
boot?: TrackerBoot;
children?: ReactNode;
}) {
const pathname = usePathname();
const readyRef = useRef(false);
const lastPathRef = useRef("");
useEffect(() => {
let disposed = false;
const channel = resolveChannel();
const inferred = inferPage(pathname || location.pathname);
const boot: TrackerBoot = {
appId: explicitBoot?.appId || process.env.NEXT_PUBLIC_TRACKER_APP_ID || "JHA-1046",
encryptedConfig:
explicitBoot?.encryptedConfig ||
process.env.NEXT_PUBLIC_TRACKER_ENCRYPTED_CONFIG ||
"",
appVersion: explicitBoot?.appVersion || "1.0.0",
pageKey: explicitBoot?.pageKey || inferred.key,
pageName: explicitBoot?.pageName || inferred.name,
userType: explicitBoot?.userType || "normal",
uid: explicitBoot?.uid || "",
channel: explicitBoot?.channel || channel,
};
void loadScript(SDK_SRC)
.then(() => initializeTracker(boot))
.then(() => {
if (disposed) return;
readyRef.current = true;
lastPathRef.current = pathname || location.pathname;
pageView();
bootThirdParty();
});
const click = (event: MouseEvent) => {
if (!(event.target instanceof Element)) return;
const target = event.target;
if (
!target.closest(
"[data-ad-close],[data-dialog-ad-close],[data-download-close],[data-login-close]",
)
) {
pageClick(event);
}
const anchor = target.closest<HTMLAnchorElement>(
"a[data-navigation-key],a[data-nav-key]",
);
if (anchor) navigation(anchor);
const ad = target.closest<HTMLElement>('[data-track-ad="external"][data-ad-id]');
if (ad) externalAd(ad, "click");
};
document.addEventListener("click", click, true);
const observer =
typeof IntersectionObserver === "undefined"
? null
: new IntersectionObserver(
(entries) => {
for (const entry of entries) {
if (entry.isIntersecting) {
externalAd(entry.target as HTMLElement, "show");
observer?.unobserve(entry.target);
}
}
},
{ threshold: 0.1 },
);
const observed = new WeakSet<Element>();
const observe = () =>
document
.querySelectorAll('[data-track-ad="external"][data-ad-id]:not([data-ad-clone])')
.forEach((node) => {
if (!observed.has(node)) {
observed.add(node);
if (observer) observer.observe(node);
else externalAd(node as HTMLElement, "show");
}
});
observe();
const mutations = new MutationObserver(observe);
mutations.observe(document.body, { childList: true, subtree: true });
const external = (event: Event) => {
const detail = (event as CustomEvent<{ element: HTMLElement; eventType: string }>).detail;
if (detail?.element) externalAd(detail.element, detail.eventType);
};
const advertising = (event: Event) => {
const detail = (event as CustomEvent<{ element: HTMLElement; eventType: string }>).detail;
const node = detail?.element;
if (!node) return;
void track("advertising", {
event_type: detail.eventType,
advertising_key: node.dataset.advertisingKey || "dialog_ad",
advertising_name: node.dataset.advertisingName || "弹窗广告",
advertising_id: node.dataset.advertisingId || node.dataset.dialogAdId || "",
});
};
document.addEventListener("external-ad:track", external);
document.addEventListener("dialog-ad:track", advertising);
const flush = () => {
void tracker.flush();
};
window.addEventListener("pagehide", flush);
return () => {
disposed = true;
observer?.disconnect();
mutations.disconnect();
document.removeEventListener("click", click, true);
document.removeEventListener("external-ad:track", external);
document.removeEventListener("dialog-ad:track", advertising);
window.removeEventListener("pagehide", flush);
};
// 仅随 boot 关键字段变化重建;pathname 由下方 effect 处理
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
explicitBoot?.appId,
explicitBoot?.encryptedConfig,
explicitBoot?.uid,
explicitBoot?.channel,
explicitBoot?.userType,
]);
useEffect(() => {
if (!readyRef.current) return;
const path = pathname || "";
if (!path || path === lastPathRef.current) return;
lastPathRef.current = path;
const next = inferPage(path);
setPage(next, true);
}, [pathname]);
return children;
}
export function useTracker() {
return tracker;
}
export default TrackerProvider;
@@ -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>
</>
);
}
-36
View File
@@ -1,36 +0,0 @@
import { connection } from "next/server";
import { getHomeBaseCached } from "@/lib/api/home";
import { TrackerProvider } from "./TrackerProvider";
/**
* 服务端拉取 reportSdkConfig,客户端初始化 Web SDK。
* 须放在 <Suspense> 内,并用 connection() 排除在 prerender shell 外。
*/
export async function TrackerHost() {
await connection();
let encryptedConfig =
process.env.NEXT_PUBLIC_TRACKER_ENCRYPTED_CONFIG?.trim() ||
process.env.TRACKER_ENCRYPTED_CONFIG?.trim() ||
"";
try {
const base = await getHomeBaseCached();
// 接口字段在 config.reportSdkConfig
const fromApi = base.config?.reportSdkConfig?.trim();
if (fromApi) encryptedConfig = fromApi;
} catch {
// 接口失败时用环境变量兜底
}
return (
<TrackerProvider
boot={{
appId: process.env.NEXT_PUBLIC_TRACKER_APP_ID || "JHA-1046",
encryptedConfig,
appVersion: "1.0.0",
}}
/>
);
}
-570
View File
@@ -1,570 +0,0 @@
/** 数据上报字段(对齐 Web SDK / jha-1043 tracker) */
export type Fields = Record<string, unknown>;
export interface TrackerBoot {
appId?: string;
encryptedConfig?: unknown;
appVersion?: string;
uid?: string;
channel?: string;
pageKey?: string;
pageName?: string;
userType?: string;
}
interface WebSDK {
init(options: Fields): unknown;
track: Record<string, (payload: Fields) => unknown>;
getCommonFields?(keys: string[]): Promise<Fields>;
flush?(): unknown;
setUid?(uid: string): void;
setChannel?(channel: string): void;
setContext?(fields: Fields): void;
}
declare global {
interface Window {
WebSDK?: WebSDK;
__TRACKER_BOOT__?: TrackerBoot;
__TRACKER__?: typeof tracker;
tracker?: typeof tracker;
__trackerCommonFields?: Record<string, string>;
__CHANNEL_CODE__?: string;
dataLayer?: unknown[];
gtag?: (...args: unknown[]) => void;
ym?: ((...args: unknown[]) => void) & { a?: unknown[][]; l?: number };
}
}
const str = (value: unknown, fallback = "") =>
String(value ?? "").trim() || fallback;
const number = (value: unknown, fallback = 0) =>
Number.isFinite(Number(value)) ? Number(value) : fallback;
const commonKeys = [
"sid",
"device_id",
"device",
"device_fingerprint",
"fp_version",
];
const serverKeys = [
"app_id",
"uid",
"channel",
"sid",
"client_ts",
"device",
"device_id",
"device_brand",
"device_model",
"device_fingerprint",
"fp_version",
"user_agent",
"sdk_version",
"app_version",
];
let activeBoot: TrackerBoot = {};
let finishReady: () => void;
const ready = new Promise<void>((resolve) => {
finishReady = resolve;
});
let initializing = false;
let common: Record<string, string> = Object.fromEntries(
commonKeys.map((key) => [key, ""]),
);
let commonReady: Promise<void> = Promise.resolve();
let page = { key: "internal_other", name: "站内其他页面" };
let userType = "normal";
let drama: Fields | null = null;
const impressions = new Set<string>();
export function normalizeUID(value: unknown): string {
const uid = str(value);
return uid.length >= 4 &&
uid.length <= 32 &&
/^[A-Za-z0-9_]+$/.test(uid) &&
!["u_1001", "stress_user", "u_lab"].includes(uid.toLowerCase())
? uid
: "";
}
export function normalizeChannel(value: unknown): string {
const channel = str(value);
return channel.length <= 50 &&
/^[A-Za-z0-9_.-]+$/.test(channel) &&
!["0", "self", "natural", "official", "channel", "unknown", "-"].includes(
channel.toLowerCase(),
)
? channel
: "organic";
}
/** 按路径推断 page_key / page_name(对齐 jha-1043 tracker_page.go,适配本站路由) */
export function inferPage(path: string) {
const raw = (path || "/").split("?")[0] || "/";
const p = raw.length > 1 && raw.endsWith("/") ? raw.slice(0, -1) : raw;
if (p === "/" || p === "") return { key: "home", name: "首页" };
// 短剧:/short-drama/{sort} 列表;/short-drama/{slug} 详情;/short-drama/{slug}/{ep} 播放
if (/^\/short-drama(?:\/|$)/.test(p)) {
const parts = p.split("/").filter(Boolean); // short-drama, ...
if (parts.length >= 3 && /^\d+$/.test(parts[2] || "")) {
return { key: "play", name: "短剧播放页" };
}
// 排序段(hot/latest 及旧中文别名)视为列表,其余视为详情
const sortKeys = new Set(["hot", "latest", "热度优先", "最近更新"]);
if (parts.length === 2 && sortKeys.has(decodeURIComponent(parts[1] || ""))) {
return { key: "list", name: "短剧列表" };
}
if (parts.length === 1) return { key: "list", name: "短剧列表" };
return { key: "detail", name: "短剧详情" };
}
// 视频:列表 / 播放
if (/^\/video(?:\/|$)/.test(p)) {
const parts = p.split("/").filter(Boolean);
const sortKeys = new Set(["hot", "latest", "热度优先", "最近更新"]);
if (parts.length === 2 && sortKeys.has(decodeURIComponent(parts[1] || ""))) {
return { key: "list", name: "视频列表" };
}
if (parts.length === 1) return { key: "list", name: "视频列表" };
return { key: "play", name: "视频播放页" };
}
const rules: Array<[RegExp, string, string]> = [
[/^\/ranking(?:\/|$)/, "rank", "排行榜"],
[/^\/topic(?:\/|$)/, "topic", "专题详情"],
[/^\/more(?:\/|$)/, "topic", "专题详情"],
[/^\/tag(?:\/|$)/, "tag_list", "标签详情"],
[/^\/search(?:\/|$)/, "search", "搜索结果页"],
[/^\/history(?:\/|$)/, "history", "观看历史"],
[/^\/favorites(?:\/|$)/, "collect", "我的收藏"],
[/^\/likes(?:\/|$)/, "likes", "我的点赞"],
[/^\/profile(?:\/|$)/, "user_center", "个人中心"],
[/^\/settings\/profile(?:\/|$)/, "edit_profile", "编辑资料"],
[/^\/settings(?:\/|$)/, "setting", "设置"],
[/^\/way-home(?:\/|$)/, "home_road", "回家的路"],
[/^\/welfare(?:\/|$)/, "application", "应用推荐"],
[/^\/nav(?:\/|$)/, "nav", "官方导航"],
[/^\/about(?:\/|$)/, "about_us", "关于我们"],
[/^\/terms(?:\/|$)/, "user_agreement", "用户协议"],
[/^\/privacy(?:\/|$)/, "privacy_policy", "隐私政策"],
[/^\/help(?:\/|$)/, "help_center", "帮助中心"],
[/^\/feedback(?:\/|$)/, "feedback", "问题反馈"],
[/^\/richtext(?:\/|$)/, "rich_text", "富文本页"],
[/^\/collection(?:\/|$)/, "collect", "合集"],
];
const hit = rules.find(([re]) => re.test(p));
return hit
? { key: hit[1], name: hit[2] }
: { key: "internal_other", name: "站内其他页面" };
}
/** SPA 路由切换时更新当前页并上报 page_view */
export function setPage(next: { key: string; name: string }, reportView = true) {
page = { key: str(next.key, page.key), name: str(next.name, page.name) };
if (reportView) pageView();
}
export function initializeTracker(boot: TrackerBoot): Promise<void> {
const inferred = inferPage(location.pathname);
page = {
key: str(boot.pageKey, inferred.key),
name: str(boot.pageName, inferred.name),
};
userType = boot.userType === "vip" ? "vip" : "normal";
activeBoot = boot;
window.__TRACKER_BOOT__ = boot;
window.__TRACKER__ = tracker;
window.tracker = tracker;
if (!initializing) {
initializing = true;
const resolve = () => finishReady();
let attempts = 0;
const timer = setInterval(() => {
if (!window.WebSDK?.track && ++attempts < 100) return;
clearInterval(timer);
if (!window.WebSDK) {
resolve();
return;
}
Promise.resolve()
.then(() =>
window.WebSDK?.init({
appId: str(boot.appId),
uid: normalizeUID(boot.uid),
channel: normalizeChannel(boot.channel || window.__CHANNEL_CODE__),
encryptedConfig: str(boot.encryptedConfig),
appVersion: str(boot.appVersion, "1.0.0"),
disableAutoEvents: ["app_page_view", "page_click"],
}),
)
.catch(() => undefined)
.then(() => {
// Core events need only SDK initialization; device fingerprint loading must not stall them.
commonReady = (async () => {
try {
const fields = await window.WebSDK?.getCommonFields?.(
commonKeys.slice(),
);
common = Object.fromEntries(
commonKeys.map((key) => [key, str(fields?.[key])]),
);
} catch {
/* Empty common fields preserve the original degraded SDK contract. */
}
window.__trackerCommonFields = common;
window.dispatchEvent(
new CustomEvent("tracker:common-fields", { detail: common }),
);
})();
window.dispatchEvent(
new CustomEvent("tracker:ready", { detail: page }),
);
resolve();
});
}, 50);
}
return ready;
}
export async function track(method: string, payload: Fields): Promise<unknown> {
await ready;
try {
return await window.WebSDK?.track[method]?.(payload);
} catch {
return { sent: false, ok: false, reason: "exception" };
}
}
export function pageView(extra: Fields = {}) {
let referrer = { key: "direct", name: "直接访问" };
try {
const saved = sessionStorage.getItem("__tracker_last_page");
if (saved) referrer = JSON.parse(saved);
else if (document.referrer) {
const url = new URL(document.referrer);
referrer =
url.host === location.host
? inferPage(url.pathname)
: { key: "external", name: url.host };
}
} catch {
/* Storage is optional. */
}
const navigation = performance.getEntriesByType("navigation")[0] as
| PerformanceNavigationTiming
| undefined;
void track("appPageView", {
user_type: userType,
page_key: page.key,
page_name: page.name,
referrer_page_key: referrer.key,
referrer_page_name: referrer.name,
current_page_key: page.key,
current_page_name: page.name,
page_load_time: Math.max(
0,
Math.round(
navigation?.loadEventEnd ||
navigation?.domContentLoadedEventEnd ||
performance.now(),
),
),
recommend_trace_id: "",
...extra,
});
try {
sessionStorage.setItem("__tracker_last_page", JSON.stringify(page));
} catch {
/* Storage is optional. */
}
}
export function navigation(anchor: HTMLAnchorElement) {
const href = anchor.getAttribute("href");
if (!href || /^(#|javascript:)/i.test(href)) return;
let key = str(anchor.dataset.navigationKey || anchor.dataset.navKey);
if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(key)) {
const url = new URL(href, location.href);
const target = inferPage(url.pathname);
key =
url.origin !== location.origin
? "nav_external"
: target.key !== "internal_other"
? "nav_" + target.key
: "nav_" +
(url.pathname.split("/").filter(Boolean)[0] || "home")
.replace(/[^a-z0-9]+/gi, "_")
.slice(0, 48);
}
void track("navigation", {
navigation_key: key.toLowerCase(),
navigation_name: str(
anchor.dataset.navigationName || anchor.dataset.navName,
anchor.getAttribute("aria-label") ||
anchor.textContent?.replace(/\s+/g, " ") ||
key,
).slice(0, 255),
});
}
export function pageClick(event: MouseEvent) {
void track("pageClick", {
page_key: page.key,
page_name: page.name,
click_page_x: Math.trunc(event.clientX),
click_page_y: Math.trunc(event.clientY),
click_x_percent: innerWidth
? Math.round(
Math.max(0, Math.min(100, (event.clientX / innerWidth) * 100)),
)
: 0,
click_y_percent: innerHeight
? Math.round(
Math.max(0, Math.min(100, (event.clientY / innerHeight) * 100)),
)
: 0,
screen_width: screen.width,
screen_height: screen.height,
recommend_trace_id: "",
});
}
export function externalAd(node: HTMLElement, type: string) {
if (!["show", "click"].includes(type) || !node.dataset.adId) return;
const slots = Array.from(
document.querySelectorAll(
'[data-track-ad="external"][data-ad-id]:not([data-ad-clone])',
),
);
const slot = node.hasAttribute("data-ad-clone")
? slots.find(
(slot) => slot.getAttribute("data-ad-id") === node.dataset.adId,
)
: node;
const position = Math.max(1, slots.indexOf(slot as Element) + 1);
const interstitial = node.dataset.adType === "interstitial";
const payload = {
page_key: page.key,
page_name: page.name,
ad_slot_key: str(
node.dataset.adSlotKey,
`${page.key}_${interstitial ? "popup" : "content_banner"}_${position}`,
),
ad_slot_name: str(
node.dataset.adSlotName,
page.name + (interstitial ? "弹窗广告位" : `内容横幅第${position}位`),
),
ad_id: node.dataset.adId,
creative_id: str(node.dataset.creativeId),
ad_type: str(node.dataset.adType, "banner"),
};
const key = payload.ad_slot_key + "|" + payload.ad_id;
if (!impressions.has(key)) {
impressions.add(key);
void track("adImpression", payload);
}
if (type === "click" && node.dataset.adClickable === "1")
void track("adClick", payload);
}
export function setDramaContext(value: Fields | null) {
drama = value;
}
const behaviorNames: Record<string, string> = {
ep_view: "展示",
ep_play: "播放",
ep_pause: "暂停",
ep_forward: "快进",
ep_rewind: "快退",
ep_complete: "播放完成",
ep_share: "分享",
ep_fail: "播放失败",
};
const videoBehaviorNames: Record<string, string> = {
video_view: "展示",
video_play: "播放",
video_pause: "暂停",
video_forward: "快进",
video_rewind: "快退",
video_complete: "播放完成",
video_fail: "播放失败",
};
let videoCtx: Fields | null = null;
export function setVideoContext(value: Fields | null) {
videoCtx = value;
}
export function videoEvent(
behavior: string,
media?: HTMLVideoElement | null,
options: { played?: number; forceProgress?: number } = {},
) {
if (!videoCtx) return Promise.resolve();
const duration =
media && Number.isFinite(media.duration)
? Math.round(media.duration)
: number(videoCtx.video_duration);
const current = Math.round(media?.currentTime || 0);
return track("videoEvent", {
...videoCtx,
media_id: str(videoCtx.media_id, str(videoCtx.video_id)),
video_duration: Math.max(0, duration),
play_duration: Math.max(0, Math.round(options.played || 0)),
play_progress:
options.forceProgress ??
(behavior === "video_complete"
? 100
: duration > 0
? Math.round(Math.min(100, (current / duration) * 100))
: 0),
play_speed: Math.max(1, Math.round((media?.playbackRate || 1) * 100)),
video_behavior_key: behavior,
video_behavior_name: videoBehaviorNames[behavior] || behavior,
});
}
export function dramaEvent(
behavior: string,
video?: HTMLVideoElement | null,
options: { played?: number; forceProgress?: number } = {},
) {
if (!drama) return Promise.resolve();
const duration =
video && Number.isFinite(video.duration)
? Math.round(video.duration)
: number(drama.drama_duration);
const current = Math.round(video?.currentTime || 0);
return track("dramaEvent", {
...drama,
drama_duration: Math.max(0, duration),
play_duration: Math.max(0, Math.round(options.played || 0)),
play_progress:
options.forceProgress ??
(behavior === "ep_complete"
? 100
: duration > 0
? Math.round(Math.min(100, (current / duration) * 100))
: 0),
play_speed: Math.max(1, Math.round((video?.playbackRate || 1) * 100)),
play_behavior_key: behavior,
play_behavior_name: behaviorNames[behavior] || behavior,
});
}
export function dramaStatusChange(
episode: number,
videoID: string | number,
override?: string,
) {
if (!drama) return Promise.resolve();
const previous = number(drama.episode, 1);
const behavior =
override ||
(episode === previous + 1
? "ep_next"
: episode === previous - 1
? "ep_previous"
: "ep_switch");
if (!override && episode === previous && str(videoID) === str(drama.video_id))
return Promise.resolve();
const names: Record<string, string> = {
ep_auto_play: "自动播放",
ep_previous: "上一集",
ep_next: "下一集",
ep_switch: "切换剧集",
ep_unlock: "解锁",
};
return track("dramaStatusChange", {
media_id: drama.media_id,
drama_id: drama.drama_id,
drama_title: drama.drama_title,
episode: Math.max(1, episode),
video_id: str(videoID, str(drama.video_id)),
pre_episode: previous,
drama_behavior_key: behavior,
drama_behavior_name: names[behavior] || behavior,
});
}
/** Full per-request SDK snapshot for server-side drama events; header compatibility remains five fields. */
export async function serverContext(keys = serverKeys): Promise<Fields> {
await ready;
let fields: Fields = {};
try {
fields = (await window.WebSDK?.getCommonFields?.(serverKeys.slice())) || {};
} catch {
/* Cached device identifiers remain usable. */
}
const defaults: Fields = {
...common,
app_id: str(activeBoot.appId),
uid: normalizeUID(activeBoot.uid),
channel: normalizeChannel(activeBoot.channel || window.__CHANNEL_CODE__),
client_ts: Math.floor(Date.now() / 1000),
device_brand: "",
device_model: "",
user_agent: navigator.userAgent,
sdk_version: "1.2.0",
app_version: str(activeBoot.appVersion, "1.0.0"),
};
return Object.fromEntries(
keys.map((key) => [
key,
key === "client_ts"
? Math.floor(number(fields[key], number(defaults[key])))
: str(fields[key] ?? defaults[key]),
]),
);
}
export const tracker = {
init: initializeTracker,
pageView,
setPage,
inferPage,
dramaEvent,
dramaStatusChange,
dramaUnlock: () =>
dramaStatusChange(
number(drama?.episode, 1),
str(drama?.video_id),
"ep_unlock",
),
setDramaContext,
videoEvent,
setVideoContext,
getVideoContext: () => (videoCtx ? { ...videoCtx } : null),
externalAd,
advertising: (payload: Fields) => track("advertising", payload),
keywordSearch: (payload: Fields) => track("keywordSearch", payload),
keywordClick: (payload: Fields) => track("keywordClick", payload),
getDramaContext: () => ({ ...drama }),
getCommonFieldsSync: () => common,
getCommonFields: serverContext,
serverContext,
getCommonField: async (key: string) => {
await ready;
await commonReady;
return common[key] || "";
},
encodeSDKCommonHeader: (fields = common) =>
btoa(
unescape(
encodeURIComponent(
JSON.stringify(
Object.fromEntries(
commonKeys.map((key) => [key, str(fields[key])]),
),
),
),
),
),
getSDKCommonHeader: async () => {
await ready;
await commonReady;
return tracker.encodeSDKCommonHeader();
},
flush: async () => {
try {
await window.WebSDK?.flush?.();
} catch {
/* Analytics must never interrupt playback. */
}
},
setUid: (uid: unknown) => {
activeBoot.uid = normalizeUID(uid);
window.WebSDK?.setUid?.(activeBoot.uid);
},
setChannel: (channel: unknown) => {
activeBoot.channel = normalizeChannel(channel);
window.WebSDK?.setChannel?.(activeBoot.channel);
},
setContext: (context: Fields) => window.WebSDK?.setContext?.(context),
};
@@ -1,168 +0,0 @@
"use client";
import { useEffect, useRef } from "react";
import {
dramaEvent,
setDramaContext,
setVideoContext,
tracker,
videoEvent,
type Fields,
} from "@/components/analytics/tracker";
export function useDramaContext(context: Fields | null) {
const viewed = useRef("");
useEffect(() => {
setDramaContext(context);
const key = context ? `${String(context.drama_id)}:${String(context.video_id)}` : "";
if (context && viewed.current !== key) {
viewed.current = key;
void dramaEvent("ep_view");
}
return () => setDramaContext(null);
}, [context]);
}
export function useVideoContext(context: Fields | null) {
const viewed = useRef("");
useEffect(() => {
setVideoContext(context);
const key = context ? String(context.video_id) : "";
if (context && viewed.current !== key) {
viewed.current = key;
void videoEvent("video_view");
}
return () => setVideoContext(null);
}, [context]);
}
const reporters = new WeakMap<HTMLVideoElement, (behavior: string) => void>();
export function reportPlaybackAction(behavior: string, video?: HTMLVideoElement | null) {
const report = video && reporters.get(video);
if (report) report(behavior);
else void dramaEvent(behavior, video);
}
/** 墙钟播放时长(排除缓冲/seek),对齐原 SDK */
export function bindPlaybackAnalytics(
video: HTMLVideoElement,
enabled: boolean,
kind: "drama" | "video" = "drama",
): () => void {
if (!enabled) return () => undefined;
let started = 0;
let elapsed = 0;
let position = 0;
let seekFrom: number | null = null;
const settle = () => {
if (started) elapsed += Math.max(0, Date.now() - started);
started = 0;
};
const begin = () => {
if (!started) started = Date.now();
};
const mapBehavior = (behavior: string) => {
if (kind === "drama") return behavior;
const map: Record<string, string> = {
ep_play: "video_play",
ep_pause: "video_pause",
ep_forward: "video_forward",
ep_rewind: "video_rewind",
ep_complete: "video_complete",
ep_fail: "video_fail",
};
return map[behavior] || behavior;
};
const emit = (behavior: string, keep = false, forceProgress?: number) => {
const played = (elapsed + (started ? Math.max(0, Date.now() - started) : 0)) / 1000;
const key = mapBehavior(behavior);
if (kind === "video") void videoEvent(key, video, { played, forceProgress });
else void dramaEvent(key, video, { played, forceProgress });
if (!keep) {
elapsed = 0;
if (started) started = Date.now();
}
};
reporters.set(video, emit);
const events: Record<string, () => void> = {
play: () => emit("ep_play"),
playing: begin,
waiting: settle,
pause: () => {
const pending = started || elapsed > 0;
settle();
if (!video.ended && !video.seeking && pending) emit("ep_pause");
},
timeupdate: () => {
if (!video.seeking) position = video.currentTime;
},
seeking: () => {
if (seekFrom == null) {
settle();
seekFrom = position;
}
},
seeked: () => {
if (seekFrom == null) return;
const from = seekFrom;
seekFrom = null;
position = video.currentTime;
if (Math.abs(position - from) >= 0.5) emit(position > from ? "ep_forward" : "ep_rewind");
if (!video.paused && !video.ended) begin();
},
ended: () => {
settle();
emit("ep_complete", true);
emit("ep_play", false, 100);
},
error: () => {
settle();
emit("ep_fail");
},
};
Object.entries(events).forEach(([name, handler]) => video.addEventListener(name, handler));
const report = () => {
if (elapsed + (started ? Date.now() - started : 0) >= 500) {
settle();
emit("ep_play");
void tracker.flush();
setTimeout(() => void tracker.flush(), 50);
setTimeout(() => void tracker.flush(), 200);
}
};
const visibility = () => {
if (document.visibilityState === "hidden") report();
if (!video.paused && !video.ended) begin();
};
document.addEventListener("visibilitychange", visibility);
window.addEventListener("pagehide", report);
window.addEventListener("beforeunload", report);
return () => {
reporters.delete(video);
const pending = started || elapsed;
settle();
if (pending && !video.ended) emit("ep_pause");
Object.entries(events).forEach(([name, handler]) => video.removeEventListener(name, handler));
document.removeEventListener("visibilitychange", visibility);
window.removeEventListener("pagehide", report);
window.removeEventListener("beforeunload", report);
};
}
/** 从 xgplayer 实例拿到内部 video 并绑定埋点 */
export function bindPlayerAnalytics(
player: { media?: HTMLVideoElement | null; video?: HTMLVideoElement | null } | null | undefined,
kind: "drama" | "video" = "drama",
): () => void {
const video = player?.media || player?.video || null;
if (!video) return () => undefined;
return bindPlaybackAnalytics(video, true, kind);
}
@@ -3,7 +3,6 @@
import { useEffect, useState } from "react";
import { ensureGuestSession } from "@/lib/auth/session";
import { tracker } from "@/lib/tracker";
/**
* 仅在挂载后异步拉游客会话,不参与 SSR / 首屏阻塞。
@@ -19,8 +18,6 @@ export function GuestAuthBootstrap() {
void ensureGuestSession()
.then((user) => {
if (cancelled || !user) return;
// 埋点 uid:SDK 要求非空时长度 ≥ 4
tracker.setUid(String(user.userId || ""));
if (process.env.NODE_ENV === "development") {
console.info("[guest-auth]", {
userId: user.userId,
+5 -5
View File
@@ -3,7 +3,8 @@
import Link from "next/link";
import { useCallback, useEffect, useId, useState, useSyncExternalStore, type FormEvent, type ReactNode } from "react";
import { useMockUser } from "@/components/profile/use-mock-user";
import { lockBodyScroll } from "@/lib/browser/scroll-lock";
import { useMockUser } from "@/components/auth/use-mock-user";
import {
ACCOUNT_RULE_HINT,
CREDENTIAL_MAX_LEN,
@@ -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]);
@@ -156,7 +156,7 @@ export function LoginDialogHost() {
onSubmit={submit}
className="flex w-[311px] flex-col items-center gap-4 rounded-3xl bg-[#0E0C17] px-[18px] py-6 lg:w-[456px] lg:gap-3.5 lg:bg-[#0A0915]/90 lg:px-8 lg:py-7 lg:shadow-[0_20px_50px_rgba(0,0,0,0.35)] lg:outline lg:outline-1 lg:-outline-offset-1 lg:outline-white/13"
>
<img src="/logo.svg" alt="海角社区" className="h-[33px] w-auto lg:h-12" />
<img src="/logo.svg" alt="黄果黑料" className="h-[33px] w-auto lg:h-12" />
{isLogin ? (
<div className="flex gap-4 self-stretch lg:hidden" role="tablist">
@@ -1,212 +0,0 @@
"use client";
import { useRouter } from "next/navigation";
import { useRef, useState } from "react";
import { EmptyState } from "@/components/common/empty-state";
import { Pagination } from "@/components/common/pagination";
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
import type { ShortDramaItem } from "@/components/short-drama/data";
import { H5ShortDramaCard, ShortDramaCard } from "@/components/short-drama/short-drama-card";
import { H5VideoCard, VideoCard } from "@/components/video/video-card";
type CollectionPageProps<T extends string, S extends string> = {
title: string;
subtitle: string;
breadcrumb: string;
types: readonly T[];
mobileTypes?: readonly T[];
scopes: readonly S[];
defaultScope: S;
totalPages: number;
getItems: (type: T, scope: S, page: number) => ShortDramaItem[];
clearable?: boolean;
showMobileScopes?: boolean;
showPcScopes?: boolean;
showVideoScopes?: boolean;
showMobileEpisodes?: boolean;
emptyText: string;
};
type FilterPillsProps<T extends string> = {
options: readonly T[];
value: T;
onChange: (value: T) => void;
className?: string;
itemClassName: string;
};
function FilterPills<T extends string>({ options, value, onChange, className = "", itemClassName }: FilterPillsProps<T>) {
return (
<div className={`items-center ${className}`}>
{options.map((option) => (
<button
key={option}
type="button"
aria-pressed={option === value}
onClick={() => onChange(option)}
className={`cursor-pointer flex items-center justify-center rounded-2xl transition-colors ${itemClassName} ${
option === value ? "bg-[#F12B9E] text-white" : "bg-[#242138] text-[#B4AFC4] hover:text-white"
}`}
>
{option}
</button>
))}
</div>
);
}
export function CollectionPage<T extends string, S extends string>({
title,
subtitle,
breadcrumb,
types,
mobileTypes = types,
scopes,
defaultScope,
totalPages,
getItems,
clearable = false,
showMobileScopes = true,
showPcScopes = true,
showVideoScopes = true,
showMobileEpisodes = true,
emptyText,
}: CollectionPageProps<T, S>) {
const router = useRouter();
const [type, setType] = useState<T>(types[0]);
const [scope, setScope] = useState<S>(defaultScope);
const [page, setPage] = useState(1);
const [cleared, setCleared] = useState(false);
const topRef = useRef<HTMLDivElement>(null);
const items = cleared ? [] : getItems(type, scope, page);
const isVideo = type === "视频";
const PcCard = isVideo ? VideoCard : ShortDramaCard;
const MobileCard = isVideo ? H5VideoCard : H5ShortDramaCard;
const changeType = (next: T) => {
setType(next);
setPage(1);
};
const changeScope = (next: S) => {
setScope(next);
setPage(1);
};
const changePage = (next: number) => {
setPage(next);
topRef.current?.scrollIntoView({ behavior: "smooth" });
};
const goBack = () => {
if (window.history.length > 1) router.back();
else router.push("/profile");
};
return (
<main data-component="collection-page" className="flex-1 bg-[#07060D] lg:bg-[#070611]">
<div className="relative flex h-12 items-center justify-center px-4 lg:hidden">
<button type="button" aria-label="返回" onClick={goBack} className="cursor-pointer absolute left-4 size-6">
<svg viewBox="0 0 24 24" className="size-full" aria-hidden="true">
<path d="M15 5l-7 7 7 7" fill="none" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</button>
<h1 className="text-base leading-[22px] font-bold text-white">{title}</h1>
{clearable ? (
<button
type="button"
onClick={() => setCleared(true)}
disabled={cleared}
className="cursor-pointer absolute right-4 text-xs leading-[18px] font-bold text-[#F12B9E] disabled:opacity-40"
>
清空
</button>
) : null}
</div>
<div
ref={topRef}
data-pc-scale
className="mx-auto flex w-full scroll-mt-24 flex-col gap-3 px-4 py-3 lg:w-[1700px] lg:gap-5 lg:px-0 lg:py-[30px] lg:[zoom:var(--page-scale,1)]"
>
<SeoBreadcrumb
items={[
{ name: "首页", href: "/" },
{ name: "个人中心", href: "/profile" },
{ name: breadcrumb },
]}
/>
<div className="hidden items-center lg:flex">
<div className="flex flex-1 flex-col gap-px">
<h2 className="text-[30px] leading-9 font-semibold text-white">{title}</h2>
<p className="text-sm leading-5 text-[#9790A6]">{subtitle}</p>
</div>
{clearable ? (
<button
type="button"
onClick={() => setCleared(true)}
disabled={cleared}
className="cursor-pointer h-9 w-24 rounded-[18px] bg-white/6 text-xs leading-[18px] font-semibold text-[#B5AEC1] transition-colors hover:text-white disabled:opacity-40"
>
清空记录
</button>
) : null}
</div>
<div className="flex flex-col gap-3 lg:gap-2.5">
<FilterPills
options={mobileTypes}
value={type}
onChange={changeType}
className="flex gap-3 lg:hidden"
itemClassName="h-8 px-4 text-sm leading-5"
/>
<FilterPills
options={types}
value={type}
onChange={changeType}
className="hidden gap-[9px] lg:flex"
itemClassName="h-8 w-[88px] px-4 text-xs leading-[18px]"
/>
{isVideo && !showVideoScopes ? null : (
<FilterPills
options={scopes}
value={scope}
onChange={changeScope}
className={`flex gap-2 lg:gap-[9px] ${showMobileScopes ? "" : "max-lg:hidden"} ${showPcScopes ? "" : "lg:hidden"}`}
itemClassName="h-6 px-3 text-xs leading-[18px] lg:h-8 lg:px-4"
/>
)}
</div>
{items.length === 0 ? (
<EmptyState
title={emptyText}
description="去首页发现更多好剧吧"
onReload={null}
className="rounded-2xl px-4 py-12 lg:rounded-3xl lg:py-24"
/>
) : (
<>
<div
className={`hidden justify-between gap-x-5 gap-y-6 lg:grid ${
isVideo ? "grid-cols-[repeat(auto-fill,324px)]" : "grid-cols-[repeat(auto-fill,266px)]"
}`}
>
{items.map((item) => (
<PcCard key={item.id} item={item} />
))}
</div>
<div className="grid grid-cols-2 gap-x-[7px] gap-y-3 lg:hidden">
{items.map((item) => (
<MobileCard key={item.id} item={item} showEpisodes={showMobileEpisodes} />
))}
</div>
<Pagination page={page} total={totalPages} onChange={changePage} showJump={false} />
</>
)}
</div>
</main>
);
}
+15 -4
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>
{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} />;
}
+7 -14
View File
@@ -1,8 +1,9 @@
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 { adHref, adTrackProps, pickBannerAds } from "./pick";
import { adHref, pickBannerAds } from "./pick";
type AdBannersProps = {
variant?: "pc" | "h5";
@@ -11,7 +12,7 @@ type AdBannersProps = {
className?: string;
};
/** 公共 Banner 广告:对接 advitise.detailbannerList;无数据不渲染 */
/** 公共 Banner 广告:对接 advitise.detailbannerList(后台位置 3「详情横幅」,素材 720×150);无数据不渲染 */
export function AdBanners({
variant = "pc",
items,
@@ -38,12 +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"
{...adTrackProps(ad, {
slotKey: `content_banner_${index + 1}`,
slotName: `内容横幅第${index + 1}位`,
adType: "banner",
})}
{...adClickData(ad)}
className="block aspect-[720/150] overflow-hidden rounded-xl"
>
<DecryptedImage
src={ad.images || null}
@@ -73,12 +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"
{...adTrackProps(ad, {
slotKey: `content_banner_${index + 1}`,
slotName: `内容横幅第${index + 1}位`,
adType: "banner",
})}
{...adClickData(ad)}
className="block aspect-[720/150] overflow-hidden rounded-xl"
>
<DecryptedImage
src={ad.images || null}
-75
View File
@@ -1,75 +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, adTrackProps, 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}
{...adTrackProps(ad, {
slotKey: `icon_grid_${index + 1}`,
slotName: `九宫格第${index + 1}位`,
adType: "icon",
})}
>
<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 -33
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;
@@ -36,21 +30,3 @@ export function adHref(link?: string, fallback = "#download") {
export function adContentKey(list: AdvertiseInfo[]) {
return list.map((item) => item.id || item.title || item.images || "").join("|") || "mock";
}
/** 外链广告埋点属性(对齐 hkdj / jha-1043 data-track-ad) */
export function adTrackProps(
ad: AdvertiseInfo,
options?: { slotKey?: string; slotName?: string; adType?: string },
) {
const adId = String(ad.advertiseCode || ad.id || "").trim();
if (!adId) return {};
return {
"data-track-ad": "external" as const,
"data-ad-id": adId,
"data-ad-clickable": "1",
"data-ad-type": options?.adType || "banner",
"data-ad-slot-key": options?.slotKey || ad.advertiseLocationCode || undefined,
"data-ad-slot-name": options?.slotName || ad.advertiseLocationName || ad.title || undefined,
"data-creative-id": String(ad.id || ""),
};
}
+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,284 +0,0 @@
"use client";
import { useState, type FormEvent } from "react";
import { DecryptedImage } from "@/components/common/decrypted-image";
import { useMockUser } from "@/components/profile/use-mock-user";
import type { CommentInfo } from "@/lib/api/types";
import { COMMENT_MAX_LENGTH, COMMENT_SELF_NAME, COMMENT_SORTS, formatCommentTime, type CommentTarget } from "./data";
import { CommentReplyPreview } from "./comment-reply-preview";
import { HeartIcon } from "./heart-icon";
import { InlineReplyBox } from "./inline-reply-box";
import { useComments } from "./use-comments";
const fallbackAvatar = "/images/default_avatar.svg";
const panelStyles = {
detail: {
section: "rounded-2xl bg-[rgba(24,23,46,0.88)] outline-[#383657]",
item: "py-4",
more: "mt-4 h-[43px] rounded-[7px]",
},
play: {
section: "rounded-xl bg-[rgba(19,15,22,0.91)] outline-[rgba(199,145,89,0.7)]",
item: "py-3",
more: "mt-3 h-8 rounded-lg",
},
};
type ReplyTarget = {
id: number;
userName: string;
};
function CommentComposer({
onSubmit,
posting,
error,
}: {
onSubmit: (content: string) => Promise<boolean>;
posting: boolean;
error: string | null;
}) {
const { user } = useMockUser();
const avatar = user?.avatar || fallbackAvatar;
const displayName = user?.name || COMMENT_SELF_NAME;
const [text, setText] = useState("");
const submit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
const content = text.trim();
if (!content || posting) return;
const ok = await onSubmit(content);
if (ok) setText("");
};
return (
<div className="mt-2 flex flex-col gap-2">
<form onSubmit={submit} className="flex h-[76px] items-center gap-4 rounded-[10px] bg-[#211F38] px-4 py-3">
<DecryptedImage
src={avatar}
fallback={fallbackAvatar}
alt=""
className="size-9 shrink-0 rounded-full object-cover"
/>
<label className="flex h-[52px] min-w-0 flex-1 items-center gap-3 rounded-lg bg-[#110F1F] px-3 py-2.5 outline outline-1 -outline-offset-1 outline-[#383657] focus-within:outline-[#F12B9E]">
<input
value={text}
maxLength={COMMENT_MAX_LENGTH}
disabled={posting}
onChange={(event) => setText(event.target.value)}
placeholder="说说你对这部剧的看法…"
aria-label="评论内容"
className="min-w-0 flex-1 bg-transparent text-xs leading-[18px] text-white outline-none placeholder:text-[#948CA8] disabled:opacity-60"
/>
<span className="flex shrink-0 gap-2 text-xs leading-[18px]">
<span className="text-[#F12B9E]">已登录</span>
<span className="text-[#948CA8]">{displayName}</span>
<span className="text-[#736E87]">
{text.length} / {COMMENT_MAX_LENGTH}
</span>
</span>
</label>
<button
type="submit"
disabled={!text.trim() || posting}
className="cursor-pointer h-[52px] w-[120px] shrink-0 rounded-[10px] bg-[#F12B9E] text-xs leading-[18px] font-semibold text-white transition-colors enabled:hover:bg-[#F23DA8] disabled:opacity-60"
>
{posting ? "发布中…" : "发表评论"}
</button>
</form>
{error && !posting ? <p className="text-xs leading-[18px] text-[#FF8FA8]">{error}</p> : null}
</div>
);
}
/** PC 评论面板(详情 / 播放页)— GET /api/app/comment/list */
export function CommentPanel({
variant = "detail",
target,
}: {
variant?: keyof typeof panelStyles;
target: CommentTarget | null;
}) {
const {
sort,
setSort,
comments,
total,
hasMore,
loading,
loadingMore,
error,
loadMore,
toggleLike,
post,
posting,
postError,
reload,
} = useComments({ target });
const styles = panelStyles[variant];
const [replyTo, setReplyTo] = useState<ReplyTarget | null>(null);
const [expandedIds, setExpandedIds] = useState<Set<number>>(() => new Set());
const startReply = (comment: CommentInfo) => {
const id = Number(comment.id);
if (!Number.isInteger(id) || id < 1) return;
setReplyTo({ id, userName: (comment.userName || "").trim() || "用户" });
};
const toggleExpanded = (commentId: number) => {
setExpandedIds((current) => {
const next = new Set(current);
if (next.has(commentId)) next.delete(commentId);
else next.add(commentId);
return next;
});
};
const submitRoot = async (content: string) => post(content);
const submitReply = async (content: string) => {
if (!replyTo) return false;
const ok = await post(content, { parentsId: replyTo.id });
if (ok) setReplyTo(null);
return ok;
};
return (
<section
data-component="comment-panel"
className={`flex w-[1196px] shrink-0 flex-col p-6 outline outline-1 -outline-offset-1 ${styles.section}`}
>
<div className="flex h-10 items-center justify-between">
<h2 className="text-[22px] leading-[30px] text-white">评论 ({total})</h2>
<div className="flex h-8 items-center gap-3 rounded-[7px] bg-[#110F1F] px-2 text-xs leading-[18px]">
{COMMENT_SORTS.map((item) => (
<button
key={item}
type="button"
aria-pressed={sort === item}
onClick={() => setSort(item)}
className={`cursor-pointer ${sort === item ? "text-white" : "text-[#948CA8] hover:text-white"}`}
>
{item}
</button>
))}
</div>
</div>
<CommentComposer
onSubmit={submitRoot}
posting={posting && !replyTo}
error={!replyTo ? postError : null}
/>
{loading ? (
<p className="py-8 text-center text-sm text-[#948CA8]">评论加载中…</p>
) : error ? (
<div className="flex flex-col items-center gap-3 py-8">
<p className="text-sm text-[#948CA8]">{error}</p>
<button
type="button"
onClick={reload}
className="cursor-pointer rounded-lg bg-[#211F38] px-4 py-2 text-xs text-white hover:opacity-90"
>
重试
</button>
</div>
) : comments.length === 0 ? (
<p className="py-8 text-center text-sm text-[#948CA8]">暂无评论</p>
) : (
<ul>
{comments.map((comment) => {
const liked = Boolean(comment.isLike);
const commentId = Number(comment.id) || 0;
const expanded = expandedIds.has(commentId);
const replies = comment.subComment ?? [];
const isReplying = replyTo?.id === commentId;
return (
<li key={comment.id} className={`flex gap-4 border-b border-[#2E2B47] ${styles.item}`}>
<DecryptedImage
src={comment.avatar}
fallback="/images/default_avatar.svg"
alt=""
className="size-12 shrink-0 rounded-full object-cover"
/>
<div className="flex min-w-0 flex-1 flex-col gap-1.5">
<p className="text-sm leading-[21px] text-[#948CA8]">{comment.userName}</p>
<p className="text-base leading-6 text-white">{comment.text}</p>
<div className="flex items-center gap-2 text-xs leading-[18px] text-[#948CA8]">
<span className="font-semibold">{formatCommentTime(comment.createdAt)}</span>
<button
type="button"
aria-label={liked ? "取消点赞" : "点赞"}
aria-pressed={liked}
onClick={() => void toggleLike(comment)}
className="cursor-pointer flex items-center gap-2 font-semibold"
>
<HeartIcon filled={liked} />
{comment.countLike ?? 0}
</button>
<button
type="button"
onClick={() => (isReplying ? setReplyTo(null) : startReply(comment))}
className={`cursor-pointer hover:text-white ${isReplying ? "text-[#F12B9E]" : ""}`}
>
回复
</button>
</div>
{isReplying && replyTo ? (
<InlineReplyBox
userName={replyTo.userName}
posting={posting}
error={postError}
onSubmit={submitReply}
onCancel={() => setReplyTo(null)}
/>
) : null}
{expanded && replies.length > 1 ? (
<div className="flex flex-col gap-2 rounded-lg bg-[#211F38] px-3 py-2.5 text-xs leading-[18px] text-[#EBE8F5]">
{replies.map((reply) => (
<p key={reply.id}>
{reply.replyUserName
? `${reply.userName || ""} 回复 ${reply.replyUserName}:${reply.text || ""}`
: `${reply.userName || ""}:${reply.text || ""}`}
</p>
))}
<button
type="button"
onClick={() => toggleExpanded(commentId)}
className="cursor-pointer self-start text-[#F12B9E]"
>
收起回复
</button>
</div>
) : (
<CommentReplyPreview
comment={comment}
className="flex flex-col gap-1.5 rounded-lg bg-[#211F38] px-3 py-2.5 text-xs leading-[18px]"
textClassName="text-[#EBE8F5]"
onMore={replies.length > 1 ? () => toggleExpanded(commentId) : undefined}
/>
)}
</div>
</li>
);
})}
</ul>
)}
{!loading && !error && comments.length > 0 ? (
<button
type="button"
disabled={!hasMore || loadingMore}
onClick={loadMore}
className={`cursor-pointer ${styles.more} bg-[#211F38] text-xs leading-[18px] text-[#948CA8] enabled:hover:text-white disabled:opacity-60`}
>
{loadingMore ? "加载中…" : hasMore ? "加载更多" : "没有更多了"}
</button>
) : null}
</section>
);
}
@@ -1,35 +0,0 @@
import type { CommentInfo } from "@/lib/api/types";
/** 直接展示接口 subComment / commentCount,不做字段改名 */
export function CommentReplyPreview({
comment,
className = "",
textClassName = "",
onMore,
}: {
comment: CommentInfo;
className?: string;
textClassName?: string;
onMore?: () => void;
}) {
const first = comment.subComment?.[0];
const more = Number(comment.commentCount) || comment.subComment?.length || 0;
if (!first && more < 1) return null;
const replyLabel = first
? first.replyUserName
? `${first.userName || ""} 回复 ${first.replyUserName}:${first.text || ""}`
: `${first.userName || ""}:${first.text || ""}`
: `共 ${more} 条回复`;
return (
<div data-component="comment-reply-preview" className={className}>
<p className={textClassName}>{replyLabel}</p>
{more > 0 && onMore ? (
<button type="button" onClick={onMore} className="cursor-pointer self-start text-[#F12B9E]">
查看更多 {more} 条回复 ›
</button>
) : null}
</div>
);
}
-82
View File
@@ -1,82 +0,0 @@
import { COMMENT_OBJECT_TYPE, type CommentInfo, type CommentObjectType } from "@/lib/api/types";
export type { CommentInfo };
export type CommentTarget = {
objectId: number;
objectType: CommentObjectType;
};
export const COMMENT_SORTS = ["热门", "最新"] as const;
export type CommentSort = (typeof COMMENT_SORTS)[number];
export const COMMENT_SELF_NAME = "剧迷1024";
export const COMMENT_MAX_LENGTH = 200;
export const COMMENT_PAGE_SIZE = 6;
/** 列表请求超时,避免上游卡住拖住 UI */
export const COMMENT_FETCH_TIMEOUT_MS = 8000;
export function sortToOrder(sort: CommentSort): 1 | 2 {
return sort === "热门" ? 1 : 2;
}
/** 过滤无效评论,保留接口原字段 */
export function filterCommentList(list: CommentInfo[] | null | undefined): CommentInfo[] {
return (list ?? []).filter((item) => {
const id = Number(item?.id);
return Number.isInteger(id) && id > 0;
});
}
/** 本地乐观插入用,字段名与 CommentInfo 一致 */
export function createSelfComment(
text: string,
options?: { userName?: string; avatar?: string },
): CommentInfo {
return {
id: -Date.now(),
userName: (options?.userName || "").trim() || COMMENT_SELF_NAME,
avatar: (options?.avatar || "").trim() || "/images/default_avatar.svg",
text,
createdAt: new Date().toISOString(),
countLike: 0,
isLike: false,
commentCount: 0,
subComment: [],
};
}
export function formatCommentCount(value: number) {
return value >= 10000 ? `${(value / 10000).toFixed(1)}w` : String(value);
}
/** 仅做展示格式化,不改字段名;空则回退原串 */
export function formatCommentTime(value?: string | null) {
const raw = (value || "").trim();
if (!raw) return "";
const date = new Date(raw);
if (Number.isNaN(date.getTime())) return raw;
const pad = (n: number) => String(n).padStart(2, "0");
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
}
export function commentTarget(
objectId: number | string | null | undefined,
objectType: CommentObjectType,
): CommentTarget | null {
const id = Number(objectId);
if (!Number.isInteger(id) || id < 1) return null;
return { objectId: id, objectType };
}
export function playletCommentTarget(playletId: number | string | null | undefined) {
return commentTarget(playletId, COMMENT_OBJECT_TYPE.playlet);
}
export function playletChapterCommentTarget(chapterId: number | string | null | undefined) {
return commentTarget(chapterId, COMMENT_OBJECT_TYPE.playletChapter);
}
export function videoCommentTarget(videoId: number | string | null | undefined) {
return commentTarget(videoId, COMMENT_OBJECT_TYPE.video);
}
@@ -1,204 +0,0 @@
"use client";
import { useState, type FormEvent, type ReactNode } from "react";
import { DecryptedImage } from "@/components/common/decrypted-image";
import { COMMENT_MAX_LENGTH, COMMENT_SORTS, formatCommentTime, type CommentTarget } from "./data";
import { CommentReplyPreview } from "./comment-reply-preview";
import { HeartIcon } from "./heart-icon";
import { InlineReplyBox } from "./inline-reply-box";
import { useComments } from "./use-comments";
function SheetHead({ title, onClose, children }: { title: ReactNode; onClose: () => void; children?: ReactNode }) {
return (
<div className="flex items-center gap-3">
<button
type="button"
aria-label="收起"
onClick={onClose}
className="cursor-pointer flex size-6 items-center justify-center text-white"
>
<svg viewBox="0 0 16 16" className="size-4" aria-hidden="true">
<path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
</svg>
</button>
<h2 className="min-w-0 flex-1 text-center text-base leading-[22px] font-medium text-white">{title}</h2>
{children ?? <span className="size-6" />}
</div>
);
}
/** H5 短剧播放页评论底部弹层 */
export function H5CommentSheet({ onClose, target }: { onClose: () => void; target: CommentTarget | null }) {
const {
sort,
setSort,
comments,
total,
hasMore,
loading,
loadingMore,
error,
loadMore,
toggleLike,
post,
posting,
postError,
reload,
} = useComments({ target });
const [text, setText] = useState("");
const [replyTo, setReplyTo] = useState<{ id: number; userName: string } | null>(null);
const submit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
const content = text.trim();
if (!content || posting || replyTo) return;
const ok = await post(content);
if (ok) setText("");
};
const submitReply = async (content: string) => {
if (!replyTo) return false;
const ok = await post(content, { parentsId: replyTo.id });
if (ok) setReplyTo(null);
return ok;
};
return (
<div data-component="h5-comment-sheet" className="flex h-[70vh] flex-col">
<div className="px-4 pt-[18px] pb-3">
<SheetHead title={`评论 ${total}`} onClose={onClose}>
<div className="flex gap-3 text-xs leading-[18px]">
{COMMENT_SORTS.map((item) => (
<button
key={item}
type="button"
aria-pressed={sort === item}
onClick={() => setSort(item)}
className={`cursor-pointer ${sort === item ? "text-white" : "text-white/35"}`}
>
{item}
</button>
))}
</div>
</SheetHead>
</div>
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain px-4">
{loading ? (
<p className="py-10 text-center text-sm text-white/50">评论加载中…</p>
) : error ? (
<div className="flex flex-col items-center gap-3 py-10">
<p className="text-sm text-white/50">{error}</p>
<button
type="button"
onClick={reload}
className="cursor-pointer rounded-md bg-white/10 px-4 py-2 text-xs text-white"
>
重试
</button>
</div>
) : comments.length === 0 ? (
<p className="py-10 text-center text-sm text-white/50">暂无评论</p>
) : (
<ul>
{comments.map((comment) => {
const liked = Boolean(comment.isLike);
const commentId = Number(comment.id) || 0;
const isReplying = replyTo?.id === commentId;
return (
<li key={comment.id} className="flex gap-3 border-b border-white/5 py-3">
<DecryptedImage
src={comment.avatar}
fallback="/images/default_avatar.svg"
alt=""
className="size-8 shrink-0 rounded-full object-cover"
/>
<div className="flex min-w-0 flex-1 flex-col gap-1">
<p className="text-xs leading-[18px] text-white/50">{comment.userName}</p>
<p className="text-sm leading-5 text-white">{comment.text}</p>
<div className="flex items-center gap-3 text-[11px] leading-4 text-white/35">
<span>{formatCommentTime(comment.createdAt)}</span>
<button
type="button"
aria-pressed={liked}
onClick={() => void toggleLike(comment)}
className="cursor-pointer flex items-center gap-1"
>
<HeartIcon filled={liked} />
{comment.countLike ?? 0}
</button>
<button
type="button"
onClick={() => {
if (isReplying) {
setReplyTo(null);
return;
}
if (!Number.isInteger(commentId) || commentId < 1) return;
setReplyTo({
id: commentId,
userName: (comment.userName || "").trim() || "用户",
});
}}
className={`cursor-pointer ${isReplying ? "text-[#F12B9E]" : "hover:text-white"}`}
>
回复
</button>
</div>
{isReplying && replyTo ? (
<InlineReplyBox
compact
userName={replyTo.userName}
posting={posting}
error={postError}
onSubmit={submitReply}
onCancel={() => setReplyTo(null)}
/>
) : null}
<CommentReplyPreview
comment={comment}
className="rounded-md bg-white/5 px-2.5 py-2 text-xs leading-[18px]"
textClassName="text-white/70"
/>
</div>
</li>
);
})}
</ul>
)}
{!loading && !error && comments.length > 0 ? (
<button
type="button"
disabled={!hasMore || loadingMore}
onClick={loadMore}
className="cursor-pointer my-3 h-9 w-full rounded-md bg-white/5 text-xs text-white/50 disabled:opacity-50"
>
{loadingMore ? "加载中…" : hasMore ? "加载更多" : "没有更多了"}
</button>
) : null}
</div>
<div className="border-t border-white/5 px-4 py-2.5">
{!replyTo && postError ? <p className="mb-2 text-xs text-[#FF8FA8]">{postError}</p> : null}
<form onSubmit={submit} className="flex items-center gap-2.5">
<input
value={text}
maxLength={COMMENT_MAX_LENGTH}
disabled={posting || Boolean(replyTo)}
onChange={(event) => setText(event.target.value)}
placeholder="发表评论…"
aria-label="评论内容"
className="h-9 min-w-0 flex-1 rounded-full bg-white/5 px-4 text-sm text-white outline-none placeholder:text-white/35 disabled:opacity-60"
/>
<button
type="submit"
disabled={!text.trim() || posting || Boolean(replyTo)}
className="cursor-pointer h-9 shrink-0 rounded-full bg-[#F12B9E] px-4 text-sm text-white disabled:opacity-50"
>
{posting && !replyTo ? "发送中" : "发送"}
</button>
</form>
</div>
</div>
);
}
@@ -1,209 +0,0 @@
"use client";
import { useState, type FormEvent, type ReactNode } from "react";
import { DecryptedImage } from "@/components/common/decrypted-image";
import { COMMENT_MAX_LENGTH, COMMENT_SORTS, formatCommentCount, formatCommentTime } from "./data";
import { CommentReplyPreview } from "./comment-reply-preview";
import { InlineReplyBox } from "./inline-reply-box";
import type { UseCommentsResult } from "./use-comments";
type H5CommentsTabProps = {
/** 由页面 useComments 托管,便于 Tab 标题同步总数 */
state: UseCommentsResult;
footerExtra?: ReactNode;
};
/** H5 视频播放页「评论」Tab */
export function H5CommentsTab({ state, footerExtra }: H5CommentsTabProps) {
const {
sort,
setSort,
comments,
total,
hasMore,
loading,
loadingMore,
error,
loadMore,
toggleLike,
post,
posting,
postError,
reload,
} = state;
const [text, setText] = useState("");
const [replyTo, setReplyTo] = useState<{ id: number; userName: string } | null>(null);
const submit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
const content = text.trim();
if (!content || posting || replyTo) return;
const ok = await post(content);
if (ok) setText("");
};
const submitReply = async (content: string) => {
if (!replyTo) return false;
const ok = await post(content, { parentsId: replyTo.id });
if (ok) setReplyTo(null);
return ok;
};
return (
<div data-component="h5-comments-tab" className="flex flex-col">
<div className="flex flex-col gap-3 px-4 py-3">
<div className="flex items-center justify-between">
<h2 className="text-base leading-[22px] font-medium text-white">{total}条评论</h2>
<div className="flex rounded-full bg-white/5 p-0.5">
{COMMENT_SORTS.map((item) => (
<button
key={item}
type="button"
aria-pressed={sort === item}
onClick={() => setSort(item)}
className={`cursor-pointer rounded-full px-2.5 py-1 text-[10px] leading-4 ${
sort === item ? "bg-white/10 text-white" : "text-white/65"
}`}
>
{item === "最新" ? "最新" : "最热"}
</button>
))}
</div>
</div>
{loading ? (
<p className="py-8 text-center text-sm text-white/50">评论加载中…</p>
) : error ? (
<div className="flex flex-col items-center gap-3 py-8">
<p className="text-sm text-white/50">{error}</p>
<button
type="button"
onClick={reload}
className="cursor-pointer rounded-[3px] bg-white/10 px-4 py-2 text-xs text-white"
>
重试
</button>
</div>
) : comments.length === 0 ? (
<p className="py-8 text-center text-sm text-white/50">暂无评论</p>
) : (
<ul className="flex flex-col gap-5">
{comments.map((comment) => {
const liked = Boolean(comment.isLike);
const commentId = Number(comment.id) || 0;
const isReplying = replyTo?.id === commentId;
return (
<li key={comment.id} className="flex gap-3">
<DecryptedImage
src={comment.avatar}
fallback="/images/default_avatar.svg"
alt=""
className="size-10 shrink-0 rounded-full object-cover"
/>
<div className="flex min-w-0 flex-1 flex-col gap-2.5">
<p className="text-sm leading-5 text-white/65">{comment.userName}</p>
<p className="text-sm leading-5 break-words text-white">{comment.text}</p>
<div className="flex items-center justify-between text-xs leading-[18px]">
<div className="flex items-center gap-3">
<span className="text-white/65">{formatCommentTime(comment.createdAt)}</span>
<button
type="button"
className={`cursor-pointer ${isReplying ? "text-[#F12B9E]" : "text-white"}`}
onClick={() => {
if (isReplying) {
setReplyTo(null);
return;
}
if (!Number.isInteger(commentId) || commentId < 1) return;
setReplyTo({
id: commentId,
userName: (comment.userName || "").trim() || "用户",
});
}}
>
回复
</button>
</div>
<button
type="button"
aria-pressed={liked}
onClick={() => void toggleLike(comment)}
className="cursor-pointer flex items-center gap-1 text-white/65"
>
<svg viewBox="0 0 18 18" className="size-[18px]" aria-hidden="true">
<path
d="M9 15.5c-.22 0-.45-.08-.62-.23C5.97 13.25 2.25 10.65 2.25 7.2c0-2.25 1.6-4.05 3.6-4.05 1.24 0 2.37.68 3.15 1.7.78-1.02 1.9-1.7 3.15-1.7 2 0 3.6 1.8 3.6 4.05 0 3.45-3.72 6.05-6.13 8.07-.17.15-.4.23-.62.23Z"
fill={liked ? "#F52C56" : "none"}
stroke="#F52C56"
strokeWidth="1.4"
/>
</svg>
{formatCommentCount(Number(comment.countLike) || 0)}
</button>
</div>
{isReplying && replyTo ? (
<InlineReplyBox
compact
userName={replyTo.userName}
posting={posting}
error={postError}
onSubmit={submitReply}
onCancel={() => setReplyTo(null)}
/>
) : null}
<CommentReplyPreview
comment={comment}
className="flex flex-col gap-1 rounded-[3px] bg-white/5 px-3 py-1.5 text-xs leading-[18px]"
textClassName="text-white/80"
/>
</div>
</li>
);
})}
</ul>
)}
{!loading && !error && comments.length > 0 ? (
<button
type="button"
disabled={!hasMore || loadingMore}
onClick={loadMore}
className="cursor-pointer h-9 w-full rounded-[3px] bg-white/5 text-xs text-white/50 disabled:opacity-50"
>
{loadingMore ? "加载中…" : hasMore ? "加载更多" : "没有更多了"}
</button>
) : null}
</div>
<div className="sticky bottom-0 z-10 bg-[#1A1A1A]">
{!replyTo && postError ? <p className="px-4 pt-2 text-xs text-[#FF8FA8]">{postError}</p> : null}
<form onSubmit={submit} className="flex h-[58px] items-center px-4 py-1.5">
<label className="flex h-full flex-1 items-center gap-2 rounded-[3px] bg-white/5 px-3 py-1.5">
<input
value={text}
maxLength={COMMENT_MAX_LENGTH}
disabled={posting || Boolean(replyTo)}
onChange={(event) => setText(event.target.value)}
placeholder={posting && !replyTo ? "发布中…" : "发表评论…"}
enterKeyHint="send"
className="min-w-0 flex-1 bg-transparent text-sm leading-5 text-white outline-none placeholder:text-white/35 disabled:opacity-60"
/>
<svg viewBox="0 0 24 24" className="size-6 shrink-0" fill="none" aria-hidden="true">
<circle cx="12" cy="12" r="9" stroke="rgba(255,255,255,0.65)" strokeWidth="1.5" />
<path
d="M8.5 14a4 4 0 0 0 7 0"
stroke="rgba(255,255,255,0.65)"
strokeWidth="1.5"
strokeLinecap="round"
/>
<circle cx="9" cy="10" r="1" fill="rgba(255,255,255,0.65)" />
<circle cx="15" cy="10" r="1" fill="rgba(255,255,255,0.65)" />
</svg>
</label>
</form>
</div>
{footerExtra}
</div>
);
}
@@ -1,12 +0,0 @@
export function HeartIcon({ filled, className = "size-[18px]" }: { filled: boolean; className?: string }) {
return (
<svg viewBox="0 0 14 14" fill="none" className={className} aria-hidden="true">
<path
d="M7 11.5c-.2 0-.4-.07-.55-.2C4.6 9.8 2.5 8.2 2.5 5.9 2.5 4.5 3.5 3.5 4.8 3.5c.9 0 1.7.5 2.2 1.2.5-.7 1.3-1.2 2.2-1.2 1.3 0 2.3 1 2.3 2.4 0 2.3-2.1 3.9-3.95 5.4-.15.13-.35.2-.55.2Z"
fill={filled ? "#F12B9E" : "none"}
stroke={filled ? "#F12B9E" : "rgba(255,255,255,0.55)"}
strokeWidth="1.5"
/>
</svg>
);
}

Some files were not shown because too many files have changed in this diff Show More