-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathHeader.vue
More file actions
154 lines (143 loc) · 3.76 KB
/
Header.vue
File metadata and controls
154 lines (143 loc) · 3.76 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
<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"
style="width: 300px;"
/>
</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;
padding: 0 20px;
background: #fff;
}
.header-left,
.header-right {
display: flex;
align-items: center;
}
.header-left button,
.header-right button {
margin-right: 10px;
}
.header-center {
flex-grow: 1;
display: flex;
justify-content: center;
}
.header-center a-input-search {
width: 300px;
}
</style>