Bladeren bron

Работа над расширенным поиском

Book Pauk 2 jaren geleden
bovenliggende
commit
5faa6a1e8f

+ 4 - 0
client/components/Api/Api.vue

@@ -235,6 +235,10 @@ class Api {
         return await this.request({action: 'search', from, query}, 30);
         return await this.request({action: 'search', from, query}, 30);
     }
     }
 
 
+    async bookSearch(query) {
+        return await this.request({action: 'bookSearch', query}, 30);
+    }
+
     async getAuthorBookList(authorId) {
     async getAuthorBookList(authorId) {
         return await this.request({action: 'get-author-book-list', authorId});
         return await this.request({action: 'get-author-book-list', authorId});
     }
     }

+ 8 - 1
client/components/Search/Search.vue

@@ -256,6 +256,7 @@ const route2component = {
     'author': {component: 'AuthorList', label: 'Авторы'},
     'author': {component: 'AuthorList', label: 'Авторы'},
     'series': {component: 'SeriesList', label: 'Серии'},
     'series': {component: 'SeriesList', label: 'Серии'},
     'title': {component: 'TitleList', label: 'Книги'},
     'title': {component: 'TitleList', label: 'Книги'},
+    'extended': {component: 'TitleList', label: 'Расширенный поиск'},
 };
 };
 
 
 const componentOptions = {
 const componentOptions = {
@@ -529,7 +530,13 @@ class Search {
     get listOptions() {
     get listOptions() {
         const result = [];
         const result = [];
         for (const [route, rec] of Object.entries(route2component))
         for (const [route, rec] of Object.entries(route2component))
-            result.push({label: rec.label, value: route});
+            if (route == 'extended') {
+                if (this.config.extendedSearch) {
+                    result.push({value: route, icon: 'la la-code', size: '10px'});
+                }
+            } else {
+                result.push({label: rec.label, value: route, icon: rec.icon});
+            }
         return result;
         return result;
     }
     }
 
 

+ 1 - 0
client/router.js

@@ -8,6 +8,7 @@ const myRoutes = [
     ['/author', Search],
     ['/author', Search],
     ['/series', Search],
     ['/series', Search],
     ['/title', Search],
     ['/title', Search],
+    ['/extended', Search],
     ['/:pathMatch(.*)*', null, null, '/'],
     ['/:pathMatch(.*)*', null, null, '/'],
 ];
 ];
 
 

+ 13 - 0
server/controllers/WebSocketController.js

@@ -87,6 +87,8 @@ class WebSocketController {
                     await this.getWorkerState(req, ws); break;
                     await this.getWorkerState(req, ws); break;
                 case 'search':
                 case 'search':
                     await this.search(req, ws); break;
                     await this.search(req, ws); break;
+                case 'bookSearch':
+                    await this.bookSearch(req, ws); break;
                 case 'get-author-book-list':
                 case 'get-author-book-list':
                     await this.getAuthorBookList(req, ws); break;
                     await this.getAuthorBookList(req, ws); break;
                 case 'get-author-series-list':
                 case 'get-author-series-list':
@@ -165,6 +167,17 @@ class WebSocketController {
         this.send(result, req, ws);
         this.send(result, req, ws);
     }
     }
 
 
+    async bookSearch(req, ws) {
+        if (!this.config.extendedSearch)
+            throw new Error('config.extendedSearch disabled');
+        if (!req.query)
+            throw new Error(`query is empty`);
+
+        const result = await this.webWorker.bookSearch(req.query);
+
+        this.send(result, req, ws);
+    }
+
     async getAuthorBookList(req, ws) {
     async getAuthorBookList(req, ws) {
         const result = await this.webWorker.getAuthorBookList(req.authorId);
         const result = await this.webWorker.getAuthorBookList(req.authorId);
 
 

+ 11 - 0
server/core/WebWorker.js

@@ -268,6 +268,17 @@ class WebWorker {
         return result;
         return result;
     }
     }
 
 
+    async bookSearch(query) {
+        this.checkMyState();
+
+        const result = await this.dbSearcher.bookSearch(query);
+
+        const config = await this.dbConfig();
+        result.inpxHash = (config.inpxHash ? config.inpxHash : '');
+
+        return result;
+    }
+
     async opdsQuery(from, query) {
     async opdsQuery(from, query) {
         this.checkMyState();
         this.checkMyState();