2021-09-17 00:18:50 +08:00
|
|
|
<script setup lang="ts">
|
2021-09-22 22:37:35 +08:00
|
|
|
import { computed } from 'vue'
|
2021-09-23 14:16:37 +08:00
|
|
|
import { useData, inBrowser } from 'vitepress'
|
2021-09-17 00:18:50 +08:00
|
|
|
|
2021-09-23 14:16:37 +08:00
|
|
|
import { useFeatureFlag } from '../composables/feature-flag'
|
2021-09-17 00:18:50 +08:00
|
|
|
import VPNavbarSearch from './navbar/vp-search.vue'
|
|
|
|
import VPNavbarMenu from './navbar/vp-menu.vue'
|
|
|
|
import VPNavbarThemeToggler from './navbar/vp-theme-toggler.vue'
|
|
|
|
import VPNavbarTranslation from './navbar/vp-translation.vue'
|
|
|
|
import VPNavbarSocialLinks from './navbar/vp-social-links.vue'
|
|
|
|
import VPNavbarHamburger from './navbar/vp-hamburger.vue'
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
fullScreen: boolean
|
|
|
|
}>()
|
|
|
|
|
|
|
|
defineEmits(['toggle'])
|
|
|
|
const themeEnabled = useFeatureFlag('theme')
|
|
|
|
|
|
|
|
const { theme } = useData()
|
2021-09-22 22:37:35 +08:00
|
|
|
|
|
|
|
const currentLink = computed(() => {
|
|
|
|
if (!inBrowser) return '/'
|
|
|
|
const existLangIndex = theme.value.langs.findIndex((lang) =>
|
|
|
|
window?.location?.pathname.startsWith(`/${lang}`)
|
|
|
|
)
|
|
|
|
|
|
|
|
return existLangIndex === -1 ? '/' : `/${theme.value.langs[existLangIndex]}/`
|
|
|
|
})
|
2021-09-17 00:18:50 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="navbar-wrapper">
|
|
|
|
<div class="container">
|
|
|
|
<div class="logo-container">
|
2021-09-22 22:37:35 +08:00
|
|
|
<a :href="currentLink">
|
2021-09-17 00:18:50 +08:00
|
|
|
<img
|
|
|
|
class="logo"
|
|
|
|
src="/images/element-plus-logo.svg"
|
|
|
|
alt="Elemenet Plus Logo"
|
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<VPNavbarSearch class="search" :options="theme.agolia" />
|
|
|
|
<VPNavbarMenu class="menu" />
|
|
|
|
<VPNavbarThemeToggler v-if="themeEnabled" class="theme-toggler" />
|
|
|
|
<VPNavbarTranslation class="translation" />
|
|
|
|
<VPNavbarSocialLinks class="social-links" />
|
|
|
|
<VPNavbarHamburger
|
|
|
|
:active="fullScreen"
|
|
|
|
class="hamburger"
|
|
|
|
@click="$emit('toggle')"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.logo-container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
height: var(--header-height);
|
|
|
|
> a {
|
|
|
|
height: 28px;
|
|
|
|
width: 128px;
|
|
|
|
}
|
|
|
|
.logo {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|