index.vue
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
<!-- From Uiverse.io by ZAKARIAE48CHELLE -->
<div class="input-wrapper">
<button class="icon">
<svg
width="25px"
height="25px"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 21C16.7467 21 21 16.7467 21 11.5C21 6.25329 16.7467 2 11.5 2C6.25329 2 2 6.25329 2 11.5C2 16.7467 6.25329 21 11.5 21Z"
stroke="#fff"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
></path>
<path
d="M22 22L20 20"
stroke="#fff"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
</button>
<input
v-model="keyWord"
type="text"
name="searchKeyword"
class="input"
placeholder="输入应用名称回车查找"
@keyup.enter="onSearch"
/>
</div>
</template>
<script setup>
const keyWord = ref("");
function onSearch() {
if (keyWord.value) {
// 跳转到搜索页面
// this.$router.push({ path: "/search", query: { q: keyword.value } });
window.location.href = "/search?keyword=" + keyWord.value;
}
}
</script>
<style scoped>
/* From Uiverse.io by ZAKARIAE48CHELLE */
.input-wrapper {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 15px;
position: relative;
width: 250px;
}
.input {
border-style: none;
height: 50px;
width: 50px;
padding: 10px;
outline: none;
border-radius: 50%;
transition: 0.5s ease-in-out;
background-color: #5961f9;
box-shadow: 0px 0px 3px #5961f9;
padding-right: 40px;
color: #fff;
}
.input::placeholder,
.input {
font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
"Lucida Sans", Arial, sans-serif;
font-size: 17px;
}
.input::placeholder {
color: #8f8f8f;
}
.icon {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right: 0px;
cursor: pointer;
width: 50px;
height: 50px;
outline: none;
border-style: none;
border-radius: 50%;
pointer-events: painted;
background-color: transparent;
transition: 0.2s linear;
}
.icon:focus ~ .input,
.input:focus {
box-shadow: none;
width: 250px;
border-radius: 0px;
background-color: transparent;
border-bottom: 3px solid #5961f9;
transition: all 500ms cubic-bezier(0, 0.11, 0.35, 2);
}
/* 当最大宽度为768pxs时 */
@media (max-width: 768px) {
.input-wrapper {
width: 200px;
gap: 10px;
}
.icon {
width: 40px;
height: 40px;
}
.input {
width: 40px;
height: 40px;
padding-right: 31px;
}
.input::placeholder,
.input {
font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
"Lucida Sans", Arial, sans-serif;
font-size: 14px;
}
.icon:focus ~ .input,
.input:focus {
box-shadow: none;
width: 200px;
border-radius: 0px;
background-color: transparent;
border-bottom: 1.5px solid #5961f9;
transition: all 500ms cubic-bezier(0, 0.11, 0.35, 2);
}
}
</style>