naive-ui/demo/Site.vue

45 lines
1.0 KiB
Vue
Raw Normal View History

2020-09-27 22:27:25 +08:00
<template>
2021-04-06 01:31:09 +08:00
<n-layout :position="isXs ? undefined : 'absolute'" class="root-layout">
<site-header />
2020-12-12 13:51:22 +08:00
<n-layout
class="home-layout"
2021-04-06 01:31:09 +08:00
:style="isXs ? undefined : 'top: 64px; overflow: hidden'"
:position="isXs ? undefined : 'absolute'"
2020-12-12 13:51:22 +08:00
>
2020-09-27 22:27:25 +08:00
<router-view />
</n-layout>
</n-layout>
</template>
<script>
2021-04-18 20:01:19 +08:00
import { onMounted } from 'vue'
import { useLoadingBar } from 'naive-ui'
2020-09-27 22:27:25 +08:00
import SiteHeader from './SiteHeader.vue'
import { loadingBarApiRef } from './routes/router'
2021-04-06 01:31:09 +08:00
import { useIsXs } from './utils/composables'
2020-09-27 22:27:25 +08:00
export default {
name: 'Site',
2020-11-03 15:10:29 +08:00
components: {
SiteHeader
},
2021-01-13 12:01:02 +08:00
setup () {
2021-04-18 20:01:19 +08:00
const loadingBar = useLoadingBar()
2021-04-06 01:31:09 +08:00
const isXsRef = useIsXs()
2021-01-13 12:01:02 +08:00
onMounted(() => {
loadingBarApiRef.value = loadingBar
loadingBar.finish()
const memoedHash = window.location.hash
if (memoedHash) {
// scroll to hashed element
window.location.hash = ''
window.location.hash = memoedHash
}
2021-01-13 12:01:02 +08:00
})
return {
2021-04-06 01:31:09 +08:00
isXs: isXsRef
}
2020-09-27 22:27:25 +08:00
}
}
</script>