Skip to content

Commit 0cbb178

Browse files
author
Taois
committed
feat: 增加csp策略测试
1 parent 2375965 commit 0cbb178

File tree

12 files changed

+1680
-199
lines changed

12 files changed

+1680
-199
lines changed

dashboard/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta name="referrer" content="no-referrer" />
78
<title>DrPlayer</title>
89
</head>
910
<body>

dashboard/src/components/players/ArtVideoPlayer.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Artplayer.PLAYBACK_RATE = [0.5, 0.75, 1, 1.25, 1.5, 2, 2.5, 3, 4, 5]
6666
import PlayerHeader from './PlayerHeader.vue'
6767
import SkipSettingsDialog from './SkipSettingsDialog.vue'
6868
import { useSkipSettings } from '@/composables/useSkipSettings'
69+
import { applyCSPBypass, setVideoReferrerPolicy, REFERRER_POLICIES } from '@/utils/csp'
6970
7071
// Props - 已添加 HLS 支持、动态高度自适应和自动下一集功能
7172
const props = defineProps({
@@ -210,6 +211,14 @@ const initArtPlayer = async (url) => {
210211
211212
console.log('初始化 ArtPlayer:', url)
212213
214+
// 应用CSP绕过策略
215+
try {
216+
const appliedPolicy = applyCSPBypass(url)
217+
console.log(`已为ArtPlayer应用CSP策略: ${appliedPolicy}`)
218+
} catch (error) {
219+
console.warn('应用CSP策略失败:', error)
220+
}
221+
213222
// 重置重连状态
214223
resetRetryState()
215224

dashboard/src/components/players/VideoPlayer.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import Hls from 'hls.js'
8989
import PlayerHeader from './PlayerHeader.vue'
9090
import SkipSettingsDialog from './SkipSettingsDialog.vue'
9191
import { useSkipSettings } from '@/composables/useSkipSettings'
92+
import { applyCSPBypass, setVideoReferrerPolicy, REFERRER_POLICIES } from '@/utils/csp'
9293
9394
// Props
9495
const props = defineProps({
@@ -309,6 +310,16 @@ const initVideoPlayer = (url) => {
309310
310311
const video = videoPlayer.value
311312
313+
// 应用CSP绕过策略
314+
try {
315+
const appliedPolicy = applyCSPBypass(url, video)
316+
console.log(`已为视频播放应用CSP策略: ${appliedPolicy}`)
317+
} catch (error) {
318+
console.warn('应用CSP策略失败:', error)
319+
// 降级到基本的no-referrer策略
320+
setVideoReferrerPolicy(video, REFERRER_POLICIES.NO_REFERRER)
321+
}
322+
312323
// 视频结束事件处理函数
313324
const handleVideoEnded = () => {
314325
// 防抖:如果正在处理自动连播,则忽略

dashboard/src/components/readers/ReaderHeader.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,17 @@ onUnmounted(() => {
304304
color: var(--color-text-4);
305305
}
306306
307-
/* 章节下拉菜单样式 */
307+
/* 章节下拉菜单样式 - 使用更强的选择器覆盖Arco Design默认样式 */
308+
:deep(.arco-dropdown-content) {
309+
max-height: calc(100vh - 120px) !important;
310+
padding: 0 !important;
311+
}
312+
308313
.chapter-dropdown {
309314
width: 300px;
310-
max-height: 70vh; /* 使用视口高度的70% */
315+
max-height: calc(100vh - 120px);
316+
display: flex;
317+
flex-direction: column;
311318
}
312319
313320
.chapter-dropdown-header {
@@ -318,6 +325,8 @@ onUnmounted(() => {
318325
border-bottom: 1px solid var(--color-border-2);
319326
font-weight: 500;
320327
color: var(--color-text-1);
328+
flex-shrink: 0;
329+
background: var(--color-bg-1);
321330
}
322331
323332
.total-count {
@@ -327,7 +336,8 @@ onUnmounted(() => {
327336
}
328337
329338
.chapter-dropdown-content {
330-
max-height: calc(70vh - 60px); /* 减去头部高度 */
339+
flex: 1;
340+
max-height: calc(100vh - 180px);
331341
overflow-y: auto;
332342
/* 优化滚动条样式 */
333343
scrollbar-width: thin;

0 commit comments

Comments
 (0)