Skip to content

Commit 70ba1fc

Browse files
author
Taois
committed
feat:支持源内搜索.
1 parent f8c6567 commit 70ba1fc

File tree

8 files changed

+401
-64
lines changed

8 files changed

+401
-64
lines changed

dashboard/src/components/CategoryNavigation.vue

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
<div class="category-nav-container">
33
<div class="category-nav-wrapper" ref="navWrapperRef">
44
<!-- 分类tabs -->
5+
<!-- 特殊分类显示 -->
6+
<div v-if="specialCategoryState.isActive" class="special-category-header">
7+
<div class="special-category-title">
8+
<span class="category-name">{{ specialCategoryState.categoryData?.type_name || '特殊分类' }}</span>
9+
<span class="category-type">(源内搜索)</span>
10+
</div>
11+
</div>
12+
13+
<!-- 正常分类tabs -->
514
<a-tabs
6-
v-model:active-key="activeKey"
7-
class="category-tabs"
15+
v-else
16+
v-model:active-key="activeKey"
817
type="line"
9-
size="large"
1018
position="top"
1119
:editable="false"
1220
@change="handleTabChange"
@@ -36,8 +44,14 @@
3644
</a-tab-pane>
3745
</a-tabs>
3846

47+
<!-- 特殊分类关闭按钮 -->
48+
<div v-if="specialCategoryState.isActive" class="special-category-close" @click="handleCloseSpecialCategory">
49+
<icon-close />
50+
<span>返回</span>
51+
</div>
52+
3953
<!-- 分类管理按钮 -->
40-
<div class="category-manage" @click="openCategoryModal">
54+
<div v-else class="category-manage" @click="openCategoryModal">
4155
<icon-apps />
4256
</div>
4357
</div>
@@ -56,7 +70,7 @@
5670

5771
<script setup>
5872
import { ref, computed, watch, onMounted, onBeforeUnmount } from 'vue';
59-
import { IconApps, IconFilter } from '@arco-design/web-vue/es/icon';
73+
import { IconApps, IconFilter, IconClose } from '@arco-design/web-vue/es/icon';
6074
import FilterSection from './FilterSection.vue';
6175
6276
const props = defineProps({
@@ -83,10 +97,20 @@ const props = defineProps({
8397
selectedFilters: {
8498
type: Object,
8599
default: () => ({})
100+
},
101+
// 特殊分类状态
102+
specialCategoryState: {
103+
type: Object,
104+
default: () => ({
105+
isActive: false,
106+
categoryData: null,
107+
originalClassList: null,
108+
originalRecommendVideos: null
109+
})
86110
}
87111
});
88112
89-
const emit = defineEmits(['tab-change', 'open-category-modal', 'toggle-filter', 'reset-filters']);
113+
const emit = defineEmits(['tab-change', 'open-category-modal', 'toggle-filter', 'reset-filters', 'close-special-category']);
90114
91115
// 计算默认的activeKey
92116
const getDefaultActiveKey = () => {
@@ -161,6 +185,12 @@ const openCategoryModal = () => {
161185
emit('open-category-modal');
162186
};
163187
188+
// 处理关闭特殊分类
189+
const handleCloseSpecialCategory = () => {
190+
console.log('关闭特殊分类');
191+
emit('close-special-category');
192+
};
193+
164194
onMounted(() => {
165195
const wrapper = navWrapperRef.value;
166196
if (!wrapper) return;
@@ -343,6 +373,54 @@ onBeforeUnmount(() => {
343373
margin-left: 12px;
344374
}
345375
376+
.special-category-close {
377+
display: flex;
378+
align-items: center;
379+
justify-content: center;
380+
gap: 4px;
381+
padding: 8px 12px;
382+
border-radius: 6px;
383+
background: rgba(245, 63, 63, 0.1);
384+
color: #f53f3f;
385+
cursor: pointer;
386+
transition: all 0.3s ease;
387+
margin-left: 12px;
388+
font-size: 14px;
389+
}
390+
391+
.special-category-close:hover {
392+
background: rgba(245, 63, 63, 0.2);
393+
transform: translateY(-1px);
394+
}
395+
396+
.special-category-header {
397+
display: flex;
398+
align-items: center;
399+
height: 40px;
400+
padding: 0 16px;
401+
background: rgba(22, 93, 255, 0.05);
402+
border-radius: 8px;
403+
border: 1px solid rgba(22, 93, 255, 0.1);
404+
}
405+
406+
.special-category-title {
407+
display: flex;
408+
align-items: center;
409+
gap: 8px;
410+
font-size: 16px;
411+
font-weight: 500;
412+
}
413+
414+
.special-category-title .category-name {
415+
color: #165dff;
416+
}
417+
418+
.special-category-title .category-type {
419+
color: #86909c;
420+
font-size: 14px;
421+
font-weight: 400;
422+
}
423+
346424
.category-manage:hover {
347425
background: #165dff;
348426
color: white;

dashboard/src/components/SearchResults.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ const handleSpecialAction = (actionType, actionData) => {
463463
console.log('处理专项动作:', actionType, actionData);
464464
465465
switch (actionType) {
466-
case 'self-search':
466+
case '__self_search__':
467467
// 处理源内搜索
468468
console.log('执行源内搜索:', actionData);
469469
break;

dashboard/src/components/VideoGrid.vue

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const props = defineProps({
114114
}
115115
});
116116
117-
const emit = defineEmits(['load-more', 'scroll-bottom', 'refresh-list']);
117+
const emit = defineEmits(['load-more', 'scroll-bottom', 'refresh-list', 'special-action']);
118118
119119
const router = useRouter();
120120
const visitedStore = useVisitedStore();
@@ -417,29 +417,12 @@ const handleActionSubmit = (result) => {
417417
const handleSpecialAction = (actionType, actionData) => {
418418
console.log('VideoGrid处理专项动作:', actionType, actionData);
419419
420-
switch (actionType) {
421-
case 'self-search':
422-
// 处理源内搜索
423-
console.log('执行源内搜索:', actionData);
424-
break;
425-
case 'detail':
426-
// 处理详情页跳转
427-
console.log('跳转到详情页:', actionData);
428-
break;
429-
case 'ktv-player':
430-
// 处理KTV播放
431-
console.log('启动KTV播放:', actionData);
432-
break;
433-
case 'refresh-list':
434-
// 处理刷新列表
435-
console.log('刷新列表:', actionData);
436-
// 可以触发父组件的刷新事件
437-
emit('refresh-list');
438-
break;
439-
default:
440-
console.log('未知的专项动作:', actionType, actionData);
441-
break;
442-
}
420+
// 将special-action事件传递给父组件处理
421+
emit('special-action', actionType, actionData);
422+
423+
// 关闭ActionRenderer
424+
showActionRenderer.value = false;
425+
currentActionData.value = null;
443426
};
444427
445428
// 暴露方法给父组件

dashboard/src/components/VideoList.vue

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,36 @@
88
:activeKey="activeKey"
99
:filters="props.classList?.filters || {}"
1010
:selectedFilters="selectedFilters"
11+
:specialCategoryState="props.specialCategoryState"
1112
@tab-change="handleTabChange"
1213
@open-category-modal="openCategoryModal"
1314
@toggle-filter="handleToggleFilter"
1415
@reset-filters="handleResetFilters"
16+
@close-special-category="() => emit('close-special-category')"
1517
/>
1618

1719
<!-- 内容区域 -->
1820
<div class="content-area">
21+
<!-- 特殊分类内容 -->
22+
<div v-if="specialCategoryState.isActive" class="tab-content">
23+
<VideoGrid
24+
:videos="listData[specialCategoryState.categoryData?.type_id] || []"
25+
:loading="loadingMore[specialCategoryState.categoryData?.type_id] || false"
26+
:hasMore="pageData[specialCategoryState.categoryData?.type_id]?.hasNext || false"
27+
:statsText="`${specialCategoryState.categoryData?.type_name || '特殊分类'}:共 ${listData[specialCategoryState.categoryData?.type_id]?.length || 0} 条`"
28+
:sourceRoute="props.sourceRoute"
29+
:module="props.module"
30+
:extend="props.extend"
31+
:api-url="props.apiUrl"
32+
@load-more="loadMoreData(specialCategoryState.categoryData?.type_id)"
33+
@scroll-bottom="loadMoreData(specialCategoryState.categoryData?.type_id)"
34+
@refresh-list="handleRefreshList"
35+
@special-action="(actionType, actionData) => emit('special-action', actionType, actionData)"
36+
/>
37+
</div>
38+
1939
<!-- 推荐分类内容 -->
20-
<div v-if="activeKey === 'recommendTuijian404'" class="tab-content">
40+
<div v-else-if="activeKey === 'recommendTuijian404'" class="tab-content">
2141
<VideoGrid
2242
:videos="listData[activeKey] || []"
2343
:loading="loadingMore[activeKey] || false"
@@ -28,6 +48,7 @@
2848
:extend="props.extend"
2949
:api-url="props.apiUrl"
3050
@refresh-list="handleRefreshList"
51+
@special-action="(actionType, actionData) => emit('special-action', actionType, actionData)"
3152
/>
3253
</div>
3354

@@ -46,6 +67,7 @@
4667
@load-more="loadMoreData(activeKey)"
4768
@scroll-bottom="loadMoreData(activeKey)"
4869
@refresh-list="handleRefreshList"
70+
@special-action="(actionType, actionData) => emit('special-action', actionType, actionData)"
4971
/>
5072
</div>
5173
</div>
@@ -103,10 +125,20 @@ const props = defineProps({
103125
apiUrl: {
104126
type: String,
105127
default: ''
128+
},
129+
// 特殊分类状态
130+
specialCategoryState: {
131+
type: Object,
132+
default: () => ({
133+
isActive: false,
134+
categoryData: null,
135+
originalClassList: null,
136+
originalRecommendVideos: null
137+
})
106138
}
107139
});
108140
109-
const emit = defineEmits(['activeKeyChange']);
141+
const emit = defineEmits(['activeKeyChange', 'special-action', 'close-special-category']);
110142
111143
// 使用翻页统计store
112144
const paginationStore = usePaginationStore();
@@ -471,6 +503,29 @@ defineExpose({
471503
// 重新加载数据
472504
getListData(activeKey.value);
473505
}
506+
},
507+
setSpecialCategoryData: (categoryId, videos, pagination) => {
508+
console.log('设置特殊分类数据:', { categoryId, videosCount: videos?.length, pagination });
509+
510+
// 直接设置特殊分类的数据
511+
listData[categoryId] = videos || [];
512+
pageData[categoryId] = {
513+
page: pagination?.page || 1,
514+
hasNext: pagination?.hasNext || false,
515+
total: pagination?.total || 0
516+
};
517+
loadingMore[categoryId] = false;
518+
519+
// 更新全局翻页统计信息
520+
setTimeout(() => {
521+
paginationStore.updateStats(getStatsText(categoryId));
522+
}, 100);
523+
524+
console.log('特殊分类数据设置完成:', {
525+
categoryId,
526+
videosCount: listData[categoryId]?.length || 0,
527+
pageInfo: pageData[categoryId]
528+
});
474529
}
475530
});
476531

dashboard/src/components/actions/ActionRenderer.vue

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
@action="handleAction"
1616
@toast="handleToast"
1717
@reset="handleReset"
18+
@special-action="handleSpecialActionFromChild"
1819
/>
1920

2021
<!-- 错误提示 -->
@@ -219,9 +220,35 @@ export default {
219220
220221
switch (actionId) {
221222
case '__self_search__':
222-
// 源内搜索
223-
showToast('执行源内搜索', 'info')
224-
emit('special-action', 'self-search', actionData)
223+
// 源内搜索 - 处理T4返回的数据格式
224+
console.log('🚀 [ActionRenderer DEBUG] 处理__self_search__专项动作');
225+
console.log('🚀 [ActionRenderer DEBUG] actionData:', JSON.stringify(actionData, null, 2));
226+
227+
// 验证必要的参数
228+
if (!actionData.tid) {
229+
console.error('🚀 [ActionRenderer ERROR] 源内搜索参数不完整:缺少tid');
230+
showToast('源内搜索参数不完整:缺少tid', 'error')
231+
handleClose()
232+
break
233+
}
234+
235+
// 构造特殊分类数据
236+
const specialCategory = {
237+
tid: actionData.tid,
238+
type_id: actionData.tid,
239+
name: actionData.name,
240+
type_name: actionData.name || `搜索: ${actionData.tid}`,
241+
isSpecialCategory: true,
242+
actionData: actionData
243+
}
244+
245+
console.log('🚀 [ActionRenderer DEBUG] 构造的 specialCategory:', JSON.stringify(specialCategory, null, 2));
246+
console.log('🚀 [ActionRenderer DEBUG] 即将触发 special-action 事件');
247+
248+
showToast(actionData.msg || '执行源内搜索', 'info')
249+
emit('special-action', '__self_search__', specialCategory)
250+
251+
console.log('🚀 [ActionRenderer DEBUG] special-action 事件已触发,关闭组件');
225252
handleClose()
226253
break
227254
@@ -451,6 +478,20 @@ export default {
451478
error.value = null
452479
}
453480
481+
// 处理子组件的special-action事件
482+
const handleSpecialActionFromChild = (actionType, actionData) => {
483+
console.log('🔗 [ActionRenderer DEBUG] 接收到子组件的 special-action 事件');
484+
console.log('🔗 [ActionRenderer DEBUG] actionType:', actionType);
485+
console.log('🔗 [ActionRenderer DEBUG] actionData:', JSON.stringify(actionData, null, 2));
486+
487+
// 将事件向上传递给父组件
488+
console.log('🔗 [ActionRenderer DEBUG] 向父组件传递 special-action 事件');
489+
emit('special-action', actionType, actionData);
490+
491+
// 关闭当前组件
492+
handleClose();
493+
}
494+
454495
455496
456497
// 监听actionData变化
@@ -511,6 +552,7 @@ export default {
511552
handleAction,
512553
handleToast,
513554
handleReset,
555+
handleSpecialActionFromChild,
514556
clearError,
515557
show,
516558
hide,

0 commit comments

Comments
 (0)