refactor: 重构搜索栏使用Vant组件并优化样式

This commit is contained in:
wangqiao
2025-09-03 18:03:58 +08:00
parent b1d2378cec
commit addef04ff0
4 changed files with 1721 additions and 2999 deletions

View File

@ -1,20 +1,15 @@
<template> <template>
<div class="search-container"> <div class="search-container">
<div class="search-input"> <!-- <span class="icon">🔍</span> -->
<span class="icon">🔍</span> <!-- <input v-model="searchValue" type="text" class="input" placeholder="搜一搜" @keyup.enter="onSearch" /> -->
<input <van-search
v-model="searchValue" v-model="searchValue"
type="text" shape="round"
class="input" class="vant-input"
placeholder="搜一搜" background="#fff"
@keyup.enter="onSearch" placeholder="请输入搜索关键词"
/> />
</div> </div>
<button class="search-btn" @click="onSearch">
<img src="~/assets/images/info.png" alt="info" />
</button>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -32,33 +27,19 @@ function onSearch() {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
}
.search-input {
display: flex;
align-items: center;
background: #efeff1;
border-radius: 32rpx;
padding: 0 22.11rpx;
flex: 1; flex: 1;
} .vant-input {
.search-input .icon { margin-right: 8px; }
.search-input .input {
flex: 1; flex: 1;
height: 64rpx; padding: 0px !important;
border: none; /* 设置 Vant Search 内部输入高度 */
outline: none; --van-search-input-height: 48px;
background: transparent; :deep(.van-search__content) {
min-height: 48px;
}
:deep(.van-field__control) {
height: 48px;
line-height: 48px;
} }
.search-btn {
margin-left: 19.44rpx;
width: 43.75rpx;
height: 43.75rpx;
background-color: #fff;
border: none;
padding: 0;
} }
.search-btn img {
width: 100%;
height: 100%;
} }
</style> </style>

View File

@ -23,6 +23,7 @@
"pinia": "^3.0.3", "pinia": "^3.0.3",
"postcss-px-to-viewport": "^1.1.1", "postcss-px-to-viewport": "^1.1.1",
"qrcode.vue": "^3.6.0", "qrcode.vue": "^3.6.0",
"vant": "^4.9.21",
"vue": "^3.5.18", "vue": "^3.5.18",
"vue-pdf-embed": "^2.1.3", "vue-pdf-embed": "^2.1.3",
"vue-router": "^4.5.1", "vue-router": "^4.5.1",

View File

@ -98,13 +98,15 @@ function navigateTo(category: string) {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: #fff; background-color: #fff;
padding: 21px;
box-sizing: border-box;
} }
.banner-section { .banner-section {
margin-top: 20rpx; margin-top: 25px;
border-radius: 20rpx; border-radius: 20px;
overflow: hidden; overflow: hidden;
height: 300rpx; height: 285px;
} }
.banner-swiper { .banner-swiper {
@ -116,6 +118,7 @@ function navigateTo(category: string) {
height: 100%; height: 100%;
img { img {
height: 100%; height: 100%;
width: 100%;
} }
} }
@ -140,13 +143,13 @@ function navigateTo(category: string) {
} }
.category-grid { .category-grid {
margin-top: 40rpx; margin-top: 33px;
} }
.category-row { .category-row {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-bottom: 30rpx; margin-bottom: 40px;
} }
.category-item { .category-item {
@ -157,8 +160,8 @@ function navigateTo(category: string) {
} }
.category-icon { .category-icon {
width: 100rpx; width: 78px;
height: 100rpx; height: 78px;
border-radius: 20rpx; border-radius: 20rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -191,7 +194,7 @@ function navigateTo(category: string) {
} }
.category-text { .category-text {
font-size: 24rpx; font-size: 25px;
color: #333; color: #191919;
} }
</style> </style>

4611
yarn.lock

File diff suppressed because it is too large Load Diff