Skip to content

Commit

Permalink
feat(projects): 增加返回顶部功能
Browse files Browse the repository at this point in the history
  • Loading branch information
yanbowe committed Jun 17, 2022
1 parent d214bb2 commit 894b0f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/layouts/BasicLayout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<global-footer />
</template>
</admin-layout>
<global-back-top />
<setting-drawer />
</template>

Expand All @@ -35,7 +36,15 @@ import AdminLayout from '@soybeanjs/vue-admin-layout';
import { useAppStore, useThemeStore } from '@/store';
import { useBasicLayout } from '@/composables';
import { useBoolean } from '@/hooks';
import { SettingDrawer, GlobalHeader, GlobalTab, GlobalSider, GlobalContent, GlobalFooter } from '../common';
import {
SettingDrawer,
GlobalHeader,
GlobalTab,
GlobalSider,
GlobalContent,
GlobalFooter,
GlobalBackTop
} from '../common';
const app = useAppStore();
const theme = useThemeStore();
Expand Down
13 changes: 13 additions & 0 deletions src/layouts/common/GlobalBackTop/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<n-back-top :show="show" class="z-1000" />
</template>

<script lang="ts" setup>
import { computed } from 'vue';
import { useWindowScroll } from '@vueuse/core';
const { y: scrollY } = useWindowScroll();
const show = computed(() => scrollY.value > 180);
</script>
<style scoped></style>
3 changes: 2 additions & 1 deletion src/layouts/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import GlobalSider from './GlobalSider/index.vue';
import GlobalContent from './GlobalContent/index.vue';
import GlobalFooter from './GlobalFooter/index.vue';
import GlobalLogo from './GlobalLogo/index.vue';
import GlobalBackTop from './GlobalBackTop/index.vue';

export { SettingDrawer, GlobalHeader, GlobalTab, GlobalSider, GlobalContent, GlobalFooter, GlobalLogo };
export { SettingDrawer, GlobalHeader, GlobalTab, GlobalSider, GlobalContent, GlobalFooter, GlobalLogo, GlobalBackTop };

0 comments on commit 894b0f1

Please sign in to comment.