提交 570559b3 authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 32b21cbc
......@@ -18,8 +18,14 @@ const video = ref(null)
const playing = ref(false)
const duration = ref(0)
onMounted(() => {
video.value.onloadedmetadata = (e) => {
video.value.ondurationchange = (e) => {
if (e.target.duration === Infinity) {
video.value.currentTime = 1e101
} else {
video.value.currentTime = 0
}
duration.value = e.target.duration === Infinity ? parseFloat(record.value.live_duration) : e.target.duration
console.log('ondurationchange', e.target.duration)
}
video.value.ontimeupdate = () => {
currentTime.value = video.value.currentTime
......@@ -52,7 +58,7 @@ const hover = ref(false)
<p>主播:{{ userName }}</p>
</div>
<div class="live-bd">
<video :src="record.live_video_addres" ref="video"></video>
<video :src="record.live_video_addres" preload="metadata" ref="video"></video>
<LiveCover
:messages="messages"
:stats="stats"
......
......@@ -28,7 +28,7 @@ interface UseLiveProps {
export function useLive({ enabledUserMedia = true, onStart, onRecord, onStop }: UseLiveProps) {
const startTime = ref(0)
const endTime = ref(0)
const duration = computed(() => Math.floor((endTime.value - startTime.value) / 1000))
const duration = computed(() => (endTime.value - startTime.value) / 1000)
const currentTime = ref(0)
// 获取设备列表并设置默认设备
......@@ -78,7 +78,7 @@ export function useLive({ enabledUserMedia = true, onStart, onRecord, onStop }:
// 录像停止时处理
const handleStop = () => {
endTime.value = Date.now()
const blob = new Blob(recordedChunks.value, { type: 'video/mp4' })
const blob = new Blob(recordedChunks.value, { type: mediaRecorder?.mimeType })
onStop && onStop(blob)
recordedChunks.value = []
......
......@@ -365,19 +365,30 @@ export const useMenuStore = defineStore({
getters: {
menus: (state) => {
const userStore = useUserStore()
// const menus = userStore.role?.id === 1 ? state.studentMenus : state.adminMenus
return state.adminMenus
.filter((item) => {
// 过滤有权限的菜单
return userStore.menus.find((menu) => menu.id == item.id)
})
.map((item) => {
// 如果当前角色是学生,则使用学生的路径
if (userStore.role?.id === 1 && item.studentPath) {
item.path = item.studentPath
}
return item
})
const userRole = userStore.role?.id
const userPermissions = userStore.menus || []
// 递归过滤菜单及其子菜单
const filterMenus = (menus: IMenuItem[]): IMenuItem[] => {
return menus
.filter((menu) => userPermissions.some((perm) => perm.id === menu.id))
.map((menu) => {
const filteredMenu: IMenuItem = {
...menu,
// 替换路径为学生路径(如果有学生路径并且角色为学生)
path: userRole === 1 && menu.studentPath ? menu.studentPath : menu.path,
}
// 如果存在子菜单,则递归过滤
if (menu.children) {
filteredMenu.children = filterMenus(menu.children)
}
return filteredMenu
})
}
// 根据用户角色选择基础菜单
// const baseMenus = userRole === 1 ? state.studentMenus : state.adminMenus
return filterMenus(state.adminMenus)
},
},
})
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论