2323 >
2424 </div >
2525
26- <div id =" result" >
26+ <div id =" result" ref = " result " >
2727 <div >
2828 <template v-if =" isEmpty " >
2929 <p >{{ text }}</p >
4747 </div >
4848 </template >
4949 </template >
50- <ul v-else-if =" results.length > 0" >
51- <li v-for =" (s,k) in results " :key =" k" >
50+ <ul v-show =" results.length > 0" >
51+ <li v-for =" (s,k) in filteredResults " :key =" k" >
5252 <router-link @click.native =" close" :to =" './' + s.path" >
5353 <i v-if =" s.dir" class =" material-icons" >folder</i >
5454 <i v-else class =" material-icons" >insert_drive_file</i >
@@ -69,8 +69,6 @@ import { mapState, mapGetters, mapMutations } from "vuex"
6969import url from " @/utils/url"
7070import { search } from " @/api"
7171
72- // TODO: show fifty at the tie
73-
7472var boxes = {
7573 image: { label: " images" , icon: " insert_photo" },
7674 audio: { label: " music" , icon: " volume_up" },
@@ -92,7 +90,7 @@ export default {
9290 }
9391 },
9492 watch: {
95- show (val , old ) {
93+ show (val , old ) {
9694 this .active = val === " search"
9795
9896 if (old === " search" && ! this .active ) {
@@ -102,12 +100,19 @@ export default {
102100
103101 document .body .style .overflow = " auto"
104102 this .reset ()
103+ this .value = ' '
104+ this .active = false
105105 this .$refs .input .blur ()
106106 } else if (this .active ) {
107107 this .reload = false
108108 this .$refs .input .focus ()
109109 document .body .style .overflow = " hidden"
110110 }
111+ },
112+ value () {
113+ if (this .results .length ) {
114+ this .reset ()
115+ }
111116 }
112117 },
113118 computed: {
@@ -125,6 +130,9 @@ export default {
125130 }
126131
127132 return this .value === ' ' ? this .$t (" search.typeToSearch" ) : this .$t (" search.pressToSearch" )
133+ },
134+ filteredResults () {
135+ return this .results .slice (0 , this .resultsCount )
128136 }
129137 },
130138 mounted () {
@@ -133,6 +141,12 @@ export default {
133141 this .closeHovers ()
134142 }
135143 })
144+
145+ this .$refs .result .addEventListener (' scroll' , event => {
146+ if (event .target .offsetHeight + event .target .scrollTop >= event .target .scrollHeight - 100 ) {
147+ this .resultsCount += 50
148+ }
149+ })
136150 },
137151 methods: {
138152 ... mapMutations ([" showHover" , " closeHovers" , " setReload" ]),
@@ -157,8 +171,6 @@ export default {
157171 this .$refs .input .focus ()
158172 },
159173 reset () {
160- this .value = ' '
161- this .active = false
162174 this .ongoing = false
163175 this .resultsCount = 50
164176 this .results = []
@@ -177,6 +189,7 @@ export default {
177189
178190 this .ongoing = true
179191
192+
180193 this .results = await search (path, this .value )
181194 this .ongoing = false
182195 }
0 commit comments