2018-02-16 17:35:15 +09:00
|
|
|
<template>
|
2019-02-18 09:17:55 +09:00
|
|
|
<div>
|
|
|
|
<mk-notes ref="timeline" :make-promise="makePromise" @inited="inited">
|
2019-02-18 11:13:56 +09:00
|
|
|
<template #header>
|
2019-02-18 09:48:00 +09:00
|
|
|
<header class="oxgbmvii">
|
|
|
|
<span><fa icon="search"/> {{ q }}</span>
|
|
|
|
</header>
|
|
|
|
</template>
|
2019-02-18 09:17:55 +09:00
|
|
|
</mk-notes>
|
2019-02-15 14:52:21 +09:00
|
|
|
</div>
|
2018-02-16 17:35:15 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-09 03:44:35 +09:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-16 17:35:15 +09:00
|
|
|
import Progress from '../../../common/scripts/loading';
|
2019-04-25 07:46:39 +09:00
|
|
|
import { genSearchQuery } from '../../../common/scripts/gen-search-query';
|
2018-02-16 17:35:15 +09:00
|
|
|
|
2018-02-26 00:39:05 +09:00
|
|
|
const limit = 20;
|
2018-02-16 17:35:15 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-09 03:44:35 +09:00
|
|
|
i18n: i18n('desktop/views/pages/search.vue'),
|
2018-02-16 17:35:15 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2019-04-25 07:46:39 +09:00
|
|
|
makePromise: async cursor => this.$root.api('notes/search', {
|
2019-02-18 09:17:55 +09:00
|
|
|
limit: limit + 1,
|
|
|
|
offset: cursor ? cursor : undefined,
|
2019-04-25 07:46:39 +09:00
|
|
|
...(await genSearchQuery(this, this.q))
|
2019-02-18 09:17:55 +09:00
|
|
|
}).then(notes => {
|
|
|
|
if (notes.length == limit + 1) {
|
|
|
|
notes.pop();
|
|
|
|
return {
|
|
|
|
notes: notes,
|
|
|
|
cursor: cursor ? cursor + limit : limit
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {
|
|
|
|
notes: notes,
|
2019-04-08 14:17:44 +09:00
|
|
|
more: false
|
2019-02-18 09:17:55 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
})
|
2018-02-16 17:35:15 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2018-02-26 00:39:05 +09:00
|
|
|
q(): string {
|
|
|
|
return this.$route.query.q;
|
2018-02-16 17:35:15 +09:00
|
|
|
}
|
|
|
|
},
|
2019-02-18 09:17:55 +09:00
|
|
|
watch: {
|
|
|
|
$route() {
|
|
|
|
this.$refs.timeline.reload();
|
|
|
|
}
|
|
|
|
},
|
2018-02-16 17:35:15 +09:00
|
|
|
mounted() {
|
|
|
|
document.addEventListener('keydown', this.onDocumentKeydown);
|
2018-06-07 01:52:03 +09:00
|
|
|
window.addEventListener('scroll', this.onScroll, { passive: true });
|
2019-02-18 09:17:55 +09:00
|
|
|
Progress.start();
|
2018-02-16 17:35:15 +09:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
document.removeEventListener('keydown', this.onDocumentKeydown);
|
|
|
|
window.removeEventListener('scroll', this.onScroll);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onDocumentKeydown(e) {
|
|
|
|
if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
|
|
|
|
if (e.which == 84) { // t
|
|
|
|
(this.$refs.timeline as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-02-18 09:17:55 +09:00
|
|
|
inited() {
|
|
|
|
Progress.done();
|
2018-02-26 00:39:05 +09:00
|
|
|
},
|
2018-02-16 17:35:15 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2019-02-15 14:52:21 +09:00
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.oxgbmvii
|
2019-02-18 09:17:55 +09:00
|
|
|
padding 0 8px
|
|
|
|
z-index 10
|
|
|
|
background var(--faceHeader)
|
|
|
|
box-shadow 0 var(--lineWidth) var(--desktopTimelineHeaderShadow)
|
2018-02-16 17:35:15 +09:00
|
|
|
|
2019-02-18 09:17:55 +09:00
|
|
|
> span
|
|
|
|
padding 0 8px
|
|
|
|
font-size 0.9em
|
|
|
|
line-height 42px
|
|
|
|
color var(--text)
|
2018-02-16 17:35:15 +09:00
|
|
|
</style>
|