Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit eb0531b

Browse files
committed
完成 - 完成播放历史记录,构建最近播放之前
1 parent 464c512 commit eb0531b

File tree

5 files changed

+70
-8
lines changed

5 files changed

+70
-8
lines changed

src/base/base-search-list.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default {
4848
align-items: center;
4949
height: 40px;
5050
overflow: hidden;
51+
color: $color-text-l;
5152
.text {
5253
flex: 1;
5354
font-size: $font-size-medium-x;

src/common/js/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import localStorage from 'store/dist/store.modern'
1313

1414
const SEARCH_KEY = '__search__'
15-
const SEARCH_MAX_LENGTH = 15
15+
const SEARCH_MAX_LENGTH = 20
1616

1717
function insertItem (arr, value, compare, maxLength) {
1818
const index = arr.findIndex(compare)

src/components/parts-add-to-list/parts-add-to-list.vue

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,34 @@
1919
@selectSwitch="toggleSwitchIndex"
2020
/>
2121

22-
<div class="list-wrapper"></div>
22+
<div class="list-wrapper">
23+
<BaseScroll class="scroll-wrapper" v-if="switchIndex === 0">
24+
<div class="currentPlay-list"></div>
25+
</BaseScroll>
26+
<BaseScroll
27+
class="scroll-wrapper"
28+
ref="scrollSearchList"
29+
v-if="switchIndex === 1"
30+
:data="searchHistory"
31+
>
32+
<!-- better-scroll 组件封装,其子元素不能直接是另一个组件,子组件必须有一个包裹,否则无法正确挂载 -->
33+
<div class="result-wrapper">
34+
<BaseSearchList
35+
:searchData="searchHistory"
36+
@selectItem="saveSearchItem"
37+
@deleteItem="deleteSearchItem"
38+
/>
39+
</div>
40+
</BaseScroll>
41+
</div>
2342
</div>
2443

2544
<div class="search-result-wrapper" v-show="queryKey">
26-
<PartsResult ref="searchList" :query="queryKey" :showArtist="false"/>
45+
<PartsResult
46+
:query="queryKey"
47+
:showArtist="false"
48+
@selectQuery="saveSearchItem"
49+
/>
2750
</div>
2851

2952
</div>
@@ -32,8 +55,11 @@
3255

3356
<script>
3457
import BaseSearchBox from 'base/base-search-box'
58+
import BaseScroll from 'base/base-scroll'
59+
import BaseSearchList from 'base/base-search-list'
3560
import BaseSwitches from 'base/base-switches/base-switches'
3661
import PartsResult from 'components/parts-search-result/parts-search-result'
62+
import { mapGetters, mapActions } from 'vuex'
3763
3864
export default {
3965
data () {
@@ -46,6 +72,14 @@ export default {
4672
},
4773
4874
methods: {
75+
deleteSearchItem (item) {
76+
this.deleteSearchHistory(item)
77+
},
78+
79+
saveSearchItem () {
80+
this.saveSearchHistory(this.queryKey)
81+
},
82+
4983
toggleSwitchIndex (index) {
5084
this.switchIndex = index
5185
},
@@ -60,18 +94,31 @@ export default {
6094
if (this.switchIndex === 0) {
6195
// TODO:
6296
} else {
63-
this.$refs.searchList.refresh()
97+
this.$refs.scrollSearchList.refresh()
6498
}
6599
}, 20)
66100
},
67101
68102
hideComponent () {
69103
this.hasShowComponent = false
70-
}
104+
},
105+
106+
...mapActions([
107+
'saveSearchHistory',
108+
'deleteSearchHistory' // 自动传入载荷
109+
])
110+
},
111+
112+
computed: {
113+
...mapGetters([
114+
'searchHistory'
115+
])
71116
},
72117
73118
components: {
74119
BaseSearchBox,
120+
BaseScroll,
121+
BaseSearchList,
75122
BaseSwitches,
76123
PartsResult
77124
}
@@ -80,6 +127,7 @@ export default {
80127

81128
<style lang="scss" scoped>
82129
@import '~scss/variables';
130+
@import '~scss/mixin';
83131
84132
.add-to-list {
85133
position: fixed;
@@ -115,6 +163,19 @@ export default {
115163
}
116164
}
117165
}
166+
.list-wrapper {
167+
position: absolute;
168+
top: 165px;
169+
bottom: 0;
170+
width: 100%;
171+
.scroll-wrapper {
172+
height: 100%;
173+
overflow: hidden;
174+
.search-list {
175+
padding: 20px 30px;
176+
}
177+
}
178+
}
118179
.search-box-wrapper {
119180
margin: 20px;
120181
}

src/components/parts-search-result/parts-search-result.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export default {
206206
@import '~scss/mixin';
207207
208208
.search-result {
209+
height: 100%;
209210
overflow: hidden;
210211
font-size: 0;
211212
.result-list {

src/components/the-search/search.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@
4040
</BaseScroll>
4141
</div>
4242

43-
<div class="search-result-wrapper">
43+
<div class="search-result-wrapper" ref="resultWrapper" v-show="queryKey">
4444
<PartsResult
4545
@listScrolling="blurInputBox"
4646
@selectQuery="saveSearchItem"
4747
ref="resultList"
4848
:query="queryKey"
49-
v-show="queryKey"
5049
/>
5150
</div>
5251

@@ -99,7 +98,7 @@ export default {
9998
const bottom = this.playlist.length > 0 ? '60px' : ''
10099
101100
this.$refs.shortcutWrapper.style.bottom = bottom // 历史记录页
102-
this.$refs.resultList.$el.style.bottom = bottom // 搜索结果页
101+
this.$refs.resultWrapper.style.bottom = bottom // 搜索结果页
103102
this.$refs.scroll.refresh()
104103
this.$refs.resultList.refreshScroll()
105104
},

0 commit comments

Comments
 (0)