|
@@ -7,18 +7,13 @@
|
|
|
<template v-if="item.styleType === 0">
|
|
|
<n-grid x-gap="100" y-gap="100" :cols="2">
|
|
|
<n-gi v-for="child of item.children" :key="child.id">
|
|
|
- <div
|
|
|
- class="show-item b-rd-3xl relative"
|
|
|
- :class="{ [`style-${item.styleType}`]: true }"
|
|
|
+ <div class="show-item b-rd-3xl relative" :class="{ [`style-${item.styleType}`]: true }"
|
|
|
:style="{ backgroundImage: `url(${child.cover})` }"
|
|
|
- @click="handleToDoc(child as any as ArticleDetailType)"
|
|
|
- >
|
|
|
+ @click="handleToDoc(child as any as ArticleDetailType)">
|
|
|
<div
|
|
|
- class="w-full h-full flex flex-col absolute top-0 left-0 -mx-auto justify-end overflow-hidden shadow-blueGray"
|
|
|
- >
|
|
|
+ class="w-full h-full flex flex-col absolute top-0 left-0 -mx-auto justify-end overflow-hidden shadow-blueGray">
|
|
|
<div
|
|
|
- class="w-full h-[60px] title text-black font-size-[20px] flex justify-center items-center bg-white bg-op-50"
|
|
|
- >
|
|
|
+ class="w-full h-[60px] title text-black font-size-[20px] flex justify-center items-center bg-white bg-op-50">
|
|
|
{{ child.title }}
|
|
|
</div>
|
|
|
</div>
|
|
@@ -28,31 +23,19 @@
|
|
|
</template>
|
|
|
|
|
|
<template v-if="item.styleType === 1">
|
|
|
- <swiper
|
|
|
- :slides-per-view="item.grid"
|
|
|
- :space-between="50"
|
|
|
- @swiper="onSwiper"
|
|
|
- @slideChange="onSlideChange"
|
|
|
- >
|
|
|
- <swiper-slide
|
|
|
- v-for="child of item.children"
|
|
|
- :key="child.id"
|
|
|
- @click="handleToDoc(child as any as ArticleDetailType)"
|
|
|
- >
|
|
|
- <div
|
|
|
- class="cover w-full h-[400px] overflow-hidden b-rd-xl"
|
|
|
- :style="{ backgroundImage: `url(${child.cover})` }"
|
|
|
- ></div>
|
|
|
+ <swiper :slides-per-view="item.grid" :space-between="50" @swiper="onSwiper" @slideChange="onSlideChange">
|
|
|
+ <swiper-slide v-for="child of item.children" :key="child.id"
|
|
|
+ @click="handleToDoc(child as any as ArticleDetailType)">
|
|
|
+ <div class="cover w-full h-[400px] overflow-hidden b-rd-xl"
|
|
|
+ :style="{ backgroundImage: `url(${child.cover})` }"></div>
|
|
|
<div
|
|
|
- class="w-full h-full flex flex-col absolute top-0 left-0 -mx-auto justify-end overflow-hidden shadow-blueGray"
|
|
|
- >
|
|
|
+ class="w-full h-full flex flex-col absolute top-0 left-0 -mx-auto justify-end overflow-hidden shadow-blueGray">
|
|
|
<div
|
|
|
- class="w-full h-[50px] title text-black font-size-[20px] flex justify-center items-center bg-white bg-op-50"
|
|
|
- >
|
|
|
+ class="w-full h-[50px] title text-black font-size-[20px] flex justify-center items-center bg-white bg-op-50">
|
|
|
{{ child.title }}
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
</swiper-slide>
|
|
|
<!-- <div class="swiper-button-prev">
|
|
|
<button @click="swiperInstance.slidePrev()">Prev</button>
|
|
@@ -66,27 +49,18 @@
|
|
|
<template v-if="item.styleType === 2">
|
|
|
<n-grid x-gap="100" y-gap="100" :cols="2">
|
|
|
<n-gi v-for="child of item.children" :key="child.id">
|
|
|
- <div
|
|
|
- @click="handleToDoc(child as any as ArticleDetailType)"
|
|
|
- :class="{ [`style-${item.styleType}`]: true }"
|
|
|
- class="show-item b-rd-3xl relative w-full h-full"
|
|
|
- >
|
|
|
- <img
|
|
|
- :src="child.cover"
|
|
|
- alt=""
|
|
|
- class="absolute w-[128px] h-[128px] left-0 top-[-40px]"
|
|
|
- />
|
|
|
+ <div @click="handleToDoc(child as any as ArticleDetailType)"
|
|
|
+ :class="{ [`style-${item.styleType}`]: true }" class="show-item b-rd-3xl relative w-full h-full">
|
|
|
+ <img :src="child.cover" alt="" class="absolute w-[128px] h-[128px] left-0 top-[-40px]" />
|
|
|
|
|
|
<div class="pl-[128px] w-[calc(100%-128px)] overflow-hidden">
|
|
|
<div
|
|
|
- class="font-size-[20px] whitespace-nowrap text-ellipsis font-bold mt-[25px] w-[calc(100%-20px)] overflow-hidden"
|
|
|
- >
|
|
|
+ class="font-size-[20px] whitespace-nowrap text-ellipsis font-bold mt-[25px] w-[calc(100%-20px)] overflow-hidden">
|
|
|
{{ child.title }}
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
- class="text-size-base whitespace-nowrap text-ellipsis w-[calc(100%-20px)] overflow-hidden color-[#909090]"
|
|
|
- >
|
|
|
+ class="text-size-base whitespace-nowrap text-ellipsis w-[calc(100%-20px)] overflow-hidden color-[#909090]">
|
|
|
{{ child.description }}
|
|
|
</div>
|
|
|
</div>
|
|
@@ -98,6 +72,41 @@
|
|
|
<template v-if="item.styleType === 3">
|
|
|
<n-grid x-gap="100" y-gap="100" :cols="3">
|
|
|
<n-gi v-for="child of item.children" :key="child.id">
|
|
|
+ <div @click="handleToDoc(child as any as ArticleDetailType)"
|
|
|
+ :class="{ [`style-${item.styleType}`]: true }"
|
|
|
+ class="show-item b-rd-3xl relative w-full h-full flex flex-col align-center items-center justify-center">
|
|
|
+ <img :src="child.cover" alt="" class="w-[40px] h-[40px]" />
|
|
|
+
|
|
|
+ <div class="font-size-[20px] font-bold my-[16px]">{{ child.title }}</div>
|
|
|
+
|
|
|
+ <div class="color-[#909090] w-[calc(100%-30px)] text-center">
|
|
|
+ {{ child.description }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </n-gi>
|
|
|
+ </n-grid>
|
|
|
+ </template>
|
|
|
+ <template v-if="item.styleType === 4">
|
|
|
+ <!-- {{ otherstyleEnum }} -->
|
|
|
+ <n-grid x-gap="100" y-gap="20" :cols="2">
|
|
|
+ <n-gi v-for="other of otherstyleEnum" :key="other.value">
|
|
|
+
|
|
|
+ <div :class="{ [`style-${item.styleType}`]: true }" class="show-item">
|
|
|
+ <n-h5 class="font-size-[16px] font-800"> {{ other.label }}</n-h5>
|
|
|
+ <ul class="otherList">
|
|
|
+ <li class="font-size-[14px]" @click="handleToDoc(child as any as ArticleDetailType)"
|
|
|
+ v-for="child of item.children.filter(c => c.otherType === other.value).slice(0,3)" :key="child.id">
|
|
|
+ <span>{{ child.title }}</span>
|
|
|
+ </li>
|
|
|
+ <li v-if="item.children.filter(c => c.otherType === other.value).length > 3" class="font-size-[14px] more" @click="handleToMore">
|
|
|
+ <span class="font-medium">{{ $t('more') }}>></span>
|
|
|
+ </li>
|
|
|
+
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </n-gi>
|
|
|
+ <!-- <n-gi v-for="child of item.children" :key="child.id">
|
|
|
<div
|
|
|
@click="handleToDoc(child as any as ArticleDetailType)"
|
|
|
:class="{ [`style-${item.styleType}`]: true }"
|
|
@@ -111,9 +120,10 @@
|
|
|
{{ child.description }}
|
|
|
</div>
|
|
|
</div>
|
|
|
- </n-gi>
|
|
|
+ </n-gi> -->
|
|
|
</n-grid>
|
|
|
</template>
|
|
|
+
|
|
|
</template>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -128,7 +138,7 @@ layout: "default"
|
|
|
}
|
|
|
</route>
|
|
|
<script setup lang="ts">
|
|
|
-import { NH1, NGrid, NGi } from 'naive-ui'
|
|
|
+import { NH1, NH5, NGrid, NGi } from 'naive-ui'
|
|
|
import { getMenuList, type ArticleDetailType } from '@/api'
|
|
|
import type { MenuItem } from '@/api'
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue'
|
|
@@ -136,8 +146,19 @@ import 'swiper/css'
|
|
|
import router from '@/plugins/router.ts'
|
|
|
// import { useSwiper } from 'swiper/vue';
|
|
|
|
|
|
+const otherstyleEnum = [
|
|
|
+ {
|
|
|
+ value: 0,
|
|
|
+ label: '开发者',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 1,
|
|
|
+ label: '推荐阅读',
|
|
|
+ },
|
|
|
+]
|
|
|
+
|
|
|
const list = ref<MenuItem[]>([])
|
|
|
-const swiperInstance =ref();
|
|
|
+const swiperInstance = ref();
|
|
|
getMenuList().then((data) => {
|
|
|
if (data.data) {
|
|
|
list.value = data.data
|
|
@@ -148,7 +169,7 @@ const onSwiper = (swiper: unknown) => {
|
|
|
console.log(swiper)
|
|
|
swiperInstance.value = swiper
|
|
|
}
|
|
|
-const onSlideChange = (index:number) => {
|
|
|
+const onSlideChange = (index: number) => {
|
|
|
console.log('slide change', index)
|
|
|
}
|
|
|
|
|
@@ -161,6 +182,9 @@ const handleToDoc = (child: ArticleDetailType) => {
|
|
|
// router.push({ path: '/showdoc', query: { cid: categoryId } })
|
|
|
}
|
|
|
}
|
|
|
+const handleToMore = () => {
|
|
|
+
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -199,5 +223,36 @@ const handleToDoc = (child: ArticleDetailType) => {
|
|
|
box-shadow: 0px 0px 10px 0px rgba(6, 97, 201, 0.2);
|
|
|
border-radius: 10px 10px 10px 10px;
|
|
|
}
|
|
|
+
|
|
|
+ &.style-4 {
|
|
|
+ width: 482px;
|
|
|
+ min-height: 200px;
|
|
|
+ background: #F5F9FF;
|
|
|
+ border-radius: 10px 10px 10px 10px;
|
|
|
+ padding: 30px 64px;
|
|
|
+ cursor: default;
|
|
|
+ }
|
|
|
+
|
|
|
+ .otherList {
|
|
|
+ padding: 0;
|
|
|
+
|
|
|
+ li {
|
|
|
+ padding: 5px 0;
|
|
|
+ text-decoration: none;
|
|
|
+ list-style: none;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.more {
|
|
|
+ color: #0661C9;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ color: #107bf5;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|