2020-09-27 22:27:25 +08:00
|
|
|
<template>
|
|
|
|
<n-layout position="absolute" class="root-layout">
|
|
|
|
<site-header :items="flattenedItems" />
|
|
|
|
<n-layout class="home-layout" style="top: 64px; overflow: hidden;" position="absolute">
|
|
|
|
<router-view />
|
|
|
|
</n-layout>
|
|
|
|
</n-layout>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-11-14 20:38:30 +08:00
|
|
|
import { computed } from 'vue'
|
2020-09-27 22:27:25 +08:00
|
|
|
import SiteHeader from './SiteHeader.vue'
|
|
|
|
import menuOptions from './menu-options'
|
|
|
|
import { loadingBarApiRef } from './routes/router'
|
2020-11-14 20:38:30 +08:00
|
|
|
import {
|
|
|
|
useSiteDisplayMode,
|
|
|
|
useSiteTheme,
|
|
|
|
useSiteLang
|
|
|
|
} from './util-composables'
|
2020-09-27 22:27:25 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Site',
|
2020-11-03 15:10:29 +08:00
|
|
|
components: {
|
|
|
|
SiteHeader
|
|
|
|
},
|
2020-09-27 22:27:25 +08:00
|
|
|
inject: [
|
|
|
|
'SiteProvider',
|
|
|
|
'loadingBar'
|
|
|
|
],
|
|
|
|
provide () {
|
|
|
|
return {
|
|
|
|
Site: this
|
|
|
|
}
|
|
|
|
},
|
2020-09-30 14:56:45 +08:00
|
|
|
setup () {
|
2020-11-14 20:38:30 +08:00
|
|
|
const themeRef = useSiteTheme()
|
|
|
|
const langRef = useSiteLang()
|
|
|
|
const displayModeRef = useSiteDisplayMode()
|
|
|
|
const itemsRef = computed(() => menuOptions({
|
|
|
|
theme: themeRef.value,
|
|
|
|
lang: langRef.value,
|
|
|
|
mode: displayModeRef.value
|
|
|
|
}))
|
|
|
|
const flattenedItemsRef = computed(() => {
|
2020-09-27 22:27:25 +08:00
|
|
|
const flattenedItems = []
|
|
|
|
const traverse = items => {
|
|
|
|
if (items) {
|
|
|
|
items.forEach(item => {
|
|
|
|
if (item.childItems) traverse(item.childItems)
|
|
|
|
else flattenedItems.push(item)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-11-14 20:38:30 +08:00
|
|
|
traverse(itemsRef.value)
|
2020-09-27 22:27:25 +08:00
|
|
|
return flattenedItems
|
2020-11-14 20:38:30 +08:00
|
|
|
})
|
|
|
|
return {
|
|
|
|
items: itemsRef,
|
|
|
|
flattenedItems: flattenedItemsRef
|
2020-09-27 22:27:25 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
this.loadingBar.finish()
|
|
|
|
loadingBarApiRef.value = this.loadingBar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-11-01 19:35:00 +08:00
|
|
|
<style scoped>
|
2020-09-27 22:27:25 +08:00
|
|
|
.demo {
|
|
|
|
z-index: auto;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
min-width: 1080px;
|
|
|
|
}
|
|
|
|
body {
|
|
|
|
-webkit-text-size-adjust: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.root-layout.n-layout.n-light-theme {
|
|
|
|
background-color: #FFF;
|
|
|
|
}
|
|
|
|
.home-layout.n-layout.n-light-theme {
|
|
|
|
background-color: #FFF;
|
|
|
|
}
|
|
|
|
</style>
|