NoChildren.vue
4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
<!-- 分类导航 -->
<div class="mb-6">
<div class="flex items-center mb-2">
<h4 class="text-gray dark:text-[#888] text-lg m-0">
<i
:id="`term-${childData.id}`"
class="iconfont text-lg mr-2"
:class="[`icon-${childData.icon}`]"
></i>
{{ childData.label }}
</h4>
<div class="flex-auto"></div>
<nuxt-link
class="hidden md:block text-xs ml-2 text-[#282a2d] hover:text-[#5961f9] dark:text-[#989da1]"
:to="`${routePath}/category/${childData.alias}`"
>查看更多 >></nuxt-link
>
<nuxt-link
class="md:hidden text-xs ml-2 text-[#282a2d] hover:text-[#5961f9]"
:to="`${routePath}/category/${childData.alias}`"
>>></nuxt-link
>
</div>
</div>
<!-- 分类内容 -->
<div
class="grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 md:gap-6 gap-4"
>
<div
v-for="(item, index) in childData.appVos"
:key="index"
class="bg-white dark:bg-[#272929] rounded-xl shadow-md overflow-hidden hover:shadow-lg hover:translate-y-[-6px] transition-all duration-300"
>
<el-popconfirm
v-if="item.isPopup == '1'"
class="box-item"
:title="item.popupContent"
placement="top-start"
icon-color="#5961f9"
width="280"
:icon="Promotion"
confirm-button-text="确认前往"
cancel-button-text="取消"
@confirm="onConfirm(item.id)"
>
<template #reference>
<nuxt-link
:to="routePath + '/site-details/' + item.id"
target="_blank"
@click.stop="onNuxtLink"
>
<div class="group p-3">
<div class="flex items-start space-x-4">
<img
loading="lazy"
:src="config.public.apiUrl + item.image"
:alt="item.title"
class="w-10 h-10 md:w-14 md:h-14 object-cover rounded-lg"
/>
<div>
<h3
class="font-bold dark:text-[#c6c9cf] md:text-base text-sm line-clamp-1 text-gray-800 transition group-hover:text-[#5961f9] dark:group-hover:text-white"
>
{{ item.title }}
</h3>
<p
class="text-gray-600 dark:text-[#6c757d] text-xs mt-1 md:line-clamp-2 line-clamp-1"
>
{{ item.description }}
</p>
</div>
</div>
</div>
</nuxt-link>
</template>
</el-popconfirm>
<nuxt-link
v-else
:to="routePath + '/site-details/' + item.id"
target="_blank"
>
<div class="group p-3">
<div class="flex items-start space-x-4">
<img
loading="lazy"
:src="config.public.apiUrl + item.image"
:alt="item.title"
class="w-10 h-10 md:w-14 md:h-14 object-cover rounded-lg"
/>
<div>
<h3
class="font-bold dark:text-[#c6c9cf] md:text-base text-sm line-clamp-1 text-gray-800 transition group-hover:text-[#5961f9] dark:group-hover:text-white"
>
{{ item.title }}
</h3>
<p
class="text-gray-600 dark:text-[#6c757d] text-xs mt-1 md:line-clamp-2 line-clamp-1"
>
{{ item.description }}
</p>
</div>
</div>
</div>
</nuxt-link>
</div>
</div>
</template>
<script setup lang="ts">
import { Promotion } from "@element-plus/icons-vue";
// 设置默认值
const props = withDefaults(
defineProps<{
childData: any;
routePath?: string; // 必须加 ? 表示可选
}>(),
{
routePath: "", // 默认值
},
);
const config = useRuntimeConfig();
const route = useRoute();
// 阻止默认行为
function onNuxtLink(event: any) {
event.preventDefault();
}
// 点击确认跳转
function onConfirm(id: number) {
window.open(props.routePath + "/site-details/" + id);
}
</script>