From 96b7401578c8fa2fdd5a064b299af776af38a5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=B2=AB=E8=8A=B1=E7=81=ABzzz=F0=9F=8C=99?= Date: Fri, 11 Oct 2024 10:25:18 +0800 Subject: [PATCH] =?UTF-8?q?[+]=20=E8=B7=AF=E7=94=B1=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=BB=9A=E5=8A=A8=E5=88=B0=E9=A1=B6=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 12 +++++++++--- src/components/sidebar/GuestSidebar.vue | 2 +- src/components/sidebar/MainSidebar.vue | 3 +-- src/router/index.js | 8 +------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/App.vue b/src/App.vue index 395369b..fe0e78a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -21,7 +21,7 @@ - +
@@ -35,7 +35,7 @@
-
+ @@ -74,7 +74,7 @@ import api from '@/api' import { sendWarningMessage } from '@/utils/message' import { logout } from '@/utils/profile' import router from '@router' -import { useRoute } from 'vue-router' +import { useRoute, useRouter } from 'vue-router' // 手机状态下收缩菜单栏 const collapsed = ref(true) @@ -84,6 +84,7 @@ if (document.body.clientWidth >= 1000) { const osThemeRef = useOsTheme() const route = useRoute() +const vRouter = useRouter() const theme = computed(() => (osThemeRef.value === 'dark' ? darkTheme : null)) // let initFinished = false @@ -91,10 +92,15 @@ const loading = ref(true) const tokenValid = ref(false) const showGuestSidebar = ref(false) const showMainSidebar = ref(false) +const contentRef = ref(null) hljs.registerLanguage('ini', ini) hljs.registerLanguage('nginx', nginx) +vRouter.afterEach(() => { + contentRef.value?.scrollTo({ top: 0, behavior: 'smooth' }) +}) + // function getMessage(e) { // const rs = JSON.parse(e.data) // // 通知 diff --git a/src/components/sidebar/GuestSidebar.vue b/src/components/sidebar/GuestSidebar.vue index 7f87db7..95fda11 100644 --- a/src/components/sidebar/GuestSidebar.vue +++ b/src/components/sidebar/GuestSidebar.vue @@ -7,7 +7,7 @@ @expand="collapsed = false" collapse-mode="width" :collapsed-width="64" - :native-scrollbar="true" + :native-scrollbar="false" id="sider" style="height: 100%; bottom: 0" > diff --git a/src/components/sidebar/MainSidebar.vue b/src/components/sidebar/MainSidebar.vue index b6cb5a9..4cf5c5a 100644 --- a/src/components/sidebar/MainSidebar.vue +++ b/src/components/sidebar/MainSidebar.vue @@ -7,8 +7,7 @@ @expand="collapsed = false" collapse-mode="width" :collapsed-width="64" - :native-scrollbar="true" - :inverted="false" + :native-scrollbar="false" id="sider" style="height: 100%; bottom: 0" > diff --git a/src/router/index.js b/src/router/index.js index 4f80c65..34b13d8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -284,13 +284,7 @@ const routes = [ const router = createRouter({ history: createWebHistory(), - routes, - scrollBehavior(to, from, savedPosition) { - return { - top: 0, - behavior: 'smooth' - } - } + routes }) // // 检查本地存储是否存在token,若存在则直接使用