From 4e05c7bcaa8829179c6703792877c084a72c484f Mon Sep 17 00:00:00 2001 From: mtvpls Date: Wed, 3 Dec 2025 18:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=84=E8=AE=BA=E5=BC=80?= =?UTF-8?q?=E5=85=B3=EF=BC=8C=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 +- pnpm-lock.yaml | 243 +++++++++++++++++------------- src/app/admin/page.tsx | 115 ++++++++++++++ src/app/api/admin/site/route.ts | 6 +- src/app/layout.tsx | 3 + src/app/play/page.tsx | 193 +++++++++++++----------- src/components/DoubanComments.tsx | 13 ++ src/components/Sidebar.tsx | 3 + src/hooks/useEnableComments.ts | 19 +++ src/lib/admin.types.ts | 2 + src/lib/config.ts | 7 + 11 files changed, 416 insertions(+), 194 deletions(-) create mode 100644 src/hooks/useEnableComments.ts diff --git a/package.json b/package.json index 238919d..3454a0e 100644 --- a/package.json +++ b/package.json @@ -40,11 +40,11 @@ "hls.js": "^1.6.10", "lucide-react": "^0.438.0", "media-icons": "^1.1.5", - "next": "^14.2.23", + "next": "^14.2.33", "next-pwa": "^5.6.0", "next-themes": "^0.4.6", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", "react-icons": "^5.4.0", "redis": "^4.6.7", "swiper": "^11.2.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 846dfe0..c8358f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -72,19 +72,19 @@ importers: specifier: ^1.1.5 version: 1.1.5 next: - specifier: ^14.2.23 - version: 14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + specifier: ^14.2.33 + version: 14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) next-pwa: specifier: ^5.6.0 - version: 5.6.0(@babel/core@7.27.4)(@types/babel__core@7.20.5)(next@14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(webpack@5.99.9) + version: 5.6.0(@babel/core@7.27.4)(@types/babel__core@7.20.5)(next@14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(webpack@5.99.9) next-themes: specifier: ^0.4.6 version: 0.4.6(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: - specifier: ^18.2.0 + specifier: ^18.3.1 version: 18.3.1 react-dom: - specifier: ^18.2.0 + specifier: ^18.3.1 version: 18.3.1(react@18.3.1) react-icons: specifier: ^5.4.0 @@ -176,7 +176,7 @@ importers: version: 12.5.0 next-router-mock: specifier: ^0.9.0 - version: 0.9.13(next@14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) + version: 0.9.13(next@14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) postcss: specifier: ^8.5.1 version: 8.5.6 @@ -1138,66 +1138,62 @@ packages: '@napi-rs/wasm-runtime@0.2.11': resolution: {integrity: sha512-9DPkXtvHydrcOsopiYpUgPHpmj0HWZKMUnL2dZqpvC42lsratuBG06V5ipyno0fUek5VlFsNQ+AcFATSrJXgMA==} - '@next/env@14.2.30': - resolution: {integrity: sha512-KBiBKrDY6kxTQWGzKjQB7QirL3PiiOkV7KW98leHFjtVRKtft76Ra5qSA/SL75xT44dp6hOcqiiJ6iievLOYug==} + '@next/env@14.2.33': + resolution: {integrity: sha512-CgVHNZ1fRIlxkLhIX22flAZI/HmpDaZ8vwyJ/B0SDPTBuLZ1PJ+DWMjCHhqnExfmSQzA/PbZi8OAc7PAq2w9IA==} '@next/eslint-plugin-next@14.2.30': resolution: {integrity: sha512-mvVsMIutMxQ4NGZEMZ1kiBNc+la8Xmlk30bKUmCPQz2eFkmsLv54Mha8QZarMaCtSPkkFA1TMD+FIZk0l/PpzA==} - '@next/swc-darwin-arm64@14.2.30': - resolution: {integrity: sha512-EAqfOTb3bTGh9+ewpO/jC59uACadRHM6TSA9DdxJB/6gxOpyV+zrbqeXiFTDy9uV6bmipFDkfpAskeaDcO+7/g==} + '@next/swc-darwin-arm64@14.2.33': + resolution: {integrity: sha512-HqYnb6pxlsshoSTubdXKu15g3iivcbsMXg4bYpjL2iS/V6aQot+iyF4BUc2qA/J/n55YtvE4PHMKWBKGCF/+wA==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@next/swc-darwin-x64@14.2.30': - resolution: {integrity: sha512-TyO7Wz1IKE2kGv8dwQ0bmPL3s44EKVencOqwIY69myoS3rdpO1NPg5xPM5ymKu7nfX4oYJrpMxv8G9iqLsnL4A==} + '@next/swc-darwin-x64@14.2.33': + resolution: {integrity: sha512-8HGBeAE5rX3jzKvF593XTTFg3gxeU4f+UWnswa6JPhzaR6+zblO5+fjltJWIZc4aUalqTclvN2QtTC37LxvZAA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@next/swc-linux-arm64-gnu@14.2.30': - resolution: {integrity: sha512-I5lg1fgPJ7I5dk6mr3qCH1hJYKJu1FsfKSiTKoYwcuUf53HWTrEkwmMI0t5ojFKeA6Vu+SfT2zVy5NS0QLXV4Q==} + '@next/swc-linux-arm64-gnu@14.2.33': + resolution: {integrity: sha512-JXMBka6lNNmqbkvcTtaX8Gu5by9547bukHQvPoLe9VRBx1gHwzf5tdt4AaezW85HAB3pikcvyqBToRTDA4DeLw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [glibc] - '@next/swc-linux-arm64-musl@14.2.30': - resolution: {integrity: sha512-8GkNA+sLclQyxgzCDs2/2GSwBc92QLMrmYAmoP2xehe5MUKBLB2cgo34Yu242L1siSkwQkiV4YLdCnjwc/Micw==} + '@next/swc-linux-arm64-musl@14.2.33': + resolution: {integrity: sha512-Bm+QulsAItD/x6Ih8wGIMfRJy4G73tu1HJsrccPW6AfqdZd0Sfm5Imhgkgq2+kly065rYMnCOxTBvmvFY1BKfg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [musl] - '@next/swc-linux-x64-gnu@14.2.30': - resolution: {integrity: sha512-8Ly7okjssLuBoe8qaRCcjGtcMsv79hwzn/63wNeIkzJVFVX06h5S737XNr7DZwlsbTBDOyI6qbL2BJB5n6TV/w==} + '@next/swc-linux-x64-gnu@14.2.33': + resolution: {integrity: sha512-FnFn+ZBgsVMbGDsTqo8zsnRzydvsGV8vfiWwUo1LD8FTmPTdV+otGSWKc4LJec0oSexFnCYVO4hX8P8qQKaSlg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [glibc] - '@next/swc-linux-x64-musl@14.2.30': - resolution: {integrity: sha512-dBmV1lLNeX4mR7uI7KNVHsGQU+OgTG5RGFPi3tBJpsKPvOPtg9poyav/BYWrB3GPQL4dW5YGGgalwZ79WukbKQ==} + '@next/swc-linux-x64-musl@14.2.33': + resolution: {integrity: sha512-345tsIWMzoXaQndUTDv1qypDRiebFxGYx9pYkhwY4hBRaOLt8UGfiWKr9FSSHs25dFIf8ZqIFaPdy5MljdoawA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [musl] - '@next/swc-win32-arm64-msvc@14.2.30': - resolution: {integrity: sha512-6MMHi2Qc1Gkq+4YLXAgbYslE1f9zMGBikKMdmQRHXjkGPot1JY3n5/Qrbg40Uvbi8//wYnydPnyvNhI1DMUW1g==} + '@next/swc-win32-arm64-msvc@14.2.33': + resolution: {integrity: sha512-nscpt0G6UCTkrT2ppnJnFsYbPDQwmum4GNXYTeoTIdsmMydSKFz9Iny2jpaRupTb+Wl298+Rh82WKzt9LCcqSQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@next/swc-win32-ia32-msvc@14.2.30': - resolution: {integrity: sha512-pVZMnFok5qEX4RT59mK2hEVtJX+XFfak+/rjHpyFh7juiT52r177bfFKhnlafm0UOSldhXjj32b+LZIOdswGTg==} + '@next/swc-win32-ia32-msvc@14.2.33': + resolution: {integrity: sha512-pc9LpGNKhJ0dXQhZ5QMmYxtARwwmWLpeocFmVG5Z0DzWq5Uf0izcI8tLc+qOpqxO1PWqZ5A7J1blrUIKrIFc7Q==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@next/swc-win32-x64-msvc@14.2.30': - resolution: {integrity: sha512-4KCo8hMZXMjpTzs3HOqOGYYwAXymXIy7PEPAXNEcEOyKqkjiDlECumrWziy+JEF0Oi4ILHGxzgQ3YiMGG2t/Lg==} + '@next/swc-win32-x64-msvc@14.2.33': + resolution: {integrity: sha512-nOjfZMy8B94MdisuzZo9/57xuFVLHJaDj5e/xrduJp9CV2/HrfxTRH2fbyLe+K9QT41WBLUd4iXX3R7jBp0EUg==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1587,8 +1583,8 @@ packages: '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} - '@types/validator@13.15.2': - resolution: {integrity: sha512-y7pa/oEJJ4iGYBxOpfAKn5b9+xuihvzDVnC/OSvlVnGxVg0pOqmjiMafiJ1KVNQEaPZf9HsEp5icEwGg8uIe5Q==} + '@types/validator@13.15.10': + resolution: {integrity: sha512-T8L6i7wCuyoK8A/ZeLYt1+q0ty3Zb9+qbSSvrIVitzT3YjZqkTZ40IbRsPanlB4h1QB3JVL1SYCdR6ngtFYcuA==} '@types/yargs-parser@21.0.3': resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} @@ -1699,49 +1695,41 @@ packages: resolution: {integrity: sha512-vdqBh911wc5awE2bX2zx3eflbyv8U9xbE/jVKAm425eRoOVv/VseGZsqi3A3SykckSpF4wSROkbQPvbQFn8EsA==} cpu: [arm64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-arm64-musl@1.9.0': resolution: {integrity: sha512-/8JFZ/SnuDr1lLEVsxsuVwrsGquTvT51RZGvyDB/dOK3oYK2UqeXzgeyq6Otp8FZXQcEYqJwxb9v+gtdXn03eQ==} cpu: [arm64] os: [linux] - libc: [musl] '@unrs/resolver-binding-linux-ppc64-gnu@1.9.0': resolution: {integrity: sha512-FkJjybtrl+rajTw4loI3L6YqSOpeZfDls4SstL/5lsP2bka9TiHUjgMBjygeZEis1oC8LfJTS8FSgpKPaQx2tQ==} cpu: [ppc64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-riscv64-gnu@1.9.0': resolution: {integrity: sha512-w/NZfHNeDusbqSZ8r/hp8iL4S39h4+vQMc9/vvzuIKMWKppyUGKm3IST0Qv0aOZ1rzIbl9SrDeIqK86ZpUK37w==} cpu: [riscv64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-riscv64-musl@1.9.0': resolution: {integrity: sha512-bEPBosut8/8KQbUixPry8zg/fOzVOWyvwzOfz0C0Rw6dp+wIBseyiHKjkcSyZKv/98edrbMknBaMNJfA/UEdqw==} cpu: [riscv64] os: [linux] - libc: [musl] '@unrs/resolver-binding-linux-s390x-gnu@1.9.0': resolution: {integrity: sha512-LDtMT7moE3gK753gG4pc31AAqGUC86j3AplaFusc717EUGF9ZFJ356sdQzzZzkBk1XzMdxFyZ4f/i35NKM/lFA==} cpu: [s390x] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-x64-gnu@1.9.0': resolution: {integrity: sha512-WmFd5KINHIXj8o1mPaT8QRjA9HgSXhN1gl9Da4IZihARihEnOylu4co7i/yeaIpcfsI6sYs33cNZKyHYDh0lrA==} cpu: [x64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-x64-musl@1.9.0': resolution: {integrity: sha512-CYuXbANW+WgzVRIl8/QvZmDaZxrqvOldOwlbUjIM4pQ46FJ0W5cinJ/Ghwa/Ng1ZPMJMk1VFdsD/XwmCGIXBWg==} cpu: [x64] os: [linux] - libc: [musl] '@unrs/resolver-binding-wasm32-wasi@1.9.0': resolution: {integrity: sha512-6Rp2WH0OoitMYR57Z6VE8Y6corX8C6QEMWLgOV6qXiJIeZ1F9WGXY/yQ8yDC4iTraotyLOeJ2Asea0urWj2fKQ==} @@ -2118,6 +2106,10 @@ packages: base-x@5.0.1: resolution: {integrity: sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==} + baseline-browser-mapping@2.8.32: + resolution: {integrity: sha512-OPz5aBThlyLFgxyhdwf/s2+8ab3OvT7AdTNvKHBwpXomIYeXqpUUuT8LrdtxZSsWJ4R4CU1un4XGh5Ez3nlTpw==} + hasBin: true + big.js@5.2.2: resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==} @@ -2146,8 +2138,8 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true - browserslist@4.25.2: - resolution: {integrity: sha512-0si2SJK3ooGzIawRu61ZdPCO1IncZwS8IzuX73sPZsXW6EQ/w/DAfPyKI8l1ETTCr2MnvqWitmlCUxgdul45jA==} + browserslist@4.28.0: + resolution: {integrity: sha512-tbydkR/CxfMwelN0vwdP/pLkDwyAASZ+VfWm4EOwlB6SWhx1sYnWLqo8N5j0rAzPfzfRaxt0mM/4wPU/Su84RQ==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true @@ -2203,8 +2195,8 @@ packages: caniuse-lite@1.0.30001723: resolution: {integrity: sha512-1R/elMjtehrFejxwmexeXAtae5UO9iSyFn6G/I806CYC/BLyyBk1EPhrKBkWhy6wM6Xnm47dSJQec+tLJ39WHw==} - caniuse-lite@1.0.30001734: - resolution: {integrity: sha512-uhE1Ye5vgqju6OI71HTQqcBCZrvHugk0MjLak7Q+HfoBgoq5Bi+5YnwjP4fjDgrtYr/l8MVRBvzz9dPD4KyK0A==} + caniuse-lite@1.0.30001759: + resolution: {integrity: sha512-Pzfx9fOKoKvevQf8oCXoyNRQ5QyxJj+3O0Rqx2V5oxT61KGx8+n6hV/IUyJeifUci2clnmmKVpvtiqRzgiWjSw==} chalk@3.0.0: resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==} @@ -2600,8 +2592,8 @@ packages: electron-to-chromium@1.5.168: resolution: {integrity: sha512-RUNQmFLNIWVW6+z32EJQ5+qx8ci6RGvdtDC0Ls+F89wz6I2AthpXF0w0DIrn2jpLX0/PU9ZCo+Qp7bg/EckJmA==} - electron-to-chromium@1.5.199: - resolution: {integrity: sha512-3gl0S7zQd88kCAZRO/DnxtBKuhMO4h0EaQIN3YgZfV6+pW+5+bf2AdQeHNESCoaQqo/gjGVYEf2YM4O5HJQqpQ==} + electron-to-chromium@1.5.263: + resolution: {integrity: sha512-DrqJ11Knd+lo+dv+lltvfMDLU27g14LMdH2b0O3Pio4uk0x+z7OR+JrmyacTPN2M8w3BrZ7/RTwG3R9B7irPlg==} emittery@0.8.1: resolution: {integrity: sha512-uDfvUjVrfGJJhymx/kz6prltenw1u7WrCg1oa94zYY8xxVpLLUu045LAT0dhDZdXG58/EpPL/5kA180fQ/qudg==} @@ -2982,6 +2974,10 @@ packages: functions-have-names@1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} + generator-function@2.0.1: + resolution: {integrity: sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==} + engines: {node: '>= 0.4'} + generic-pool@3.9.0: resolution: {integrity: sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==} engines: {node: '>= 4'} @@ -3277,6 +3273,10 @@ packages: resolution: {integrity: sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ==} engines: {node: '>= 0.4'} + is-generator-function@1.1.2: + resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} + engines: {node: '>= 0.4'} + is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -3709,8 +3709,8 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} - libphonenumber-js@1.12.13: - resolution: {integrity: sha512-QZXnR/OGiDcBjF4hGk0wwVrPcZvbSSyzlvkjXv5LFfktj7O2VZDrt4Xs8SgR/vOFco+qk1i8J43ikMXZoTrtPw==} + libphonenumber-js@1.12.31: + resolution: {integrity: sha512-Z3IhgVgrqO1S5xPYM3K5XwbkDasU67/Vys4heW+lfSBALcUZjeIIzI8zCLifY+OCzSq+fpDdywMDa7z+4srJPQ==} lilconfig@2.0.5: resolution: {integrity: sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==} @@ -3737,8 +3737,8 @@ packages: enquirer: optional: true - loader-runner@4.3.0: - resolution: {integrity: sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==} + loader-runner@4.3.1: + resolution: {integrity: sha512-IWqP2SCPhyVFTBtRcgMHdzlf9ul25NwaFx4wCEH/KjAXuuHY4yNjvPXsBokp8jCB936PyWRaPKUNh8NvylLp2Q==} engines: {node: '>=6.11.5'} loader-utils@2.0.4: @@ -3966,8 +3966,8 @@ packages: react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc - next@14.2.30: - resolution: {integrity: sha512-+COdu6HQrHHFQ1S/8BBsCag61jZacmvbuL2avHvQFbWa2Ox7bE+d8FyNgxRLjXQ5wtPyQwEmk85js/AuaG2Sbg==} + next@14.2.33: + resolution: {integrity: sha512-GiKHLsD00t4ACm1p00VgrI0rUFAC9cRDGReKyERlM57aeEZkOQGcZTpIbsGn0b562FTPJWmYfKwplfO9EaT6ng==} engines: {node: '>=18.17.0'} hasBin: true peerDependencies: @@ -3993,6 +3993,9 @@ packages: node-releases@2.0.19: resolution: {integrity: sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==} + node-releases@2.0.27: + resolution: {integrity: sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==} + normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} @@ -4558,6 +4561,10 @@ packages: resolution: {integrity: sha512-Gn/JaSk/Mt9gYubxTtSn/QCV4em9mpAPiR1rqy/Ocu19u/G9J5WWdNoUT4SiV6mFC3y6cxyFcFwdzPM3FgxGAQ==} engines: {node: '>= 10.13.0'} + schema-utils@4.3.3: + resolution: {integrity: sha512-eflK8wEtyOE6+hsaRVPxvUKYCpRgzLqDTb8krvAsRIwOGlHoSgYLgBXoubGgLd2fT41/OUYdb48v4k4WWHQurA==} + engines: {node: '>= 10.13.0'} + semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -4858,8 +4865,8 @@ packages: engines: {node: '>=14.0.0'} hasBin: true - tapable@2.2.2: - resolution: {integrity: sha512-Re10+NauLTMCudc7T5WLFLAwDhQ0JWdrMK+9B2M8zR5hRExKmsRDCBA7/aV/pNJFltmBFO5BAMlQFi/vq3nKOg==} + tapable@2.3.0: + resolution: {integrity: sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==} engines: {node: '>=6'} temp-dir@2.0.0: @@ -5102,6 +5109,12 @@ packages: peerDependencies: browserslist: '>= 4.21.0' + update-browserslist-db@1.1.4: + resolution: {integrity: sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} @@ -5129,8 +5142,8 @@ packages: validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} - validator@13.15.15: - resolution: {integrity: sha512-BgWVbCI72aIQy937xbawcs+hrVaN/CZ2UwutgaJ36hGqRrLNM+f5LUT/YPRbo8IV/ASeFzXszezV+y2+rq3l8A==} + validator@13.15.23: + resolution: {integrity: sha512-4yoz1kEWqUjzi5zsPbAS/903QXSYp0UOtHsPpp7p9rHAw/W+dkInskAE386Fat3oKRROwO98d9ZB0G4cObgUyw==} engines: {node: '>= 0.10'} vidstack@0.6.15: @@ -6654,37 +6667,37 @@ snapshots: '@tybys/wasm-util': 0.9.0 optional: true - '@next/env@14.2.30': {} + '@next/env@14.2.33': {} '@next/eslint-plugin-next@14.2.30': dependencies: glob: 10.3.10 - '@next/swc-darwin-arm64@14.2.30': + '@next/swc-darwin-arm64@14.2.33': optional: true - '@next/swc-darwin-x64@14.2.30': + '@next/swc-darwin-x64@14.2.33': optional: true - '@next/swc-linux-arm64-gnu@14.2.30': + '@next/swc-linux-arm64-gnu@14.2.33': optional: true - '@next/swc-linux-arm64-musl@14.2.30': + '@next/swc-linux-arm64-musl@14.2.33': optional: true - '@next/swc-linux-x64-gnu@14.2.30': + '@next/swc-linux-x64-gnu@14.2.33': optional: true - '@next/swc-linux-x64-musl@14.2.30': + '@next/swc-linux-x64-musl@14.2.33': optional: true - '@next/swc-win32-arm64-msvc@14.2.30': + '@next/swc-win32-arm64-msvc@14.2.33': optional: true - '@next/swc-win32-ia32-msvc@14.2.30': + '@next/swc-win32-ia32-msvc@14.2.33': optional: true - '@next/swc-win32-x64-msvc@14.2.30': + '@next/swc-win32-x64-msvc@14.2.33': optional: true '@nodelib/fs.scandir@2.1.5': @@ -7115,7 +7128,7 @@ snapshots: '@types/trusted-types@2.0.7': {} - '@types/validator@13.15.2': {} + '@types/validator@13.15.10': {} '@types/yargs-parser@21.0.3': {} @@ -7695,6 +7708,8 @@ snapshots: base-x@5.0.1: {} + baseline-browser-mapping@2.8.32: {} + big.js@5.2.2: {} binary-extensions@2.3.0: {} @@ -7723,12 +7738,13 @@ snapshots: node-releases: 2.0.19 update-browserslist-db: 1.1.3(browserslist@4.25.0) - browserslist@4.25.2: + browserslist@4.28.0: dependencies: - caniuse-lite: 1.0.30001734 - electron-to-chromium: 1.5.199 - node-releases: 2.0.19 - update-browserslist-db: 1.1.3(browserslist@4.25.2) + baseline-browser-mapping: 2.8.32 + caniuse-lite: 1.0.30001759 + electron-to-chromium: 1.5.263 + node-releases: 2.0.27 + update-browserslist-db: 1.1.4(browserslist@4.28.0) bs58@6.0.0: dependencies: @@ -7779,7 +7795,7 @@ snapshots: caniuse-lite@1.0.30001723: {} - caniuse-lite@1.0.30001734: {} + caniuse-lite@1.0.30001759: {} chalk@3.0.0: dependencies: @@ -7842,9 +7858,9 @@ snapshots: class-validator@0.14.1: dependencies: - '@types/validator': 13.15.2 - libphonenumber-js: 1.12.13 - validator: 13.15.15 + '@types/validator': 13.15.10 + libphonenumber-js: 1.12.31 + validator: 13.15.23 clean-stack@2.2.0: {} @@ -8177,7 +8193,7 @@ snapshots: electron-to-chromium@1.5.168: {} - electron-to-chromium@1.5.199: {} + electron-to-chromium@1.5.263: {} emittery@0.8.1: {} @@ -8195,7 +8211,7 @@ snapshots: enhanced-resolve@5.18.3: dependencies: graceful-fs: 4.2.11 - tapable: 2.2.2 + tapable: 2.3.0 entities@4.5.0: {} @@ -8709,6 +8725,8 @@ snapshots: functions-have-names@1.2.3: {} + generator-function@2.0.1: {} + generic-pool@3.9.0: {} gensync@1.0.0-beta.2: {} @@ -9016,6 +9034,14 @@ snapshots: has-tostringtag: 1.0.2 safe-regex-test: 1.1.0 + is-generator-function@1.1.2: + dependencies: + call-bound: 1.0.4 + generator-function: 2.0.1 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + is-glob@4.0.3: dependencies: is-extglob: 2.1.1 @@ -9718,7 +9744,7 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 - libphonenumber-js@1.12.13: {} + libphonenumber-js@1.12.31: {} lilconfig@2.0.5: {} @@ -9756,7 +9782,7 @@ snapshots: through: 2.3.8 wrap-ansi: 7.0.0 - loader-runner@4.3.0: {} + loader-runner@4.3.1: {} loader-utils@2.0.4: dependencies: @@ -9951,12 +9977,12 @@ snapshots: neo-async@2.6.2: {} - next-pwa@5.6.0(@babel/core@7.27.4)(@types/babel__core@7.20.5)(next@14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(webpack@5.99.9): + next-pwa@5.6.0(@babel/core@7.27.4)(@types/babel__core@7.20.5)(next@14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(webpack@5.99.9): dependencies: babel-loader: 8.4.1(@babel/core@7.27.4)(webpack@5.99.9) clean-webpack-plugin: 4.0.0(webpack@5.99.9) globby: 11.1.0 - next: 14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + next: 14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) terser-webpack-plugin: 5.3.14(webpack@5.99.9) workbox-webpack-plugin: 6.6.0(@types/babel__core@7.20.5)(webpack@5.99.9) workbox-window: 6.6.0 @@ -9969,9 +9995,9 @@ snapshots: - uglify-js - webpack - next-router-mock@0.9.13(next@14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1): + next-router-mock@0.9.13(next@14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1): dependencies: - next: 14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + next: 14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: 18.3.1 next-themes@0.4.6(react-dom@18.3.1(react@18.3.1))(react@18.3.1): @@ -9979,9 +10005,9 @@ snapshots: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - next@14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + next@14.2.33(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: - '@next/env': 14.2.30 + '@next/env': 14.2.33 '@swc/helpers': 0.5.5 busboy: 1.6.0 caniuse-lite: 1.0.30001723 @@ -9991,15 +10017,15 @@ snapshots: react-dom: 18.3.1(react@18.3.1) styled-jsx: 5.1.1(@babel/core@7.27.4)(react@18.3.1) optionalDependencies: - '@next/swc-darwin-arm64': 14.2.30 - '@next/swc-darwin-x64': 14.2.30 - '@next/swc-linux-arm64-gnu': 14.2.30 - '@next/swc-linux-arm64-musl': 14.2.30 - '@next/swc-linux-x64-gnu': 14.2.30 - '@next/swc-linux-x64-musl': 14.2.30 - '@next/swc-win32-arm64-msvc': 14.2.30 - '@next/swc-win32-ia32-msvc': 14.2.30 - '@next/swc-win32-x64-msvc': 14.2.30 + '@next/swc-darwin-arm64': 14.2.33 + '@next/swc-darwin-x64': 14.2.33 + '@next/swc-linux-arm64-gnu': 14.2.33 + '@next/swc-linux-arm64-musl': 14.2.33 + '@next/swc-linux-x64-gnu': 14.2.33 + '@next/swc-linux-x64-musl': 14.2.33 + '@next/swc-win32-arm64-msvc': 14.2.33 + '@next/swc-win32-ia32-msvc': 14.2.33 + '@next/swc-win32-x64-msvc': 14.2.33 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros @@ -10013,6 +10039,8 @@ snapshots: node-releases@2.0.19: {} + node-releases@2.0.27: {} + normalize-package-data@2.5.0: dependencies: hosted-git-info: 2.8.9 @@ -10541,6 +10569,13 @@ snapshots: ajv-formats: 2.1.1(ajv@8.17.1) ajv-keywords: 5.1.0(ajv@8.17.1) + schema-utils@4.3.3: + dependencies: + '@types/json-schema': 7.0.15 + ajv: 8.17.1 + ajv-formats: 2.1.1(ajv@8.17.1) + ajv-keywords: 5.1.0(ajv@8.17.1) + semver@5.7.2: {} semver@6.3.1: {} @@ -10889,7 +10924,7 @@ snapshots: transitivePeerDependencies: - ts-node - tapable@2.2.2: {} + tapable@2.3.0: {} temp-dir@2.0.0: {} @@ -11140,9 +11175,9 @@ snapshots: escalade: 3.2.0 picocolors: 1.1.1 - update-browserslist-db@1.1.3(browserslist@4.25.2): + update-browserslist-db@1.1.4(browserslist@4.28.0): dependencies: - browserslist: 4.25.2 + browserslist: 4.28.0 escalade: 3.2.0 picocolors: 1.1.1 @@ -11165,7 +11200,7 @@ snapshots: dependencies: inherits: 2.0.4 is-arguments: 1.2.0 - is-generator-function: 1.1.0 + is-generator-function: 1.1.2 is-typed-array: 1.1.15 which-typed-array: 1.1.19 @@ -11182,7 +11217,7 @@ snapshots: spdx-correct: 3.2.0 spdx-expression-parse: 3.0.1 - validator@13.15.15: {} + validator@13.15.23: {} vidstack@0.6.15: dependencies: @@ -11243,7 +11278,7 @@ snapshots: '@webassemblyjs/wasm-edit': 1.14.1 '@webassemblyjs/wasm-parser': 1.14.1 acorn: 8.15.0 - browserslist: 4.25.2 + browserslist: 4.28.0 chrome-trace-event: 1.0.4 enhanced-resolve: 5.18.3 es-module-lexer: 1.7.0 @@ -11252,11 +11287,11 @@ snapshots: glob-to-regexp: 0.4.1 graceful-fs: 4.2.11 json-parse-even-better-errors: 2.3.1 - loader-runner: 4.3.0 + loader-runner: 4.3.1 mime-types: 2.1.35 neo-async: 2.6.2 - schema-utils: 4.3.2 - tapable: 2.2.2 + schema-utils: 4.3.3 + tapable: 2.3.0 terser-webpack-plugin: 5.3.14(webpack@5.99.9) watchpack: 2.4.4 webpack-sources: 3.3.3 diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 9780be5..4c8f799 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -269,6 +269,7 @@ interface SiteConfig { FluidSearch: boolean; DanmakuApiBase: string; DanmakuApiToken: string; + EnableComments: boolean; } // 视频源数据类型 @@ -3384,6 +3385,7 @@ const ConfigFileComponent = ({ config, refreshConfig }: { config: AdminConfig | const SiteConfigComponent = ({ config, refreshConfig }: { config: AdminConfig | null; refreshConfig: () => Promise }) => { const { alertModal, showAlert, hideAlert } = useAlertModal(); const { isLoading, withLoading } = useLoadingState(); + const [showEnableCommentsModal, setShowEnableCommentsModal] = useState(false); const [siteSettings, setSiteSettings] = useState({ SiteName: '', Announcement: '', @@ -3397,6 +3399,7 @@ const SiteConfigComponent = ({ config, refreshConfig }: { config: AdminConfig | FluidSearch: true, DanmakuApiBase: 'http://localhost:9321', DanmakuApiToken: '87654321', + EnableComments: false, }); // 豆瓣数据源相关状态 @@ -3461,6 +3464,7 @@ const SiteConfigComponent = ({ config, refreshConfig }: { config: AdminConfig | FluidSearch: config.SiteConfig.FluidSearch || true, DanmakuApiBase: config.SiteConfig.DanmakuApiBase || 'http://localhost:9321', DanmakuApiToken: config.SiteConfig.DanmakuApiToken || '87654321', + EnableComments: config.SiteConfig.EnableComments || false, }); } }, [config]); @@ -3516,6 +3520,29 @@ const SiteConfigComponent = ({ config, refreshConfig }: { config: AdminConfig | })); }; + // 处理评论开关变化 + const handleCommentsToggle = (checked: boolean) => { + if (checked) { + // 如果要开启评论,弹出确认框 + setShowEnableCommentsModal(true); + } else { + // 直接关闭评论 + setSiteSettings((prev) => ({ + ...prev, + EnableComments: false, + })); + } + }; + + // 确认开启评论 + const handleConfirmEnableComments = () => { + setSiteSettings((prev) => ({ + ...prev, + EnableComments: true, + })); + setShowEnableCommentsModal(false); + }; + // 保存站点配置 const handleSave = async () => { await withLoading('saveSiteConfig', async () => { @@ -3964,6 +3991,40 @@ const SiteConfigComponent = ({ config, refreshConfig }: { config: AdminConfig | + {/* 评论功能配置 */} +
+

+ 评论配置 +

+ + {/* 开启评论 */} +
+
+ + +
+

+ 开启后将显示豆瓣评论。评论为逆向抓取,请自行承担责任。 +

+
+
+ {/* 操作按钮 */}
+
+ +
+
+
+ + + 重要提示 + +
+

+ 评论功能为逆向抓取豆瓣评论数据,开启后请自行承担相关责任和风险。 +

+
+
+ + {/* 操作按钮 */} +
+ + +
+ + + , + document.body + )} ); }; diff --git a/src/app/api/admin/site/route.ts b/src/app/api/admin/site/route.ts index 42c8cf3..19e68da 100644 --- a/src/app/api/admin/site/route.ts +++ b/src/app/api/admin/site/route.ts @@ -41,6 +41,7 @@ export async function POST(request: NextRequest) { FluidSearch, DanmakuApiBase, DanmakuApiToken, + EnableComments, } = body as { SiteName: string; Announcement: string; @@ -54,6 +55,7 @@ export async function POST(request: NextRequest) { FluidSearch: boolean; DanmakuApiBase: string; DanmakuApiToken: string; + EnableComments: boolean; }; // 参数校验 @@ -69,7 +71,8 @@ export async function POST(request: NextRequest) { typeof DisableYellowFilter !== 'boolean' || typeof FluidSearch !== 'boolean' || typeof DanmakuApiBase !== 'string' || - typeof DanmakuApiToken !== 'string' + typeof DanmakuApiToken !== 'string' || + typeof EnableComments !== 'boolean' ) { return NextResponse.json({ error: '参数格式错误' }, { status: 400 }); } @@ -101,6 +104,7 @@ export async function POST(request: NextRequest) { FluidSearch, DanmakuApiBase, DanmakuApiToken, + EnableComments, }; // 写入数据库 diff --git a/src/app/layout.tsx b/src/app/layout.tsx index e24fcea..f52160c 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -54,6 +54,7 @@ export default async function RootLayout({ let disableYellowFilter = process.env.NEXT_PUBLIC_DISABLE_YELLOW_FILTER === 'true'; let fluidSearch = process.env.NEXT_PUBLIC_FLUID_SEARCH !== 'false'; + let enableComments = false; let customCategories = [] as { name: string; type: 'movie' | 'tv'; @@ -77,6 +78,7 @@ export default async function RootLayout({ query: category.query, })); fluidSearch = config.SiteConfig.FluidSearch; + enableComments = config.SiteConfig.EnableComments; } // 将运行时配置注入到全局 window 对象,供客户端在运行时读取 @@ -89,6 +91,7 @@ export default async function RootLayout({ DISABLE_YELLOW_FILTER: disableYellowFilter, CUSTOM_CATEGORIES: customCategories, FLUID_SEARCH: fluidSearch, + EnableComments: enableComments, }; return ( diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 9ce544f..114b35a 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -41,6 +41,7 @@ import { getVideoResolutionFromM3u8, processImageUrl } from '@/lib/utils'; import EpisodeSelector from '@/components/EpisodeSelector'; import PageLayout from '@/components/PageLayout'; import DoubanComments from '@/components/DoubanComments'; +import { useEnableComments } from '@/hooks/useEnableComments'; // 扩展 HTMLVideoElement 类型以支持 hls 属性 declare global { @@ -60,6 +61,7 @@ interface WakeLockSentinel { function PlayPageClient() { const router = useRouter(); const searchParams = useSearchParams(); + const enableComments = useEnableComments(); // ----------------------------------------------------------------------------- // 状态变量(State) @@ -597,13 +599,17 @@ function PlayPageClient() { try { // 在销毁前从弹幕插件读取最新配置并保存 if (danmakuPluginRef.current?.option && artPlayerRef.current.storage) { + // 获取当前弹幕设置的快照,避免循环引用 + const currentDanmakuSettings = danmakuSettingsRef.current; + const danmakuPluginOption = danmakuPluginRef.current.option; + const currentSettings = { - ...danmakuSettingsRef.current, - opacity: danmakuPluginRef.current.option.opacity || danmakuSettingsRef.current.opacity, - fontSize: danmakuPluginRef.current.option.fontSize || danmakuSettingsRef.current.fontSize, - speed: danmakuPluginRef.current.option.speed || danmakuSettingsRef.current.speed, - marginTop: (danmakuPluginRef.current.option.margin && danmakuPluginRef.current.option.margin[0]) ?? danmakuSettingsRef.current.marginTop, - marginBottom: (danmakuPluginRef.current.option.margin && danmakuPluginRef.current.option.margin[1]) ?? danmakuSettingsRef.current.marginBottom, + ...currentDanmakuSettings, + opacity: danmakuPluginOption.opacity || currentDanmakuSettings.opacity, + fontSize: danmakuPluginOption.fontSize || currentDanmakuSettings.fontSize, + speed: danmakuPluginOption.speed || currentDanmakuSettings.speed, + marginTop: (danmakuPluginOption.margin && danmakuPluginOption.margin[0]) ?? currentDanmakuSettings.marginTop, + marginBottom: (danmakuPluginOption.margin && danmakuPluginOption.margin[1]) ?? currentDanmakuSettings.marginBottom, }; // 保存到 localStorage 和 art.storage @@ -901,63 +907,71 @@ function PlayPageClient() { setSkipConfig(newConfig); if (!newConfig.enable && !newConfig.intro_time && !newConfig.outro_time) { await deleteSkipConfig(currentSourceRef.current, currentIdRef.current); - artPlayerRef.current.setting.update({ - name: '跳过片头片尾', - html: '跳过片头片尾', - switch: skipConfigRef.current.enable, - onSwitch: function (item: any) { - const newConfig = { - ...skipConfigRef.current, - enable: !item.switch, - }; - handleSkipConfigChange(newConfig); - return !item.switch; - }, - }); - artPlayerRef.current.setting.update({ - name: '设置片头', - html: '设置片头', - icon: '', - tooltip: - skipConfigRef.current.intro_time === 0 - ? '设置片头时间' - : `${formatTime(skipConfigRef.current.intro_time)}`, - onClick: function () { - const currentTime = artPlayerRef.current?.currentTime || 0; - if (currentTime > 0) { - const newConfig = { - ...skipConfigRef.current, - intro_time: currentTime, - }; - handleSkipConfigChange(newConfig); - return `${formatTime(currentTime)}`; - } - }, - }); - artPlayerRef.current.setting.update({ - name: '设置片尾', - html: '设置片尾', - icon: '', - tooltip: - skipConfigRef.current.outro_time >= 0 - ? '设置片尾时间' - : `-${formatTime(-skipConfigRef.current.outro_time)}`, - onClick: function () { - const outroTime = - -( - artPlayerRef.current?.duration - - artPlayerRef.current?.currentTime - ) || 0; - if (outroTime < 0) { - const newConfig = { - ...skipConfigRef.current, - outro_time: outroTime, - }; - handleSkipConfigChange(newConfig); - return `-${formatTime(-outroTime)}`; - } - }, - }); + + // 安全地更新播放器设置,仅在播放器存在时执行 + if (artPlayerRef.current && artPlayerRef.current.setting) { + try { + artPlayerRef.current.setting.update({ + name: '跳过片头片尾', + html: '跳过片头片尾', + switch: skipConfigRef.current.enable, + onSwitch: function (item: any) { + const newConfig = { + ...skipConfigRef.current, + enable: !item.switch, + }; + handleSkipConfigChange(newConfig); + return !item.switch; + }, + }); + artPlayerRef.current.setting.update({ + name: '设置片头', + html: '设置片头', + icon: '', + tooltip: + skipConfigRef.current.intro_time === 0 + ? '设置片头时间' + : `${formatTime(skipConfigRef.current.intro_time)}`, + onClick: function () { + const currentTime = artPlayerRef.current?.currentTime || 0; + if (currentTime > 0) { + const newConfig = { + ...skipConfigRef.current, + intro_time: currentTime, + }; + handleSkipConfigChange(newConfig); + return `${formatTime(currentTime)}`; + } + }, + }); + artPlayerRef.current.setting.update({ + name: '设置片尾', + html: '设置片尾', + icon: '', + tooltip: + skipConfigRef.current.outro_time >= 0 + ? '设置片尾时间' + : `-${formatTime(-skipConfigRef.current.outro_time)}`, + onClick: function () { + const outroTime = + -( + artPlayerRef.current?.duration - + artPlayerRef.current?.currentTime + ) || 0; + if (outroTime < 0) { + const newConfig = { + ...skipConfigRef.current, + outro_time: outroTime, + }; + handleSkipConfigChange(newConfig); + return `-${formatTime(-outroTime)}`; + } + }, + }); + } catch (settingErr) { + console.warn('更新播放器设置失败:', settingErr); + } + } } else { await saveSkipConfig( currentSourceRef.current, @@ -1828,7 +1842,7 @@ function PlayPageClient() { window.removeEventListener('beforeunload', handleBeforeUnload); document.removeEventListener('visibilitychange', handleVisibilityChange); }; - }, [currentEpisodeIndex, detail, artPlayerRef.current]); + }, [currentEpisodeIndex, detail]); // 清理定时器 useEffect(() => { @@ -2231,15 +2245,20 @@ function PlayPageClient() { ? '设置片头时间' : `${formatTime(skipConfigRef.current.intro_time)}`, onClick: function () { - const currentTime = artPlayerRef.current?.currentTime || 0; - if (currentTime > 0) { - const newConfig = { - ...skipConfigRef.current, - intro_time: currentTime, - }; - handleSkipConfigChange(newConfig); - return `${formatTime(currentTime)}`; + // 安全地获取当前播放时间,避免循环依赖 + const player = artPlayerRef.current; + if (player && player.currentTime) { + const currentTime = player.currentTime || 0; + if (currentTime > 0) { + const newConfig = { + ...skipConfigRef.current, + intro_time: currentTime, + }; + handleSkipConfigChange(newConfig); + return `${formatTime(currentTime)}`; + } } + return ''; }, }, { @@ -2251,19 +2270,21 @@ function PlayPageClient() { ? '设置片尾时间' : `-${formatTime(-skipConfigRef.current.outro_time)}`, onClick: function () { - const outroTime = - -( - artPlayerRef.current?.duration - - artPlayerRef.current?.currentTime - ) || 0; - if (outroTime < 0) { - const newConfig = { - ...skipConfigRef.current, - outro_time: outroTime, - }; - handleSkipConfigChange(newConfig); - return `-${formatTime(-outroTime)}`; + // 安全地获取播放器时长和当前时间,避免循环依赖 + const player = artPlayerRef.current; + if (player && player.duration && player.currentTime) { + const outroTime = + -(player.duration - player.currentTime) || 0; + if (outroTime < 0) { + const newConfig = { + ...skipConfigRef.current, + outro_time: outroTime, + }; + handleSkipConfigChange(newConfig); + return `-${formatTime(-outroTime)}`; + } } + return ''; }, }, ], @@ -2496,7 +2517,7 @@ function PlayPageClient() { console.error('创建播放器失败:', err); setError('播放器初始化失败'); } - }, [Artplayer, Hls, videoUrl, loading, blockAdEnabled]); + }, [videoUrl, loading, blockAdEnabled, currentEpisodeIndex, detail]); // 当组件卸载时清理定时器、Wake Lock 和播放器资源 useEffect(() => { @@ -3283,7 +3304,7 @@ function PlayPageClient() { {/* 豆瓣评论区域 */} - {videoDoubanId !== 0 && ( + {videoDoubanId !== 0 && enableComments && (
{/* 标题 */} diff --git a/src/components/DoubanComments.tsx b/src/components/DoubanComments.tsx index bb43fdf..af4633f 100644 --- a/src/components/DoubanComments.tsx +++ b/src/components/DoubanComments.tsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect, useState, useCallback } from 'react'; +import { useEnableComments } from '@/hooks/useEnableComments'; interface DoubanComment { id: string; @@ -17,6 +18,11 @@ interface DoubanCommentsProps { doubanId: number; } +// 获取运行时配置的类型 +interface RuntimeConfig { + EnableComments: boolean; +} + export default function DoubanComments({ doubanId }: DoubanCommentsProps) { const [comments, setComments] = useState([]); const [loading, setLoading] = useState(false); @@ -26,6 +32,13 @@ export default function DoubanComments({ doubanId }: DoubanCommentsProps) { const [hasStartedLoading, setHasStartedLoading] = useState(false); const limit = 20; + const enableComments = useEnableComments(); + + // 如果评论功能被禁用,不显示任何内容 + if (!enableComments) { + return null; + } + const fetchComments = useCallback(async (startIndex: number) => { try { console.log('正在获取评论,起始位置:', startIndex); diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 7063300..512dc85 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -50,6 +50,9 @@ interface SidebarProps { declare global { interface Window { __sidebarCollapsed?: boolean; + RUNTIME_CONFIG?: { + EnableComments: boolean; + }; } } diff --git a/src/hooks/useEnableComments.ts b/src/hooks/useEnableComments.ts new file mode 100644 index 0000000..612443c --- /dev/null +++ b/src/hooks/useEnableComments.ts @@ -0,0 +1,19 @@ +import { useState, useEffect } from 'react'; + +interface RuntimeConfig { + EnableComments: boolean; +} + +export function useEnableComments(): boolean { + const [enableComments, setEnableComments] = useState(true); + + useEffect(() => { + // 在客户端获取运行时配置 + if (typeof window !== 'undefined') { + const runtimeConfig = (window as any).RUNTIME_CONFIG as RuntimeConfig; + setEnableComments(runtimeConfig?.EnableComments ?? true); + } + }, []); + + return enableComments; +} \ No newline at end of file diff --git a/src/lib/admin.types.ts b/src/lib/admin.types.ts index 719d5e2..b621cfc 100644 --- a/src/lib/admin.types.ts +++ b/src/lib/admin.types.ts @@ -19,6 +19,8 @@ export interface AdminConfig { // 弹幕配置 DanmakuApiBase: string; DanmakuApiToken: string; + // 评论功能开关 + EnableComments: boolean; }; UserConfig: { Users: { diff --git a/src/lib/config.ts b/src/lib/config.ts index 07bdb79..7176878 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -221,6 +221,8 @@ async function getInitConfig(configFile: string, subConfig: { // 弹幕配置 DanmakuApiBase: process.env.DANMAKU_API_BASE || 'http://localhost:9321', DanmakuApiToken: process.env.DANMAKU_API_TOKEN || '87654321', + // 评论功能开关 + EnableComments: false, }, UserConfig: { Users: [], @@ -332,6 +334,7 @@ export function configSelfCheck(adminConfig: AdminConfig): AdminConfig { FluidSearch: true, DanmakuApiBase: 'http://localhost:9321', DanmakuApiToken: '87654321', + EnableComments: false, }; } // 确保弹幕配置存在 @@ -341,6 +344,10 @@ export function configSelfCheck(adminConfig: AdminConfig): AdminConfig { if (!adminConfig.SiteConfig.DanmakuApiToken) { adminConfig.SiteConfig.DanmakuApiToken = '87654321'; } + // 确保评论开关存在 + if (adminConfig.SiteConfig.EnableComments === undefined) { + adminConfig.SiteConfig.EnableComments = false; + } if (!adminConfig.UserConfig) { adminConfig.UserConfig = { Users: [] }; }