diff --git a/VERSION.txt b/VERSION.txt index 52f72b5..01024e5 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -20250806101311 \ No newline at end of file +20250806184440 \ No newline at end of file diff --git a/package.json b/package.json index f276683..25591ec 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "artplayer": "^5.2.3", "clsx": "^2.0.0", "framer-motion": "^12.18.1", + "he": "^1.2.0", "hls.js": "^1.6.6", "lucide-react": "^0.438.0", "media-icons": "^1.1.5", @@ -56,6 +57,7 @@ "@tailwindcss/forms": "^0.5.10", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^15.0.7", + "@types/he": "^1.2.3", "@types/node": "24.0.3", "@types/react": "^18.3.18", "@types/react-dom": "^19.1.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 20569b3..0886074 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: framer-motion: specifier: ^12.18.1 version: 12.18.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + he: + specifier: ^1.2.0 + version: 1.2.0 hls.js: specifier: ^1.6.6 version: 1.6.6 @@ -108,6 +111,9 @@ importers: '@testing-library/react': specifier: ^15.0.7 version: 15.0.7(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@types/he': + specifier: ^1.2.3 + version: 1.2.3 '@types/node': specifier: 24.0.3 version: 24.0.3 @@ -1874,6 +1880,9 @@ packages: '@types/graceful-fs@4.1.9': resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} + '@types/he@1.2.3': + resolution: {integrity: sha512-q67/qwlxblDzEDvzHhVkwc1gzVWxaNxeyHUBF4xElrvjL11O+Ytze+1fGpBHlr/H9myiBUaUXNnNPmBHxxfAcA==} + '@types/istanbul-lib-coverage@2.0.6': resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} @@ -3868,6 +3877,10 @@ packages: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} + he@1.2.0: + resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} + hasBin: true + hls.js@1.6.6: resolution: {integrity: sha512-S4uTCwTHOtImW+/jxMjzG7udbHy5z682YQRbm/4f7VXuVNEoGBRjPJnD3Fxrufomdhzdtv24KnxRhPMXSvL6Fw==} @@ -8309,6 +8322,8 @@ snapshots: dependencies: '@types/node': 24.0.3 + '@types/he@1.2.3': {} + '@types/istanbul-lib-coverage@2.0.6': {} '@types/istanbul-lib-report@3.0.3': @@ -10515,6 +10530,8 @@ snapshots: dependencies: function-bind: 1.1.2 + he@1.2.0: {} + hls.js@1.6.6: {} hosted-git-info@2.8.9: {} diff --git a/src/lib/utils.ts b/src/lib/utils.ts index cc5152c..54d4770 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any,no-console */ +import he from 'he'; import Hls from 'hls.js'; /** @@ -80,13 +81,16 @@ export function processDoubanUrl(originalUrl: string): string { export function cleanHtmlTags(text: string): string { if (!text) return ''; - return text + + const cleanedText = text .replace(/<[^>]+>/g, '\n') // 将 HTML 标签替换为换行 .replace(/\n+/g, '\n') // 将多个连续换行合并为一个 .replace(/[ \t]+/g, ' ') // 将多个连续空格和制表符合并为一个空格,但保留换行符 .replace(/^\n+|\n+$/g, '') // 去掉首尾换行 - .replace(/ /g, ' ') // 将   替换为空格 .trim(); // 去掉首尾空格 + + // 使用 he 库解码 HTML 实体 + return he.decode(cleanedText); } /** diff --git a/src/lib/version.ts b/src/lib/version.ts index 5863e6a..b70998e 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -2,7 +2,7 @@ 'use client'; -const CURRENT_VERSION = '20250806101311'; +const CURRENT_VERSION = '20250806184440'; // 版本检查结果枚举 export enum UpdateStatus {