From 92c32c5ec1faa612d6d9fbc82b941588d8381ced Mon Sep 17 00:00:00 2001 From: CzBiX Date: Thu, 3 Sep 2020 01:36:23 +0800 Subject: [PATCH] Refine search dialog code --- src/Api.ts | 4 +- src/components/Drawer.vue | 6 +- src/components/dialogs/SearchDialog.vue | 193 ++++++++++++++++-------- src/locale/en.ts | 1 + src/locale/zh-CN.ts | 1 + src/types.ts | 2 +- 6 files changed, 142 insertions(+), 65 deletions(-) diff --git a/src/Api.ts b/src/Api.ts index 77c54c9..7d3e555 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -297,9 +297,9 @@ class Api { return this.axios.post('/search/start', body).then(Api.handleResponse); } - public stopSearch(id: number): AxiosResponse | PromiseLike> { + public stopSearch(id: number) { const body = new URLSearchParams({ id: id.toString() }); - return this.axios.post('/search/stop', body); + return this.axios.post('/search/stop', body).then(Api.handleResponse) } public getSearchResults(id: number): Promise { diff --git a/src/components/Drawer.vue b/src/components/Drawer.vue index 38a5b68..19cfe0e 100644 --- a/src/components/Drawer.vue +++ b/src/components/Drawer.vue @@ -167,7 +167,11 @@ export default class Drawer extends Vue { torrentGroupByState!: {[state: string]: Torrent[]} created() { - const searchMenuItem = { icon: 'mdi-card-search-outline', title: 'Search', click: () => this.updateOptions('showSearch', true) }; + const searchMenuItem = { + icon: 'mdi-card-search-outline', + title: tr('search'), + click: () => this.updateOptions('showSearch', true) + }; if (this.phoneLayout) { this.endItems = this.endItems.concat([ diff --git a/src/components/dialogs/SearchDialog.vue b/src/components/dialogs/SearchDialog.vue index 174d4a5..f45a099 100644 --- a/src/components/dialogs/SearchDialog.vue +++ b/src/components/dialogs/SearchDialog.vue @@ -10,7 +10,7 @@ mdi-card-search-outline - Search + - + - + + + + + + @@ -43,21 +68,14 @@ v-model="searchForm.pattern" prepend-inner-icon="mdi-magnify" :label="$t('search')" - /> - - - - {{ loading ? $t('stop') : $t('search') }} @@ -74,13 +92,18 @@ :loading="loading" class="elevation-1" > + diff --git a/src/locale/en.ts b/src/locale/en.ts index 8e4c933..bda37ae 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -59,6 +59,7 @@ export default { more: 'More', feed: 'Feed', date: 'Date', + query: 'Query', plugin: 'Plugin |||| Plugins', action: 'Action |||| Actions', search_engine: 'Search engine', diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 77c269c..f5aa6ba 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -57,6 +57,7 @@ export default { more: '更多', feed: '订阅', date: '日期', + query: '查询', title: { _: '标题', diff --git a/src/types.ts b/src/types.ts index 17c95b4..c3a71ee 100644 --- a/src/types.ts +++ b/src/types.ts @@ -290,7 +290,7 @@ export interface SearchPlugin { enabled: boolean; fullName: string; name: string; - supportedCategories: { id: string; name: string }[]; + supportedCategories: string[]; url: string; version: string; }