51 changed files with 2064 additions and 312 deletions
@ -1,41 +0,0 @@
|
||||
<template> |
||||
<div> |
||||
<!-- 用于显示视频流的video元素 --> |
||||
<video ref="videoPlayer" id="videoPlayer" class="video-js vjs-default-skin" controls></video> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
// 导入 srs.js 库 |
||||
import 'https://cdn.jsdelivr.net/npm/srs.js@latest/dist/srs.min.js'; // 使用最新版本的 srs.js |
||||
|
||||
export default { |
||||
mounted() { |
||||
// 初始化 WebRTC 播放器 |
||||
this.player = new SRS.Player({ |
||||
url: 'webrtc://47.121.143.167/live/livestream', // WebRTC流地址 |
||||
el: this.$refs.videoPlayer, // 视频播放元素 |
||||
width: '100%', // 宽度设置为 100% |
||||
height: 'auto', // 高度自适应 |
||||
}); |
||||
|
||||
this.player.play().catch((err) => { |
||||
console.error('Failed to play WebRTC stream:', err); |
||||
}); |
||||
}, |
||||
beforeDestroy() { |
||||
// 销毁播放器 |
||||
if (this.player) { |
||||
this.player.dispose(); |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
|
||||
<style scoped> |
||||
/* 确保视频播放器自适应 */ |
||||
#videoPlayer { |
||||
width: 100%; |
||||
height: auto; |
||||
} |
||||
</style> |
||||
@ -1,39 +1,27 @@
|
||||
const { VITE_PROFILES } = process.env; |
||||
|
||||
export function setCookie(name, value, daysToLive) { |
||||
let cookie = name + "=" + encodeURIComponent(value); |
||||
if (typeof daysToLive === "number") { |
||||
cookie += "; max-age=" + (daysToLive*24*60*60); // 将天数转换为秒数
|
||||
} |
||||
document.cookie = cookie; |
||||
export function setStorageItem(name, value) { |
||||
window.localStorage.setItem(name, value); |
||||
} |
||||
|
||||
export function getCookie(name) { |
||||
const cookies = document.cookie.split("; "); |
||||
for (let i = 0; i < cookies.length; i++) { |
||||
const [cookieName, cookieValue] = cookies[i].split("="); |
||||
if (name === cookieName) { |
||||
return decodeURIComponent(cookieValue); |
||||
} |
||||
} |
||||
return ""; |
||||
export function getStorageItem(name) { |
||||
return window.localStorage.getItem(name);; |
||||
} |
||||
|
||||
export function deleteCookie(name) { |
||||
document.cookie = name + `=; expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;`; |
||||
document.cookie = name + `=; expires=Thu, 01 Jan 1970 00:00:00 GMT;path=${VITE_PROFILES};`; |
||||
export function deleteStorageItem(name) { |
||||
window.localStorage.removeItem(name);; |
||||
} |
||||
|
||||
const TOKEN_KEY = "token" |
||||
export function setToken(value) { |
||||
setCookie(TOKEN_KEY, value, 1) |
||||
setStorageItem(TOKEN_KEY, value, 1) |
||||
} |
||||
|
||||
|
||||
export function getToken() { |
||||
return getCookie(TOKEN_KEY); |
||||
return getStorageItem(TOKEN_KEY); |
||||
} |
||||
|
||||
export function deleteToken() { |
||||
return deleteCookie(TOKEN_KEY); |
||||
return deleteStorageItem(TOKEN_KEY); |
||||
} |
||||
@ -0,0 +1,9 @@
|
||||
<template> |
||||
|
||||
</template> |
||||
<script setup> |
||||
|
||||
</script> |
||||
<style lang="scss" scoped> |
||||
|
||||
</style> |
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue