-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathCategoryModal.vue
More file actions
156 lines (137 loc) · 3.04 KB
/
CategoryModal.vue
File metadata and controls
156 lines (137 loc) · 3.04 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<template>
<a-modal
:visible="visible"
title="全部分类"
:footer="false"
width="80%"
class="category-modal"
@cancel="handleClose"
>
<div class="category-modal-content">
<!-- 推荐分类 -->
<div
v-if="hasRecommendVideos"
class="category-item"
:class="{ active: activeKey === 'recommendTuijian404' }"
@click="handleSelectCategory('recommendTuijian404')"
>
推荐
</div>
<!-- 其他分类 -->
<div
v-for="item in classList.class"
:key="item.type_id"
class="category-item"
:class="{ active: activeKey === item.type_id }"
@click="handleSelectCategory(item.type_id)"
>
{{ item.type_name }}
</div>
</div>
</a-modal>
</template>
<script setup>
const props = defineProps({
visible: {
type: Boolean,
default: false
},
classList: {
type: Object,
required: true
},
hasRecommendVideos: {
type: Boolean,
default: false
},
activeKey: {
type: String,
required: true
}
});
const emit = defineEmits(['update:visible', 'select-category']);
const handleClose = () => {
emit('update:visible', false);
};
const handleSelectCategory = (categoryId) => {
emit('select-category', categoryId);
handleClose();
};
</script>
<style scoped>
.category-modal-content {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 12px;
max-height: 60vh;
overflow-y: auto;
padding: 16px 0;
}
.category-item {
padding: 12px 16px;
background: #f7f8fa;
border: 1px solid #e5e6eb;
border-radius: 8px;
text-align: center;
cursor: pointer;
transition: all 0.2s ease;
font-size: 14px;
font-weight: 500;
color: #1d2129;
}
.category-item:hover {
background: #e8f3ff;
border-color: #7bc4ff;
color: #165dff;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.category-item.active {
background: #165dff !important;
border-color: #165dff !important;
color: white !important;
font-weight: 600;
}
.category-item.active:hover {
background: #4080ff !important;
border-color: #4080ff !important;
color: white !important;
}
/* 滚动条样式 */
.category-modal-content::-webkit-scrollbar {
width: 6px;
}
.category-modal-content::-webkit-scrollbar-track {
background: #f7f8fa;
border-radius: 3px;
}
.category-modal-content::-webkit-scrollbar-thumb {
background: #c9cdd4;
border-radius: 3px;
}
.category-modal-content::-webkit-scrollbar-thumb:hover {
background: #a9aeb8;
}
/* 暗色主题适配 */
@media (prefers-color-scheme: dark) {
.category-item {
background: #2a2a2b;
border-color: #3a3a3c;
color: #ffffff;
}
.category-item:hover {
background: #1a3a5c;
border-color: #4080ff;
color: #7bc4ff;
}
.category-modal-content::-webkit-scrollbar-track {
background: #2a2a2b;
}
.category-modal-content::-webkit-scrollbar-thumb {
background: #4a4a4c;
}
.category-modal-content::-webkit-scrollbar-thumb:hover {
background: #5a5a5c;
}
}
</style>