fix: 调整搜索界面样式 #15
@ -38,17 +38,18 @@
|
|||||||
|
|
||||||
<!-- 右侧功能区 -->
|
<!-- 右侧功能区 -->
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<el-input
|
<el-link
|
||||||
v-model="searchQuery"
|
class="search-link"
|
||||||
class="search-input"
|
:underline="false"
|
||||||
:placeholder="$t('search-placeholder')"
|
type="info"
|
||||||
:prefix-icon="Search"
|
@click="navigateTo(localePath('/search'))"
|
||||||
clearable
|
>
|
||||||
@keyup.enter="handleSearch"
|
<el-icon class="action-icon"><ElIconSearch /></el-icon>
|
||||||
/>
|
</el-link>
|
||||||
|
|
||||||
<el-dropdown @command="setLocale">
|
<el-dropdown @command="setLocale">
|
||||||
<el-link type="info" :underline="false">
|
<el-link type="info" :underline="false">
|
||||||
<el-icon class="mdi mdi-translate translate-link" />
|
<el-icon class="mdi mdi-translate action-icon" />
|
||||||
</el-link>
|
</el-link>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
@ -62,29 +63,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Search } from '@element-plus/icons-vue';
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const localePath = useLocalePath();
|
const localePath = useLocalePath();
|
||||||
|
|
||||||
const { setLocale } = useI18n();
|
const { setLocale } = useI18n();
|
||||||
|
|
||||||
const searchQuery = ref('');
|
|
||||||
|
|
||||||
const activeName = ref<string | undefined>(undefined);
|
const activeName = ref<string | undefined>(undefined);
|
||||||
|
|
||||||
const handleSearch = () => {
|
|
||||||
const trimmed = searchQuery.value.trim();
|
|
||||||
if (!trimmed) return;
|
|
||||||
navigateTo({
|
|
||||||
path: localePath('/search'),
|
|
||||||
query: {
|
|
||||||
query: trimmed,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
searchQuery.value = '';
|
|
||||||
};
|
|
||||||
|
|
||||||
const refreshMenu = () => {
|
const refreshMenu = () => {
|
||||||
const path = router.currentRoute.value.path;
|
const path = router.currentRoute.value.path;
|
||||||
if (path.startsWith('/productions')) {
|
if (path.startsWith('/productions')) {
|
||||||
@ -170,11 +155,7 @@
|
|||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input {
|
.action-icon {
|
||||||
width: 200px;
|
font-size: 24px;
|
||||||
}
|
|
||||||
|
|
||||||
.translate-link {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -10,15 +10,18 @@
|
|||||||
:prefix-icon="Search"
|
:prefix-icon="Search"
|
||||||
clearable
|
clearable
|
||||||
@keyup.enter="navigateToQuery(keyword)"
|
@keyup.enter="navigateToQuery(keyword)"
|
||||||
@input="handleInput(keyword)"
|
|
||||||
@clear="handleClear"
|
@clear="handleClear"
|
||||||
/>
|
/>
|
||||||
<el-button type="primary" @click="navigateToQuery(keyword)">
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
class="search-button"
|
||||||
|
@click="navigateToQuery(keyword)"
|
||||||
|
>
|
||||||
{{ $t('search.search-button') }}
|
{{ $t('search.search-button') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="keyword && hasResults" class="search-meta">
|
<p v-if="hasResults" class="search-meta">
|
||||||
{{ $t('search.results-for', { query: keyword }) }}
|
{{ $t('search.results-for', { query: route.query?.query }) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -63,8 +66,8 @@
|
|||||||
<div v-else class="search-state">
|
<div v-else class="search-state">
|
||||||
<el-empty
|
<el-empty
|
||||||
:description="
|
:description="
|
||||||
keyword
|
route.query.query
|
||||||
? $t('search.no-results', { query: keyword })
|
? $t('search.no-results', { query: route.query?.query })
|
||||||
: $t('search.no-query')
|
: $t('search.no-query')
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@ -231,9 +234,9 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleInput = debounce((value: string) => {
|
// const handleInput = debounce((value: string) => {
|
||||||
performSearch(value);
|
// performSearch(value);
|
||||||
}, 300);
|
// }, 300);
|
||||||
|
|
||||||
const handleClear = () => {
|
const handleClear = () => {
|
||||||
keyword.value = '';
|
keyword.value = '';
|
||||||
@ -241,6 +244,18 @@
|
|||||||
router.replace(localePath({ path: '/search' }));
|
router.replace(localePath({ path: '/search' }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.query.query,
|
||||||
|
(newQuery) => {
|
||||||
|
if (typeof newQuery === 'string' && newQuery.trim()) {
|
||||||
|
keyword.value = newQuery;
|
||||||
|
performSearch(newQuery);
|
||||||
|
} else {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (typeof route.query.query === 'string' && route.query.query.trim()) {
|
if (typeof route.query.query === 'string' && route.query.query.trim()) {
|
||||||
keyword.value = route.query.query;
|
keyword.value = route.query.query;
|
||||||
@ -280,10 +295,18 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input {
|
.search-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-button {
|
||||||
|
height: 50px;
|
||||||
|
width: 100px;
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-meta {
|
.search-meta {
|
||||||
|
|||||||
Reference in New Issue
Block a user