mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-28 15:14:56 +08:00
webui: change search bar style.
This commit is contained in:
@@ -77,4 +77,10 @@ export const apiSearch = {
|
||||
|
||||
return bangumiInfo$;
|
||||
},
|
||||
|
||||
async getProvider() {
|
||||
const { data } = await axios.get<string[]>('api/v1/search/provider');
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ defineEmits(['click']);
|
||||
fx-cer justify-between
|
||||
space-x-16px>
|
||||
<div w-400px space-x-16px fx-cer>
|
||||
<div h-44px w-72px rounded-6px class="image-container">
|
||||
<div h-44px w-72px rounded-6px overflow-hidden>
|
||||
<template v-if="poster !== ''">
|
||||
<img :src="`https://mikanani.me${poster}`" alt="poster" w-full class="search-image"/>
|
||||
</template>
|
||||
@@ -105,19 +105,10 @@ defineEmits(['click']);
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.vertical-border {
|
||||
border: 4px solid #EEE5F4;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.card-border {
|
||||
background: #EEE5F4;
|
||||
}
|
||||
|
||||
.image-container {
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.search-image {
|
||||
transform: translateY(-25%);
|
||||
|
||||
@@ -1,23 +1,73 @@
|
||||
<script lang="ts" setup>
|
||||
import { Search } from '@icon-park/vue-next';
|
||||
import {Search} from '@icon-park/vue-next';
|
||||
import {ref} from 'vue';
|
||||
import {Down, Up} from '@icon-park/vue-next';
|
||||
import {isString} from "lodash";
|
||||
import type {SelectItem} from "#/components";
|
||||
import {apiSearch} from "@/api/search";
|
||||
import {
|
||||
Subject,
|
||||
tap,
|
||||
map,
|
||||
switchMap,
|
||||
debounceTime,
|
||||
} from "rxjs";
|
||||
import type {BangumiRule} from "#/bangumi";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
}>(),
|
||||
{
|
||||
value: '',
|
||||
placeholder: '',
|
||||
}
|
||||
defineProps<{
|
||||
value?: string;
|
||||
provider: string[];
|
||||
placeholder?: string;
|
||||
}>(),
|
||||
{
|
||||
value: '',
|
||||
provider: ['Mikan', 'Dmhy', 'Nyaa'],
|
||||
placeholder: '',
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits(['update:value', 'click-search']);
|
||||
|
||||
function onInput(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
emit('update:value', input.value);
|
||||
}
|
||||
const selected = ref<SelectItem | string>(
|
||||
(props.provider?.[0] ?? '')
|
||||
);
|
||||
|
||||
const selectedProvider = computed(() => {
|
||||
if (isString(selected.value)) {
|
||||
return selected.value;
|
||||
} else {
|
||||
return selected.value.label ?? selected.value.value;
|
||||
}
|
||||
});
|
||||
|
||||
const onSelect = ref(false);
|
||||
|
||||
const input$ = new Subject<string>();
|
||||
const onInput = (value: string) => {
|
||||
input$.next(value);
|
||||
};
|
||||
|
||||
const bangumiInfo$ = apiSearch.get('魔女之旅')
|
||||
|
||||
input$.pipe(
|
||||
debounceTime(500),
|
||||
tap((input: string) => {
|
||||
console.log(input);
|
||||
}),
|
||||
switchMap((input: string) => {
|
||||
return apiSearch.get(input, site);
|
||||
}),
|
||||
tap((bangumi: BangumiRule) => console.log(bangumi)),
|
||||
tap((bangumi: BangumiRule) => {
|
||||
console.log('bangumi', bangumi)
|
||||
// set bangumi info to Search Result List
|
||||
}),
|
||||
).subscribe({
|
||||
complete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function onSearch() {
|
||||
emit('click-search', props.value);
|
||||
@@ -26,33 +76,80 @@ function onSearch() {
|
||||
|
||||
<template>
|
||||
<div
|
||||
bg="#7752B4"
|
||||
text-white
|
||||
fx-cer
|
||||
rounded-12px
|
||||
h-36px
|
||||
px-12px
|
||||
space-x-12px
|
||||
w-276px
|
||||
focus-within:w-396px
|
||||
transition-width
|
||||
bg="#7752B4"
|
||||
text-white
|
||||
fx-cer
|
||||
rounded-12px
|
||||
h-36px
|
||||
pl-12px
|
||||
space-x-12px
|
||||
w-400px
|
||||
overflow-hidden
|
||||
transition-width
|
||||
shadow-inner
|
||||
>
|
||||
<Search
|
||||
theme="outline"
|
||||
size="24"
|
||||
fill="#fff"
|
||||
is-btn
|
||||
btn-click
|
||||
@click="onSearch"
|
||||
theme="outline"
|
||||
size="24"
|
||||
fill="#fff"
|
||||
is-btn
|
||||
btn-click
|
||||
@click="onSearch"
|
||||
/>
|
||||
|
||||
<input
|
||||
type="text"
|
||||
:value="value"
|
||||
:placeholder="placeholder"
|
||||
input-reset
|
||||
@input="onInput"
|
||||
@keyup.enter="onSearch"
|
||||
type="text"
|
||||
:value="value"
|
||||
:placeholder="placeholder"
|
||||
input-reset
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<div
|
||||
h-full
|
||||
f-cer
|
||||
justify-between
|
||||
px-12px
|
||||
w-100px
|
||||
is-btn
|
||||
@click="() => onSelect = !onSelect"
|
||||
class="provider-select"
|
||||
>
|
||||
<div text-h3>
|
||||
{{ selectedProvider }}
|
||||
</div>
|
||||
<div class="provider-select">
|
||||
<Down/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="onSelect" abs top-84px left-540px w-100px rounded-12px shadow bg-white z-99 overflow-hidden>
|
||||
<div
|
||||
v-for="i in provider"
|
||||
:key="i"
|
||||
hover:bg-theme-row
|
||||
is-btn
|
||||
@click="() => {
|
||||
selected = i;
|
||||
onSelect = false;
|
||||
}"
|
||||
|
||||
>
|
||||
<div
|
||||
text-h3
|
||||
text-primary
|
||||
hover:text-white
|
||||
p-12px
|
||||
>
|
||||
{{ i }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.provider-select {
|
||||
background: #4E2A94;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
2
webui/src/store/search.ts
Normal file
2
webui/src/store/search.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import type {BangumiRule} from "#/bangumi";
|
||||
import type {ApiSuccess} from "#/api";
|
||||
Reference in New Issue
Block a user