37
37
@click =" searchDetail = null"
38
38
></i >
39
39
{{ hotKeyword }}
40
+ <div v-if =" searchDetail?.songs?.length" class =" title-play-all" >
41
+ <div class =" play-all-btn" @click =" handlePlayAll" >
42
+ <i class =" ri-play-circle-fill" ></i >
43
+ <span >{{ t('search.button.playAll') }}</span >
44
+ </div >
45
+ </div >
40
46
</div >
41
47
<div v-loading =" searchDetailLoading" class =" search-list-box" >
42
48
<template v-if =" searchDetail " >
46
52
v-for =" (item, index) in searchDetail?.bilibili"
47
53
:key =" item.bvid"
48
54
:class =" setAnimationClass('animate__bounceInRight')"
49
- :style =" setAnimationDelay (index, 50 )"
55
+ :style =" getSearchListAnimation (index)"
50
56
>
51
57
<bilibili-item :item =" item" @play =" handlePlayBilibili" />
52
58
</div >
62
68
v-for =" (item, index) in searchDetail?.songs"
63
69
:key =" item.id"
64
70
:class =" setAnimationClass('animate__bounceInRight')"
65
- :style =" setAnimationDelay (index, 50 )"
71
+ :style =" getSearchListAnimation (index)"
66
72
>
67
- <song-item :item =" item" @play =" handlePlay" />
73
+ <song-item :item =" item" @play =" handlePlay" :is-next = " true " />
68
74
</div >
69
75
<template v-for =" (list , key ) in searchDetail " >
70
76
<template v-if =" key .toString () !== ' songs' " >
73
79
:key =" item.id"
74
80
class =" mb-3"
75
81
:class =" setAnimationClass('animate__bounceInRight')"
76
- :style =" setAnimationDelay (index, 50 )"
82
+ :style =" getSearchListAnimation (index)"
77
83
>
78
84
<search-item :item =" item" />
79
85
</div >
104
110
v-for =" (item, index) in searchHistory"
105
111
:key =" index"
106
112
:class =" setAnimationClass('animate__bounceIn')"
107
- :style =" setAnimationDelay (index, 50 )"
113
+ :style =" getSearchListAnimation (index)"
108
114
class =" search-history-item"
109
115
round
110
116
closable
@@ -162,6 +168,10 @@ const hasMore = ref(true);
162
168
const isLoadingMore = ref (false );
163
169
const currentKeyword = ref (' ' );
164
170
171
+ const getSearchListAnimation = (index : number ) => {
172
+ return setAnimationDelay (index % ITEMS_PER_PAGE , 50 );
173
+ };
174
+
165
175
// 从 localStorage 加载搜索历史
166
176
const loadSearchHistory = () => {
167
177
const history = localStorage .getItem (' searchHistory' );
@@ -398,9 +408,9 @@ watch(
398
408
{ immediate: true }
399
409
);
400
410
401
- const handlePlay = () => {
402
- const tracks = searchDetail . value ?. songs || [];
403
- playerStore .setPlayList ( tracks );
411
+ const handlePlay = (item : any ) => {
412
+ // 添加到下一首
413
+ playerStore .addToNextPlay ( item );
404
414
};
405
415
406
416
// 点击搜索历史
@@ -418,6 +428,18 @@ const handlePlayBilibili = (item: IBilibiliSearchResult) => {
418
428
// 使用路由导航到B站播放页面
419
429
router .push (` /bilibili/${item .bvid } ` );
420
430
};
431
+
432
+ const handlePlayAll = () => {
433
+ if (! searchDetail .value ?.songs ?.length ) return ;
434
+
435
+ // 设置播放列表为搜索结果中的所有歌曲
436
+ playerStore .setPlayList (searchDetail .value .songs );
437
+
438
+ // 开始播放第一首歌
439
+ if (searchDetail .value .songs [0 ]) {
440
+ playerStore .setPlay (searchDetail .value .songs [0 ]);
441
+ }
442
+ };
421
443
</script >
422
444
423
445
<style lang="scss" scoped>
@@ -469,8 +491,21 @@ const handlePlayBilibili = (item: IBilibiliSearchResult) => {
469
491
}
470
492
471
493
.title {
472
- @apply text-xl font-bold my-2 mx- 4;
494
+ @apply text-xl font-bold my-2 mx-4 flex items-center ;
473
495
@apply text-gray-900 dark :text- white;
496
+
497
+ & -play-all {
498
+ @apply ml-auto ;
499
+ }
500
+ }
501
+
502
+ .play-all-btn {
503
+ @apply flex items-center gap-1 px-3 py-1 rounded-full cursor-pointer transition-all ;
504
+ @apply text-sm font-normal text-gray-900 dark :text- white hover:bg- light- 300 dark :hover:bg- dark- 300 hover:text- green- 500;
505
+
506
+ i {
507
+ @apply text-xl ;
508
+ }
474
509
}
475
510
476
511
.search-history {
0 commit comments