100 lines
3.6 KiB
Vue
100 lines
3.6 KiB
Vue
<template>
|
|
<div class="xl:w-screen-xl m-auto py-4 px-4 sm:px-0">
|
|
<div class="text-center flex justify-between items-center z-0 relative my-5">
|
|
<el-space class="text-3xl font-bold text-green-600 flex items-center"><el-icon><CameraFilled /></el-icon>校园风光</el-space>
|
|
<nuxt-link :to="`/article/4145.html`" class="font-normal text-sm text-gray-400 flex items-center cursor-pointer">查看更多<el-icon><ArrowRight /></el-icon></nuxt-link>
|
|
</div>
|
|
<!-- <div class="text-center flex flex-col items-center z-0 relative">-->
|
|
<!-- <nuxt-link to="/article/4145.html">-->
|
|
<!-- <span class="text-4xl font-bold tracking-tight text-gray-800 dark:text-white">{{ title }}</span>-->
|
|
<!-- </nuxt-link>-->
|
|
<!-- <div class="sub-title">-->
|
|
<!-- <p class="text-gray-400 text-sm dark:text-gray-400 py-3">-->
|
|
<!-- {{ comments || 'Unlimited Scenery' }}-->
|
|
<!-- </p>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
<el-row :gutter="24" class="clearfix">
|
|
<el-col v-for="(item,index) in list" :key="index" :xs="12" :span="6" class="left mb-6">
|
|
<el-card shadow="hover" :body-style="{ padding: '0px' }" class=" hover:bg-gray-50 cursor-pointer" @click="navigateTo(`/detail/${item.articleId}.html`)">
|
|
<el-image
|
|
:src="item.image"
|
|
fit="cover"
|
|
:lazy="true" class="w-full md:h-[166px] h-[100px] lg:h-[199px] cursor-pointer bg-gray-50"/>
|
|
<div class="flex-1 px-4 py-5 sm:p-6 !p-4">
|
|
<div class="text-gray-700 dark:text-white text-base font-semibold flex flex-col gap-1.5">
|
|
<div class="line-clamp-2 text-sm lg:text-lg lg:min-h-[54px] min-h-auto">
|
|
{{ item.title }}
|
|
</div>
|
|
</div>
|
|
<!-- <div class="flex items-center gap-1.5 py-2 text-gray-500 justify-between">-->
|
|
<!-- <div class="text-gray-500 line-clamp-2">{{ item.comments }}</div>-->
|
|
<!-- </div>-->
|
|
<div class="button-group flex justify-between items-center mt-3 text-sm">
|
|
<el-space class="flex items-end">
|
|
<div class="text-gray-400 gap-1 flex items-center"><el-icon><View /></el-icon><span>{{ getViews(item) }}</span></div>
|
|
</el-space>
|
|
<div class="text-gray-400">
|
|
{{ dayjs(item.createTime).format('YYYY.MM.DD') }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
</el-row>
|
|
</div>
|
|
<div v-if="disabled" class="px-1 text-center text-gray-500 min-h-xs">
|
|
没有更多了
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import {navigateTo} from "#imports";
|
|
import dayjs from "dayjs";
|
|
import { View } from '@element-plus/icons-vue'
|
|
import type {CmsArticle} from "~/api/cms/cmsArticle/model";
|
|
import {listCmsArticle, pageCmsArticle} from "~/api/cms/cmsArticle";
|
|
import type {CmsArticleParam} from "~/api/cms/cmsArticle/model";
|
|
import {getImage} from "~/utils/common";
|
|
import {
|
|
ArrowRight,
|
|
Tickets,
|
|
CameraFilled
|
|
} from '@element-plus/icons-vue'
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
param?: CmsArticleParam;
|
|
disabled?: boolean;
|
|
categoryId?: number;
|
|
title?: string;
|
|
comments?: string;
|
|
fit?: any;
|
|
}>(),
|
|
{
|
|
fit: 'cover'
|
|
}
|
|
);
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'done'): void;
|
|
}>();
|
|
|
|
const list = ref<CmsArticle[]>([]);
|
|
const id = ref<number>(0);
|
|
|
|
// 请求数据
|
|
const reload = async () => {
|
|
pageCmsArticle({
|
|
limit: 8,
|
|
categoryId: props.categoryId
|
|
}).then(res => {
|
|
list.value = res?.list.map(d => {
|
|
d.image = getImage(d.image)
|
|
return d;
|
|
}) || [];
|
|
})
|
|
}
|
|
reload();
|
|
</script>
|