Skip to content

Commit

Permalink
Merge branch 'pr-386'
Browse files Browse the repository at this point in the history
  • Loading branch information
shankerwangmiao committed Aug 21, 2023
2 parents f30297b + 40e2b65 commit c31baf0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h3>暂时无法提供服务</h3>
<div class="row">
<h3 id="mirror-title">{% fa_svg fas.fa-cube %} 镜像列表 </h3>
{% unless page.legacy %}
<input type="search" v-model.trim="filter" id="search" placeholder="搜索" autocomplete="off">
<input type="search" v-model.trim="filter" id="search" ref="search" placeholder="按 / 搜索" autocomplete="off">
{% endunless %}
</div>
<table class="table" v-if="mirrorList.length">
Expand Down
20 changes: 20 additions & 0 deletions static/js/index.es6
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,24 @@ var vmMirList = new Vue({
filter: "",
rawMirrorList: [],
dateTooltip: localStorage.getItem('DateTooltip') !== 'false',
haveSearchBox: false,
},
created () {
this.refreshMirrorList();
},
mounted () {
if(this.$refs.search){
this.haveSearchBox = true;
}
if(this.haveSearchBox){
window.addEventListener("keypress", this.onKeyPress);
}
},
beforeDestroy() {
if(this.haveSearchBox){
window.removeEventListener("keypress", this.onKeyPress);
}
},
updated () {
$('.mirror-item-label').popover();
},
Expand Down Expand Up @@ -76,6 +90,12 @@ var vmMirList = new Vue({
self.rawMirrorList = status_data;
setTimeout(() => {self.refreshMirrorList()}, 10000);
});
},
onKeyPress(event) {
if (event.key === '/' && document.activeElement !== this.$refs.search) {
event.preventDefault();
this.$refs.search.focus();
}
}
}
})
Expand Down

0 comments on commit c31baf0

Please sign in to comment.