Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eeb9986923 | ||
|
|
c8895f407c |
@@ -36,7 +36,7 @@ pnpm dev:test # test.env
|
|||||||
| `config/test.env` | 测试构建 / 测试服 |
|
| `config/test.env` | 测试构建 / 测试服 |
|
||||||
| `config/production.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,9 +2,7 @@ APP_ENV=development
|
|||||||
# 浏览器走同源 /api/*(配合 next.config rewrites)
|
# 浏览器走同源 /api/*(配合 next.config rewrites)
|
||||||
NEXT_PUBLIC_API_BASE_URL=
|
NEXT_PUBLIC_API_BASE_URL=
|
||||||
# 上游地址:rewrites + 服务端直连
|
# 上游地址:rewrites + 服务端直连
|
||||||
API_PROXY_TARGET=https://mdcom-wz.80sygtm.com
|
API_PROXY_TARGET=https://webhghlapi.mfcg.me
|
||||||
PORT=26122
|
PORT=26122
|
||||||
NEXT_PUBLIC_TRACKER_APP_ID=JHA-1046
|
NEXT_PUBLIC_SITE_URL=https://huangguohl.com
|
||||||
NEXT_PUBLIC_GTAG_ID=G-748CPNEVP5
|
|
||||||
NEXT_PUBLIC_SITE_URL=https://haijiaosq.net
|
|
||||||
NEXT_PUBLIC_APP_VERSION=1.0.0
|
NEXT_PUBLIC_APP_VERSION=1.0.0
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
NEXT_PUBLIC_API_BASE_URL=
|
NEXT_PUBLIC_API_BASE_URL=
|
||||||
API_PROXY_TARGET=http://139.162.44.29:26119
|
API_PROXY_TARGET=https://webhghlapi.mfcg.me
|
||||||
PORT=3000
|
PORT=3000
|
||||||
NEXT_PUBLIC_TRACKER_APP_ID=JHA-1046
|
NEXT_PUBLIC_SITE_URL=https://huangguohl.com
|
||||||
NEXT_PUBLIC_GTAG_ID=G-748CPNEVP5
|
|
||||||
NEXT_PUBLIC_SITE_URL=https://denv08sep7brv.cloudfront.net
|
|
||||||
NEXT_PUBLIC_APP_VERSION=1.0.0
|
NEXT_PUBLIC_APP_VERSION=1.0.0
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
APP_ENV=test
|
APP_ENV=test
|
||||||
NEXT_PUBLIC_API_BASE_URL=
|
NEXT_PUBLIC_API_BASE_URL=
|
||||||
API_PROXY_TARGET=https://mdcom-wz.80sygtm.com
|
API_PROXY_TARGET=https://webhghlapi.mfcg.me
|
||||||
PORT=26122
|
PORT=26122
|
||||||
NEXT_PUBLIC_TRACKER_APP_ID=JHA-1046
|
NEXT_PUBLIC_SITE_URL=https://huangguohl.com
|
||||||
NEXT_PUBLIC_GTAG_ID=G-748CPNEVP5
|
|
||||||
NEXT_PUBLIC_SITE_URL=https://haijiaosq.net
|
|
||||||
NEXT_PUBLIC_APP_VERSION=1.0.0
|
NEXT_PUBLIC_APP_VERSION=1.0.0
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 434 KiB After Width: | Height: | Size: 65 KiB |
@@ -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 |
@@ -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 |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 164 KiB |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 26 KiB |
@@ -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 |
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 14 KiB |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 328 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
@@ -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 |
@@ -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 |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 15 KiB |
@@ -8,7 +8,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: "关于我们",
|
title: "关于我们",
|
||||||
description: "了解海角社区的品牌、产品与服务。",
|
description: "了解黄果黑料的品牌、产品与服务。",
|
||||||
},
|
},
|
||||||
canonical: "/about",
|
canonical: "/about",
|
||||||
});
|
});
|
||||||
@@ -22,7 +22,7 @@ export default async function Page() {
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: "/about",
|
path: "/about",
|
||||||
title: "关于我们",
|
title: "关于我们",
|
||||||
description: "了解海角社区的品牌、产品与服务。",
|
description: "了解黄果黑料的品牌、产品与服务。",
|
||||||
type: "AboutPage",
|
type: "AboutPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -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 />;
|
|
||||||
}
|
|
||||||
@@ -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} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -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 />;
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import { Suspense } from "react";
|
|||||||
import { AdDialogSlot } from "@/components/ad/ad-dialog-slot";
|
import { AdDialogSlot } from "@/components/ad/ad-dialog-slot";
|
||||||
import { AddressDialogSlot } from "@/components/address/address-dialog-slot";
|
import { AddressDialogSlot } from "@/components/address/address-dialog-slot";
|
||||||
import { AgeGateDialogHost } from "@/components/age-gate/age-gate-dialog";
|
import { AgeGateDialogHost } from "@/components/age-gate/age-gate-dialog";
|
||||||
import { TrackerHost } from "@/components/analytics/tracker-host";
|
|
||||||
import { RequestHeadersPrime } from "@/components/api/request-headers-prime";
|
import { RequestHeadersPrime } from "@/components/api/request-headers-prime";
|
||||||
import { AuthUnauthorizedBridge } from "@/components/auth/auth-unauthorized-bridge";
|
import { AuthUnauthorizedBridge } from "@/components/auth/auth-unauthorized-bridge";
|
||||||
import { GuestAuthBootstrap } from "@/components/auth/guest-auth-bootstrap";
|
import { GuestAuthBootstrap } from "@/components/auth/guest-auth-bootstrap";
|
||||||
@@ -40,20 +39,17 @@ const pageScaleScript = `(function () {
|
|||||||
window.addEventListener("resize", update);
|
window.addEventListener("resize", update);
|
||||||
})();`;
|
})();`;
|
||||||
|
|
||||||
/** GA4 测量 ID(全站 head 注入) */
|
|
||||||
const GA4_MEASUREMENT_ID = "G-748CPNEVP5";
|
|
||||||
|
|
||||||
/** metadataBase 随请求 Host 变化,保证 rel=canonical 与访问地址一致 */
|
/** metadataBase 随请求 Host 变化,保证 rel=canonical 与访问地址一致 */
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
const origin = await getRequestOrigin();
|
const origin = await getRequestOrigin();
|
||||||
return {
|
return {
|
||||||
metadataBase: new URL(origin),
|
metadataBase: new URL(origin),
|
||||||
title: {
|
title: {
|
||||||
default: "海角社区",
|
default: "黄果黑料",
|
||||||
template: "%s",
|
template: "%s",
|
||||||
},
|
},
|
||||||
description: "发现好故事,开启追剧时光",
|
description: "发现好故事,开启追剧时光",
|
||||||
applicationName: "海角社区",
|
applicationName: "黄果黑料",
|
||||||
verification: {
|
verification: {
|
||||||
google: "0Bby47n1AEIB3W8wtLZ-oFQ3l8xRqRT78oA0JVRJ5pM",
|
google: "0Bby47n1AEIB3W8wtLZ-oFQ3l8xRqRT78oA0JVRJ5pM",
|
||||||
yandex: "69b55a6aa9ee9a5f",
|
yandex: "69b55a6aa9ee9a5f",
|
||||||
@@ -64,8 +60,8 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
openGraph: {
|
openGraph: {
|
||||||
type: "website",
|
type: "website",
|
||||||
locale: "zh_CN",
|
locale: "zh_CN",
|
||||||
siteName: "海角社区",
|
siteName: "黄果黑料",
|
||||||
images: [{ url: OG_DEFAULT_IMAGE, alt: "海角社区" }],
|
images: [{ url: OG_DEFAULT_IMAGE, alt: "黄果黑料" }],
|
||||||
},
|
},
|
||||||
twitter: {
|
twitter: {
|
||||||
card: "summary_large_image",
|
card: "summary_large_image",
|
||||||
@@ -93,29 +89,10 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
|
|||||||
// beforeInteractive 会给 html 加 is-cn-browser 等 class,需压制告警
|
// beforeInteractive 会给 html 加 is-cn-browser 等 class,需压制告警
|
||||||
suppressHydrationWarning
|
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">
|
<body className="flex min-h-full flex-col">
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<RequestHeadersPrime />
|
<RequestHeadersPrime />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<Suspense fallback={null}>
|
|
||||||
<TrackerHost />
|
|
||||||
</Suspense>
|
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<HomeBaseDebugSlot />
|
<HomeBaseDebugSlot />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|||||||
@@ -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 />;
|
|
||||||
}
|
|
||||||
@@ -30,8 +30,8 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: data.title,
|
title: data.title,
|
||||||
description: data.subtitle || `浏览海角社区「${data.title}」更多精选内容。`,
|
description: data.subtitle || `浏览黄果黑料「${data.title}」更多精选内容。`,
|
||||||
keyworld: ["海角社区", data.title],
|
keyworld: ["黄果黑料", data.title],
|
||||||
},
|
},
|
||||||
page: pageNum,
|
page: pageNum,
|
||||||
canonical: moreListHref(pathKey, pageNum),
|
canonical: moreListHref(pathKey, pageNum),
|
||||||
@@ -72,7 +72,7 @@ export default async function Page({ params }: { params: Params }) {
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: moreListHref(pathKey, page),
|
path: moreListHref(pathKey, page),
|
||||||
title: data.title,
|
title: data.title,
|
||||||
description: data.subtitle || `浏览海角社区「${data.title}」更多精选内容。`,
|
description: data.subtitle || `浏览黄果黑料「${data.title}」更多精选内容。`,
|
||||||
type: "CollectionPage",
|
type: "CollectionPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { moreListHref } from "@/components/more/route";
|
|||||||
|
|
||||||
/** 无 id 的空壳页;正式内容在 /more/{id},本页不索引 */
|
/** 无 id 的空壳页;正式内容在 /more/{id},本页不索引 */
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "更多内容 - 海角社区",
|
title: "更多内容 - 黄果黑料",
|
||||||
robots: { index: false, follow: false },
|
robots: { index: false, follow: false },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { NavPage } from "@/components/nav/nav-page";
|
|||||||
import { JsonLd } from "@/components/seo/json-ld";
|
import { JsonLd } from "@/components/seo/json-ld";
|
||||||
import { getHomeBaseCached } from "@/lib/api/home";
|
import { getHomeBaseCached } from "@/lib/api/home";
|
||||||
import type { AppTranslationInfo, ConfigInfo } from "@/lib/api/types";
|
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<{
|
async function loadNavBase(): Promise<{
|
||||||
config?: ConfigInfo;
|
config?: ConfigInfo;
|
||||||
@@ -31,17 +31,17 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
description: config?.dhDescription,
|
description: config?.dhDescription,
|
||||||
keyworld: config?.dhKeyworld,
|
keyworld: config?.dhKeyworld,
|
||||||
},
|
},
|
||||||
siteName: config?.dhSiteName?.trim() || undefined,
|
siteName: SITE_NAME,
|
||||||
fallbackTitle: `${config?.dhSiteName?.trim() || "海角社区"} · 官方导航`,
|
fallbackTitle: `${SITE_NAME} · 官方导航`,
|
||||||
fallbackDescription: `${config?.dhSiteName?.trim() || "海角社区"}官方导航页,提供最新访问线路、永久地址、APP 下载与官方联系方式。`,
|
fallbackDescription: `${SITE_NAME}官方导航页,提供最新访问线路、永久地址、APP 下载与官方联系方式。`,
|
||||||
fallbackKeywords: [config?.dhSiteName || "海角社区", "官方导航", "最新地址"].filter(Boolean) as string[],
|
fallbackKeywords: [SITE_NAME, "官方导航", "最新地址"],
|
||||||
canonical: "/nav",
|
canonical: "/nav",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { config, bottonTranslations } = await loadNavBase();
|
const { config, bottonTranslations } = await loadNavBase();
|
||||||
const siteName = config?.dhSiteName?.trim() || config?.webSiteName?.trim() || "海角社区";
|
const siteName = SITE_NAME;
|
||||||
const seo = mergeSEO(
|
const seo = mergeSEO(
|
||||||
{ title: config?.dhTitle, description: config?.dhDescription, keyworld: config?.dhKeyworld },
|
{ title: config?.dhTitle, description: config?.dhDescription, keyworld: config?.dhKeyworld },
|
||||||
{ title: config?.webTitle, description: config?.webDescription, keyworld: config?.webKeyworld },
|
{ title: config?.webTitle, description: config?.webDescription, keyworld: config?.webKeyworld },
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { GoBackButton } from "@/components/not-found/go-back-button";
|
|||||||
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
|
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "页面不存在 - 海角社区",
|
title: "页面不存在 - 黄果黑料",
|
||||||
robots: { index: false, follow: false },
|
robots: { index: false, follow: false },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
// seoInfo → home/base 公共 web* → 代码兜底
|
// seoInfo → home/base 公共 web* → 代码兜底
|
||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: home?.seoInfo,
|
seoInfo: home?.seoInfo,
|
||||||
fallbackTitle: "海角社区 - 热门短剧在线看",
|
fallbackTitle: "黄果黑料 - 热门短剧在线看",
|
||||||
fallbackDescription: "海角社区汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。",
|
fallbackDescription: "黄果黑料汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。",
|
||||||
fallbackKeywords: ["海角社区", "短剧", "在线短剧", "热门短剧"],
|
fallbackKeywords: ["黄果黑料", "短剧", "在线短剧", "热门短剧"],
|
||||||
canonical: "/",
|
canonical: "/",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -64,9 +64,9 @@ export default async function Home() {
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
const seo = mergeSEO(home?.seoInfo, siteSeo.seo);
|
const seo = mergeSEO(home?.seoInfo, siteSeo.seo);
|
||||||
const homeTitle = seo.title || "海角社区 - 热门短剧在线看";
|
const homeTitle = seo.title || "黄果黑料 - 热门短剧在线看";
|
||||||
const homeDescription =
|
const homeDescription =
|
||||||
seo.description || "海角社区汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。";
|
seo.description || "黄果黑料汇集热门短剧、最近上新、排行榜与精选专题推荐,支持高清在线播放。";
|
||||||
const itemListUrls =
|
const itemListUrls =
|
||||||
home?.homeBannerData
|
home?.homeBannerData
|
||||||
?.filter((item): item is PlayletData & { id: number } => Boolean(item?.id))
|
?.filter((item): item is PlayletData & { id: number } => Boolean(item?.id))
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: "隐私政策",
|
title: "隐私政策",
|
||||||
description: "查看海角社区隐私政策与个人信息保护说明。",
|
description: "查看黄果黑料隐私政策与个人信息保护说明。",
|
||||||
},
|
},
|
||||||
canonical: "/privacy",
|
canonical: "/privacy",
|
||||||
});
|
});
|
||||||
@@ -22,7 +22,7 @@ export default async function Page() {
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: "/privacy",
|
path: "/privacy",
|
||||||
title: "隐私政策",
|
title: "隐私政策",
|
||||||
description: "查看海角社区隐私政策与个人信息保护说明。",
|
description: "查看黄果黑料隐私政策与个人信息保护说明。",
|
||||||
type: "WebPage",
|
type: "WebPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -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 />;
|
|
||||||
}
|
|
||||||
@@ -39,8 +39,8 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: `${tabText}排行榜`,
|
title: `${tabText}排行榜`,
|
||||||
description: `查看海角社区实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
|
description: `查看黄果黑料实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
|
||||||
keyworld: ["海角社区", "排行榜", tabText],
|
keyworld: ["黄果黑料", "排行榜", tabText],
|
||||||
},
|
},
|
||||||
page: pageNum,
|
page: pageNum,
|
||||||
canonical: rankingHref(tab, pageNum),
|
canonical: rankingHref(tab, pageNum),
|
||||||
@@ -100,7 +100,7 @@ async function RankingContent({ params }: { params: Params }) {
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: rankingHref(tab, page),
|
path: rankingHref(tab, page),
|
||||||
title: `${tabText}排行榜`,
|
title: `${tabText}排行榜`,
|
||||||
description: `查看海角社区实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
|
description: `查看黄果黑料实时更新的${tabText}排行榜,浏览热播内容与精选推荐。`,
|
||||||
type: "CollectionPage",
|
type: "CollectionPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -1,37 +1,17 @@
|
|||||||
import type { MetadataRoute } from "next";
|
import type { MetadataRoute } from "next";
|
||||||
|
|
||||||
import { getHomeBaseCached } from "@/lib/api/home";
|
|
||||||
import { getRequestOrigin, getSiteOrigin } from "@/lib/seo/site";
|
import { getRequestOrigin, getSiteOrigin } from "@/lib/seo/site";
|
||||||
|
|
||||||
/** 从地址字符串解析 origin(支持无协议域名) */
|
/** 基础 robots:私有页 / 搜索 disallow,并声明 sitemap(取本站域名) */
|
||||||
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) */
|
|
||||||
export default async function robots(): Promise<MetadataRoute.Robots> {
|
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 configured = process.env.NEXT_PUBLIC_SITE_URL?.trim();
|
||||||
const origin = forever || (configured ? getSiteOrigin() : await getRequestOrigin());
|
const origin = configured ? getSiteOrigin() : await getRequestOrigin();
|
||||||
return {
|
return {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
userAgent: "*",
|
userAgent: "*",
|
||||||
allow: "/",
|
allow: "/",
|
||||||
disallow: [
|
disallow: [
|
||||||
"/profile",
|
|
||||||
"/history",
|
|
||||||
"/favorites",
|
|
||||||
"/likes",
|
|
||||||
"/settings",
|
|
||||||
"/feedback",
|
|
||||||
// 前缀匹配:/search、/search/短剧/... 均不抓
|
// 前缀匹配:/search、/search/短剧/... 均不抓
|
||||||
"/search",
|
"/search",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: `搜索「${parsed.query}」`,
|
title: `搜索「${parsed.query}」`,
|
||||||
description: `在海角社区搜索「${parsed.query}」的${parsed.type}结果。`,
|
description: `在黄果黑料搜索「${parsed.query}」的${parsed.type}结果。`,
|
||||||
keyworld: ["海角社区", "搜索", parsed.query, parsed.type],
|
keyworld: ["黄果黑料", "搜索", parsed.query, parsed.type],
|
||||||
},
|
},
|
||||||
page: parsed.page,
|
page: parsed.page,
|
||||||
canonical: searchListHref(parsed.query, parsed.type, parsed.page),
|
canonical: searchListHref(parsed.query, parsed.type, parsed.page),
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ function first(value: string | string[] | undefined) {
|
|||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
fallbackTitle: "搜索",
|
fallbackTitle: "搜索",
|
||||||
fallbackDescription: "搜索海角社区短剧与视频。",
|
fallbackDescription: "搜索黄果黑料短剧与视频。",
|
||||||
fallbackKeywords: ["海角社区", "搜索"],
|
fallbackKeywords: ["黄果黑料", "搜索"],
|
||||||
canonical: "/search",
|
canonical: "/search",
|
||||||
// 搜索入口不收录;robots.txt 同步 Disallow /search
|
// 搜索入口不收录;robots.txt 同步 Disallow /search
|
||||||
robots: { index: false, follow: false },
|
robots: { index: false, follow: false },
|
||||||
|
|||||||
@@ -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 />;
|
|
||||||
}
|
|
||||||
@@ -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 />;
|
|
||||||
}
|
|
||||||
@@ -13,12 +13,12 @@ import {
|
|||||||
playHref,
|
playHref,
|
||||||
RECOMMEND_DISPLAY_COUNT,
|
RECOMMEND_DISPLAY_COUNT,
|
||||||
resolvePlayURL,
|
resolvePlayURL,
|
||||||
|
totalEpisodeOf,
|
||||||
type DramaDetail,
|
type DramaDetail,
|
||||||
type DramaPlayView,
|
type DramaPlayView,
|
||||||
type RelatedDrama,
|
type RelatedDrama,
|
||||||
} from "@/components/drama-detail/data";
|
} from "@/components/drama-detail/data";
|
||||||
import { DramaDetailPage } from "@/components/drama-detail/drama-detail-page";
|
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 { DramaPlayPage } from "@/components/drama-play/drama-play-page";
|
||||||
import { JsonLd } from "@/components/seo/json-ld";
|
import { JsonLd } from "@/components/seo/json-ld";
|
||||||
import {
|
import {
|
||||||
@@ -39,6 +39,7 @@ import {
|
|||||||
import { ShortDramaPage } from "@/components/short-drama/short-drama-page";
|
import { ShortDramaPage } from "@/components/short-drama/short-drama-page";
|
||||||
import {
|
import {
|
||||||
getPlayletChapterInfoCached,
|
getPlayletChapterInfoCached,
|
||||||
|
getPlayletGuessListCached,
|
||||||
getPlayletInfoCached,
|
getPlayletInfoCached,
|
||||||
getPlayletListCached,
|
getPlayletListCached,
|
||||||
getPlayletRecommendListCached,
|
getPlayletRecommendListCached,
|
||||||
@@ -52,6 +53,7 @@ import {
|
|||||||
buildPlayletDetailJSONLD,
|
buildPlayletDetailJSONLD,
|
||||||
buildPlayletPlayJSONLD,
|
buildPlayletPlayJSONLD,
|
||||||
buildWebPageJSONLD,
|
buildWebPageJSONLD,
|
||||||
|
clipText,
|
||||||
getHomeBaseSEOCached,
|
getHomeBaseSEOCached,
|
||||||
mergeSEO,
|
mergeSEO,
|
||||||
resolveContentMetadata,
|
resolveContentMetadata,
|
||||||
@@ -80,7 +82,10 @@ function playletLookup(idOrSlug: string): { id?: string; slug?: string } {
|
|||||||
return { slug: idOrSlug };
|
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[]> {
|
async function loadPlayletRecommend(excludeId?: number | string | null): Promise<RelatedDrama[]> {
|
||||||
try {
|
try {
|
||||||
const data = await getPlayletRecommendListCached({
|
const data = await getPlayletRecommendListCached({
|
||||||
@@ -88,9 +93,20 @@ async function loadPlayletRecommend(excludeId?: number | string | null): Promise
|
|||||||
pageSize: RECOMMEND_PAGE_SIZE,
|
pageSize: RECOMMEND_PAGE_SIZE,
|
||||||
sortList: 1,
|
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) {
|
} catch (error) {
|
||||||
console.error("[short-drama/recommend]", 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 [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,9 +156,9 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
|
|||||||
seoInfo: theme?.seoInfo,
|
seoInfo: theme?.seoInfo,
|
||||||
fallbackTitle: themeName ? `短剧·${themeName}·${sortText}` : `短剧·${sortText}`,
|
fallbackTitle: themeName ? `短剧·${themeName}·${sortText}` : `短剧·${sortText}`,
|
||||||
fallbackDescription: themeName
|
fallbackDescription: themeName
|
||||||
? `浏览海角社区短剧「${themeName}」题材,按${sortText}发现精彩作品。`
|
? `浏览黄果黑料短剧「${themeName}」题材,按${sortText}发现精彩作品。`
|
||||||
: `浏览海角社区短剧列表,按${sortText}发现精彩作品。`,
|
: `浏览黄果黑料短剧列表,按${sortText}发现精彩作品。`,
|
||||||
fallbackKeywords: ["海角社区", "短剧", themeName, sortText].filter(Boolean),
|
fallbackKeywords: ["黄果黑料", "短剧", themeName, sortText].filter(Boolean),
|
||||||
page: pageNum,
|
page: pageNum,
|
||||||
canonical: shortDramaListHref(sortKey, pageNum, themeSlug),
|
canonical: shortDramaListHref(sortKey, pageNum, themeSlug),
|
||||||
});
|
});
|
||||||
@@ -151,20 +167,23 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
|
|||||||
// 播放页 title:短剧标题 + 第几集 + 网页标题(站点名由 withSiteSuffix 追加)
|
// 播放页 title:短剧标题 + 第几集 + 网页标题(站点名由 withSiteSuffix 追加)
|
||||||
if (page?.length === 1) {
|
if (page?.length === 1) {
|
||||||
const play = await loadPlayletPlay(decodeSegment(sort), page[0]);
|
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 dramaTitle = play.detail.title?.trim() || "短剧";
|
||||||
const playTitle = `${dramaTitle} 第${play.episode}集`;
|
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;
|
void _seoTitle;
|
||||||
return resolveContentMetadata({
|
return resolveContentMetadata({
|
||||||
seoInfo: play.detail.seoInfo ? playSeoRest : null,
|
seoInfo: play.detail.seoInfo ? playSeoRest : null,
|
||||||
fallbackTitle: playTitle,
|
fallbackTitle: playTitle,
|
||||||
fallbackDescription:
|
fallbackDescription: [
|
||||||
play.detail.desc || `在线观看《${dramaTitle}》第${play.episode}集`,
|
`《${dramaTitle}》第${play.episode}集(共${totalEpisodeOf(play.detail)}集)`,
|
||||||
|
clipText(seoDescription || play.detail.desc, 70) || "按集收看,分集目录与同类短剧推荐见本页。",
|
||||||
|
].join(":"),
|
||||||
fallbackKeywords: [
|
fallbackKeywords: [
|
||||||
"海角社区",
|
"黄果黑料",
|
||||||
"短剧",
|
"短剧",
|
||||||
"在线播放",
|
"分集",
|
||||||
dramaTitle,
|
dramaTitle,
|
||||||
playTitle,
|
playTitle,
|
||||||
...(play.detail.tagNames ?? []),
|
...(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),
|
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)
|
// 详情页:TDK 用短剧详情(playlet/info)
|
||||||
const detail = await loadPlayletDetail(decodeSegment(sort));
|
const detail = await loadPlayletDetail(decodeSegment(sort));
|
||||||
if (!detail) return resolveContentMetadata({ fallbackTitle: "海角社区" });
|
if (!detail) return resolveContentMetadata({ fallbackTitle: "黄果黑料" });
|
||||||
return resolveContentMetadata({
|
return resolveContentMetadata({
|
||||||
seoInfo: detail.seoInfo,
|
seoInfo: detail.seoInfo,
|
||||||
fallbackTitle: detail.title,
|
fallbackTitle: detail.title ? `${detail.title}(全${totalEpisodeOf(detail)}集)` : undefined,
|
||||||
fallbackDescription: detail.desc || `在线观看《${detail.title}》,查看选集、剧情信息与相关推荐。`,
|
fallbackDescription: [
|
||||||
fallbackKeywords: ["海角社区", "短剧", detail.title || "", ...(detail.tagNames ?? [])].filter(
|
`《${detail.title || "短剧"}》全${totalEpisodeOf(detail)}集${detail.themeNames?.[0] ? `·${detail.themeNames[0]}` : ""}`,
|
||||||
|
clipText(detail.desc, 90) || "剧情介绍、分集目录与同类短剧推荐。",
|
||||||
|
].join("|"),
|
||||||
|
fallbackKeywords: ["黄果黑料", "短剧", detail.title || "", ...(detail.tagNames ?? [])].filter(
|
||||||
Boolean,
|
Boolean,
|
||||||
),
|
),
|
||||||
canonical: dramaDetailHref(detail),
|
canonical: dramaDetailHref(detail),
|
||||||
@@ -317,8 +339,8 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
|
|||||||
const listDescription =
|
const listDescription =
|
||||||
listSeo.description ||
|
listSeo.description ||
|
||||||
(themeName
|
(themeName
|
||||||
? `浏览海角社区短剧「${themeName}」题材,按${sortText}发现精彩作品。`
|
? `浏览黄果黑料短剧「${themeName}」题材,按${sortText}发现精彩作品。`
|
||||||
: `浏览海角社区短剧列表,按${sortText}发现精彩作品。`);
|
: `浏览黄果黑料短剧列表,按${sortText}发现精彩作品。`);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<JsonLd
|
<JsonLd
|
||||||
@@ -365,7 +387,6 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
|
|||||||
<DramaDetailPage
|
<DramaDetailPage
|
||||||
detail={mapped.detail}
|
detail={mapped.detail}
|
||||||
related={mapped.related}
|
related={mapped.related}
|
||||||
relatedAside={<RelatedAside items={mapped.related} />}
|
|
||||||
adIcons={<AdIconsSlot variant="pc" />}
|
adIcons={<AdIconsSlot variant="pc" />}
|
||||||
promo={<AdBannersSlot variant="pc" />}
|
promo={<AdBannersSlot variant="pc" />}
|
||||||
adGrid={<AdIconsSlot variant="h5" />}
|
adGrid={<AdIconsSlot variant="h5" />}
|
||||||
@@ -407,7 +428,6 @@ async function ShortDramaRouteContent({ params }: { params: Params }) {
|
|||||||
episode={play.episode}
|
episode={play.episode}
|
||||||
src={play.src}
|
src={play.src}
|
||||||
related={play.related}
|
related={play.related}
|
||||||
relatedAside={<RelatedAside items={play.related} />}
|
|
||||||
adIcons={<AdIconsSlot variant="pc" />}
|
adIcons={<AdIconsSlot variant="pc" />}
|
||||||
promo={<AdBannersSlot variant="pc" />}
|
promo={<AdBannersSlot variant="pc" />}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export async function generateMetadata({
|
|||||||
const query = await searchParams;
|
const query = await searchParams;
|
||||||
const parsed = parseTagSlug((await params).slug, query.kind, query.page);
|
const parsed = parseTagSlug((await params).slug, query.kind, query.page);
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
return resolvePageMetadata({ seoInfo: { title: "标签", keyworld: ["海角社区", "标签"] } });
|
return resolvePageMetadata({ seoInfo: { title: "标签", keyworld: ["黄果黑料", "标签"] } });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { key, page, kind: preferredKind } = parsed;
|
const { key, page, kind: preferredKind } = parsed;
|
||||||
@@ -98,15 +98,15 @@ export async function generateMetadata({
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: `${data.name}标签`,
|
title: `${data.name}标签`,
|
||||||
description: `浏览海角社区「${data.name}」标签相关${unit}。`,
|
description: `浏览黄果黑料「${data.name}」标签相关${unit}。`,
|
||||||
keyworld: ["海角社区", "标签", data.name, unit],
|
keyworld: ["黄果黑料", "标签", data.name, unit],
|
||||||
},
|
},
|
||||||
page,
|
page,
|
||||||
canonical: tagListHref(pathKey, page, data.kind),
|
canonical: tagListHref(pathKey, page, data.kind),
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: { title: key, keyworld: ["海角社区", "标签", key] },
|
seoInfo: { title: key, keyworld: ["黄果黑料", "标签", key] },
|
||||||
page,
|
page,
|
||||||
canonical: tagListHref(key, page, preferredKind ?? "playlet"),
|
canonical: tagListHref(key, page, preferredKind ?? "playlet"),
|
||||||
});
|
});
|
||||||
@@ -163,7 +163,7 @@ export default async function Page({
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: tagListHref(pathKey, page, data.kind),
|
path: tagListHref(pathKey, page, data.kind),
|
||||||
title: `${data.name}标签`,
|
title: `${data.name}标签`,
|
||||||
description: `浏览海角社区「${data.name}」标签相关${unit}。`,
|
description: `浏览黄果黑料「${data.name}」标签相关${unit}。`,
|
||||||
type: "CollectionPage",
|
type: "CollectionPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: "用户协议",
|
title: "用户协议",
|
||||||
description: "查看海角社区用户服务条款及平台使用规则。",
|
description: "查看黄果黑料用户服务条款及平台使用规则。",
|
||||||
},
|
},
|
||||||
canonical: "/terms",
|
canonical: "/terms",
|
||||||
});
|
});
|
||||||
@@ -22,7 +22,7 @@ export default async function Page() {
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: "/terms",
|
path: "/terms",
|
||||||
title: "用户协议",
|
title: "用户协议",
|
||||||
description: "查看海角社区用户服务条款及平台使用规则。",
|
description: "查看黄果黑料用户服务条款及平台使用规则。",
|
||||||
type: "WebPage",
|
type: "WebPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ export async function generateMetadata({
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: data.seoInfo ?? {
|
seoInfo: data.seoInfo ?? {
|
||||||
title: name,
|
title: name,
|
||||||
description: (data.desc || "").trim() || `浏览海角社区专题「${name}」。`,
|
description: (data.desc || "").trim() || `浏览黄果黑料专题「${name}」。`,
|
||||||
keyworld: ["海角社区", name],
|
keyworld: ["黄果黑料", name],
|
||||||
},
|
},
|
||||||
page: parsed.page,
|
page: parsed.page,
|
||||||
canonical,
|
canonical,
|
||||||
@@ -229,7 +229,7 @@ export default async function Page({
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: topicListHref(pathKey, { dataType: resolvedDataType, page, sortType }),
|
path: topicListHref(pathKey, { dataType: resolvedDataType, page, sortType }),
|
||||||
title: `${name} · ${topicSortLabel(sortType)}`,
|
title: `${name} · ${topicSortLabel(sortType)}`,
|
||||||
description: desc || `浏览海角社区专题「${name}」。`,
|
description: desc || `浏览黄果黑料专题「${name}」。`,
|
||||||
type: "CollectionPage",
|
type: "CollectionPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { PageLoading } from "@/components/common/page-loading";
|
|||||||
import { sortLabels } from "@/components/short-drama/data";
|
import { sortLabels } from "@/components/short-drama/data";
|
||||||
import {
|
import {
|
||||||
buildVideoList,
|
buildVideoList,
|
||||||
|
mapVideoListItem,
|
||||||
VIDEO_PAGE_SIZE,
|
VIDEO_PAGE_SIZE,
|
||||||
videoSorts,
|
videoSorts,
|
||||||
videoSortType,
|
videoSortType,
|
||||||
@@ -25,7 +26,6 @@ import {
|
|||||||
VIDEO_RECOMMEND_DISPLAY_COUNT,
|
VIDEO_RECOMMEND_DISPLAY_COUNT,
|
||||||
type VideoPlayView,
|
type VideoPlayView,
|
||||||
} from "@/components/video-play/data";
|
} from "@/components/video-play/data";
|
||||||
import { VideoRelatedAside } from "@/components/video-play/related-aside";
|
|
||||||
import { VideoPlayPage } from "@/components/video-play/video-play-page";
|
import { VideoPlayPage } from "@/components/video-play/video-play-page";
|
||||||
import { JsonLd } from "@/components/seo/json-ld";
|
import { JsonLd } from "@/components/seo/json-ld";
|
||||||
import {
|
import {
|
||||||
@@ -41,6 +41,7 @@ import { primeRequestForwardHeaders } from "@/lib/api/request-context";
|
|||||||
import {
|
import {
|
||||||
buildVideoPlayJSONLD,
|
buildVideoPlayJSONLD,
|
||||||
buildWebPageJSONLD,
|
buildWebPageJSONLD,
|
||||||
|
clipText,
|
||||||
getHomeBaseSEOCached,
|
getHomeBaseSEOCached,
|
||||||
mergeSEO,
|
mergeSEO,
|
||||||
resolveContentMetadata,
|
resolveContentMetadata,
|
||||||
@@ -98,7 +99,28 @@ async function loadVideoDetailWithRecommend(idOrSlug: string): Promise<VideoPlay
|
|||||||
const mapped = await loadVideoDetail(idOrSlug);
|
const mapped = await loadVideoDetail(idOrSlug);
|
||||||
if (!mapped) return null;
|
if (!mapped) return null;
|
||||||
const related = await loadVideoRecommend(mapped.detail.id);
|
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> {
|
export async function generateMetadata({ params }: { params: Params }): Promise<Metadata> {
|
||||||
@@ -119,23 +141,27 @@ export async function generateMetadata({ params }: { params: Params }): Promise<
|
|||||||
seoInfo: category?.seoInfo,
|
seoInfo: category?.seoInfo,
|
||||||
fallbackTitle: categoryName ? `视频·${categoryName}·${sortText}` : `视频·${sortText}`,
|
fallbackTitle: categoryName ? `视频·${categoryName}·${sortText}` : `视频·${sortText}`,
|
||||||
fallbackDescription: categoryName
|
fallbackDescription: categoryName
|
||||||
? `浏览海角社区视频「${categoryName}」分类,按${sortText}发现精彩内容。`
|
? `浏览黄果黑料视频「${categoryName}」分类,按${sortText}发现精彩内容。`
|
||||||
: `浏览海角社区视频列表,按${sortText}发现精彩内容。`,
|
: `浏览黄果黑料视频列表,按${sortText}发现精彩内容。`,
|
||||||
fallbackKeywords: ["海角社区", "视频", categoryName, sortText].filter(Boolean),
|
fallbackKeywords: ["黄果黑料", "视频", categoryName, sortText].filter(Boolean),
|
||||||
page: pageNum,
|
page: pageNum,
|
||||||
canonical: videoListHref(sortKey, pageNum, categorySlug),
|
canonical: videoListHref(sortKey, pageNum, categorySlug),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (page?.length) return resolvePageMetadata({ fallbackTitle: "海角社区" });
|
if (page?.length) return resolvePageMetadata({ fallbackTitle: "黄果黑料" });
|
||||||
// 视频播放页:TDK 用视频详情(video/info)
|
// 视频播放页:TDK 用视频详情(video/info)
|
||||||
const mapped = await loadVideoDetail(decodeSegment(sort));
|
const mapped = await loadVideoDetail(decodeSegment(sort));
|
||||||
const detail = mapped?.detail;
|
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);
|
const tagNames = (detail.tags ?? []).map((tag) => tag.name?.trim() || "").filter(Boolean);
|
||||||
return resolveContentMetadata({
|
return resolveContentMetadata({
|
||||||
fallbackTitle: detail.title,
|
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",
|
ogType: "video.episode",
|
||||||
canonical: videoHref(String(detail.id), detail.slug),
|
canonical: videoHref(String(detail.id), detail.slug),
|
||||||
});
|
});
|
||||||
@@ -231,8 +257,8 @@ async function VideoRouteContent({ params }: { params: Params }) {
|
|||||||
const listDescription =
|
const listDescription =
|
||||||
listSeo.description ||
|
listSeo.description ||
|
||||||
(categoryName
|
(categoryName
|
||||||
? `浏览海角社区视频「${categoryName}」分类,按${sortText}发现精彩内容。`
|
? `浏览黄果黑料视频「${categoryName}」分类,按${sortText}发现精彩内容。`
|
||||||
: `浏览海角社区视频列表,按${sortText}发现精彩内容。`);
|
: `浏览黄果黑料视频列表,按${sortText}发现精彩内容。`);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<JsonLd
|
<JsonLd
|
||||||
@@ -281,7 +307,6 @@ async function VideoRouteContent({ params }: { params: Params }) {
|
|||||||
detail={mapped.detail}
|
detail={mapped.detail}
|
||||||
src={mapped.src}
|
src={mapped.src}
|
||||||
related={mapped.related}
|
related={mapped.related}
|
||||||
relatedAside={<VideoRelatedAside items={mapped.related} />}
|
|
||||||
adIcons={<AdIconsSlot variant="pc" labels={false} />}
|
adIcons={<AdIconsSlot variant="pc" labels={false} />}
|
||||||
promo={<AdBannersSlot variant="pc" />}
|
promo={<AdBannersSlot variant="pc" />}
|
||||||
adGrid={<AdIconsSlot variant="h5" />}
|
adGrid={<AdIconsSlot variant="h5" />}
|
||||||
|
|||||||
@@ -4,16 +4,13 @@ import { cache } from "react";
|
|||||||
import { JsonLd } from "@/components/seo/json-ld";
|
import { JsonLd } from "@/components/seo/json-ld";
|
||||||
import { WayHomePage } from "@/components/way-home/way-home-page";
|
import { WayHomePage } from "@/components/way-home/way-home-page";
|
||||||
import { getHomeBaseCached } from "@/lib/api/home";
|
import { getHomeBaseCached } from "@/lib/api/home";
|
||||||
import type { AnnouncementInfo, ConfigInfo } from "@/lib/api/types";
|
import type { AnnouncementInfo } from "@/lib/api/types";
|
||||||
import { buildWebPageJSONLD, resolvePageMetadata } from "@/lib/seo";
|
import { buildWebPageJSONLD, resolvePageMetadata, SITE_NAME } from "@/lib/seo";
|
||||||
|
|
||||||
const loadWayHomeBase = cache(async (): Promise<{
|
const loadWayHomeBase = cache(async (): Promise<{ announcement?: AnnouncementInfo }> => {
|
||||||
announcement?: AnnouncementInfo;
|
|
||||||
config?: ConfigInfo;
|
|
||||||
}> => {
|
|
||||||
try {
|
try {
|
||||||
const base = await getHomeBaseCached();
|
const base = await getHomeBaseCached();
|
||||||
return { announcement: base.announcement, config: base.config };
|
return { announcement: base.announcement };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("[way-home] home/base failed", error);
|
console.warn("[way-home] home/base failed", error);
|
||||||
return {};
|
return {};
|
||||||
@@ -21,8 +18,7 @@ const loadWayHomeBase = cache(async (): Promise<{
|
|||||||
});
|
});
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
const { config } = await loadWayHomeBase();
|
const siteName = SITE_NAME;
|
||||||
const siteName = config?.webSiteName?.trim() || config?.dhSiteName?.trim() || "海角社区";
|
|
||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
siteName,
|
siteName,
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
@@ -35,8 +31,8 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const { announcement, config } = await loadWayHomeBase();
|
const { announcement } = await loadWayHomeBase();
|
||||||
const siteName = config?.webSiteName?.trim() || config?.dhSiteName?.trim() || "海角社区";
|
const siteName = SITE_NAME;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<JsonLd
|
<JsonLd
|
||||||
@@ -52,7 +48,7 @@ export default async function Page() {
|
|||||||
siteName,
|
siteName,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<WayHomePage announcement={announcement} config={config} />
|
<WayHomePage announcement={announcement} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
return resolvePageMetadata({
|
return resolvePageMetadata({
|
||||||
seoInfo: {
|
seoInfo: {
|
||||||
title: "福利应用",
|
title: "福利应用",
|
||||||
description: "海角社区福利应用与精选推荐。",
|
description: "黄果黑料福利应用与精选推荐。",
|
||||||
keyworld: ["海角社区", "福利应用"],
|
keyworld: ["黄果黑料", "福利应用"],
|
||||||
},
|
},
|
||||||
canonical: "/welfare",
|
canonical: "/welfare",
|
||||||
});
|
});
|
||||||
@@ -35,7 +35,7 @@ async function WelfareContent() {
|
|||||||
data={buildWebPageJSONLD({
|
data={buildWebPageJSONLD({
|
||||||
path: "/welfare",
|
path: "/welfare",
|
||||||
title: "福利应用",
|
title: "福利应用",
|
||||||
description: "海角社区福利应用与精选推荐。",
|
description: "黄果黑料福利应用与精选推荐。",
|
||||||
type: "CollectionPage",
|
type: "CollectionPage",
|
||||||
breadcrumbs: [
|
breadcrumbs: [
|
||||||
["首页", "/"],
|
["首页", "/"],
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ const sections: { title: string; paragraphs: string[]; slogan?: boolean }[] = [
|
|||||||
{
|
{
|
||||||
title: "联系我们",
|
title: "联系我们",
|
||||||
paragraphs: [
|
paragraphs: [
|
||||||
"商务合作:business@qimengshorts.com",
|
"官方TG:@jbd125",
|
||||||
"用户反馈:support@qimengshorts.com",
|
|
||||||
"服务时间:工作日 10:00–18:00",
|
"服务时间:工作日 10:00–18:00",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore
|
|||||||
|
|
||||||
import { getAgeGateOpen, subscribeAgeGate } from "@/components/age-gate/age-gate-dialog";
|
import { getAgeGateOpen, subscribeAgeGate } from "@/components/age-gate/age-gate-dialog";
|
||||||
import { DecryptedImage } from "@/components/common/decrypted-image";
|
import { DecryptedImage } from "@/components/common/decrypted-image";
|
||||||
import { adTrackProps } from "@/components/common/ads/pick";
|
|
||||||
import { useChromeless } from "@/components/layout/route-visibility";
|
import { useChromeless } from "@/components/layout/route-visibility";
|
||||||
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
|
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
|
||||||
|
|
||||||
@@ -200,34 +199,6 @@ export function AdDialogHost({
|
|||||||
}, [index, showNext]);
|
}, [index, showNext]);
|
||||||
|
|
||||||
const ad = index >= 0 && index < ads.length ? ads[index] : null;
|
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 null;
|
||||||
|
|
||||||
const picture = (
|
const picture = (
|
||||||
@@ -252,10 +223,6 @@ export function AdDialogHost({
|
|||||||
aria-label={ad.title || "广告"}
|
aria-label={ad.title || "广告"}
|
||||||
className="my-auto flex flex-col items-center gap-9 lg:gap-6"
|
className="my-auto flex flex-col items-center gap-9 lg:gap-6"
|
||||||
onClick={(event) => event.target === event.currentTarget && showNext()}
|
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 ? (
|
{ad.link ? (
|
||||||
<a
|
<a
|
||||||
@@ -263,24 +230,6 @@ export function AdDialogHost({
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer sponsored"
|
rel="noopener noreferrer sponsored"
|
||||||
className="block"
|
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}
|
{picture}
|
||||||
</a>
|
</a>
|
||||||
@@ -290,7 +239,6 @@ export function AdDialogHost({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="关闭广告"
|
aria-label="关闭广告"
|
||||||
data-dialog-ad-close=""
|
|
||||||
onClick={showNext}
|
onClick={showNext}
|
||||||
className="size-9 cursor-pointer"
|
className="size-9 cursor-pointer"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { getAdOpen, hasAdShown, subscribeAd } from "@/components/ad/ad-dialog";
|
|||||||
import { getAgeGateOpen, subscribeAgeGate } from "@/components/age-gate/age-gate-dialog";
|
import { getAgeGateOpen, subscribeAgeGate } from "@/components/age-gate/age-gate-dialog";
|
||||||
import { useChromeless } from "@/components/layout/route-visibility";
|
import { useChromeless } from "@/components/layout/route-visibility";
|
||||||
import type { AnnouncementInfo, ConfigInfo } from "@/lib/api/types";
|
import type { AnnouncementInfo, ConfigInfo } from "@/lib/api/types";
|
||||||
|
import { OFFICIAL_TG_URL, SITE_DOMAIN } from "@/lib/seo/metadata";
|
||||||
|
|
||||||
/** 对齐 FOYA latestAddrPop(1041/1038):倒计时结束后才允许关闭,默认 3 秒 */
|
/** 对齐 FOYA latestAddrPop(1041/1038):倒计时结束后才允许关闭,默认 3 秒 */
|
||||||
const CLOSE_DELAY_SECONDS = 3;
|
const CLOSE_DELAY_SECONDS = 3;
|
||||||
@@ -17,47 +18,26 @@ export type AddressDialogInfo = {
|
|||||||
permanent: string;
|
permanent: string;
|
||||||
latest: string;
|
latest: string;
|
||||||
telegram: string;
|
telegram: string;
|
||||||
email: string;
|
|
||||||
mirrors: string[];
|
mirrors: string[];
|
||||||
publishPage: string;
|
publishPage: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 从 home/base 的 announcement / config 组装地址弹窗文案(不改字段名映射,只做展示拼装) */
|
/**
|
||||||
|
* 组装地址弹窗文案:地址固定本站域名、联系方式固定官方 TG,不取接口字段
|
||||||
|
* (保留参数兼容调用方)。
|
||||||
|
*/
|
||||||
export function buildAddressDialogInfo(
|
export function buildAddressDialogInfo(
|
||||||
announcement?: AnnouncementInfo | null,
|
_announcement?: AnnouncementInfo | null,
|
||||||
config?: ConfigInfo | null,
|
_config?: ConfigInfo | null,
|
||||||
): AddressDialogInfo | null {
|
): AddressDialogInfo | null {
|
||||||
const permanent = (announcement?.foreverUrlAddr || config?.foreverUrlAddr || "").trim();
|
void _announcement;
|
||||||
const latest = (announcement?.newUrlAddr || config?.newUrlAddr || "").trim();
|
void _config;
|
||||||
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;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
permanent: permanent || latest,
|
permanent: SITE_DOMAIN,
|
||||||
latest: latest || permanent,
|
latest: SITE_DOMAIN,
|
||||||
telegram,
|
telegram: OFFICIAL_TG_URL,
|
||||||
email,
|
mirrors: [],
|
||||||
mirrors,
|
publishPage: "/way-home",
|
||||||
publishPage,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,28 +188,17 @@ function AddressCard({
|
|||||||
{info.latest ? <p>最新地址: {info.latest}</p> : null}
|
{info.latest ? <p>最新地址: {info.latest}</p> : null}
|
||||||
{info.telegram ? (
|
{info.telegram ? (
|
||||||
<p>
|
<p>
|
||||||
TG交流群:{" "}
|
官方TG:{" "}
|
||||||
<a
|
<a
|
||||||
href={info.telegram}
|
href={info.telegram}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="text-[#FF2D55] hover:underline lg:font-medium"
|
className="text-[#FF2D55] hover:underline lg:font-medium"
|
||||||
>
|
>
|
||||||
点击加入官方TG群!
|
点击联系官方TG!
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : 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 ? (
|
{info.mirrors.length > 0 ? (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
@@ -301,10 +270,8 @@ function saveAddressImage(info: AddressDialogInfo) {
|
|||||||
...(info.permanent ? [[{ text: `永久地址: ${info.permanent}` }]] : []),
|
...(info.permanent ? [[{ text: `永久地址: ${info.permanent}` }]] : []),
|
||||||
...(info.latest ? [[{ text: `最新地址: ${info.latest}` }]] : []),
|
...(info.latest ? [[{ text: `最新地址: ${info.latest}` }]] : []),
|
||||||
...(info.telegram
|
...(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
|
...(info.publishPage
|
||||||
? [[{ text: "地址发布页: " }, { text: info.publishPage, color: ACCENT }]]
|
? [[{ text: "地址发布页: " }, { text: info.publishPage, color: ACCENT }]]
|
||||||
: []),
|
: []),
|
||||||
@@ -353,7 +320,7 @@ function saveAddressImage(info: AddressDialogInfo) {
|
|||||||
|
|
||||||
ctx.fillStyle = "#FFFFFF";
|
ctx.fillStyle = "#FFFFFF";
|
||||||
ctx.font = '500 20px "PingFang SC", "Microsoft YaHei", sans-serif';
|
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;
|
ctx.font = font;
|
||||||
let y = padding + titleHeight + 18 + lineHeight / 2;
|
let y = padding + titleHeight + 18 + lineHeight / 2;
|
||||||
@@ -368,7 +335,7 @@ function saveAddressImage(info: AddressDialogInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.download = "海角社区地址.png";
|
link.download = "黄果黑料地址.png";
|
||||||
link.href = canvas.toDataURL("image/png");
|
link.href = canvas.toDataURL("image/png");
|
||||||
link.click();
|
link.click();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
@@ -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",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -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 { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { ensureGuestSession } from "@/lib/auth/session";
|
import { ensureGuestSession } from "@/lib/auth/session";
|
||||||
import { tracker } from "@/lib/tracker";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅在挂载后异步拉游客会话,不参与 SSR / 首屏阻塞。
|
* 仅在挂载后异步拉游客会话,不参与 SSR / 首屏阻塞。
|
||||||
@@ -19,8 +18,6 @@ export function GuestAuthBootstrap() {
|
|||||||
void ensureGuestSession()
|
void ensureGuestSession()
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
if (cancelled || !user) return;
|
if (cancelled || !user) return;
|
||||||
// 埋点 uid:SDK 要求非空时长度 ≥ 4
|
|
||||||
tracker.setUid(String(user.userId || ""));
|
|
||||||
if (process.env.NODE_ENV === "development") {
|
if (process.env.NODE_ENV === "development") {
|
||||||
console.info("[guest-auth]", {
|
console.info("[guest-auth]", {
|
||||||
userId: user.userId,
|
userId: user.userId,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useCallback, useEffect, useId, useState, useSyncExternalStore, type FormEvent, type ReactNode } from "react";
|
import { useCallback, useEffect, useId, useState, useSyncExternalStore, type FormEvent, type ReactNode } from "react";
|
||||||
|
|
||||||
import { useMockUser } from "@/components/profile/use-mock-user";
|
import { useMockUser } from "@/components/auth/use-mock-user";
|
||||||
import {
|
import {
|
||||||
ACCOUNT_RULE_HINT,
|
ACCOUNT_RULE_HINT,
|
||||||
CREDENTIAL_MAX_LEN,
|
CREDENTIAL_MAX_LEN,
|
||||||
@@ -156,7 +156,7 @@ export function LoginDialogHost() {
|
|||||||
onSubmit={submit}
|
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"
|
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 ? (
|
{isLogin ? (
|
||||||
<div className="flex gap-4 self-stretch lg:hidden" role="tablist">
|
<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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ import { DecryptedImage } from "@/components/common/decrypted-image";
|
|||||||
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
|
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
|
||||||
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
||||||
|
|
||||||
import { adHref, adTrackProps, pickBannerAds } from "./pick";
|
import { adHref, pickBannerAds } from "./pick";
|
||||||
|
|
||||||
type AdBannersProps = {
|
type AdBannersProps = {
|
||||||
variant?: "pc" | "h5";
|
variant?: "pc" | "h5";
|
||||||
@@ -39,11 +39,6 @@ export function AdBanners({
|
|||||||
target={external ? "_blank" : undefined}
|
target={external ? "_blank" : undefined}
|
||||||
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
|
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
|
||||||
className="block h-10 overflow-hidden rounded-xl"
|
className="block h-10 overflow-hidden rounded-xl"
|
||||||
{...adTrackProps(ad, {
|
|
||||||
slotKey: `content_banner_${index + 1}`,
|
|
||||||
slotName: `内容横幅第${index + 1}位`,
|
|
||||||
adType: "banner",
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
<DecryptedImage
|
<DecryptedImage
|
||||||
src={ad.images || null}
|
src={ad.images || null}
|
||||||
@@ -74,11 +69,6 @@ export function AdBanners({
|
|||||||
target={external ? "_blank" : undefined}
|
target={external ? "_blank" : undefined}
|
||||||
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
|
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
|
||||||
className="block h-[97px] overflow-hidden rounded-xl"
|
className="block h-[97px] overflow-hidden rounded-xl"
|
||||||
{...adTrackProps(ad, {
|
|
||||||
slotKey: `content_banner_${index + 1}`,
|
|
||||||
slotName: `内容横幅第${index + 1}位`,
|
|
||||||
adType: "banner",
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
<DecryptedImage
|
<DecryptedImage
|
||||||
src={ad.images || null}
|
src={ad.images || null}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { AdIconMarquee } from "@/components/common/ad-icon-marquee";
|
|||||||
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
|
import type { AdvertiseInfo, AdvitiseData } from "@/lib/api/types";
|
||||||
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
||||||
|
|
||||||
import { adContentKey, adHref, adTrackProps, pickIconAds } from "./pick";
|
import { adContentKey, adHref, pickIconAds } from "./pick";
|
||||||
|
|
||||||
type AdIconsProps = {
|
type AdIconsProps = {
|
||||||
variant?: "pc" | "h5";
|
variant?: "pc" | "h5";
|
||||||
@@ -54,11 +54,6 @@ export function AdIcons({
|
|||||||
target={external ? "_blank" : undefined}
|
target={external ? "_blank" : undefined}
|
||||||
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
|
rel={external ? "sponsored nofollow noopener noreferrer" : undefined}
|
||||||
className={iconClass}
|
className={iconClass}
|
||||||
{...adTrackProps(ad, {
|
|
||||||
slotKey: `icon_grid_${index + 1}`,
|
|
||||||
slotName: `九宫格第${index + 1}位`,
|
|
||||||
adType: "icon",
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
<DecryptedImage
|
<DecryptedImage
|
||||||
src={ad.images || null}
|
src={ad.images || null}
|
||||||
|
|||||||
@@ -36,21 +36,3 @@ export function adHref(link?: string, fallback = "#download") {
|
|||||||
export function adContentKey(list: AdvertiseInfo[]) {
|
export function adContentKey(list: AdvertiseInfo[]) {
|
||||||
return list.map((item) => item.id || item.title || item.images || "").join("|") || "mock";
|
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 || ""),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
export {
|
|
||||||
COMMENT_FETCH_TIMEOUT_MS,
|
|
||||||
COMMENT_MAX_LENGTH,
|
|
||||||
COMMENT_PAGE_SIZE,
|
|
||||||
COMMENT_SELF_NAME,
|
|
||||||
COMMENT_SORTS,
|
|
||||||
commentTarget,
|
|
||||||
createSelfComment,
|
|
||||||
filterCommentList,
|
|
||||||
formatCommentCount,
|
|
||||||
formatCommentTime,
|
|
||||||
playletChapterCommentTarget,
|
|
||||||
playletCommentTarget,
|
|
||||||
sortToOrder,
|
|
||||||
videoCommentTarget,
|
|
||||||
type CommentSort,
|
|
||||||
type CommentTarget,
|
|
||||||
} from "./data";
|
|
||||||
export { CommentPanel } from "./comment-panel";
|
|
||||||
export { CommentReplyPreview } from "./comment-reply-preview";
|
|
||||||
export { H5CommentSheet } from "./h5-comment-sheet";
|
|
||||||
export { H5CommentsTab } from "./h5-comments-tab";
|
|
||||||
export { HeartIcon } from "./heart-icon";
|
|
||||||
export { useComments, type UseCommentsOptions, type UseCommentsResult } from "./use-comments";
|
|
||||||
export type { CommentInfo } from "@/lib/api/types";
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useEffect, useRef, useState, type FormEvent } from "react";
|
|
||||||
|
|
||||||
import { COMMENT_MAX_LENGTH } from "./data";
|
|
||||||
|
|
||||||
/** 挂在单条评论下方的回复输入框 */
|
|
||||||
export function InlineReplyBox({
|
|
||||||
userName,
|
|
||||||
posting,
|
|
||||||
error,
|
|
||||||
onSubmit,
|
|
||||||
onCancel,
|
|
||||||
compact = false,
|
|
||||||
}: {
|
|
||||||
userName: string;
|
|
||||||
posting: boolean;
|
|
||||||
error?: string | null;
|
|
||||||
onSubmit: (content: string) => Promise<boolean>;
|
|
||||||
onCancel: () => void;
|
|
||||||
compact?: boolean;
|
|
||||||
}) {
|
|
||||||
const [text, setText] = useState("");
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
inputRef.current?.focus();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
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
|
|
||||||
data-component="inline-reply-box"
|
|
||||||
className={`flex flex-col gap-2 ${
|
|
||||||
compact
|
|
||||||
? "mt-1 rounded-md bg-white/[0.06] p-2.5 outline outline-1 -outline-offset-1 outline-white/15"
|
|
||||||
: "mt-2 rounded-xl bg-[#211F38] p-3 outline outline-1 -outline-offset-1 outline-[#4A4668]"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={`flex items-center justify-between leading-[18px] ${
|
|
||||||
compact ? "text-[11px] text-white/55" : "text-xs text-[#948CA8]"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<span>
|
|
||||||
回复 <span className="font-medium text-[#F12B9E]">@{userName}</span>
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={onCancel}
|
|
||||||
className="cursor-pointer text-white/50 transition-colors hover:text-white"
|
|
||||||
>
|
|
||||||
取消
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<form onSubmit={submit} className="flex items-center gap-2">
|
|
||||||
<label
|
|
||||||
className={`flex min-w-0 flex-1 items-center gap-2 transition-[outline-color] ${
|
|
||||||
compact
|
|
||||||
? "h-10 rounded-[3px] bg-[#0F0F0F] px-3 outline outline-1 -outline-offset-1 outline-white/20 focus-within:outline-[#F12B9E]"
|
|
||||||
: "h-11 rounded-lg bg-[#110F1F] px-3 outline outline-1 -outline-offset-1 outline-[#5A5678] focus-within:outline-[#F12B9E]"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
ref={inputRef}
|
|
||||||
value={text}
|
|
||||||
maxLength={COMMENT_MAX_LENGTH}
|
|
||||||
disabled={posting}
|
|
||||||
onChange={(event) => setText(event.target.value)}
|
|
||||||
placeholder={`回复 @${userName}…`}
|
|
||||||
aria-label={`回复 ${userName}`}
|
|
||||||
className={`min-w-0 flex-1 bg-transparent text-white outline-none placeholder:text-white/40 disabled:opacity-60 ${
|
|
||||||
compact ? "text-sm leading-5" : "text-sm leading-5"
|
|
||||||
}`}
|
|
||||||
/>
|
|
||||||
<span className="shrink-0 text-[10px] leading-4 text-white/30">
|
|
||||||
{text.length}/{COMMENT_MAX_LENGTH}
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
disabled={!text.trim() || posting}
|
|
||||||
className={`cursor-pointer shrink-0 font-medium text-white transition-colors enabled:hover:bg-[#F23DA8] disabled:opacity-45 ${
|
|
||||||
compact
|
|
||||||
? "h-10 rounded-[3px] bg-[#F12B9E] px-3.5 text-xs"
|
|
||||||
: "h-11 rounded-lg bg-[#F12B9E] px-4 text-sm"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{posting ? "发送中" : "发送"}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{error ? <p className="text-xs leading-[18px] text-[#FF8FA8]">{error}</p> : null}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,315 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
|
||||||
import { toast } from "@heroui/react";
|
|
||||||
|
|
||||||
import { openLoginDialog } from "@/components/auth/login-dialog";
|
|
||||||
import { getCommentList, sendComment, setCommentLike } from "@/lib/api/comment";
|
|
||||||
import type { CommentInfo } from "@/lib/api/types";
|
|
||||||
import { handleUnauthorized } from "@/lib/auth/handle-unauthorized";
|
|
||||||
import { ensureGuestSession, getAuthToken } from "@/lib/auth/session";
|
|
||||||
|
|
||||||
import {
|
|
||||||
COMMENT_FETCH_TIMEOUT_MS,
|
|
||||||
COMMENT_PAGE_SIZE,
|
|
||||||
filterCommentList,
|
|
||||||
sortToOrder,
|
|
||||||
type CommentSort,
|
|
||||||
type CommentTarget,
|
|
||||||
} from "./data";
|
|
||||||
|
|
||||||
export type UseCommentsOptions = {
|
|
||||||
target: CommentTarget | null;
|
|
||||||
initialSort?: CommentSort;
|
|
||||||
pageSize?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type UseCommentsResult = {
|
|
||||||
sort: CommentSort;
|
|
||||||
setSort: (sort: CommentSort) => void;
|
|
||||||
comments: CommentInfo[];
|
|
||||||
total: number;
|
|
||||||
hasMore: boolean;
|
|
||||||
loading: boolean;
|
|
||||||
loadingMore: boolean;
|
|
||||||
posting: boolean;
|
|
||||||
error: string | null;
|
|
||||||
postError: string | null;
|
|
||||||
loadMore: () => void;
|
|
||||||
toggleLike: (comment: CommentInfo) => Promise<void>;
|
|
||||||
post: (text: string, options?: { parentsId?: number }) => Promise<boolean>;
|
|
||||||
reload: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
function formatCommentError(err: unknown, fallback = "评论加载失败") {
|
|
||||||
if (err instanceof DOMException && err.name === "TimeoutError") return "加载超时,请重试";
|
|
||||||
if (err instanceof Error) {
|
|
||||||
if (/aborted|timeout|超时/i.test(err.message) || err.name === "AbortError") return "加载超时,请重试";
|
|
||||||
return err.message || fallback;
|
|
||||||
}
|
|
||||||
return fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
function abortAfter(ms: number) {
|
|
||||||
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {
|
|
||||||
return AbortSignal.timeout(ms);
|
|
||||||
}
|
|
||||||
const controller = new AbortController();
|
|
||||||
setTimeout(() => controller.abort(), ms);
|
|
||||||
return controller.signal;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mergeSignals(a: AbortSignal, b: AbortSignal) {
|
|
||||||
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.any === "function") {
|
|
||||||
return AbortSignal.any([a, b]);
|
|
||||||
}
|
|
||||||
const controller = new AbortController();
|
|
||||||
const onAbort = () => controller.abort();
|
|
||||||
if (a.aborted || b.aborted) {
|
|
||||||
controller.abort();
|
|
||||||
return controller.signal;
|
|
||||||
}
|
|
||||||
a.addEventListener("abort", onAbort, { once: true });
|
|
||||||
b.addEventListener("abort", onAbort, { once: true });
|
|
||||||
return controller.signal;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resolveAuthToken() {
|
|
||||||
let token = getAuthToken();
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
await ensureGuestSession();
|
|
||||||
} catch {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
token = getAuthToken();
|
|
||||||
}
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
function patchComment(list: CommentInfo[], id: number, patch: Partial<CommentInfo>): CommentInfo[] {
|
|
||||||
return list.map((item) => (Number(item.id) === id ? { ...item, ...patch } : item));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useComments({
|
|
||||||
target,
|
|
||||||
initialSort = "热门",
|
|
||||||
pageSize = COMMENT_PAGE_SIZE,
|
|
||||||
}: UseCommentsOptions): UseCommentsResult {
|
|
||||||
const [sort, setSort] = useState<CommentSort>(initialSort);
|
|
||||||
const [comments, setComments] = useState<CommentInfo[]>([]);
|
|
||||||
const [total, setTotal] = useState(0);
|
|
||||||
const [pageNum, setPageNum] = useState(1);
|
|
||||||
const [loading, setLoading] = useState(Boolean(target));
|
|
||||||
const [loadingMore, setLoadingMore] = useState(false);
|
|
||||||
const [posting, setPosting] = useState(false);
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
const [postError, setPostError] = useState<string | null>(null);
|
|
||||||
const [reloadKey, setReloadKey] = useState(0);
|
|
||||||
const fetchSeq = useRef(0);
|
|
||||||
const likingIds = useRef(new Set<number>());
|
|
||||||
|
|
||||||
const objectId = target?.objectId ?? 0;
|
|
||||||
const objectType = target?.objectType;
|
|
||||||
const enabled = Boolean(target && objectId > 0 && objectType != null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const controller = new AbortController();
|
|
||||||
let cancelled = false;
|
|
||||||
|
|
||||||
void (async () => {
|
|
||||||
await Promise.resolve();
|
|
||||||
if (cancelled) return;
|
|
||||||
|
|
||||||
if (!enabled || objectType == null) {
|
|
||||||
setComments([]);
|
|
||||||
setTotal(0);
|
|
||||||
setLoading(false);
|
|
||||||
setError(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const seq = ++fetchSeq.current;
|
|
||||||
setLoading(true);
|
|
||||||
setError(null);
|
|
||||||
setPageNum(1);
|
|
||||||
likingIds.current.clear();
|
|
||||||
|
|
||||||
try {
|
|
||||||
const data = await getCommentList(
|
|
||||||
{
|
|
||||||
objectId,
|
|
||||||
objectType,
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize,
|
|
||||||
sortOrder: sortToOrder(sort),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: getAuthToken(),
|
|
||||||
signal: mergeSignals(controller.signal, abortAfter(COMMENT_FETCH_TIMEOUT_MS)),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (cancelled || seq !== fetchSeq.current) return;
|
|
||||||
setComments(filterCommentList(data?.list));
|
|
||||||
setTotal(Number(data?.totalCount) || 0);
|
|
||||||
setPageNum(1);
|
|
||||||
} catch (err: unknown) {
|
|
||||||
if (cancelled || seq !== fetchSeq.current || controller.signal.aborted) return;
|
|
||||||
setComments([]);
|
|
||||||
setTotal(0);
|
|
||||||
setError(formatCommentError(err));
|
|
||||||
} finally {
|
|
||||||
if (!cancelled && seq === fetchSeq.current) setLoading(false);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancelled = true;
|
|
||||||
controller.abort();
|
|
||||||
};
|
|
||||||
}, [enabled, objectId, objectType, sort, pageSize, reloadKey]);
|
|
||||||
|
|
||||||
const hasMore = comments.length < total;
|
|
||||||
|
|
||||||
const loadMore = useCallback(() => {
|
|
||||||
if (!enabled || objectType == null || loading || loadingMore || !hasMore) return;
|
|
||||||
|
|
||||||
const nextPage = pageNum + 1;
|
|
||||||
const controller = new AbortController();
|
|
||||||
setLoadingMore(true);
|
|
||||||
|
|
||||||
void getCommentList(
|
|
||||||
{
|
|
||||||
objectId,
|
|
||||||
objectType,
|
|
||||||
pageNum: nextPage,
|
|
||||||
pageSize,
|
|
||||||
sortOrder: sortToOrder(sort),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: getAuthToken(),
|
|
||||||
signal: mergeSignals(controller.signal, abortAfter(COMMENT_FETCH_TIMEOUT_MS)),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.then((data) => {
|
|
||||||
const mapped = filterCommentList(data?.list);
|
|
||||||
setComments((current) => {
|
|
||||||
const seen = new Set(current.map((item) => Number(item.id)));
|
|
||||||
return [...current, ...mapped.filter((item) => !seen.has(Number(item.id)))];
|
|
||||||
});
|
|
||||||
setTotal(Number(data?.totalCount) || total);
|
|
||||||
setPageNum(nextPage);
|
|
||||||
})
|
|
||||||
.catch((err: unknown) => {
|
|
||||||
if (controller.signal.aborted) return;
|
|
||||||
setError(formatCommentError(err, "加载更多失败"));
|
|
||||||
})
|
|
||||||
.finally(() => setLoadingMore(false));
|
|
||||||
}, [enabled, objectId, objectType, loading, loadingMore, hasMore, pageNum, pageSize, sort, total]);
|
|
||||||
|
|
||||||
const toggleLike = useCallback(async (comment: CommentInfo) => {
|
|
||||||
const commentId = Number(comment.id);
|
|
||||||
if (!Number.isInteger(commentId) || commentId < 1) return;
|
|
||||||
if (likingIds.current.has(commentId)) return;
|
|
||||||
|
|
||||||
const token = await resolveAuthToken();
|
|
||||||
if (!token) {
|
|
||||||
openLoginDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextIsLike = !Boolean(comment.isLike);
|
|
||||||
const nextCountLike = Math.max(0, (Number(comment.countLike) || 0) + (nextIsLike ? 1 : -1));
|
|
||||||
const snapshot = { isLike: comment.isLike, countLike: comment.countLike };
|
|
||||||
|
|
||||||
likingIds.current.add(commentId);
|
|
||||||
setComments((current) => patchComment(current, commentId, { isLike: nextIsLike, countLike: nextCountLike }));
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await setCommentLike(
|
|
||||||
{ commentId, isLike: nextIsLike },
|
|
||||||
token,
|
|
||||||
abortAfter(COMMENT_FETCH_TIMEOUT_MS),
|
|
||||||
);
|
|
||||||
setComments((current) =>
|
|
||||||
patchComment(current, commentId, {
|
|
||||||
isLike: result?.isLike ?? nextIsLike,
|
|
||||||
countLike: typeof result?.countLike === "number" ? result.countLike : nextCountLike,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} catch (err: unknown) {
|
|
||||||
setComments((current) => patchComment(current, commentId, snapshot));
|
|
||||||
handleUnauthorized(err);
|
|
||||||
} finally {
|
|
||||||
likingIds.current.delete(commentId);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const post = useCallback(
|
|
||||||
async (text: string, options?: { parentsId?: number }) => {
|
|
||||||
const trimmed = text.trim();
|
|
||||||
if (!trimmed || posting) return false;
|
|
||||||
if (!enabled || objectType == null) {
|
|
||||||
setPostError("无法发布评论");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPostError(null);
|
|
||||||
const token = await resolveAuthToken();
|
|
||||||
if (!token) {
|
|
||||||
openLoginDialog();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPosting(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await sendComment(
|
|
||||||
{
|
|
||||||
objectId,
|
|
||||||
objectType,
|
|
||||||
text: trimmed,
|
|
||||||
parentsId: options?.parentsId ?? 0,
|
|
||||||
},
|
|
||||||
token,
|
|
||||||
abortAfter(COMMENT_FETCH_TIMEOUT_MS),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 审核通过前不写入列表(对齐 1045)
|
|
||||||
toast.success("发布成功,评论审核后才会展示");
|
|
||||||
return true;
|
|
||||||
} catch (err: unknown) {
|
|
||||||
if (handleUnauthorized(err)) {
|
|
||||||
setPostError("登录已过期或没有权限,请重新登录");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const message = formatCommentError(err, "发表失败,请稍后重试");
|
|
||||||
setPostError(message);
|
|
||||||
toast.danger(message);
|
|
||||||
return false;
|
|
||||||
} finally {
|
|
||||||
setPosting(false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[enabled, objectId, objectType, posting],
|
|
||||||
);
|
|
||||||
|
|
||||||
const reload = useCallback(() => setReloadKey((value) => value + 1), []);
|
|
||||||
|
|
||||||
return {
|
|
||||||
sort,
|
|
||||||
setSort,
|
|
||||||
comments,
|
|
||||||
total,
|
|
||||||
hasMore,
|
|
||||||
loading,
|
|
||||||
loadingMore,
|
|
||||||
posting,
|
|
||||||
error,
|
|
||||||
postError,
|
|
||||||
loadMore,
|
|
||||||
toggleLike,
|
|
||||||
post,
|
|
||||||
reload,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import type { BadgeTone } from "@/components/home/data";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 黄果黑料卡片 / 详情页公用视觉:琥珀色强调(区别于其它导航站的品红主题)。
|
||||||
|
* 卡片不做整块底色,封面 + 正文排版;hover 只给封面描边、标题变色。
|
||||||
|
*/
|
||||||
|
export const HL_ACCENT = "#FFB020";
|
||||||
|
|
||||||
|
export const HL_COVER =
|
||||||
|
"relative block overflow-hidden rounded-md bg-[#17161D] outline outline-1 -outline-offset-1 outline-white/5 transition-[outline-color] duration-300 group-hover:outline-[#FFB020]/80";
|
||||||
|
|
||||||
|
export const HL_COVER_IMG =
|
||||||
|
"absolute inset-0 h-full w-full object-cover transition-transform duration-500 ease-out group-hover:scale-[1.04]";
|
||||||
|
|
||||||
|
export const HL_TITLE_LINK = "transition-colors duration-200 hover:text-[#FFB020] group-hover:text-[#FFB020]";
|
||||||
|
|
||||||
|
const badgeText: Record<BadgeTone, string> = {
|
||||||
|
hot: "热播",
|
||||||
|
fresh: "新上架",
|
||||||
|
original: "独家",
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 封面左上角琥珀角标(文字,不用图片角标) */
|
||||||
|
export function HlBadge({ tone, small = false }: { tone?: BadgeTone | null; small?: boolean }) {
|
||||||
|
if (!tone) return null;
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`absolute top-0 left-0 z-[1] rounded-br-md bg-[#FFB020] font-semibold text-[#1A1206] ${
|
||||||
|
small ? "px-1.5 py-0.5 text-[10px] leading-[14px]" : "px-2 py-0.5 text-xs leading-[18px]"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{badgeText[tone]}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 接口时间 → YYYY-MM-DD;无效返回空串。优先直接截取,避免服务端 / 浏览器时区不同导致水合不一致 */
|
||||||
|
export function formatDay(raw?: string | null) {
|
||||||
|
const text = raw?.trim();
|
||||||
|
if (!text) return "";
|
||||||
|
const head = /^\d{4}-\d{2}-\d{2}/.exec(text);
|
||||||
|
if (head) return head[0];
|
||||||
|
const date = new Date(/^\d+$/.test(text) ? Number(text) : text);
|
||||||
|
if (Number.isNaN(date.getTime())) return "";
|
||||||
|
const pad = (value: number) => String(value).padStart(2, "0");
|
||||||
|
return `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 秒 → m:ss / h:mm:ss;无效返回空串 */
|
||||||
|
export function formatDuration(seconds?: number | null) {
|
||||||
|
const total = Math.floor(Number(seconds) || 0);
|
||||||
|
if (total <= 0) return "";
|
||||||
|
const h = Math.floor(total / 3600);
|
||||||
|
const m = Math.floor((total % 3600) / 60);
|
||||||
|
const s = total % 60;
|
||||||
|
const pad = (value: number) => String(value).padStart(2, "0");
|
||||||
|
return h ? `${h}:${pad(m)}:${pad(s)}` : `${m}:${pad(s)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 卡片元信息里的小眼睛图标 */
|
||||||
|
export function EyeIcon({ className = "size-3.5" }: { className?: string }) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true">
|
||||||
|
<path
|
||||||
|
d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="1.3"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
|
<circle cx="8" cy="8" r="2" stroke="currentColor" strokeWidth="1.3" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -165,11 +165,11 @@ function DownloadPanel({ onClose }: { onClose: () => void }) {
|
|||||||
<section
|
<section
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-label="下载海角社区 App"
|
aria-label="下载黄果黑料 App"
|
||||||
className="flex w-80 flex-col items-center gap-[18px] rounded-[18px] bg-[#121118] p-6 text-center shadow-[0_14px_32px_rgba(0,0,0,0.45)]"
|
className="flex w-80 flex-col items-center gap-[18px] rounded-[18px] bg-[#121118] p-6 text-center shadow-[0_14px_32px_rgba(0,0,0,0.45)]"
|
||||||
>
|
>
|
||||||
<img src="/logo.svg" alt="海角社区" className="h-[65px] w-auto" />
|
<img src="/logo.svg" alt="黄果黑料" className="h-[65px] w-auto" />
|
||||||
<p className="text-sm leading-5 text-[#BEB9CB]">扫码下载「海角社区 App」</p>
|
<p className="text-sm leading-5 text-[#BEB9CB]">扫码下载「黄果黑料 App」</p>
|
||||||
<p className="text-xs leading-[18px] text-[#8E889C]">海量短剧,随时畅看</p>
|
<p className="text-xs leading-[18px] text-[#8E889C]">海量短剧,随时畅看</p>
|
||||||
{link ? <QrBox link={link} className="size-[180px] rounded-[10px] p-2" /> : null}
|
{link ? <QrBox link={link} className="size-[180px] rounded-[10px] p-2" /> : null}
|
||||||
<button
|
<button
|
||||||
@@ -181,7 +181,7 @@ function DownloadPanel({ onClose }: { onClose: () => void }) {
|
|||||||
{copied ? "下载链接已复制" : link || "暂无下载地址"}
|
{copied ? "下载链接已复制" : link || "暂无下载地址"}
|
||||||
</button>
|
</button>
|
||||||
<p className="bg-[linear-gradient(54deg,#FF5693_0%,#B421D5_58%,#76DFF2_100%)] bg-clip-text text-lg leading-[25px] font-bold tracking-[0.2em] text-transparent">
|
<p className="bg-[linear-gradient(54deg,#FF5693_0%,#B421D5_58%,#76DFF2_100%)] bg-clip-text text-lg leading-[25px] font-bold tracking-[0.2em] text-transparent">
|
||||||
海角社区
|
黄果黑料
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
<CloseCircle onClick={onClose} />
|
<CloseCircle onClick={onClose} />
|
||||||
@@ -194,10 +194,10 @@ function DownloadPanel({ onClose }: { onClose: () => void }) {
|
|||||||
className="relative my-auto hidden h-[500px] w-[760px] flex-col overflow-hidden rounded-3xl bg-[linear-gradient(90deg,#2B1233_0%,#101F41_100%)] shadow-[0_24px_50px_rgba(0,0,0,0.55)] outline outline-1 -outline-offset-1 outline-white/14 lg:flex"
|
className="relative my-auto hidden h-[500px] w-[760px] flex-col overflow-hidden rounded-3xl bg-[linear-gradient(90deg,#2B1233_0%,#101F41_100%)] shadow-[0_24px_50px_rgba(0,0,0,0.55)] outline outline-1 -outline-offset-1 outline-white/14 lg:flex"
|
||||||
>
|
>
|
||||||
<header className="flex h-[92px] shrink-0 items-start gap-[17px] border-b border-white/12 px-7 pt-[22px]">
|
<header className="flex h-[92px] shrink-0 items-start gap-[17px] border-b border-white/12 px-7 pt-[22px]">
|
||||||
<img src="/logo.svg" alt="海角社区" className="h-[58px] w-32" />
|
<img src="/logo.svg" alt="黄果黑料" className="h-[58px] w-32" />
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<h2 id="download-dialog-title" className="text-2xl leading-[30px] font-semibold text-white">
|
<h2 id="download-dialog-title" className="text-2xl leading-[30px] font-semibold text-white">
|
||||||
下载海角社区 App
|
下载黄果黑料 App
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-sm leading-5 text-[#A49DB4]">扫码安装,继续追剧不丢进度</p>
|
<p className="text-sm leading-5 text-[#A49DB4]">扫码安装,继续追剧不丢进度</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ export function getEpisodeState(episode: number, detail: DramaDetail): EpisodeSt
|
|||||||
/** 猜你喜欢侧栏展示条数(详情 / 播放) */
|
/** 猜你喜欢侧栏展示条数(详情 / 播放) */
|
||||||
export const RELATED_DISPLAY_COUNT = 8;
|
export const RELATED_DISPLAY_COUNT = 8;
|
||||||
|
|
||||||
/** 更多好剧推荐条数(三列网格 3×3) */
|
/** 同类短剧推荐条数(PC 6 列 × 2 行) */
|
||||||
export const RECOMMEND_DISPLAY_COUNT = 9;
|
export const RECOMMEND_DISPLAY_COUNT = 12;
|
||||||
|
|
||||||
/** 猜你喜欢:过滤广告后保留接口原字段 */
|
/** 猜你喜欢:过滤广告后保留接口原字段 */
|
||||||
export function mapPlayletGuessList(data: PlayletGuessListResp | null | undefined): RelatedDrama[] {
|
export function mapPlayletGuessList(data: PlayletGuessListResp | null | undefined): RelatedDrama[] {
|
||||||
@@ -198,15 +198,6 @@ export function mapPlayletInfo(data: QueryPlayletInfoResp | null | undefined): D
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getEpisodeRanges(total: number, size: number): EpisodeRange[] {
|
|
||||||
const count = Math.max(1, Math.floor(total / size));
|
|
||||||
return Array.from({ length: count }, (_, index) => {
|
|
||||||
const start = index * size + 1;
|
|
||||||
const end = index === count - 1 ? total : start + size - 1;
|
|
||||||
return { label: `${start}–${end}`, start, end };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getEpisodeChunks(total: number, size: number): EpisodeRange[] {
|
export function getEpisodeChunks(total: number, size: number): EpisodeRange[] {
|
||||||
return Array.from({ length: Math.ceil(total / size) }, (_, index) => {
|
return Array.from({ length: Math.ceil(total / size) }, (_, index) => {
|
||||||
const start = index * size + 1;
|
const start = index * size + 1;
|
||||||
|
|||||||
@@ -1,36 +1,41 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { toast } from "@heroui/react";
|
import { toast } from "@heroui/react";
|
||||||
import Link from "next/link";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useEffect, useState, type ReactNode } from "react";
|
import { useEffect, useState, type ReactNode } from "react";
|
||||||
|
|
||||||
import { openLoginDialog } from "@/components/auth/login-dialog";
|
import { openLoginDialog } from "@/components/auth/login-dialog";
|
||||||
import { AdBanners, AdIcons } from "@/components/common/ads";
|
import { AdBanners, AdIcons } from "@/components/common/ads";
|
||||||
import { BackButton } from "@/components/common/back-button";
|
import { BackButton } from "@/components/common/back-button";
|
||||||
import { cardTagCanLink, pickPlayletCardTags } from "@/components/common/card-tags";
|
import { pickPlayletCardTags } from "@/components/common/card-tags";
|
||||||
import { DecryptedImage } from "@/components/common/decrypted-image";
|
import { DecryptedImage } from "@/components/common/decrypted-image";
|
||||||
import { openDownloadDialog } from "@/components/download/download-dialog";
|
import { openDownloadDialog } from "@/components/download/download-dialog";
|
||||||
import { FloatingActions } from "@/components/home/floating-actions";
|
import { FloatingActions } from "@/components/home/floating-actions";
|
||||||
import { tagPageHref } from "@/components/tag/href";
|
import { EpisodeDirectory } from "@/components/media-page/episode-directory";
|
||||||
|
import {
|
||||||
|
DramaRecommend,
|
||||||
|
HlAction,
|
||||||
|
HlPrimaryLink,
|
||||||
|
InfoList,
|
||||||
|
SectionTitle,
|
||||||
|
TagLinks,
|
||||||
|
tagLinkItems,
|
||||||
|
} from "@/components/media-page/parts";
|
||||||
|
import { PageBreadcrumb } from "@/components/seo/page-breadcrumb";
|
||||||
|
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
|
||||||
import { favoritePlaylet, getPlayletInfo, likePlaylet } from "@/lib/api/playlet-actions";
|
import { favoritePlaylet, getPlayletInfo, likePlaylet } from "@/lib/api/playlet-actions";
|
||||||
import { handleUnauthorized } from "@/lib/auth/handle-unauthorized";
|
import { handleUnauthorized } from "@/lib/auth/handle-unauthorized";
|
||||||
import { ensureGuestSession, getAuthToken } from "@/lib/auth/session";
|
import { ensureGuestSession, getAuthToken } from "@/lib/auth/session";
|
||||||
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
||||||
|
|
||||||
import { CommentPanel, playletCommentTarget } from "@/components/common/comments";
|
|
||||||
import { PageBreadcrumb } from "@/components/seo/page-breadcrumb";
|
|
||||||
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
|
|
||||||
import {
|
import {
|
||||||
formatPlays,
|
formatPlays,
|
||||||
playHref,
|
playHref,
|
||||||
totalEpisodeOf,
|
totalEpisodeOf,
|
||||||
|
updateStatusLabel,
|
||||||
yearFromOnlineAt,
|
yearFromOnlineAt,
|
||||||
type DramaDetail,
|
type DramaDetail,
|
||||||
type RelatedDrama,
|
type RelatedDrama,
|
||||||
} from "./data";
|
} from "./data";
|
||||||
import { EpisodePanel, H5EpisodeStrip, H5MorePlaylets } from "./episodes";
|
|
||||||
import { RelatedAside } from "./related-aside";
|
|
||||||
|
|
||||||
async function ensurePlayletAuthToken() {
|
async function ensurePlayletAuthToken() {
|
||||||
let token = getAuthToken();
|
let token = getAuthToken();
|
||||||
@@ -50,49 +55,12 @@ function resolvePlayletLikeFavorite(data: Awaited<ReturnType<typeof getPlayletIn
|
|||||||
return {
|
return {
|
||||||
isLike: Boolean(data?.isLike ?? info?.isLike),
|
isLike: Boolean(data?.isLike ?? info?.isLike),
|
||||||
isFavorite: Boolean(data?.isFavorite ?? info?.isFavorite),
|
isFavorite: Boolean(data?.isFavorite ?? info?.isFavorite),
|
||||||
displayCountLike: Number(info?.displayCountLike) || 0,
|
|
||||||
countCollect: Number(info?.countCollect) || 0,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActionProps = {
|
|
||||||
icon: string;
|
|
||||||
label: string;
|
|
||||||
active?: boolean;
|
|
||||||
onClick?: () => void;
|
|
||||||
href?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
function DetailAction({ icon, label, active = false, onClick, href }: ActionProps) {
|
|
||||||
const className = `flex items-center gap-2.5 text-base leading-[22px] transition-opacity hover:opacity-85 ${
|
|
||||||
active ? "text-[#F12B9E]" : "text-white/90"
|
|
||||||
}`;
|
|
||||||
const content: ReactNode = (
|
|
||||||
<>
|
|
||||||
<span
|
|
||||||
className={`flex size-9 items-center justify-center rounded-full ${active ? "bg-[#F12B9E]" : "bg-[#F12B9E]/10"}`}
|
|
||||||
>
|
|
||||||
<img src={icon} alt="" className="max-h-[21px] max-w-[22px]" />
|
|
||||||
</span>
|
|
||||||
{label}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
return href ? (
|
|
||||||
<Link href={href} className={className}>
|
|
||||||
{content}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<button type="button" aria-pressed={active} onClick={onClick} className={`cursor-pointer ${className}`}>
|
|
||||||
{content}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function DramaDetailPage({
|
export function DramaDetailPage({
|
||||||
detail,
|
detail,
|
||||||
related = [],
|
related = [],
|
||||||
relatedAside,
|
|
||||||
promo,
|
promo,
|
||||||
adIcons,
|
adIcons,
|
||||||
adGrid,
|
adGrid,
|
||||||
@@ -100,8 +68,6 @@ export function DramaDetailPage({
|
|||||||
}: {
|
}: {
|
||||||
detail: DramaDetail;
|
detail: DramaDetail;
|
||||||
related?: RelatedDrama[];
|
related?: RelatedDrama[];
|
||||||
/** 服务端渲染的热门推荐侧栏 */
|
|
||||||
relatedAside?: ReactNode;
|
|
||||||
/** 服务端渲染的 PC banner */
|
/** 服务端渲染的 PC banner */
|
||||||
promo?: ReactNode;
|
promo?: ReactNode;
|
||||||
/** 服务端渲染的 PC icon */
|
/** 服务端渲染的 PC icon */
|
||||||
@@ -115,10 +81,11 @@ export function DramaDetailPage({
|
|||||||
const [liking, setLiking] = useState(false);
|
const [liking, setLiking] = useState(false);
|
||||||
const [collected, setCollected] = useState(Boolean(detail.isFavorite));
|
const [collected, setCollected] = useState(Boolean(detail.isFavorite));
|
||||||
const [collecting, setCollecting] = useState(false);
|
const [collecting, setCollecting] = useState(false);
|
||||||
const router = useRouter();
|
const tags = tagLinkItems(pickPlayletCardTags(detail), "playlet");
|
||||||
const tags = pickPlayletCardTags(detail);
|
|
||||||
const totalEpisode = totalEpisodeOf(detail);
|
const totalEpisode = totalEpisodeOf(detail);
|
||||||
const playEpisode = (episode: number) => router.push(playHref(detail.id, episode, detail.slug));
|
const firstHref = playHref(detail.id, 1, detail.slug);
|
||||||
|
const title = detail.title || "短剧";
|
||||||
|
const desc = detail.desc?.trim() || "";
|
||||||
|
|
||||||
const likeFavoriteKey = `${detail.id}:${detail.isLike}:${detail.isFavorite}`;
|
const likeFavoriteKey = `${detail.id}:${detail.isLike}:${detail.isFavorite}`;
|
||||||
const [likeFavoriteSync, setLikeFavoriteSync] = useState(likeFavoriteKey);
|
const [likeFavoriteSync, setLikeFavoriteSync] = useState(likeFavoriteKey);
|
||||||
@@ -211,205 +178,135 @@ export function DramaDetailPage({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
const crumbs = [
|
||||||
<main data-component="drama-detail-page" className="relative flex-1 bg-[#0E0E0E] lg:bg-[#060611]">
|
{ name: "首页", href: "/" },
|
||||||
<div className="pointer-events-none absolute inset-x-0 top-0 h-[544px] overflow-hidden lg:hidden" aria-hidden="true">
|
{ name: "短剧库", href: "/short-drama/hot" },
|
||||||
<DecryptedImage src={detail.cover} fallback={IMG_PLACEHOLDER} alt="" priority className="size-full object-cover" />
|
{ name: title },
|
||||||
<div className="absolute inset-0 bg-black/80" />
|
];
|
||||||
<div className="absolute inset-0 bg-[linear-gradient(180deg,rgba(0,0,0,0.1)_0%,rgba(102,102,102,0)_40%,rgba(14,14,14,0.55)_70%,#0E0E0E_100%)]" />
|
|
||||||
</div>
|
|
||||||
<BackButton fallback="/short-drama/hot" className="absolute top-3 left-4 z-10 lg:hidden" />
|
|
||||||
|
|
||||||
|
const infoRows = [
|
||||||
|
{ label: "集数", value: `全 ${totalEpisode} 集` },
|
||||||
|
{ label: "状态", value: updateStatusLabel(detail.updateStatus) },
|
||||||
|
{ label: "上线", value: yearFromOnlineAt(detail.onlineAt) },
|
||||||
|
{ label: "题材", value: detail.themeNames?.slice(0, 3).join(" / ") },
|
||||||
|
{ label: "主演", value: detail.anchor?.trim() },
|
||||||
|
{ label: "热度", value: formatPlays(detail.countBrowse ?? detail.heatValue) },
|
||||||
|
];
|
||||||
|
|
||||||
|
const actions = (compact?: boolean) => (
|
||||||
|
<>
|
||||||
|
<HlAction kind="like" label={liked ? "已点赞" : "点赞"} active={liked} onClick={liking ? undefined : toggleLike} compact={compact} />
|
||||||
|
<HlAction
|
||||||
|
kind="collect"
|
||||||
|
label={collected ? "已收藏" : "收藏"}
|
||||||
|
active={collected}
|
||||||
|
onClick={collecting ? undefined : toggleCollect}
|
||||||
|
compact={compact}
|
||||||
|
/>
|
||||||
|
<HlAction kind="share" label="分享" onClick={share} compact={compact} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main data-component="hl-drama-detail" className="relative flex-1 bg-[#0C0B10]">
|
||||||
|
<SeoBreadcrumb items={crumbs} />
|
||||||
|
|
||||||
|
{/* PC */}
|
||||||
<div
|
<div
|
||||||
data-pc-scale
|
data-pc-scale
|
||||||
className="relative hidden flex-col gap-8 pt-8 pb-12 lg:mx-auto lg:flex lg:w-[1700px] lg:[zoom:var(--page-scale,1)]"
|
className="relative hidden flex-col gap-10 pt-8 pb-14 lg:mx-auto lg:flex lg:w-[1700px] lg:[zoom:var(--page-scale,1)]"
|
||||||
>
|
>
|
||||||
<SeoBreadcrumb
|
<PageBreadcrumb items={crumbs} />
|
||||||
items={[
|
|
||||||
{ name: "首页", href: "/" },
|
|
||||||
{ name: detail.title || "短剧详情" },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<PageBreadcrumb
|
|
||||||
items={[
|
|
||||||
{ name: "首页", href: "/" },
|
|
||||||
{ name: detail.title || "短剧详情" },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<section className="flex h-[544px] gap-10 overflow-hidden rounded-[20px] bg-[rgba(14,13,29,0.92)] p-8 outline outline-1 -outline-offset-1 outline-[rgba(59,56,92,0.1)]">
|
<article className="grid grid-cols-[minmax(0,1fr)_340px] gap-14 border-t-2 border-[#FFB020] pt-10">
|
||||||
<DecryptedImage
|
<div className="flex min-w-0 flex-col gap-6">
|
||||||
src={detail.cover}
|
<p className="text-sm leading-5 tracking-[0.2em] text-[#FFB020]">短剧 · {updateStatusLabel(detail.updateStatus)}</p>
|
||||||
fallback={IMG_PLACEHOLDER}
|
<h1 className="text-[44px] leading-[56px] font-bold text-white">{title}</h1>
|
||||||
alt={detail.title}
|
<InfoList rows={infoRows} />
|
||||||
priority
|
<TagLinks tags={tags} />
|
||||||
className="h-[480px] w-[360px] shrink-0 rounded-xl object-cover"
|
{desc ? (
|
||||||
/>
|
<section className="flex flex-col gap-3">
|
||||||
<div className="flex min-w-0 flex-1 flex-col justify-center gap-[18px]">
|
<SectionTitle>剧情介绍</SectionTitle>
|
||||||
<div className="flex gap-[9px] text-xs leading-[18px]">
|
<p className="max-w-[1100px] text-[15px] leading-7 whitespace-pre-line text-[#B5B3BE]">{desc}</p>
|
||||||
<span className="flex h-[26px] items-center rounded-[13px] bg-[#F12B9E] px-[11px] text-white">全站免费</span>
|
</section>
|
||||||
{tags.map((tag) =>
|
) : null}
|
||||||
cardTagCanLink(tag) ? (
|
<div className="mt-2 flex flex-wrap items-center gap-3">
|
||||||
<Link
|
<HlPrimaryLink href={firstHref}>播放第 1 集</HlPrimaryLink>
|
||||||
key={tag.slug ?? tag.id ?? tag.name}
|
{actions()}
|
||||||
href={tagPageHref(tag, "playlet")}
|
|
||||||
className="flex h-[26px] items-center rounded-[13px] bg-[#171624] px-[11px] text-[#9E96AD] hover:text-white"
|
|
||||||
>
|
|
||||||
{tag.name}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<span
|
|
||||||
key={tag.name}
|
|
||||||
className="flex h-[26px] items-center rounded-[13px] bg-[#171624] px-[11px] text-[#9E96AD]"
|
|
||||||
>
|
|
||||||
{tag.name}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<p className="text-[40px] leading-[47px] text-white">{detail.title}</p>
|
|
||||||
<p className="text-sm whitespace-pre text-[#9E96AD]">
|
|
||||||
{yearFromOnlineAt(detail.onlineAt)} {detail.themeNames?.[0] || "地区未知"} 共 {totalEpisode} 集
|
|
||||||
</p>
|
|
||||||
<p className="line-clamp-6 text-sm leading-[22px] text-[#9E96AD]">简介:{detail.desc}</p>
|
|
||||||
<div className="flex h-[52px] items-center gap-6">
|
|
||||||
<Link
|
|
||||||
href={playHref(detail.id, 1, detail.slug)}
|
|
||||||
className="flex h-[45px] w-36 items-center justify-center rounded-[23px] bg-[#F12B9E] text-base leading-[22px] font-semibold text-white transition-colors hover:bg-[#F23DA8]"
|
|
||||||
>
|
|
||||||
立即播放
|
|
||||||
</Link>
|
|
||||||
<div className="flex w-[490px] items-center justify-between">
|
|
||||||
<DetailAction
|
|
||||||
icon="/images/icon_like.svg"
|
|
||||||
label={liked ? "已点赞" : "点赞"}
|
|
||||||
active={liked}
|
|
||||||
onClick={liking ? undefined : toggleLike}
|
|
||||||
/>
|
|
||||||
<span className="h-[19px] w-0.5 bg-white/10" />
|
|
||||||
<DetailAction
|
|
||||||
icon="/images/icon_collect.svg"
|
|
||||||
label={collected ? "已收藏" : "收藏"}
|
|
||||||
active={collected}
|
|
||||||
onClick={collecting ? undefined : toggleCollect}
|
|
||||||
/>
|
|
||||||
<span className="h-[19px] w-0.5 bg-white/10" />
|
|
||||||
<DetailAction icon="/images/icon_share.svg" label="分享" onClick={share} />
|
|
||||||
<span className="h-[19px] w-0.5 bg-white/10" />
|
|
||||||
<DetailAction icon="/images/icon_feedback.svg" label="反馈" href="/feedback" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex h-[88px] shrink-0 items-center justify-between rounded-xl bg-[linear-gradient(90deg,#301438_0%,#171A40_100%)] px-5">
|
|
||||||
<div className="flex flex-col">
|
|
||||||
<p className="text-sm leading-5 text-white">App 内继续看,不丢进度</p>
|
|
||||||
<p className="text-xs leading-[18px] text-[#9E96AD]">同步观看记录、收藏、金币余额和更新提醒。</p>
|
|
||||||
</div>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => openDownloadDialog()}
|
onClick={() => openDownloadDialog()}
|
||||||
className="cursor-pointer h-[38px] w-[111px] rounded-[19px] bg-[linear-gradient(90deg,#F22BA1_0%,#4A59FF_100%)] text-base leading-[22px] text-white transition-opacity hover:opacity-90"
|
className="ml-2 cursor-pointer text-sm text-[#8E8C99] underline-offset-4 hover:text-[#FFB020] hover:underline"
|
||||||
>
|
>
|
||||||
下载
|
下载 APP 离线观看
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
<figure className="flex flex-col gap-3">
|
||||||
|
<DecryptedImage
|
||||||
|
src={detail.cover}
|
||||||
|
fallback={IMG_PLACEHOLDER}
|
||||||
|
alt={`${title}海报`}
|
||||||
|
priority
|
||||||
|
className="aspect-[2/3] w-full rounded-md object-cover"
|
||||||
|
/>
|
||||||
|
<figcaption className="text-center text-xs leading-[18px] text-[#6F6C7B]">《{title}》海报</figcaption>
|
||||||
|
</figure>
|
||||||
|
</article>
|
||||||
|
|
||||||
{adIcons ?? <AdIcons variant="pc" />}
|
{adIcons ?? <AdIcons variant="pc" />}
|
||||||
|
|
||||||
<EpisodePanel detail={detail} current={1} onSelect={playEpisode} />
|
<EpisodeDirectory detail={detail} variant="panel" />
|
||||||
|
|
||||||
<div className="flex items-start gap-6">
|
<DramaRecommend items={related} />
|
||||||
<CommentPanel target={playletCommentTarget(detail.id)} />
|
|
||||||
{relatedAside ?? <RelatedAside items={related} />}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{promo ?? <AdBanners variant="pc" />}
|
{promo ?? <AdBanners variant="pc" />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="relative flex flex-col gap-[18px] px-4 pt-[60px] pb-8 lg:hidden">
|
{/* H5 */}
|
||||||
<section className="flex items-center gap-3">
|
<div className="relative flex flex-col gap-6 px-4 pt-3 pb-10 lg:hidden">
|
||||||
<DecryptedImage
|
<div className="flex h-9 items-center">
|
||||||
src={detail.cover}
|
<BackButton fallback="/short-drama/hot" />
|
||||||
fallback={IMG_PLACEHOLDER}
|
</div>
|
||||||
alt={detail.title}
|
<article className="flex flex-col gap-4">
|
||||||
className="h-[106px] w-[76px] shrink-0 rounded-md object-cover"
|
<div className="flex gap-4">
|
||||||
/>
|
<div className="flex min-w-0 flex-1 flex-col gap-2.5">
|
||||||
<div className="flex min-w-0 flex-1 flex-col gap-3">
|
<p className="text-[11px] leading-4 tracking-[0.15em] text-[#FFB020]">短剧 · {updateStatusLabel(detail.updateStatus)}</p>
|
||||||
<h1 className="line-clamp-2 text-base leading-[22px] font-medium text-white">{detail.title}</h1>
|
<h1 className="line-clamp-3 text-xl leading-7 font-bold text-white">{title}</h1>
|
||||||
<p className="flex flex-wrap items-start gap-1.5 text-xs leading-[18px] text-white/35">
|
<InfoList rows={infoRows.slice(0, 4)} compact />
|
||||||
<span>全{totalEpisode}集</span>
|
|
||||||
<span aria-hidden="true">·</span>
|
|
||||||
<span>{formatPlays(detail.countBrowse ?? detail.heatValue)}</span>
|
|
||||||
</p>
|
|
||||||
<div className="flex flex-wrap items-center gap-1.5 text-xs leading-[18px] text-white/90">
|
|
||||||
{tags.slice(0, 3).map((tag) =>
|
|
||||||
cardTagCanLink(tag) ? (
|
|
||||||
<Link
|
|
||||||
key={tag.slug ?? tag.id ?? tag.name}
|
|
||||||
href={tagPageHref(tag, "playlet")}
|
|
||||||
className="rounded-[3px] bg-white/10 px-1.5 py-0.5"
|
|
||||||
>
|
|
||||||
#{tag.name}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<span key={tag.name} className="rounded-[3px] bg-white/10 px-1.5 py-0.5">
|
|
||||||
#{tag.name}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
{detail.anchor ? (
|
|
||||||
<span className="rounded-[3px] bg-white/10 px-1.5 py-0.5">演员·{detail.anchor}</span>
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
|
<DecryptedImage
|
||||||
|
src={detail.cover}
|
||||||
|
fallback={IMG_PLACEHOLDER}
|
||||||
|
alt={`${title}海报`}
|
||||||
|
priority
|
||||||
|
className="aspect-[2/3] w-[104px] shrink-0 self-start rounded-md object-cover"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
<TagLinks tags={tags} compact />
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
{detail.desc?.trim() ? (
|
<HlPrimaryLink href={firstHref} compact className="w-full">
|
||||||
<section className="flex w-full flex-col gap-3">
|
播放第 1 集
|
||||||
<h2 className="text-base leading-[22px] font-medium text-white">简介</h2>
|
</HlPrimaryLink>
|
||||||
<p className="text-xs leading-[18px] text-white/65">{detail.desc.trim()}</p>
|
<div className="grid grid-cols-3 gap-2">{actions(true)}</div>
|
||||||
</section>
|
</div>
|
||||||
) : null}
|
{desc ? (
|
||||||
|
<section className="flex flex-col gap-2">
|
||||||
|
<SectionTitle compact>剧情介绍</SectionTitle>
|
||||||
|
<p className="text-[13px] leading-[22px] whitespace-pre-line text-[#A9A7B3]">{desc}</p>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
|
</article>
|
||||||
|
|
||||||
{adGrid ?? <AdIcons variant="h5" />}
|
{adGrid ?? <AdIcons variant="h5" />}
|
||||||
|
|
||||||
<H5EpisodeStrip detail={detail} onSelect={playEpisode} />
|
<EpisodeDirectory detail={detail} variant="h5" />
|
||||||
|
|
||||||
<H5MorePlaylets items={related} />
|
<DramaRecommend items={related} compact />
|
||||||
|
|
||||||
{bannerAds ?? <AdBanners variant="h5" />}
|
{bannerAds ?? <AdBanners variant="h5" />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
|
||||||
data-component="h5-bottom-bar"
|
|
||||||
data-h5-bottom-bar
|
|
||||||
className="fixed inset-x-0 bottom-0 z-40 flex h-[68px] items-center justify-center gap-3 bg-[#010101] px-4 pb-[env(safe-area-inset-bottom)] lg:hidden"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-pressed={collected}
|
|
||||||
disabled={collecting}
|
|
||||||
onClick={toggleCollect}
|
|
||||||
className={`cursor-pointer flex h-11 w-[108px] items-center justify-center gap-3 rounded-full bg-white text-base leading-[22px] font-medium disabled:opacity-70 ${
|
|
||||||
collected ? "text-[#F12B9E]" : "text-[#3D3D3D]"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className={`size-[18px] [mask:url(/images/icon_collect.svg)_center/contain_no-repeat] ${
|
|
||||||
collected ? "bg-[#F12B9E]" : "bg-[#A3A3B8]"
|
|
||||||
}`}
|
|
||||||
/>
|
|
||||||
{collected ? "已收藏" : "收藏"}
|
|
||||||
</button>
|
|
||||||
<Link
|
|
||||||
href={playHref(detail.id, 1, detail.slug)}
|
|
||||||
className="flex h-11 w-[223px] items-center justify-center rounded-full bg-[#F12B9E] text-base leading-[22px] font-medium text-white"
|
|
||||||
>
|
|
||||||
开始播放
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="max-lg:hidden">
|
<div className="max-lg:hidden">
|
||||||
<FloatingActions />
|
<FloatingActions />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,306 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import Link from "next/link";
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
import { DecryptedImage } from "@/components/common/decrypted-image";
|
|
||||||
import { CornerFlagBadge, resolveContentBadge } from "@/components/home/section-heading";
|
|
||||||
import { dramaHref } from "@/components/short-drama/data";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getEpisodeChunks,
|
|
||||||
getEpisodeRanges,
|
|
||||||
getEpisodeState,
|
|
||||||
totalEpisodeOf,
|
|
||||||
updateStatusLabel,
|
|
||||||
type DramaDetail,
|
|
||||||
type RelatedDrama,
|
|
||||||
} from "./data";
|
|
||||||
|
|
||||||
type EpisodeProps = {
|
|
||||||
detail: DramaDetail;
|
|
||||||
current: number;
|
|
||||||
onSelect: (episode: number) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
function LockIcon({ className = "" }: { className?: string }) {
|
|
||||||
return (
|
|
||||||
<svg viewBox="0 0 18 18" fill="none" className={className} aria-hidden="true">
|
|
||||||
<rect x="3.75" y="7.5" width="10.5" height="8.25" rx="1.5" stroke="currentColor" strokeWidth="1.5" />
|
|
||||||
<path d="M6 7.5V5.25a3 3 0 0 1 6 0V7.5" stroke="currentColor" strokeWidth="1.5" />
|
|
||||||
<path d="M9 10.5v2.25" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 免费/未解锁均进播放页;未解锁由播放页在播放器上盖下载遮罩 */
|
|
||||||
function useEpisodeClick(_detail: DramaDetail, onSelect: (episode: number) => void) {
|
|
||||||
return (episode: number) => onSelect(episode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 与播放页「更多好剧」一致的三列推荐卡片 */
|
|
||||||
export function MorePlayletsGrid({ items }: { items: RelatedDrama[] }) {
|
|
||||||
if (!items.length) {
|
|
||||||
return <p className="py-8 text-center text-xs text-white/35">暂无更多推荐</p>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-3 gap-x-[5px] gap-y-3">
|
|
||||||
{items.map((item) => {
|
|
||||||
const badge = resolveContentBadge(item);
|
|
||||||
return (
|
|
||||||
<Link key={item.id} href={dramaHref(item.id, item.slug)} className="flex flex-col gap-1">
|
|
||||||
<div className="relative aspect-[3/4] w-full overflow-hidden rounded-md bg-[#525252]">
|
|
||||||
<DecryptedImage src={item.cover} alt="" className="size-full object-cover" />
|
|
||||||
<CornerFlagBadge
|
|
||||||
tone={badge}
|
|
||||||
className="absolute top-2 right-2 z-[1]"
|
|
||||||
badgeClassName="h-[18px]"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<span className="truncate text-sm leading-5 text-white">{item.title}</span>
|
|
||||||
<span className="truncate text-xs leading-[18px] text-white/50">
|
|
||||||
{item.tagNames?.[0]}
|
|
||||||
{item.tagNames?.[0] && item.totalEpisode ? " · " : ""}
|
|
||||||
{item.totalEpisode ? `${item.totalEpisode}集` : ""}
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function EpisodePanel({ detail, current, onSelect }: EpisodeProps) {
|
|
||||||
const totalEpisode = totalEpisodeOf(detail);
|
|
||||||
const ranges = getEpisodeRanges(totalEpisode, 20);
|
|
||||||
const [rangeIndex, setRangeIndex] = useState(-1);
|
|
||||||
const range = ranges[rangeIndex];
|
|
||||||
const start = range?.start ?? 1;
|
|
||||||
const end = range?.end ?? totalEpisode;
|
|
||||||
const handleClick = useEpisodeClick(detail, onSelect);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section
|
|
||||||
data-component="episode-panel"
|
|
||||||
data-episodes
|
|
||||||
className="flex flex-col gap-4 rounded-2xl bg-[rgba(20,23,46,0.9)] p-6 outline outline-1 -outline-offset-1 outline-[#333354]"
|
|
||||||
>
|
|
||||||
<div className="flex h-10 items-center gap-6">
|
|
||||||
<h2 className="text-[22px] leading-[30px] text-white">选集</h2>
|
|
||||||
<p className="flex-1 text-sm text-[#8C879C]">共 {totalEpisode} 集</p>
|
|
||||||
<div className="flex items-center gap-8 text-sm">
|
|
||||||
{[{ label: "全部", index: -1 }, ...ranges.map((item, index) => ({ label: item.label, index }))].map(
|
|
||||||
(item) => (
|
|
||||||
<button
|
|
||||||
key={item.label}
|
|
||||||
type="button"
|
|
||||||
aria-pressed={rangeIndex === item.index}
|
|
||||||
onClick={() => setRangeIndex(item.index)}
|
|
||||||
className={`cursor-pointer ${rangeIndex === item.index ? "text-[#F12B9E]" : "text-[#8C879C] hover:text-white"}`}
|
|
||||||
>
|
|
||||||
{item.label}
|
|
||||||
</button>
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="grid grid-cols-[repeat(10,154px)] justify-between gap-y-3">
|
|
||||||
{Array.from({ length: end - start + 1 }, (_, index) => start + index).map((episode) => {
|
|
||||||
const locked = getEpisodeState(episode, detail) === "locked";
|
|
||||||
const playing = episode === current;
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={episode}
|
|
||||||
type="button"
|
|
||||||
aria-current={playing || undefined}
|
|
||||||
aria-label={`第${episode}集${locked ? "(未解锁)" : ""}`}
|
|
||||||
onClick={() => handleClick(episode)}
|
|
||||||
className={`cursor-pointer relative flex h-[58px] items-center justify-center gap-0.5 overflow-hidden rounded-lg text-lg leading-6 font-semibold transition-colors ${
|
|
||||||
playing
|
|
||||||
? "bg-[rgba(241,43,158,0.1)] text-[#F12B9E] outline outline-1 -outline-offset-1 outline-[#F12B9E]"
|
|
||||||
: locked
|
|
||||||
? "bg-white/10 text-[#828186] outline outline-1 -outline-offset-1 outline-white/5 hover:bg-white/15"
|
|
||||||
: "bg-[#3A3D53] text-white hover:bg-[#454866]"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
第{episode}集
|
|
||||||
{locked ? <LockIcon className="size-[18px]" /> : null}
|
|
||||||
{!locked ? (
|
|
||||||
<span className="absolute top-1 right-1 flex h-5 w-9 items-center justify-center rounded bg-[linear-gradient(136deg,#74FFED_0%,#10B9A2_100%)] text-[10px] font-normal leading-4 text-[#002D27]">
|
|
||||||
免费
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function H5EpisodeStrip({ detail, onSelect, current }: Omit<EpisodeProps, "current"> & { current?: number }) {
|
|
||||||
const totalEpisode = totalEpisodeOf(detail);
|
|
||||||
const ranges = getEpisodeChunks(totalEpisode, 30);
|
|
||||||
const [rangeIndex, setRangeIndex] = useState(0);
|
|
||||||
const { start, end } = ranges[rangeIndex] ?? ranges[0];
|
|
||||||
const handleClick = useEpisodeClick(detail, onSelect);
|
|
||||||
const hasPreview = Boolean(detail.preview?.trim());
|
|
||||||
const previewChapter = detail.chapterList?.find(
|
|
||||||
(item) => item.title?.trim() === "预告" || Number(item.currentEpisode) === 0,
|
|
||||||
);
|
|
||||||
const showPreview = hasPreview || Boolean(previewChapter);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section data-component="h5-episode-strip" data-episodes className="inline-flex w-full flex-col items-start gap-3">
|
|
||||||
<div className="inline-flex w-full items-center justify-between">
|
|
||||||
<h2 className="text-sm leading-5 font-medium text-white/90">剧集</h2>
|
|
||||||
<div className="flex items-center gap-4">
|
|
||||||
<span className="flex items-center gap-0.5 text-xs leading-[18px] text-[#656565]">
|
|
||||||
{updateStatusLabel(detail.updateStatus)} 共{totalEpisode}集
|
|
||||||
<img src="/images/arrow_rught.svg" alt="" className="size-[18px] opacity-50" />
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="inline-flex w-full items-center gap-6 overflow-x-auto text-sm leading-5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
|
||||||
{ranges.map((item, index) => (
|
|
||||||
<button
|
|
||||||
key={item.label}
|
|
||||||
type="button"
|
|
||||||
aria-pressed={rangeIndex === index}
|
|
||||||
onClick={() => setRangeIndex(index)}
|
|
||||||
className={`cursor-pointer shrink-0 ${rangeIndex === index ? "text-white" : "text-white/35"}`}
|
|
||||||
>
|
|
||||||
{item.start}-{item.end}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
<Link href="/short-drama/hot" className="shrink-0 text-white/35">
|
|
||||||
更多好剧
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="inline-flex w-full items-center gap-1.5 overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
|
||||||
{showPreview && rangeIndex === 0 ? (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-label="预告"
|
|
||||||
onClick={() => {
|
|
||||||
if (previewChapter && Number(previewChapter.currentEpisode) > 0) {
|
|
||||||
handleClick(Number(previewChapter.currentEpisode));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleClick(1);
|
|
||||||
}}
|
|
||||||
className="relative size-[58px] shrink-0 cursor-pointer overflow-hidden rounded-md bg-[rgba(246,103,38,0.1)]"
|
|
||||||
>
|
|
||||||
<span className="absolute top-[21px] inset-x-0 flex items-end justify-center text-center text-base leading-[22px] font-medium text-[#F12B9E]">
|
|
||||||
预告
|
|
||||||
</span>
|
|
||||||
<img src="/images/playing.svg" alt="" className="absolute top-0 left-[38px] size-5" />
|
|
||||||
</button>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{Array.from({ length: end - start + 1 }, (_, index) => start + index).map((episode) => {
|
|
||||||
const locked = getEpisodeState(episode, detail) === "locked";
|
|
||||||
const playing = current != null && episode === current;
|
|
||||||
|
|
||||||
if (playing) {
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={episode}
|
|
||||||
type="button"
|
|
||||||
aria-current="true"
|
|
||||||
aria-label={`第${episode}集`}
|
|
||||||
onClick={() => handleClick(episode)}
|
|
||||||
className="relative size-[58px] shrink-0 cursor-pointer overflow-hidden rounded-md bg-[rgba(246,103,38,0.1)]"
|
|
||||||
>
|
|
||||||
<span className="absolute top-[21px] inset-x-0 flex items-end justify-center text-center text-base leading-[22px] font-medium text-[#F12B9E]">
|
|
||||||
{episode}
|
|
||||||
</span>
|
|
||||||
<img src="/images/playing.svg" alt="" className="absolute top-0 left-[38px] size-5" />
|
|
||||||
{!locked ? (
|
|
||||||
<img
|
|
||||||
src="/images/tag_mf.png"
|
|
||||||
alt="免费"
|
|
||||||
className="pointer-events-none absolute top-0 right-0 h-[14px] w-[25px]"
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locked) {
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={episode}
|
|
||||||
type="button"
|
|
||||||
aria-label={`第${episode}集(未解锁)`}
|
|
||||||
onClick={() => handleClick(episode)}
|
|
||||||
className="relative size-[58px] shrink-0 cursor-pointer overflow-hidden rounded-md bg-white/5 outline outline-1 -outline-offset-1 outline-[#222222]"
|
|
||||||
>
|
|
||||||
<span className="absolute top-[21px] left-2.5 inline-flex w-10 items-center justify-center text-base leading-[22px] font-medium text-[#828186]">
|
|
||||||
<span className="min-w-0 flex-1 text-center">{episode}</span>
|
|
||||||
<LockIcon className="size-[18px] shrink-0" />
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={episode}
|
|
||||||
type="button"
|
|
||||||
aria-label={`第${episode}集`}
|
|
||||||
onClick={() => handleClick(episode)}
|
|
||||||
className="relative size-[58px] shrink-0 cursor-pointer overflow-hidden rounded-md bg-white/5"
|
|
||||||
>
|
|
||||||
<span className="absolute top-[21px] inset-x-0 flex items-end justify-center text-center text-base leading-[22px] font-medium text-white">
|
|
||||||
{episode}
|
|
||||||
</span>
|
|
||||||
<img
|
|
||||||
src="/images/tag_mf.png"
|
|
||||||
alt="免费"
|
|
||||||
className="pointer-events-none absolute top-0 right-0 h-[14px] w-[25px]"
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** H5 详情:热门推荐 — 一行横向滚动 */
|
|
||||||
export function H5MorePlaylets({ items }: { items: RelatedDrama[] }) {
|
|
||||||
if (!items.length) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section id="more-playlets" data-component="h5-more-playlets" className="flex scroll-mt-4 flex-col gap-3">
|
|
||||||
<h2 className="text-sm leading-5 font-medium text-white/90">热门推荐</h2>
|
|
||||||
<div className="-mx-4 flex gap-[9px] overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
|
||||||
{items.map((item) => {
|
|
||||||
const badge = resolveContentBadge(item);
|
|
||||||
return (
|
|
||||||
<Link key={item.id} href={dramaHref(item.id, item.slug)} className="flex w-[98px] shrink-0 flex-col gap-1">
|
|
||||||
<div className="relative aspect-[3/4] w-full overflow-hidden rounded-md bg-[#525252]">
|
|
||||||
<DecryptedImage src={item.cover} alt="" className="size-full object-cover" />
|
|
||||||
<CornerFlagBadge
|
|
||||||
tone={badge}
|
|
||||||
className="absolute top-2 right-2 z-[1]"
|
|
||||||
badgeClassName="h-[18px]"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<span className="truncate text-xs leading-[18px] font-medium text-white">{item.title}</span>
|
|
||||||
<span className="truncate text-xs leading-[18px] text-white/65">
|
|
||||||
{item.tagNames?.[0]}
|
|
||||||
{item.tagNames?.[0] && item.totalEpisode ? " · " : ""}
|
|
||||||
{item.totalEpisode ? `${item.totalEpisode}集` : ""}
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import Link from "next/link";
|
|
||||||
|
|
||||||
import { DecryptedImage } from "@/components/common/decrypted-image";
|
|
||||||
import { formatHeat } from "@/components/ranking/data";
|
|
||||||
import { dramaHref } from "@/components/short-drama/data";
|
|
||||||
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
|
||||||
|
|
||||||
import type { RelatedDrama } from "./data";
|
|
||||||
|
|
||||||
export function RelatedAside({ items }: { items: RelatedDrama[] }) {
|
|
||||||
if (!items.length) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<aside data-component="drama-related-aside" className="flex min-w-0 flex-1 flex-col gap-4 rounded-2xl bg-[rgba(24,23,46,0.88)] p-6 outline outline-1 -outline-offset-1 outline-[#383657]">
|
|
||||||
<div className="flex h-9 items-center justify-between">
|
|
||||||
<h2 className="text-[22px] font-bold text-white">热门推荐</h2>
|
|
||||||
<Link href="/short-drama/hot" className="flex items-center gap-1 text-xs leading-[18px] text-[#B8B2C2] hover:text-white">
|
|
||||||
更多
|
|
||||||
<img src="/images/more_arrow.svg" alt="" className="size-3.5" />
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
{items.map((item) => (
|
|
||||||
<Link
|
|
||||||
key={item.id}
|
|
||||||
href={dramaHref(String(item.id), item.slug)}
|
|
||||||
className="group flex h-24 items-center gap-4"
|
|
||||||
>
|
|
||||||
<DecryptedImage
|
|
||||||
src={item.cover}
|
|
||||||
fallback={IMG_PLACEHOLDER}
|
|
||||||
alt=""
|
|
||||||
className="h-24 w-[72px] shrink-0 rounded-lg object-cover"
|
|
||||||
/>
|
|
||||||
<div className="flex min-w-0 flex-1 flex-col gap-2">
|
|
||||||
<h3 className="truncate text-base leading-[23px] text-[#F5F0FA] group-hover:text-[#F12B9E]">
|
|
||||||
{item.title}
|
|
||||||
</h3>
|
|
||||||
<p className="truncate text-sm leading-[21px] text-[#8C859C]">{item.desc}</p>
|
|
||||||
<div className="flex items-center justify-between text-xs leading-[18px]">
|
|
||||||
<span className="text-[#A89EB5]">{item.tagNames?.[0]}</span>
|
|
||||||
<span className="text-[#ABA1B8]">{formatHeat(item.heatValue ?? item.countBrowse)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</aside>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -2,36 +2,31 @@
|
|||||||
|
|
||||||
import { toast } from "@heroui/react";
|
import { toast } from "@heroui/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
import { useEffect, useState, type ReactNode } from "react";
|
||||||
|
|
||||||
import { useDramaContext } from "@/components/analytics/use-playback-analytics";
|
|
||||||
import { openLoginDialog } from "@/components/auth/login-dialog";
|
import { openLoginDialog } from "@/components/auth/login-dialog";
|
||||||
import { AdBanners, AdIcons } from "@/components/common/ads";
|
import { AdBanners, AdIcons } from "@/components/common/ads";
|
||||||
import { DecryptedImage } from "@/components/common/decrypted-image";
|
import { pickPlayletCardTags } from "@/components/common/card-tags";
|
||||||
import {
|
|
||||||
CommentPanel,
|
|
||||||
playletCommentTarget,
|
|
||||||
type CommentTarget,
|
|
||||||
} from "@/components/common/comments";
|
|
||||||
import {
|
import {
|
||||||
dramaDetailHref,
|
dramaDetailHref,
|
||||||
getEpisodeState,
|
getEpisodeState,
|
||||||
|
playHref,
|
||||||
|
totalEpisodeOf,
|
||||||
|
updateStatusLabel,
|
||||||
type DramaDetail,
|
type DramaDetail,
|
||||||
type RelatedDrama,
|
type RelatedDrama,
|
||||||
} from "@/components/drama-detail/data";
|
} from "@/components/drama-detail/data";
|
||||||
import { RelatedAside } from "@/components/drama-detail/related-aside";
|
|
||||||
import { FloatingActions } from "@/components/home/floating-actions";
|
import { FloatingActions } from "@/components/home/floating-actions";
|
||||||
|
import { EpisodeDirectory } from "@/components/media-page/episode-directory";
|
||||||
|
import { DramaRecommend, HlAction, TagLinks, tagLinkItems } from "@/components/media-page/parts";
|
||||||
import { PageBreadcrumb } from "@/components/seo/page-breadcrumb";
|
import { PageBreadcrumb } from "@/components/seo/page-breadcrumb";
|
||||||
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
|
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
|
||||||
import { favoritePlaylet, getPlayletInfo, likePlaylet } from "@/lib/api/playlet-actions";
|
import { favoritePlaylet, getPlayletInfo, likePlaylet } from "@/lib/api/playlet-actions";
|
||||||
import { handleUnauthorized } from "@/lib/auth/handle-unauthorized";
|
import { handleUnauthorized } from "@/lib/auth/handle-unauthorized";
|
||||||
import { ensureGuestSession, getAuthToken } from "@/lib/auth/session";
|
import { ensureGuestSession, getAuthToken } from "@/lib/auth/session";
|
||||||
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
|
||||||
|
|
||||||
import { H5Play } from "./h5-play";
|
import { H5Play } from "./h5-play";
|
||||||
import { PcPlayer } from "./pc-player";
|
import { PcPlayer } from "./pc-player";
|
||||||
import { PlayEpisodePanel } from "./play-episode-panel";
|
|
||||||
import { useReportPlayletHistory } from "./use-report-playlet-history";
|
|
||||||
|
|
||||||
const pcFrame = "mx-auto w-[1700px] [zoom:var(--page-scale,1)]";
|
const pcFrame = "mx-auto w-[1700px] [zoom:var(--page-scale,1)]";
|
||||||
const pcScaleProps = { "data-pc-scale": true as const };
|
const pcScaleProps = { "data-pc-scale": true as const };
|
||||||
@@ -67,46 +62,11 @@ function initialCountCollect(detail: DramaDetail) {
|
|||||||
return Number(detail.countCollect) || 0;
|
return Number(detail.countCollect) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
type PillProps = {
|
|
||||||
icon: string;
|
|
||||||
label: string;
|
|
||||||
active?: boolean;
|
|
||||||
onClick?: () => void;
|
|
||||||
href?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function ActionPill({ icon, label, active = false, onClick, href }: PillProps) {
|
|
||||||
const className = `inline-flex h-[52px] w-auto shrink-0 items-center justify-center gap-2.5 rounded-[26px] bg-[rgba(31,23,31,0.55)] px-4 text-base leading-[22px] whitespace-nowrap outline outline-1 -outline-offset-1 outline-[rgba(255,227,196,0.28)] transition-colors hover:bg-[rgba(31,23,31,0.85)] ${
|
|
||||||
active ? "text-[#F12B9E]" : "text-white/90"
|
|
||||||
}`;
|
|
||||||
const content = (
|
|
||||||
<>
|
|
||||||
<span
|
|
||||||
className={`flex size-9 shrink-0 items-center justify-center rounded-full ${active ? "bg-[#F12B9E]" : "bg-[#F12B9E]/10"}`}
|
|
||||||
>
|
|
||||||
<img src={icon} alt="" className="max-h-[21px] max-w-[22px]" />
|
|
||||||
</span>
|
|
||||||
{label}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
return href ? (
|
|
||||||
<Link href={href} className={className}>
|
|
||||||
{content}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<button type="button" aria-pressed={active} onClick={onClick} className={`cursor-pointer ${className}`}>
|
|
||||||
{content}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function DramaPlayPage({
|
export function DramaPlayPage({
|
||||||
detail,
|
detail,
|
||||||
episode,
|
episode,
|
||||||
src,
|
src,
|
||||||
related = [],
|
related = [],
|
||||||
relatedAside,
|
|
||||||
adIcons,
|
adIcons,
|
||||||
promo,
|
promo,
|
||||||
}: {
|
}: {
|
||||||
@@ -114,7 +74,6 @@ export function DramaPlayPage({
|
|||||||
episode: number;
|
episode: number;
|
||||||
src: string;
|
src: string;
|
||||||
related?: RelatedDrama[];
|
related?: RelatedDrama[];
|
||||||
relatedAside?: ReactNode;
|
|
||||||
adIcons?: ReactNode;
|
adIcons?: ReactNode;
|
||||||
promo?: ReactNode;
|
promo?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
@@ -127,24 +86,11 @@ export function DramaPlayPage({
|
|||||||
const [expanded, setExpanded] = useState(false);
|
const [expanded, setExpanded] = useState(false);
|
||||||
const locked = getEpisodeState(episode, detail) === "locked" || !src;
|
const locked = getEpisodeState(episode, detail) === "locked" || !src;
|
||||||
const playSrc = locked ? "" : src;
|
const playSrc = locked ? "" : src;
|
||||||
const episodeLabel = String(episode).padStart(2, "0");
|
const title = detail.title || "短剧";
|
||||||
const chapter = detail.chapterList?.find((item) => Number(item.currentEpisode) === episode);
|
const totalEpisode = totalEpisodeOf(detail);
|
||||||
const tagName = detail.tagNames?.[0] || detail.themeNames?.[0] || "";
|
const prevHref = episode > 1 ? playHref(detail.id, episode - 1, detail.slug) : null;
|
||||||
const dramaTrackContext = useMemo(
|
const nextHref = episode < totalEpisode ? playHref(detail.id, episode + 1, detail.slug) : null;
|
||||||
() => ({
|
const tags = tagLinkItems(pickPlayletCardTags(detail), "playlet");
|
||||||
media_id: String(detail.id || ""),
|
|
||||||
drama_id: String(detail.id || ""),
|
|
||||||
drama_title: detail.title || "未命名短剧",
|
|
||||||
episode: Math.max(1, episode),
|
|
||||||
video_id: String(chapter?.id || detail.id || ""),
|
|
||||||
drama_duration: Math.max(0, Math.round(Number(chapter?.mediaTime) || 0)),
|
|
||||||
recommend_trace_id: "",
|
|
||||||
drama_tag_key: tagName ? "tag" : "default",
|
|
||||||
drama_tag_name: tagName || "默认标签",
|
|
||||||
}),
|
|
||||||
[detail.id, detail.title, episode, chapter?.id, chapter?.mediaTime, tagName],
|
|
||||||
);
|
|
||||||
useDramaContext(dramaTrackContext);
|
|
||||||
|
|
||||||
const likeFavoriteKey = `${detail.id}:${detail.isLike}:${detail.isFavorite}:${detail.countCollect}:${detail.displayCountLike}`;
|
const likeFavoriteKey = `${detail.id}:${detail.isLike}:${detail.isFavorite}:${detail.countCollect}:${detail.displayCountLike}`;
|
||||||
const [likeFavoriteSync, setLikeFavoriteSync] = useState(likeFavoriteKey);
|
const [likeFavoriteSync, setLikeFavoriteSync] = useState(likeFavoriteKey);
|
||||||
@@ -268,107 +214,89 @@ export function DramaPlayPage({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const chapterId = detail.chapterList?.find((item) => Number(item.currentEpisode) === episode)?.id;
|
const crumbs = [
|
||||||
/** 与短剧详情共用短剧维度评论,不按单集拆分 */
|
{ name: "首页", href: "/" },
|
||||||
const commentTarget: CommentTarget | null = playletCommentTarget(detail.id);
|
{ name: "短剧库", href: "/short-drama/hot" },
|
||||||
const reportWatchHistory = useReportPlayletHistory(Number(detail.id), Number(chapterId) || undefined);
|
{ name: title, href: dramaDetailHref(detail) },
|
||||||
|
{ name: `第${episode}集` },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main data-component="drama-play-page" className="relative flex-1 bg-[#0B0709]">
|
<main data-component="hl-drama-play" className="relative flex-1 bg-[#0C0B10]">
|
||||||
{!expanded ? (
|
<SeoBreadcrumb items={crumbs} />
|
||||||
<div
|
|
||||||
aria-hidden="true"
|
|
||||||
className="pointer-events-none absolute inset-x-0 top-0 hidden h-[1200px] overflow-hidden [mask-image:linear-gradient(180deg,#000_70%,transparent_100%)] lg:block"
|
|
||||||
>
|
|
||||||
<DecryptedImage
|
|
||||||
src={detail.cover}
|
|
||||||
fallback={IMG_PLACEHOLDER}
|
|
||||||
alt=""
|
|
||||||
className="size-full scale-110 object-cover opacity-70 blur-[12px]"
|
|
||||||
/>
|
|
||||||
<div className="absolute inset-0 bg-[linear-gradient(180deg,rgba(9,5,9,0.32)_0%,rgba(9,5,9,0.56)_55%,rgba(6,5,9,0.94)_100%)]" />
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
{...(expanded ? {} : pcScaleProps)}
|
{...(expanded ? {} : pcScaleProps)}
|
||||||
className={`relative hidden flex-col gap-6 pb-8 lg:flex ${expanded ? "" : `pt-6 ${pcFrame}`}`}
|
className={`relative hidden flex-col gap-8 pb-14 lg:flex ${expanded ? "" : `pt-6 ${pcFrame}`}`}
|
||||||
>
|
>
|
||||||
{!expanded ? (
|
{!expanded ? <PageBreadcrumb items={crumbs} /> : null}
|
||||||
<>
|
|
||||||
<SeoBreadcrumb
|
|
||||||
items={[
|
|
||||||
{ name: "首页", href: "/" },
|
|
||||||
{ name: detail.title || "短剧", href: dramaDetailHref(detail) },
|
|
||||||
{ name: `第${episode}集` },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<PageBreadcrumb
|
|
||||||
items={[
|
|
||||||
{ name: "首页", href: "/" },
|
|
||||||
{ name: detail.title || "短剧", href: dramaDetailHref(detail) },
|
|
||||||
{ name: `第${episode}集` },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<div className={expanded ? "contents" : "flex flex-col gap-4"}>
|
<div className={expanded ? "contents" : "flex flex-col gap-8"}>
|
||||||
<div className={expanded ? "contents" : "flex h-[648px] gap-5"}>
|
<div className={expanded ? "contents" : "flex h-[648px] gap-5"}>
|
||||||
<PcPlayer
|
<PcPlayer
|
||||||
key={`${episode}-${playSrc}`}
|
key={`${episode}-${playSrc}`}
|
||||||
src={playSrc}
|
src={playSrc}
|
||||||
poster={detail.cover || ""}
|
poster={detail.cover || ""}
|
||||||
title={`${detail.title || ""} 第${episode}集`}
|
title={`${title} 第${episode}集`}
|
||||||
locked={locked}
|
locked={locked}
|
||||||
episode={episode}
|
episode={episode}
|
||||||
dramaId={detail.slug?.trim() || String(detail.id)}
|
dramaId={detail.slug?.trim() || String(detail.id)}
|
||||||
dramaTitle={detail.title || ""}
|
dramaTitle={title}
|
||||||
layout={expanded ? "theater" : "inline"}
|
layout={expanded ? "theater" : "inline"}
|
||||||
onToggleExpand={toggleExpanded}
|
onToggleExpand={toggleExpanded}
|
||||||
onPlaySuccess={reportWatchHistory}
|
|
||||||
/>
|
/>
|
||||||
{!expanded ? <PlayEpisodePanel detail={detail} current={episode} /> : null}
|
{!expanded ? <EpisodeDirectory detail={detail} current={episode} variant="side" /> : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
{...(expanded ? pcScaleProps : {})}
|
{...(expanded ? pcScaleProps : {})}
|
||||||
className={expanded ? `flex flex-col gap-4 ${pcFrame}` : "contents"}
|
className={expanded ? `flex flex-col gap-8 ${pcFrame}` : "contents"}
|
||||||
>
|
>
|
||||||
{expanded ? <PlayEpisodePanel detail={detail} current={episode} wide /> : null}
|
<article className="grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-10 gap-y-5 border-t-2 border-[#FFB020] pt-8">
|
||||||
|
<div className="flex min-w-0 flex-col gap-3">
|
||||||
{adIcons ?? <AdIcons variant="pc" />}
|
<p className="text-sm leading-5 tracking-[0.2em] text-[#FFB020]">
|
||||||
|
第 {episode} / {totalEpisode} 集 · {updateStatusLabel(detail.updateStatus)}
|
||||||
<section className="flex h-[140px] items-center justify-between rounded-xl bg-[rgba(19,15,22,0.9)] px-6 py-5 outline outline-1 -outline-offset-1 outline-[rgba(199,145,89,0.7)]">
|
|
||||||
<div className="flex min-w-0 flex-col gap-1.5">
|
|
||||||
<p className="text-sm leading-5 text-[#F12B9E]">第 {episode} 集</p>
|
|
||||||
<p className="truncate text-[28px] leading-[34px] font-semibold text-white">{detail.title}</p>
|
|
||||||
<p className="text-sm leading-5 text-[#9991AB]">
|
|
||||||
{detail.title} - 第{episodeLabel}集
|
|
||||||
</p>
|
</p>
|
||||||
|
<h1 className="text-4xl leading-[48px] font-bold text-white">
|
||||||
|
{title}
|
||||||
|
<span className="ml-3 text-[#FFB020]">第{episode}集</span>
|
||||||
|
</h1>
|
||||||
|
<TagLinks tags={tags} />
|
||||||
|
{detail.desc?.trim() ? (
|
||||||
|
<p className="line-clamp-3 max-w-[1100px] text-[15px] leading-7 text-[#B5B3BE]">{detail.desc.trim()}</p>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex shrink-0 gap-3">
|
<div className="flex shrink-0 gap-3 pt-7">
|
||||||
<ActionPill
|
<HlAction kind="like" label={liked ? "已点赞" : "点赞"} active={liked} onClick={toggleLike} />
|
||||||
icon="/images/icon_like.svg"
|
<HlAction
|
||||||
label={liked ? "已点赞" : "点赞"}
|
kind="collect"
|
||||||
active={liked}
|
|
||||||
onClick={toggleLike}
|
|
||||||
/>
|
|
||||||
<ActionPill
|
|
||||||
icon="/images/icon_collect.svg"
|
|
||||||
label={collected ? "已收藏" : "收藏"}
|
label={collected ? "已收藏" : "收藏"}
|
||||||
active={collected}
|
active={collected}
|
||||||
onClick={collecting ? undefined : toggleCollect}
|
onClick={collecting ? undefined : toggleCollect}
|
||||||
/>
|
/>
|
||||||
<ActionPill icon="/images/icon_share.svg" label="分享" onClick={share} />
|
<HlAction kind="share" label="分享" onClick={share} />
|
||||||
<ActionPill icon="/images/icon_feedback.svg" label="反馈" href="/feedback" />
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
<nav aria-label="分集导航" className="col-span-2 flex items-center gap-3 text-sm">
|
||||||
|
{prevHref ? (
|
||||||
|
<Link href={prevHref} className="rounded-md border border-white/12 px-4 py-2 text-[#D8D6DF] hover:border-[#FFB020] hover:text-[#FFB020]">
|
||||||
|
‹ 上一集:第{episode - 1}集
|
||||||
|
</Link>
|
||||||
|
) : null}
|
||||||
|
{nextHref ? (
|
||||||
|
<Link href={nextHref} className="rounded-md border border-white/12 px-4 py-2 text-[#D8D6DF] hover:border-[#FFB020] hover:text-[#FFB020]">
|
||||||
|
下一集:第{episode + 1}集 ›
|
||||||
|
</Link>
|
||||||
|
) : null}
|
||||||
|
<Link href={dramaDetailHref(detail)} className="ml-auto text-[#8E8C99] hover:text-[#FFB020]">
|
||||||
|
《{title}》剧情介绍与全部分集 ›
|
||||||
|
</Link>
|
||||||
|
</nav>
|
||||||
|
</article>
|
||||||
|
|
||||||
<div className="flex items-start gap-6">
|
{expanded ? <EpisodeDirectory detail={detail} current={episode} variant="panel" /> : null}
|
||||||
<CommentPanel target={commentTarget} />
|
|
||||||
{relatedAside ?? <RelatedAside items={related} />}
|
{adIcons ?? <AdIcons variant="pc" />}
|
||||||
</div>
|
|
||||||
|
<DramaRecommend items={related} />
|
||||||
|
|
||||||
{promo ?? <AdBanners variant="pc" />}
|
{promo ?? <AdBanners variant="pc" />}
|
||||||
</div>
|
</div>
|
||||||
@@ -389,8 +317,6 @@ export function DramaPlayPage({
|
|||||||
onLike={toggleLike}
|
onLike={toggleLike}
|
||||||
onCollect={toggleCollect}
|
onCollect={toggleCollect}
|
||||||
onShare={share}
|
onShare={share}
|
||||||
commentTarget={commentTarget}
|
|
||||||
onPlaySuccess={reportWatchHistory}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="max-lg:hidden">
|
<div className="max-lg:hidden">
|
||||||
|
|||||||
@@ -5,25 +5,24 @@ import { useRouter } from "next/navigation";
|
|||||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||||
|
|
||||||
import { BackButton } from "@/components/common/back-button";
|
import { BackButton } from "@/components/common/back-button";
|
||||||
import { H5CommentSheet, type CommentTarget } from "@/components/common/comments";
|
import { pickPlayletCardTags } from "@/components/common/card-tags";
|
||||||
import { DecryptedImage } from "@/components/common/decrypted-image";
|
import { DecryptedImage } from "@/components/common/decrypted-image";
|
||||||
import {
|
import {
|
||||||
dramaDetailHref,
|
dramaDetailHref,
|
||||||
getEpisodeState,
|
|
||||||
playHref,
|
playHref,
|
||||||
totalEpisodeOf,
|
totalEpisodeOf,
|
||||||
updateStatusLabel,
|
updateStatusLabel,
|
||||||
type DramaDetail,
|
type DramaDetail,
|
||||||
type RelatedDrama,
|
type RelatedDrama,
|
||||||
} from "@/components/drama-detail/data";
|
} from "@/components/drama-detail/data";
|
||||||
import { MorePlayletsGrid } from "@/components/drama-detail/episodes";
|
|
||||||
import { openAppDownload } from "@/components/download/download-dialog";
|
import { openAppDownload } from "@/components/download/download-dialog";
|
||||||
|
import { EpisodeDirectory } from "@/components/media-page/episode-directory";
|
||||||
|
import { DramaRecommend, HlAction, TagLinks, tagLinkItems } from "@/components/media-page/parts";
|
||||||
import { playbackRates, XgPlayer, type XgPlayerInstance } from "@/components/player/xg-player";
|
import { playbackRates, XgPlayer, type XgPlayerInstance } from "@/components/player/xg-player";
|
||||||
|
|
||||||
import { CheckIcon, ChevronIcon } from "./icons";
|
import { CheckIcon, ChevronIcon } from "./icons";
|
||||||
import { useEpisodeRange } from "./play-episode-panel";
|
|
||||||
|
|
||||||
type Sheet = "episodes" | "speed" | "comments" | null;
|
type Sheet = "speed" | null;
|
||||||
|
|
||||||
/** 播完自动下一集倒计时(秒) */
|
/** 播完自动下一集倒计时(秒) */
|
||||||
const AUTO_NEXT_SECONDS = 3;
|
const AUTO_NEXT_SECONDS = 3;
|
||||||
@@ -64,7 +63,6 @@ type H5PlayProps = {
|
|||||||
onLike: () => void;
|
onLike: () => void;
|
||||||
onCollect: () => void;
|
onCollect: () => void;
|
||||||
onShare: () => void;
|
onShare: () => void;
|
||||||
commentTarget: CommentTarget | null;
|
|
||||||
onPlaySuccess?: () => void;
|
onPlaySuccess?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,7 +73,7 @@ function LockedNotice() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={openAppDownload}
|
onClick={openAppDownload}
|
||||||
className="cursor-pointer inline-flex h-9 items-center justify-center rounded-full bg-[#F12B9E] px-6 text-sm font-medium text-white"
|
className="cursor-pointer inline-flex h-9 items-center justify-center rounded-md bg-[#FFB020] px-6 text-sm font-semibold text-[#1A1206]"
|
||||||
>
|
>
|
||||||
下载APP观看完整剧集
|
下载APP观看完整剧集
|
||||||
</button>
|
</button>
|
||||||
@@ -140,147 +138,6 @@ function SheetHead({ title, onClose, children }: { title: ReactNode; onClose: ()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function EpisodeSheet({
|
|
||||||
detail,
|
|
||||||
episode,
|
|
||||||
collected,
|
|
||||||
related = [],
|
|
||||||
onCollect,
|
|
||||||
onClose,
|
|
||||||
}: Pick<H5PlayProps, "detail" | "episode" | "collected" | "related" | "onCollect"> & {
|
|
||||||
onClose: () => void;
|
|
||||||
}) {
|
|
||||||
const { ranges, rangeIndex, setRangeIndex, episodes } = useEpisodeRange(detail, episode);
|
|
||||||
const [tab, setTab] = useState<"episodes" | "more">("episodes");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex max-h-[75vh] flex-col gap-3 px-4 pt-2.5 pb-[18px]">
|
|
||||||
<span className="mx-auto h-[5px] w-9 shrink-0 rounded-full bg-white/20" />
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2.5">
|
|
||||||
<DecryptedImage
|
|
||||||
src={detail.cover}
|
|
||||||
alt=""
|
|
||||||
className="h-[75px] w-[54px] shrink-0 rounded-[3px] object-cover"
|
|
||||||
/>
|
|
||||||
<div className="flex min-w-0 flex-col gap-2">
|
|
||||||
<Link href={dramaDetailHref(detail)} className="flex items-center gap-2 text-sm leading-5 text-white">
|
|
||||||
<span className="truncate">{detail.title}</span>
|
|
||||||
<ChevronIcon direction="right" className="size-3 shrink-0" />
|
|
||||||
</Link>
|
|
||||||
<p className="text-xs leading-[18px] text-white/35">
|
|
||||||
{updateStatusLabel(detail.updateStatus)} 共{totalEpisodeOf(detail)}集
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-pressed={collected}
|
|
||||||
onClick={onCollect}
|
|
||||||
className={`cursor-pointer shrink-0 rounded-full px-3 py-1 text-[10px] leading-4 ${collected ? "bg-white/5 text-[#F12B9E]" : "bg-[#F12B9E] text-white"}`}
|
|
||||||
>
|
|
||||||
{collected ? "已收藏" : "收藏"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex shrink-0 gap-6 overflow-x-auto text-sm leading-5 [scrollbar-width:none]">
|
|
||||||
{ranges.map((range, index) => (
|
|
||||||
<button
|
|
||||||
key={range.label}
|
|
||||||
type="button"
|
|
||||||
aria-pressed={tab === "episodes" && rangeIndex === index}
|
|
||||||
onClick={() => {
|
|
||||||
setTab("episodes");
|
|
||||||
setRangeIndex(index);
|
|
||||||
}}
|
|
||||||
className={`cursor-pointer shrink-0 ${tab === "episodes" && rangeIndex === index ? "text-white" : "text-white/35"}`}
|
|
||||||
>
|
|
||||||
{range.start}-{range.end}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-pressed={tab === "more"}
|
|
||||||
onClick={() => setTab("more")}
|
|
||||||
className={`cursor-pointer shrink-0 ${tab === "more" ? "text-white" : "text-white/35"}`}
|
|
||||||
>
|
|
||||||
更多好剧
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="min-h-0 overflow-y-auto overscroll-contain">
|
|
||||||
{tab === "episodes" ? (
|
|
||||||
<div className="grid grid-cols-5 gap-x-[11px] gap-y-2">
|
|
||||||
{episodes.map((item) => {
|
|
||||||
const active = item === episode;
|
|
||||||
const locked = getEpisodeState(item, detail) === "locked";
|
|
||||||
if (active) {
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={item}
|
|
||||||
href={playHref(detail.id, item, detail.slug)}
|
|
||||||
replace
|
|
||||||
onClick={onClose}
|
|
||||||
aria-current="true"
|
|
||||||
className="relative flex h-[58px] items-center justify-center overflow-hidden rounded-md bg-[rgba(241,43,158,0.1)] text-base leading-[22px] text-[#F12B9E] outline outline-1 -outline-offset-1 outline-[#F12B9E]"
|
|
||||||
>
|
|
||||||
{item}
|
|
||||||
<img src="/images/playing.svg" alt="" className="absolute top-0 right-0 size-5 p-[3px]" />
|
|
||||||
{!locked ? (
|
|
||||||
<span className="absolute top-0 left-0 flex h-[14px] w-[25px] items-center justify-center rounded-sm bg-[linear-gradient(136deg,#74FFED_0%,#10B9A2_100%)] text-[8px] leading-3 text-[#002D27]">
|
|
||||||
免费
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!locked) {
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={item}
|
|
||||||
href={playHref(detail.id, item, detail.slug)}
|
|
||||||
replace
|
|
||||||
onClick={onClose}
|
|
||||||
className="relative flex h-[58px] items-center justify-center overflow-hidden rounded-md bg-[#3A3D53] text-base leading-[22px] text-white"
|
|
||||||
>
|
|
||||||
{item}
|
|
||||||
<span className="absolute top-0 right-0 flex h-[14px] w-[25px] items-center justify-center rounded-sm bg-[linear-gradient(136deg,#74FFED_0%,#10B9A2_100%)] text-[8px] leading-3 text-[#002D27]">
|
|
||||||
免费
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={item}
|
|
||||||
href={playHref(detail.id, item, detail.slug)}
|
|
||||||
replace
|
|
||||||
onClick={onClose}
|
|
||||||
aria-label={`第${item}集(未解锁)`}
|
|
||||||
className="relative flex h-[58px] items-center justify-center gap-0.5 overflow-hidden rounded-md bg-white/10 text-base leading-[22px] text-[#828186] outline outline-1 -outline-offset-1 outline-white/5"
|
|
||||||
>
|
|
||||||
{item}
|
|
||||||
<svg viewBox="0 0 18 18" fill="none" className="size-3.5" aria-hidden="true">
|
|
||||||
<path
|
|
||||||
d="M5.29 7.65V5.25a3.71 3.71 0 0 1 7.42 0v2.4"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="1.35"
|
|
||||||
strokeLinecap="round"
|
|
||||||
/>
|
|
||||||
<rect x="3.75" y="7.5" width="10.5" height="8.25" rx="1.5" stroke="currentColor" strokeWidth="1.35" />
|
|
||||||
</svg>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<MorePlayletsGrid items={related} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function H5Play({
|
export function H5Play({
|
||||||
detail,
|
detail,
|
||||||
episode,
|
episode,
|
||||||
@@ -294,14 +151,12 @@ export function H5Play({
|
|||||||
onLike,
|
onLike,
|
||||||
onCollect,
|
onCollect,
|
||||||
onShare,
|
onShare,
|
||||||
commentTarget,
|
|
||||||
onPlaySuccess,
|
onPlaySuccess,
|
||||||
}: H5PlayProps) {
|
}: H5PlayProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const playerRef = useRef<XgPlayerInstance | null>(null);
|
const playerRef = useRef<XgPlayerInstance | null>(null);
|
||||||
const [rate, setRate] = useState(1);
|
const [rate, setRate] = useState(1);
|
||||||
const [sheet, setSheet] = useState<Sheet>(null);
|
const [sheet, setSheet] = useState<Sheet>(null);
|
||||||
const [cleared, setCleared] = useState(false);
|
|
||||||
const [introOpen, setIntroOpen] = useState(false);
|
const [introOpen, setIntroOpen] = useState(false);
|
||||||
/** null=未进入自动下一集;数字=剩余秒数 */
|
/** null=未进入自动下一集;数字=剩余秒数 */
|
||||||
const [autoNextSeconds, setAutoNextSeconds] = useState<number | null>(null);
|
const [autoNextSeconds, setAutoNextSeconds] = useState<number | null>(null);
|
||||||
@@ -309,10 +164,14 @@ export function H5Play({
|
|||||||
const [shouldAutoplay] = useState(consumeAutoplayFlag);
|
const [shouldAutoplay] = useState(consumeAutoplayFlag);
|
||||||
const closeSheet = () => setSheet(null);
|
const closeSheet = () => setSheet(null);
|
||||||
|
|
||||||
|
const title = detail.title || "短剧";
|
||||||
const totalEpisode = totalEpisodeOf(detail);
|
const totalEpisode = totalEpisodeOf(detail);
|
||||||
const nextEpisode = episode + 1;
|
const nextEpisode = episode + 1;
|
||||||
const hasNext = nextEpisode <= totalEpisode;
|
const hasNext = nextEpisode <= totalEpisode;
|
||||||
const nextHref = hasNext ? playHref(detail.id, nextEpisode, detail.slug) : null;
|
const nextHref = hasNext ? playHref(detail.id, nextEpisode, detail.slug) : null;
|
||||||
|
const prevHref = episode > 1 ? playHref(detail.id, episode - 1, detail.slug) : null;
|
||||||
|
const tags = tagLinkItems(pickPlayletCardTags(detail), "playlet");
|
||||||
|
const desc = detail.desc?.trim() || "";
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!sheet) return;
|
if (!sheet) return;
|
||||||
@@ -357,47 +216,11 @@ export function H5Play({
|
|||||||
const likeCount = displayCountLike ?? (Number(detail.displayCountLike) || 0);
|
const likeCount = displayCountLike ?? (Number(detail.displayCountLike) || 0);
|
||||||
const collectCount = countCollect ?? (Number(detail.countCollect) || 0);
|
const collectCount = countCollect ?? (Number(detail.countCollect) || 0);
|
||||||
|
|
||||||
/** 已点赞 #F52C56 · 已收藏 #F68902 · 文案始终 #DCDCDC */
|
|
||||||
const sideItems = [
|
|
||||||
{
|
|
||||||
label: formatCount(likeCount),
|
|
||||||
icon: "/images/icon_like.svg",
|
|
||||||
active: liked,
|
|
||||||
activeColor: "#F52C56",
|
|
||||||
onClick: onLike,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "评论",
|
|
||||||
icon: "/images/comment.svg",
|
|
||||||
active: false,
|
|
||||||
activeColor: "#FFFFFF",
|
|
||||||
onClick: () => setSheet("comments"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: formatCount(collectCount),
|
|
||||||
icon: "/images/icon_collect.svg",
|
|
||||||
active: collected,
|
|
||||||
activeColor: "#F68902",
|
|
||||||
onClick: onCollect,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "分享",
|
|
||||||
icon: "/images/share_h5.svg",
|
|
||||||
active: false,
|
|
||||||
activeColor: "#FFFFFF",
|
|
||||||
onClick: onShare,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-component="drama-h5-play" className="fixed inset-0 z-30 flex flex-col bg-[#0E0E0E] lg:hidden">
|
<div data-component="hl-drama-play-h5" className="flex flex-col bg-[#0C0B10] lg:hidden">
|
||||||
<div className="relative min-h-0 flex-1 overflow-hidden">
|
<div className="sticky top-0 z-30 aspect-[3/4] max-h-[72vh] w-full overflow-hidden bg-black">
|
||||||
{locked ? (
|
{locked ? (
|
||||||
<DecryptedImage
|
<DecryptedImage src={detail.cover} alt={`${title} 第${episode}集`} className="absolute inset-0 size-full object-cover" />
|
||||||
src={detail.cover}
|
|
||||||
alt={detail.title}
|
|
||||||
className="absolute inset-0 size-full object-cover"
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<XgPlayer
|
<XgPlayer
|
||||||
src={src}
|
src={src}
|
||||||
@@ -410,146 +233,93 @@ export function H5Play({
|
|||||||
}}
|
}}
|
||||||
onPlaySuccess={onPlaySuccess}
|
onPlaySuccess={onPlaySuccess}
|
||||||
onEnded={handleEnded}
|
onEnded={handleEnded}
|
||||||
analyticsKind="drama"
|
|
||||||
clickToPlay={!shouldAutoplay}
|
clickToPlay={!shouldAutoplay}
|
||||||
className="absolute inset-0"
|
className="absolute inset-0"
|
||||||
options={{ ignores: ["playbackrate", "cssfullscreen"] }}
|
options={{ ignores: ["playbackrate", "cssfullscreen"] }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="pointer-events-none absolute inset-x-0 top-0 h-[min(300px,40%)] bg-[linear-gradient(180deg,#000_0%,rgba(0,0,0,0)_100%)]" />
|
<div className="pointer-events-none absolute inset-x-0 top-0 h-20 bg-[linear-gradient(180deg,rgba(0,0,0,0.7)_0%,rgba(0,0,0,0)_100%)]" />
|
||||||
{!cleared ? (
|
<div className="absolute inset-x-0 top-0 z-20 flex items-center gap-2 px-3 pt-[calc(8px+env(safe-area-inset-top))] pb-2">
|
||||||
<div className="pointer-events-none absolute inset-x-0 bottom-0 h-[min(212px,30%)] bg-[linear-gradient(180deg,rgba(0,0,0,0)_0%,rgba(0,0,0,0.75)_100%)]" />
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<div className="absolute inset-x-0 top-0 z-20 flex items-center gap-1 px-4 pt-[calc(12px+env(safe-area-inset-top))] pb-3">
|
|
||||||
<BackButton fallback={dramaDetailHref(detail)} />
|
<BackButton fallback={dramaDetailHref(detail)} />
|
||||||
<p className="min-w-0 flex-1 truncate text-lg leading-6 font-medium text-white">第{episode}集</p>
|
<p className="min-w-0 flex-1 truncate text-sm leading-5 text-white/90">
|
||||||
<div className="flex items-center gap-3">
|
第 {episode} / {totalEpisode} 集
|
||||||
<button
|
</p>
|
||||||
type="button"
|
<button
|
||||||
onClick={() => setSheet("speed")}
|
type="button"
|
||||||
className="cursor-pointer flex items-center gap-1 text-xs leading-[18px] font-medium text-white"
|
onClick={() => setSheet("speed")}
|
||||||
>
|
className="cursor-pointer flex items-center gap-1 rounded bg-black/40 px-2 py-1 text-xs leading-[18px] font-medium text-white"
|
||||||
<img src="/images/speed.svg" alt="" className="size-[18px]" />
|
>
|
||||||
{rate === 1 ? "1.0" : rate}x
|
<img src="/images/speed.svg" alt="" className="size-4" />
|
||||||
</button>
|
{rate === 1 ? "1.0" : rate}x
|
||||||
<Link href="/feedback" aria-label="意见反馈" className="size-6 shrink-0">
|
</button>
|
||||||
<img src="/images/feedback.svg" alt="" className="size-full" />
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{locked ? <LockedNotice /> : null}
|
{locked ? <LockedNotice /> : null}
|
||||||
|
|
||||||
{!cleared ? (
|
|
||||||
<>
|
|
||||||
<div className="pointer-events-none absolute right-4 bottom-[120px] z-10 inline-flex flex-col items-center gap-[18px]">
|
|
||||||
<div className="flex flex-col items-center gap-2.5">
|
|
||||||
{sideItems.map((item) => (
|
|
||||||
<button
|
|
||||||
key={item.icon}
|
|
||||||
type="button"
|
|
||||||
aria-pressed={item.active}
|
|
||||||
onClick={item.onClick}
|
|
||||||
className="pointer-events-auto cursor-pointer flex flex-col items-center text-center text-xs leading-[18px] font-medium text-[#DCDCDC]"
|
|
||||||
>
|
|
||||||
<span className="relative size-[30px] overflow-hidden">
|
|
||||||
<span
|
|
||||||
aria-hidden="true"
|
|
||||||
className="absolute inset-0"
|
|
||||||
style={{
|
|
||||||
background: item.active ? item.activeColor : "#FFFFFF",
|
|
||||||
mask: `url(${item.icon}) center / 24px no-repeat`,
|
|
||||||
WebkitMask: `url(${item.icon}) center / 24px no-repeat`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
{item.label}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="pointer-events-none absolute bottom-[68px] left-4 z-10 flex w-[min(278px,calc(100%-90px))] flex-col gap-2.5">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-label="选集"
|
|
||||||
onClick={() => setSheet("episodes")}
|
|
||||||
className="pointer-events-auto flex max-w-full cursor-pointer items-center gap-[5px] text-left text-xs leading-[18px] font-medium text-white"
|
|
||||||
>
|
|
||||||
<h1 className="min-w-0 truncate">{detail.title}</h1>
|
|
||||||
<ChevronIcon direction="right" className="size-[18px] shrink-0" />
|
|
||||||
</button>
|
|
||||||
<div className="flex items-end gap-1.5">
|
|
||||||
<p
|
|
||||||
className={`max-w-[248px] text-xs leading-[18px] text-white/65 ${introOpen ? "pointer-events-auto max-h-40 overflow-y-auto" : "line-clamp-2"}`}
|
|
||||||
>
|
|
||||||
{detail.desc}
|
|
||||||
</p>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setIntroOpen((open) => !open)}
|
|
||||||
className="pointer-events-auto cursor-pointer shrink-0 text-xs leading-[18px] text-white"
|
|
||||||
>
|
|
||||||
{introOpen ? "收起" : "展开"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{autoNextSeconds != null && hasNext ? (
|
{autoNextSeconds != null && hasNext ? (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={goNextEpisode}
|
onClick={goNextEpisode}
|
||||||
className="absolute inset-x-4 bottom-3 z-20 flex cursor-pointer items-center justify-between rounded-md bg-white/10 px-3 py-1.5 text-sm leading-5"
|
className="absolute inset-x-3 bottom-3 z-20 flex cursor-pointer items-center justify-between rounded-md bg-black/60 px-3 py-2 text-sm leading-5"
|
||||||
>
|
>
|
||||||
<span className="text-white">自动播放下一集</span>
|
<span className="text-white">即将播放第 {nextEpisode} 集</span>
|
||||||
<span className="text-[#FFAB6B]">倒计时{autoNextSeconds}s</span>
|
<span className="text-[#FFB020]">{autoNextSeconds}s</span>
|
||||||
</button>
|
</button>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex min-h-[58px] shrink-0 items-center gap-2.5 bg-[#1A1A1A] px-4 pt-1.5 pb-[calc(6px+env(safe-area-inset-bottom))]">
|
<div className="flex flex-col gap-6 px-4 pt-4 pb-10">
|
||||||
<button
|
<article className="flex flex-col gap-3">
|
||||||
type="button"
|
<p className="text-[11px] leading-4 tracking-[0.15em] text-[#FFB020]">
|
||||||
onClick={() => setSheet("episodes")}
|
短剧 · {updateStatusLabel(detail.updateStatus)} · 共{totalEpisode}集
|
||||||
className="cursor-pointer flex min-w-0 flex-1 items-center justify-between rounded-[3px] bg-white/5 px-3 py-1.5 text-xs leading-[18px] text-white"
|
</p>
|
||||||
>
|
<h1 className="text-lg leading-7 font-bold text-white">
|
||||||
<span className="truncate">选集·全{totalEpisode}集·免费观看</span>
|
{title}
|
||||||
<ChevronIcon direction="up" className="size-6 shrink-0" />
|
<span className="ml-2 text-[#FFB020]">第{episode}集</span>
|
||||||
</button>
|
</h1>
|
||||||
{cleared ? (
|
<TagLinks tags={tags} compact />
|
||||||
<button
|
{desc ? (
|
||||||
type="button"
|
<div className="flex items-end gap-1.5">
|
||||||
aria-label="评论"
|
<p className={`min-w-0 flex-1 text-[13px] leading-[22px] text-[#A9A7B3] ${introOpen ? "" : "line-clamp-2"}`}>{desc}</p>
|
||||||
onClick={() => setSheet("comments")}
|
<button
|
||||||
className="cursor-pointer rounded-[3px] bg-white/5 px-3 py-1.5 text-white"
|
type="button"
|
||||||
>
|
onClick={() => setIntroOpen((open) => !open)}
|
||||||
<img src="/images/comment.svg" alt="" className="size-6" />
|
className="cursor-pointer shrink-0 text-xs leading-[22px] text-[#FFB020]"
|
||||||
</button>
|
>
|
||||||
) : null}
|
{introOpen ? "收起" : "展开"}
|
||||||
<button
|
</button>
|
||||||
type="button"
|
</div>
|
||||||
aria-label={cleared ? "退出清屏" : "清屏"}
|
) : null}
|
||||||
aria-pressed={cleared}
|
<div className="flex items-center gap-2">
|
||||||
onClick={() => setCleared((value) => !value)}
|
<HlAction kind="like" label={formatCount(likeCount)} active={liked} onClick={onLike} compact />
|
||||||
className="cursor-pointer text-white"
|
<HlAction kind="collect" label={formatCount(collectCount)} active={collected} onClick={onCollect} compact />
|
||||||
>
|
<HlAction kind="share" label="分享" onClick={onShare} compact />
|
||||||
<img src={cleared ? "/images/unscreen.svg" : "/images/screen.svg"} alt="" className="size-6" />
|
</div>
|
||||||
</button>
|
<nav aria-label="分集导航" className="grid grid-cols-2 gap-2 text-xs leading-[18px]">
|
||||||
</div>
|
{prevHref ? (
|
||||||
|
<Link href={prevHref} className="flex items-center gap-1 rounded-md border border-white/12 px-3 py-2 text-[#D8D6DF]">
|
||||||
|
<ChevronIcon direction="left" className="size-3.5" />
|
||||||
|
上一集 · 第{episode - 1}集
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span />
|
||||||
|
)}
|
||||||
|
{nextHref ? (
|
||||||
|
<Link
|
||||||
|
href={nextHref}
|
||||||
|
className="flex items-center justify-end gap-1 rounded-md border border-white/12 px-3 py-2 text-[#D8D6DF]"
|
||||||
|
>
|
||||||
|
下一集 · 第{nextEpisode}集
|
||||||
|
<ChevronIcon direction="right" className="size-3.5" />
|
||||||
|
</Link>
|
||||||
|
) : null}
|
||||||
|
</nav>
|
||||||
|
</article>
|
||||||
|
|
||||||
<BottomSheet open={sheet === "episodes"} onClose={closeSheet} label="选集">
|
<EpisodeDirectory detail={detail} current={episode} variant="h5" />
|
||||||
<EpisodeSheet
|
|
||||||
detail={detail}
|
<DramaRecommend items={related} compact />
|
||||||
episode={episode}
|
</div>
|
||||||
collected={collected}
|
|
||||||
related={related}
|
|
||||||
onCollect={onCollect}
|
|
||||||
onClose={closeSheet}
|
|
||||||
/>
|
|
||||||
</BottomSheet>
|
|
||||||
|
|
||||||
<BottomSheet open={sheet === "speed"} onClose={closeSheet} label="倍速" className="gap-3 px-4 py-[18px]">
|
<BottomSheet open={sheet === "speed"} onClose={closeSheet} label="倍速" className="gap-3 px-4 py-[18px]">
|
||||||
<SheetHead title="倍速" onClose={closeSheet} />
|
<SheetHead title="倍速" onClose={closeSheet} />
|
||||||
@@ -565,17 +335,13 @@ export function H5Play({
|
|||||||
setRate(item);
|
setRate(item);
|
||||||
closeSheet();
|
closeSheet();
|
||||||
}}
|
}}
|
||||||
className={`cursor-pointer flex h-12 items-center justify-between text-base leading-[22px] ${item === rate ? "text-[#F12B9E]" : "text-white"}`}
|
className={`cursor-pointer flex h-12 items-center justify-between text-base leading-[22px] ${item === rate ? "text-[#FFB020]" : "text-white"}`}
|
||||||
>
|
>
|
||||||
{item}x{item === rate ? <CheckIcon /> : null}
|
{item}x{item === rate ? <CheckIcon /> : null}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</BottomSheet>
|
</BottomSheet>
|
||||||
|
|
||||||
<BottomSheet open={sheet === "comments"} onClose={closeSheet} label="评论">
|
|
||||||
<H5CommentSheet onClose={closeSheet} target={commentTarget} />
|
|
||||||
</BottomSheet>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,6 @@ type PcPlayerProps = PlayerProps & {
|
|||||||
layout: PlayerLayout;
|
layout: PlayerLayout;
|
||||||
onToggleExpand?: () => void;
|
onToggleExpand?: () => void;
|
||||||
onPlaySuccess?: () => void;
|
onPlaySuccess?: () => void;
|
||||||
analyticsKind?: "drama" | "video";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function PcPlayer({
|
export function PcPlayer({
|
||||||
@@ -191,7 +190,6 @@ export function PcPlayer({
|
|||||||
layout,
|
layout,
|
||||||
onToggleExpand,
|
onToggleExpand,
|
||||||
onPlaySuccess,
|
onPlaySuccess,
|
||||||
analyticsKind = "drama",
|
|
||||||
}: PcPlayerProps) {
|
}: PcPlayerProps) {
|
||||||
const playerRef = useRef<XgPlayerInstance | null>(null);
|
const playerRef = useRef<XgPlayerInstance | null>(null);
|
||||||
const toggleRef = useRef(onToggleExpand);
|
const toggleRef = useRef(onToggleExpand);
|
||||||
@@ -245,7 +243,6 @@ export function PcPlayer({
|
|||||||
playerRef={playerRef}
|
playerRef={playerRef}
|
||||||
onReady={onReady}
|
onReady={onReady}
|
||||||
onPlaySuccess={onPlaySuccess}
|
onPlaySuccess={onPlaySuccess}
|
||||||
analyticsKind={analyticsKind}
|
|
||||||
clickToPlay
|
clickToPlay
|
||||||
className="absolute inset-0"
|
className="absolute inset-0"
|
||||||
options={{ cssFullscreen: Boolean(onToggleExpand) }}
|
options={{ cssFullscreen: Boolean(onToggleExpand) }}
|
||||||
|
|||||||
@@ -1,169 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import Link from "next/link";
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
import {
|
|
||||||
dramaDetailHref,
|
|
||||||
getEpisodeChunks,
|
|
||||||
getEpisodeState,
|
|
||||||
playHref,
|
|
||||||
totalEpisodeOf,
|
|
||||||
type DramaDetail,
|
|
||||||
} from "@/components/drama-detail/data";
|
|
||||||
|
|
||||||
import { ChevronIcon } from "./icons";
|
|
||||||
|
|
||||||
export const EPISODE_CHUNK = 30;
|
|
||||||
|
|
||||||
function LockIcon({ className = "size-[18px]" }: { className?: string }) {
|
|
||||||
return (
|
|
||||||
<svg viewBox="0 0 18 18" fill="none" className={className} aria-hidden="true">
|
|
||||||
<path
|
|
||||||
d="M5.29 7.65V5.25a3.71 3.71 0 0 1 7.42 0v2.4"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="1.35"
|
|
||||||
strokeLinecap="round"
|
|
||||||
/>
|
|
||||||
<rect x="3.75" y="7.5" width="10.5" height="8.25" rx="1.5" stroke="currentColor" strokeWidth="1.35" />
|
|
||||||
<path d="M9 10.09v2.79" stroke="currentColor" strokeWidth="1.35" strokeLinecap="round" />
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function FreeBadge() {
|
|
||||||
return (
|
|
||||||
<span className="absolute top-[5px] left-11 flex h-5 w-9 items-center justify-center rounded bg-[linear-gradient(136deg,#74FFED_0%,#10B9A2_100%)] text-[10px] leading-4 text-[#002D27]">
|
|
||||||
免费
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useEpisodeRange(detail: DramaDetail, current: number) {
|
|
||||||
const ranges = getEpisodeChunks(totalEpisodeOf(detail), EPISODE_CHUNK);
|
|
||||||
const [rangeIndex, setRangeIndex] = useState(() => Math.floor((current - 1) / EPISODE_CHUNK));
|
|
||||||
const { start, end } = ranges[rangeIndex] ?? ranges[0];
|
|
||||||
const episodes = Array.from({ length: end - start + 1 }, (_, index) => start + index);
|
|
||||||
return { ranges, rangeIndex, setRangeIndex, episodes };
|
|
||||||
}
|
|
||||||
|
|
||||||
export function PlayEpisodePanel({
|
|
||||||
detail,
|
|
||||||
current,
|
|
||||||
wide = false,
|
|
||||||
}: {
|
|
||||||
detail: DramaDetail;
|
|
||||||
current: number;
|
|
||||||
wide?: boolean;
|
|
||||||
}) {
|
|
||||||
const { ranges, rangeIndex, setRangeIndex, episodes } = useEpisodeRange(detail, current);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<aside
|
|
||||||
data-component="play-episode-panel"
|
|
||||||
className={`inline-flex shrink-0 flex-col items-start justify-start gap-3 overflow-hidden rounded-xl px-6 py-5 outline outline-1 -outline-offset-1 outline-[rgba(199,145,89,0.7)] ${
|
|
||||||
wide ? "w-full" : "h-[648px] w-[528px]"
|
|
||||||
} bg-[rgba(19,15,22,0.79)]`}
|
|
||||||
>
|
|
||||||
<div className="inline-flex h-9 w-full shrink-0 items-center justify-between gap-3">
|
|
||||||
<h2 className="min-w-0 text-[22px] leading-[30px] font-normal text-white">选集</h2>
|
|
||||||
<Link
|
|
||||||
href={dramaDetailHref(detail)}
|
|
||||||
className="inline-flex w-auto shrink-0 items-center gap-2 whitespace-nowrap text-xs leading-[18px] text-[#9991AB] hover:text-white"
|
|
||||||
>
|
|
||||||
<ChevronIcon direction="left" />
|
|
||||||
返回详情
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={`relative inline-flex h-8 w-full shrink-0 items-center ${
|
|
||||||
wide ? "justify-start gap-20" : "justify-between"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{ranges.map((range, index) => {
|
|
||||||
const active = index === rangeIndex;
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={range.label}
|
|
||||||
type="button"
|
|
||||||
aria-pressed={active}
|
|
||||||
onClick={() => setRangeIndex(index)}
|
|
||||||
className={`cursor-pointer relative h-8 text-base leading-[22px] ${
|
|
||||||
active ? "font-medium text-[#F12B9E]" : "font-normal text-[#6E6B75] hover:text-white"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{range.label}
|
|
||||||
{active ? (
|
|
||||||
<span className="absolute top-[30px] left-0 h-0.5 w-[39px] rounded-sm bg-[#FF1A8C]" />
|
|
||||||
) : null}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={`inline-flex w-full flex-wrap content-start items-start justify-start gap-3 overflow-hidden ${
|
|
||||||
wide ? "" : "min-h-0 flex-1 overflow-y-auto [scrollbar-width:thin]"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{episodes.map((episode) => {
|
|
||||||
const playing = episode === current;
|
|
||||||
const locked = getEpisodeState(episode, detail) === "locked";
|
|
||||||
|
|
||||||
if (playing) {
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={episode}
|
|
||||||
href={playHref(detail.id, episode, detail.slug)}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
aria-current="true"
|
|
||||||
className="relative h-[76px] w-[86px] overflow-hidden rounded-lg bg-[rgba(241,43,158,0.1)] outline outline-1 -outline-offset-1 outline-[#F12B9E]"
|
|
||||||
>
|
|
||||||
<span className="absolute top-[29px] left-[14px] flex w-[58px] items-end justify-center text-center text-lg leading-6 text-[#F12B9E]">
|
|
||||||
{episode}
|
|
||||||
</span>
|
|
||||||
<img src="/images/playing.svg" alt="" className="absolute top-2 left-[58px] size-5" />
|
|
||||||
{!locked ? <FreeBadge /> : null}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!locked) {
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={episode}
|
|
||||||
href={playHref(detail.id, episode, detail.slug)}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
className="relative h-[76px] w-[86px] overflow-hidden rounded-lg bg-[#3A3D53] transition-colors hover:bg-[#454866]"
|
|
||||||
>
|
|
||||||
<span className="absolute top-[29px] left-[14px] flex w-[58px] items-end justify-center text-center text-lg leading-6 text-white">
|
|
||||||
{episode}
|
|
||||||
</span>
|
|
||||||
<FreeBadge />
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={episode}
|
|
||||||
href={playHref(detail.id, episode, detail.slug)}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
aria-label={`第${episode}集(未解锁)`}
|
|
||||||
className="relative h-[76px] w-[86px] overflow-hidden rounded-lg bg-white/10 outline outline-1 -outline-offset-1 outline-white/5 transition-colors hover:bg-white/15"
|
|
||||||
>
|
|
||||||
<span className="absolute top-[29px] left-[14px] inline-flex w-[58px] items-center justify-center gap-0.5 text-lg leading-6 text-[#828186]">
|
|
||||||
<span className="min-w-0 flex-1 text-center">{episode}</span>
|
|
||||||
<LockIcon className="size-[18px] shrink-0" />
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useCallback, useRef } from "react";
|
|
||||||
|
|
||||||
import { reportPlayletHistory } from "@/lib/api/playlet-actions";
|
|
||||||
import { ensureGuestSession, getAuthToken } from "@/lib/auth/session";
|
|
||||||
|
|
||||||
async function ensureToken() {
|
|
||||||
let token = getAuthToken();
|
|
||||||
if (!token) {
|
|
||||||
try {
|
|
||||||
await ensureGuestSession();
|
|
||||||
} catch {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
token = getAuthToken();
|
|
||||||
}
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 播放成功后上报观看历史;同一 playletId+chapterId 只报一次 */
|
|
||||||
export function useReportPlayletHistory(playletId: number, chapterId?: number) {
|
|
||||||
const reportedKeyRef = useRef<string | null>(null);
|
|
||||||
|
|
||||||
return useCallback(async () => {
|
|
||||||
if (!Number.isInteger(playletId) || playletId < 1) return;
|
|
||||||
if (!Number.isInteger(chapterId) || !chapterId || chapterId < 1) return;
|
|
||||||
|
|
||||||
const key = `${playletId}:${chapterId}`;
|
|
||||||
if (reportedKeyRef.current === key) return;
|
|
||||||
reportedKeyRef.current = key;
|
|
||||||
|
|
||||||
const token = await ensureToken();
|
|
||||||
if (!token) {
|
|
||||||
reportedKeyRef.current = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await reportPlayletHistory({ playletId, chapterId }, token);
|
|
||||||
} catch (error) {
|
|
||||||
reportedKeyRef.current = null;
|
|
||||||
if (process.env.NODE_ENV === "development") {
|
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
|
||||||
console.warn(`[playlet/history] report failed: ${message}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [playletId, chapterId]);
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import { pickPlayletCardTags, pickVideoCardTags } from "@/components/common/card-tags";
|
|
||||||
import { resolveContentBadge } from "@/components/home/section-heading";
|
|
||||||
import { formatHeat } from "@/components/ranking/data";
|
|
||||||
import type { ShortDramaItem } from "@/components/short-drama/data";
|
|
||||||
import type { FavoriteVideoListItem, PlayletData } from "@/lib/api/types";
|
|
||||||
|
|
||||||
export const favoriteTypes = ["短剧", "视频"] as const;
|
|
||||||
|
|
||||||
export type FavoriteType = (typeof favoriteTypes)[number];
|
|
||||||
|
|
||||||
export const FAVORITES_PAGE_SIZE = 24;
|
|
||||||
|
|
||||||
/** 短剧收藏列表项 → 卡片(接口 PlayletData) */
|
|
||||||
export function mapFavoritePlayletItem(item: PlayletData): ShortDramaItem | null {
|
|
||||||
const id = Number(item.id);
|
|
||||||
if (!Number.isInteger(id) || id < 1) return null;
|
|
||||||
return {
|
|
||||||
kind: "drama",
|
|
||||||
id: String(id),
|
|
||||||
slug: item.slug,
|
|
||||||
title: (item.title || "").trim() || "未命名短剧",
|
|
||||||
subtitle: (item.desc || "").trim(),
|
|
||||||
tags: pickPlayletCardTags(item),
|
|
||||||
heat: formatHeat(item.heatValue ?? item.countBrowse),
|
|
||||||
episodes: item.totalEpisode ? `${item.totalEpisode}集` : "",
|
|
||||||
badge: resolveContentBadge(item),
|
|
||||||
cover: (item.cover || "").trim(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 视频收藏列表项 → 卡片 */
|
|
||||||
export function mapFavoriteVideoItem(item: FavoriteVideoListItem): ShortDramaItem | null {
|
|
||||||
const id = Number(item.id);
|
|
||||||
if (!Number.isInteger(id) || id < 1) return null;
|
|
||||||
return {
|
|
||||||
kind: "drama",
|
|
||||||
id: String(id),
|
|
||||||
slug: item.slug,
|
|
||||||
title: (item.title || "").trim() || "未命名视频",
|
|
||||||
subtitle: "",
|
|
||||||
tags: pickVideoCardTags(item),
|
|
||||||
heat: formatHeat(item.watchNum),
|
|
||||||
episodes: "",
|
|
||||||
cover: (item.coverImg || "").trim(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||