From 6367cc22a211d4e3f1afce3594d0f81750f08273 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Fri, 8 Sep 2023 20:18:21 +0800 Subject: [PATCH] webui: move search component to ab-search-bar.vue --- webui/src/components/ab-search-bar.vue | 61 ++++++++++++ webui/src/components/basic/ab-search.vue | 112 +++++++--------------- webui/src/components/layout/ab-topbar.vue | 2 +- webui/src/store/search.ts | 22 ++--- webui/types/dts/components.d.ts | 1 + 5 files changed, 108 insertions(+), 90 deletions(-) create mode 100644 webui/src/components/ab-search-bar.vue diff --git a/webui/src/components/ab-search-bar.vue b/webui/src/components/ab-search-bar.vue new file mode 100644 index 00000000..66c7b2dc --- /dev/null +++ b/webui/src/components/ab-search-bar.vue @@ -0,0 +1,61 @@ + + + + + + + \ No newline at end of file diff --git a/webui/src/components/basic/ab-search.vue b/webui/src/components/basic/ab-search.vue index b5535db1..e9678637 100644 --- a/webui/src/components/basic/ab-search.vue +++ b/webui/src/components/basic/ab-search.vue @@ -1,28 +1,25 @@ @@ -41,86 +38,47 @@ onMounted(() => { shadow-inner > + -
-
- {{ provider }} -
-
- -
-
- -
-
- {{ site }} +
+ {{ provider }} +
+
+ +
-
-
-
-
diff --git a/webui/src/components/layout/ab-topbar.vue b/webui/src/components/layout/ab-topbar.vue index a216116f..70db3766 100644 --- a/webui/src/components/layout/ab-topbar.vue +++ b/webui/src/components/layout/ab-topbar.vue @@ -76,7 +76,7 @@ onUnmounted(() => { AutoBangumi - +
diff --git a/webui/src/store/search.ts b/webui/src/store/search.ts index e809ab3e..ba497d59 100644 --- a/webui/src/store/search.ts +++ b/webui/src/store/search.ts @@ -12,10 +12,11 @@ import type {BangumiRule} from "#/bangumi"; export function useSearchStore() { const bangumiList = ref([]); const inputValue = ref(''); - const selectingProvider = ref(false); const providers = ref(['mikan', 'dmhy', 'nyaa']); - const provider = ref('mikan'); + const provider = ref(providers.value[0]); + + const loading = ref(true); const input$ = new Subject(); @@ -44,31 +45,28 @@ export function useSearchStore() { // 有输入更新后清理之前的搜索结果 bangumiList.value = []; return input - ? apiSearch.get(input, provider.value) - : EMPTY + ? apiSearch.get(input, provider.value) + : EMPTY }), tap((bangumi: BangumiRule) => { bangumiList.value.push(bangumi); + }), ).subscribe() function onSearch() { + console.log('onSearch'); + loading.value = true; input$.next(inputValue.value); - } - - function onSelect(site: string) { - provider.value = site; - selectingProvider.value = !selectingProvider.value - onSearch(); + loading.value = false; } return { input$, bangumiInfo$, inputValue, - selectingProvider, - onSelect, onSearch, + loading, provider, getProviders, providers, diff --git a/webui/types/dts/components.d.ts b/webui/types/dts/components.d.ts index 259589f9..681c039a 100644 --- a/webui/types/dts/components.d.ts +++ b/webui/types/dts/components.d.ts @@ -24,6 +24,7 @@ declare module '@vue/runtime-core' { AbRssItem: typeof import('./../../src/components/ab-rss-item.vue')['default'] AbRule: typeof import('./../../src/components/ab-rule.vue')['default'] AbSearch: typeof import('./../../src/components/basic/ab-search.vue')['default'] + AbSearchBar: typeof import('./../../src/components/ab-search-bar.vue')['default'] AbSelect: typeof import('./../../src/components/basic/ab-select.vue')['default'] AbSetting: typeof import('./../../src/components/ab-setting.vue')['default'] AbSidebar: typeof import('./../../src/components/layout/ab-sidebar.vue')['default']