Skip to content

Commit f214dc6

Browse files
committed
fix(video-player): 修复字幕加载时未添加token的问题
在VideoPlayer组件中,修复了字幕加载时未添加token的问题。现在,当subtitles存在时,会检查src中是否已经包含查询参数,如果包含则使用&连接,否则使用?连接,并追加token参数。token从localStorage中获取并进行编码。
1 parent f6de589 commit f214dc6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

web/src/components/VideoPlayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function VideoPlayer({ src, subtitles }: VideoPlayerProps) {
5050
{subtitles && (
5151
<track
5252
kind="subtitles"
53-
src={subtitles}
53+
src={`${subtitles}${subtitles.includes('?') ? '&' : '?'}token=${encodeURIComponent(localStorage.getItem('token') || '')}`}
5454
srcLang="zh"
5555
label="字幕"
5656
default

0 commit comments

Comments
 (0)