add
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="filter-bar">
|
||||
<el-button :icon="Refresh" @click="load">刷新</el-button>
|
||||
<span class="text-muted">共 {{ total }} 条待审核</span>
|
||||
</div>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" border stripe>
|
||||
<el-table-column prop="video_id" label="ID" width="80" />
|
||||
<el-table-column label="封面" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-image v-if="row.cover_url" :src="row.cover_url" fit="cover" class="cover"
|
||||
:preview-src-list="[row.cover_url]" preview-teleported />
|
||||
<div v-else class="cover placeholder">无封面</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="title" label="标题" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="作者" width="150">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.author?.nickname || '-' }}</span>
|
||||
<span class="text-muted"> #{{ row.author?.user_id }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="duration" label="时长(秒)" width="90" />
|
||||
<el-table-column prop="created_at" label="提交时间" width="170" />
|
||||
<el-table-column label="操作" width="230" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" :icon="View" @click="openPreview(row)">预览</el-button>
|
||||
<el-button link type="success" :icon="Select" @click="approve(row)">通过</el-button>
|
||||
<el-button link type="danger" :icon="CloseBold" @click="reject(row)">拒绝</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty><el-empty description="暂无待审核视频" /></template>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-wrap">
|
||||
<el-pagination v-model:current-page="page" :page-size="pageSize" :total="total"
|
||||
layout="total, prev, pager, next" @current-change="load" />
|
||||
</div>
|
||||
|
||||
<VideoPreview v-model="previewVisible" :video-url="previewUrl" :title="previewTitle" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { CloseBold, Refresh, Select, View } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import { listPendingVideos, reviewVideo } from '@/api/videos'
|
||||
import VideoPreview from '@/components/VideoPreview.vue'
|
||||
import { askReason } from '@/utils/reason'
|
||||
|
||||
const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
|
||||
const previewVisible = ref(false)
|
||||
const previewUrl = ref('')
|
||||
const previewTitle = ref('')
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await listPendingVideos({ page: page.value, page_size: pageSize.value })
|
||||
rows.value = data.list || []
|
||||
total.value = data.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openPreview(row) {
|
||||
previewUrl.value = row.video_url
|
||||
previewTitle.value = `预览:${row.title}`
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
async function approve(row) {
|
||||
await ElMessageBox.confirm(`确认通过视频《${row.title}》并发布?`, '审核通过', { type: 'success' })
|
||||
await reviewVideo(row.video_id, { action: 'approve' })
|
||||
ElMessage.success('已通过并发布')
|
||||
load()
|
||||
}
|
||||
|
||||
async function reject(row) {
|
||||
let reason
|
||||
try {
|
||||
reason = await askReason({
|
||||
title: '拒绝视频',
|
||||
message: `拒绝《${row.title}》,原因将回显给作者`,
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
await reviewVideo(row.video_id, { action: 'reject', reason })
|
||||
ElMessage.success('已拒绝')
|
||||
load()
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.cover {
|
||||
width: 80px;
|
||||
height: 45px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.cover.placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
color: #c0c4cc;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user