2018-02-17 09:19:16 +09:00
|
|
|
<template>
|
|
|
|
<mk-ui>
|
2019-02-18 09:48:00 +09:00
|
|
|
<template v-slot:header><fa icon="search"/> {{ q }}</template>
|
2018-07-04 21:23:50 +09:00
|
|
|
|
|
|
|
<main>
|
2019-02-18 09:17:55 +09:00
|
|
|
<mk-notes ref="timeline" :make-promise="makePromise" @inited="inited"/>
|
2018-02-17 09:19:16 +09:00
|
|
|
</main>
|
|
|
|
</mk-ui>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-09 03:44:35 +09:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-17 09:19:16 +09:00
|
|
|
import Progress from '../../../common/scripts/loading';
|
|
|
|
|
2018-02-26 00:39:05 +09:00
|
|
|
const limit = 20;
|
2018-02-17 09:19:16 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-09 03:44:35 +09:00
|
|
|
i18n: i18n('mobile/views/pages/search.vue'),
|
2018-02-17 09:19:16 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2019-02-18 09:17:55 +09:00
|
|
|
makePromise: cursor => this.$root.api('notes/search', {
|
|
|
|
limit: limit + 1,
|
|
|
|
offset: cursor ? cursor : undefined,
|
|
|
|
query: this.q
|
|
|
|
}).then(notes => {
|
|
|
|
if (notes.length == limit + 1) {
|
|
|
|
notes.pop();
|
|
|
|
return {
|
|
|
|
notes: notes,
|
|
|
|
cursor: cursor ? cursor + limit : limit
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {
|
|
|
|
notes: notes,
|
|
|
|
cursor: null
|
|
|
|
};
|
|
|
|
}
|
|
|
|
})
|
2018-02-17 09:19:16 +09:00
|
|
|
};
|
|
|
|
},
|
2018-02-26 00:39:05 +09:00
|
|
|
watch: {
|
2019-02-18 09:17:55 +09:00
|
|
|
$route() {
|
|
|
|
this.$refs.timeline.reload();
|
|
|
|
}
|
2018-02-26 00:39:05 +09:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
q(): string {
|
|
|
|
return this.$route.query.q;
|
|
|
|
}
|
|
|
|
},
|
2018-02-17 09:19:16 +09:00
|
|
|
mounted() {
|
2018-11-09 08:26:32 +09:00
|
|
|
document.title = `%i18n:@search%: ${this.q} | ${this.$root.instanceName}`;
|
2018-02-17 09:19:16 +09:00
|
|
|
},
|
|
|
|
methods: {
|
2019-02-18 09:17:55 +09:00
|
|
|
inited() {
|
|
|
|
Progress.done();
|
2018-02-26 00:39:05 +09:00
|
|
|
},
|
2018-02-17 09:19:16 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|