Skip to content

Commit

Permalink
Fix error when isoinfo contains no os distros
Browse files Browse the repository at this point in the history
Fixes: tuna#399

Signed-off-by: Miao Wang <[email protected]>
  • Loading branch information
shankerwangmiao committed Oct 16, 2023
1 parent 4583973 commit 1abfee0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions _layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ <h4> {% fa_svg fas.fa-paperclip %} 友情链接 </h4>
<h4 class="modal-title" id="isoModalLabel">获取安装镜像</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="row" v-if="availableCategories.length > 0">
<div class="col-md-12">
<ul class="nav nav-tabs">
<li role="presentation" :class="[curCategory === 'os' ? 'active' : '']" @click="switchCategory('os')" v-show="showCategory('os')"><a href="#">操作系统</a></li>
<li role="presentation" :class="[curCategory === 'app' ? 'active' : '']" @click="switchCategory('app')" v-show="showCategory('app')"><a href="#">应用软件</a></li>
<li role="presentation" :class="[curCategory === 'font' ? 'active' : '']" @click="switchCategory('font')" v-show="showCategory('font')"><a href="#">字体</a></li>
<li role="presentation"
v-for="cat in availableCategories"
:class="[curCategory === cat ? 'active' : '']"
@click="switchCategory(cat)"
>
<a href="#">{{ knownCategories[cat] ? knownCategories[cat] : cat }}</a>
</li>
</ul>
</div>
<div class="col-md-3">
Expand Down
14 changes: 9 additions & 5 deletions static/js/index.es6
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,20 @@ var vmIso = new Vue({
data: {
distroList: [],
selected: {},
curCategory: "os"
curCategory: "",
knownCategories: {
os: "操作系统",
app: "应用软件",
font: "字体",
},
availableCategories: []
},
created: function () {
var self = this;
$.getJSON("/static/status/isoinfo.json", function (isoinfo) {
self.distroList = isoinfo;
self.availableCategories = [... new Set(isoinfo.map((x) => x.category))]
self.curCategory = self.availableCategories[0];
self.selected = self.curDistroList[0];
if (window.location.hash.match(/#iso-download(\?.*)?/)) {
$('#isoModal').modal();
Expand All @@ -211,10 +219,6 @@ var vmIso = new Vue({
},
},
methods: {
showCategory(category) {
return this.distroList
.findIndex((x) => x.category === category) > -1;
},
switchDistro (distro) {
this.selected = distro;
},
Expand Down

0 comments on commit 1abfee0

Please sign in to comment.