From d7c1a837854f3b4c742079e7d0f1acee6afe40da Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Mon, 24 Oct 2022 20:51:35 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BC=D0=B0=D1=80=D1=88=D1=80=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D1=8F,=20=D0=B2=D1=8B=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=20=D0=B2=D0=B8=D0=B4=D0=B0=20=D1=81=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=B0:=20=D0=90=D0=B2=D1=82=D0=BE=D1=80=D1=8B,=20=D0=A1?= =?UTF-8?q?=D0=B5=D1=80=D0=B8=D0=B8,=20=D0=9A=D0=BD=D0=B8=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Search/AuthorList/AuthorList.vue | 14 ++--- client/components/Search/Search.vue | 59 +++++++++++++++++-- client/quasar.js | 4 +- client/router.js | 3 + 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/client/components/Search/AuthorList/AuthorList.vue b/client/components/Search/AuthorList/AuthorList.vue index 4ce55f2..345dd04 100644 --- a/client/components/Search/AuthorList/AuthorList.vue +++ b/client/components/Search/AuthorList/AuthorList.vue @@ -122,7 +122,7 @@ -
+
Поиск не дал результатов
@@ -176,16 +176,11 @@ 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, @@ -221,6 +216,10 @@ class AuthorList extends BaseList { this.loadSettings(); } + mounted() { + this.refresh();//no await + } + loadSettings() { const settings = this.settings; @@ -811,9 +810,6 @@ class AuthorList extends BaseList { } async refresh() { - if (!this.ready) - return; - //параметры запроса const newQuery = _.cloneDeep(this.search); newQuery.offset = (newQuery.page - 1)*newQuery.limit; diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index ddc41c6..8e805a4 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -30,6 +30,16 @@ + +
{{ projectName }} @@ -111,7 +121,7 @@
- +
@@ -164,6 +174,7 @@ import vueComponent from '../vueComponent.js'; import AuthorList from './AuthorList/AuthorList.vue'; +import SeriesList from './SeriesList/SeriesList.vue'; import PageScroller from './PageScroller/PageScroller.vue'; import SelectGenreDialog from './SelectGenreDialog/SelectGenreDialog.vue'; @@ -178,9 +189,16 @@ import diffUtils from '../../share/diffUtils'; import _ from 'lodash'; +const route2component = { + 'author': {component: 'AuthorList', label: 'Авторы'}, + 'series': {component: 'SeriesList', label: 'Серии'}, + //'book': 'BookList', +}; + const componentOptions = { components: { AuthorList, + SeriesList, PageScroller, SelectGenreDialog, SelectLangDialog, @@ -229,6 +247,7 @@ const componentOptions = { this.setSetting('abCacheEnabled', newValue); }, $route(to) { + this.updateListFromRoute(to); this.updateSearchFromRouteQuery(to); }, langDefault() { @@ -245,6 +264,13 @@ const componentOptions = { }, deep: true, }, + selectedList(newValue) { + this.selectedListComponent = (route2component[newValue] ? route2component[newValue].component : null); + + if (this.getListRoute() != newValue) { + this.updateRouteQueryFromSearch(); + } + } }, }; class Search { @@ -252,6 +278,9 @@ class Search { ready = false; + selectedList = ''; + selectedListComponent = ''; + collection = ''; projectName = ''; @@ -339,6 +368,7 @@ class Search { this.$refs.authorInput.focus(); this.setDefaults(); + this.updateListFromRoute(this.$route); this.updateSearchFromRouteQuery(this.$route); this.sendMessage({type: 'mes', data: 'hello-from-inpx-web'}); @@ -403,6 +433,27 @@ class Search { return result.join(', '); } + get listOptions() { + const result = []; + for (const [route, rec] of Object.entries(route2component)) + result.push({label: rec.label, value: route}); + return result; + } + + async updateListFromRoute(to) { + const newPath = to.path; + let newList = this.getListRoute(newPath); + newList = (newList ? newList : 'author'); + if (this.selectedList != newList) + this.selectedList = newList; + } + + getListRoute(newPath) { + newPath = (newPath ? newPath : this.$route.path); + const m = newPath.match(/^\/([^/]*).*$/i); + return (m ? m[1] : newPath); + } + openReleasePage() { window.open('https://github.com/bookpauk/inpx-web/releases', '_blank'); } @@ -672,7 +723,7 @@ class Search { } } - async updateSearchFromRouteQuery(to) { + updateSearchFromRouteQuery(to) { if (this.list.liberamaReady) this.sendCurrentUrl(); @@ -709,7 +760,7 @@ class Search { const diff = diffUtils.getObjDiff(oldQuery, query); if (!diffUtils.isEmptyObjDiff(diff)) { - this.$router.replace({query}); + this.$router.replace({path: this.selectedList, query}); } } finally { (async() => { @@ -722,7 +773,7 @@ class Search { async updateGenreTreeIfNeeded() { if (this.genreTreeUpdating) return; - + this.genreTreeUpdating = true; try { if (this.genreTreeInpxHash !== this.list.inpxHash) { diff --git a/client/quasar.js b/client/quasar.js index 055d66b..1ae9050 100644 --- a/client/quasar.js +++ b/client/quasar.js @@ -14,7 +14,7 @@ import {QLinearProgress} from 'quasar/src/components/linear-progress'; import {QInput} from 'quasar/src/components/input'; import {QBtn} from 'quasar/src/components/btn'; //import {QBtnGroup} from 'quasar/src/components/btn-group'; -//import {QBtnToggle} from 'quasar/src/components/btn-toggle'; +import {QBtnToggle} from 'quasar/src/components/btn-toggle'; import {QIcon} from 'quasar/src/components/icon'; //import {QSlider} from 'quasar/src/components/slider'; //import {QTabs, QTab} from 'quasar/src/components/tabs'; @@ -48,7 +48,7 @@ const components = { QInput, QBtn, //QBtnGroup, - //QBtnToggle, + QBtnToggle, QIcon, //QSlider, //QTabs, QTab, diff --git a/client/router.js b/client/router.js index 3fb73bb..c1a0204 100644 --- a/client/router.js +++ b/client/router.js @@ -5,6 +5,9 @@ const Search = () => import('./components/Search/Search.vue'); const myRoutes = [ ['/', Search], + ['/author', Search], + ['/series', Search], + ['/book', Search], ['/:pathMatch(.*)*', null, null, '/'], ];