From f0b52d7abb37fa45f20c51ee5a6f8ef8b099c0d3 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 06 四月 2023 11:12:24 +0800
Subject: [PATCH] update 优化固定头部页签滚动条被隐藏的问题

---
 src/layout/index.vue |   73 ++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/src/layout/index.vue b/src/layout/index.vue
index da55d54..1c8f97a 100644
--- a/src/layout/index.vue
+++ b/src/layout/index.vue
@@ -1,7 +1,7 @@
 <template>
   <div :class="classObj" class="app-wrapper" :style="{ '--current-color': theme }">
-    <div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
-    <sidebar v-if="!sidebar.hide" class="sidebar-container" />
+    <div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
+    <side-bar v-if="!sidebar.hide" class="sidebar-container" />
     <div :class="{ hasTagsView: needTagsView, sidebarHide: sidebar.hide }" class="main-container">
       <div :class="{ 'fixed-header': fixedHeader }">
         <navbar ref="navbarRef" @setLayout="setLayout" />
@@ -13,61 +13,56 @@
   </div>
 </template>
 
-<script setup>
-import { useWindowSize } from '@vueuse/core'
-import Sidebar from './components/Sidebar/index.vue'
+<script setup lang="ts">
+import SideBar from './components/Sidebar/index.vue'
 import { AppMain, Navbar, Settings, TagsView } from './components'
-import defaultSettings from '@/settings'
-
 import useAppStore from '@/store/modules/app'
 import useSettingsStore from '@/store/modules/settings'
 
 const settingsStore = useSettingsStore()
 const theme = computed(() => settingsStore.theme);
-const sideTheme = computed(() => settingsStore.sideTheme);
 const sidebar = computed(() => useAppStore().sidebar);
 const device = computed(() => useAppStore().device);
 const needTagsView = computed(() => settingsStore.tagsView);
 const fixedHeader = computed(() => settingsStore.fixedHeader);
 
 const classObj = computed(() => ({
-  hideSidebar: !sidebar.value.opened,
-  openSidebar: sidebar.value.opened,
-  withoutAnimation: sidebar.value.withoutAnimation,
-  mobile: device.value === 'mobile'
+    hideSidebar: !sidebar.value.opened,
+    openSidebar: sidebar.value.opened,
+    withoutAnimation: sidebar.value.withoutAnimation,
+    mobile: device.value === 'mobile'
 }))
 
-const { proxy } = getCurrentInstance();
-const { width, height } = useWindowSize();
+const { width } = useWindowSize();
 const WIDTH = 992; // refer to Bootstrap's responsive design
 
 watchEffect(() => {
-  if (device.value === 'mobile' && sidebar.value.opened) {
-    useAppStore().closeSideBar({ withoutAnimation: false })
-  }
-  if (width.value - 1 < WIDTH) {
-    useAppStore().toggleDevice('mobile')
-    useAppStore().closeSideBar({ withoutAnimation: true })
-  } else {
-    useAppStore().toggleDevice('desktop')
-  }
+    if (device.value === 'mobile' && sidebar.value.opened) {
+        useAppStore().closeSideBar({ withoutAnimation: false })
+    }
+    if (width.value - 1 < WIDTH) {
+        useAppStore().toggleDevice('mobile')
+        useAppStore().closeSideBar({ withoutAnimation: true })
+    } else {
+        useAppStore().toggleDevice('desktop')
+    }
 })
 
-const navbarRef = ref(null);
+const navbarRef = ref(Navbar);
+const settingRef = ref(Settings);
 
 onMounted(() => {
-  nextTick(() => {
-    navbarRef.value.initTenantList();
-  })
+    nextTick(() => {
+        navbarRef.value.initTenantList();
+    })
 })
 
-function handleClickOutside() {
-  useAppStore().closeSideBar({ withoutAnimation: false })
+const handleClickOutside = () => {
+    useAppStore().closeSideBar({ withoutAnimation: false })
 }
 
-const settingRef = ref(null);
-function setLayout() {
-  settingRef.value.openSetting();
+const setLayout = () => {
+    settingRef.value.openSetting();
 }
 </script>
 
@@ -80,6 +75,18 @@
   position: relative;
   height: 100%;
   width: 100%;
+
+  .el-scrollbar {
+    height: 100%;
+  }
+
+  :deep(.el-scrollbar__bar).is-vertical {
+    z-index: 10;
+  }
+
+  :deep(.el-scrollbar__wrap) {
+    overflow-x: hidden;
+  }
 
   &.mobile.openSidebar {
     position: fixed;
@@ -117,4 +124,4 @@
 .mobile .fixed-header {
   width: 100%;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3