From 634d646622b34584635094bab37c0465a2829dce Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Mon, 24 Oct 2022 17:23:13 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3,=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D1=88=D0=B8=D0=B5=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Search/AuthorList/AuthorList.vue | 34 ++++++++----------- client/components/Search/Search.vue | 9 +++-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/client/components/Search/AuthorList/AuthorList.vue b/client/components/Search/AuthorList/AuthorList.vue index f8be95c..2b5e0f0 100644 --- a/client/components/Search/AuthorList/AuthorList.vue +++ b/client/components/Search/AuthorList/AuthorList.vue @@ -176,19 +176,22 @@ const componentOptions = { showDeleted() { this.updateTableData(); }, + ready(newValue) { + if (newValue) + this.refresh();//no await + } }, }; class AuthorList extends BaseList { _options = componentOptions; _props = { + ready: Boolean, list: Object, search: Object, genreMap: Object, liberamaReady: Boolean, }; - ready = false; - loadingMessage = ''; loadingMessage2 = ''; @@ -214,20 +217,11 @@ class AuthorList extends BaseList { created() { this.commit = this.$store.commit; + this.api = this.$root.api; this.loadSettings(); } - mounted() { - (async() => { - //локальный кеш - this.api = this.$root.api; - - this.ready = true; - this.refresh();//no await - })(); - } - loadSettings() { const settings = this.settings; @@ -821,7 +815,15 @@ class AuthorList extends BaseList { if (!this.ready) return; - //оптимизация + //параметры запроса + const newQuery = _.cloneDeep(this.search); + newQuery.offset = (newQuery.page - 1)*newQuery.limit; + + if (_.isEqual(newQuery, this.prevQuery)) + return; + this.prevQuery = newQuery; + + //оптимизация, вместо запроса к серверу, берем из кеша if (this.abCacheEnabled && this.search.author && this.search.author[0] == '=') { const authorSearch = this.search.author.substring(1); const author = this.cachedAuthors[authorSearch]; @@ -840,12 +842,6 @@ class AuthorList extends BaseList { } } - //параметры запроса - const offset = (this.search.page - 1)*this.search.limit; - - const newQuery = _.cloneDeep(this.search); - newQuery.offset = offset; - this.queryExecute = newQuery; if (this.refreshing) diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index c29382c..bdfcdba 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -111,7 +111,7 @@ - +
@@ -248,6 +248,8 @@ const componentOptions = { class Search { _options = componentOptions; + ready = false; + collection = ''; projectName = ''; @@ -312,6 +314,7 @@ class Search { created() { this.commit = this.$store.commit; + this.api = this.$root.api; this.loadSettings(); } @@ -331,8 +334,6 @@ class Search { //локальный кеш await authorBooksStorage.init(); - this.api = this.$root.api; - if (!this.$root.isMobileDevice) this.$refs.authorInput.focus(); @@ -340,6 +341,8 @@ class Search { this.updateSearchFromRouteQuery(this.$route); this.sendMessage({type: 'mes', data: 'hello-from-inpx-web'}); + + this.ready = true; })(); }