2021-09-17 00:18:50 +08:00
|
|
|
<script setup lang="ts">
|
2021-09-22 22:37:35 +08:00
|
|
|
import { computed } from 'vue'
|
2022-03-25 15:35:56 +08:00
|
|
|
import { inBrowser, useData } 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')
|
|
|
|
|
2022-04-02 12:54:03 +08:00
|
|
|
const { theme, page } = useData()
|
2021-09-22 22:37:35 +08:00
|
|
|
|
|
|
|
const currentLink = computed(() => {
|
2022-04-02 12:54:03 +08:00
|
|
|
if (!inBrowser) {
|
|
|
|
return `/${page.value?.frontmatter?.lang || ''}`
|
|
|
|
}
|
2021-09-22 22:37:35 +08:00
|
|
|
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">
|
2022-04-03 16:39:05 +08:00
|
|
|
<div class="header-container">
|
2021-09-17 00:18:50 +08:00
|
|
|
<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"
|
2022-02-24 15:59:29 +08:00
|
|
|
alt="Element Plus Logo"
|
2021-09-17 00:18:50 +08:00
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="content">
|
2021-10-22 19:10:42 +08:00
|
|
|
<VPNavbarSearch class="search" :options="theme.agolia" multilang />
|
2021-09-17 00:18:50 +08:00
|
|
|
<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;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|