From 0a4d896965f06dda5f21283b368f42b6ea72860f Mon Sep 17 00:00:00 2001
From: pany <939630029@qq.com>
Date: Tue, 6 Feb 2024 13:39:56 +0800
Subject: [PATCH] feat: add useDevice
---
src/components/SearchMenu/SearchFooter.vue | 7 ++-----
src/components/SearchMenu/SearchModal.vue | 7 +++----
src/hooks/useDevice.ts | 11 +++++++++++
src/layouts/LeftMode.vue | 6 +++---
src/layouts/LeftTopMode.vue | 1 -
src/layouts/TopMode.vue | 1 -
src/layouts/components/NavigationBar/index.vue | 15 +++++++++------
.../components/Settings/SelectLayoutMode.vue | 1 -
src/layouts/components/Sidebar/index.vue | 8 +++-----
src/layouts/index.vue | 10 ++++------
10 files changed, 35 insertions(+), 32 deletions(-)
create mode 100644 src/hooks/useDevice.ts
diff --git a/src/components/SearchMenu/SearchFooter.vue b/src/components/SearchMenu/SearchFooter.vue
index b30cfd58..3326057c 100644
--- a/src/components/SearchMenu/SearchFooter.vue
+++ b/src/components/SearchMenu/SearchFooter.vue
@@ -1,7 +1,5 @@
diff --git a/src/components/SearchMenu/SearchModal.vue b/src/components/SearchMenu/SearchModal.vue
index e185e388..c877b5a7 100644
--- a/src/components/SearchMenu/SearchModal.vue
+++ b/src/components/SearchMenu/SearchModal.vue
@@ -1,20 +1,19 @@
diff --git a/src/layouts/components/NavigationBar/index.vue b/src/layouts/components/NavigationBar/index.vue
index f38bd9e2..77c16103 100644
--- a/src/layouts/components/NavigationBar/index.vue
+++ b/src/layouts/components/NavigationBar/index.vue
@@ -13,18 +13,16 @@ import Notify from "@/components/Notify/index.vue"
import ThemeSwitch from "@/components/ThemeSwitch/index.vue"
import Screenfull from "@/components/Screenfull/index.vue"
import SearchMenu from "@/components/SearchMenu/index.vue"
-import { DeviceEnum } from "@/constants/app-key"
+import { useDevice } from "@/hooks/useDevice"
+const { isMobile } = useDevice()
const router = useRouter()
const appStore = useAppStore()
-const settingsStore = useSettingsStore()
const userStore = useUserStore()
-
-const { sidebar, device } = storeToRefs(appStore)
+const settingsStore = useSettingsStore()
const { layoutMode, showNotify, showThemeSwitch, showScreenfull, showSearchMenu } = storeToRefs(settingsStore)
const isTop = computed(() => layoutMode.value === "top")
-const isMobile = computed(() => device.value === DeviceEnum.Mobile)
/** 切换侧边栏 */
const toggleSidebar = () => {
@@ -40,7 +38,12 @@ const logout = () => {
-
+