-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathDebugInfoDialog.vue
More file actions
616 lines (546 loc) · 14.2 KB
/
DebugInfoDialog.vue
File metadata and controls
616 lines (546 loc) · 14.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
<template>
<div v-if="visible" class="debug-info-overlay" @click="handleOverlayClick">
<div class="debug-info-dialog" @click.stop>
<div class="dialog-header">
<h3>🔧 视频调试信息</h3>
<button class="close-btn" @click="$emit('close')">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="18" y1="6" x2="6" y2="18" stroke="currentColor" stroke-width="2"/>
<line x1="6" y1="6" x2="18" y2="18" stroke="currentColor" stroke-width="2"/>
</svg>
</button>
</div>
<div class="dialog-content">
<!-- 视频直链信息 -->
<div class="info-section">
<div class="section-header">
<h4>📹 视频直链</h4>
<button
class="copy-btn"
@click="copyToClipboard(videoUrl, '视频直链')"
:disabled="!videoUrl"
>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" stroke="currentColor" stroke-width="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" stroke="currentColor" stroke-width="2"/>
</svg>
复制
</button>
</div>
<div class="info-content">
<div class="url-display">
{{ videoUrl || '暂无视频链接' }}
</div>
</div>
</div>
<!-- 代理后链接信息 -->
<div v-if="proxyUrl && proxyUrl !== videoUrl" class="info-section">
<div class="section-header">
<h4>🔄 代理后链接</h4>
<div class="section-actions">
<button
class="copy-btn"
@click="copyToClipboard(proxyUrl, '代理后链接')"
:disabled="!proxyUrl"
>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" stroke="currentColor" stroke-width="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" stroke="currentColor" stroke-width="2"/>
</svg>
复制
</button>
<button
class="external-player-btn vlc-btn"
@click="openWithVLC(proxyUrl)"
:disabled="!proxyUrl"
title="使用VLC播放器打开"
>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<polygon points="5,3 19,12 5,21" fill="currentColor"/>
</svg>
VLC
</button>
<button
class="external-player-btn mpv-btn"
@click="openWithMPV(proxyUrl)"
:disabled="!proxyUrl"
title="使用MPV播放器打开"
>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
<polygon points="10,8 16,12 10,16" fill="currentColor"/>
</svg>
MPV
</button>
</div>
</div>
<div class="info-content">
<div class="url-display proxy-url">
{{ proxyUrl }}
</div>
</div>
</div>
<!-- 请求头信息 -->
<div class="info-section">
<div class="section-header">
<h4>📋 请求头信息</h4>
<button
class="copy-btn"
@click="copyToClipboard(headersText, '请求头信息')"
:disabled="!headersText"
>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" stroke="currentColor" stroke-width="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" stroke="currentColor" stroke-width="2"/>
</svg>
复制
</button>
</div>
<div class="info-content">
<div class="headers-display">
<div v-if="!headersText" class="no-data">暂无请求头信息</div>
<pre v-else class="headers-text">{{ headersText }}</pre>
</div>
</div>
</div>
<!-- 视频格式信息 -->
<div class="info-section">
<div class="section-header">
<h4>🎬 视频格式</h4>
</div>
<div class="info-content">
<div class="format-info">
<span class="format-label">检测格式:</span>
<span class="format-value">{{ detectedFormat || '未知' }}</span>
</div>
</div>
</div>
<!-- 播放器信息 -->
<div class="info-section">
<div class="section-header">
<h4>⚙️ 播放器信息</h4>
</div>
<div class="info-content">
<div class="player-info">
<span class="player-label">当前播放器:</span>
<span class="player-value">{{ playerType === 'artplayer' ? 'ArtPlayer' : '默认播放器' }}</span>
</div>
</div>
</div>
<!-- 一键复制所有信息 -->
<div class="action-section">
<button class="copy-all-btn" @click="copyAllInfo">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" stroke="currentColor" stroke-width="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" stroke="currentColor" stroke-width="2"/>
</svg>
复制所有调试信息
</button>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue'
import { Message } from '@arco-design/web-vue'
// Props
const props = defineProps({
visible: {
type: Boolean,
default: false
},
videoUrl: {
type: String,
default: ''
},
headers: {
type: Object,
default: () => ({})
},
playerType: {
type: String,
default: 'default'
},
detectedFormat: {
type: String,
default: ''
},
proxyUrl: {
type: String,
default: ''
}
})
// Emits
const emit = defineEmits(['close'])
// 计算属性
const headersText = computed(() => {
if (!props.headers || Object.keys(props.headers).length === 0) {
return ''
}
return Object.entries(props.headers)
.map(([key, value]) => `${key}: ${value}`)
.join('\n')
})
// 方法
const handleOverlayClick = () => {
emit('close')
}
const copyToClipboard = async (text, type) => {
if (!text) {
Message.warning(`${type}为空,无法复制`)
return
}
try {
await navigator.clipboard.writeText(text)
Message.success(`${type}已复制到剪贴板`)
} catch (error) {
console.error('复制失败:', error)
Message.error('复制失败,请手动选择复制')
}
}
const copyAllInfo = async () => {
const allInfo = [
'=== DrPlayer 视频调试信息 ===',
'',
'📹 视频直链:',
props.videoUrl || '暂无',
'',
...(props.proxyUrl && props.proxyUrl !== props.videoUrl ? [
'🔄 代理后链接:',
props.proxyUrl,
''
] : []),
'📋 请求头信息:',
headersText.value || '暂无',
'',
'🎬 视频格式:',
props.detectedFormat || '未知',
'',
'⚙️ 播放器类型:',
props.playerType === 'artplayer' ? 'ArtPlayer' : '默认播放器',
'',
'生成时间: ' + new Date().toLocaleString()
].join('\n')
await copyToClipboard(allInfo, '所有调试信息')
}
// 使用VLC播放器打开视频
const openWithVLC = (url) => {
if (!url) {
Message.warning('视频链接为空,无法调起VLC播放器')
return
}
try {
// 使用vlc://协议,VLC会自动处理协议前缀
const vlcUrl = `vlc://${url}`
// 创建隐藏的iframe来触发协议
const iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = vlcUrl
document.body.appendChild(iframe)
// 短暂延迟后移除iframe
setTimeout(() => {
document.body.removeChild(iframe)
}, 1000)
Message.success('正在尝试调起VLC播放器...')
console.log('调起VLC播放器:', vlcUrl)
} catch (error) {
console.error('调起VLC播放器失败:', error)
Message.error('调起VLC播放器失败,请确保已安装VLC播放器')
}
}
// 使用MPV播放器打开视频
const openWithMPV = (url) => {
if (!url) {
Message.warning('视频链接为空,无法调起MPV播放器')
return
}
try {
// 使用mpv://协议,MPV会自动处理协议前缀
const mpvUrl = `mpv://${url}`
// 创建隐藏的iframe来触发协议
const iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = mpvUrl
document.body.appendChild(iframe)
// 短暂延迟后移除iframe
setTimeout(() => {
document.body.removeChild(iframe)
}, 1000)
Message.success('正在尝试调起MPV播放器...')
console.log('调起MPV播放器:', mpvUrl)
} catch (error) {
console.error('调起MPV播放器失败:', error)
Message.error('调起MPV播放器失败,请确保已安装MPV播放器')
}
}
</script>
<style scoped>
.debug-info-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
backdrop-filter: blur(4px);
}
.debug-info-dialog {
background: white;
border-radius: 12px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
max-width: 800px;
width: 90vw;
max-height: 80vh;
overflow: hidden;
display: flex;
flex-direction: column;
}
.dialog-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 24px;
border-bottom: 1px solid #e9ecef;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.dialog-header h3 {
margin: 0;
font-size: 18px;
font-weight: 600;
}
.close-btn {
background: none;
border: none;
color: white;
cursor: pointer;
padding: 4px;
border-radius: 4px;
transition: background-color 0.2s;
}
.close-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
.close-btn svg {
width: 20px;
height: 20px;
}
.dialog-content {
padding: 24px;
overflow-y: auto;
flex: 1;
}
.info-section {
margin-bottom: 24px;
border: 1px solid #e9ecef;
border-radius: 8px;
overflow: hidden;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
background: #f8f9fa;
border-bottom: 1px solid #e9ecef;
}
.section-actions {
display: flex;
align-items: center;
gap: 8px;
}
.section-header h4 {
margin: 0;
font-size: 14px;
font-weight: 600;
color: #495057;
}
.copy-btn {
display: flex;
align-items: center;
gap: 4px;
padding: 4px 8px;
background: #23ade5;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
transition: background-color 0.2s;
}
.copy-btn:hover:not(:disabled) {
background: #1e90ff;
}
.copy-btn:disabled {
background: #6c757d;
cursor: not-allowed;
}
.copy-btn svg {
width: 14px;
height: 14px;
}
.info-content {
padding: 16px;
}
.url-display {
background: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 4px;
padding: 12px;
font-family: 'Courier New', monospace;
font-size: 13px;
word-break: break-all;
line-height: 1.4;
color: #495057;
}
.proxy-url {
background: #e8f5e8;
border-color: #4caf50;
color: #2e7d32;
}
.external-player-btn {
display: flex;
align-items: center;
gap: 4px;
padding: 4px 8px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
font-weight: 500;
transition: all 0.2s;
}
.vlc-btn {
background: #ff6b35;
color: white;
}
.vlc-btn:hover:not(:disabled) {
background: #e55a2b;
transform: translateY(-1px);
}
.mpv-btn {
background: #8e24aa;
color: white;
}
.mpv-btn:hover:not(:disabled) {
background: #7b1fa2;
transform: translateY(-1px);
}
.external-player-btn:disabled {
background: #6c757d;
cursor: not-allowed;
transform: none;
}
.external-player-btn svg {
width: 14px;
height: 14px;
}
.headers-display {
background: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 4px;
padding: 12px;
min-height: 60px;
}
.no-data {
color: #6c757d;
font-style: italic;
text-align: center;
padding: 20px;
}
.headers-text {
font-family: 'Courier New', monospace;
font-size: 13px;
margin: 0;
white-space: pre-wrap;
color: #495057;
line-height: 1.4;
}
.format-info,
.player-info {
display: flex;
align-items: center;
gap: 8px;
}
.format-label,
.player-label {
font-weight: 600;
color: #495057;
}
.format-value,
.player-value {
background: #e3f2fd;
color: #1976d2;
padding: 4px 8px;
border-radius: 4px;
font-size: 13px;
font-weight: 500;
}
.action-section {
margin-top: 24px;
padding-top: 20px;
border-top: 1px solid #e9ecef;
text-align: center;
}
.copy-all-btn {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: transform 0.2s, box-shadow 0.2s;
}
.copy-all-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}
.copy-all-btn svg {
width: 16px;
height: 16px;
}
/* 响应式设计 */
@media (max-width: 768px) {
.debug-info-dialog {
width: 95vw;
max-height: 90vh;
}
.dialog-header {
padding: 16px 20px;
}
.dialog-header h3 {
font-size: 16px;
}
.dialog-content {
padding: 20px;
}
.section-header {
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
.section-actions {
align-self: flex-end;
flex-wrap: wrap;
}
.copy-btn,
.external-player-btn {
font-size: 11px;
padding: 3px 6px;
}
.url-display,
.headers-text {
font-size: 12px;
}
}
</style>