-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathHeader.vue
More file actions
300 lines (268 loc) · 6.74 KB
/
Header.vue
File metadata and controls
300 lines (268 loc) · 6.74 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<template>
<a-layout-header class="header">
<!-- 左侧控制按钮 -->
<div class="header-left">
<a-button shape="circle" @click="goBack">
<template #icon>
<icon-left/>
</template>
</a-button>
<a-button shape="circle" @click="goForward">
<template #icon>
<icon-right/>
</template>
</a-button>
<a-button shape="circle" @click="refreshPage">
<template #icon>
<icon-refresh/>
</template>
</a-button>
</div>
<!-- 中间搜索框 -->
<div class="header-center">
<a-input-search
placeholder="搜索内容..."
enter-button="搜索"
@search="onSearch"
/>
</div>
<!-- 右侧控制按钮 -->
<div class="header-right">
<a-button shape="circle" @click="minimize">
<template #icon>
<icon-shrink/>
</template>
</a-button>
<a-button shape="circle" @click="maximize">
<template #icon>
<icon-expand/>
</template>
</a-button>
<a-popconfirm content="你确认要关闭当前应用?" @ok="closeWindow">
<a-button shape="circle">
<template #icon>
<icon-close/>
</template>
</a-button>
</a-popconfirm>
</div>
</a-layout-header>
</template>
<script>
import {defineComponent} from 'vue';
import {Message} from '@arco-design/web-vue';
export default defineComponent({
components: {},
methods: {
goBack() {
Message.info("前进按钮");
// 执行前进逻辑
},
goForward() {
Message.info("后退按钮");
// 执行后退逻辑
},
refreshPage() {
Message.info("刷新页面");
// 刷新页面逻辑
window.location.reload();
},
onSearch(value) {
Message.info(`搜索内容: ${value}`);
// 执行搜索逻辑
},
minimize() {
Message.info("最小化窗口");
// 最小化窗口的逻辑,可以通过调用系统接口来实现
this.exitFullScreen()
},
maximize() {
Message.info("最大化窗口");
// 最大化窗口的逻辑
this.enterFullScreen()
},
closeWindow() {
Message.info("将在1秒后关闭窗口");
// 关闭窗口的逻辑,可以通过调用系统接口来实现
setTimeout(function () {
window.open("about:blank", "_self").close()
}, 1000)
},
enterFullScreen() {
let element = document.documentElement;
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) { /* Firefox */
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) { /* IE/Edge */
element.msRequestFullscreen();
}
},
exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) { /* Firefox */
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) { /* Chrome, Safari and Opera */
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) { /* IE/Edge */
document.msExitFullscreen();
}
},
}
});
</script>
<style scoped>
.header {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 64px;
padding: 0;
background: var(--color-bg-3);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
border-bottom: 1px solid var(--color-border-2);
border: none;
}
.header-left {
display: flex;
align-items: center;
padding-left: 20px;
min-width: 200px;
gap: 8px;
}
.header-center {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
max-width: 600px;
margin: 0 20px;
}
.header-right {
display: flex;
align-items: center;
padding-right: 20px;
min-width: 200px;
justify-content: flex-end;
gap: 8px;
}
.header-left :deep(.arco-btn),
.header-right :deep(.arco-btn) {
width: 32px;
height: 32px;
border-radius: 6px;
border: 1px solid var(--color-border-2);
background: var(--color-bg-2);
color: var(--color-text-1);
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
}
.header-left :deep(.arco-btn:hover),
.header-right :deep(.arco-btn:hover) {
background: var(--color-fill-3);
border-color: var(--color-border-3);
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.header-left :deep(.arco-btn:active),
.header-right :deep(.arco-btn:active) {
transform: translateY(0);
background: var(--color-fill-4);
}
/* 特殊样式:关闭按钮 */
.header-right :deep(.arco-btn:last-child) {
background: #ff4757;
border-color: #ff3742;
color: white;
}
.header-right :deep(.arco-btn:last-child:hover) {
background: #ff3742;
border-color: #ff2f3a;
box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
}
/* 搜索框样式 */
.header-center :deep(.arco-input-search) {
width: 100%;
max-width: 400px;
border-radius: 8px;
background: var(--color-bg-1);
border: 1px solid var(--color-border-2);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
transition: all 0.2s ease;
}
.header-center :deep(.arco-input-search:hover) {
border-color: var(--color-border-3);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.header-center :deep(.arco-input-search:focus-within) {
border-color: var(--color-primary-6);
box-shadow: 0 0 0 2px var(--color-primary-1);
}
.header-center :deep(.arco-input-wrapper) {
border-radius: 8px;
background: transparent;
border: none;
}
.header-center :deep(.arco-input) {
background: transparent;
border: none;
color: var(--color-text-1);
font-size: 14px;
}
.header-center :deep(.arco-input::placeholder) {
color: var(--color-text-3);
}
.header-center :deep(.arco-input-search-btn) {
border-radius: 0 8px 8px 0;
background: var(--color-primary-6);
border: none;
color: white;
transition: background-color 0.2s ease;
}
.header-center :deep(.arco-input-search-btn:hover) {
background: var(--color-primary-7);
}
/* 响应式设计 */
@media (max-width: 768px) {
.header-left,
.header-right {
min-width: 120px;
}
.header-center {
margin: 0 10px;
}
.header-center :deep(.arco-input-search) {
max-width: 250px;
}
}
@media (max-width: 480px) {
.header-left,
.header-right {
min-width: 80px;
gap: 4px;
}
.header-left {
padding-left: 10px;
}
.header-right {
padding-right: 10px;
}
.header-center {
margin: 0 5px;
}
.header-center :deep(.arco-input-search) {
max-width: 200px;
}
.header-left :deep(.arco-btn),
.header-right :deep(.arco-btn) {
width: 28px;
height: 28px;
}
}
</style>