提交 89da2632 authored 作者: haodaking's avatar haodaking

chore: 直播时长格式化

上级 575cc21b
...@@ -8,6 +8,12 @@ defineEmits<{ ...@@ -8,6 +8,12 @@ defineEmits<{
(e: 'update:modelValue', visible: boolean): void (e: 'update:modelValue', visible: boolean): void
}>() }>()
function formatDuration(seconds) {
const minutes = Math.floor(seconds / 60)
const remainingSeconds = seconds % 60
return minutes > 0 ? `${minutes}m${remainingSeconds}s` : `${remainingSeconds}s`
}
// 列表配置 // 列表配置
const listOptions = $computed(() => { const listOptions = $computed(() => {
return { return {
...@@ -15,27 +21,33 @@ const listOptions = $computed(() => { ...@@ -15,27 +21,33 @@ const listOptions = $computed(() => {
httpRequest: getLiveList, httpRequest: getLiveList,
params: { params: {
experiment_id: props.data?.eid, experiment_id: props.data?.eid,
student_id: props.data?.sid student_id: props.data?.sid,
}, },
callback(res: any) { callback(res: any) {
return { list: res.items } return { list: res.items }
} },
}, },
columns: [ columns: [
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '选手姓名', prop: 'student_name' }, { label: '选手姓名', prop: 'student_name' },
{ label: '商品名称', prop: 'live_commodity.title' }, { label: '商品名称', prop: 'live_commodity.title' },
{ label: '直播时长', prop: 'live_duration' }, {
label: '直播时长',
prop: 'live_duration',
computed({ row }) {
return formatDuration(row.live_duration)
},
},
{ {
label: '文件大小(M)', label: '文件大小(M)',
prop: 'live_video_size', prop: 'live_video_size',
computed({ row }: { row: any }) { computed({ row }: { row: any }) {
return convertBytes(row.live_video_size, 'MB') return convertBytes(row.live_video_size, 'MB')
} },
}, },
{ label: '上传时间', prop: 'live_end_time' }, { label: '上传时间', prop: 'live_end_time' },
{ label: '操作', slots: 'table-x', width: 130 } { label: '操作', slots: 'table-x', width: 130 },
] ],
} }
}) })
const handleViewLive = function (row: any) { const handleViewLive = function (row: any) {
...@@ -56,7 +68,7 @@ function convertBytes(bytes: any, unit: any, decimalPlaces = 2) { ...@@ -56,7 +68,7 @@ function convertBytes(bytes: any, unit: any, decimalPlaces = 2) {
KB: 1024, KB: 1024,
MB: 1024 * 1024, MB: 1024 * 1024,
GB: 1024 * 1024 * 1024, GB: 1024 * 1024 * 1024,
TB: 1024 * 1024 * 1024 * 1024 TB: 1024 * 1024 * 1024 * 1024,
} }
if (!units[unit]) { if (!units[unit]) {
...@@ -75,8 +87,7 @@ console.log(convertBytes(1048576, 'MB'), 'convertBytes(1048576,') ...@@ -75,8 +87,7 @@ console.log(convertBytes(1048576, 'MB'), 'convertBytes(1048576,')
title="查看直播录像" title="查看直播录像"
:close-on-click-modal="false" :close-on-click-modal="false"
width="700px" width="700px"
@update:modelValue="value => $emit('update:modelValue', value)" @update:modelValue="(value) => $emit('update:modelValue', value)">
>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList">
<template #table-count="{ row }"> {{ row.checked_count }}/{{ row.need_check_count }} </template> <template #table-count="{ row }"> {{ row.checked_count }}/{{ row.need_check_count }} </template>
<template #table-score="{ row }"> <template #table-score="{ row }">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论