Commit 6f5731f4 by lijiabin

【需求 17679】 perf: 最新最热展示优化

parent b175d962
...@@ -5,19 +5,15 @@ ...@@ -5,19 +5,15 @@
<div class="p-4"> <div class="p-4">
<div class="flex items-center gap-2 justify-between"> <div class="flex items-center gap-2 justify-between">
<el-button link @click="router.back()" class="text-gray-600 hover:text-primary"> <el-button link @click="router.back()" class="text-gray-600 hover:text-primary">
<el-icon class="mr-1"><ArrowLeft /></el-icon> <el-icon class="mr-1">
<ArrowLeft />
</el-icon>
返回 返回
</el-button> </el-button>
<div class="w-auto flex items-center gap-2"> <div class="w-auto flex items-center gap-2">
<el-input <el-input v-model="searchParams.title" placeholder="输入关键词搜索" class="w-400px" size="default"
v-model="searchParams.title" @keyup.enter="handleSearch" clearable />
placeholder="输入关键词搜索"
class="w-400px"
size="default"
@keyup.enter="handleSearch"
clearable
/>
<el-button type="primary" @click="handleSearch">搜索</el-button> <el-button type="primary" @click="handleSearch">搜索</el-button>
</div> </div>
...@@ -48,35 +44,20 @@ ...@@ -48,35 +44,20 @@
</template> --> </template> -->
</div> </div>
<div class="text-gray-500 text-14px"> <div class="text-gray-500 text-14px">
<el-select <el-radio-group size="default" v-model="searchParams.sortLogic" @change="changeSort">
v-model="searchParams.sortLogic" <el-radio-button v-for="sort in sortOptions" :key="sort.value" :label="sort.label" :value="sort.value" />
placeholder="请选择排序方式" </el-radio-group>
class="w-100px!"
@change="changeSort"
>
<el-option
v-for="sort in sortOptions"
:key="sort.value"
:label="sort.label"
:value="sort.value"
/>
</el-select>
</div> </div>
</div> </div>
<div v-show="list.length"> <div v-show="list.length">
<div class="space-y-4"> <div class="space-y-4">
<div <div v-for="item in list" :key="item.articleId"
v-for="item in list"
:key="item.articleId"
class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer" class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer"
@click="handleClick(item)" @click="handleClick(item)">
>
<!-- 封面图 --> <!-- 封面图 -->
<div <div v-if="item.faceUrl"
v-if="item.faceUrl" class="flex-shrink-0 w-240px h-135px rounded-lg overflow-hidden bg-gray-100 relative">
class="flex-shrink-0 w-240px h-135px rounded-lg overflow-hidden bg-gray-100 relative"
>
<img :src="item.faceUrl" class="w-full h-full object-cover" /> <img :src="item.faceUrl" class="w-full h-full object-cover" />
<!-- <div <!-- <div
v-if="item.type === ArticleTypeEnum.VIDEO" v-if="item.type === ArticleTypeEnum.VIDEO"
...@@ -144,20 +125,13 @@ ...@@ -144,20 +125,13 @@
<!-- 右侧:分页器 --> <!-- 右侧:分页器 -->
<div class="right"> <div class="right">
<div class="pr-4"> <div class="pr-4">
<el-pagination <el-pagination v-model:current-page="searchParams.current" v-model:page-size="searchParams.size"
v-model:current-page="searchParams.current" :page-sizes="[5, 20, 1]" layout="prev, pager, next, jumper, total" :total="total"
v-model:page-size="searchParams.size" class="custom-pagination" @current-change="
:page-sizes="[5, 20, 1]"
layout="prev, pager, next, jumper, total"
:total="total"
class="custom-pagination"
@current-change="
(e) => { (e) => {
;(handleBackTop(), goToPage(e)) ; (handleBackTop(), goToPage(e))
} }
" " @size-change="changePageSize" />
@size-change="changePageSize"
/>
</div> </div>
</div> </div>
</div> </div>
...@@ -219,7 +193,7 @@ const handleClick = (item: SearchMoreColumnItemDto) => { ...@@ -219,7 +193,7 @@ const handleClick = (item: SearchMoreColumnItemDto) => {
window.open(`/articleDetail/${item.articleId}`) window.open(`/articleDetail/${item.articleId}`)
} }
onActivated(() => {}) onActivated(() => { })
</script> </script>
<style scoped></style> <style scoped></style>
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
</div> </div>
<div v-loading="loadingMore" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-6"> <div v-loading="loadingMore" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-6">
<div <div
@click="router.push(`/videoDetail/${item.articleId}`)" @click="handleOpenPage(item.articleId) "
v-for="item in listMore" v-for="item in listMore"
:key="item.id" :key="item.articleId"
class="group relative rounded-lg overflow-hidden bg-white shadow-sm hover:shadow-lg transition-all duration-300 cursor-pointer" class="group relative rounded-lg overflow-hidden bg-white shadow-sm hover:shadow-lg transition-all duration-300 cursor-pointer"
> >
<div class="relative overflow-hidden"> <div class="relative overflow-hidden">
...@@ -98,9 +98,11 @@ ...@@ -98,9 +98,11 @@
{{ item.title }} {{ item.title }}
</h3> </h3>
<div class="flex items-center justify-between text-gray-500 text-xs"> <div class="flex items-center justify-between text-gray-500 text-xs">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2 max-w-55%">
<img :src="item.showAvatar" alt="" class="w-6 h-6 rounded-full object-cover" /> <img :src="item.showAvatar" alt="" class="w-6 h-6 rounded-full object-cover" />
<el-tooltip :content="item.showName" placement="top">
<span class="font-medium">{{ item.showName }}</span> <span class="font-medium">{{ item.showName }}</span>
</el-tooltip>
</div> </div>
<span>{{ dayjs(item.createTime * 1000).format('YYYY-MM-DD HH:mm') }}</span> <span>{{ dayjs(item.createTime * 1000).format('YYYY-MM-DD HH:mm') }}</span>
</div> </div>
...@@ -144,7 +146,7 @@ ...@@ -144,7 +146,7 @@
v-for="i in item.yaColumnVoList" v-for="i in item.yaColumnVoList"
:key="i.articleId" :key="i.articleId"
class="group cursor-pointer" class="group cursor-pointer"
@click="router.push(`/videoDetail/${i.articleId}`)" @click="handleOpenPage(i.articleId)"
> >
<div class="relative mb-3 overflow-hidden rounded-lg"> <div class="relative mb-3 overflow-hidden rounded-lg">
<img <img
...@@ -159,10 +161,10 @@ ...@@ -159,10 +161,10 @@
<div class="text-12px text-#000 line-height-12px">推荐</div> <div class="text-12px text-#000 line-height-12px">推荐</div>
</div> </div>
</div> </div>
<h3 class="text font-medium text-gray-800 mb-2 transition-colors"> <h3 class="text font-medium text-gray-800 mb-2 transition-colors line-clamp-1">
{{ i.title }} {{ i.title }}
</h3> </h3>
<p class="text-sm text-gray-500 mb-3 line-clamp-2"> <p class="text-sm text-gray-500 mb-3 line-clamp-1">
{{ i.content }} {{ i.content }}
</p> </p>
<div class="flex items-center justify-between text-xs text-gray-500"> <div class="flex items-center justify-between text-xs text-gray-500">
...@@ -240,7 +242,7 @@ ...@@ -240,7 +242,7 @@
import { View, ChatDotRound, Star } from '@element-plus/icons-vue' import { View, ChatDotRound, Star } from '@element-plus/icons-vue'
import { getVideoList, getVideoListViewMore } from '@/api' import { getVideoList, getVideoListViewMore } from '@/api'
import { usePageSearch, useScrollTop } from '@/hooks' import { usePageSearch, useScrollTop } from '@/hooks'
import { TABS_REF_KEY, ArticleTypeEnum } from '@/constants' import { TABS_REF_KEY } from '@/constants'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import dayjs from 'dayjs' import dayjs from 'dayjs'
...@@ -249,8 +251,8 @@ const tabsRef = inject(TABS_REF_KEY) ...@@ -249,8 +251,8 @@ const tabsRef = inject(TABS_REF_KEY)
const { handleBackTop, ScrollTopComp } = useScrollTop(tabsRef!) const { handleBackTop, ScrollTopComp } = useScrollTop(tabsRef!)
const tabs = [ const tabs = [
{ label: '最多播放', sortLogic: 0 },
{ label: '最新发布', sortLogic: 1 }, { label: '最新发布', sortLogic: 1 },
{ label: '最多播放', sortLogic: 0 },
] ]
const { list, total, searchParams, goToPage, changePageSize, loading, refresh } = usePageSearch( const { list, total, searchParams, goToPage, changePageSize, loading, refresh } = usePageSearch(
...@@ -272,7 +274,7 @@ const { ...@@ -272,7 +274,7 @@ const {
} = usePageSearch(getVideoListViewMore, { } = usePageSearch(getVideoListViewMore, {
defaultSize: 3, defaultSize: 3,
defaultParams: { defaultParams: {
sortLogic: 0, sortLogic: 1,
}, },
immediate: false, immediate: false,
}) })
...@@ -280,6 +282,11 @@ const changeSort = (sortLogic: number) => { ...@@ -280,6 +282,11 @@ const changeSort = (sortLogic: number) => {
searchParamsMore.value.sortLogic = sortLogic searchParamsMore.value.sortLogic = sortLogic
refreshMore() refreshMore()
} }
const handleOpenPage = (articleId: number) => {
window.open(`/videoDetail/${articleId}`)
}
defineExpose({ defineExpose({
refresh: () => { refresh: () => {
// searchParams.value.current = 0 // searchParams.value.current = 0
......
...@@ -5,19 +5,15 @@ ...@@ -5,19 +5,15 @@
<div class="p-4"> <div class="p-4">
<div class="flex items-center gap-2 justify-between"> <div class="flex items-center gap-2 justify-between">
<el-button link @click="router.back()" class="text-gray-600 hover:text-primary"> <el-button link @click="router.back()" class="text-gray-600 hover:text-primary">
<el-icon class="mr-1"><ArrowLeft /></el-icon> <el-icon class="mr-1">
<ArrowLeft />
</el-icon>
返回 返回
</el-button> </el-button>
<div class="w-auto flex items-center gap-2"> <div class="w-auto flex items-center gap-2">
<el-input <el-input v-model="searchParams.title" placeholder="输入关键词搜索" class="w-400px" size="default"
v-model="searchParams.title" @keyup.enter="handleSearch" clearable />
placeholder="输入关键词搜索"
class="w-400px"
size="default"
@keyup.enter="handleSearch"
clearable
/>
<el-button type="primary" @click="handleSearch">搜索</el-button> <el-button type="primary" @click="handleSearch">搜索</el-button>
</div> </div>
...@@ -29,34 +25,19 @@ ...@@ -29,34 +25,19 @@
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<span class="text-gray-600 text-14px">分类:</span> <span class="text-gray-600 text-14px">分类:</span>
<div class="flex gap-2"> <div class="flex gap-2">
<button <button v-for="sort in [{ label: '全部', value: '' }, ...articleTypeListOptions]" :key="sort.value"
v-for="sort in [{ label: '全部', value: '' }, ...articleTypeListOptions]" class="px-4 py-1.5 rounded-lg text-14px transition-colors cursor-pointer" :class="{
:key="sort.value"
class="px-4 py-1.5 rounded-lg text-14px transition-colors cursor-pointer"
:class="{
'text-blue-600 bg-blue-50': searchParams.type === sort.value, 'text-blue-600 bg-blue-50': searchParams.type === sort.value,
'text-gray-600 hover:text-blue-600': searchParams.type !== sort.value, 'text-gray-600 hover:text-blue-600': searchParams.type !== sort.value,
}" }" @click="changeType(sort.value)">
@click="changeType(sort.value)"
>
{{ sort.label }} {{ sort.label }}
</button> </button>
</div> </div>
</div> </div>
<div class="text-gray-500 text-14px"> <div class="text-gray-500 text-14px">
<el-select <el-radio-group size="default" v-model="searchParams.sortLogic" @change="changeSort">
v-model="searchParams.sortLogic" <el-radio-button v-for="sort in sortOptions" :key="sort.value" :label="sort.label" :value="sort.value" />
placeholder="请选择排序方式" </el-radio-group>
class="w-100px!"
@change="changeSort"
>
<el-option
v-for="sort in sortOptions"
:key="sort.value"
:label="sort.label"
:value="sort.value"
/>
</el-select>
</div> </div>
</div> </div>
<!-- 二级分类 --> <!-- 二级分类 -->
...@@ -86,22 +67,15 @@ ...@@ -86,22 +67,15 @@
<div v-show="list.length"> <div v-show="list.length">
<div class="space-y-4"> <div class="space-y-4">
<div <div v-for="item in list" :key="item.id"
v-for="item in list"
:key="item.id"
class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer" class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer"
@click="handleClick(item)" @click="handleClick(item)">
>
<!-- 封面图 --> <!-- 封面图 -->
<div <div v-if="item.faceUrl"
v-if="item.faceUrl" class="flex-shrink-0 w-240px h-135px rounded-lg overflow-hidden bg-gray-100 relative">
class="flex-shrink-0 w-240px h-135px rounded-lg overflow-hidden bg-gray-100 relative"
>
<img :src="item.faceUrl" class="w-full h-full object-cover" /> <img :src="item.faceUrl" class="w-full h-full object-cover" />
<div <div v-if="item.type === ArticleTypeEnum.VIDEO"
v-if="item.type === ArticleTypeEnum.VIDEO" class="absolute bottom-2 right-2 bg-black/70 text-white text-12px px-2 py-0.5 rounded">
class="absolute bottom-2 right-2 bg-black/70 text-white text-12px px-2 py-0.5 rounded"
>
{{ item.videoDuration }} {{ item.videoDuration }}
</div> </div>
</div> </div>
...@@ -164,20 +138,13 @@ ...@@ -164,20 +138,13 @@
<!-- 右侧:分页器 --> <!-- 右侧:分页器 -->
<div class="right"> <div class="right">
<div class="pr-4"> <div class="pr-4">
<el-pagination <el-pagination v-model:current-page="searchParams.current" v-model:page-size="searchParams.size"
v-model:current-page="searchParams.current" :page-sizes="[5, 20, 1]" layout="prev, pager, next, jumper, total" :total="total"
v-model:page-size="searchParams.size" class="custom-pagination" @current-change="
:page-sizes="[5, 20, 1]"
layout="prev, pager, next, jumper, total"
:total="total"
class="custom-pagination"
@current-change="
(e) => { (e) => {
;(handleBackTop(), goToPage(e)) ; (handleBackTop(), goToPage(e))
} }
" " @size-change="changePageSize" />
@size-change="changePageSize"
/>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -5,19 +5,14 @@ ...@@ -5,19 +5,14 @@
<div class="p-4"> <div class="p-4">
<div class="flex items-center gap-2 justify-between"> <div class="flex items-center gap-2 justify-between">
<el-button link @click="router.back()" class="text-gray-600 hover:text-primary"> <el-button link @click="router.back()" class="text-gray-600 hover:text-primary">
<el-icon class="mr-1"><ArrowLeft /></el-icon> <el-icon class="mr-1">
<ArrowLeft />
</el-icon>
返回 返回
</el-button> </el-button>
<div class="w-auto flex items-center gap-2"> <div class="w-auto flex items-center gap-2">
<el-input <el-input v-model="searchParams.title" placeholder="输入关键词搜索" class="w-400px" size="default"
v-model="searchParams.title" @keyup.enter="handleSearch" clearable />
placeholder="输入关键词搜索"
class="w-400px"
size="default"
@keyup.enter="handleSearch"
clearable
/>
<el-button type="primary" @click="handleSearch">搜索</el-button> <el-button type="primary" @click="handleSearch">搜索</el-button>
</div> </div>
...@@ -25,11 +20,9 @@ ...@@ -25,11 +20,9 @@
</div> </div>
<!-- 一级分类 --> <!-- 一级分类 -->
<div class="flex items-center justify-between mb-6 border-b border-gray-200 p-4"> <div class="flex items-center justify-between border-b border-gray-200 p-4">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<span v-if="columnTitle" class="text-gray-600 text-base" <span v-if="columnTitle" class="text-gray-600 text-base">当前栏目:{{ columnTitle }}</span>
>当前栏目:{{ columnTitle }}</span
>
<!-- <template v-else> <!-- <template v-else>
<span class="text-gray-600 text-14px">分类:</span> <span class="text-gray-600 text-14px">分类:</span>
...@@ -50,39 +43,22 @@ ...@@ -50,39 +43,22 @@
</template> --> </template> -->
</div> </div>
<div class="text-gray-500 text-14px"> <div class="text-gray-500 text-14px">
<el-select <el-radio-group size="default" v-model="searchParams.sortLogic" @change="changeSort">
v-model="searchParams.sortLogic" <el-radio-button v-for="sort in sortOptions" :key="sort.value" :label="sort.label" :value="sort.value" />
placeholder="请选择排序方式" </el-radio-group>
class="w-100px!"
@change="changeSort"
>
<el-option
v-for="sort in sortOptions"
:key="sort.value"
:label="sort.label"
:value="sort.value"
/>
</el-select>
</div> </div>
</div> </div>
<div v-show="list.length"> <div v-show="list.length">
<div class="space-y-4"> <div class="space-y-4">
<div <div v-for="item in list" :key="item.articleId"
v-for="item in list"
:key="item.articleId"
class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer" class="flex gap-4 p-4 rounded-lg hover:bg-gray-50 transition-colors cursor-pointer"
@click="handleClick(item)" @click="handleClick(item)">
>
<!-- 封面图 --> <!-- 封面图 -->
<div <div v-if="item.faceUrl"
v-if="item.faceUrl" class="flex-shrink-0 w-240px h-135px rounded-lg overflow-hidden bg-gray-100 relative">
class="flex-shrink-0 w-240px h-135px rounded-lg overflow-hidden bg-gray-100 relative"
>
<img :src="item.faceUrl" class="w-full h-full object-cover" /> <img :src="item.faceUrl" class="w-full h-full object-cover" />
<div <div class="absolute bottom-2 right-2 bg-black/70 text-white text-12px px-2 py-0.5 rounded">
class="absolute bottom-2 right-2 bg-black/70 text-white text-12px px-2 py-0.5 rounded"
>
{{ item.videoDuration }} {{ item.videoDuration }}
</div> </div>
</div> </div>
...@@ -145,20 +121,13 @@ ...@@ -145,20 +121,13 @@
<!-- 右侧:分页器 --> <!-- 右侧:分页器 -->
<div class="right"> <div class="right">
<div class="pr-4"> <div class="pr-4">
<el-pagination <el-pagination v-model:current-page="searchParams.current" v-model:page-size="searchParams.size"
v-model:current-page="searchParams.current" :page-sizes="[5, 20, 1]" layout="prev, pager, next, jumper, total" :total="total"
v-model:page-size="searchParams.size" class="custom-pagination" @current-change="
:page-sizes="[5, 20, 1]"
layout="prev, pager, next, jumper, total"
:total="total"
class="custom-pagination"
@current-change="
(e) => { (e) => {
;(handleBackTop(), goToPage(e)) ; (handleBackTop(), goToPage(e))
} }
" " @size-change="changePageSize" />
@size-change="changePageSize"
/>
</div> </div>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment