diff options
Diffstat (limited to 'pages/search.vue')
-rw-r--r-- | pages/search.vue | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pages/search.vue b/pages/search.vue index 1c09e3b..6f448af 100644 --- a/pages/search.vue +++ b/pages/search.vue @@ -21,11 +21,13 @@ :key="model.id" :model="model" ) + pagination(:page="page" :pages="pages" v-if="count") </template> <script> import ModelLoading from "@/components/ModelLoading.vue"; import ModelBoxCard from "@/components/ModelBoxCard.vue"; +import Pagination from "@/components/Pagination.vue"; import { mapGetters } from "vuex"; @@ -40,20 +42,28 @@ export default { data() { return { q: "", + page: 0, + pages: 0, }; }, components: { "model-loading": ModelLoading, "model-box-card": ModelBoxCard, + pagination: Pagination, }, computed: { ...mapGetters(["isLoading"]), ...mapGetters("auth", ["isLogged"]), - ...mapGetters("models", ["models"]), + ...mapGetters("models", ["models", "count"]), }, created() { this.q = this.$route.query["q"]; - this.$store.dispatch("models/filter", { q: this.q }); + this.page = this.$route.query.page ?? 0; + this.$store + .dispatch("models/filter", { q: this.q, page: this.page }) + .then(() => { + this.pages = Math.ceil(this.count / 20); + }); }, }; </script> |