This commit is contained in:
caozehui
2026-06-01 14:12:47 +08:00
parent ae970d048c
commit 2705bedc71
6 changed files with 36 additions and 12 deletions

View File

@@ -33,13 +33,16 @@
</template>
<script setup lang="tsx" name="resourceManage">
import { reactive, ref } from 'vue'
import { onActivated, reactive, ref } from 'vue'
import { CirclePlus, EditPen, VideoPlay } from '@element-plus/icons-vue'
import ProTable from '@/components/ProTable/index.vue'
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
import type { ResourceManage } from '@/api/resourceManage/interface'
import { getResourceManageList, getResourceManagePlayUrl } from '@/api/resourceManage'
import { consumeResourceManageAutoplayFirst } from '@/utils/resourceManageAutoplay'
import {
consumeResourceManageAutoplayFirst,
hasPendingResourceManageAutoplayFirst
} from '@/utils/resourceManageAutoplay'
import ResourceManagePopup from './components/resourceManagePopup.vue'
import ResourcePlayerDialog from './components/resourcePlayerDialog.vue'
@@ -51,15 +54,17 @@ const proTable = ref<ProTableInstance>()
const resourceManagePopup = ref()
const resourcePlayerDialog = ref()
const tryAutoPlayFirstRecord = async (firstRecord?: ResourceManage.ResResourceManage) => {
if (!consumeResourceManageAutoplayFirst()) return
if (!firstRecord) return
await handlePlay(firstRecord)
}
const getTableList = async (params: ResourceManage.ReqResourceManageParams) => {
const response = await getResourceManageList(params)
const firstRecord = response.data.records?.[0]
if (consumeResourceManageAutoplayFirst()) {
if (firstRecord) {
await handlePlay(firstRecord)
}
}
await tryAutoPlayFirstRecord(firstRecord)
return response
}
@@ -146,4 +151,16 @@ const handlePlay = async (row: ResourceManage.ResResourceManage) => {
const { data } = await getResourceManagePlayUrl(row.id)
resourcePlayerDialog.value?.open(normalizeStreamUrl(data.url))
}
onActivated(async () => {
if (!hasPendingResourceManageAutoplayFirst()) return
const currentFirstRecord = proTable.value?.tableData?.[0] as ResourceManage.ResResourceManage | undefined
if (currentFirstRecord) {
await tryAutoPlayFirstRecord(currentFirstRecord)
return
}
await proTable.value?.getTableList?.()
})
</script>