视频测试

This commit is contained in:
Guwan 2024-12-08 16:58:28 +08:00
parent e894c20b98
commit 6812f9db1d
2 changed files with 19 additions and 16 deletions

View File

@ -1,3 +1,4 @@
import request from '@/utils/request'
// 模拟延迟 // 模拟延迟
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
@ -108,7 +109,7 @@ export const videoApi = {
keyword?: string keyword?: string
}) { }) {
const res = await request.get('/videos', { params }) const res = await request.get('/videos', { params })
return res.data return res
}, },
// 获取视频详情 // 获取视频详情
@ -203,4 +204,4 @@ export interface ApiResponse<T> {
code: number code: number
message: string message: string
data: T data: T
} }

View File

@ -26,12 +26,12 @@
<!-- 视频列表 --> <!-- 视频列表 -->
<div class="video-list" v-loading="loading"> <div class="video-list" v-loading="loading">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col <el-col
v-for="video in videoList" v-for="video in videoList"
:key="video.id" :key="video.id"
:xs="24" :xs="24"
:sm="12" :sm="12"
:md="8" :md="8"
:lg="6" :lg="6"
> >
<div class="video-card"> <div class="video-card">
@ -55,19 +55,19 @@
</div> </div>
<div class="actions"> <div class="actions">
<el-button-group> <el-button-group>
<el-button <el-button
:type="video.hasLiked ? 'success' : 'default'" :type="video.hasLiked ? 'success' : 'default'"
@click="handleLike(video)" @click="handleLike(video)"
> >
<el-icon><Star /></el-icon> <el-icon><Star /></el-icon>
</el-button> </el-button>
<el-button <el-button
type="primary" type="primary"
@click="handleEdit(video)" @click="handleEdit(video)"
> >
<el-icon><Edit /></el-icon> <el-icon><Edit /></el-icon>
</el-button> </el-button>
<el-button <el-button
type="danger" type="danger"
@click="handleDelete(video)" @click="handleDelete(video)"
> >
@ -117,7 +117,7 @@
<el-input v-model="uploadForm.title" /> <el-input v-model="uploadForm.title" />
</el-form-item> </el-form-item>
<el-form-item prop="description" label="描述"> <el-form-item prop="description" label="描述">
<el-input <el-input
v-model="uploadForm.description" v-model="uploadForm.description"
type="textarea" type="textarea"
rows="3" rows="3"
@ -146,7 +146,7 @@
<el-input v-model="editForm.title" /> <el-input v-model="editForm.title" />
</el-form-item> </el-form-item>
<el-form-item prop="description" label="描述"> <el-form-item prop="description" label="描述">
<el-input <el-input
v-model="editForm.description" v-model="editForm.description"
type="textarea" type="textarea"
rows="3" rows="3"
@ -220,8 +220,10 @@ const getVideoList = async () => {
pageSize: pageSize.value, pageSize: pageSize.value,
keyword: searchKeyword.value keyword: searchKeyword.value
}) })
videoList.value = res.records console.log(res)
total.value = res.total //{records: Array(1), total: 0, size: 12, current: 1, pages: 0}
videoList.value = res
// total.value = res.total
} catch (error) { } catch (error) {
console.error('Failed to load videos:', error) console.error('Failed to load videos:', error)
ElMessage.error('加载视频列表失败') ElMessage.error('加载视频列表失败')
@ -269,7 +271,7 @@ const handleUpload = async () => {
formData.append('title', uploadForm.value.title) formData.append('title', uploadForm.value.title)
formData.append('description', uploadForm.value.description) formData.append('description', uploadForm.value.description)
formData.append('tags', uploadForm.value.tags) formData.append('tags', uploadForm.value.tags)
await videoApi.upload(formData) await videoApi.upload(formData)
ElMessage.success('上传成功') ElMessage.success('上传成功')
uploadDialogVisible.value = false uploadDialogVisible.value = false
@ -483,4 +485,4 @@ onMounted(() => {
.meta .el-icon { .meta .el-icon {
font-size: 16px; font-size: 16px;
} }
</style> </style>