Use invisible "template" element for one if

see https://vuejs.org/v2/guide/conditional.html#Conditional-Groups-with-v-if-on-lt-template-gt
This commit is contained in:
Sosthène Guédon 2020-12-29 16:03:17 +01:00 committed by Chocobozzz
parent b44e850fa1
commit 8abe59db91
3 changed files with 22 additions and 10 deletions

View File

@ -8,14 +8,16 @@
<img class="title-image" v-if="configLoaded && titleImageUrl" v-bind:src="titleImageUrl" v-bind:alt="indexName" />
</h1>
<template v-if="!smallFormat">
<h4>
<div v-translate>A search engine of <a href="https://joinpeertube.org" target="_blank">PeerTube</a> videos and channels</div>
<h4>
<div v-translate>A search engine of <a href="https://joinpeertube.org" target="_blank">PeerTube</a> videos and channels</div>
<div v-translate>Developed by <a href="https://framasoft.org" target="_blank">Framasoft</a></div>
</h4>
<div v-translate>Developed by <a href="https://framasoft.org" target="_blank">Framasoft</a></div>
</h4>
<img class="search-home" v-bind:src="searchImageUrl" alt="">
<img class="search-home" v-bind:src="searchImageUrl" alt="">
</template>
</header>
</div>
</template>
@ -119,7 +121,8 @@
},
props: {
indexName: String
indexName: String,
smallFormat: Boolean,
},
async mounted () {

View File

@ -3,7 +3,7 @@
<img :title="imgTitle" v-on:click="toggleShow()" class="interface-language" src="/img/interface-languages.svg" alt="Change interface language">
<div v-if="showMenu" class="menu">
<a v-for="(lang, locale) in $language.available" :key="locale" :href="'/' + locale + '/'" class="menu-item">
<a v-for="(lang, locale) in $language.available" :key="locale" :href="buildLanguageRoute(locale)" class="menu-item">
{{lang}}
</a>
@ -87,6 +87,15 @@
methods: {
toggleShow () {
this.showMenu = !this.showMenu;
},
buildLanguageRoute(locale: string) {
const paths = this.$route.fullPath.split('/')
if (paths.length > 0 && this.$language.available.hasOwnProperty(paths[0])) {
return "/" + locale + "/" + paths.slice(1).join("/")
} else {
return "/" + locale + this.$route.fullPath
}
}
}
})

View File

@ -1,7 +1,7 @@
<template>
<div>
<my-header v-if="!searchDone" v-bind:indexName="indexName"></my-header>
<router-link v-else class="header-left-logo" to="/" @click.native="simpleFormReset(false)" :title="homeTitleMessage">
<my-header v-bind:indexName="indexName" v-bind:smallFormat="searchDone"></my-header>
<router-link v-if="searchDone" class="header-left-logo" to="/" @click.native="simpleFormReset(false)" :title="homeTitleMessage">
<img src="/img/peertube-logo.svg" alt="">
</router-link>