视频测试

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))
@ -108,7 +109,7 @@ export const videoApi = {
keyword?: string
}) {
const res = await request.get('/videos', { params })
return res.data
return res
},
// 获取视频详情
@ -203,4 +204,4 @@ export interface ApiResponse<T> {
code: number
message: string
data: T
}
}

View File

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